Commit ed1a215e authored by Facius's avatar Facius

feat: 【ID1001292】 前台-师傅在小程序前台完工后,“审核中”及“已完工”状态下均可查看完工信息

parent 5e3bcaf6
......@@ -2,7 +2,7 @@
<view class="order-view" @click="handleClickCell">
<view class="order-top-view">
<view class="left-view">
<view :class="['tag-view', {'active': active}]">
<view :class="['tag-view', { active: active }]">
{{ orderData.orderServiceType }}
</view>
<view class="store-view">{{ orderData.categoryName }}</view>
......@@ -12,20 +12,26 @@
<view class="content-view">
<view class="info-view" v-for="(item, key) in infoTexts" :key="key">
<view class="info-title">
<text>{{item.name + ':'}}</text>
<text>{{ item.name + ':' }}</text>
</view>
<view class="info-content">
<text @longpress="handleLongpress(key, orderData[key])">{{orderData[key]}}</text>
<text v-if="item.content">{{' / ' + orderData[item.content]}}</text>
<text @longpress="handleLongpress(key, orderData[key])">{{
orderData[key]
}}</text>
<text v-if="item.content">{{ ' / ' + orderData[item.content] }}</text>
</view>
</view>
<view class="address-view">
<view class="address-left-view">
<image class="address-image" :src="dizhiImage" mode="widthFix"></image>
<image
class="address-image"
:src="dizhiImage"
mode="widthFix"
></image>
<text>{{ formatAddress(orderData) }}</text>
</view>
<view v-if="showDistance" class="address-right-view">
{{orderDistance}}km
{{ orderDistance }}km
</view>
</view>
</view>
......@@ -33,34 +39,53 @@
<view class="line-view"></view>
<view class="reason-view" v-if="showReason">
<view class="reason-title"><text>未通过原因:</text></view>
<view class="reason-text"><text v-for="(item, index) in orderData.auditResults" :key="index">{{item}}</text></view>
<view class="reason-text"
><text v-for="(item, index) in orderData.auditResults" :key="index">{{
item
}}</text></view
>
</view>
<view class="bottom-view">
<view>
<view v-if="showCountTime" class="bottom-left-view">
<view :class="['bottom-tag-view', {'timeout': timeout}]"><text>{{tagText}}</text></view>
<u-count-down :timestamp="timestamp" font-size="40" show-days separator="zh"
:color="timeout ? '#FA5A49' : '#FF930D'" @change="handleChange" separator-color="#666666" ref="order-count-down"></u-count-down>
<view :class="['bottom-tag-view', { timeout: timeout }]"
><text>{{ tagText }}</text></view
>
<u-count-down
:timestamp="timestamp"
font-size="40"
show-days
separator="zh"
:color="timeout ? '#FA5A49' : '#FF930D'"
@change="handleChange"
separator-color="#666666"
ref="order-count-down"
></u-count-down>
</view>
<view v-else-if="showTime">
<text>{{timeTitle}}</text>
<text>{{timeText}}</text>
<text>{{ timeTitle }}</text>
<text>{{ timeText }}</text>
</view>
</view>
<u-button class="right-btn" @click.stop="handleClick" :custom-style="buttonStyle" type="primary"
shape="circle" :hover-class="buttonTextType ? 'none' : ''">
{{orderText}}
<u-button
class="right-btn"
@click.stop="handleClick"
:custom-style="buttonStyle"
type="primary"
shape="circle"
>
{{ orderText }}
</u-button>
</view>
</view>
</template>
<script>
export default {
export default {
props: {
orderData: {
type: Object,
default () {
default() {
return {
orderServiceType: '安装', // 服务类型:安装、维修
categoryName: '充电桩', // 品类:充电桩
......@@ -81,7 +106,7 @@
orderBusinessType: 'R', // 业务类型 R 为抢单
orderId: '0', // 订单id
}
}
},
},
/* 订单类型
waitAccept:待接单、
......@@ -93,24 +118,27 @@
finish:已完工
*/
type: String,
location: { // 当前坐标
location: {
// 当前坐标
type: Array,
default () {
default() {
return [116.3896, 39.91917] // 纬度,经度
}
}
},
},
},
data() {
return {
timeout: false,
timestamp: 0,
};
}
},
computed: {
orderText() { // 按钮文字
orderText() {
// 按钮文字
return this.typeTexts[this.orderType]
},
buttonStyle() { // 按钮样式
buttonStyle() {
// 按钮样式
/** orderType
0 待接单、
1 待预约、
......@@ -122,7 +150,7 @@
*/
switch (this.orderType) {
case 0:
if (!this.isCompetition ) {
if (!this.isCompetition) {
return this.buttonStyles[0]
} else {
return this.buttonStyles[1]
......@@ -131,59 +159,75 @@
case 2:
case 3:
case 5:
return this.buttonStyles[0]
case 4:
case 6:
return this.buttonStyles[2]
return this.buttonStyles[0]
}
},
showCountTime() { // ((待预约、 待签到、 待完工) || (待接单 && 业务类型非抢单)) && 有超过时间点
return ([1, 2, 3].indexOf(this.orderType) != -1 || (this.orderType == 0 && !this.isCompetition)) && this.orderData.currentOverTime
showCountTime() {
// ((待预约、 待签到、 待完工) || (待接单 && 业务类型非抢单)) && 有超过时间点
return (
([1, 2, 3].indexOf(this.orderType) != -1 ||
(this.orderType == 0 && !this.isCompetition)) &&
this.orderData.currentOverTime
)
},
showTime() {
return [4, 5, 6].indexOf(this.orderType) != -1
},
infoTexts() {
return {
'orderNumber': {name:'工单编号'},
'partnerCompanyName': {name: '合作厂商'},
'contactName': {name: '客户信息', content: 'contactPhone'},
orderNumber: { name: '工单编号' },
partnerCompanyName: { name: '合作厂商' },
contactName: { name: '客户信息', content: 'contactPhone' },
}
},
typeTexts() {
return [this.type0Text, '去预约', '去签到', '去完工', '审核中', '去处理', '已完工']
},
isCompetition() { // 是:订单池,抢单; 否:指派单,接单
return [
this.type0Text,
'去预约',
'去签到',
'去完工',
'去查看',
'去处理',
'去查看',
]
},
isCompetition() {
// 是:订单池,抢单; 否:指派单,接单
return this.orderData.orderBusinessType == 'R'
},
type0Text() {
return !this.isCompetition ? '接单' : '抢单'
},
buttonStyles() {
return [{
return [
{
'background-color': '#2272FF',
'color': '#FFFFFF',
color: '#FFFFFF',
'font-size': '32rpx',
'height': '80rpx',
'width': '200rpx'
}, {
height: '80rpx',
width: '200rpx',
},
{
'background-color': '#FF930D',
'color': '#FFFFFF',
color: '#FFFFFF',
'font-size': '32rpx',
'height': '80rpx',
'width': '200rpx'
}, {
'background-color': 'transparent',
'color': '#2272FF',
'font-size': '32rpx',
'height': '32rpx',
'width': '100rpx'
}]
},
buttonTextType() {
return this.orderType == 4 || this.orderType == 6
},
height: '80rpx',
width: '200rpx',
},
// {
// 'background-color': 'transparent',
// color: '#2272FF',
// 'font-size': '32rpx',
// height: '32rpx',
// width: '100rpx',
// },
]
},
// buttonTextType() {
// return this.orderType == 4 || this.orderType == 6
// },
dizhiImage() {
return process.uniEnv.qn_base_url + 'shouye-dizhi.png'
},
......@@ -194,7 +238,10 @@
return this.timeout ? '超' : '剩'
},
timeText() {
let time = this.orderType == 4 ? this.orderData.orderFinishDatetime : this.orderData.auditDatetime
let time =
this.orderType == 4
? this.orderData.orderFinishDatetime
: this.orderData.auditDatetime
return time ? this.$u.timeFormat(time, 'yyyy.mm.dd hh:MM:ss') : ''
},
timeTitle() {
......@@ -204,7 +251,12 @@
return this.orderType == 5
},
showDistance() {
return this.orderType == 0 && this.location.length >= 2 && (this.orderData.contactAddressLatitud || this.orderData.contactAddressLongitud)
return (
this.orderType == 0 &&
this.location.length >= 2 &&
(this.orderData.contactAddressLatitud ||
this.orderData.contactAddressLongitud)
)
},
isWaitFinish() {
return this.orderType == 3
......@@ -214,17 +266,22 @@
},
types() {
return {
'waitAccept': 0, // 待接单、
'waitAppointment': 1, // 待预约、
'waitCheckIn': 2, // 待签到、
'waitFinish': 3, // 待完工、
'audit': 4, // 审核中、
'exception': 5, // 异常单、
'finish': 6, //已完工
waitAccept: 0, // 待接单、
waitAppointment: 1, // 待预约、
waitCheckIn: 2, // 待签到、
waitFinish: 3, // 待完工、
audit: 4, // 审核中、
exception: 5, // 异常单、
finish: 6, //已完工
}
},
orderDistance() {
return this.distance(this.orderData.contactAddressLatitud,this.orderData.contactAddressLongitud, this.location[0], this.location[1])
return this.distance(
this.orderData.contactAddressLatitud,
this.orderData.contactAddressLongitud,
this.location[0],
this.location[1]
)
},
/** orderType
0 待接单、
......@@ -255,13 +312,24 @@
} else {
return 1
}
} else if (this.orderData.orderStatus > 31 && this.orderData.orderStatus < 80) {
} else if (
this.orderData.orderStatus > 31 &&
this.orderData.orderStatus < 80
) {
return 3
} else if (this.orderData.orderStatus == 85 || this.orderData.orderStatus == 87) {
} else if (
this.orderData.orderStatus == 85 ||
this.orderData.orderStatus == 87
) {
return 4
} else if (this.orderData.orderStatus == 86 || this.orderData.orderStatus == 88) {
} else if (
this.orderData.orderStatus == 86 ||
this.orderData.orderStatus == 88
) {
return 5
} else if ([80, 81, 89, 110].indexOf(this.orderData.orderStatus) != -1) {
} else if (
[80, 81, 89, 110].indexOf(this.orderData.orderStatus) != -1
) {
return 6
} else {
return 0
......@@ -269,57 +337,66 @@
} else {
return this.types[this.type]
}
}
},
},
created() {
this.updateTime()
},
watch:{
watch: {
'orderData.currentCellTime'(val) {
// 从后台重新获取数据之后,时间重新计算
this.updateTime()
}
},
},
methods: {
handleExceptions() {
if(this.isException) {
getApp().track("order_handleExceptions", {})
if (this.isException) {
getApp().track('order_handleExceptions', {})
}
},
// title:标题,showCountTime:是否显示倒计时。详情页面情况太多,提前传值可以避免页面晃动
handleClick() {
var func = 'click'
var func = 'action'
this.handleExceptions()
if (this.isWaitFinish || this.isException) { // 不是待完工、不是异常单点按钮算点cell
func = 'action'
}
this.$emit(func, this.orderData, this.type, this.showCountTime ? 'show' : '')
this.$emit(
func,
this.orderData,
this.type,
this.showCountTime ? 'show' : ''
)
},
handleClickCell() {
var func = 'click'
this.handleExceptions()
if (this.isException) { // 异常单点cell算点按钮
if (this.isException) {
// 异常单点cell算点按钮
func = 'action'
}
this.$emit(func, this.orderData, this.type, this.showCountTime ? 'show' : '')
this.$emit(
func,
this.orderData,
this.type,
this.showCountTime ? 'show' : ''
)
},
handleChange(timestamp) {
if (this.timeout) this.$refs['order-count-down'].seconds += 2
if (timestamp == 0 && !this.timeout) { // 超时之后倒计时变为正计时
setTimeout(()=> {
if (timestamp == 0 && !this.timeout) {
// 超时之后倒计时变为正计时
setTimeout(() => {
this.timestamp = 1
this.timeout = true
}, 1000)
}
},
formatAddress(order) {
let address = ""
if(order) {
address = order.contactProvinceText || ""
address += order.contactCityText || ""
address += order.contactCommunityText || ""
address += order.contactStreetText || ""
address += order.contactAddress || ""
let address = ''
if (order) {
address = order.contactProvinceText || ''
address += order.contactCityText || ''
address += order.contactCommunityText || ''
address += order.contactStreetText || ''
address += order.contactAddress || ''
}
return address
},
......@@ -332,43 +409,55 @@
* @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)/10000 //输出为米
return Number(s?s.toFixed(2):0);
},
Rad(d){
return d * Math.PI / 180.0;//经纬度转换成三角函数中度分表形式。
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) / 10000 //输出为米
return Number(s ? s.toFixed(2) : 0)
},
Rad(d) {
return (d * Math.PI) / 180.0 //经纬度转换成三角函数中度分表形式。
},
updateTime() {
var time = new Date().getTime()
this.timeout = this.orderData.currentOverTime < time
this.timestamp = Math.round(Math.abs(this.orderData.currentOverTime - time) / 1000)
this.timestamp = Math.round(
Math.abs(this.orderData.currentOverTime - time) / 1000
)
},
handleLongpress(key, text) { // 长按复制单号
handleLongpress(key, text) {
// 长按复制单号
if (key == 'orderNumber') {
uni.setClipboardData({
data: text,
success: function () {
console.log('success');
}
});
}
}
}
success: function() {
console.log('success')
},
})
}
},
},
}
</script>
<style lang="scss" scoped>
.order-view {
.order-view {
width: 100%;
background-color: #FFFFFF;
background-color: #ffffff;
border-radius: 12rpx;
padding: 30rpx;
margin-bottom: 20rpx;
......@@ -387,13 +476,13 @@
text-align: center;
width: 84rpx;
height: 40rpx;
color: #FFFFFF;
color: #ffffff;
border-radius: 8rpx;
background-image: linear-gradient(to right, #FF930D, #FFC174);
background-image: linear-gradient(to right, #ff930d, #ffc174);
font-size: 22rpx;
line-height: 42rpx;
&.active {
background-image: linear-gradient(to right, #2272FF, #47ABFF);
background-image: linear-gradient(to right, #2272ff, #47abff);
}
}
......@@ -409,7 +498,7 @@
text-align: center;
width: 100rpx;
height: 40rpx;
background-color: #F4F5F7;
background-color: #f4f5f7;
border-radius: 20rpx;
color: #333333;
font-size: 22rpx;
......@@ -465,7 +554,7 @@
}
.line-view {
background-color: #F4F5F7;
background-color: #f4f5f7;
height: 2rpx;
width: 100%;
margin-top: 30rpx;
......@@ -475,7 +564,7 @@
text-align: left;
margin-top: 30rpx;
font-size: 26rpx;
color: #FA5A49;
color: #fa5a49;
display: flex;
align-items: flex-start;
display: flex;
......@@ -503,20 +592,19 @@
width: 52rpx;
height: 52rpx;
border-radius: 26rpx;
color: #FFFFFF;
color: #ffffff;
font-size: 26rpx;
background-color: #FF930D;
background-color: #ff930d;
margin-right: 16rpx;
display: flex;
justify-content: center;
align-items: center;
&.timeout {
background-color: #FA5A49;
background-color: #fa5a49;
}
}
}
}
}
}
</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