daoji_h5/technician/pages/order/list.vue

914 lines
23 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="order-pages">
<view class="fix" style="top:-100%;left:-100%">
<!-- <min-countdown @end="toCountDownEnd(item.id)" :targetTime="item.start_service_time_unix * 1000"
:isPlay="true" v-for="(item,index) in unix_list" :key="index">
</min-countdown> -->
</view>
<fixed>
<tab @change="handerTabChange" :list="tabList" :activeIndex="activeIndex*1" :activeColor="primaryColor"
:width="100/tabList.length + '%'" height="100rpx"></tab>
<view class="b-1px-b"></view>
</fixed>
<view @tap.stop="goDetail(index)" class="item-child mt-md ml-lg mr-lg pd-lg fill-base radius-16 rel"
v-for="(item,index) in list.data" :key="index">
<view v-if="item.is_add">
<view class="bell-tag flex-center f-icontext c-base abs" :style="{background:primaryColor}">加钟服务
</view>
<view class="space-md"></view>
</view>
<view @tap.stop="goShop(index)" class="flex-between pb-lg">
<view class="f-paragraph c-title max-500 ellipsis">订单号:{{item.order_code}}</view>
<view class="f-caption text-bold"
:style="{color:item.pay_type==2?primaryColor: [3,4,5].includes(item.pay_type)?subColor: item.pay_type == 6 ? '#11C95E' : '#333'}">
{{statusType[item.pay_type]}}
</view>
</view>
<view class="flex-center mb-lg" v-for="(aitem,aindex) in item.order_goods" :key="aindex">
<!-- #ifdef H5 -->
<view class="avatar lg radius-16">
<view class="h5-image avatar lg radius-16"
:style="{ backgroundImage : `url('${aitem.goods_cover}')`}">
</view>
</view>
<!-- #endif -->
<!-- #ifndef H5 -->
<image mode="aspectFill" class="avatar lg radius-16" :src="aitem.goods_cover"></image>
<!-- #endif -->
<view class="flex-1 ml-md">
<view class="flex-between">
<view class="f-mini-title c-title text-bold ellipsis"
:class="[{'max-300':aitem.refund_num>0},{'max-450':aitem.refund_num==0}]">
{{aitem.goods_name}}
</view>
<view class="f-caption c-warning" v-if="aitem.refund_num>0">已退x{{aitem.refund_num}}</view>
</view>
<view class="f-caption c-caption mt-md">服务时间:{{item.start_time}}</view>
<view class="flex-between">
<view class="flex-y-baseline f-caption c-warning">¥<view class="f-title text-bold">
{{aitem.price}}
</view>
</view>
<view class="c-paragraph">x{{aitem.num}}</view>
</view>
</view>
</view>
<view class="flex-between pt-lg b-1px-t">
<view class="flex-y-center f-desc c-title">总计:
<view class="f-paragraph c-warning text-bold">¥{{item.pay_price}}</view>
</view>
<view class="flex-warp">
<!-- // pay_type 2待接单5待服务6服务中7服务完成 -->
<!-- 待接单 -->
<block v-if="item.pay_type == 2">
<button @tap.stop="toRefuse(index)" class="clear-btn order">拒绝接单</button>
<button @tap.stop="toConfirm(index,3)" class="clear-btn order"
:style="{color:'#fff',background:primaryColor,borderColor:primaryColor}">确认接单</button>
</block>
<!-- 待服务 -->
<block v-if="[3,4,5].includes(item.pay_type)">
<button @tap.stop="toTel(index)" class="clear-btn order">联系客户</button>
<button @tap.stop="toConfirm(index, item.is_add || item.store_id ? 6 : item.pay_type*1+1 )"
class="clear-btn order"
:style="{color:'#fff',background:primaryColor,borderColor:primaryColor}">{{item.is_add || item.store_id ? '开始服务' : item.pay_type == 3 ? '已出发': item.pay_type == 4 ?'拍照确认到达' : '开始服务'}}</button>
</block>
<!-- 服务中 -->
<block v-if="item.pay_type == 6">
<button @tap.stop="toTel(index)" class="clear-btn order">联系客户</button>
<button @tap.stop="toConfirm(index,7)" class="clear-btn order"
:style="{color:'#fff',background:primaryColor,borderColor:primaryColor}">拍照完成服务</button>
</block>
<!-- 已完成 -->
<block v-if="item.pay_type == 7">
<button @tap.stop="toShield(index)" class="clear-btn order" v-if="item.can_shield">屏蔽Ta</button>
<button
@tap.stop="$util.goUrl({url:`/technician/pages/order/label?id=${item.id}&uid=${item.user_id}`})"
class="clear-btn order"
:style="{color:'#fff',background:primaryColor,borderColor:primaryColor}"
v-if="!item.is_add && !item.label_time">评价客户</button>
</block>
</view>
</view>
</view>
<load-more :noMore="list.current_page>=list.last_page&&list.data.length>0" :loading="loading" v-if="loading">
</load-more>
<abnor v-if="!loading&&list.data.length<=0&&list.current_page==1"></abnor>
<view class="space-footer"></view>
<uni-popup ref="refuse_item" type="center" :custom="true">
<view class="common-popup-content fill-base pd-lg radius-34">
<view class="title">拒绝接单</view>
<view class="desc">请确认是否拒接接单</view>
<textarea v-model="coach_refund_text" class="pd-lg textarea f-desc c-title mt-lg radius-20"
maxlength="200" placeholder="请输入拒单原因" placeholder-class="f-desc c-caption"></textarea>
<view class="flex-center mt-md" style="width: 540rpx">
<view class="flex-1"></view>
<view>{{coach_refund_text.length>200?200:coach_refund_text.length}}/200</view>
</view>
<view class="button">
<view @tap.stop="$refs.refuse_item.close()" class="item-child">取消</view>
<view @tap.stop="confirmRefuse" class="item-child c-base"
:style="{background: primaryColor,color:'#fff'}">确定</view>
</view>
</view>
</uni-popup>
<uni-popup ref="oper_item" type="center" :custom="true">
<view class="common-popup-content fill-base pd-lg radius-34">
<view class="title">{{popupInfo.title}}</view>
<view class="space-md"></view>
<view class="flex-warp mt-md" style="width: 100%;" v-if="popupInfo.type !== 4">
<view>拍照打卡:</view>
<view class="flex-1">
<upload @upload="imgUpload" @del="imgUpload" :imagelist="popupInfo.imgs" filetype="picture"
imgtype="imgs" text="拍摄图片" :imgsize="1" :sourceType="2">
</upload>
</view>
</view>
<view class="flex-warp mt-md" style="width: 100%;">
<view>当前地点:</view>
<view @tap.stop="toGetLocation" class="flex-1"
:class="[{'c-title':popupInfo.location.address},{'c-caption':!popupInfo.location.address}]">
{{popupInfo.location.address || '点击获取定位'}}
</view>
</view>
<view class="button">
<view @tap.stop="$refs.oper_item.close()" class="item-child">取消</view>
<view @tap.stop="confirmOper" class="item-child c-base"
:style="{background: primaryColor,color:'#fff'}">确定</view>
</view>
</view>
</uni-popup>
<uni-popup ref="shield_item" type="center" :custom="true">
<view class="common-popup-content fill-base pd-lg radius-34">
<view class="title">温馨提示</view>
<view class="desc">屏蔽客户之后该客户将不能在列表看到您的信息会影响你的接单可以在{{$t('action.attendantName')}} -
屏蔽客户页面移除屏蔽客户确认屏蔽吗</view>
<view class="button">
<view @tap.stop="$refs.shield_item.close()" class="item-child">我再想想</view>
<view @tap.stop="confirmShield" class="item-child c-base"
:style="{background: primaryColor,color:'#fff'}">确定</view>
</view>
</view>
</uni-popup>
<!-- #ifdef H5 -->
<!-- <block v-if="configInfo.plugAuth.recording && configInfo.service_recording_show">
<mumu-recorder ref="recorder" @success='handlerSuccess' @error='handlerError'></mumu-recorder>
</block> -->
<!-- #endif -->
</view>
</template>
<script>
import {
mapState,
mapActions,
mapMutations
} from "vuex"
// #ifdef H5
// import MumuRecorder from '@/uni_modules/mumu-recorder/components/mumu-recorder/mumu-recorder.vue'
// #endif
// #ifndef H5
var recorderManager = null;
var timer = null
// #endif
export default {
components: {
// #ifdef H5
// MumuRecorder
// #endif
},
data() {
return {
options: {},
activeIndex: 0,
tabList: [{
// title: '全部',
// id: 0
// }, {
title: '待接单',
id: 2,
number: 0
}, {
title: '待服务',
id: 5,
number: 0
}, {
title: '服务中',
id: 6,
number: 0
}, {
title: '已完成',
id: 7,
number: 0
}],
statusType: {
2: '待接单',
3: '已接单',
4: '已出发',
5: '已到达',
6: '服务中',
7: '已完成',
8: '待转单'
},
param: {
page: 1,
pay_type: 0,
},
list: {
data: []
},
loading: true,
index: -1,
coach_refund_text: '',
lockTap: false,
popupInfo: {
title: '',
index: '',
type: '',
param: {},
imgs: [],
location: {
lat: 0,
lng: 0,
address: ''
}
},
unix_list: [],
// #ifndef H5
isReset: false,
duration_time: 600,
duration: ''
// #endif
}
},
computed: mapState({
primaryColor: state => state.config.configInfo.primaryColor,
subColor: state => state.config.configInfo.subColor,
configInfo: state => state.config.configInfo,
// recorder: state => state.order.recorder,
// recorder_status: state => state.order.recorder_status,
// recorder_order_id: state => state.order.recorder_order_id,
}),
async onLoad(options) {
this.options = options
let {
tab = 0
} = options
this.activeIndex = tab
this.initIndex()
},
onPullDownRefresh() {
// #ifndef APP-PLUS
uni.showNavigationBarLoading()
// #endif
this.initRefresh();
uni.stopPullDownRefresh()
},
onReachBottom() {
if (this.list.current_page >= this.list.last_page || this.loading) return;
this.param.page = this.param.page + 1;
this.loading = true;
this.getList();
},
methods: {
...mapActions(['getConfigInfo', 'getCoachInfo', 'toPlayAudio']),
...mapMutations(['updateOrderItem']),
async initIndex(refresh = false) {
// #ifdef H5
if (!refresh && this.$jweixin.isWechat()) {
await this.$jweixin.initJssdk();
this.$jweixin.wxReady(() => {
this.$jweixin.hideOptionMenu()
})
}
// #endif
if (!this.configInfo.id || refresh) {
await this.getConfigInfo()
}
await this.getList()
this.$util.setNavigationBarColor({
bg: this.primaryColor
})
if (refresh) return
// #ifndef H5
// recorderManager = uni.getRecorderManager()
// //开始录音
// recorderManager.onStart(() => {
// this.$util.log('开始录音')
// this.recordingTimer()
// })
// //结束录音
// recorderManager.onStop((res) => {
// this.$util.log('结束录音', res)
// this.handlerOnSave(res)
// this.recordingTimer(false)
// let {
// duration
// } = res
// let currentTime = parseInt(duration / 1000)
// let isReset = this.duration_time * 1 - currentTime > 1 ? false : true
// // console.log(this.duration_time, currentTime, isReset, "===========hhhhhhhhhhhh")
// this.isReset = isReset
// if (isReset) {
// this.handlerOnChanger()
// }
// })
// // 录音异常
// recorderManager.onError((e) => {
// this.$util.log('录音异常', e)
// this.updateOrderItem({
// key: 'recorder_status',
// val: false
// })
// })
// #endif
},
initRefresh() {
uni.pageScrollTo({
duration: 0,
scrollTop: 0
})
this.param.page = 1
this.initIndex(true)
},
async getList(flag = false) {
let {
list: oldList,
param,
tabList,
activeIndex
} = this
param.pay_type = tabList[activeIndex].id
let newList = await this.$api.technician.orderList(param)
if (!flag) {
if (this.param.page == 1) {
this.list = newList
} else {
newList.data = oldList.data.concat(newList.data)
this.list = newList
}
}
this.tabList[0].number = newList.agent_order_count
this.tabList[1].number = newList.wait_order_count
this.tabList[2].number = newList.service_order_count
this.loading = false
this.$util.hideAll()
},
handerTabChange(index) {
this.activeIndex = index;
this.$util.showLoading()
this.param.page = 1;
this.getList()
},
// 开始录音
async handlerOnChanger() {
// #ifndef H5
await this.$util.checkAuth({
type: "record"
});
// #endif
let {
recorder_status,
duration_time
} = this
if (recorder_status) {
// #ifdef H5
this.$refs.recorder.stop()
// #endif
// #ifndef H5
recorderManager.stop()
// #endif
} else {
// #ifdef H5
this.$refs.recorder.start()
// #endif
// #ifndef H5
recorderManager.start({
format: 'mp3',
duration: duration_time * 1000,
})
// #endif
}
this.updateOrderItem({
key: 'recorder_status',
val: !recorder_status
})
},
async handlerOnEnd() {
// #ifdef H5
this.$refs.recorder.stop()
setTimeout(() => {
this.handlerOnSave()
}, 200)
// #endif
// #ifndef H5
recorderManager.stop()
// #endif
this.updateOrderItem({
key: 'recorder_status',
val: false
})
},
async handlerOnSave(res = {}) {
let filePath = ''
let unix = parseInt(new Date().getTime() / 1000)
let name = `服务过程录音-${unix}.mp3`
// #ifdef H5
let {
localUrl
} = this.recorder
filePath = localUrl
// #endif
// #ifndef H5
let {
tempFilePath,
} = res
filePath = tempFilePath
// #endif
let {
attachment_path: link
} = await this.$api.base.uploadFile({
filePath,
formData: {
type: 'audio',
name
}
})
let {
recorder_order_id: order_id
} = this
await this.$api.technician.recordingAdd({
order_id,
link
})
this.updateOrderItem({
key: 'recorder_order_id',
val: 0
})
// #ifdef H5
this.$refs.recorder.chunks = []
// #endif
},
// #ifdef H5
handlerSuccess(res) {
this.updateOrderItem({
key: 'recorder',
val: res
})
},
handlerError(code) {
switch (code) {
case '101':
uni.showModal({
content: '当前浏览器版本较低,请更换浏览器使用,推荐在微信中打开。'
})
break;
case '201':
uni.showModal({
content: '麦克风权限被拒绝,请刷新页面后授权麦克风权限。'
})
break
default:
uni.showModal({
content: '未知错误,请刷新页面重试'
})
break
}
},
// #endif
// #ifndef H5
recordingTimer(flag = true) {
if (flag) {
//将计时器赋值给timer
if (timer) return
timer = setInterval(() => {
let {
duration
} = this
duration++
// console.log(timer, duration, "======duration")
this.duration = duration
}, 1000);
} else {
clearInterval(timer)
timer = null
console.log("暂停计时 recordingTimer", timer)
}
},
// #endif
// 服务倒计时结束
toCountDownEnd(id) {
let {
recorder_status,
recorder_order_id
} = this
if (recorder_order_id == id && recorder_status) {
this.handlerOnEnd()
}
},
// 拒绝接单
async toRefuse(index) {
this.index = index
this.coach_refund_text = ''
this.$refs.refuse_item.open()
},
// 确认:拒绝接单
async confirmRefuse() {
let {
coach_refund_text
} = this
coach_refund_text = coach_refund_text.length > 0 ? coach_refund_text.replace(/(^\s*)|(\s*$)/g, "") : ''
if (coach_refund_text.length == 0) {
this.$util.showToast({
title: `请输入拒单原因`
})
return
}
this.coach_refund_text = this.coach_refund_text.substring(0, 200)
let {
index,
} = this
this.toConfirm(index, -1)
},
// 获取定位
async toGetLocation() {
let {
lat: loca_lat = 0,
lng: loca_lng = 0,
address: loca_addr = ''
} = this.popupInfo
if (loca_lat && loca_lng && loca_addr) return
// #ifdef H5
if (this.$jweixin.isWechat()) {
this.$util.showLoading()
await this.$jweixin.wxReady2();
let {
latitude: lat = 0,
longitude: lng = 0
} = await this.$jweixin.getWxLocation()
if (!lat) {
this.$util.hideAll()
this.$util.showToast({
title: `请授权定位当前地址`
})
return
}
if (lat && lng) {
let key = `${lat},${lng}`
let data = await this.$api.base.getMapInfo({
location: key
})
let {
status,
result
} = JSON.parse(data)
if (status == 0) {
this.$util.hideAll()
let {
address
} = result
this.popupInfo.location = {
lat,
lng,
address
}
}
}
}
// #endif
// #ifndef H5
this.$util.showLoading()
let {
lat = '',
lng = '',
address = ''
} = await this.$util.getBmapLocation()
if (!lat) {
this.$util.hideAll()
this.$util.showToast({
title: `请授权定位当前地址`
})
return
}
this.popupInfo.location = {
lat,
lng,
address
}
this.$util.hideAll()
// #endif
},
imgUpload(e) {
let {
imagelist,
imgtype
} = e;
this.popupInfo[imgtype] = imagelist;
},
// 确认: 4已出发/5已到达/7服务完成
confirmOper() {
let popupInfo = this.$util.deepCopy(this.popupInfo)
let {
index,
type,
param,
imgs,
location
} = popupInfo
let {
lat = 0, lng = 0, address = ''
} = location
if ([5, 7].includes(type) && imgs.length === 0) {
this.$util.showToast({
title: `请先拍照`
})
return
}
if (!lat && !lng && !address) {
this.$util.showToast({
title: `请先获取当前定位地址`
})
return
}
if ([5, 7].includes(type)) {
let {
path
} = imgs[0]
location.path = path
}
this.toConfirmUpdate(index, type, param, location)
},
// type: -1拒绝接单3确定接单4已出发5已到达6开始服务7服务完成
async toConfirm(index, type) {
let {
id: order_id,
} = this.list.data[index]
let param = {
order_id,
type,
}
if (type == -1) {
param.coach_refund_text = this.coach_refund_text
}
if ([4, 5, 7].includes(type)) {
let arr = {
4: '确认出发',
5: '确认到达',
7: '确认完成',
}
let title = arr[type]
this.popupInfo = Object.assign({}, this.popupInfo, {
title,
index,
type,
param,
imgs: [],
location: {
lat: 0,
lng: 0,
address: ''
}
})
// #ifndef MP-WEIXIN
await this.toGetLocation()
// #endif
this.$refs.oper_item.open()
} else {
this.toConfirmUpdate(index, type, param)
}
},
async toConfirmUpdate(index, type, param, location = {}) {
if ([4, 5, 7].includes(type)) {
let {
lat,
lng,
address,
path
} = location
if (type === 4) {
param.serout_lat = lat
param.serout_lng = lng
param.serout_address = address
}
if (type == 5) {
param.arrive_img = path
param.arr_lat = lat
param.arr_lng = lng
param.arr_address = address
}
if (type == 7) {
param.end_img = path
param.end_lat = lat
param.end_lng = lng
param.end_address = address
}
}
let msg = {
'-1': '已拒绝接单',
3: '接单成功',
4: '已成功出发',
5: '已成功到达',
6: '已开始服务',
7: '服务已完成'
}
if (this.lockTap) return;
// this.lockTap = true;
this.$util.showLoading()
let {
plugAuth,
service_recording_show
} = this.configInfo
let {
recording
} = plugAuth
let {
recorder_order_id,
recorder_status
} = this
let flag = true
// if (type === 6 && recorder_order_id && recorder_status) {
// let [res_del, {
// confirm
// }] = await uni.showModal({
// title: '提示',
// content: "已有开始的服务还未结束录音,请确认是否完成录音并开始新的服务?"
// })
// if (confirm) {
// this.handlerOnEnd()
// } else {
// flag = false
// }
// }
// if (!flag) {
// this.lockTap = false
// this.$util.hideAll()
// return
// }
let {
order_id
} = param
try {
await this.$api.technician.updateOrder(param)
if (type == -1) {
this.$refs.refuse_item.close()
}
if ([4, 5, 7].includes(type)) {
this.$refs.oper_item.close()
}
this.$util.showToast({
title: msg[type]
})
if (type == 4 || type == 5) {
this.list.data[index].pay_type = type
} else {
this.list.data.splice(index, 1)
if (type == 7) {
await this.getCoachInfo()
}
}
this.lockTap = false;
this.$util.hideAll()
if (type == 6) {
// this.toPlayAudio({
// key: 'service_start_recording'
// })
// if (recording && service_recording_show) {
// let [res_del, {
// confirm
// }] = await uni.showModal({
// title: '提示',
// content: "服务过程将自动录音,直至服务结束!",
// showCancel: false,
// confirmText: '知道了'
// })
// if (confirm) {
// this.handlerOnChanger()
// this.updateOrderItem({
// key: 'recorder_order_id',
// val: order_id
// })
// }
// }
let {
time_long,
start_service_time
} = await this.$api.technician.orderInfo({
id: order_id
})
let start_service_time_unix = this.$util.DateToUnix(start_service_time) +
time_long * 60
this.unix_list.push({
id: order_id,
time_long,
start_service_time,
start_service_time_unix
})
}
if (type == 7) {
if (recorder_order_id == order_id && recorder_status) {
// this.handlerOnEnd()
}
let ind = this.unix_list.findIndex(item => {
return item.id == order_id
})
if (ind !== -1) {
this.unix_list.splice(ind, 1)
}
}
await this.getList(true)
} catch (e) {
setTimeout(() => {
this.lockTap = false
this.$util.hideAll()
}, 2000)
return
}
},
// 屏蔽用户
toShield(index) {
this.index = index
this.$refs.shield_item.open()
},
// 确认:屏蔽用户
async confirmShield() {
let {
index
} = this
if (this.lockTap) return;
this.lockTap = true;
this.$util.showLoading()
let {
user_id
} = this.list.data[index]
try {
await this.$api.technician.shieldUserAdd({
user_id
})
this.lockTap = false
this.$util.hideAll()
this.$refs.shield_item.close()
this.$util.showToast({
title: `屏蔽成功`
})
this.initRefresh()
} catch (e) {
setTimeout(() => {
this.lockTap = false
this.$util.hideAll()
}, 2000)
}
},
// 联系客户
async toTel(index) {
let {
id
} = this.list.data[index]
let url = await this.$api.technician.getVirtualPhone({
order_id: id
})
this.$util.goUrl({
url,
openType: `call`
})
},
// 订单详情
goDetail(index) {
let {
id
} = this.list.data[index]
let url = `/technician/pages/order/detail?id=${id}`
this.$util.goUrl({
url
})
}
}
}
</script>
<style lang="scss">
</style>