Commit 6a97f680 authored by Facius's avatar Facius

Merge branch 'dev-1.4.5' into test

parents 7a3f1140 8d17eb09
;(function() {
let NODE_ENV = 'test' // dev:开发环境 | test:测试环境 | prod:生产环境
let ENV_VAR = null
let VERSION_NUMBER = '1.4.0' //版本号
let VERSION_NUMBER = '1.4.1' //版本号
//小程序是否审核通过,参数配置在ucenter库version表,对应版本号的is_audit设置为1,将显示学习视频
if (process.env.NODE_ENV === 'development') {
if (NODE_ENV === 'dev') {
......
<!-- 预约时间 -->
<template>
<view :class="{'con-box':titleShow}">
<view class="title" v-if="titleShow">{{ title }}</view>
<view class="u-m-t-40">
<view class="appoint-box">
<view class="select-date">
<view class="u-flex u-row-between ">
<view class="txt">选择日期:</view>
<view class="txt active">{{appointTime | datefmt('YYYY.MM.DD')}}</view>
</view>
<view class="u-m-t-30 u-flex u-row-between date-list">
<view v-show="hasLast" class="last" @click="lastWeek(dateList[0],dateList)">
<u-icon name="arrow-left" color="#2979ff" size="28"></u-icon>
</view>
<view class="u-flex u-row-between date-box">
<view :class="{'date-item':true,'active':item.day===appointTime}"
@click="dateChange(item,index,dateList)" v-for="(item,index) in dateList" :key="index">
<text class="day">{{ weekFmt(item.day)}}</text>
<text class="day day1">{{ item.day | datefmt('DD')}}</text>
</view>
</view>
<view class="next" @click="nextWeek(dateList[0],dateList)">
<u-icon name="arrow-right" color="#2979ff" size="28"></u-icon>
</view>
</view>
</view>
<!-- weekChange -->
<view class="select-time u-m-t-50">
<view class="u-flex u-row-between">
<view class="txt">选择时间:</view>
<view class="txt active">{{ appointRangeText }}</view>
</view>
<view class="u-m-t-30 time-list">
<view
:class="{'time-item':true,'active': item.pkey===appointRange}" v-for="(item,index) in timeList"
:key="item.pkey">
<button class="time" :plain="true"
:disabled="item.disabled || (currentDayIndex == 0 && item.pkey.replace(/[^0-9]/ig,'') <= currentPkey && needTodyClipping)" :hair-line="false"
@click="timeChange(item,index,timeList)">
{{item.name}}
</button>
</view>
</view>
</view>
</view>
</view>
</view>
<view :class="{ 'con-box': titleShow }">
<view class="title" v-if="titleShow">{{ title }}</view>
<view class="u-m-t-40">
<view class="appoint-box">
<view class="select-date">
<view class="u-flex u-row-between ">
<view class="txt">选择日期:</view>
<view class="txt active">{{
appointTime | datefmt('YYYY.MM.DD')
}}</view>
</view>
<view class="u-m-t-30 u-flex u-row-between date-list">
<view
v-show="hasLast"
class="last"
@click="lastWeek(dateList[0], dateList)"
>
<u-icon name="arrow-left" color="#2979ff" size="28"></u-icon>
</view>
<view class="u-flex u-row-between date-box">
<view
:class="{ 'date-item': true, active: item.day === appointTime }"
@click="dateChange(item, index, dateList)"
v-for="(item, index) in dateList"
:key="index"
>
<text class="day">{{ weekFmt(item.day) }}</text>
<text class="day day1">{{ item.day | datefmt('DD') }}</text>
</view>
</view>
<view class="next" @click="nextWeek(dateList[0], dateList)">
<u-icon name="arrow-right" color="#2979ff" size="28"></u-icon>
</view>
</view>
</view>
<!-- weekChange -->
<view class="select-time u-m-t-50">
<view class="u-flex u-row-between">
<view class="txt">选择时间:</view>
<view class="txt active">{{ appointRangeText }}</view>
</view>
<view class="u-m-t-30 time-list">
<view
:class="{ 'time-item': true, active: item.pkey === appointRange }"
v-for="(item, index) in timeList"
:key="item.pkey"
>
<button
class="time"
:plain="true"
:disabled="
item.disabled ||
(currentDayIndex == 0 &&
item.pkey.replace(/[^0-9]/gi, '') <= currentPkey &&
needTodyClipping)
"
:hair-line="false"
@click="timeChange(item, index, timeList)"
>
{{ item.name }}
</button>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
let now = new Date(new Date().toLocaleDateString()).getTime()
export default {
props: {
titleShow: {
type: Boolean,
default: true
},
title: {
type: String,
default(){
return "预约时间"
}
},
type: { // subscribe 预约; filing 报备
type: String,
default: 'subscribe'
},
dateList: {
type: Array,
default(){
return [
{day: now, timeRange: []},
{day: now + (1*86400000), timeRange: []},
{day: now + (2*86400000), timeRange: []},
{day: now + (3*86400000), timeRange: []},
{day: now + (4*86400000), timeRange: []},
{day: now + (5*86400000), timeRange: []},
{day: now + (6*86400000), timeRange: []},
]
}
},
timeList: {
type: Array,
default(){
return [
{"name":"06:00-08:00","pkey":"appointment_range_8","disabled":false},
{"name":"08:00-10:00","pkey":"appointment_range_10","disabled":false},
{"name":"10:00-12:00","pkey":"appointment_range_12","disabled":false},
{"name":"12:00-14:00","pkey":"appointment_range_14","disabled":false},
{"name":"14:00-16:00","pkey":"appointment_range_16","disabled":false},
{"name":"16:00-18:00","pkey":"appointment_range_18","disabled":false},
{"name":"18:00-20:00","pkey":"appointment_range_20","disabled":false},
{"name":"20:00-22:00","pkey":"appointment_range_22","disabled":false},
{"name":"22:00-24:00","pkey":"appointment_range_24","disabled":false}
]
}
},
defaultAppointRangeItem: {
type: Object,
default() {
// return {"name":"22:00-24:00","pkey":"appointment_range_24","disabled":false}
return {}
}
}
},
data() {
return {
appointTime: null,
appointRange: null,
appointRangeText: '',
num: 0,
hasLast: false,
currentPkey: new Date().getHours(),
currentDayIndex: -1,
}
},
watch: {
title() {
this.appointTime = null
this.appointRange = null
this.appointRangeText = ''
this.currentDayIndex = -1
}
},
computed: {
needTodyClipping() { // 报备不限制当天已经过去的时间
return this.type != 'filing'
}
},
methods: {
getDateList() {
// 获取日期
},
async dateChange(item, index, list) {
let data = {
item,
index,
list,
}
this.appointTime = item.day
this.initAppointRange()
this.currentDayIndex = index
this.$emit('date-change', data)
if (this.appointRange) {
this.$emit('time-change', {item:{pkey:this.appointRange, name:this.appointRangeText}})
}
},
timeChange(item, index, list) {
let data = {
item,
index,
list,
}
this.appointRange = item.pkey
this.appointRangeText = item.name
this.$emit('time-change', data)
},
weekChange(item, index, list) {
let data = {
item,
index,
list,
}
this.$emit('week-change', data)
},
lastWeek(item, list) {
if(this.num > 0) {
this.num --
let len = list.length
if(this.num == 0) {
this.hasLast = false
len ++
}
let time = item.day - len*86400000
let data = {
time: time,
num: this.num
}
this.$emit('week-change', data)
}
},
nextWeek(item, list) {
this.hasLast = true
this.num ++
let len = list.length
let time = item.day + len*86400000
let data = {
time: time,
num: this.num
}
this.$emit('week-change', data)
},
weekFmt(day) {
let morrow = this.moment(now).add(1, 'days')
let content
if(day == now) {
content = '今天'
} else if(day == morrow) {
content = '明天'
} else {
content = this.moment(day).format('周dd')
}
return content
},
initAppointRange() {
this.appointRange = this.defaultAppointRangeItem.pkey
this.appointRangeText = this.defaultAppointRangeItem.name
}
}
}
let now = new Date(new Date().toLocaleDateString()).getTime()
export default {
props: {
titleShow: {
type: Boolean,
default: true,
},
title: {
type: String,
default() {
return '预约时间'
},
},
type: {
// subscribe 预约; filing 报备
type: String,
default: 'subscribe',
},
dateList: {
type: Array,
default() {
return [
{ day: now, timeRange: [] },
{ day: now + 1 * 86400000, timeRange: [] },
{ day: now + 2 * 86400000, timeRange: [] },
{ day: now + 3 * 86400000, timeRange: [] },
{ day: now + 4 * 86400000, timeRange: [] },
{ day: now + 5 * 86400000, timeRange: [] },
{ day: now + 6 * 86400000, timeRange: [] },
]
},
},
timeList: {
type: Array,
default() {
return [
{ name: '06:00-08:00', pkey: 'appointment_range_8', disabled: false },
{
name: '08:00-10:00',
pkey: 'appointment_range_10',
disabled: false,
},
{
name: '10:00-12:00',
pkey: 'appointment_range_12',
disabled: false,
},
{
name: '12:00-14:00',
pkey: 'appointment_range_14',
disabled: false,
},
{
name: '14:00-16:00',
pkey: 'appointment_range_16',
disabled: false,
},
{
name: '16:00-18:00',
pkey: 'appointment_range_18',
disabled: false,
},
{
name: '18:00-20:00',
pkey: 'appointment_range_20',
disabled: false,
},
{
name: '20:00-22:00',
pkey: 'appointment_range_22',
disabled: false,
},
{
name: '22:00-24:00',
pkey: 'appointment_range_24',
disabled: false,
},
]
},
},
defaultAppointRangeItem: {
type: Object,
default() {
// return {"name":"22:00-24:00","pkey":"appointment_range_24","disabled":false}
return {}
},
},
},
data() {
return {
appointTime: null,
appointRange: null,
appointRangeText: '',
num: 0,
hasLast: false,
currentPkey: new Date().getHours(),
currentDayIndex: -1,
}
},
// watch: {
// title() {
// this.appointTime = null
// this.appointRange = null
// this.appointRangeText = ''
// this.currentDayIndex = -1
// }
// },
computed: {
needTodyClipping() {
// 报备不限制当天已经过去的时间
// return this.type != 'filing'
return false // 报备和改约都不限制了
},
},
methods: {
getDateList() {
// 获取日期
},
async dateChange(item, index, list) {
let data = {
item,
index,
list,
}
this.appointTime = item.day
this.initAppointRange()
this.currentDayIndex = index
this.$emit('date-change', data)
if (this.appointRange) {
this.$emit('time-change', {
item: { pkey: this.appointRange, name: this.appointRangeText },
})
}
},
timeChange(item, index, list) {
let data = {
item,
index,
list,
}
this.appointRange = item.pkey
this.appointRangeText = item.name
this.$emit('time-change', data)
},
weekChange(item, index, list) {
let data = {
item,
index,
list,
}
this.$emit('week-change', data)
},
lastWeek(item, list) {
if (this.num > 0) {
this.num--
let len = list.length
if (this.num == 0) {
this.hasLast = false
len++
}
let time = item.day - len * 86400000
let data = {
time: time,
num: this.num,
}
this.$emit('week-change', data)
}
},
nextWeek(item, list) {
this.hasLast = true
this.num++
let len = list.length
let time = item.day + len * 86400000
let data = {
time: time,
num: this.num,
}
this.$emit('week-change', data)
},
weekFmt(day) {
let morrow = this.moment(now).add(1, 'days')
let content
if (day == now) {
content = '今天'
} else if (day == morrow) {
content = '明天'
} else {
content = this.moment(day).format('周dd')
}
return content
},
initAppointRange() {
this.appointRange = this.defaultAppointRangeItem.pkey
this.appointRangeText = this.defaultAppointRangeItem.name
},
},
}
</script>
<style lang="scss" scoped>
.con-box {
padding: 30rpx 30rpx 10rpx 30rpx;
border-radius: 12rpx;
background-color: #FFFFFF;
.con-box {
padding: 30rpx 30rpx 10rpx 30rpx;
border-radius: 12rpx;
background-color: #ffffff;
.title {
font-weight: bold;
font-size: 32rpx;
line-height: 32rpx;
color: #333;
}
}
.txt {
font-size: 26rpx;
line-height: 26rpx;
color: #333;
&.active {
color: #2272ff;
}
}
.title {
font-weight: bold;
font-size: 32rpx;
line-height: 32rpx;
color: #333;
}
}
.date-list {
background-color: #f4f5f7;
.last {
width: 60rpx;
height: 120rpx;
line-height: 120rpx;
text-align: center;
border-right: 2rpx solid #fff;
}
.date-box {
padding: 20rpx 18rpx 16rpx 20rpx;
width: 568rpx;
.date-item {
// padding: 20rpx 20rpx 16rpx;
border-radius: 12rpx;
.txt {
font-size: 26rpx;
line-height: 26rpx;
color: #333;
.day {
display: block;
font-size: 24rpx;
line-height: 26rpx;
color: #999;
&.active {
color: #2272FF
}
}
&.day1 {
width: 48rpx;
height: 48rpx;
margin-top: 10rpx;
border-radius: 50%;
font-size: 28rpx;
text-align: center;
line-height: 48rpx;
}
}
.date-list {
background-color: #F4F5F7;
.last{
width: 60rpx;
height: 120rpx;
line-height: 120rpx;
text-align: center;
border-right: 2rpx solid #fff;
}
.date-box {
padding: 20rpx 18rpx 16rpx 20rpx;
width: 568rpx;
.date-item {
// padding: 20rpx 20rpx 16rpx;
border-radius: 12rpx;
.day {
display: block;
font-size: 24rpx;
line-height: 26rpx;
color: #999;
&.day1 {
width: 48rpx;
height: 48rpx;
margin-top: 10rpx;
border-radius: 50%;
font-size: 28rpx;
text-align: center;
line-height: 48rpx;
}
}
&.active {
.day {
color: #2272FF;
&.day1 {
background-color: #2272FF;
color: #fff !important;
}
}
}
}
}
.next{
width: 60rpx;
height: 120rpx;
line-height: 120rpx;
text-align: center;
border-left: 2rpx solid #fff;
}
&.active {
.day {
color: #2272ff;
}
&.day1 {
background-color: #2272ff;
color: #fff !important;
}
}
}
}
}
.next {
width: 60rpx;
height: 120rpx;
line-height: 120rpx;
text-align: center;
border-left: 2rpx solid #fff;
}
}
.time-list {
display: flex;
flex-flow: row wrap;
align-content: flex-start;
.time-list {
display: flex;
flex-flow: row wrap;
align-content: flex-start;
.time-item {
flex: 0 0 196rpx;
min-width: 196rpx;
margin-right: auto;
margin-bottom: 20rpx;
border-radius: 12rpx;
background-color: #F4F5F7;
.time-item {
flex: 0 0 196rpx;
min-width: 196rpx;
margin-right: auto;
margin-bottom: 20rpx;
border-radius: 12rpx;
background-color: #f4f5f7;
&:nth-child(3n) {
margin-right: 0;
}
&.active{
background-color: #2272FF;
.time{
color:#fff;
}
}
.time {
font-size: 26rpx;
line-height: 76rpx;
color: #999;
}
/deep/ button {
padding: 0;
height: 76rpx;
}
/deep/ button[plain] {
border: none;
}
button[disabled]:not([type]) {
background: #FFFFFF;
color: #CCCCCC;
border: 2rpx solid #F4F5F7;
}
}
}
&:nth-child(3n) {
margin-right: 0;
}
&.active {
background-color: #2272ff;
.time {
color: #fff;
}
}
.time {
font-size: 26rpx;
line-height: 76rpx;
color: #999;
}
/deep/ button {
padding: 0;
height: 76rpx;
}
/deep/ button[plain] {
border: none;
}
button[disabled]:not([type]) {
background: #ffffff;
color: #cccccc;
border: 2rpx solid #f4f5f7;
}
}
}
</style>
<!-- 改约 -->
<template>
<view class="content-view">
<view class="con-box">
<view class="title">{{ traceTitles[0] }}</view>
<view class="u-flex u-flex-wrap">
<view
v-for="(item, index) in options['owns']"
:key="index"
@click="changeOwn(index, item.name, item.types)"
:class="{ 'txt-item': true, active: curOwn == index }"
>
<text class="txt">{{ item.name }}</text>
</view>
</view>
<u-gap height="30"></u-gap>
<view class="title">{{ traceTitles[1] }}</view>
<view class="u-flex u-flex-wrap">
<view
v-for="(txt, index) in options['owns'][curOwn]['types']"
:key="index"
@click="changeType(index, txt)"
:class="{ 'txt-item': true, active: trace.reason == txt }"
style="width: 306rpx;margin-right: 18rpx"
>
<text class="txt">{{ txt }}</text>
</view>
</view>
<view class="input-view">
<u-input
v-model="trace.remark"
class="textarea"
height="156"
type="textarea"
placeholder="请补充详细说明,以便于记录您的接单信用分"
></u-input>
</view>
</view>
<view class="time-view">
<appoint-time
:dateList="dateList"
:title="appointTitle"
:timeList="timeList"
:type="type"
:defaultAppointRangeItem="defaultAppointRangeItem"
@dateChange="dateChange"
@timeChange="timeChange"
@weekChange="weekChange"
></appoint-time>
</view>
</view>
</template>
<script>
let now = new Date(new Date().toLocaleDateString()).getTime()
import appointTime from '@/components/appoint/appoint-time.vue'
export default {
components: {
appointTime,
},
props: {
// 报备(预约): 'filing', 改约: 'subscribe'
type: {
type: String,
default: 'subscribe',
},
categoryId: {
type: String,
default: null,
},
},
data() {
return {
feedback: null,
options: [
{
name: '报备',
owns: [
{
name: '客户',
types: [
'等客户报装电表',
'等客户与物业沟通',
'等客户改造电源',
'客户不确定安装时间',
'等客户通知安装时间',
'客户电话未打通',
'客户反馈暂不安装',
],
},
{ name: '个人', types: [] },
{ name: '客观', types: [] },
],
},
{
name: '改约',
owns: [
{
name: '客户',
types: ['有事耽搁', '未带齐工具', '个人改约', '其他'],
},
{ name: '个人', types: [] },
{ name: '客观', types: [] },
],
},
],
dateList: [
{ day: now, timeRange: [] },
{ day: now + 1 * 86400000, timeRange: [] },
{ day: now + 2 * 86400000, timeRange: [] },
{ day: now + 3 * 86400000, timeRange: [] },
{ day: now + 4 * 86400000, timeRange: [] },
{ day: now + 5 * 86400000, timeRange: [] },
{ day: now + 6 * 86400000, timeRange: [] },
],
timeList: [
{ name: '06:00-08:00', pkey: 'appointment_range_8', disabled: false },
{ name: '08:00-10:00', pkey: 'appointment_range_10', disabled: false },
{ name: '10:00-12:00', pkey: 'appointment_range_12', disabled: false },
{ name: '12:00-14:00', pkey: 'appointment_range_14', disabled: false },
{ name: '14:00-16:00', pkey: 'appointment_range_16', disabled: false },
{ name: '16:00-18:00', pkey: 'appointment_range_18', disabled: false },
{ name: '18:00-20:00', pkey: 'appointment_range_20', disabled: false },
{ name: '20:00-22:00', pkey: 'appointment_range_22', disabled: false },
{ name: '22:00-24:00', pkey: 'appointment_range_24', disabled: false },
],
traceTitles: ['问题归属', '问题类型'],
appointTitle: '改约时间',
appoint: ['下次联系时间', '改约时间'],
trace: {
reasonType: '报备', // 反馈类型
reasonRelegation: '客户', // 反馈归属
reason: '', // 反馈原因
remark: '', // 备注
traceDate: null, // 反馈时间
timeRange: null, // 反馈时间段
dateItem: null,
timeItem: null,
},
curOwn: 0,
num: 0,
}
},
computed: {
curTab() {
return this.isSubscribe ? 1 : 0
},
isSubscribe() {
return this.type == 'subscribe'
},
disabledSubmit() {
let self = this
if (
self.trace.reasonRelegation &&
self.trace.reason &&
self.trace.traceDate &&
self.trace.timeRange
) {
return false
}
return true
},
types() {
return { 报备: 'filing', 改约: 'subscribe' }
},
typeKeys() {
return { filing: '报备', subscribe: '改约' }
},
// timeType() {
// return this.types[this.options.name]
// },
defaultAppointRangeItem() {
return this.options.defaultAppointRangeItem
},
submitData() {
if (this.isSubscribe) {
// 改约
let params = {
reason: this.trace.reason,
reasonRelegation: this.trace.reasonRelegation,
reasonType: this.trace.reasonType,
remark: this.trace.remark,
}
params.appointmentDatetime = this.trace.traceDate
params.appointmentDatetimeRange = this.trace.timeRange
return params
} else {
// 报备(预约)
let data = {
reason: this.trace.reason,
reasonRelegation: this.trace.reasonRelegation,
reasonType: this.trace.reasonType,
remark: this.trace.remark,
}
data.appointmentDatetime = this.trace.traceDate
data.appointmentDatetimeRange = this.trace.timeRange
// 最后一个24:00点,按照23:59分处理
if (
this.trace.timeItem &&
this.trace.timeItem.pkey &&
this.trace.traceDate
) {
let traceDate = this.moment(this.trace.traceDate)
let timeArr = this.trace.timeItem.pkey.split('_')
if (this.trace.timeItem.pkey == 'appointment_range_24') {
let traceDateTime = traceDate
.clone()
.add(23, 'hours')
.add(59, 'minutes')
data.nextTraceDatetime = traceDateTime.unix() * 1000
} else {
let hours = timeArr && timeArr.length && timeArr.pop()
let traceDateTime = traceDate.clone().add(Number(hours), 'hours')
data.nextTraceDatetime = traceDateTime.unix() * 1000
}
}
return data
}
},
},
watch: {
disabledSubmit(val) {
this.$emit('change', val)
},
categoryId(val) {
if (val) {
this.initPageData()
}
},
},
created() {
if (this.categoryId) {
this.initPageData()
}
},
methods: {
/* 初始化页面数据 */
async initPageData() {
let self = this
await Promise.all([self.loadCalendar(), self.loadTimerange()])
let params = { categoryId: self.categoryId }
let res = await self.$u.api.feedbackConfig(params)
if (res && res.code == 200) {
self.feedback = res.data || {}
self.buildConfig()
}
uni.hideLoading()
},
/* 组装数据项参数 */
buildConfig() {
let self = this
if (self.feedback) {
let key = self.typeKeys[this.type]
let data = self.feedback[key]
let configs = {}
let owns = Object.keys(data)
let ownVals = Object.values(data)
var defaultAppointRangeItem =
this.isSubscribe
? {
name: '',
pkey: '',
disabled: false,
}
: {
name: '22:00-24:00',
pkey: 'appointment_range_24',
disabled: false,
}
configs = {
name: key,
owns: [],
defaultAppointRangeItem: defaultAppointRangeItem,
}
owns.forEach(function(own, key) {
configs['owns'][key] = { name: own, types: ownVals[key] }
})
// 数组改写需要刷新绑定数据
self.options = configs
this.initParams()
}
},
/* 初始化参数 */
initParams() {
let self = this
if (self.options) {
let tabList = self.options
self.trace.reasonType = tabList.name
self.trace.reasonRelegation = tabList['owns'][self.curOwn].name
self.trace.reason = tabList['owns'][self.curOwn]['types'][0]
self.appointTitle = self.appoint[self.curTab]
self.trace.remark = ''
self.trace.traceDate = null
self.trace.timeRange = null
self.trace.dateItem = null
// if (self.trace.reasonType == '改约') { // 屏蔽改约对时间段选择的限制
// if (self.dateList && self.timeList) {
// self.timeList.map((item, index) => {
// if (
// (self.trace.dateItem &&
// self.trace.dateItem.timeRange &&
// self.trace.dateItem.timeRange.indexOf(item.pkey) > -1) ||
// item.isEnd
// ) {
// item.disabled = true
// } else {
// item.disabled = false
// }
// })
// }
// } else {
self.timeList.map((item, index) => {
item.disabled = false
})
// }
}
},
/* 加载日历数据 */
async loadCalendar() {
let self = this
let res = await this.$u.api.workerCalendar({ num: this.num })
if (res && res.code == 200) {
self.dateList = res.data
}
},
/* 加载预约时间段 */
async loadTimerange() {
let self = this
let res = await this.$u.api.openTimerange()
if (res && res.code == 200) {
let list = res.data
list.map((item, index) => {
item.disabled = false
})
self.timeList = list
}
},
changeOwn(index, own, types) {
let self = this
self.curOwn = index
self.trace.reasonRelegation = own
self.trace.reason = types[0]
},
changeType(index, type) {
this.trace.reason = type
},
weekChange(data) {
// 点击下一周
console.log(data, 'week-data')
if (data && data.time) {
let num = data.num
let time = data.time
this.num = num
if (num == 0) {
this.loadCalendar()
} else {
this.loadCalendar()
}
}
},
dateChange(data) {
// 点击日期选择
let self = this
self.trace.dateItem = data.item
// if (self.trace.reasonType == '改约') { // 屏蔽改约对时间段选择的限制
// self.timeList.map((item, index) => {
// if (
// (data.item.timeRange &&
// data.item.timeRange.indexOf(item.pkey) > -1) ||
// item.isEnd
// ) {
// item.disabled = true
// } else {
// item.disabled = false
// }
// })
// } else {
self.timeList.map((item, index) => {
item.disabled = false
})
// }
self.trace.traceDate = data.item.day
self.trace.timeRange = null
},
timeChange(data) {
// 时间段选择变化
console.log(data, 'week-data')
this.trace.timeRange = data.item.pkey
this.trace.timeItem = data.item
},
},
}
</script>
<style lang="scss" scoped>
.content-view {
height: 100%;
border-radius: 12rpx;
overflow: auto;
.time-view {
border-radius: 12rpx;
background-color: #ffffff;
padding-bottom: 20rpx;
}
}
.con-box {
padding: 30rpx 30rpx 8rpx 30rpx;
border-radius: 12rpx;
background-color: #ffffff;
margin-bottom: 20rpx;
.title {
font-weight: bold;
font-size: 32rpx;
line-height: 32rpx;
color: #333;
}
& > .u-flex {
margin-top: 40rpx;
margin-right: -24rpx;
.txt-item {
border-radius: 12rpx;
padding: 24rpx 38rpx;
width: 196rpx;
height: 72rpx;
text-align: center;
margin-right: 22rpx;
margin-bottom: 20rpx;
background-color: #f4f5f7;
&.active {
background-color: #2272ff;
.txt {
color: #fff;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
}
}
}
.txt {
display: block;
font-size: 26rpx;
line-height: 26rpx;
color: #333;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.input-view {
margin-top: 24rpx;
margin-bottom: 24rpx;
border: 2rpx solid #ececec;
padding: 18rpx 30rpx;
}
}
</style>
......@@ -299,7 +299,7 @@ export default {
待预约 orderStatus == 31 and appointmentDatetime == null 工单状态等于30并且预约时间为空
待签到 orderStatus == 31 and appointmentDatetime is not null 工单状态等于30并且预约时间不为空
待完工 orderStatus >31 and orderStatus < 80 工单状态大于31 小于80
审核中 orderStatus ==85 or orderStatus == 87 or orderStatus == 88 工单状态 等于85 或者 等于有87
审核中 orderStatus ==85 or orderStatus == 87 or orderStatus == 88 工单状态 等于85 或者 等于87 或者 等于88
异常 orderStatus ==86 工单状态 等于86
已完工 orderStatus in(80,81,89,110) 工单状态 等于80 or 81 or 89 or 110
*/
......
<template>
<view class="order-record-view">
<view class="top-item">
<text>履约记录</text>
</view>
<view v-if="orderRecords.length == 0" class="no-record-view">当前暂无履约记录</view>
<view v-else :class="['record-list-view', {'short': orderRecords.length <= showLenght}]">
<view class="record-right-view">
<view class="dashed-line-view"></view>
<view class="order-list">
<view v-for="(record,index) in showOrderRecords" :key="record.operationContent" :class="['order-cell', {'first': index == 0}]">
<view class="node-view">
<view class="node-border-view">
<view class="node-middle-view"></view>
</view>
</view>
<view class="right-view">
<view class="line-view-top">
<text>{{$u.timeFormat(record.operationDatetime, 'yyyy.mm.dd &nbsp hh:MM:ss')}}</text>
<text style="color: red;">{{record.overTime?'超时':''}}{{record.overTime && record.exception ? '/' : ''}}{{record.exception?'异常':''}}</text>
<text style="color: #2272FF;" v-show="record.isTrace">跟进</text>
</view>
<view class="line-view-item">
<view>
<text>{{record.operationTypeText}}</text>
</view>
<view class="item-operation-view" v-show="record.isTrace">
<text class="item-label" >{{record.traceLabel + ":"}}</text>
<text class="item-content">{{record.traceTime}}</text>
</view>
<view class="item-operation-view" v-show="record.operationContent">
<text class="item-label">备注:</text>
<text class="item-content">{{ record.operationContent }}</text>
</view>
</view>
</view>
</view>
</view>
</view>
<view v-if="orderRecords && orderRecords.length > showLenght" @click="readMoreRecord = !readMoreRecord">
<view v-if="readMoreRecord" class="read-more-toggle">
<u-icon name="arrow-down"></u-icon>
<text class="read-more-text">查看更多</text>
</view>
<view v-else class="read-more-toggle">
<u-icon name="arrow-up"></u-icon>
<text class="read-more-text">点击收起</text>
</view>
</view>
<view v-else style="height: 10rpx;"></view>
</view>
</view>
<view class="order-record-view">
<view class="top-item">
<text>履约记录</text>
</view>
<view v-if="orderRecords.length == 0" class="no-record-view"
>当前暂无履约记录</view
>
<view
v-else
:class="[
'record-list-view',
{ short: orderRecords.length <= showLenght },
]"
>
<view class="record-right-view">
<view class="dashed-line-view"></view>
<view class="order-list">
<view
v-for="(record, index) in showOrderRecords"
:key="record.operationContent"
:class="['order-cell', { first: index == 0 }]"
>
<view class="node-view">
<view class="node-border-view">
<view class="node-middle-view"></view>
</view>
</view>
<view class="right-view">
<view class="line-view-top">
<text>{{
$u.timeFormat(
record.operationDatetime,
'yyyy.mm.dd &nbsp hh:MM:ss'
)
}}</text>
<text style="color: red;"
>{{ record.overTime ? '超时' : ''
}}{{ record.overTime && record.exception ? '/' : ''
}}{{ record.exception ? '异常' : '' }}</text
>
<text style="color: #2272FF;" v-show="record.isTrace"
>跟进</text
>
</view>
<view class="line-view-item">
<view>
<text>{{ record.operationTypeText }}</text>
</view>
<view class="item-operation-view" v-show="record.isTrace">
<text class="item-label">{{ record.traceLabel + ':' }}</text>
<text class="item-content">{{ record.traceTime }}</text>
</view>
<view
class="item-operation-view"
v-show="record.operationContent"
>
<text class="item-label">备注:</text>
<text class="item-content">{{
record.operationContent
}}</text>
</view>
</view>
</view>
</view>
</view>
</view>
<view
v-if="orderRecords && orderRecords.length > showLenght"
@click="readMoreRecord = !readMoreRecord"
>
<view v-if="readMoreRecord" class="read-more-toggle">
<u-icon name="arrow-down"></u-icon>
<text class="read-more-text">查看更多</text>
</view>
<view v-else class="read-more-toggle">
<u-icon name="arrow-up"></u-icon>
<text class="read-more-text">点击收起</text>
</view>
</view>
<view v-else style="height: 10rpx;"></view>
</view>
</view>
</template>
<script>
export default {
props: {
// 履约记录
orderRecords: {
type: Array,
default () {
return []
}
},
},
data() {
return {
readMoreRecord: true,
showLenght: 5,
}
},
computed: {
showOrderRecords() {
if (this.readMoreRecord && this.orderRecords && this.orderRecords.length > 0) {
return this.orderRecords.slice(0, this.showLenght)
} else {
return this.orderRecords
}
},
},
}
export default {
props: {
// 履约记录
orderRecords: {
type: Array,
default() {
return []
},
},
},
data() {
return {
readMoreRecord: true,
showLenght: 5,
}
},
computed: {
showOrderRecords() {
if (
this.readMoreRecord &&
this.orderRecords &&
this.orderRecords.length > 0
) {
return this.orderRecords.slice(0, this.showLenght)
} else {
return this.orderRecords
}
},
},
}
</script>
<style lang="scss" scoped>
.order-record-view {
.top-item {
font-size: 32rpx;
color: #333333;
font-weight: bold;
margin-bottom: 20rpx;
}
.no-record-view {
font-size: 26rpx;
color: #333333;
padding-bottom: 30rpx;
}
.record-list-view {
position: relative;
&.short {
padding-bottom: 30rpx;
}
.record-right-view {
position: relative;
display: flex;
justify-content: space-between;
.dashed-line-view {
position: absolute;
width: 2rpx;
border-left: 1px dashed #2272FF;
height: 100%;
top: 14rpx;
left: 11rpx;
}
.order-list {
width: 100%;
.order-cell {
margin-top: 50rpx;
display: flex;
&.first {
margin-top: 0;
}
.node-view {
margin-right: 18rpx;
flex-shrink: 0;
margin-top: 8rpx;
z-index: 1;
.node-border-view {
border: 2rpx solid #2272FF;
border-radius: 11rpx;
width: 22rpx;
height: 22rpx;
// display: flex;
// align-items: center;
// justify-content: center;
padding: 5rpx;
background-color: #FFFFFF;
.node-middle-view {
width: 10rpx;
height: 10rpx;
background-color: #2272FF;
border-radius: 6rpx;
}
}
}
.right-view {
width: 100%;
.line-view-top {
display: flex;
align-items: center;
justify-content: space-between;
color: #333333;
font-weight: bold;
font-size: 28rpx;
}
.line-view-item {
color: #666666;
font-size: 26rpx;
margin-top: 10rpx;
.item-operation-view {
margin-top: 20rpx;
.item-label {
color: #2272FF;
}
.item-content {
word-break: break-all;
}
}
}
}
}
}
}
}
.read-more-toggle {
text-align: center;
color: #2272FF;
font-size: 26rpx;
padding-top: 30rpx;
padding-bottom: 30rpx;
}
.read-more-text {
padding-left: 8rpx;
}
.order-item-more {
font-size: 26rpx;
color: #333333;
text-align: right;
.line-view {
background-color: #F4F5F7;
height: 2rpx;
margin-bottom: 20rpx;
}
}
}
</style>
.order-record-view {
.top-item {
font-size: 32rpx;
color: #333333;
font-weight: bold;
margin-bottom: 20rpx;
}
.no-record-view {
font-size: 26rpx;
color: #333333;
padding-bottom: 30rpx;
}
.record-list-view {
position: relative;
&.short {
padding-bottom: 30rpx;
}
.record-right-view {
position: relative;
display: flex;
justify-content: space-between;
.dashed-line-view {
position: absolute;
width: 2rpx;
border-left: 1px dashed #2272ff;
height: 100%;
top: 14rpx;
left: 11rpx;
}
.order-list {
width: 100%;
.order-cell {
margin-top: 50rpx;
display: flex;
&.first {
margin-top: 0;
}
.node-view {
margin-right: 18rpx;
flex-shrink: 0;
margin-top: 8rpx;
z-index: 1;
.node-border-view {
border: 2rpx solid #2272ff;
border-radius: 50%;
width: 22rpx;
height: 22rpx;
display: flex;
align-items: center;
justify-content: center;
// padding: 6rpx;
background-color: #ffffff;
.node-middle-view {
width: 10rpx;
height: 10rpx;
background-color: #2272ff;
border-radius: 50%;
}
}
}
.right-view {
width: 100%;
.line-view-top {
display: flex;
align-items: center;
justify-content: space-between;
color: #333333;
font-weight: bold;
font-size: 28rpx;
}
.line-view-item {
color: #666666;
font-size: 26rpx;
margin-top: 10rpx;
.item-operation-view {
margin-top: 20rpx;
.item-label {
color: #2272ff;
}
.item-content {
word-break: break-all;
}
}
}
}
}
}
}
}
.read-more-toggle {
text-align: center;
color: #2272ff;
font-size: 26rpx;
padding-top: 30rpx;
padding-bottom: 30rpx;
}
.read-more-text {
padding-left: 8rpx;
}
.order-item-more {
font-size: 26rpx;
color: #333333;
text-align: right;
.line-view {
background-color: #f4f5f7;
height: 2rpx;
margin-bottom: 20rpx;
}
}
}
</style>
<template>
<view class="order-wrap">
<u-navbar title-color="#FFFFFF" title-size="32" back-icon-color="#FFFFFF" :background="background" :border-bottom="false" title-bold></u-navbar>
<view class="content">
<view class="title-view">
<view class="title-text">{{title}}</view>
<!-- 拒单 -->
<view v-show="allowRejection" class="reject-button" @click="$u.throttle(rejectOrder, 500)">拒单</view>
</view>
<!-- 订单详情 -->
<view class="card">
<view class="header" v-if="showTimeView">
<view class="header-left-view">
<u-icon :name="clockName" margin-left="10" custom-prefix="wxh"
:color="countColor" size="40" :label="tipText" label-size="32"
:label-color="countColor" :custom-style="{'font-weight': 'bold'}" />
</view>
<!-- 倒计时 -->
<view class="title">
<u-count-down :timestamp="timestamp" font-size="28" show-days separator="zh" separator-size="32" height="40"
color="#FFFFFF" separator-color="#666666" @change="timeOutChange" ref="order-count-down" :bg-color="countColor"></u-count-down>
</view>
</view>
<Detail :order="order" :readMore.sync="readMore" :operate="isAllowDianhuaAndDaohang"></Detail>
</view>
<!-- 从我的页面进来显示结算信息 -->
<view v-if="isOther" class="settlement-view">
<view class="settlement-title">结算信息</view>
<view class="settlement-content">
<text class="content-left">工单确认时间:</text>
<text>{{settlementInfo.formatTime}}</text>
</view>
<view class="settlement-content" v-for="(item, index) in settlementInfo.list" :key="index">
<text class="content-left">{{item.businessSettlementType + ':'}}</text>
<text>{{(item.realSettlementAmount || item.settlementAmount) + '元'}}</text>
<text v-if="item.adjustmentRemark">{{'-' + item.adjustmentRemark}}</text>
</view>
<view class="settlement-content">
<text class="content-left">最终结算金额:</text>
<text>{{settlementInfo.amount}}元</text>
</view>
</view>
<!-- 不是从我的页面,而是其他页面进来 -->
<view v-else>
<!-- 业务文件 -->
<view class="order-file" v-if="showFile" @click="$u.throttle(handleClickFile, 500)">
<view class="order-file-left">
<image :src="wenjianImage" class="file-image"></image>
<text>充电桩安装业务文件</text>
</view>
<view class="order-file-right">
<text>点击查看</text>
<u-icon name="arrow-right"></u-icon>
</view>
</view>
<!-- 带预约显示时间选择 -->
<view class="card appoint-item" v-show="isWaitAppointment">
<appoint-time :dateList="dateList" :timeList="timeList" @dateChange="dateChange" @timeChange="timeChange" @weekChange="weekChange"></appoint-time>
</view>
<!-- 履约记录 -->
<view class="card record-item">
<Record :orderRecords="orderRecords"></Record>
</view>
</view>
</view>
<!-- 不是从我的页面进来才显示 -->
<template v-if="!isOther">
<!-- 提示窗口 -->
<view>
<u-toast ref="uToast" />
</view>
<BottomButtons v-if="showBottomBtn" :buttons="buttons" @submit="handleSubmit"></BottomButtons>
<!-- 拍照 -->
<take-photo type="test" v-if="takeStatus" @close="closeTake" :upload="false" :num="1"></take-photo>
<!-- 添加客服 -->
<u-popup border-radius="12" v-model="visible" safe-area-inset-bottom mode="center" width="690rpx"
:mask-close-able="false" close-icon-color="#FFFFFF">
<view class="order-pop-view">
<Customer type="pop" @click="handleJoin"></Customer>
</view>
</u-popup>
<!-- 已申请配件列表 -->
<!-- <ApplyList :show.sync="showApplyList" :list="partsList" @action="handleClickCell" @operate="handleOperate" @apply="handleApply"></ApplyList> -->
</template>
</view>
<view class="order-wrap">
<u-navbar
title-color="#FFFFFF"
title-size="32"
back-icon-color="#FFFFFF"
:background="background"
:border-bottom="false"
title-bold
></u-navbar>
<view class="content">
<view class="title-view">
<view class="title-text">{{ title }}</view>
<!-- 拒单 -->
<view
v-show="allowRejection"
class="reject-button"
@click="$u.throttle(rejectOrder, 500)"
>拒单</view
>
</view>
<!-- 订单详情 -->
<view class="card">
<view class="header" v-if="showTimeView">
<view class="header-left-view">
<u-icon
:name="clockName"
margin-left="10"
custom-prefix="wxh"
:color="countColor"
size="40"
:label="tipText"
label-size="32"
:label-color="countColor"
:custom-style="{ 'font-weight': 'bold' }"
/>
</view>
<!-- 倒计时 -->
<view class="title">
<u-count-down
:timestamp="timestamp"
font-size="28"
show-days
separator="zh"
separator-size="32"
height="40"
color="#FFFFFF"
separator-color="#666666"
@change="timeOutChange"
ref="order-count-down"
:bg-color="countColor"
></u-count-down>
</view>
</view>
<Detail
:order="order"
:readMore.sync="readMore"
:operate="isAllowDianhuaAndDaohang"
></Detail>
</view>
<!-- 从我的页面进来显示结算信息 -->
<view v-if="isOther" class="settlement-view">
<view class="settlement-title">结算信息</view>
<view class="settlement-content">
<text class="content-left">工单确认时间:</text>
<text>{{ settlementInfo.formatTime }}</text>
</view>
<view
class="settlement-content"
v-for="(item, index) in settlementInfo.list"
:key="index"
>
<text class="content-left">{{
item.businessSettlementType + ':'
}}</text>
<text>{{
(item.realSettlementAmount || item.settlementAmount) + '元'
}}</text>
<text v-if="item.adjustmentRemark">{{
'-' + item.adjustmentRemark
}}</text>
</view>
<view class="settlement-content">
<text class="content-left">最终结算金额:</text>
<text>{{ settlementInfo.amount }}元</text>
</view>
</view>
<!-- 不是从我的页面,而是其他页面进来 -->
<view v-else>
<!-- 业务文件 -->
<view
class="order-file"
v-if="showFile"
@click="$u.throttle(handleClickFile, 500)"
>
<view class="order-file-left">
<image :src="wenjianImage" class="file-image"></image>
<text>充电桩安装业务文件</text>
</view>
<view class="order-file-right">
<text>点击查看</text>
<u-icon name="arrow-right"></u-icon>
</view>
</view>
<!-- 带预约显示时间选择 -->
<FeedbackContent
ref="feed-back"
v-show="isWaitAppointment"
:categoryId="order.categoryId"
type="filing"
@change="handleChange"
class="content-view"
/>
<!-- 履约记录 -->
<view class="card record-item">
<Record :orderRecords="orderRecords"></Record>
</view>
</view>
</view>
<!-- 不是从我的页面进来才显示 -->
<template v-if="!isOther">
<!-- 提示窗口 -->
<view>
<u-toast ref="uToast" />
</view>
<BottomButtons
v-if="showBottomBtn"
:buttons="buttons"
@submit="handleSubmit"
></BottomButtons>
<!-- 拍照 -->
<take-photo
type="test"
v-if="takeStatus"
@close="closeTake"
:upload="false"
:num="1"
></take-photo>
<!-- 添加客服 -->
<u-popup
border-radius="12"
v-model="visible"
safe-area-inset-bottom
mode="center"
width="690rpx"
:mask-close-able="false"
close-icon-color="#FFFFFF"
>
<view class="order-pop-view">
<Customer type="pop" @click="handleJoin"></Customer>
</view>
</u-popup>
<!-- 已申请配件列表 -->
<!-- <ApplyList :show.sync="showApplyList" :list="partsList" @action="handleClickCell" @operate="handleOperate" @apply="handleApply"></ApplyList> -->
</template>
</view>
</template>
<script>
import appointTime from '@/components/appoint/appoint-time.vue'
import takePhoto from '@/components/take/index.vue'
// import PopView from "@/components/popView/index.vue"
import baseFile from '@/components/upload/index'
import Customer from "@/components/mine/customer.vue"
import Record from "@/components/order/performanceRecord.vue"
import Detail from "@/components/order/detail.vue"
import BottomButtons from "@/components/order/bottomButtons.vue"
// import ApplyList from "@/components/parts/applyList.vue"
let now = new Date(new Date().toLocaleDateString()).getTime();
export default {
components: {
appointTime,
'take-photo': takePhoto,
// PopView,
Customer,
Record,
Detail,
BottomButtons,
// ApplyList
},
mixins: [baseFile],
data() {
return {
type: '',
readMore: true, // 是:显示的是'查看更多'按钮;否:显示的是'点击收起'按钮
dateList: [
{day: now, timeRange: []},
{day: now + (1*86400000), timeRange: []},
{day: now + (2*86400000), timeRange: []},
{day: now + (3*86400000), timeRange: []},
{day: now + (4*86400000), timeRange: []},
{day: now + (5*86400000), timeRange: []},
{day: now + (6*86400000), timeRange: []},
],
timeList: [
{"name":"06:00-08:00","pkey":"appointment_range_8"},
{"name":"08:00-10:00","pkey":"appointment_range_10"},
{"name":"10:00-12:00","pkey":"appointment_range_12"},
{"name":"12:00-14:00","pkey":"appointment_range_14"},
{"name":"14:00-16:00","pkey":"appointment_range_16"},
{"name":"16:00-18:00","pkey":"appointment_range_18"},
{"name":"18:00-20:00","pkey":"appointment_range_20"},
{"name":"20:00-22:00","pkey":"appointment_range_22"},
{"name":"22:00-24:00","pkey":"appointment_range_24"}
],
background: {
backgroundColor: 'none',
// 导航栏背景图
// background: 'url(https://cdn.uviewui.com/uview/swiper/1.jpg) no-repeat',
// 还可以设置背景图size属性
// backgroundSize: 'cover',
// 渐变色
},
visible: false,
// orderId: null,
orderId: 11880366, // 测试数据
order: {},
needPhotograph: true, // 需要现场拍摄
orderRecords: [],
method: null,
submitType: '',
nextUrl:'',
takeStatus:false,
isErrorSign:false,
errorSignUrl:'',
appointmentDatetimeRange:'',
appointmentDatetime:'',
signDistance:3000,
contactAddressLongitud:0,
contactAddressLatitud:0,
num:0,
clicking: false,
dateItem: null,
centerBtnDisabled:false,
settlementInfo: {formatTime: '-', list: [], amount: ''},
unloaded: false,
timeout: false,
timestamp: 0,
showCountTime : false, // 从上个页面传入是否显示倒计时
// showApplyList: false, // 显示已申请配件列表
partsList: [], // 已申请的配件列表
partsCount: 0
}
},
computed: {
customStyle() {
return {
'height': '48rpx',
'width': '100rpx',
'color': '#FFFFFF',
'border-color': 'transparent',
'background-color': 'transparent'
}
},
buttons() {
//id: 0 主流程; 1 过程反馈;2 异常签到; 3 现场拍照; 4 备件申请
// label: 按钮文字,
// type: 'image' 上图片下文字;'text' 纯文字,
// image: 图片名,
// show: 是否显示,
// disabled: 是 禁用;否 正常,
// id: 区分各个按钮
return [{
label: '过程反馈',
type: 'image',
image: 'guochengfankui.png',
show: this.allowFeedback,
disabled: false,
id: 1
},
{
label: '异常签到',
type: 'image',
image: 'yichangqiandao.png',
show: this.isWaitCheckIn, // 待签到显示
disabled: false,
id: 2
},
{
label: '现场拍照',
type: 'image',
image: 'xiancahngpaizhao.png',
show: this.isWaitFinish,
disabled: false,
id: 3
},
{
label: '备件申请',
type: 'image',
image: 'peijian.png',
show: this.allowFeedback,
disabled: false,
count: this.partsCount,
id: 4
},
{
label: this.bottomButtonText,
type: 'text',
image: '',
show: true,
disabled: this.centerBtnDisabled,
id: 0,
customStyle: {
'background-color': this.isCompetitionAndWaitAccept ? '#FF930D' : (this.centerBtnDisabled ? '#D1D4D4' : '#2272FF')
}
}]
},
clockName() {
return this.timeout ? 'timeout' : 'clock'
},
countColor() {
return this.timeout ? '#FA5A49' : '#2272FF'
},
wenjianImage() {
return process.uniEnv.qn_base_url + 'wenjian.png'
},
types() {
return {
'waitAccept': 0, // 待接单、待抢单
'waitAppointment': 1, // 待预约、
'waitCheckIn': 2, // 待签到、
'waitFinish': 3, // 待完工、
'audit': 4, // 审核中、
'exception': 5, // 异常单、
'finish': 6, // 已完工
'snapped': 8, // 已被抢
'other': 9, // 工单结算信息
}
},
titles() {
return ['待' + this.type0Text,'待预约','待签到','待完工','审核中','异常单','已完工','','','订单信息']
},
bottomButtonText() { // 底部主流程按钮文字
return this.buttonTexts[this.types[this.type]]
},
buttonTexts() {
return [this.type0Text,'预约','签到','去完工','','','','','已被抢','']
},
tipText() { // 时间紧迫提示文字
return this.timeout ? '订单超时' : '剩余时间'
},
title() { // 标题
return this.titles[this.types[this.type]]
},
type0Text() {
return this.isCompetition ? '抢单' : '接单'
},
isCompetition() { // 是:订单池,抢单; 否:指派单,接单
return this.order.orderBusinessType == 'R'
},
isOther() { // 工单结算信息
return this.type == 'other'
},
allowRejection() { // 允许拒单
// 待接单 && 业务类型非抢单
return this.type == 'waitAccept' && !this.isCompetition
},
isCompetitionAndWaitAccept() { // 抢单页面
// 待接单 && 业务类型抢单
return this.type == 'waitAccept' && this.isCompetition
},
showBottomBtn() { // 显示底部button
// 0 待接单、待抢单, 1 待预约, 2 待签到, 3 待完工, 8 已被抢
return [0, 1, 2, 3, 8].indexOf(this.types[this.type]) != -1
},
showFile() { // 显示查看业务文件
// 1 待预约, 2 待签到, 3 待完工, 4 审核中, 5 异常单, 6 已完工, 8 已被抢
return this.types[this.type] > 0
},
isAllowDianhuaAndDaohang() { // 可以点击电话和定位按钮
return this.type != 'waitAccept'
},
showTimeView() { // 是否显示倒计时窗口
// 上个页面传入 || 订单信息有超过时间点 && ((待预约、 待签到、 待完工) || (待接单 && 业务类型非抢单))
return this.showCountTime || this.order.currentOverTime && ([1, 2, 3].indexOf(this.types[this.type]) != -1 || (this.type == 'waitAccept' && !this.isCompetition))
},
allowFeedback() { // 允许过程反馈 // 显示配件申请按钮
// 1 待预约, 2 待签到, 3 待完工
return [1, 2, 3].indexOf(this.types[this.type]) != -1
},
isWaitCheckIn() { // 待签到
return this.type == 'waitCheckIn'
},
isWaitAppointment() { // 待预约
return this.type == 'waitAppointment'
},
isWaitFinish() {
return this.type == 'waitFinish'
}
},
onLoad(option) {
getApp().trackPage('订单详情页')
// 生命周期函数--监听页面加载
if (option && option.id) {
this.orderId = option.id
}
if (option && option.showCountTime) { // 是否显示倒计时,上个页面传入,可以快速显示避免页面跳动太大;之后还需要从后台获取信息,再根据其他条件判断一次
this.showCountTime = option.showCountTime
}
if (option && option.type) { // 类型,从上个页面传进来可以快速构建页面;之后还需要从后台获取信息,更新状态
// 'waitAccept': 待接单、待抢单;'waitAppointment': 待预约;'waitCheckIn': 待签到;'waitFinish': 待完工;'audit': 审核中;'exception': 异常单;'finish': 已完工;'other': 工单结算信息
this.type = option.type
}
this.loadOrderDetail()
this.getLocation()
if (this.isOther) {
// 获取结算信息
this.loadSettlement()
} else {
this.loadOrderRecord() // 履约记录
this.getSignDistance() // 定位
// this.getOrderPartsSum() // 备件单数量
}
},
onShow() {
// 从过程反馈回来,需要刷新数据
let pages = getCurrentPages()
let page = pages[pages.length - 1]
if (page.needFresh) {
page.needFresh = null
this.loadOrderDetail()
this.loadOrderRecord()
}
if (page.needRefresh) {
page.needRefresh = null
this.getApplyList()
}
},
onUnload() {
this.unloaded = true
this.closeLocationChange()
},
methods: {
updateLocation(){
let self = this
wx.startLocationUpdate({
success:function(){
self.openLocationChange()
}
})
},
_locationChangeFn(res) {
let self = this
console.log('location change', res)
const dataValue = this.dataValue || []
dataValue.push(res.longitude)
dataValue.push(res.latitude)
self.dataValue = dataValue
if(this.getDistance(res.latitude,res.longitude)>this.signDistance){
// 计算签到距离
this.centerBtnDisabled = true
}else{
this.centerBtnDisabled = false
}
},
openLocationChange(){
console.log("openLocationChange")
wx.onLocationChange(this._locationChangeFn);
},
closeLocationChange(){
console.log("closeLocationChange")
wx.offLocationChange(this._locationChangeFn);
},
handleClickRight(active) {
this.isWaitFinish ? this.scenePhotoClick() : this.take()
},
scenePhotoClick() { // 跳转拍照小程序
uni.navigateTo({
url: 'pages/photo/list?orderId='+this.order.orderId+'&brandId='+this.order.lianbaoBrandId+'&brand='+this.order.brandName
+'&systemId='+this.order.partnerCompanyId+'&classifyId='+this.order.categoryId
})
},
take() {
uni.hideTabBar()
this.takeStatus = true
},
async closeTake(img) {
this.takeStatus = false
// 获取返回的图片 ,如果返回的图片存在则直接异常签约,成功后跳转到去完工页面,
if(img){ // 拍照完成
const files = img.map(v => v.path)
const value = await this.saveToTask(files)
this.isErrorSign = true
this.errorSignUrl = value[0].key
this.handleBtn()
}else{
this.$refs.uToast.show({
title: '异常签到失败,请先按要求拍照',
type: 'warning'
})
}
},
loadOrderDetail() { // 获取工单详情
let self = this
let timestamp = new Date().getTime();
var data = {
'orderId': self.orderId
};
self.$u.api.orderDetail(data, self.orderId).then((res) => {
if (res.code == 200) {
self.order = res.data
this.setOrderType()
var nowTime = new Date().getTime();
this.timeout = this.order.currentOverTime && nowTime> this.order.currentOverTime
this.timestamp = Math.round(Math.abs(this.order.currentOverTime - nowTime) / 1000)
// 格式化时间
this.settlementInfo.formatTime = this.order.settleCenterSyncDatetime ? this.$u.timeFormat(this.order.settleCenterSyncDatetime, 'yyyy.mm.dd hh:MM:ss') : '-'
} else {
console.log(res.message, "获取订单详情失败!");
}
});
},
loadSettlement() { // 获取工单详情
let self = this
var data = {
'orderId': self.orderId
};
self.$u.api.querySettleByOrder(data, self.orderId).then((res) => {
if (res.code == 200) {
var amount = 0
for (var item of res.data) {
amount += (item.realSettlementAmount || item.settlementAmount)
}
this.settlementInfo.amount = amount
this.settlementInfo.list = res.data
} else {
console.log(res.message, "获取订单详情失败!");
}
});
},
// getOrderPartsSum() { // 获取订单配件数量
// this.$u.api.getOrderPartsSum(this.orderId).then((res) => {
// if (res.code == 200) {
// if (res.data) {
// this.partsCount = res.data.totalPartCount
// }
// } else {
// console.log(res.message)
// }
// });
// },
getSignDistance(){
let self = this
var data={}
self.$u.api.getSignDistance(data).then((res) => {
if (res.code == 200) {
self.signDistance = res.data
}
});
},
loadOrderRecord() {
let self = this
var param = {
orderId: self.orderId
};
self.$u.api.listOrderRecord(param).then((res) => {
if (res.code == 200) {
res.data.forEach(item =>{
item.isTrace = false
item.traceTime = null
item.traceLabel = item.operationType
if (item.operationType === '报备' || item.operationType === '改约'){
item.isTrace = true
item.traceLabel = item.operationType === '报备' ? '下次联系时间' : '改约时间'
item.operationTypeText = item.operationType
item.traceTime = item.orderRecordRemark
let arr = item.orderRecordRemark.split(',')
if(arr && arr.length > 1) {
let remark = arr[1].substring(arr[1].indexOf(':')+1,arr[1].length)
item.traceTime = remark
item.operationTypeText = arr[0]
}
} else if(item.operationType === '预约') {
let remark = item.orderRecordRemark.substring(item.orderRecordRemark.lastIndexOf(",")+1);
item.traceTime = remark
item.operationTypeText = `上门 ${remark}`
} else {
item.operationTypeText = item.operationType
}
})
self.orderRecords = res.data
} else {
console.log(res.message, "获取订单详情失败!");
}
})
},
weekChange(data){
// 点击下一周
if (data && data.time) {
let num = data.num
let time = data.time
this.num = num
if (num == 0) {
this.loadCalendar()
} else {
this.loadCalendar()
}
}
},/* 加载日历数据 */
async loadCalendar() {
let self = this
let params = {
num: this.num
}
self.dateItem = null
let res = await this.$u.api.workerCalendar(params)
if(res && res.code == 200) {
self.dateList = res.data
}
this.loadTimerange()
},
/* 加载预约时间段 */
async loadTimerange() {
let self = this
let res = await this.$u.api.openTimerange()
if(res && res.code == 200) {
let list = res.data
list.map((item, index) => {
if(self.dateItem && self.dateItem.timeRange.indexOf(item.pkey) > -1 || item.isEnd) {
item.disabled = true
} else {
false
}
})
self.timeList = list
}
},
dateChange(data){
// 点击日期选择
let self = this
self.appointmentDatetime = data.item.day
self.dateItem = data.item
self.appointmentDatetimeRange = null
self.timeList.map((item, index) => {
if(data.item.timeRange.indexOf(item.pkey) > -1 || item.isEnd) {
item.disabled = true
} else {
item.disabled = false
}
})
},
timeChange(data){
// 时间段选择变化
this.appointmentDatetimeRange = data.item
},
addressToCoordinate(){
let self = this
self.$u.api.addressToCoordinate(self.orderId).then((res) => {
if (res.code == 200) {
self.contactAddressLongitud=res.data.lng
self.contactAddressLatitud = res.data.lat
} else {
console.log(res.message);
}
})
},
setOrderType() {
// 确定工单类型
var orderStatus = this.order.orderStatus
if (orderStatus < 31) {
// 接单
this.type = 'waitAccept'
this.submitType = this.isCompetition ? 'orderGan' : 'orderAccept'
} else if (orderStatus === 31 && !this.order.appointmentDatetime) {
// 预约
this.type = 'waitAppointment'
this.submitType = "workerAppointment"
this.loadCalendar()
} else if (orderStatus === 31 && this.order.appointmentDatetime) {
// 签到
this.type = 'waitCheckIn'
this.submitType = "maintainWorkerCheckin"
this.updateLocation()
} else if (orderStatus > 31 && orderStatus < 80) {
// 完工
this.type = 'waitFinish'
this.submitType = "toFilish"
}else if (orderStatus == 85 || orderStatus == 87 || orderStatus == 88) { // 审核中
this.type = 'audit'
} else if (orderStatus == 86) { // 异常单
this.type = 'exception'
} else if ([80, 81, 89, 110].indexOf(orderStatus) != -1) { // 已完工
this.type = 'finish'
}
this.readMore = this.type != 'waitAccept'
},
handleClickSure() {
if ((this.submitType == 'orderAccept' || this.submitType == 'orderGan') && process.uniEnv.node_env == 'prod') {
this.$u.api.checkAddCustomer().then((res) => {
if (res.code == 200) {
if(res.data === true){
this.handleBtn()
} else {
this.visible = true
}
} else {}
})
} else {
this.handleBtn()
}
},
handleSubmit(id) {
console.log(id)
// 0 主流程; 1 过程反馈;2 异常签到; 3 现场拍照
switch (id) {
case 0:
this.handleClickSure()
break
case 1:
this.clickFeedback()
break
case 2:
getApp().track("order_errorSign", {orderId: this.orderId})
this.take()
break
case 3:
getApp().track("order_scenePhotoClick", {orderId: this.orderId})
this.scenePhotoClick()
break
case 4:
this.handleApplyParts()
break
}
},
handleApplyParts() { // 点击了配件申请按钮
// if (this.buttons[3].count > 0) { // 已经有配件,弹出配件列表
// this.showApplyList = true
// this.getApplyList()
// } else { // 没有配件,跳到配件申请
this.toApplyParts()
// }
},
async getApplyList() {
let res = await this.$u.api.applyList({
'pageSize': 1000,
'pageNumber': 1,
// 'status': null, // -不传值 全部 待签收 15 待发货 10 待审核 1 已取消 -1 已驳回 -2 已签收 20
'workOrderId': this.order.orderId
})
if(res && res.code == 200) {
this.partsList = res.data || []
}
},
handleBtn() {
console.log('click button')
if(!this.submitType){
return;
}
const data = {}
// 不同请求类型传递不同数据
if(this.submitType === 'orderAccept'){ // 接单
data.orderId = this.order.orderId
}else if(this.submitType === 'orderGan'){ // 抢单
data.orderId = this.order.orderId
data.channel = 4
}else if(this.submitType === 'workerAppointment'){ // 预约
data.appointmentDatetime =this.appointmentDatetime
if(!data.appointmentDatetime ){
this.commonToast('请选择预约日期','waring')
return
}
if( !this.appointmentDatetimeRange || !this.appointmentDatetimeRange.pkey ){
this.commonToast('请选择预约时间段','waring')
return
}
data.appointmentDatetimeRange = this.appointmentDatetimeRange.pkey
}else if (this.submitType === 'maintainWorkerCheckin') { // 签到
// 检查见到距离是否符合
if(!this.isErrorSign){
if(this.centerBtnDisabled){
return
}else{
this.closeLocationChange()
}
if(this.getDistance() > this.signDistance){
this.commonToast('签到失败,请点击异常签到处理或联系客服','error')
return
}
}
data.channel = 4
data.exception = this.isErrorSign
data.coordinate = this.dataValue ? this.dataValue[0]+','+this.dataValue[1]:''
data.url = this.errorSignUrl?this.errorSignUrl:''
} else if(this.submitType === 'toFilish'){ // 去完工
if (this.order.categoryName != '充电桩') {
uni.showModal({
title: '提示',
content: '非充电桩订单,请在扳手APP进行完工',
showCancel:false,
confirmText: '好的',
})
} else {
this.filish()
}
return
}
if (this.clicking) {
return
}
this.clicking = true
this.$u.api[this.submitType](data, this.order.orderId).then(res => {
let self = this
if (res.code === 200) {
this.trackOrder()
this.$refs.uToast.show({
title: this.bottomButtonText + '操作成功',
type: 'success',
duration: 1000,
callback : function(){
if(self.unloaded === false) { // 如果用户一秒钟之内没有后退退出该页面才跳转
self.clicking = false
uni.redirectTo({
url: 'pages/order/detail?id='+self.order.orderId
});
}
}
})
} else {
let self = this
this.$refs.uToast.show({
title: res.data.message!==undefined ? res.data.message:res.message,
// 如果不传此type参数,默认为default,也可以手动写上 type: 'default'
type: 'warning',
callback: function() {
self.clicking = false
res.data.message==='抱歉,手快的师傅已经抢到此单!'?self.isGan():''
}
})
}
})
},
// 去业务材料页面
handleClickFile() {
getApp().track("order_click_view_files", {
brandId: this.order.lianbaoBrandId,
partnerCompanyId: this.order.partnerCompanyId
})
this.$u.route({url: 'pages/order/document' + '?partnerCompanyId=' + this.order.partnerCompanyId + '&brandId=' + this.order.lianbaoBrandId})
},
trackOrder() {
// 接单成功事件,签到成功事件
if(this.submitType == 'orderAccept'
|| this.submitType == 'maintainWorkerCheckin') {
getApp().track(this.submitType, {
orderId: this.order.orderId
});
}
},
commonToast(message,type,url,params){ // 统一得toast
this.$refs.uToast.show({
title: message,
type: type,
url: url,
params:params
})
},
isGan(){
this.type = 'snapped'
this.submitType = ''
this.centerBtnDisabled = true
},
clickFeedback(){
getApp().track("order_clickFeedback", {
orderId: this.order.orderId,
categoryId: this.order.categoryId
})
// 过程反馈
uni.navigateTo({
url: 'pages/order/feedback?orderId='+this.order.orderId+'&categoryId='+this.order.categoryId+'&showGY=' + (this.bottomButtonText != '预约' ? '1' : '0')
})
},
filish(){
// 去完工
// import appointTime from '@/components/appoint/appoint-time.vue'
import takePhoto from '@/components/take/index.vue'
// import PopView from "@/components/popView/index.vue"
import baseFile from '@/components/upload/index'
import Customer from '@/components/mine/customer.vue'
import Record from '@/components/order/performanceRecord.vue'
import Detail from '@/components/order/detail.vue'
import BottomButtons from '@/components/order/bottomButtons.vue'
import FeedbackContent from '@/components/order/feedback.vue'
uni.navigateTo({
url: 'pages/order/complete?orderId='+this.order.orderId
+ "&categoryId=" + this.order.categoryId
+ "&orderServiceType=" + this.order.orderServiceType
+ "&inGuaranteePeriod=" + this.order.inGuaranteePeriod
+ "&partnerCompanyId=" + this.order.partnerCompanyId
+ '&partnerCompanyName=' + this.order.partnerCompanyName
+ '&maintainStep=' + this.order.maintainStep
+ '&orderStatus=' + this.order.orderStatus
+ '&brandId=' + this.order.lianbaoBrandId
})
},
rejectOrder() { // 拒单
// 检查是否可以拒单
var data={}
this.$u.api.checkRejectable(data).then(res => {
if (res.code === 200 ) {
if( res.data && res.data.rejectable){
this.$u.route({
type: 'redirect',
url: 'pages/order/refuse',
params: {
orderId: this.order.orderId,
count: res.data.remainderTimes
}
})
}else{
this.commonToast("本月无拒单机会,请联系客服","warning")
}
}
})
},
/**
* 获取当前位置的经纬度
*/
getLocation() {
let self = this
const dataValue = this.dataValue || []
uni.getLocation({
type: 'gcj02',
success: function(res) {
dataValue.push(res.longitude)
dataValue.push(res.latitude)
self.dataValue = dataValue
},
complete: function(res) {
if (res.errMsg.indexOf('auth') != -1) {
uni.showModal({
title: '提示',
content: '获取权限失败,请到设置页面开启权限',
confirmText: '好的',
success(res) {
if (res.confirm) {
uni.openSetting({
success(res) {
console.log(res.authSetting)
}
});
}
}
})
}
},
});
},
getDistance(Latitud, Longitud){
return this.distance(this.order.contactAddressLatitud,this.order.contactAddressLongitud,this.dataValue[1],this.dataValue[0])
},
/**
* echo distance(116.3896,39.91917,116.3940,39.91726);
* 计算两点之间直线距离
* @param float $lon1 纬度
* @param float $lat1 经度
* @param float $lon2 纬度
* @param float $lat2 经度
* @return float 浮点数
*/
distance(lat1, lng1, lat2, lng2) {
var radLat1 = this.Rad(lat1);
var radLat2 = this.Rad(lat2);
var a = radLat1 - radLat2;
var b = this.Rad(lng1) - this.Rad(lng2);
var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) +
Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));
s = s *6378.137 ;// EARTH_RADIUS;
s = Math.round(s * 10000)/10 ; //输出为米
console.log("计算结果",s,'M');
return Number(s?s.toFixed(2):0);
},
Rad(d){
return d * Math.PI / 180.0;//经纬度转换成三角函数中度分表形式。
},
timeOutChange(timestamp){
if (this.timeout) this.$refs['order-count-down'].seconds += 2
if (timestamp == 0 && !this.timeout) { // 超时之后倒计时变为正计时
setTimeout(()=> {
this.timestamp = 1
this.timeout = true
}, 1000)
}
},
// handleClick(){
// this.visible = false
// // 交互规范
// uni.switchTab({
// url: 'pages/index/learn'
// })
// },
handleJoin() {
this.visible = false
// 添加客服
},
handleOperate() { // 点了弹窗里的配件操作
this.$u.api[operateType](partsId).then(res => {
var type = 'error'
var message = res.message
if (res.code === 200) {
type = 'success'
for (var item of this.partsList) {
if (item.id == partsId) {
item.status = willStatus
break
}
}
} else {
console.log(res.message)
}
this.$refs.uToast.show({
title: message,
type: type,
duration: 1500,
callback: function() {}
})
})
},
handleClickCell(info) {
this.setPageInfo(info)
uni.navigateTo({
url: 'pages/mine/warehouse/partsDetail'
})
},
handleClickExpress(info) {
this.setPageInfo(info)
uni.navigateTo({
url: 'pages/mine/warehouse/express'
})
},
setPageInfo(info) {
var pages = getCurrentPages();
if (pages.length >= 1) {
var page = pages[pages.length - 1];
page.info = info
}
},
handleApply() { // 点了弹窗的申请配件
this.toApplyParts()
},
toApplyParts() {
uni.navigateTo({
url: 'pages/parts/application?orderId='+this.order.orderId
})
}
}
};
// import ApplyList from "@/components/parts/applyList.vue"
let now = new Date(new Date().toLocaleDateString()).getTime()
export default {
components: {
// appointTime,
'take-photo': takePhoto,
// PopView,
Customer,
Record,
Detail,
BottomButtons,
FeedbackContent,
// ApplyList
},
mixins: [baseFile],
data() {
return {
type: '',
readMore: true, // 是:显示的是'查看更多'按钮;否:显示的是'点击收起'按钮
background: {
backgroundColor: 'none',
// 导航栏背景图
// background: 'url(https://cdn.uviewui.com/uview/swiper/1.jpg) no-repeat',
// 还可以设置背景图size属性
// backgroundSize: 'cover',
// 渐变色
},
visible: false,
// orderId: null,
orderId: 11880366, // 测试数据
order: {},
needPhotograph: true, // 需要现场拍摄
orderRecords: [],
method: null,
submitType: '',
nextUrl: '',
takeStatus: false,
isErrorSign: false,
errorSignUrl: '',
signDistance: 3000,
contactAddressLongitud: 0,
contactAddressLatitud: 0,
num: 0,
clicking: false,
dateItem: null,
centerBtnDisabled: false,
settlementInfo: { formatTime: '-', list: [], amount: '' },
unloaded: false,
timeout: false,
timestamp: 0,
showCountTime: false, // 从上个页面传入是否显示倒计时
// showApplyList: false, // 显示已申请配件列表
partsList: [], // 已申请的配件列表
partsCount: 0,
}
},
computed: {
customStyle() {
return {
height: '48rpx',
width: '100rpx',
color: '#FFFFFF',
'border-color': 'transparent',
'background-color': 'transparent',
}
},
buttons() {
//id: 0 主流程; 1 过程反馈;2 异常签到; 3 现场拍照; 4 备件申请
// label: 按钮文字,
// type: 'image' 上图片下文字;'text' 纯文字,
// image: 图片名,
// show: 是否显示,
// disabled: 是 禁用;否 正常,
// id: 区分各个按钮
return [
{
label: '异常签到',
type: 'image',
image: 'yichangqiandao.png',
show: this.isWaitCheckIn, // 待签到显示
disabled: false,
id: 2,
},
{
label: '现场拍照',
type: 'image',
image: 'xiancahngpaizhao.png',
show: this.isWaitFinish,
disabled: false,
id: 3,
},
{
label: '备件申请',
type: 'image',
image: 'peijian.png',
show: this.showPartsButton,
disabled: false,
count: this.partsCount,
id: 4,
},
{
label: '改约',
type: 'image',
image: 'guochengfankui.png',
show: this.allowFeedback,
disabled: false,
id: 1,
},
{
label: this.bottomButtonText,
type: 'text',
image: '',
show: true,
disabled: this.centerBtnDisabled,
id: 0,
customStyle: {
'background-color': this.isCompetitionAndWaitAccept
? '#FF930D'
: this.centerBtnDisabled
? '#D1D4D4'
: '#2272FF',
},
},
]
},
clockName() {
return this.timeout ? 'timeout' : 'clock'
},
countColor() {
return this.timeout ? '#FA5A49' : '#2272FF'
},
wenjianImage() {
return process.uniEnv.qn_base_url + 'wenjian.png'
},
types() {
return {
waitAccept: 0, // 待接单、待抢单
waitAppointment: 1, // 待预约、
waitCheckIn: 2, // 待签到、
waitFinish: 3, // 待完工、
audit: 4, // 审核中、
exception: 5, // 异常单、
finish: 6, // 已完工
snapped: 8, // 已被抢
other: 9, // 工单结算信息
}
},
titles() {
return [
'待' + this.type0Text,
'待预约',
'待签到',
'待完工',
'审核中',
'异常单',
'已完工',
'',
'',
'订单信息',
]
},
bottomButtonText() {
// 底部主流程按钮文字
return this.buttonTexts[this.types[this.type]]
},
buttonTexts() {
return [
this.type0Text,
'预约',
'签到',
'去完工',
'',
'',
'',
'',
'已被抢',
'',
]
},
tipText() {
// 时间紧迫提示文字
return this.timeout ? '订单超时' : '剩余时间'
},
title() {
// 标题
return this.titles[this.types[this.type]]
},
type0Text() {
return this.isCompetition ? '抢单' : '接单'
},
isCompetition() {
// 是:订单池,抢单; 否:指派单,接单
return this.order.orderBusinessType == 'R'
},
isOther() {
// 工单结算信息
return this.type == 'other'
},
allowRejection() {
// 允许拒单
// 待接单 && 业务类型非抢单
return this.type == 'waitAccept' && !this.isCompetition
},
isCompetitionAndWaitAccept() {
// 抢单页面
// 待接单 && 业务类型抢单
return this.type == 'waitAccept' && this.isCompetition
},
showBottomBtn() {
// 显示底部button
// 0 待接单、待抢单, 1 待预约, 2 待签到, 3 待完工, 8 已被抢
return [0, 1, 2, 3, 8].indexOf(this.types[this.type]) != -1
},
showFile() {
// 显示查看业务文件
// 1 待预约, 2 待签到, 3 待完工, 4 审核中, 5 异常单, 6 已完工, 8 已被抢
return this.types[this.type] > 0
},
isAllowDianhuaAndDaohang() {
// 可以点击电话和定位按钮
return this.type != 'waitAccept'
},
showTimeView() {
// 是否显示倒计时窗口
// 上个页面传入 || 订单信息有超过时间点 && ((待预约、 待签到、 待完工) || (待接单 && 业务类型非抢单))
return (
this.showCountTime ||
(this.order.currentOverTime &&
([1, 2, 3].indexOf(this.types[this.type]) != -1 ||
(this.type == 'waitAccept' && !this.isCompetition)))
)
},
showPartsButton() {
// 显示配件申请按钮
// 1 待预约, 2 待签到, 3 待完工
return [1, 2, 3].indexOf(this.types[this.type]) != -1
},
allowFeedback() {
// 允许改约
// 2 待签到, 3 待完工
return [2, 3].indexOf(this.types[this.type]) != -1
// return [1, 2, 3].indexOf(this.types[this.type]) != -1
},
isWaitCheckIn() {
// 待签到
return this.type == 'waitCheckIn'
},
isWaitAppointment() {
// 待预约
return this.type == 'waitAppointment'
},
isWaitFinish() {
return this.type == 'waitFinish'
},
},
onLoad(option) {
getApp().trackPage('订单详情页')
// 生命周期函数--监听页面加载
if (option && option.id) {
this.orderId = option.id
}
if (option && option.showCountTime) {
// 是否显示倒计时,上个页面传入,可以快速显示避免页面跳动太大;之后还需要从后台获取信息,再根据其他条件判断一次
this.showCountTime = option.showCountTime
}
if (option && option.type) {
// 类型,从上个页面传进来可以快速构建页面;之后还需要从后台获取信息,更新状态
// 'waitAccept': 待接单、待抢单;'waitAppointment': 待预约;'waitCheckIn': 待签到;'waitFinish': 待完工;'audit': 审核中;'exception': 异常单;'finish': 已完工;'other': 工单结算信息
this.type = option.type
}
this.loadOrderDetail()
this.getLocation()
if (this.isOther) {
// 获取结算信息
this.loadSettlement()
} else {
this.loadOrderRecord() // 履约记录
this.getSignDistance() // 定位
// this.getOrderPartsSum() // 备件单数量
}
},
onShow() {
// 从过程反馈回来,需要刷新数据
let pages = getCurrentPages()
let page = pages[pages.length - 1]
if (page.needFresh) {
page.needFresh = null
this.loadOrderDetail()
this.loadOrderRecord()
}
if (page.needRefresh) {
page.needRefresh = null
this.getApplyList()
}
},
onUnload() {
this.unloaded = true
this.closeLocationChange()
},
methods: {
updateLocation() {
let self = this
wx.startLocationUpdate({
success: function() {
self.openLocationChange()
},
})
},
_locationChangeFn(res) {
let self = this
console.log('location change', res)
const dataValue = this.dataValue || []
dataValue.push(res.longitude)
dataValue.push(res.latitude)
self.dataValue = dataValue
if (this.getDistance(res.latitude, res.longitude) > this.signDistance) {
// 计算签到距离
this.centerBtnDisabled = true
} else {
this.centerBtnDisabled = false
}
},
openLocationChange() {
console.log('openLocationChange')
wx.onLocationChange(this._locationChangeFn)
},
closeLocationChange() {
console.log('closeLocationChange')
wx.offLocationChange(this._locationChangeFn)
},
handleClickRight(active) {
this.isWaitFinish ? this.scenePhotoClick() : this.take()
},
scenePhotoClick() {
// 跳转拍照小程序
uni.navigateTo({
url:
'pages/photo/list?orderId=' +
this.order.orderId +
'&brandId=' +
this.order.lianbaoBrandId +
'&brand=' +
this.order.brandName +
'&systemId=' +
this.order.partnerCompanyId +
'&classifyId=' +
this.order.categoryId,
})
},
take() {
uni.hideTabBar()
this.takeStatus = true
},
async closeTake(img) {
this.takeStatus = false
// 获取返回的图片 ,如果返回的图片存在则直接异常签约,成功后跳转到去完工页面,
if (img) {
// 拍照完成
const files = img.map((v) => v.path)
const value = await this.saveToTask(files)
this.isErrorSign = true
this.errorSignUrl = value[0].key
this.handleBtn()
} else {
this.$refs.uToast.show({
title: '异常签到失败,请先按要求拍照',
type: 'warning',
})
}
},
loadOrderDetail() {
// 获取工单详情
let self = this
let timestamp = new Date().getTime()
var data = {
orderId: self.orderId,
}
self.$u.api.orderDetail(data, self.orderId).then((res) => {
if (res.code == 200) {
self.order = res.data
this.setOrderType()
var nowTime = new Date().getTime()
this.timeout =
this.order.currentOverTime && nowTime > this.order.currentOverTime
this.timestamp = Math.round(
Math.abs(this.order.currentOverTime - nowTime) / 1000
)
// 格式化时间
this.settlementInfo.formatTime = this.order.settleCenterSyncDatetime
? this.$u.timeFormat(
this.order.settleCenterSyncDatetime,
'yyyy.mm.dd hh:MM:ss'
)
: '-'
} else {
console.log(res.message, '获取订单详情失败!')
}
})
},
loadSettlement() {
// 获取工单详情
let self = this
var data = {
orderId: self.orderId,
}
self.$u.api.querySettleByOrder(data, self.orderId).then((res) => {
if (res.code == 200) {
var amount = 0
for (var item of res.data) {
amount += item.realSettlementAmount || item.settlementAmount
}
this.settlementInfo.amount = amount
this.settlementInfo.list = res.data
} else {
console.log(res.message, '获取订单详情失败!')
}
})
},
// getOrderPartsSum() { // 获取订单配件数量
// this.$u.api.getOrderPartsSum(this.orderId).then((res) => {
// if (res.code == 200) {
// if (res.data) {
// this.partsCount = res.data.totalPartCount
// }
// } else {
// console.log(res.message)
// }
// });
// },
getSignDistance() {
let self = this
var data = {}
self.$u.api.getSignDistance(data).then((res) => {
if (res.code == 200) {
self.signDistance = res.data
}
})
},
loadOrderRecord() {
let self = this
var param = {
orderId: self.orderId,
}
self.$u.api.listOrderRecord(param).then((res) => {
if (res.code == 200) {
res.data.forEach((item) => {
item.isTrace = false
item.traceTime = null
item.traceLabel = item.operationType
if (
item.operationType === '报备' ||
item.operationType === '改约'
) {
item.isTrace = true
item.traceLabel =
item.operationType === '报备' ? '下次联系时间' : '改约时间'
item.operationTypeText = item.operationType
item.traceTime = item.orderRecordRemark
let arr = item.orderRecordRemark.split(',')
if (arr && arr.length > 1) {
let remark = arr[1].substring(
arr[1].indexOf(':') + 1,
arr[1].length
)
item.traceTime = remark
item.operationTypeText = arr[0]
}
} else if (item.operationType === '预约') {
let remark = item.orderRecordRemark.substring(
item.orderRecordRemark.lastIndexOf(',') + 1
)
item.traceTime = remark
item.operationTypeText = `上门 ${remark}`
} else {
item.operationTypeText = item.operationType
}
})
self.orderRecords = res.data
} else {
console.log(res.message, '获取订单详情失败!')
}
})
},
handleChange(val) {
console.log('-----handleChange-------', val)
},
addressToCoordinate() {
let self = this
self.$u.api.addressToCoordinate(self.orderId).then((res) => {
if (res.code == 200) {
self.contactAddressLongitud = res.data.lng
self.contactAddressLatitud = res.data.lat
} else {
console.log(res.message)
}
})
},
setOrderType() {
// 确定工单类型
var orderStatus = this.order.orderStatus
if (orderStatus < 31) {
// 接单
this.type = 'waitAccept'
this.submitType = this.isCompetition ? 'orderGan' : 'orderAccept'
} else if (orderStatus === 31 && !this.order.appointmentDatetime) {
// 预约
this.type = 'waitAppointment'
this.submitType = 'workerAppointment'
// this.loadCalendar()
} else if (orderStatus === 31 && this.order.appointmentDatetime) {
// 签到
this.type = 'waitCheckIn'
this.submitType = 'maintainWorkerCheckin'
this.updateLocation()
} else if (orderStatus > 31 && orderStatus < 80) {
// 完工
this.type = 'waitFinish'
this.submitType = 'toFilish'
} else if (orderStatus == 85 || orderStatus == 87 || orderStatus == 88) {
// 审核中
this.type = 'audit'
} else if (orderStatus == 86) {
// 异常单
this.type = 'exception'
} else if ([80, 81, 89, 110].indexOf(orderStatus) != -1) {
// 已完工
this.type = 'finish'
}
this.readMore = this.type != 'waitAccept'
},
handleClickSure() {
if (
(this.submitType == 'orderAccept' || this.submitType == 'orderGan') &&
process.uniEnv.node_env == 'prod'
) {
this.$u.api.checkAddCustomer().then((res) => {
if (res.code == 200) {
if (res.data === true) {
this.handleBtn()
} else {
this.visible = true
}
} else {
}
})
} else {
this.handleBtn()
}
},
handleSubmit(id) {
// 0 主流程; 1 过程反馈;2 异常签到; 3 现场拍照
switch (id) {
case 0:
this.handleClickSure()
break
case 1:
this.clickFeedback()
break
case 2:
getApp().track('order_errorSign', { orderId: this.orderId })
this.take()
break
case 3:
getApp().track('order_scenePhotoClick', { orderId: this.orderId })
this.scenePhotoClick()
break
case 4:
this.handleApplyParts()
break
}
},
handleApplyParts() {
// 点击了配件申请按钮
// if (this.buttons[3].count > 0) { // 已经有配件,弹出配件列表
// this.showApplyList = true
// this.getApplyList()
// } else { // 没有配件,跳到配件申请
this.toApplyParts()
// }
},
async getApplyList() {
let res = await this.$u.api.applyList({
pageSize: 1000,
pageNumber: 1,
// 'status': null, // -不传值 全部 待签收 15 待发货 10 待审核 1 已取消 -1 已驳回 -2 已签收 20
workOrderId: this.order.orderId,
})
if (res && res.code == 200) {
this.partsList = res.data || []
}
},
handleBtn() {
if (!this.submitType) {
return
}
var data = {}
// 不同请求类型传递不同数据
if (this.submitType === 'orderAccept') {
// 接单
data.orderId = this.order.orderId
} else if (this.submitType === 'orderGan') {
// 抢单
data.orderId = this.order.orderId
data.channel = 4
} else if (this.submitType === 'workerAppointment') {
data = this.$refs['feed-back'].submitData
if (!data.appointmentDatetime) {
this.commonToast('请选择预约日期', 'waring')
return
}
if (!data.appointmentDatetimeRange) {
this.commonToast('请选择预约时间段', 'waring')
return
}
} else if (this.submitType === 'maintainWorkerCheckin') {
// 签到
// 检查见到距离是否符合
if (!this.isErrorSign) {
if (this.centerBtnDisabled) {
return
} else {
this.closeLocationChange()
}
if (this.getDistance() > this.signDistance) {
this.commonToast('签到失败,请点击异常签到处理或联系客服', 'error')
return
}
}
data.channel = 4
data.exception = this.isErrorSign
data.coordinate = this.dataValue
? this.dataValue[0] + ',' + this.dataValue[1]
: ''
data.url = this.errorSignUrl ? this.errorSignUrl : ''
} else if (this.submitType === 'toFilish') {
// 去完工
if (this.order.categoryName != '充电桩') {
uni.showModal({
title: '提示',
content: '非充电桩订单,请在扳手APP进行完工',
showCancel: false,
confirmText: '好的',
})
} else {
this.filish()
}
return
}
if (this.clicking) {
return
}
this.clicking = true
this.$u.api[this.submitType](data, this.order.orderId).then((res) => {
let self = this
if (res.code === 200) {
this.trackOrder()
this.$refs.uToast.show({
title: this.bottomButtonText + '操作成功',
type: 'success',
duration: 1000,
callback: function() {
if (self.unloaded === false) {
// 如果用户一秒钟之内没有后退退出该页面才跳转
self.clicking = false
uni.redirectTo({
url: 'pages/order/detail?id=' + self.order.orderId,
})
}
},
})
} else {
let self = this
this.$refs.uToast.show({
title:
res.data.message !== undefined ? res.data.message : res.message,
// 如果不传此type参数,默认为default,也可以手动写上 type: 'default'
type: 'warning',
callback: function() {
self.clicking = false
res.data.message === '抱歉,手快的师傅已经抢到此单!'
? self.isGan()
: ''
},
})
}
})
},
// 去业务材料页面
handleClickFile() {
getApp().track('order_click_view_files', {
brandId: this.order.lianbaoBrandId,
partnerCompanyId: this.order.partnerCompanyId,
})
this.$u.route({
url:
'pages/order/document' +
'?partnerCompanyId=' +
this.order.partnerCompanyId +
'&brandId=' +
this.order.lianbaoBrandId,
})
},
trackOrder() {
// 接单成功事件,签到成功事件
if (
this.submitType == 'orderAccept' ||
this.submitType == 'maintainWorkerCheckin'
) {
getApp().track(this.submitType, {
orderId: this.order.orderId,
})
}
},
commonToast(message, type, url, params) {
// 统一得toast
this.$refs.uToast.show({
title: message,
type: type,
url: url,
params: params,
})
},
isGan() {
this.type = 'snapped'
this.submitType = ''
this.centerBtnDisabled = true
},
clickFeedback() {
getApp().track('order_clickFeedback', {
orderId: this.order.orderId,
categoryId: this.order.categoryId,
})
// 过程反馈
uni.navigateTo({
url:
'pages/order/feedback?orderId=' +
this.order.orderId +
'&categoryId=' +
this.order.categoryId +
'&showGY=' +
(this.bottomButtonText != '预约' ? '1' : '0'),
})
},
filish() {
// 去完工
uni.navigateTo({
url:
'pages/order/complete?orderId=' +
this.order.orderId +
'&categoryId=' +
this.order.categoryId +
'&orderServiceType=' +
this.order.orderServiceType +
'&inGuaranteePeriod=' +
this.order.inGuaranteePeriod +
'&partnerCompanyId=' +
this.order.partnerCompanyId +
'&partnerCompanyName=' +
this.order.partnerCompanyName +
'&maintainStep=' +
this.order.maintainStep +
'&orderStatus=' +
this.order.orderStatus +
'&brandId=' +
this.order.lianbaoBrandId,
})
},
rejectOrder() {
// 拒单
// 检查是否可以拒单
var data = {}
this.$u.api.checkRejectable(data).then((res) => {
if (res.code === 200) {
if (res.data && res.data.rejectable) {
this.$u.route({
type: 'redirect',
url: 'pages/order/refuse',
params: {
orderId: this.order.orderId,
count: res.data.remainderTimes,
},
})
} else {
this.commonToast('本月无拒单机会,请联系客服', 'warning')
}
}
})
},
/**
* 获取当前位置的经纬度
*/
getLocation() {
let self = this
const dataValue = this.dataValue || []
uni.getLocation({
type: 'gcj02',
success: function(res) {
dataValue.push(res.longitude)
dataValue.push(res.latitude)
self.dataValue = dataValue
},
complete: function(res) {
if (res.errMsg.indexOf('auth') != -1) {
uni.showModal({
title: '提示',
content: '获取权限失败,请到设置页面开启权限',
confirmText: '好的',
success(res) {
if (res.confirm) {
uni.openSetting({
success(res) {
console.log(res.authSetting)
},
})
}
},
})
}
},
})
},
getDistance(Latitud, Longitud) {
return this.distance(
this.order.contactAddressLatitud,
this.order.contactAddressLongitud,
this.dataValue[1],
this.dataValue[0]
)
},
/**
* echo distance(116.3896,39.91917,116.3940,39.91726);
* 计算两点之间直线距离
* @param float $lon1 纬度
* @param float $lat1 经度
* @param float $lon2 纬度
* @param float $lat2 经度
* @return float 浮点数
*/
distance(lat1, lng1, lat2, lng2) {
var radLat1 = this.Rad(lat1)
var radLat2 = this.Rad(lat2)
var a = radLat1 - radLat2
var b = this.Rad(lng1) - this.Rad(lng2)
var s =
2 *
Math.asin(
Math.sqrt(
Math.pow(Math.sin(a / 2), 2) +
Math.cos(radLat1) *
Math.cos(radLat2) *
Math.pow(Math.sin(b / 2), 2)
)
)
s = s * 6378.137 // EARTH_RADIUS;
s = Math.round(s * 10000) / 10 //输出为米
console.log('计算结果', s, 'M')
return Number(s ? s.toFixed(2) : 0)
},
Rad(d) {
return (d * Math.PI) / 180.0 //经纬度转换成三角函数中度分表形式。
},
timeOutChange(timestamp) {
if (this.timeout) this.$refs['order-count-down'].seconds += 2
if (timestamp == 0 && !this.timeout) {
// 超时之后倒计时变为正计时
setTimeout(() => {
this.timestamp = 1
this.timeout = true
}, 1000)
}
},
// handleClick(){
// this.visible = false
// // 交互规范
// uni.switchTab({
// url: 'pages/index/learn'
// })
// },
handleJoin() {
this.visible = false
// 添加客服
},
handleOperate() {
// 点了弹窗里的配件操作
this.$u.api[operateType](partsId).then((res) => {
var type = 'error'
var message = res.message
if (res.code === 200) {
type = 'success'
for (var item of this.partsList) {
if (item.id == partsId) {
item.status = willStatus
break
}
}
} else {
console.log(res.message)
}
this.$refs.uToast.show({
title: message,
type: type,
duration: 1500,
callback: function() {},
})
})
},
handleClickCell(info) {
this.setPageInfo(info)
uni.navigateTo({
url: 'pages/mine/warehouse/partsDetail',
})
},
handleClickExpress(info) {
this.setPageInfo(info)
uni.navigateTo({
url: 'pages/mine/warehouse/express',
})
},
setPageInfo(info) {
var pages = getCurrentPages()
if (pages.length >= 1) {
var page = pages[pages.length - 1]
page.info = info
}
},
handleApply() {
// 点了弹窗的申请配件
this.toApplyParts()
},
toApplyParts() {
uni.navigateTo({
url: 'pages/parts/application?orderId=' + this.order.orderId,
})
},
},
}
</script>
<style lang="scss">
.order-wrap {
.u-countdown-colon {
margin-left: 6rpx;
margin-right: 6rpx;
}
.u-mode-center-box {
background-color: transparent !important;
padding-top: 40rpx;
}
}
.order-wrap {
.u-countdown-colon {
margin-left: 6rpx;
margin-right: 6rpx;
}
.u-mode-center-box {
background-color: transparent !important;
padding-top: 40rpx;
}
}
</style>
<style lang="scss" scoped>
.order-wrap {
width: 750rpx;
height: 100vh;
overflow: auto;
background-color: #F4F5F7;
background-image: linear-gradient(to top, #F4F5F7 0%, #2272FF 50%);
background-size: 750rpx 600rpx;
background-repeat: no-repeat;
display: flex;
flex-direction: column;
.order-wrap {
width: 750rpx;
height: 100vh;
overflow: auto;
background-color: #f4f5f7;
background-image: linear-gradient(to top, #f4f5f7 0%, #2272ff 50%);
background-size: 750rpx 600rpx;
background-repeat: no-repeat;
display: flex;
flex-direction: column;
.content {
height: 100%;
border-radius: 12rpx;
overflow: auto;
margin: 0rpx 30rpx 30rpx 30rpx;
.title-view {
display: flex;
justify-content: space-between;
align-items: flex-end;
margin-bottom: 20rpx;
.title-text {
font-weight: bold;
font-size: 48rpx;
color: #ffffff;
}
.reject-button {
width: 106rpx;
height: 52rpx;
font-size: 26rpx;
line-height: 52rpx;
color: #dedede;
text-align: right;
margin-right: 4rpx;
}
}
.card {
background-color: #ffffff;
margin-bottom: 20rpx;
padding: 30rpx 30rpx 0 30rpx;
border-radius: 6px;
.content {
height: 100%;
border-radius: 12rpx;
overflow: auto;
margin: 0rpx 30rpx 30rpx 30rpx;
.title-view {
display: flex;
justify-content: space-between;
align-items: flex-end;
margin-bottom: 20rpx;
.title-text {
font-weight: bold;
font-size: 48rpx;
color: #FFFFFF;
}
.reject-button {
width: 106rpx;
height: 52rpx;
font-size: 26rpx;
line-height: 52rpx;
color: #DEDEDE;
text-align: right;
margin-right: 4rpx;
}
}
.card {
background-color: #FFFFFF;
margin-bottom: 20rpx;
padding: 30rpx 30rpx 0 30rpx;
border-radius: 6px;
.header {
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 2rpx solid #F4F5F7;
padding-bottom: 26rpx;
margin-bottom: 30rpx;
.header-left-view {
display: flex;
align-items: center;
}
}
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 2rpx solid #f4f5f7;
padding-bottom: 26rpx;
margin-bottom: 30rpx;
.header-left-view {
display: flex;
align-items: center;
}
}
}
.record-item {
margin-bottom: 0rpx;
}
.record-item {
margin-bottom: 0rpx;
}
.appoint-item {
padding: 0;
}
}
}
.appoint-item {
padding: 0;
}
}
}
.settlement-view {
padding: 30rpx;
background-color: #FFFFFF;
border-radius: 12rpx;
.settlement-title {
font-size: 32rpx;
font-weight: bold;
color: #333333;
margin-bottom: 30rpx;
}
.settlement-content {
font-size: 26rpx;
color: #333333;
margin-bottom: 20rpx;
display: flex;
align-items: flex-start;
.content-left {
flex-shrink: 0;
}
}
}
.order-file {
display: flex;
justify-content: space-between;
align-items: center;
margin: 20rpx 0;
border-radius: 12rpx;
background-color: #FFFFFF;
padding: 24rpx 30rpx;
.order-file-left {
color: #333333;
font-size: 26rpx;
display: flex;
align-items: center;
.file-image {
width: 52rpx;
height: 52rpx;
flex-shrink: 0;
margin-right: 16rpx;
}
}
.order-file-right {
color: #2272FF;
font-size: 26rpx;
}
}
.settlement-view {
padding: 30rpx;
background-color: #ffffff;
border-radius: 12rpx;
.settlement-title {
font-size: 32rpx;
font-weight: bold;
color: #333333;
margin-bottom: 30rpx;
}
.settlement-content {
font-size: 26rpx;
color: #333333;
margin-bottom: 20rpx;
display: flex;
align-items: flex-start;
.content-left {
flex-shrink: 0;
}
}
}
.order-file {
display: flex;
justify-content: space-between;
align-items: center;
margin: 20rpx 0;
border-radius: 12rpx;
background-color: #ffffff;
padding: 24rpx 30rpx;
.order-file-left {
color: #333333;
font-size: 26rpx;
display: flex;
align-items: center;
.file-image {
width: 52rpx;
height: 52rpx;
flex-shrink: 0;
margin-right: 16rpx;
}
}
.order-file-right {
color: #2272ff;
font-size: 26rpx;
}
}
</style>
<!-- 过程反馈 -->
<!-- 改约 -->
<template>
<view class="feedback-box bg">
<u-navbar back-icon-color="#FFFFFF" :background="background" title="过程反馈" titleColor="#FFFFFF" :border-bottom="false" title-bold></u-navbar>
<view class="content u-p-l-30 u-p-r-30">
<view class="top-tab">
<u-tabs
:list="options"
:current="curTab"
height="60"
gutter="89"
bar-height="4"
bar-width="44"
bg-color="none"
active-color="#FFFFFF"
inactive-color="#DEDEDE"
font-size="32"
bold
@change="changeTab"
></u-tabs>
</view>
<view class="content-view">
<view class="con-box">
<view class="title">{{ traceTitles[0] }}</view>
<view class="u-flex u-flex-wrap">
<view
v-for="(item, index) in options[curTab]['owns']"
:key="index"
@click="changeOwn(index, item.name, item.types)"
:class="{ 'txt-item': true, active: curOwn == index }"
>
<text class="txt">{{ item.name }}</text>
</view>
</view>
<u-gap height="30"></u-gap>
<view class="title">{{ traceTitles[1] }}</view>
<view class="u-flex u-flex-wrap">
<view
v-for="(txt, index) in options[curTab]['owns'][curOwn]['types']"
:key="index"
@click="changeType(index, txt)"
:class="{ 'txt-item': true, active: trace.reason == txt }"
style="width: 306rpx;margin-right: 18rpx"
>
<text class="txt">{{ txt }}</text>
</view>
</view>
<view class="input-view">
<u-input v-model="trace.remark" class="textarea" height="156" type="textarea" placeholder="请补充详细说明,以便于记录您的接单信用分"></u-input>
</view>
</view>
<view class="time-view">
<appoint-time
:dateList="dateList"
:title="appointTitle"
:timeList="timeList"
:type="timeType"
:defaultAppointRangeItem="defaultAppointRangeItem"
@dateChange="dateChange"
@timeChange="timeChange"
@weekChange="weekChange"
></appoint-time>
</view>
</view>
</view>
<view class="bottom-view">
<button class="btn, bottom-btn" @click="$u.throttle(submitForm, 500)" :loading="submiting" :disabled="disabledSubmit"><text class="button-text">确定</text></button>
</view>
</view>
<view class="feedback-box bg">
<u-navbar
back-icon-color="#FFFFFF"
:background="background"
title="改约"
titleColor="#FFFFFF"
:border-bottom="false"
title-bold
></u-navbar>
<view class="content u-p-l-30 u-p-r-30">
<FeedbackContent
ref="feed-back"
:categoryId="categoryId"
@change="handleChange"
class="content-view"
/>
</view>
<view class="bottom-view">
<button
class="btn, bottom-btn"
@click="$u.throttle(submitForm, 500)"
:loading="submiting"
:disabled="disabledSubmit"
>
<text class="button-text">确定</text>
</button>
</view>
</view>
</template>
<script>
let now = new Date(new Date().toLocaleDateString()).getTime();
import appointTime from '@/components/appoint/appoint-time.vue';
export default {
data() {
return {
orderId: null,
categoryId: null,
showGY: true, // 非预约进来才显示改约
background: {
backgroundColor: 'none'
},
feedback: null,
options: [
{
name: '报备',
owns: [
{
name: '客户',
types: ['等客户报装电表', '等客户与物业沟通', '等客户改造电源', '客户不确定安装时间', '等客户通知安装时间', '客户电话未打通', '客户反馈暂不安装']
},
{ name: '个人', types: [] },
{ name: '客观', types: [] }
]
},
{ name: '改约', owns: [{ name: '客户', types: ['有事耽搁', '未带齐工具', '个人改约', '其他'] }, { name: '个人', types: [] }, { name: '客观', types: [] }] }
],
dateList: [
{ day: now, timeRange: [] },
{ day: now + 1 * 86400000, timeRange: [] },
{ day: now + 2 * 86400000, timeRange: [] },
{ day: now + 3 * 86400000, timeRange: [] },
{ day: now + 4 * 86400000, timeRange: [] },
{ day: now + 5 * 86400000, timeRange: [] },
{ day: now + 6 * 86400000, timeRange: [] }
],
timeList: [
{ name: '06:00-08:00', pkey: 'appointment_range_8', disabled: false },
{ name: '08:00-10:00', pkey: 'appointment_range_10', disabled: false },
{ name: '10:00-12:00', pkey: 'appointment_range_12', disabled: false },
{ name: '12:00-14:00', pkey: 'appointment_range_14', disabled: false },
{ name: '14:00-16:00', pkey: 'appointment_range_16', disabled: false },
{ name: '16:00-18:00', pkey: 'appointment_range_18', disabled: false },
{ name: '18:00-20:00', pkey: 'appointment_range_20', disabled: false },
{ name: '20:00-22:00', pkey: 'appointment_range_22', disabled: false },
{ name: '22:00-24:00', pkey: 'appointment_range_24', disabled: false }
],
traceTitles: ['问题归属', '问题类型'],
appointTitle: '预约时间',
appoint: ['下次联系时间', '预约时间'],
trace: {
reasonType: '报备', // 反馈类型
reasonRelegation: '客户', // 反馈归属
reason: '', // 反馈原因
remark: '' // 备注
},
traceDate: null, // 反馈时间
timeRange: null, // 反馈时间段
dateItem: null,
timeItem: null,
showRemark: false,
submiting: false,
curTab: 0,
curOwn: 0,
num: 0
};
},
components: {
appointTime
},
watch: {
// vuex_token(val) {
// this.initPageData();
// }
},
computed: {
disabledSubmit() {
let self = this;
if(self.trace.reasonRelegation && self.trace.reason && self.traceDate && self.timeRange) {
return false;
}
return true;
},
types() {
return {'报备': 'filing', '改约': 'subscribe'}
},
timeType() {
return this.types[this.options[this.curTab].name]
},
defaultAppointRangeItem() {
return this.options[this.curTab].defaultAppointRangeItem
}
},
async onLoad(e) {
getApp().trackPage('订单过程反馈页')
if (e) {
this.orderId = e.orderId || null;
this.categoryId = e.categoryId || null;
this.showGY = e.showGY == '1'
}
uni.showLoading({
title: '数据加载中',
mask: true
});
await this.initPageData();
},
methods: {
/* 初始化页面数据 */
async initPageData() {
let self = this;
await Promise.all([self.loadCalendar(), self.loadTimerange()]);
let params = { categoryId: self.categoryId };
let res = await self.$u.api.feedbackConfig(params);
if (res && res.code == 200) {
self.feedback = res.data || {};
self.buildConfig();
}
uni.hideLoading();
},
/* 组装数据项参数 */
buildConfig() {
let self = this;
if (self.feedback) {
let tabs = Object.keys(self.feedback);
let tabVals = Object.values(self.feedback);
let configs = [];
tabs.forEach(function(tab, index) {
let row = tabVals[index];
let owns = Object.keys(row);
let ownVals = Object.values(row);
var defaultAppointRangeItem = tab == '报备' ? { name: '22:00-24:00', pkey: 'appointment_range_24', disabled: false } : {}
configs[index] = { name: tab, owns: [], defaultAppointRangeItem: defaultAppointRangeItem};
if(tab == '改约') {
self.appoint[index] = '预约时间'
} else {
self.appoint[index] = '下次联系时间'
}
owns.forEach(function(own, key) {
configs[index]['owns'][key] = { name: own, types: ownVals[key] };
});
});
configs.map((item, key) => {
if(item.name == '报备') {
configs.splice(key, 1);
configs.unshift(item);
// 更新时间标题
let title = self.appoint[key]
self.appoint.splice(key, 1);
self.appoint.unshift(title);
} else if (item.name == '改约' && !self.showGY) {
configs.splice(key, 1);
// 更新时间标题
self.appoint.splice(key, 1);
}
})
// 数组改写需要刷新绑定数据
self.options = configs;
this.initParams()
}
},
/* 初始化参数 */
initParams() {
let self = this;
if (self.options) {
let tabList = self.options[self.curTab]
self.trace.reasonType = tabList.name;
self.trace.reasonRelegation = tabList['owns'][self.curOwn].name;
self.trace.reason = tabList['owns'][self.curOwn]['types'][0];
self.appointTitle = self.appoint[self.curTab]
self.trace.remark = '';
self.traceDate = null;
self.timeRange = null;
self.dateItem = null
if (self.trace.reasonType == '改约') {
self.showRemark = true;
if (self.dateList && self.timeList) {
self.timeList.map((item, index) => {
if (self.dateItem && self.dateItem.timeRange
&& self.dateItem.timeRange.indexOf(item.pkey) > -1 || item.isEnd) {
item.disabled = true;
} else {
item.disabled = false;
}
});
}
} else {
self.showRemark = false;
self.timeList.map((item, index) => {
item.disabled = false;
});
}
}
},
import FeedbackContent from '@/components/order/feedback.vue'
/* 加载日历数据 */
async loadCalendar() {
let self = this;
let res = await this.$u.api.workerCalendar({num: this.num});
if (res && res.code == 200) {
self.dateList = res.data;
}
},
export default {
data() {
return {
orderId: null,
categoryId: null,
submiting: false,
disabledSubmit: true,
}
},
components: {
FeedbackContent,
},
computed: {},
onLoad(e) {
getApp().trackPage('订单过程反馈页')
if (e) {
this.orderId = e.orderId || null
this.categoryId = e.categoryId || null
}
},
methods: {
handleChange(val) {
this.disabledSubmit = val
},
async submitForm() {
let submitData = this.$refs['feed-back'].submitData
let self = this
if (!self.orderId) {
uni.showToast({
icon: error,
title: '工单ID不能为空',
})
return false
}
/* 加载预约时间段 */
async loadTimerange() {
let self = this;
let res = await this.$u.api.openTimerange();
if (res && res.code == 200) {
let list = res.data;
list.map((item, index) => {
item.disabled = false;
});
self.timeList = list;
}
},
self.submiting = true
getApp().track('order_feedback_submitForm', {
reasonType: submitData.reasonType,
traceDate: submitData.traceDate,
})
/**
* 切换tab项
*/
changeTab(index) {
this.curTab = index;
this.initParams();
},
changeOwn(index, own, types) {
let self = this;
self.curOwn = index;
self.trace.reasonRelegation = own;
self.trace.reason = types[0];
},
changeType(index, type) {
this.trace.reason = type;
},
weekChange(data) {
// 点击下一周
console.log(data, 'week-data');
if (data && data.time) {
let num = data.num;
let time = data.time;
this.num = num;
if (num == 0) {
this.loadCalendar();
} else {
this.loadCalendar();
}
}
},
dateChange(data) {
// 点击日期选择
let self = this;
self.dateItem = data.item
if (self.trace.reasonType == '改约') {
self.timeList.map((item, index) => {
if (data.item.timeRange && data.item.timeRange.indexOf(item.pkey) > -1 || item.isEnd) {
item.disabled = true;
} else {
item.disabled = false;
}
});
} else {
self.timeList.map((item, index) => {
item.disabled = false;
});
}
self.traceDate = data.item.day;
self.timeRange = null;
},
timeChange(data) {
// 时间段选择变化
console.log(data, 'week-data');
this.timeRange = data.item.pkey;
this.timeItem = data.item
},
async submitForm() {
let self = this;
if (!self.orderId) {
uni.showToast({
icon: error,
title: '工单ID不能为空'
});
return false;
}
let res = await self.$u.api.traceAndAppointment(submitData, self.orderId)
self.submiting = false
if (res && res.code == 200) {
var pages = getCurrentPages()
if (pages.length >= 2) {
var page = pages[pages.length - 2]
page.needFresh = true
}
self.submiting = true;
getApp().track("order_feedback_submitForm", {
reasonType: self.trace.reasonType,
traceDate: self.traceDate
})
let params = this.$u.deepClone(self.trace);
if(self.trace.reasonType != '改约') {
if(self.timeItem && self.timeItem.pkey && self.traceDate){
let traceDate = self.moment(self.traceDate);
let timeArr = self.timeItem.pkey.split("_")
if (self.timeItem.pkey == 'appointment_range_24') {
let traceDateTime = traceDate.clone().add(23, 'hours').add(59, 'minutes')
params.nextTraceDatetime = traceDateTime.unix() * 1000
} else {
let hours = timeArr && timeArr.length && timeArr.pop()
let traceDateTime = traceDate.clone().add(Number(hours), 'hours');
params.nextTraceDatetime = traceDateTime.unix() * 1000
}
}
} else {
params.appointmentDatetime = self.traceDate
params.appointmentDatetimeRange = self.timeRange
}
let res = await self.$u.api.traceAndAppointment(params, self.orderId);
self.submiting = false;
if(res && res.code == 200) {
var pages = getCurrentPages();
if (pages.length >= 2) {
var page = pages[pages.length - 2];
page.needFresh = true
}
uni.navigateBack()
}
}
}
};
uni.navigateBack()
}
},
},
}
</script>
<style lang="scss">
<style lang="scss" scoped>
.bg {
width: 750rpx;
height: 100vh;
overflow: auto;
background-color: #f4f5f7;
background-image: linear-gradient(to top, #f4f5f7 0%, #2272ff 50%);
background-size: 750rpx 600rpx;
background-repeat: no-repeat;
width: 750rpx;
height: 100vh;
overflow: auto;
background-color: #f4f5f7;
background-image: linear-gradient(to top, #f4f5f7 0%, #2272ff 50%);
background-size: 750rpx 600rpx;
background-repeat: no-repeat;
}
.feedback-box {
display: flex;
flex-direction: column;
.header {
padding: 12rpx 30rpx 40rpx 30rpx;
display: flex;
justify-content: space-between;
align-items: center;
.title {
font-size: 40rpx;
font-weight: bold;
color: #ffffff;
}
}
}
/deep/ .u-subsection {
padding: 4rpx !important;
display: flex;
flex-direction: column;
.header {
padding: 12rpx 30rpx 40rpx 30rpx;
display: flex;
justify-content: space-between;
align-items: center;
.title {
font-size: 40rpx;
font-weight: bold;
color: #ffffff;
}
}
}
.top-tab {
text-align: center;
}
.content {
display: flex;
flex-direction: column;
overflow: hidden;
margin-bottom: 188rpx;
.content-view {
height: 100%;
border-radius: 12rpx;
overflow: auto;
margin-top: 30rpx;
.time-view {
border-radius: 12rpx;
background-color: #ffffff;
padding-bottom: 20rpx;
}
}
.content {
display: flex;
flex-direction: column;
overflow: hidden;
margin-bottom: 188rpx;
margin-top: 30rpx;
.content-view {
height: 100%;
overflow: auto;
}
}
.bottom-view {
position: fixed;
bottom: 44rpx;
width: 100%;
position: fixed;
bottom: 44rpx;
width: 100%;
}
.bottom-btn {
height: 104rpx;
width: 600rpx;
display: flex;
align-items: center;
justify-content: center;
.button-text {
font-size: 32rpx;
font-weight: bold;
}
}
.con-box {
padding: 30rpx 30rpx 8rpx 30rpx;
border-radius: 12rpx;
background-color: #ffffff;
margin-bottom: 20rpx;
.title {
font-weight: bold;
font-size: 32rpx;
line-height: 32rpx;
color: #333;
}
& > .u-flex {
margin-top: 40rpx;
margin-right: -24rpx;
.txt-item {
border-radius: 12rpx;
padding: 24rpx 38rpx;
width: 196rpx;
height: 72rpx;
text-align: center;
margin-right: 22rpx;
margin-bottom: 20rpx;
background-color: #f4f5f7;
&.active {
background-color: #2272ff;
.txt {
color: #fff;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
}
}
}
.txt {
display: block;
font-size: 26rpx;
line-height: 26rpx;
color: #333;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.input-view {
margin-bottom: 24rpx;
}
.textarea {
/deep/ .u-input {
textarea {
margin-top: 20rpx;
border: 2rpx solid #ececec;
padding: 18rpx 30rpx;
}
}
}
height: 104rpx;
width: 600rpx;
display: flex;
align-items: center;
justify-content: center;
.button-text {
font-size: 32rpx;
font-weight: bold;
}
}
.btn {
padding: 30rpx;
border-radius: 52rpx;
line-height: 44rpx;
font-size: 32rpx;
text-align: center;
background-color: #2272ff;
color: #fff;
&::after {
content: '';
height: 0;
border: none;
}
padding: 30rpx;
border-radius: 52rpx;
line-height: 44rpx;
font-size: 32rpx;
text-align: center;
background-color: #2272ff;
color: #fff;
&::after {
content: '';
height: 0;
border: none;
}
}
.btn {
padding: 30rpx;
border-radius: 52rpx;
line-height: 44rpx;
font-size: 32rpx;
text-align: center;
background-color: #2272ff;
color: #fff;
&::after {
content: '';
height: 0;
}
padding: 30rpx;
border-radius: 52rpx;
line-height: 44rpx;
font-size: 32rpx;
text-align: center;
background-color: #2272ff;
color: #fff;
&::after {
content: '';
height: 0;
}
}
.width-320 {
width: 320rpx;
width: 320rpx;
}
/deep/ button[plain] {
border: none;
border: none;
}
button[disabled]:not([type]) {
background: #d1d4d4;
color: #ffffff;
background: #d1d4d4;
color: #ffffff;
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment