代码提交

This commit is contained in:
jia 2023-10-20 16:31:24 +08:00
commit 5d9a08e5e8
37 changed files with 3675 additions and 953 deletions

197
App.vue
View File

@ -1,105 +1,108 @@
<script>
//#ifdef APP-PLUS
const jpushModule = uni.requireNativePlugin("JG-JPush");
// #endif
import { loginShopAccount, userInfo } from "@/api/oaUser.js"
export default {
onLaunch: async function(info) {
// let noticeArr = []
// jpushModule.addNotificationListener(res => {
// if (!noticeArr.includes(res.messageID)) {
// const audioContext = uni.createInnerAudioContext()
// //
// audioContext.src = `/static/audio/order.mp3`;
// // console.log(res.messageID)
// audioContext.play()
// noticeArr.push(res.messageID)
// console.log("app")
// }
// })
//#ifdef APP-PLUS
const jpushModule = uni.requireNativePlugin("JG-JPush");
// #endif
import {
loginShopAccount,
userInfo
} from "@/api/oaUser.js"
export default {
onLaunch: async function(info) {
// let noticeArr = []
// jpushModule.addNotificationListener(res => {
// if (!noticeArr.includes(res.messageID)) {
// const audioContext = uni.createInnerAudioContext()
// //
// audioContext.src = `/static/audio/order.mp3`;
// // console.log(res.messageID)
// audioContext.play()
// noticeArr.push(res.messageID)
// console.log("app")
// }
// })
// uni.showModal({
// content: info.referrerInfo.extraData
// })
// uni.showModal({
// content: info.referrerInfo.extraData
// })
if (info.referrerInfo?.extraData?.uniMP) {
//宿App
uni.onHostEventReceive((event, data) => {
if(event=='getLocation') uni.$emit('uniMP_getLocation', data);
});
uni.setStorageSync('uniMP', info.referrerInfo?.extraData?.uniMP);
uni.setStorageSync('APP_token', info.referrerInfo?.extraData?.token);
try {
let res = await loginShopAccount({
shop_token: info.referrerInfo?.extraData?.token
});
this.$store.commit('SET_USERINFO', {
user: data,
token: res.data.token
})
this.$store.dispatch('initConfig');
let {
data
} = await userInfo();
this.$store.commit('setUserInfo', data);
this.$isResolve()
// uni.$emit('home_initUserInfo', data);
return;
} catch (e) {
this.$isResolve()
console.log(e);
}
}
console.log('App Launch')
this.$store.dispatch('initConfig');
this.$isResolve()
try {
if (!this.$store.state.app.token) uni.reLaunch({
url: '/pages/oaLogin/oaLogin',
success() {
// #ifdef APP-PLUS
plus.navigator.closeSplashscreen(); //
// #endif
}
})
else {
// #ifdef APP-PLUS
plus.navigator.closeSplashscreen(); //
// #endif
}
} catch (e) {
// #ifdef APP-PLUS
plus.navigator.closeSplashscreen(); //
// #endif
}
},
onShow: function() {
const audioContext = uni.createInnerAudioContext()
//
audioContext.src = '/static/mp3/order.mp3'
//
//#ifdef APP-PLUS
jpushModule.addNotificationListener(res => {
if (res.notificationEventType == 'notificationOpened') return
audioContext.play()
uni.vibrateLong();
console.log("app的监听")
})
// #endif
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
}
}
if (info.referrerInfo?.extraData?.uniMP) {
//宿App
uni.onHostEventReceive((event, data) => {
if (event == 'getLocation') uni.$emit('uniMP_getLocation', data);
});
uni.setStorageSync('uniMP', info.referrerInfo?.extraData?.uniMP);
uni.setStorageSync('APP_token', info.referrerInfo?.extraData?.token);
try {
let res = await loginShopAccount({
shop_token: info.referrerInfo?.extraData?.token
});
this.$store.commit('SET_USERINFO', {
user: data,
token: res.data.token
})
this.$store.dispatch('initConfig');
let {
data
} = await userInfo();
this.$store.commit('setUserInfo', data);
this.$isResolve()
// uni.$emit('home_initUserInfo', data);
return;
} catch (e) {
this.$isResolve()
console.log(e);
}
}
console.log('App Launch')
this.$store.dispatch('initConfig');
this.$isResolve()
try {
if (!this.$store.state.app.token) uni.reLaunch({
url: '/pages/oaLogin/oaLogin',
success() {
// #ifdef APP-PLUS
plus.navigator.closeSplashscreen(); //
// #endif
}
})
else {
// #ifdef APP-PLUS
plus.navigator.closeSplashscreen(); //
// #endif
}
} catch (e) {
// #ifdef APP-PLUS
plus.navigator.closeSplashscreen(); //
// #endif
}
},
onShow: function() {
const audioContext = uni.createInnerAudioContext()
//
audioContext.src = '/static/mp3/order.mp3'
//
//#ifdef APP-PLUS
jpushModule.addNotificationListener(res => {
if (res.notificationEventType == 'notificationOpened') return
audioContext.play()
uni.vibrateLong();
console.log("app的监听")
})
// #endif
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
}
}
</script>
<style>
/*每个页面公共css */
@import "static/css/base.css";
@import "static/css/style.scss";
/*每个页面公共css */
@import "static/css/base.css";
@import "static/css/style.scss";
view {
box-sizing: border-box;
}
view {
box-sizing: border-box;
}
</style>

14
api/bussness.js Normal file
View File

@ -0,0 +1,14 @@
import oahttp from "@/utils/aa.js";
/**
* 绑定scoket
*/
export const bindScoket = (data) => oahttp.post('/common/im/doBindUid', data)
// 发送消息
export const sendMsgApi = (data) => oahttp.post('/common/im/sendTextMsg', data)
// 发送文件
export const sendFileApi = (data) => oahttp.post('/common/im/sendFileMsg', data)
// 消息列表
export const getMsgListApi = (data) => oahttp.post('/common/im/msgList', data)
// 片区经理id
export const getAreaManagerApi = (data) => oahttp.post('/common/im/getAreaManager', data)

View File

@ -66,3 +66,12 @@ export const postsms = (data) => oahttp.post('/company/postsms', data)
*/
export const sss = (data) => oahttp.post('/company/postsms', data)
/**
* 查询甲方公司信息
*/
export const getPartyACompany = (data) => oahttp.get('/company/getPartyACompany', data)
/**
* 查询押金凭证记录
*/
export const getDepositRechargeTransferVoucherList = (data) => oahttp.get('/company/getDepositRechargeTransferVoucherList', data)

View File

@ -1,45 +1,50 @@
import {
HTTP_REQUEST_URL_THREE,
HEADER,
TOKENNAME,
HTTP_REQUEST_URL_THREE,
HEADER,
TOKENNAME,
} from '@/config/app';
import { Toast } from '../libs/uniApi';
import {
Toast
} from '../libs/uniApi';
// import { checkLogin } from '../libs/login';
import store from '../store';
function toLogin() {
store.commit("LOGOUT");
uni.showToast({
title: '请登录',
icon: 'none',
duration: 1000
});
store.commit("LOGOUT");
uni.showToast({
title: '请登录',
icon: 'none',
duration: 1000
});
}
function upLoad(url, data) {
let Url = HTTP_REQUEST_URL_THREE,
header = {}
if (store.state.app.token) header[TOKENNAME] = store.state.app.token;
return new Promise((reslove, reject) => {
uni.uploadFile({
url: Url + '/api' + url,
filePath: data.filePath,
name: data.name,
success: (uploadFileRes) => {
uploadFileRes.data = JSON.parse(uploadFileRes.data)
if(uploadFileRes.data.code==1) reslove(uploadFileRes.data)
else Toast('网络错误')
},
fail: (err) => {
Toast('网络错误')
}
})
});
let Url = HTTP_REQUEST_URL_THREE,
header = {}
if (store.state.app.token) header[TOKENNAME] = store.state.app.token;
return new Promise((reslove, reject) => {
uni.uploadFile({
url: Url + '/api' + url,
filePath: data.filePath,
name: data.name,
success: (uploadFileRes) => {
uploadFileRes.data = JSON.parse(uploadFileRes.data)
if (uploadFileRes.data.code == 1) reslove(uploadFileRes.data)
else Toast('网络错误')
},
fail: (err) => {
Toast('网络错误')
}
})
});
}
export const upLoadImage = (data)=>{
return upLoad('/upload/image', data)
export const upLoadImage = (data) => {
return upLoad('/upload/image', data)
}
export const VIDEO_URL = HTTP_REQUEST_URL_THREE + '/api/upload/video'
export const FILE_URL = HTTP_REQUEST_URL_THREE + '/api/upload/file'
export const FILE_URL = HTTP_REQUEST_URL_THREE + '/api/upload/file'
// im文件上传
// export const VIDEO_URL_IM = HTTP_REQUEST_URL_THREE + '/api/upload/video'
export const FILE_URL_IM = HTTP_REQUEST_URL_THREE + '/common/im/sendFileMsg'

28
api/index.js Normal file
View File

@ -0,0 +1,28 @@
// let Token = localStorage.getItem("token")
let Token = uni.getStorageSync("token")
let request = (METHOD, URL, DATA) => {
return new Promise((reslove, reject) => {
uni.request({
url: 'https://ceshi-im.lihaink.cn/' + URL,
method: METHOD,
data: {
...DATA
},
header: {
'content-type': 'application/json',
"Authorization": Token || ""
},
success: function(res) {
reslove(res)
},
fail: function(err) {
reject(err)
},
});
})
}
export default request;

View File

@ -1,5 +1,5 @@
import oahttp from "@/utils/oahttp.js";
import oahttp2 from "@/utils/logistics.js";
// http://logistics.lihaink.cn/api/getCarHistory
/**
* 车辆列表
@ -14,6 +14,10 @@ export const upVehicleApi = (data) => oahttp.post('/vehicle/rentApply', data)
export const applycarApi = (data) => oahttp.post('/vehicle/rentApply', data)
// 显示轨迹
export const locusApi = (data) => oahttp.post('/vehicle/vehicleTrack', data)
// 获取可购买车辆列表
export const canBuyCarListApi = (data) => oahttp.get('/vehicle/getFreeCars', data)
// 购买车辆
export const buyCarApi = (data) => oahttp.post('/vehicle/buyCars', data)
// 当前车辆位置信息
// export const locusApi = (data) => oahttp.post('/vehicle/vehicleTrack', data)
// api / getCarLocal

View File

@ -44,9 +44,19 @@ export const taskOtherTaskCommit = (data) => oahttp.post('/task/commit_other_tas
/**
* 任务:服务任务详情
*/
export const serviceTaskDetails = (data) => oahttp.get('/task/service_task_detail', data)
export const townTaskDetails = (data) => oahttp.get('/task/service_task_detail', data)
/**
* 任务:提交督促小组服务团队学习任务
*/
export const serviceTask4Commit = (data) => oahttp.post('/task/commit_town_task_type4', data)
/**
* 任务:数字农贸宣传加工业务建设和招商任务详情
*/
export const marketTask10Detail = (data) => oahttp.post('/task/town_task_type_marketing_director_10_detail', data)
/**
* 任务:数字农贸宣传加工业务建设和招商任务提交
*/
export const marketTask10Commit = (data) => oahttp.post('/task/commit_town_task_type_marketing_director_10', data)

View File

@ -0,0 +1,696 @@
<template>
<view style="background-color: #F6F7FD;">
<!-- <view class="storeName" style="padding-top:var(--status-bar-height) ;">
<u--image src="/static/right.png" width="50rpx" height="50rpx" @click='backFn'></u--image>
<view class="" @click="timeFn">
{{timeFn()}}
</view>
<view class="">
</view>
</view> -->
<!-- 消息 -->
<view class="content" @click="showPlus=false" id="content">
<view class="">
<u-loadmore :status="status" />
</view>
<!-- -->
<view class="task-li" v-for="item,index in list" :key="index">
<!-- 对方消息 -->
<view v-if="formId==item.fromUser.id">
<view class="task-li-r">
<view class="" style="margin-right: 10rpx;">
<u--image :showLoading="true" :src="a" shape="circle" width="40px" height="40px"></u--image>
</view>
<view @longpress="copyText(item.content)" class="task-li-content" v-if="item.type=='text'"
style="margin-right: 10rpx;">
{{item.content}}
</view>
<!-- 图片 -->
<view class="task-li-content" v-if="item.type=='image'" style="margin-right: 10rpx;"
@tap="showOverLayFn(item.content,item.type)">
<image :src="item.content" style="width:200rpx" mode="widthFix"></image>
</view>
<!-- 视频 -->
<view class="task-li-content" v-if="item.type=='video'"
style="margin-right: 10rpx;position: relative;"
@tap="showOverLayFn(item.content,item.type)">
<u--image :showLoading="true" :src="a" width="100px" height="80px"></u--image>
<view class="yl-text">
点击预览
</view>
<!-- <video :src="item.content" @loadedmetadata="onVideoLoaded" controls id="vi1"
style="width: 400rpx; height: 100px;"></video> -->
<!-- <image src="item.content" style="width:200rpx" mode="widthFix"></image> -->
<!-- <canvas canvas-id="videoCanvas1" style="width: 100px; height: 100px;"></canvas> -->
</view>
</view>
<view class="send-time">
{{item.sendTime}}
</view>
</view>
<!-- 我的消息 -->
<view class="task-li-l" v-if="true">
<!-- 文字 -->
<view class="task-li-content" @longpress="copyText(item.content)" v-if="item.type=='text'"
style="margin-right: 10rpx;">
{{item.content}}
</view>
<!-- 图片 -->
<view class="task-li-content" v-if="item.type=='image'" style="margin-right: 10rpx;"
@tap="showOverLayFn(item.content,item.type)">
<image :src="item.content" style="width:200rpx" mode="widthFix"></image>
</view>
<!-- 视频 -->
<view class="task-li-content" v-if="item.type=='video'"
style="margin-right: 10rpx;position: relative;" @tap="showOverLayFn(item.content,item.type)">
<u--image :showLoading="true" src="/static/YL1.png" width="100px" height="80px"></u--image>
<view class="yl-text">
点击预览
</view>
</view>
<view class="">
<u--image :showLoading="true" :src="a" shape="circle" width="40px" height="40px"></u--image>
</view>
</view>
</view>
<!-- 本地 -->
<view v-if="local">
<view class="localTask" v-if="localType=='video'">
<view class="task-li-content" style="margin-right: 10rpx;">
<video :src="local" controls id="vi1" style="width: 400rpx; height: 100px;"></video>
<u-line-progress :percentage="progress" activeColor="#19BE6B"></u-line-progress>
<!-- <canvas canvas-id="videoCanvas1" style="width: 100px; height: 100px;"></canvas> -->
</view>
<view class="" style="margin-right: 10rpx;">
<u--image :showLoading="true" shape="circle" :src="a" width="40px" height="40px"></u--image>
</view>
</view>
<view class="localTask" v-if="localType=='image'">
<view class="task-li-content" style="margin-right: 10rpx;">
<!-- <image :src="local" controls id="vi1" style="width: 400rpx; height: 100px;"></image> -->
<image :src="local" style="width:200rpx" mode="widthFix"></image>
<u-line-progress :percentage="progress" activeColor="#19BE6B"></u-line-progress>
</view>
<view class="" style="margin-right: 10rpx;">
<u--image :showLoading="true" shape="circle" :src="a" width="40px" height="40px"></u--image>
</view>
</view>
</view>
<view style="height: 50px;background-color: #F6F7FD;">
</view>
</view>
<!-- 底部 -->
<view class="bottom">
<!-- -->
<view class="send-col">
<input type="text" class="send-ipt" @click="scrollFn(300)" v-model="value" placeholder="请输入聊天内容"
placeholder-style="color:#DDD;" :cursor-spacing="6">
<u--image :showLoading="true" src="/static/img/bussness/Plus.png" width="32px" height="32px"
@click="showPlusFn"></u--image>
<button class="send" @tap="sendFn">发送</button>
</view>
<!-- 发送照片 -->
<view class="plus" v-if="showPlus">
<view class="plus_li">
<u--image :showLoading="true" src="/static/img/bussness/XC.png" width="120rpx" height="120rpx"
@click="choseImgFn"></u--image>
<text>图片</text>
</view>
<view class="plus_li">
<u--image :showLoading="true" src="/static/img/bussness/SP.png" width="120rpx" height="120rpx"
@click="choseVideoFn"></u--image>
<text>视频</text>
</view>
<!-- asdas -->
</view>
</view>
<!-- 遮罩图 -->
<u-overlay :show="show" @click="show = false">
<view class="warp">
<view class="rect" @tap.stop @longpress="saveImage(overLaySrc)" v-if="overLayType=='image'">
<image :showLoading="true" style="width: 80vw;" mode="widthFix" :src="overLaySrc"></image>
</view>
<view class="rect" @tap.stop v-if="overLayType=='video'">
<video :src="overLaySrc"></video>
</view>
</view>
</u-overlay>
</view>
</template>
<script>
// import request from "@/api/index.js"
import {
bindScoket,
sendMsgApi
} from "@/api/bussness.js"
export default {
data() {
return {
a: "https://img1.baidu.com/it/u=716638254,3920932970&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1695920400&t=aeec3d0e86c23759d5f82b3757e9b442",
list: [],
value: "",
showPlus: false,
num: 0,
flags: true,
scollNum: 999999999999,
client_id: "",
formId: "",
name: "",
status: "lodemore",
page: 1,
limit: 10,
formUser: "",
show: false,
overLaySrc: "",
overLayType: "",
canvasContext: null,
timer: "",
local: "",
localType: "",
progress: "",
showNotice: false
}
},
methods: {
timeFn(time) {
// 1695722299000
const currentDate = new Date(); //
const targetDate = new Date(1695722299000);
if (this.isSameDay(currentDate, targetDate)) {
const hours = targetDate.getHours(); //
const minutes = targetDate.getMinutes(); //
return hours + ':' + minutes;
} else if (this.isYesterday(currentDate, targetDate)) {
return '昨天';
}
const month = targetDate.getMonth() + 1; // 01
const day = targetDate.getDate(); //
return month + '月' + day + '日';
},
isSameDay(date1, date2) {
return (
date1.getFullYear() === date2.getFullYear() &&
date1.getMonth() === date2.getMonth() &&
date1.getDate() === date2.getDate()
);
},
isYesterday(currentDate, targetDate) {
const yesterday = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() - 1);
return this.isSameDay(yesterday, targetDate);
},
saveImage(src) {
uni.saveImageToPhotosAlbum({
filePath: src,
success() {
uni.showToast({
title: '保存成功',
icon: 'none'
});
},
fail() {
uni.showToast({
title: '保存失败',
icon: 'none'
});
}
});
},
copyText(value) {
const text = value;
uni.setClipboardData({
data: text,
success() {
uni.showToast({
title: '复制成功',
icon: 'none'
});
}
});
},
backFn() {
uni.navigateBack()
},
showOverLayFn(src, type) {
this.show = true
this.overLaySrc = src
this.overLayType = type
},
getListFn() {
request("POST", "enterprise/im/getMessageList", {
limit: this.limit,
page: this.page,
toContactId: this.formId,
}).then(res => {
if (res.data.data.length == 0) {
this.status = "nomore"
return
}
this.list.unshift(...res.data.data)
this.status = "loadmore"
}).catch(err => {
console.log(err, "获取消息列表失败")
})
},
scrollFn(time) {
this.scollNum += 500
setTimeout(() => {
uni.pageScrollTo({
scrollTop: this.scollNum,
});
}, time ? time : 100)
},
generateRandId() {
var d = new Date().getTime();
var uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c == "x" ? r : r & 0x3 | 0x8).toString(16);
});
return uuid;
},
sendFn() {
if (!this.value) return
this.num++
this.flags = !this.flags
request("POST", "enterprise/im/sendMessage", {
content: this.value,
extends: null,
fileName: "",
fileSize: 0,
file_cate: 0,
file_id: 0,
fromUser: {
...this.fromUser
},
from_user: this.fromUser.id,
id: this.generateRandId(),
is_group: 0,
is_read: 0,
sendTime: Date.now(),
status: "going",
toContactId: this.formId,
type: "text",
}).then(res => {
console.log("发送消息成功")
// this.list.push(res.data.data)
}).catch(err => {
console.log(err, "发送消息失败")
})
this.value = ""
this.scrollFn(100)
},
login() {
return
// request("POST", "common/Pub/login", {
// account: 13800000006,
// password: "123456",
// rememberMe: false,
// }).then(res => {
// uni.setStorageSync("token", (res.data.data.authToken))
// uni.setStorageSync("userinfo", JSON.stringify(res.data.data.userInfo))
// })
},
showPlusFn() {
this.showPlus = !this.showPlus
this.scrollFn(200)
},
choseImgFn() {
this.login()
let time = Date.now()
let that = this
// https://im.raingad.com/common/upload/uploadFile
uni.chooseImage({
count: 1, //
success: res => {
const tempFilePath = res.tempFilePaths[0];
const file = res.tempFiles[0]
console.log(file)
that.local = tempFilePath
that.localType = 'image'
that.showPlus = false
that.scrollFn(200)
const uploadTask = uni.uploadFile({
url: "https://ceshi-im.lihaink.cn/common/upload/uploadFile",
filePath: tempFilePath, //
name: 'file',
header: {
"Authorization": uni.getStorageSync("token")
},
formData: {
message: JSON.stringify({
"id": this.generateRandId(),
"sendTime": Date.now(),
"status": "going",
"type": "image",
// "content": "blob:https://im.raingad.com/e2ffd725-a9e7-4a01-b7da-83fd64af97a4",
"content": `blob:${tempFilePath}`,
"is_read": 0,
"is_group": 0,
"file_id": 0,
"file_cate": 0,
"fileName": file.name,
"fileSize": file.size,
"extends": null,
"fromUser": {
...this.fromUser
},
from_user: this.fromUser.id,
toContactId: this.formId,
})
}, //
success: function(uploadRes) {
that.local = ""
that.list.push(JSON.parse(uploadRes.data).data)
//
},
fail: function(error) {
console.log('上传失败', error);
//
}
});
uploadTask.onProgressUpdate((res) => {
this.progress = res.progress
console.log('上传进度', res.progress);
});
},
fail: err => {
console.log(err, "没有选择图片");
}
});
},
choseVideoFn() {
let that = this
uni.chooseVideo({
sourceType: ['album', 'camera'], //
maxDuration: 600, //
camera: 'back', //
success: res => {
const tempFilePath = res.tempFilePath;
that.local = res.tempFilePath
that.localType = 'video'
that.showPlus = false
that.scrollFn(200)
const uploadTask = uni.uploadFile({
url: "https://ceshi-im.lihaink.cn/common/upload/uploadFile",
filePath: tempFilePath, //
name: 'file',
header: {
"Authorization": uni.getStorageSync("token")
},
formData: {
message: JSON.stringify({
"id": this.generateRandId(),
"sendTime": Date.now(),
"status": "going",
"type": "image",
// "content": "blob:https://im.raingad.com/e2ffd725-a9e7-4a01-b7da-83fd64af97a4",
"content": `blob:${tempFilePath}`,
"is_read": 0,
"is_group": 0,
"file_id": 0,
"file_cate": 0,
"fileName": "20210719150601_4401e.jpg",
"fileSize": 72046,
"extends": null,
"fromUser": {
...this.fromUser
},
from_user: this.fromUser.id,
toContactId: this.formId,
})
}, //
success: function(uploadRes) {
that.local = ""
that.list.push(JSON.parse(uploadRes.data).data)
//
},
fail: function(error) {
uni.showToast({
title: '视频不能超过60s',
duration: 2000,
icon: 'none'
});
that.local = false
}
});
uploadTask.onProgressUpdate((res) => {
this.progress = res.progress
console.log('上传进度', res.progress);
});
},
fail: err => {
uni.showToast({
title: '视频不能超过60s',
duration: 2000,
icon: 'none'
});
}
});
},
},
onShow() {
return
let that = this
this.scrollFn(500)
this.timer = setInterval(() => {
request("POST", "enterprise/im/getMessageList", {
limit: 1,
page: 1,
toContactId: this.formId,
}).then(res => {
if (res.data.data[0]?.id != this.list[this.list.length - 1]?.id) {
this.list.push(res.data.data[0])
if (res.data.data[0].type == 'video' || res.data.data[0].type == 'image') {
this.local = ""
}
// console.log(res.data.data)
}
// this.list.unshift(...res.data.data)
// this.status = "loadmore"
})
}, 3000)
},
async onPullDownRefresh() {
this.status = "loading"
this.page++
await this.getListFn()
// console.log("")
uni.stopPullDownRefresh();
},
created() {
let obj = {
"user_id": 2,
"account": "13800000002",
"realname": "熊大",
"avatar": "https://ceshi-im.lihaink.cn/avatar/熊大/120/2",
"email": "xiongda@kaishanlaw.com",
"sex": 2,
"role": 0,
"motto": null,
"remark": "",
"name_py": "xiongda",
"setting": null,
"is_auth": 0,
"last_login_time": 1695720745,
"last_login_ip": "221.182.82.214",
"delete_time": 0,
"status": 1,
"qrUrl": "https://ceshi-im.lihaink.cn/scan/u/oVQ5OmjEa7zD",
"displayName": "熊大",
"id": 2
}
this.fromUser = obj
console.log(this.fromUser)
return
this.getListFn()
},
onUnload() {
clearInterval(this.timer)
},
}
</script>
<style lang="scss">
.yl-text {
position: absolute;
color: black;
top: 60%;
left: 50%;
transform: translateX(-50%);
font-size: 24rpx;
}
// .storeName {
// position: fixed;
// text-align: center;
// background-color: white;
// font-weight: bold;
// height: 80rpx;
// width: 100vw;
// z-index: 9;
// display: flex;
// align-items: center;
// justify-content: space-between;
// }
.topflag {
height: 80rpx;
background-color: #F6F7FD;
}
.content {
padding: 0 20rpx;
min-height: 100vh;
// height: 89vh;
background-color: #F6F7FD;
overflow: auto;
padding-top: 10rpx;
// padding-bottom: 50px;
.task-li {
margin-bottom: 20rpx;
}
.task-li-l {
display: flex;
justify-content: flex-end;
}
.task-li-r {
display: flex;
}
.task-li-content {
background-color: white;
padding: 20rpx;
border-radius: 20rpx;
color: white;
word-break: break-all;
max-width: 60vw;
}
}
.bottom {
background-color: white;
// height: 8vh;
// padding: 20rpx;
padding: 20rpx 0;
position: fixed;
box-sizing: border-box;
// bottom: 400px;
padding-bottom: 500px;
/* #ifdef APP-PLUS */
bottom: 0px;
padding-bottom: 10px;
/* #endif */
.send-col {
display: flex;
align-items: center;
justify-content: space-around;
.send-ipt {
width: 70vw;
background-color: #F5F5F5;
height: 60rpx;
border-radius: 20rpx;
padding-left: 20rpx;
}
}
.send {
background-color: #2573fb;
color: #fff;
height: 64rpx;
margin-left: 20rpx;
border-radius: 6rpx;
padding: 0;
width: 120rpx;
line-height: 62rpx;
&:active {
background-color: #1573fb;
}
}
.plus {
display: flex;
background-color: white;
padding: 20rpx;
.plus_li {
display: flex;
flex-direction: column;
align-items: center;
margin-right: 20rpx;
flex-wrap: wrap;
}
}
}
.warp {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
.rect {}
.localTask {
display: flex;
justify-content: flex-end;
}
</style>

View File

@ -318,7 +318,7 @@
</view>
</view>
</template>
<script>
@ -427,7 +427,6 @@
brigade.forEach((item) => {
this.brigade += item.brigade_name ?? ''
})
uni.$emit('companyInfo', this.company); //
this.user = res.data.user;
this.contract = res.data.contract;
this.skeleton = false;

View File

@ -1,7 +1,7 @@
<template>
<view class="c_card">
<view class="f_card">
<view class="item" @click="navTo('/subpkg/topUp/topUp')">
<view class="item" @click="navTo('/subpkg/topUpDeposit/topUpDeposit')">
<view>押金()</view>
<view class="price" v-if="company.deposit">{{cCount(+company.deposit)}}</view>
<view class="price" v-else>0.00</view>
@ -28,9 +28,7 @@
</view>
</view>
<view class="f_list">
<view class="item" v-for="(item, index) in list" :key="index">
<view class="top">
账单日期: {{current?item.month:item.create_time}}
</view>
@ -61,10 +59,6 @@
</view>
</view>
</view>
<u-loadmore :status="loadConfig.status" :loading-text="loadConfig.loadingText"
:loadmore-text="loadConfig.loadmoreText" :nomore-text="loadConfig.nomoreText" />
</view>
@ -74,7 +68,8 @@
<script>
import {
accountMonthList,
accountDateList
accountDateList,
companyView
} from "@/api/company.js"
import {
Toast
@ -101,12 +96,14 @@
};
},
mounted() {
uni.$on('companyInfo', (e) => {
this.company = e;
this.initLoad();
})
this.loadCompany();
this.initLoad();
},
methods: {
async loadCompany(){
let res = await companyView();
this.company = res.data.company;
},
navTo(url) {
if(url){
uni.showLoading({

View File

@ -31,9 +31,16 @@
<u--textarea :disabled="readonly" v-model="formData.notes" autoHeight placeholder="请输入备注" border="surround"
count></u--textarea>
</u-form-item>
<u-form-item labelWidth="auto" label="养殖类型" required prop="breeding_type" borderBottom>
<!-- <u-form-item labelWidth="auto" label="养殖类型" required prop="breeding_type" borderBottom>
<u--input :readonly="readonly" v-model="formData.breeding_type" placeholder="请输入养殖类型"></u--input>
</u-form-item>
</u-form-item> -->
<picker :range="breedingTypeList" range-key="name" :disabled="readonly" mode="selector" @change="changeBreeding">
<u-form-item labelWidth="auto" label="养殖类型" required prop="planning" borderBottom>
<u--input :value="breedingName" style="pointer-events: none;" placeholder="请选择养殖类型" disabled
disabledColor="#fff"></u--input>
<u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item>
</picker>
<picker mode="date" @change="changeDate" :disabled="readonly" :data-value="'breeding_time'">
<u-form-item labelWidth="auto" label="养殖开始时间" required prop="breeding_time" borderBottom>
<u--input :value="formData.breeding_time" style="pointer-events: none;" placeholder="请选择养殖开始时间" disabled disabledColor="#fff"></u--input>
@ -121,13 +128,8 @@
border="surround" count></u--textarea>
</u-form-item>
</u--form>
</view>
</view>
</template>
<script>
@ -149,6 +151,11 @@
data() {
return {
landPlanList: ['自己养', '出租', '代养', '租更多地扩大养殖'],
breedingTypeList: [
{ id: 1, name: "水产"},
{ id: 2, name: "禽类" },
{ id: 3, name: "大型动物" },
],
formData: {
// "breeding_training": 1, //
// "breeding_company": 0, //
@ -223,6 +230,11 @@
}
}
},
computed:{
breedingName(){
return this.breedingTypeList.find((item)=>item.id==this.formData.breeding_type)?.name;
}
},
methods: {
//
initRules() {
@ -245,10 +257,10 @@
async validate() {
return await this.$refs.breedingForm.validate();
},
//
changeLanPlan(e) {
let index = e.currentTarget.dataset.index;
this.formData.planning = e.detail.value;
//
changeBreeding(e) {
// let index = e.currentTarget.dataset.index;
this.formData.breeding_type = this.breedingTypeList[e.detail.value].id;
},
//
changeDate(e) {

View File

@ -66,7 +66,7 @@
<block v-else>进行中</block>
</block>
<block
v-else-if="datas.type == 44||datas.type == 45||datas.type == 46||datas.type == 47||datas.type == 48||datas.type == 49||datas.type == 50">
v-else-if="townService(datas.type)">
<block v-if="datas.type == 44">
{{extend.total-extend.not_done_count||0}}/{{extend.total||0}}
</block>
@ -119,7 +119,12 @@
},
data() {
return {
extend: {}
extend: {},
// : ,,
taskRoleTypeList: ['town_task_type', 'town_task_type_marketing_director', 'town_task_type_master'],
townServiceList: [44,45,46,47,48,49,50], //
navToTownServiceList: [44,45,46,48,49,50], // /subpkg/townTask/townTask 0
navToTownMarketList: [51,52,53,54,55,57,58,59] // /subpkg/townTask/townTask 1
};
},
mounted() {
@ -145,6 +150,10 @@
// if ((this.$props.datas.type != 31) && this.$props.datas.status !== 2 && this.$props.datas.status !== 1) {
// return this.$props.datas.status == 3 ? Toast('!') : Toast('!');
// }
if(this.navToTownServiceList.includes(this.$props.datas.type))
return this.navTo(`/subpkg/townTask/townTask?task_id=${this.$props.datas?.id}&type_value=${this.taskRoleTypeList[0]}`);
if(this.navToTownMarketList.includes(this.$props.datas.type))
return this.navTo(`/subpkg/townTask/townTask?task_id=${this.$props.datas?.id}&type_value=${this.taskRoleTypeList[1]}`);
switch (this.$props.datas.type) {
case 31:
if (this.$store.state.app.userInfo.admin_id) this.navTo(
@ -165,32 +174,21 @@
case 35:
this.navTo(`/subpkg/buyShare/buyShare?task_id=${this.$props.datas?.id}`);
break;
case 44:
this.navTo(`/subpkg/serviceTask/serviceTask?task_id=${this.$props.datas?.id}`);
break;
case 45:
this.navTo(`/subpkg/serviceTask/serviceTask?task_id=${this.$props.datas?.id}`);
break;
case 46:
this.navTo(`/subpkg/serviceTask/serviceTask?task_id=${this.$props.datas?.id}`);
break;
case 47:
this.navTo(`/subpkg/serviceTask/serviceTask4?task_id=${this.$props.datas?.id}`);
this.navTo(`/subpkg/townTask/serviceTask4?task_id=${this.$props.datas?.id}`);
break;
case 48:
this.navTo(`/subpkg/serviceTask/serviceTask?task_id=${this.$props.datas?.id}`);
break;
case 49:
this.navTo(`/subpkg/serviceTask/serviceTask?task_id=${this.$props.datas?.id}`);
break;
case 50:
this.navTo(`/subpkg/serviceTask/serviceTask?task_id=${this.$props.datas?.id}`);
case 60:
this.navTo(`/subpkg/townTask/marketTask10?task_id=${this.$props.datas?.id}&stage=${this.$props.datas?.stage}`);
break;
default:
this.navTo('');
break;
}
},
//
townService(type){
return this.townServiceList.includes(type);
},
isTimeInRange() {
const now = new Date();
const startTime = new Date(now.getTime());

View File

@ -2,9 +2,10 @@ let httpApiThree;
let httpApi; // 总域名
let httpApiTwo; // 物流系统域名
// const env = 'dev'; // 开发
const env = 'dev'; // 开发
// const env = 'prod'; // 生产
const env = 'prew'; // 预上线
// const env = 'prew'; // 预上线
// const env = 'local'; // 本地
switch (env) {
case 'prod':
@ -17,10 +18,16 @@ switch (env) {
httpApiThree = 'https://preview-worker-task.lihaink.cn' //预上线
httpApiTwo = 'https://preview-logistics.lihaink.cn' //预上线
break;
case 'local':
httpApi = 'http://192.168.1.12:8001' //预上线
httpApiThree = 'http://192.168.1.12:8001' //预上线
httpApiTwo = 'http://192.168.1.12:8001' //预上线
break;
default:
httpApi = 'https://ceshi-worker-task.lihaink.cn' //测试
httpApiThree = 'https://ceshi-worker-task.lihaink.cn' //测试
httpApiTwo = 'https://ceshi-logistics.lihaink.cn' //测试环境
//测试环境
}
@ -49,6 +56,7 @@ module.exports = {
HTTP_REQUEST_URL_THREE: httpApiThree,
HTTP_REQUEST_URL_TWO: httpApiTwo,
// #ifdef H5
//H5接口是浏览器地址
// HTTP_REQUEST_URL: httpApi || window.location.protocol + "//" + window.location.host,

View File

@ -3,8 +3,8 @@
// "appid" : "__UNI__3A527D1",
"appid" : "__UNI__B5B1EDD",
"description" : "",
"versionName" : "1.2.1",
"versionCode" : 121,
"versionName" : "1.2.4",
"versionCode" : 124,
"transformPx" : false,
/* 5+App */
"app-plus" : {

1461
pages.json

File diff suppressed because it is too large Load Diff

View File

@ -97,7 +97,7 @@
</view>
<view class="list">
<text>
详情
详情
</text>
<view>
<view>

View File

@ -110,9 +110,28 @@
</view>
</view>
</view>
<!-- 片区经理聊天 -->
<view class="chat" @click="navTo('/subpkg/chatMang/index')" style="margin-top: 130rpx;">
<view class="chat-l">
<u--image shape="circle" :showLoading="true" :src="managerInfo.manager_avatar" width="91rpx" height="91rpx"></u--image>
<view class="" style="margin-left: 40rpx;">
{{managerInfo.manager_name}}
</view>
</view>
<view class="" style="display: flex;">
<view class="brange" v-if="managerInfo.msg_num">
{{managerInfo.msg_num}}
</view>
<view class="iconfont icon-you">
<uni-icons type="forward"></uni-icons>
</view>
</view>
</view>
<view class="my_task">
<view class="task_title flex_a_c_j_sb">
<view class="title">工作管理</view>
<view class="title" @click="leftClick">工作管理</view>
<!-- <view class="flex_a_c"
>更多
<view class="iconfont icon-you">
@ -215,6 +234,9 @@ import {
import {
noticeList
} from "@/api/notice.js";
import {
getAreaManagerApi
} from "@/api/bussness.js"
// import tabbar from '../components/tabbar'
import {
getIndexListAPI,
@ -241,6 +263,8 @@ export default {
},
data () {
return {
brange:0,
options: {
data: '',
},
@ -248,6 +272,7 @@ export default {
page_num: 1,
flag: false,
uniMP: false,
managerInfo:{},
id: "",
is_captain: 0,
notArr: [],
@ -289,14 +314,16 @@ export default {
};
},
async onLoad () {
await this.$onLaunched;
this.is_captain = JSON.parse(uni.getStorageSync("USER_INFO")||'{}')?.is_captain
this.options.data = bj;
//#ifdef APP-PLUS
let that = this;
jpushModule.addNotificationListener(function (result) {
if (!that.notArr.includes(result.messageID)) {
that.$refs.globalPopup.showPopu();
// that.$refs.globalPopup.showPopu();
that.getOrderList();
console.log("idnex的");
that.notArr.push(result.messageID);
@ -326,8 +353,16 @@ export default {
})
},
async onShow () {
// uni.navigateTo({
// url:'/subpkg/chatMang/index'
// }
// this.getUserIndex()
// this.getIndexList()
let user_id= JSON.parse( uni.getStorageSync("USER_INFO")).id
getAreaManagerApi({user_id}).then(res=>{
console.log(res.data)
this.managerInfo=res.data
})
await this.$onLaunched;
if (uni.getStorageSync('uniMP')) this.uniMP = true;
userInfo().then(({
@ -408,18 +443,26 @@ export default {
methods: {
//
noticeFn () {
const audioContext = uni.createInnerAudioContext()
audioContext.src = '/static/mp3/order.mp3'
jpushModule.addNotificationListener(res => {
jpushModule.addNotificationListener(res => {
const audioContext = uni.createInnerAudioContext()
if(res.content.includes('')){
audioContext.src = '/static/mp3/im.wav'
audioContext.play()
uni.vibrateLong();
console.log("im")
return
}
if (res.notificationEventType == 'notificationOpened') return
audioContext.src = '/static/mp3/order.mp3'
audioContext.play()
uni.vibrateLong();
this.getOrderList()
this.$refs.globalPopup.showPopu();
// this.$refs.globalPopup.showPopu();
console.log("index的监听")
})
},
leftClick (e) {
console.log("发送给宿主")
uni.sendHostEvent('closeApp', e, (ret) => {
//
console.log('关闭应用' + JSON.stringify(ret));
@ -958,4 +1001,32 @@ export default {
}
}
}
.chat{
margin-top: 1000px;
// margin-top: 2000rpx;
width: 694.74rpx;
margin: 0 auto;
background-color: white;
border-radius: 12px;
padding:20rpx;
// padding-top: 10rpx;
padding-right: 24rpx;
display: flex;
justify-content: space-between;
align-items: center;
.chat-l{
display: flex;
align-items: center;
}
}
.brange{
color: white;
background-color: red;
width: 40rpx;
height: 40rpx;
border-radius: 40rpx;
font-size: 12px;
text-align: center;
lighting-color: 40rpx;
}
</style>

View File

@ -1,10 +1,10 @@
<template>
<view class="login">
<!-- <image class="bg-iamge" src="../../static/img/login/login_back_img.png"></image> -->
<hx-lottie :options="options" ref="lottie" style="width: 100vw;height: 100vh;transform: scale(1.3);background-color: #0122c7;"/>
<u-navbar v-if="uniMP" @leftClick="leftClick" bgColor="rgba(0,0,0,0)"
leftIconColor=" #fff" :autoBack="false">
</u-navbar>
<hx-lottie :options="options" ref="lottie"
style="width: 100vw;height: 100vh;transform: scale(1.3);background-color: #0122c7;" />
<u-navbar v-if="uniMP" @leftClick="leftClick" bgColor="rgba(0,0,0,0)" leftIconColor=" #fff" :autoBack="false">
</u-navbar>
<!-- #ifdef APP-PLUS||H5 -->
<!-- <view style="height: var(--status-bar-height)"></view> -->
<!-- #endif -->
@ -18,10 +18,10 @@
</view>
<input @click="getId" class="mobile item" v-model="formData.account" type="tel"
placeholder="输入账号" />
<input style="width: 0;height: 0;opacity: 0;margin: 0;padding: 0;" v-model="formData.account" type="tel"
placeholder="输入账号" />
<input @click="getId" class="mobile item" v-model="formData.password"
maxlength="26" placeholder="输入密码" password type="safe-password" />
<input style="width: 0;height: 0;opacity: 0;margin: 0;padding: 0;" v-model="formData.account"
type="tel" placeholder="输入账号" />
<input @click="getId" class="mobile item" v-model="formData.password" maxlength="26"
placeholder="输入密码" password type="safe-password" />
<!-- <input v-if="current == 1" class="mobile item" v-model="formData.account" placeholder="输入手机号" />
<view v-if="current == 1" class="code item">
<input placeholder="输入验证码" v-model="formData.code" maxlength="6" />
@ -42,12 +42,14 @@
loginAccount,
userInfo
} from "@/api/oaUser.js"
import { getConfig } from "@/api/config.js";
import {
getConfig
} from "@/api/config.js";
import {
Toast
} from "../../libs/uniApi";
import bj from "@/static/animation/bj2.json"
import encrypt from "@/utils/encrypt.js"
import bj from "@/static/animation/bj2.json"
import encrypt from "@/utils/encrypt.js"
// #ifdef APP-PLUS
var jpushModule = uni.requireNativePlugin("JG-JPush");
@ -56,11 +58,11 @@
export default {
data() {
return {
options: {
data: '',
},
uniMP: false,
APP_token: '',
options: {
data: '',
},
uniMP: false,
APP_token: '',
tabList: [{
name: '账号登录'
},
@ -74,33 +76,33 @@
terminal: 6, //6APP
scene: 1,
register_id: "",
shop_token: ""
shop_token: ""
},
tips: '获取验证码',
// refCode: null,
seconds: 60,
};
},
onLoad() {
this.APP_token = uni.getStorageSync('APP_token');
this.options.data = bj;
// this.$refs.lottie.call('play');
this.initTerminal();
},
onShow() {
if(uni.getStorageSync('uniMP'))this.uniMP = true;
},
onLoad() {
this.APP_token = uni.getStorageSync('APP_token');
this.options.data = bj;
// this.$refs.lottie.call('play');
this.initTerminal();
},
onShow() {
if (uni.getStorageSync('uniMP')) this.uniMP = true;
},
methods: {
changeTabs(e) {
this.current = e.index;
this.formData.scene = e.index + 1;
},
leftClick(e) {
uni.sendHostEvent('closeApp', e, (ret) => {
//
console.log('关闭应用'+JSON.stringify(ret));
});
},
leftClick(e) {
uni.sendHostEvent('closeApp', e, (ret) => {
//
console.log('关闭应用' + JSON.stringify(ret));
});
},
// id
getId() {
// #ifdef APP-PLUS
@ -118,13 +120,13 @@
if (!this.formData.account) return Toast('账号不能为空');
if (this.formData.scene == 1 && !this.formData.password) return Toast('密码不能为空');
if (this.formData.scene == 2 && !this.formData.code) return Toast('验证码不能为空');
this.formData.shop_token = uni.getStorageSync('APP_token');
this.formData.shop_token = uni.getStorageSync('APP_token');
let that = this;
uni.showLoading({
title: '正在登录中'
})
let res = await loginAccount(that.formData);
encrypt.encode('ACT', that.formData);
encrypt.encode('ACT', that.formData);
this.$store.commit('SET_USERINFO', {
user: data,
token: res.data.token
@ -133,8 +135,8 @@
data
} = await userInfo();
this.$store.commit('setUserInfo', data);
let config = await getConfig();
this.$store.commit('SET_CONFIG', config.data);
let config = await getConfig();
this.$store.commit('SET_CONFIG', config.data);
uni.hideLoading()
if (data.is_new_user) {
uni.showLoading({
@ -150,13 +152,13 @@
}
})
// #endif
return uni.reLaunch({
url: '/pages/oaHome/oaHome',
success: () => {
uni.$emit('initOaTask'); //
uni.hideLoading()
}
})
return uni.reLaunch({
url: '/pages/oaHome/oaHome',
success: () => {
uni.$emit('initOaTask'); //
uni.hideLoading()
}
})
} else uni.navigateTo({
url: '/pages/updatePassword/updatePassword'
});
@ -223,7 +225,7 @@
width: 100vw;
height: 100vh;
position: relative;
overflow: hidden;
overflow: hidden;
background-color: $theme-oa-color;
/* #ifdef H5 */
// background-image: url("../../static/img/login/login_back_img.png");
@ -238,10 +240,10 @@
// }
.body {
position: absolute;
top: 45%;
left: 50%;
transform: translate(-50%, -50%);
position: absolute;
top: 45%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
flex-direction: column;
align-items: center;
@ -257,10 +259,10 @@
line-height: 68rpx;
-webkit-background-clip: text;
}
::v-deep uni-input{
min-height: 0 !important;
}
::v-deep uni-input {
min-height: 0 !important;
}
.login-card {
width: 694rpx;

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
static/img/bussness/SP.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
static/img/bussness/XC.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
static/mp3/im.mp3 Normal file

Binary file not shown.

BIN
static/mp3/im.wav Normal file

Binary file not shown.

666
subpkg/chatMang/index.vue Normal file
View File

@ -0,0 +1,666 @@
<template>
<view style="background-color: #F6F7FD;">
<u-loading-page :loading="showLoading" v-if="showLoading"></u-loading-page>
<!-- 消息 -->
<view class="content" @click="showPlus=false" id="content" v-show='!showLoading'>
<view class="">
<u-loadmore :status="status" :loadmore-text="`你正在与${manager_nmae}聊天`" />
</view>
<view class="task-li" v-for="item,index in list" :key="index">
<view class="" v-if="index %5 ==0" style="text-align: center;">
{{timeFn(item.create_time)}}
</view>
<!-- 对方消息 -->
<view v-if="item.from_user_id!=fromId">
<view class="task-li-r">
<view class="" style="margin-right: 10rpx;">
<u--image :showLoading="true" :src="item.from_user_avatar" shape="circle" width="40px"
height="40px"></u--image>
</view>
<view @longpress="copyText(item.content)" class="task-li-content" v-if="item.type=='text'"
style="margin-right: 10rpx;">
<view style="color: #576B95;" @click="href(item.content)" v-if="isLink(item.content)">
{{item.content}}
</view>
<view class="" v-else>
{{item.content}}
</view>
</view>
<!-- 图片 -->
<view class="task-li-content" v-if="item.type=='image'" style="margin-right: 10rpx;"
@tap="previewImage(item.content)">
<image :src="item.content" style="width:200rpx" mode="widthFix"></image>
</view>
<!-- 视频 -->
<view class="task-li-content" v-if="item.type=='video'"
style="margin-right: 10rpx;position: relative;"
@tap="showOverLayFn(item.content,item.type)">
<u--image :showLoading="true"
:src=" item.content+'?x-oss-process=video\/snapshot,t_1000,m_fast,w_800,f_png' "
width="100px" height="80px"></u--image>
<view class="yl-text">
<u-icon name="play-circle" color='white' size='30'></u-icon>
</view>
</view>
</view>
<view class="send-time">
{{item.sendTime}}
</view>
</view>
<!-- 我的消息 -->
<view class="task-li-l" v-else>
<!-- 文字 -->
<view class="task-li-content" @longpress="copyText(item.content)" v-if="item.type=='text'"
style="margin-right: 10rpx;">
<!-- {{item.content}} -->
<view style="color: #576B95;" @click="href(item.content)" v-if="isLink(item.content)">
{{item.content}}
</view>
<view class="" v-else>
{{item.content}}
</view>
<!-- <a href="item.content" target="_blank"> {{item.content}}</a> -->
</view>
<!-- 图片 -->
<view class="task-li-content" v-if="item.type=='image'" style="margin-right: 10rpx;"
@tap="previewImage(item.content)">
<image :src="item.content" style="width:200rpx" mode="widthFix"></image>
</view>
<!-- 视频 -->
<view class="task-li-content" v-if="item.type=='video'"
style="margin-right: 10rpx;position: relative;" @tap="showOverLayFn(item.content,item.type)">
<u--image :showLoading="true"
:src=" item.content+'?x-oss-process=video\/snapshot,t_1000,m_fast,w_800,f_png' "
width="100px" height="80px"></u--image>
<view class="yl-text">
<u-icon name="play-circle" color='white' size='30'></u-icon>
</view>
</view>
<view class="">
<u--image :showLoading="true" :src="a" shape="circle" width="40px" height="40px"></u--image>
</view>
</view>
</view>
<!-- 本地 -->
<view v-show="item.status" v-for="(item,index) in local">
<view class="localTask" v-if="item.localType=='video'">
<view class="task-li-content" style="margin-right: 10rpx;">
<video :src="item.localSrc" controls id="vi1" style="width: 400rpx; height: 100px;"></video>
<!-- <image :src="" style="width:200rpx" mode="widthFix"></image> -->
<u-loadmore status="loading" loading-text="努力上传中" />
</view>
<view class="" style="margin-right: 10rpx;">
<u--image :showLoading="true" shape="circle" :src="a" width="40px" height="40px"></u--image>
</view>
</view>
<view class="localTask" v-if="item.localType=='image'">
<view class="task-li-content" style="margin-right: 10rpx;">
<image :src="item.localSrc" style="width:200rpx" mode="widthFix"></image>
<u-loadmore status="loading" loading-text="努力上传中" />
</view>
<view class="" style="margin-right: 10rpx;">
<u--image :showLoading="true" shape="circle" :src="a" width="40px" height="40px"></u--image>
</view>
</view>
</view>
<view style="height: 300rpx;background-color: #F6F7FD;" v-if="showPlus">
</view>
<view style="height: 150rpx;background-color: #F6F7FD;" v-else>
</view>
</view>
<!-- 底部 -->
<view class="bottom">
<!-- -->
<view class="send-col">
<input type="text" class="send-ipt" @focus="scrollFn" v-model="value" placeholder="请输入聊天内容"
placeholder-style="color:#DDD;" :cursor-spacing="6">
<u--image :showLoading="true" src="/static/img/bussness/Plus.png" width="32px" height="32px"
@click="showPlusFn"></u--image>
<button class="send" @tap="sendFn">发送</button>
</view>
<!-- 发送照片 -->
<view class="plus" v-if="showPlus">
<view class="plus_li">
<u--image :showLoading="true" src="/static/img/bussness/XC.png" width="120rpx" height="120rpx"
@click="choseImgFn"></u--image>
<text>图片</text>
</view>
<view class="plus_li">
<u--image :showLoading="true" src="/static/img/bussness/SP.png" width="120rpx" height="120rpx"
@click="choseVideoFn"></u--image>
<text>视频</text>
</view>
</view>
</view>
<!-- 遮罩图 -->
<u-overlay :show="show" @click="show = false">
<view class="warp">
<view class="rect" @tap.stop v-if="overLayType=='video'">
<video :src="overLaySrc" controls :autoplay="true"></video>
</view>
</view>
</u-overlay>
</view>
</template>
<script>
import {
FILE_URL_IM
} from "@/api/file.js"
import {
sendMsgApi,
getMsgListApi,
bindScoket,
sendFileApi,
getAreaManagerApi
} from "@/api/bussness.js"
export default {
data() {
return {
showLoading: true,
a: "https://img1.baidu.com/it/u=716638254,3920932970&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1695920400&t=aeec3d0e86c23759d5f82b3757e9b442",
list: [],
bind: false,
value: "",
showPlus: false,
scollNum: 500000000000,
client_id: "",
fromId: "",
toId: "",
name: "",
status: "loadmore",
page_no: 1,
limit: 10,
show: false,
overLaySrc: "",
overLayType: "",
local: [],
localType: "",
imageList: [],
sendData: {},
manager_nmae: "",
msg_id: "",
aaa: false,
}
},
methods: {
isLink(text) {
var pattern = /^(https?:\/\/|www\.|.*\.com).*$/i;
return pattern.test(text);
},
href(url) {
// uni.navigate
plus.runtime.openURL(url);
// plus.runtime.openUrl(url)
},
previewImage(src) {
this.imageList[0] = src
uni.previewImage({
urls: this.imageList,
})
},
generateRandId() {
var d = new Date().getTime();
var uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c == "x" ? r : r & 0x3 | 0x8).toString(16);
});
// return uuid;
this.msg_id = uuid
console.log("改变id")
},
timeFn(time) {
time = time * 1000
const currentDate = new Date(); //
const targetDate = new Date(time);
if (this.isSameDay(currentDate, targetDate)) {
const hours = targetDate.getHours(); //
const minutes = targetDate.getMinutes(); //
return hours + ':' + (minutes >= 10 ? minutes : '0' + minutes);
} else if (this.isYesterday(currentDate, targetDate)) {
return '昨天';
}
const month = targetDate.getMonth() + 1; // 01
const day = targetDate.getDate(); //
return month + '月' + day + '日';
},
isSameDay(date1, date2) {
return (
date1.getFullYear() === date2.getFullYear() &&
date1.getMonth() === date2.getMonth() &&
date1.getDate() === date2.getDate()
);
},
isYesterday(currentDate, targetDate) {
const yesterday = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() - 1);
return this.isSameDay(yesterday, targetDate);
},
toast(msg) {
uni.showToast({
title: msg,
icon: 'none'
});
},
saveImage(src) {
uni.saveImageToPhotosAlbum({
filePath: src,
success() {
uni.showToast({
title: '保存成功',
icon: 'none'
});
},
fail() {
this.toast('保存失败')
}
});
},
copyText(value) {
const text = value;
uni.setClipboardData({
data: text,
success() {
uni.showToast({
title: '复制成功',
icon: 'none'
});
}
});
},
showOverLayFn(src, type) {
this.show = true
this.overLaySrc = src
this.overLayType = type
},
getListFn() {
getMsgListApi({
from_user_id: this.fromId,
to_user_id: this.toId,
scene: 0,
page_no: this.page_no,
page_size: 10
}).then(res => {
if (res.data.length <= 0) {
uni.stopPullDownRefresh();
this.status = "nomore"
return
}
this.list = res.data.reverse().concat(this.list)
uni.stopPullDownRefresh();
})
},
scrollFn() {
let that = this
this.scollNum += 100
setTimeout(() => {
uni.pageScrollTo({
scrollTop: that.scollNum, //
success: function() {
console.log('滚动')
}
})
}, 100)
},
sendFn() {
let that = this
if (!this.value) {
this.toast("消息不能为空")
return
}
let data = {
from_user_id: this.fromId,
to_user_id: this.toId,
type: "text",
content: this.value,
scene: 0,
create_time: (Date.now() / 1000),
msg_id: this.msg_id
}
sendMsgApi({
...data
}).then(res => {
console.log(data)
this.list.push(data)
this.scrollFn(100)
this.value = ""
this.generateRandId()
}).catch(err => {
this.toast('发送失败')
this.generateRandId()
})
},
showPlusFn() {
this.showPlus = !this.showPlus
this.scrollFn()
},
choseImgFn() {
this.generateRandId()
let time = Date.now()
let that = this
uni.chooseImage({
count: 1, //
success: res => {
const tempFilePath = res.tempFilePaths[0];
that.local.push({
localType: 'image',
localSrc: tempFilePath,
status: true,
msg_id: that.msg_id
})
that.showPlus = false
that.scrollFn()
console.log(that.local)
uni.uploadFile({
url: FILE_URL_IM,
filePath: tempFilePath, //
name: 'file',
header: {
"Authorization": uni.getStorageSync("TOKEN")
},
formData: {
from_user_id: that.fromId,
to_user_id: that.toId,
scene: 0,
msg_id: that.msg_id,
type: 'image'
},
success: function(uploadRes) {
let data = JSON.parse(uploadRes.data).data
var localIndex = that.local.findIndex(function(element) {
return element.msg_id === data.msg_id;
});
that.local[localIndex].status = false
that.list.push(data)
},
fail: function(error) {
this.toast('上传失败')
}
});
},
fail: err => {
this.toast('操作取消')
}
});
},
choseVideoFn() {
this.generateRandId()
let that = this
uni.chooseVideo({
sourceType: ['album', 'camera'], //
maxDuration: 600, //
camera: 'back', //
success: res => {
const tempFilePath = res.tempFilePath;
that.local.push({
localType: 'video',
localSrc: tempFilePath,
status: true,
msg_id: that.msg_id
})
that.showPlus = false
that.scrollFn()
uni.uploadFile({
url: FILE_URL_IM,
filePath: tempFilePath, //
name: 'file',
header: {
"Authorization": uni.getStorageSync("token")
},
formData: {
from_user_id: that.fromId,
to_user_id: that.toId,
scene: 0,
msg_id: that.msg_id,
type: 'video'
}, //
success: function(uploadRes) {
let data = JSON.parse(uploadRes.data).data
var localIndex = that.local.findIndex(function(element) {
return element.msg_id === data.msg_id;
});
that.local[localIndex].status = false
that.list.push(data)
//
},
fail: function(error) {
console.log(error)
uni.showToast({
title: '视频不能超过60s',
duration: 2000,
icon: 'none'
});
// that.local = false
}
});
},
fail: err => {
// uni.showToast({
// title: '60s',
// duration: 2000,
// icon: 'none'
// });
}
});
},
},
onShow() {
this.page_no = 1
this.generateRandId()
this.fromId = JSON.parse(uni.getStorageSync("USER_INFO")).id
getAreaManagerApi({
user_id: this.fromId
}).then(res => {
this.toId = res.data.to_user_id
this.manager_nmae = res.data.manager_name
getMsgListApi({
from_user_id: this.fromId,
to_user_id: this.toId,
scene: 0,
page_no: 1,
page_size: 10
}).then(res => {
this.showLoading = false
this.list = res.data.reverse()
this.scrollFn()
})
})
},
async onPullDownRefresh() {
let that = this
this.status = "loading"
this.page_no++
await this.getListFn()
this.status = "loadmore"
},
onLoad() {
console.log(F)
let user = JSON.parse(uni.getStorageSync('USER_INFO'))
this.a = user.avatar
console.log(user.avatar)
uni.connectSocket({
url: 'wss://worker-task.lihaink.cn/wss'
});
uni.onSocketOpen(function(res) {
console.log('WebSocket连接已打开');
});
uni.onSocketError(function(res) {
console.log('WebSocket连接打开失败请检查');
});
let that = this
uni.onSocketMessage(function(res) {
let data = JSON.parse(res.data)
if (data.client_id) {
let client_id = data.client_id
if (!that.bind) {
bindScoket({
client_id: client_id,
user_id: that.fromId,
scene: 0,
}).then(res => {
that.bind = true
})
}
}
//
else if (data.type != 'ping') {
console.log(data)
that.list.push(data)
that.scrollFn()
}
});
this.generateRandId()
},
}
</script>
<style lang="scss">
.yl-text {
position: absolute;
color: white;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 24rpx;
}
.topflag {
height: 80rpx;
background-color: #F6F7FD;
}
.content {
padding: 0 20rpx;
min-height: 95vh;
background-color: #F6F7FD;
padding-top: 10rpx;
.task-li {
margin-bottom: 20rpx;
}
.task-li-l {
display: flex;
justify-content: flex-end;
}
.task-li-r {
display: flex;
}
.task-li-content {
background-color: white;
padding: 10rpx 20rpx;
line-height: 50rpx;
// line-height: 30rpx;
border-radius: 20rpx;
// color: white;
word-break: break-all;
max-width: 535rpx;
overflow-wrap: break-word;
}
}
.bottom {
background-color: white;
padding: 20rpx 0;
position: fixed;
box-sizing: border-box;
bottom: 0px;
padding-bottom: 10px;
/* #ifndef APP-PLUS */
// bottom: 40px;
/* #endif */
.send-col {
display: flex;
align-items: center;
justify-content: space-around;
.send-ipt {
width: 70vw;
background-color: #F5F5F5;
height: 60rpx;
border-radius: 20rpx;
padding-left: 20rpx;
}
}
.send {
background-color: #2573fb;
color: #fff;
height: 64rpx;
margin-left: 20rpx;
border-radius: 6rpx;
padding: 0;
width: 120rpx;
line-height: 62rpx;
&:active {
background-color: #1573fb;
}
}
.plus {
display: flex;
background-color: white;
padding: 20rpx;
.plus_li {
display: flex;
flex-direction: column;
align-items: center;
margin-right: 20rpx;
flex-wrap: wrap;
}
}
}
.warp {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
.rect {}
.localTask {
display: flex;
justify-content: flex-end;
}
</style>

View File

@ -215,7 +215,10 @@
},
onPullDownRefresh() {
if (this.current == 1) this.initLoad();
else if (this.current == 2) this.$refs.financeRef.initLoad();
else if (this.current == 2) {
this.$refs.financeRef.loadCompany();
this.$refs.financeRef.initLoad();
}
else if (this.current == 3) this.$refs.taskRef.initLoadConfig();
this.$u.sleep(500).then(() => {
uni.stopPullDownRefresh()

View File

@ -161,7 +161,7 @@
//
async submit() {
if(!this.isReject())return; //
if (this.other.note.trim() == '') return Toast('详情描述不能为空');
if (this.note.trim() == '') return Toast('详情描述不能为空');
await taskOtherTaskCommit({
id: this.task_id,
note: this.note,

View File

@ -13,9 +13,15 @@
{{item.create_time.slice(0, 10)}}
</view>
<view class="">
<view class="" v-if="item.type==0">
{{item.company_b_name}}提出租赁车辆一辆
</view>
<view class="" v-if="item.type==1">
{{item.company_b_name}}上传自有车辆一辆
</view>
<view class="" v-if="item.type==2">
{{item.company_b_name}}提出解除租赁
</view>
</view>
</view>
@ -64,6 +70,10 @@
background-color: #FF7C32;
color: white;
padding: 0 10rpx;
font-size: 24rpx;
// line-height: rpx;
display: flex;
align-items: center;
width: 200rpx;
height: 50rpx;
margin-right: 10rpx;

268
subpkg/property/buyCar.vue Normal file
View File

@ -0,0 +1,268 @@
<template>
<view class="box">
<!-- 搜索 -->
<view class="" style="padding:10rpx 20rpx;">
<u-search :showAction="true" bgColor='white' @search="queryCarFn" placeholder="搜索车牌号" actionText="搜索"
:animation="true" v-model="queryCar" @custom='queryCarFn'></u-search>
</view>
<view style="height: 80vh;" v-if="carList.length==0">
<u-empty mode="search" marginTop='100' icon="/static/img/empty/data.png">
</u-empty>
</view>
<view v-else class="car-list" v-for="item,index in carList" :key="index">
<view class="car-info">
<view class="car-info-l">
<view class="">
<u--image :src="item.pic" width="150rpx" height="150rpx" style="margin-right:20rpx"></u--image>
</view>
<view class="car-info-c">
<view class="lincense">
车牌号: {{item.license}}
</view>
<!-- <view class="lincense">
行驶里程: 1212KM
</view> -->
<view class="lincense" v-if="item.flag">
当前状态: 当前使用中
</view>
<view class="lincense" v-else>
当前状态: 闲置中
</view>
</view>
</view>
<!-- -->
<view class="car-info-r">
<view class="" style="margin: 10rpx 50rpx;">
<u-checkbox-group v-model="item.checked" placement="column" @change="checkboxChange(item.id)">
<u-checkbox>
</u-checkbox>
</u-checkbox-group>
</view>
<view class="" v-show="item.id==carCheckedArr[0] &&type!=2">
选择该车辆为监管车辆
</view>
</view>
</view>
</view>
<view class="bottom">
<view class="" @tap="open">
已选择{{carCheckedArr.length}}辆车
</view>
<view class="bottom-btn" @tap="buyCarFn">
<u-button type="primary" style="background-color: #0122C7;border: none;" text="确定"></u-button>
</view>
</view>
<!-- 组件 -->
<u-popup :show="showPop" mode="bottom" @close="close" @open="open">
<view class="pop">
<view class="check-car-list" v-for="item,index in carList" v-show="item.checked.length" :key="index">
<u--image :src="item.pic" width="150rpx" height="150rpx"></u--image>
<view class="" style="margin-top: 10rpx;">
{{item.license}}
</view>
<view class="pop-check">
<u-checkbox-group v-model="item.checked" @change="popChange(item.id)">
<u-checkbox>
</u-checkbox>
</u-checkbox-group>
</view>
</view>
</view>
</u-popup>
</view>
</template>
<script scoped>
// import { methods } from '../../uni_modules/uview-ui/libs/mixin/mixin'
import {
canBuyCarListApi,
buyCarApi
} from "@/api/property.js"
import {
Toast
} from "../../libs/uniApi"
export default {
data() {
return {
queryCar: '',
carList: [],
carListI: [],
showPop: false,
carCheckeList: [],
carCheckedArr: [],
type: "",
}
},
methods: {
buyCarFn() {
if (this.carCheckedArr.length == 0) {
Toast("请先选择车辆!")
return
}
let data = []
this.carList.forEach(item => {
this.carCheckedArr.forEach(items => {
if (item.id == items) {
data.push({
id: item.id,
license: item.license
})
}
})
})
let datas = JSON.stringify(data)
buyCarApi({
cars: datas
}).then(res => {
Toast("申请成功!")
setTimeout(() => {
uni.redirectTo({
url: '/subpkg/property/index'
})
}, 1000)
})
// uni.navigateTo({
// url: '/subpkg/property/index'
// })
},
queryCarFn() {
this.carList = []
this.carListI.forEach(item => {
// console.log(item.license)
if (item.license.includes(this.queryCar)) {
this.carList.push(item)
}
})
},
checkboxChange(i) {
if (this.carCheckedArr.includes(i)) {
// let index=this.ca
let index = this.carCheckedArr.indexOf(i)
// console.log(index)
this.carCheckedArr.splice(index, 1)
// this.arr
} else {
this.carCheckedArr.push(i)
}
console.log(this.carCheckedArr)
},
popChange(index) {
this.checkboxChange(index)
// console.log(this.carCheckedArr)
},
close() {
this.showPop = false
},
open() {
if (this.carCheckedArr.length == 0) return
this.showPop = true
},
change(e) {
console.log(e)
}
},
onLoad(option) {
this.type = option.type
// console.log(option.license)
canBuyCarListApi().then(res => {
res.data.forEach(item => {
if (item.license == option.license) {
item.flag = true
}
})
this.carListI = res.data
this.carList = Array.from(this.carListI);
})
}
}
</script>
<style lang="scss" scoped>
.box {
padding-bottom: 100rpx;
}
.car-list {
padding: 20rpx;
background-color: #fff;
.car-info {
display: flex;
justify-content: space-between;
margin-bottom: 20rpx;
.car-info-l {
display: flex;
}
.car-info-c {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.car-info-r {
max-width: 20vw;
}
}
}
.pop {
min-height: 40vh;
display: flex;
flex-wrap: wrap;
box-sizing: border-box;
padding: 20rpx 10rpx;
padding-right: 0;
padding-bottom: 100rpx;
.check-car-list {
// margin-right: 30rpx;
width: 182.5rpx;
display: flex;
// justify-tent: ;
flex-direction: column;
align-items: center;
position: relative;
}
.pop-check {
position: absolute;
right: 0;
top: -5rpx;
}
}
.bottom {
background-color: white;
height: 100rpx;
position: fixed;
bottom: 0;
z-index: 1000;
width: 100vw;
box-sizing: border-box;
border-radius: 30rpx 30rpx 0 0;
padding: 0 20rpx;
display: flex;
align-items: center;
justify-content: space-between;
.bottom-btn {
width: 200rpx;
}
}
</style>

View File

@ -46,12 +46,12 @@
<view class="car_type">
<text>自有车辆</text>
</view>
<view class="car_li">
<view class="car_li" v-for="(item,index) in dataList.cars_info">
<view class="" style="display: flex;justify-content: space-between;align-items: center;">
<view class="" style="display: flex;align-items: center;">
<u--image :src="dataList.cars_info.pic" width="100rpx" height="100rpx"></u--image>
<u--image :src="item.pic" width="100rpx" height="100rpx"></u--image>
<view class="" style="margin-left: 10rpx;">
车牌号{{dataList.cars_info.license}}
车牌号{{item.license}}
</view>
</view>
@ -133,7 +133,7 @@
<view class="name">{{typeFn( dataList.type) }}
</view>
<view>
<text>{{'2023-03-03'}}</text>
<text>{{dataList.update_time}}</text>
</view>
</view>
</view>
@ -202,11 +202,11 @@
this.dataList = res.data.vehicleContract
this.carList = res.data.vehicleRentCars
this.checked = [this.carList[0]?.car_id] || ''
this.dataList.cars_info = JSON.parse(this.dataList.cars_info) || ""
// if (this.dataList.status == 3) {
// uni.navigateBack()
// }
console.log(this.dataList.cars_info.pic)
if (this.carList.length > 0 || this.dataList.cars_info) {
this.flag1 = false
}
@ -244,7 +244,7 @@
return "租赁合同"
}
if (status == 1) {
return "自有车"
return "自有车"
}
if (status == 2) {
"解除合同"

View File

@ -30,7 +30,7 @@
export default {
data() {
return {
datasList: [1, 2, 3],
datasList: [],
}
},
onLoad() {

View File

@ -4,23 +4,23 @@
<u-loading-page :loading="showLoading"></u-loading-page>
</view>
<view class="" v-else>
<!-- 小组公司 -->
<view class="noCar" v-if='company_type==18'>
<!-- 申请 -->
<view class="" v-if="step==6||step==9999">
<u-empty text="你还没有所属车辆哦,请向镇公司申请用车或使用自有车辆并绑定系统~" icon="../../static/img/empty/data.png">
</u-empty>
<view>
<mytn text='购买车辆' class="buyCar" :position="false" @click="navgo('/subpkg/property/buyCar')">
</mytn>
</view>
<view>
<mytn text='申请用车' class="upCar" :position="false" @click="applycarFn"></mytn>
</view>
<view class="">
<mytn text='上传自有车辆' @click="show=true"></mytn>
</view>
<u-modal :show="show" @close="show=false" :showCancelButton="true" @confirm="upCarFn"
:closeOnClickOverlay="true" @cancel="show=false" title="车辆上传">
<view class="slot-content">
@ -44,7 +44,7 @@
</view>
<view class="uplode" v-else>
<u-icon name="plus-circle-fill" color="#0022C7" size="28"></u-icon>
上传头像
上传车辆图片
<view class="up" style="opacity: 0;">
<u-upload :fileList="imgUrl?[{url:imgUrl}]:[]"
@afterRead="afterReadAvatar" :maxCount="1">
@ -60,13 +60,10 @@
</view>
</view>
</u-modal>
</view>
<!-- 等待 -->
<view class="" v-if='[5,-1,0,1,2].includes(step)'>
<view class="loading" v-if='step==5'>
<span>你已提交解除申请,等待签约</span>
<span class="dots">...</span>
@ -79,6 +76,7 @@
<span class="dots">...</span>
</view>
</view>
<!-- 申请用车 -->
<view v-if="datas.type ==0">
<view class="loading">
@ -86,7 +84,13 @@
<span class="dots">...</span>
</view>
</view>
<!-- 购买车辆 -->
<view class="loading" v-if="datas.type==3">
<span>您的购车申请已经提交我们正在加快审核中请耐心等待在此期间您可以继续使用车辆完成配送任务哦~</span>
<span class="dots">...</span>
</view>
</view>
<!-- 审核结束 -->
<view class="" v-if="step==4">
<view style="margin-top: 15vh;">
@ -101,16 +105,16 @@
</view>
</view>
<view class="">
<mytn text='购买车辆' class="buyCar" :position="false" @click="navgo('/subpkg/property/buyCar')">
</mytn>
<view class="" style="margin: 20rpx 0;">
<mytn text='上传自有车辆' @click="show=true"></mytn>
</view>
<view class="">
<mytn text='申请用车' :position="false" class="upCar" @click="applycarFn"></mytn>
</view>
<u-modal :show="show" @close="show=false" :showCancelButton="true" @confirm="upCarFn"
:closeOnClickOverlay="true" @cancel="show=false" title="车辆上传">
<view class="slot-content">
@ -134,7 +138,7 @@
</view>
<view class="uplode" v-else>
<u-icon name="plus-circle-fill" color="#0022C7" size="28"></u-icon>
上传头像
上传车辆图片
<view class="up" style="opacity: 0;">
<u-upload :fileList="imgUrl?[{url:imgUrl}]:[]"
@afterRead="afterReadAvatar" :maxCount="1">
@ -166,13 +170,13 @@
申请用车</u-button>
</view>
</view>
</view>
<!-- 镇街公司 -->
<view v-if='company_type==16'>
<view class="info">
<text>可监管车辆数量 {{datas.monitor_num}}</text>
<text>购买车辆 {{datas.buy_num}}</text>
<view @click="showPop=true" class="not_leased">
<view class="">
租赁 {{datas.rent_num}}<text v-if="datas.apply_num">(待审核:{{datas.apply_num}})</text>
@ -184,6 +188,7 @@
</view>
</view>
<text v-if="datas.self_num">自有车辆 {{datas.self_num}}</text>
<!-- <text v-if="datas.self_num">出售车辆 {{datas.self_num}}</text> -->
</view>
<!-- 公告栏 -->
<view class="application_tit" v-if="applicationList.length">
@ -208,7 +213,6 @@
<u-icon name="arrow-right"></u-icon>
</view>
</view>
</view>
</view>
<view class="personnel_list">
@ -227,7 +231,8 @@
<text> {{item.rent_user.user_name}}</text>
<view style="float: right;">
<text style="color: green;" v-if="item.type==1">自有车辆</text>
<text style="color: orange;" v-else>租赁车辆</text>
<text style="color: orange;" v-if='item.type==0'>租赁车辆</text>
<text style="color: orange;" v-if='item.type==2'>购买车辆</text>
</view>
</view>
<view class="li">
@ -272,7 +277,6 @@
<view class="slot-content">
<u--input placeholder="请输入内容" type="number" v-model="newCarNum"></u--input>
<view style="color: red;font-size: 20rpx;" v-show="novalue">
<view class="" v-if="newCarNum>datas.can_rent_num">
数量超过上限
</view>
@ -296,13 +300,16 @@
</template>
<script>
import {
FILE_URL_IM
} from "@/api/file.js"
import {
getvehicleListApi,
getAgencyListApi,
leaseApi,
upVehicleApi,
getAgencyDetailApi,
getvehicleDetailApi,
// getvehicleDetailApi,
villageCompanyApi,
} from "@/api/property.js"
@ -341,69 +348,54 @@
newcarTit: "",
flag: false,
showpopp: false,
};
},
onLoad() {
// if (true) {
// uni.navigateTo({
// url: '/subpkg/property/vehicle_a'
// })
// }
// getvehicleListApi().then(res => {
// console.log(res)
// // this.getvehicleList = res
// })
// getAgencyListApi().then(res => {
// // this.applicationList=res
// })
this.initIndex()
// this.initIndex()
setTimeout(() => {
this.flag = true
})
},
onShow() {
this.initIndex()
},
onPullDownRefresh() {
this.initIndex()
//
// setTimeout(() => {
// const newList = this.hostProduct.reverse();
// this.hostProduct = newList;
uni.stopPullDownRefresh();
// }, 500)
},
methods: {
//
initIndex() {
let type = (JSON.parse(Cache.get("USER_INFO")).company.company_type)
let type = this.$store.state.app.userInfo.company.company_type
this.company_type = type
//
if (type == 18) {
villageCompanyApi().then(res => {
this.showLoading = false
this.datas = res.data
this.step = res.data?.status || 9999
console.log(res.data?.id)
if (res.data?.id) {
this.step = res.data?.status
} else {
this.step = 9999
}
if (this.step == 3) {
uni.redirectTo({
url: `/subpkg/property/vehicle_a?id=${res.data.cars_info.id}`
})
}
})
}
//
else {
getvehicleListApi().then(res => {
this.datas = res.data
res.data.apply.length >= 2 ? this.applicationList = res.data.apply : this.applicationList =
res
.data.apply.slice(0, 2)
res.data.apply.slice(0, 2)
this.dataList = res.data.car_list
this.showLoading = false
})
@ -419,7 +411,7 @@
},
confirmFn() {
uni.reLaunch({
url: '/subpkg/property/index' //
url: '/subpkg/property/index'
});
},
@ -454,7 +446,6 @@
})
}, 2000)
})
this.show = false
this.noInfo = false
@ -556,7 +547,19 @@
position: fixed;
bottom: 110rpx;
left: 0;
// z-index: 9999999;
z-index: 1;
width: 100%;
border-radius: 0;
color: #fff;
height: 90rpx;
line-height: 90rpx;
background-color: $theme-oa-color;
}
.buyCar {
position: fixed;
bottom: 220rpx;
left: 0;
z-index: 1;
width: 100%;
border-radius: 0;

View File

@ -24,7 +24,9 @@
<view class="right">
<view class="li" style="display: flex;justify-content: space-between;">
<text>行驶总里程: {{datas.mileage}}</text>
<text v-if="datas.type" style="color: green;">自有车辆</text>
<text v-if="datas.type==2" style="color: green;">购买车辆</text>
<text v-if="datas.type==0" style="color: green;">租赁车辆</text>
<text v-if="datas.type==1" style="color: green;">自有车辆</text>
</view>
<view class="li">
<text>承租公司: </text>
@ -46,7 +48,7 @@
<text>签约时间: </text>
<text>{{datas.rent_time}} </text>
</view>
<view class="li" v-if="datas.type">
<view class="li" v-if="datas.type==1">
<text>到期时间: </text>
<text> {{overDateFn(datas.rent_time) }} </text>
</view>
@ -68,7 +70,10 @@
<u--image :showLoading="true" src="../../static/img/contract/pdf.png" width="80px"
height="80px"></u--image>
<view class="text">
<view class="name">租赁合同</view>
<view class="name" v-if="datas.type==0">租赁合同</view>
<view class="name" v-if="datas.type==1">自有车辆合同</view>
<view class="name" v-if="datas.type==2">购车合同</view>
<!-- <view class="name">购买合同</view> -->
<view>
<text>{{ datas.create_time}}</text>
</view>
@ -82,6 +87,12 @@
</view>
</view>
</view>
<mybtn text="购买车辆"
@click="navTo2(`/subpkg/property/buyCar?license=${datas.car_license}&type=${datas.type}`)"
v-if="company_type==18"></mybtn>
</view>
<web-view style="height: 100vh;" :src="pdfUrl" v-if="showPDF"></web-view>
@ -163,6 +174,16 @@
},
methods: {
navTo(url) {
uni.navigateTo({
url
})
},
navTo2(url) {
uni.redirectTo({
url
})
},
//
overDateFn(date) {
var specifiedDate = new Date(date);
@ -208,7 +229,7 @@
end_time: `${this.queryData} 23:59:59`,
start_time: `${this.queryData} 00:00:00`,
}).then(res => {
console.log(res.data)
// console.log(res.data)
this.markers[0].latitude = res.data[0].latitude
this.markers[0].longitude = res.data[0].longitude
this.polyline = [{

View File

@ -0,0 +1,259 @@
<template>
<view class="">
<view class="info">
<view class="bg"></view>
<view class="card">
<view class="title">充值信息</view>
<view class="item">
<text>充值账户</text>
<text>{{$store.state.app.userInfo.company.company_name||''}}</text>
</view>
<u-line style="margin: 20rpx 0;"></u-line>
<view class="item">
<text>收款公司</text>
<text>{{partyA.company_name}}</text>
</view>
<view class="item" @click="copyPhone(partyA.qualification.corporate_account, '对公账号')">
<text>对公账号</text>
<text>{{partyA.qualification.corporate_account||'暂无信息'}}</text>
</view>
</view>
</view>
<view class="deposit-list">
<view class="card" v-for="(item, index) in list">
<view class="item"><view>创建时间:</view><view class="text">{{item.create_time}}</view></view>
<view class="item"><view>充值金额:</view><view class="text green">{{item.deposit}}</view></view>
<view class="item" @click="previewVoucher(item.voucher)"><view>充值凭证:</view><view class="text blue">查看凭证</view></view>
</view>
</view>
<u-empty v-if="list.length==0&&loadConfig.status=='nomore'" icon="/static/img/empty/data.png" text="没有数据"></u-empty>
<u-loadmore v-else :status="loadConfig.status" :loading-text="loadConfig.loadingText"
:loadmore-text="loadConfig.loadmoreText" :nomore-text="loadConfig.nomoreText" />
</view>
</template>
<script>
import { Toast } from '@/libs/uniApi.js'
import { getPartyACompany, getDepositRechargeTransferVoucherList } from "@/api/company.js"
export default {
data() {
return {
partyA: {
id:"",
company_name:"",
qualification:{
corporate_account: ""
}
},
list: [],
loadConfig: {
page: 1,
limit: 15,
lastpage: '',
loadingText: '努力加载中',
loadmoreText: '轻轻上拉',
nomoreText: '我也是有底线的~~',
status: 'loadmore'
},
}
},
//
onNavigationBarButtonTap(res){
if (res.index === 0) {
uni.navigateTo({
url: '/subpkg/topUpList/topUpList'
})
}
},
onLoad(options) {
this.loadPartyACompany();
this.initLoad();
},
onReachBottom() {
this.loadList()
},
methods: {
async loadPartyACompany(){
let res = await getPartyACompany();
if(res.data.qualification){
try{
res.data.qualification = JSON.parse(res.data.qualification);
}catch(e){
console.log(e);
}
}
this.partyA = res.data;
if(!this.partyA.qualification.corporate_account)this.partyA.qualification.corporate_account="";
},
async initLoad() {
this.loadConfig.page = 1;
this.loadConfig.status = "loadmore";
this.list = [];
await this.loadList();
},
async loadList(){
if (this.loadConfig.status == "nomore") return;
this.loadConfig.status = "loading";
let res = await getDepositRechargeTransferVoucherList({
page: this.loadConfig.page,
limit: this.loadConfig.limit
})
this.loadConfig.status = "loadmore"
if (res.data.data.length < this.loadConfig.limit) {
this.loadConfig.status = "nomore"
} else {
this.loadConfig.page++;
}
this.list = [...this.list, ...res.data?.data]
},
previewVoucher(str=""){
if(str.substring(str.length-4, str.length)=='.pdf'){ // PDFPDF
uni.navigateTo({
url: `/subpkg/pdfView/pdfView?url=${str}`
})
}else {
uni.previewImage({
urls: [str],
longPressActions: {
itemList: ['保存图片'],
success: function(data) {
if (data.tapIndex === 0) {
uni.saveImageToPhotosAlbum({
filePath: url,
success: function() {
uni.showToast({
title: '保存成功',
icon: 'success'
})
},
fail: function() {
uni.showToast({
title: '保存失败',
icon: 'none'
})
}
})
}
}
}
})
}
},
copyPhone(str = "", type = "号码") {
if (str) uni.setClipboardData({
data: str + "",
success: (e) => {
Toast(type + '已复制')
},
fail: (e) => {
Toast('复制失败')
}
})
}
},
onPullDownRefresh() {
this.initLoad().then(()=>{
setTimeout(()=>{
uni.stopPullDownRefresh()
}, 500)
})
}
}
</script>
<style lang="scss">
page {
background-color: #fff;
}
.info {
display: flex;
flex-direction: column;
align-items: center;
position: relative;
height: 350rpx;
.bg {
background-color: $theme-oa-color;
height: 200rpx;
width: 100vw;
border-radius: 0rpx 0rpx 28rpx 28rpx;
position: absolute;
top: 0;
left: 0;
}
.card {
width: 694rpx;
min-height: 180rpx;
background: #FFFFFF;
margin-top: 38.55rpx;
box-shadow: 0rpx 0rpx 18rpx 2rpx rgba(50, 116, 249, 0.1);
border-radius: 14rpx 14rpx 14rpx 14rpx;
opacity: 1;
padding: 31.5rpx 28rpx;
display: flex;
flex-direction: column;
justify-content: space-around;
position: absolute;
top: 0;
.title {
font-size: 32rpx;
font-weight: 600;
color: #333333;
padding-bottom: 10rpx;
}
.item {
display: flex;
justify-content: space-between;
font-size: 32rpx;
font-weight: 400;
color: #333333;
text:nth-child(1){
flex-shrink: 0;
margin-right: 18rpx;
}
}
}
}
.deposit-list{
display: flex;
flex-direction: column;
align-items: center;
.card {
width: 694rpx;
min-height: 180rpx;
background: #FFFFFF;
margin-bottom: 28rpx;
box-shadow: 0rpx 0rpx 18rpx 2rpx rgba(50, 116, 249, 0.1);
border-radius: 14rpx 14rpx 14rpx 14rpx;
opacity: 1;
padding: 31.5rpx 28rpx;
display: flex;
flex-direction: column;
justify-content: space-around;
.item{
font-size: 28rpx;
display: flex;
justify-content: left;
.text{
margin-left: 12rpx;
color: #999;
}
.green{
color: #4cd964;
}
.blue{
color: #0122c7;
}
}
}
}
</style>

View File

@ -0,0 +1,334 @@
<template>
<view class="task_page">
<u-skeleton v-if="skeleton" :class="{'loading': skeleton}" :animate="true" title rows="5" rows-width="92%"
rowsHeight="56">
</u-skeleton>
<block v-else>
<view class="card">
<view class="c_title">{{`任务名称: ${taskInfo.title||''}`}}</view>
<view>{{taskInfo.content||''}}</view>
</view>
<view class="card" v-if="taskInfo.approve_status==3">
<view class="c_title" style="color: #FF7C32;">驳回提示</view>
<u-line style="margin: 14rpx 0;"></u-line>
<view class="text" style="color: #FF7C32;">{{taskInfo.deny_notes}}</view>
<button v-if="other.is_commit==1" class="btn" @click="toUpdate">去修改</button>
</view>
<view class="card">
<view class="c_title">任务完成证明</view>
<view class="file">
<view class="file_item" v-for="(item, index) in imgList" :key="'file'+index">
<image class="image" :src="item" @click="priview(index)"></image>
<image v-if="taskInfo.status==2 && other.is_commit==0" class="del" src="/static/icons/delete.png" @click.stop="deleteFile(index)">
</image>
</view>
<view v-if="taskInfo.status==2 && other.is_commit==0" class="file_btn" @click="chooseFile">
<image src="/static/icons/plus.png"></image>
</view>
<view class="file_empty" v-for="k in placeholderLength" :key="'empty'+k"></view>
</view>
</view>
<view class="card" style="margin-bottom: 160rpx;">
<view class="c_title">补充说明</view>
<u--textarea :disabled="taskInfo.status!=2 || other.is_commit==1" v-model="remark" placeholder="请输入内容"
placeholderStyle="font-size: 22rpx;" count maxlength="500" autoHeight
style="font-size: 28rpx;background-color: #eee;min-height: 100px;padding-bottom: 50rpx;"></u--textarea>
</view>
<mybtn v-if="taskInfo.status==2&&other.is_commit==0" text="确认提交" @click="$u.throttle(submit, 1500)"></mybtn>
<mybtn v-else-if="taskInfo.status==3" text="已完成" :my_btn_disabled="true" @click="showToast('任务已完成!')"></mybtn>
<mybtn v-else-if="taskInfo.status==5" text="已关闭" :my_btn_disabled="true" @click="showToast('任务已关闭!')"></mybtn>
<mybtn v-else-if="taskInfo.approve_status==3" text="已驳回,请重新提交" @click="toUpdate"></mybtn>
<mybtn v-else text="已提交,请等待审核" :my_btn_disabled="true" @click="showToast('请耐心等待审核结果')"></mybtn>
</block>
</view>
</template>
<script>
import {
upLoadImage,
} from "@/api/file.js";
import { Toast } from "../../libs/uniApi";
import { marketTask10Detail, marketTask10Commit } from "@/api/task.js"
export default {
data() {
return {
skeleton: true,
other: {
annex: [], //
is_commit: 0, //
note: "", //
video_annex: [] //
},
taskInfo: {
id: '',
title: '',
content: '',
extend: {},
status: 0
},
sign_in_table: '',
remark: '',
imgList: [], //
stage: 1, //
stage1: {},
stage2: {},
stage3: {},
stage4: {},
}
},
onLoad(options) {
options.task_id ? this.taskInfo.id = options.task_id : null;
options.stage ? this.stage = +options.stage : null;
this.initTask();
},
onShow() {},
computed: {
//
placeholderLength() {
if (this.taskInfo.status != 2||this.other.is_commit==1) return this.imgList.length % 3 == 0 ? 0 : 3 - this.imgList.length % 3;
return (this.imgList.length + 1) % 3 == 0 ? 0 : 3 - (this.imgList.length + 1) % 3;
},
},
methods: {
async initTask() {
this.skeleton = true;
let res = await marketTask10Detail({
id: this.taskInfo.id
});
// approve_status 0,1,2,3,4
this.taskInfo = res.data;
if(!this.taskInfo.approve_status)this.taskInfo.approve_status=0;
if(this.taskInfo?.extend?.stage){
//
if(this.taskInfo.extend.stage4?.is_commit==1)this.other.is_commit = 1;
else if(this.taskInfo.extend.stage3?.is_commit==1)this.other.is_commit = 1;
else if(this.taskInfo.extend.stage2?.is_commit==1)this.other.is_commit = 1;
else if(this.taskInfo.extend.stage1?.is_commit==1)this.other.is_commit = 1;
else this.other.is_commit = 0;
let task;
switch(+this.taskInfo?.extend?.stage){
case 1: task = this.taskInfo.extend.stage1;break;
case 2: task = this.taskInfo.extend.stage2;break;
case 3: task = this.taskInfo.extend.stage3;break;
case 4: task = this.taskInfo.extend.stage4;break;
}
this.imgList = task?.file||[];
this.remark = task?.remark;
}
// this.sign_in_table = this.taskInfo?.extend?.town_task_type_4?.sign_in_table;
// this.remark = this.taskInfo?.extend?.town_task_type_4?.remark;
// this.imgList = JSON.parse(JSON.stringify(this.taskInfo?.extend?.town_task_type_4?.imgList || []));
this.skeleton = false;
},
//
toUpdate() {
this.other.is_commit = 0;
},
// , true
isReject(){
if (this.taskInfo.approve_status == 3) { //
let other = {
file: this.imgList,
remark: this.remark
}
let flag = true;
if(JSON.stringify(other)==JSON.stringify({
file: this.taskInfo.extend.file,
remark: this.taskInfo.extend.remark
})) flag = false;
if (!flag) {
Toast('未检测到您的修改,请修改后提交')
}
return flag;
}
else return true;
},
//
async submit() {
if (this.imgList.length < 1) return Toast('证明数量不得小于1');
if(!this.isReject()) return;
let that = this;
switch (that.stage) {
case 1:
that.stage1 = { file: that.imgList, remark: that.remark };
break;
case 2:
that.stage2 = { file: that.imgList, remark: that.remark };
break;
case 3:
that.stage3 = { file: that.imgList, remark: that.remark };
break;
case 4:
that.stage4 = { file: that.imgList, remark: that.remark };
break;
}
await marketTask10Commit({
id: this.taskInfo.id,
stage: this.stage,
stage1: this.stage1,
stage2: this.stage2,
stage3: this.stage3,
stage4: this.stage4,
});
this.other.is_commit = 1;
Toast('提交成功');
uni.navigateBack();
},
showToast(str) {
Toast(str)
},
chooseFile() {
uni.chooseImage({
count: 9,
sizeType: ['compressed'],
success: async (res) => {
for (let item of res.tempFiles) {
let ul = await upLoadImage({
filePath: item.path,
name: 'file'
});
this.imgList.push(ul.data.uri);
}
}
});
},
priview(index) {
uni.previewImage({
urls: this.imgList,
current: index,
longPressActions: {
itemList: ['删除'],
itemColor: '#ff0000',
success(e) {
if (e.tapIndex == 0) this.deleteFile(e.index);
}
},
})
},
chooseOneFile() {
uni.chooseImage({
count: 1,
sizeType: ['compressed'],
success: async (res) => {
let ul = await upLoadImage({
filePath: res.tempFilePaths[0],
name: 'file'
});
this.sign_in_table = ul.data.uri;
}
});
},
priviewOne(index) {
uni.previewImage({
urls: [this.sign_in_table],
current: index,
longPressActions: {
itemList: ['删除'],
itemColor: '#ff0000',
success(e) {
if (e.tapIndex == 0) this.sign_in_table = '';
}
},
})
},
//
deleteFile(index) {
this.imgList.splice(index, 1);
},
},
}
</script>
<style lang="scss">
.task_page {
padding-top: 30rpx;
.card {
margin: 0 auto;
margin-bottom: 28rpx;
width: 694rpx;
background-color: #fff;
border-radius: 26rpx;
padding: 28rpx;
.c_title {
font-size: 32rpx;
font-weight: bold;
color: #333333;
margin-bottom: 20rpx;
}
.btn {
background-color: $theme-oa-color;
color: #FFFFFF;
font-size: 28rpx;
height: 60rpx;
line-height: 60rpx;
margin-top: 16rpx;
}
.file {
display: flex;
justify-content: left;
flex-wrap: wrap;
&_item {
flex-shrink: 0;
width: 200rpx;
height: 200rpx;
margin: 0 auto;
margin-bottom: 16rpx;
border: 2px solid #ccc;
border-radius: 10rpx;
overflow: hidden;
position: relative;
.image {
width: 100%;
height: 100%;
}
.del {
position: absolute;
height: 40rpx;
width: 40rpx;
top: 10rpx;
right: 10rpx;
}
}
&_btn {
flex-shrink: 0;
width: 200rpx;
height: 200rpx;
margin: 0 auto;
margin-bottom: 16rpx;
border: 2px solid #ccc;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
border-radius: 10rpx;
image {
width: 100rpx;
height: 100rpx;
}
}
&_empty {
flex-shrink: 0;
width: 200rpx;
height: 200rpx;
margin: 0 auto;
margin-bottom: 16rpx;
border: 2px solid transparent;
}
}
}
.loading {
padding: 28rpx;
}
}
</style>

View File

@ -57,7 +57,7 @@
upLoadImage,
} from "@/api/file.js";
import { Toast } from "../../libs/uniApi";
import { serviceTaskDetails, serviceTask4Commit } from "@/api/task.js"
import { townTaskDetails, serviceTask4Commit } from "@/api/task.js"
export default {
data() {
return {
@ -95,7 +95,7 @@
methods: {
async initTask() {
this.skeleton = true;
let res = await serviceTaskDetails({
let res = await townTaskDetails({
id: this.taskInfo.id
});
this.taskInfo = res.data;

View File

@ -18,7 +18,7 @@
<script>
import { Toast } from "../../libs/uniApi";
import { serviceTaskDetails } from "@/api/task.js"
import { townTaskDetails } from "@/api/task.js"
import { dictDataListsTypeValue } from "@/api/oaPbulic.js"
export default {
data() {
@ -30,23 +30,25 @@
extend: {}
},
remark: '',
skeleton: true
skeleton: true,
type_value: 'town_task_type', //
}
},
onLoad(options) {
options.task_id?this.taskInfo.id=options.task_id:null;
options.type_value?this.type_value=options.type_value:null;
this.initTask();
},
onShow() {},
methods: {
async initTask(){
this.skeleton = true;
let res = await serviceTaskDetails({
let res = await townTaskDetails({
id: this.taskInfo.id
});
this.taskInfo = res.data;
let dict = await dictDataListsTypeValue({
type_value: 'town_task_type'
type_value: this.type_value
})
dict.data.forEach((item)=>{
if(item.id==this.taskInfo.type){

127
utils/aa.js Normal file
View File

@ -0,0 +1,127 @@
import {
HTTP_REQUEST_URL_THREE,
HEADER,
TOKENNAME,
} from '@/config/app';
import {
Toast
} from '../libs/uniApi';
// import { checkLogin } from '../libs/login';
import store from '../store';
function toLogin() {
uni.showToast({
title: '请先登录',
icon: 'none',
duration: 1000
});
}
function baseRequestTwo(url, method, data, {
noAuth = false,
noVerify = false,
onReLogin = false
}) {
let Url = HTTP_REQUEST_URL_THREE,
header = HEADER;
if (!noAuth) {
// 已经未登录了,禁止请求
if (!store.state.config.request) return Promise.reject({
msg: '未登录'
});
//登录过期自动登录
if (!store.state.app.token) {
toLogin();
store.commit("SET_REQUEST", false);
return Promise.reject({
msg: '未登录'
});
}
}
// if (store.state.app.token) header[TOKENNAME] = 'Bearer ' + store.state.app.token;
if (store.state.app.token) header[TOKENNAME] = store.state.app.token;
// header[TOKENNAME] = 'Bearer sdjflidshjgfkbdasgjmasbgvhauuiavhkesvndkaesbvkjsdbv';
return new Promise((reslove, reject) => {
// uni.showLoading({
// title: '加载中'
// })
uni.request({
// url: Url + '/api/v1' + url,
url: Url + url,
method: method || 'GET',
header: {
...header
},
data: method != 'GET' ? data || {} : {},
params: method == 'GET' ? data : {},
success: (res) => {
if (noVerify)
reslove(res.data);
else if (res.data.code == -1) {
if(onReLogin) {
store.commit('LOGOUT');
return reject();
}
// 如果登录超时,自动重新登录并且继续发送请求
store.dispatch("RE_LOGIN", {
url: url,
method: method,
data: data,
opt: {
noAuth,
noVerify
}
}).then((e)=>{
reslove(e);
}).catch((err)=>{
reject(res.data);
})
// store.commit("SET_REQUEST", false);
} else if (res.data.code == 0) {
if (res.data.msg != '无登录信息') {
uni.showToast({
title: res.data.msg || '请检查网络',
icon: 'none',
})
}
reject(res.data);
} else if (res.data.code == 1) {
store.commit("SET_REQUEST");
reslove(res.data);
} else if (res.data.code == 200) {
store.commit("SET_REQUEST");
reslove(res.data.data);
} else if ([410000, 410001, 410002, 40000].indexOf(res.data.code) !== -1) {
toLogin();
reject(res.data);
} else if (res.data.code == 501) {
reject(res.data);
} else {
uni.showToast({
title: res.data.msg || '请检查网络',
icon: 'none'
})
reject(res.data.msg || '请检查网络');
}
},
fail: (message) => {
// uni.hideLoading()
uni.showToast({
title: '网络错误',
icon: 'none'
})
reject('请求失败');
}
})
});
}
const oahttp = {};
['options', 'get', 'post', 'put', 'head', 'delete', 'trace', 'connect'].forEach((method) => {
oahttp[method] = (api, data, opt) => baseRequestTwo(api, method, data, opt || {})
});
export default oahttp;