sadjv2/anmo-user/my/order/pay.vue

1344 lines
40 KiB
Vue
Raw Permalink Normal View History

2024-06-04 10:11:25 +08:00
<template>
<view style="padding-bottom: 300rpx;">
<view class="u-skeleton">
<view class="bgbox" style="">
<view v-if="order.status ==1">待付款...</view>
<view v-if="order.status ==2">待服务</view>
<view v-if="order.status ==5">已完成</view>
<view v-if="order.status ==6">服务中</view>
<view v-if="order.status ==7">已出发</view>
<view v-if="order.status ==8">已到达</view>
<view v-if="order.status ==3">待评价</view>
<view v-if="order.status ==4">已取消</view>
</view>
<view class="padding-bottom" style="padding: 30rpx;margin-top: -80rpx;">
<view style="border-radius: 15rpx;background-color: white;padding: 30rpx;">
<!-- 服务倒计时 -->
<view class="countDown" v-if="order.status == 6">
<!-- <uni-countdown ref="countDownEl" :showDay="false" :ordersId="orderIdSend" :fontSize="'40'"
:hour="goods.endTime.hour" :minute="goods.endTime.minute" :second="goods.endTime.second"
color="#20C675" :tipTime="2">
</uni-countdown> -->
<!-- <CountDown :timestamp="formatTimeStamp" :autoplay="true" /> -->
<u-count-down :timestamp="endOfServiceTimer" separator-color="#20C675" color="#20C675"
font-size="74" separator-size="74" @change="onCountdownChange"></u-count-down>
</view>
<view style="font-size: 28rpx;margin-bottom: 22rpx;">服务内容</view>
<view class="flex justify-around">
<view class="" style="width: 220upx;height: 160upx;">
<image v-if="order && order.ordersMassageList"
:src="(order.ordersMassageList[0].massageType || {}).massageImg"
style="width: 100%;height: 100%;border-radius: 4upx;"></image>
</view>
<view class="u-flex-1 margin-left-sm">
<view class="flex">
<image src="../../static/images/geren.png" style="width: 35rpx;height: 35rpx;">
</image>
<view v-if="order && order.ordersMassageList"
class="margin-right-xs text-df margin-left-xs u-skeleton-fillet"
style="margin-top: -2px;display: inline-block;width: 400rpx; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
{{(order.ordersMassageList[0].massageType || {}).title}}
</view>
</view>
<view class="flex justify-between margin-tb-sm" style="color: #999999;">
<view v-if="order && order.ordersMassageList">
时长{{(order.ordersMassageList[0].massageType || {}).duration}}分钟
x{{order.ordersMassageList[0].num}}</view>
</view>
<view style="color:#FF1200;font-size: 24upx;">
实付<text class="text-bold text-lg">{{order.payMoney}}</text>
</view>
</view>
</view>
<!-- <view class="flex justify-between margin-top-lg" v-if="order.artificerTaxiMoney">
<view style="width: 180upx;">出行交通费用</view>
<view class="">{{order.artificerTaxiMoney}}</view>
</view> -->
<view class="flex justify-between margin-top" v-if="order.couponMoney">
<view style="width: 120upx;">优惠券</view>
<view class="">{{order.couponMoney}}</view>
</view>
<view class="flex justify-between margin-top" v-if="order.addNum">
<view style="width: 120upx;">加钟次数</view>
<view class="">{{order.addNum}}</view>
</view>
<view class="flex justify-between margin-top" v-if="order.addTime">
<view style="width: 120upx;">加钟时长</view>
<view class="">{{order.addTime}}分钟</view>
</view>
<view class="flex justify-between margin-top" v-if="order.addMoney">
<view style="width: 120upx;">加钟费用</view>
<view class="">{{order.addMoney}}</view>
</view>
<!-- <view style="width: 100%;height: 1rpx;background: #F2F2F2;margin-top:15rpx;"></view> -->
<!-- <view class="flex align-center " style="margin-top:35rpx">
<image :src="order.artificer.artificerImg" style="width:100upx;height: 100upx;border-radius: 50%;"></image>
<view class="margin-left-sm">
<view class="flex align-center">
<view class="text-bold text-df ">{{order.artificer.artificerName}}</view>
<image src="../../static/img/phone.png" style="width: 10px;height: 13px;margin-left: 11px;"
@click="bindphone(order.artificer.phone)"></image>
</view>
<view class="flex align-center flex-wrap">
<view class="margin-right">
<image src="../../static/images/start.png" style="width: 24rpx;height: 22rpx;"></image>
<text style="color: #F93731;margin-left: 5rpx;">5.0</text>
</view>
<text class="margin-bottom-xs box" style="margin-right: 10upx;">健康理疗师</text>
</view>
</view>
</view> -->
</view>
<view class="flex align-center justify-between"
@tap="bindGps(order.latitude,order.longitude,order.address)"
style="background-color: #fff;padding: 30rpx;border-radius: 15rpx;margin-top: 24rpx;">
<view>
<view style="color: #000000;font-size: 32rpx;" @tap.stop="copyAddress()"
v-if="order.status !=1 && order.status !=5 && order.status !=3 && order.status !=4">
{{order.userName}}
{{order.phone ? order.phone.substring(0,3) + '****' + order.phone.substring(7,11) : ''}}
<u-icon name="file-text"></u-icon>
</view>
<view style="color: #000000;font-size: 32rpx;" v-else>
{{order.userName}}
{{order.phone ? order.phone.substring(0,3) + '****' + order.phone.substring(7,11) : ''}}
</view>
<view style="color: #999999;margin-top: 8rpx;">{{order.address}}</view>
</view>
<image src="../../static/img/you.png" style="width: 15rpx;height: 28rpx;"></image>
</view>
<view class="" style="background-color: #fff;padding: 30rpx;border-radius: 15rpx;margin-top: 24rpx;">
<view class="" style="font-size: 30rpx;color: #000000;font-weight: bold;">
订单信息
</view>
<view class="margin-right-xs">
<view class="flex justify-between margin-top">
<view style="width: 120upx;">订单编号</view>
<view class="flex align-center" @tap="copy(order.ordersNo)">
<view class="">{{order.ordersNo}}</view>
<u-icon name="file-text"></u-icon>
</view>
</view>
<view class="flex justify-between margin-top text-bold" style="color: red;">
<view style="width: 120upx;">预约时间</view>
<view class="">{{order.serveTime}}</view>
</view>
<view class="flex justify-between margin-top">
<view style="width: 120upx;">下单时间</view>
<view class="">{{order.createTime}}</view>
</view>
<view class="flex justify-between margin-top" v-if="order.startTime">
<view style="width: 200rpx;">开始服务时间</view>
<view class="">{{order.startTime}}</view>
</view>
<view class="flex justify-between margin-top" v-if="order.endTimes">
<view style="width: 200rpx;">结束服务时间</view>
<view class="">{{order.endTimes}}</view>
</view>
<view class="flex justify-between margin-top" v-if="order.endTime">
<view style="width: 200rpx;">预估结束时间</view>
<view class="">{{formatEndTime}}</view>
</view>
<view class="flex justify-between margin-top" v-if="order.tripWay">
<view style="width: 120upx;">出行方式</view>
<view v-if="order.tripWay == 1">公交</view>
<view v-if="order.tripWay == 2">出租</view>
<view v-if="order.tripWay == 3">免费</view>
</view>
<view class="flex justify-between margin-top" v-if="order.km">
<view style="width: 120upx;">全程距离</view>
<view class="">{{order.km}}km</view>
</view>
<view class="flex justify-between margin-top" v-if="order.artificerTaxiMoney">
<view style="width: 120upx;">出行费用</view>
<view class="">{{order.artificerTaxiMoney}}</view>
</view>
<!-- <view class="flex justify-between margin-top-lg" v-if="order.pingMoney">
<view style="width: 120upx;">平台费用</view>
<view class="">{{order.pingMoney}}</view>
</view> -->
<!-- <view class="flex justify-between margin-top-lg" v-if="order.pingTaxiMoney">
<view style="width: 240rpx;">平台扣除交通费用</view>
<view class="">{{order.pingTaxiMoney}}</view>
</view> -->
<view class="flex justify-between margin-top" v-if="sumMoney">
<view style="width: 120upx;">项目费用</view>
<view class="">{{sumMoney}}</view>
</view>
<view class="flex justify-between margin-top"
v-if="order.status !=1 && order.status !=5 && order.status !=3 && order.status !=4">
<view style="width: 170rpx;">联系客户</view>
<view class="" @click="bindphone(order.phone)">
{{order.phone ? order.phone.substring(0,3) + '****' + order.phone.substring(7,11) : ''}}
<image src="../../static/images/phone.png"
style="width: 14px;height: 14px;margin-left: 10rpx;"></image>
</view>
</view>
<view class="flex justify-between margin-top" v-if="order.remark">
<view style="width: 170rpx;">备注内容</view>
<view class="flex">
<view class="">
{{order.remark}}
</view>
</view>
</view>
<view class="flex justify-between margin-top-lg">
<view style="width: 120upx;">预计收益</view>
<view class="" style="color: #FF1200;"><text
style="font-size: 35rpx;font-weight: bold;">{{order.sumArtificerMoney}}</text>
</view>
</view>
</view>
</view>
<view class="bg padding radius margin-top" v-if="order.startImg && startImgSel != '否'">
<view class="" style="font-size: 30rpx;color: #000000;font-weight: bold;margin-bottom: 20rpx;">服务前照片
</view>
<view class="flex flex-wrap justify-between">
<view class="flex margin-bottom-sm"
style="width: 48%;height: 200rpx;margin-right: 5rpx;position: relative;"
v-for="(image,index) in order.startImg" :key="index"
@click="saveImg( order.startImg,index)">
<image :src="image" style="width: 100%;height: 100%;border-radius: 10upx;"
mode="aspectFill">
</image>
</view>
</view>
</view>
<view class="bg padding radius margin-top" v-if="order.status==8 && startImgSel != '否'">
<view class="" style="font-size: 30rpx;color: #000000;font-weight: bold;margin-bottom: 20rpx;">服务前照片
</view>
<view class="flex flex-wrap">
<view v-if="startImgs.length">
<view class="flex margin-right-sm flex-wrap">
<view class="flex"
style="width: 200rpx;height: 200rpx;margin-right: 5rpx;position: relative;"
v-for="(image,index) in startImgs" :key="index">
<image :src="pictureEcho[0]" style="width: 100%;height: 100%;"></image>
<view style="z-index: 0;position: absolute;top: -15rpx;right: -15rpx;"
@click="removeImg(index,1)">
<u-icon name="close-circle-fill" color="#2979ff" size="50rpx"></u-icon>
</view>
</view>
</view>
</view>
<view class="flex align-center justify-center padding-tb "
style="background: #f5f5f5;width: 200rpx;height: 200rpx;">
<view class="text-center" @click="addImage(1)">
<image src="../static/photo.png" style="width:60upx;height: 50upx;"></image>
<view class="text-sm">上传照片</view>
</view>
</view>
</view>
</view>
<!-- <view class="bg padding radius margin-top-sm">
<view class="text-lg text-bold">
服务信息
</view>
<view class="margin-right-xs">
<view class="flex justify-between margin-top-lg">
<view style="width: 170rpx;">服务时间</view>
<view class="">
<text>{{order.serveTime}}</text>
</view>
</view>
<view class="flex justify-between margin-top-lg">
<view style="width: 170rpx;">服务地点</view>
<view class="flex" @tap="bindGps(order.latitude,order.longitude,order.address)">
<view class="">
{{order.address}}
<image src="../../static/images/address.png" style="width: 13px;height: 15px;"></image>
</view>
</view>
</view>
<view class="flex justify-between margin-top-lg">
<view style="width: 170rpx;">联系方式</view>
<view class="" @click="bindphone(order.phone)">
{{order.phone}}
<image src="../../static/images/phone.png" style="width: 15px;height: 15px;"></image>
</view>
</view>
<view class="flex justify-between margin-top-lg" v-if="order.remark">
<view style="width: 170rpx;">备注内容</view>
<view class="flex">
<view class="">
{{order.remark}}
</view>
</view>
</view>
</view>
</view> -->
<view class="flex tabber align-center" style="display: flex;justify-content: center;padding: 30rpx;">
<!-- <u-button @click="cancelOrder(order)" shape="circle" class="gdfsb"
:hair-line="false" v-if="order.status == 2">取消订单
</u-button> -->
<!-- 当订单状态为2 按钮为 现在出发 当状态为7时 按钮为 我已到达 然后状态为8 的时候 按钮就是现在的 开始服务 -->
<u-button @click="cxOrder(order)" class="gdfsb" shape="circle" :hair-line="false"
v-if="order.status == 2">现在出发
</u-button>
<u-button @click="cxOrder(order)" class="gdfsb" shape="circle" :hair-line="false"
v-if="order.status == 7">我已到达
</u-button>
<u-button @click="fuwuOrder(order)" class="gdfsb" shape="circle" :hair-line="false"
v-if="order.status == 8">开始服务
</u-button>
<u-button @click="cancel(order)" class="gdfsb" shape="circle" :hair-line="false"
v-if="order.status == 6">服务完成
</u-button>
<view class="lxkf" type="" shape="circle" :plain="true" @click="goChat">联系客服</view>
</view>
</view>
<u-skeleton :loading="loading" :animation="true" bgColor="#FFF"></u-skeleton>
<!-- #ifndef H5 -->
<image src="../../static/images/index/jinji.png" class="bj_view" @tap="goBaoJing"></image>
<!-- #endif -->
<!-- 支付方式 -->
<u-popup v-model="showpay" mode="bottom" :closeable="closeable">
<view class="popup_pay">
<view style="background-color: #fff;">
<view style="padding: 0 20upx;margin-top: 60rpx;margin-bottom: 20rpx;">
<view
style="display: flex;height: 100upx;align-items: center;padding: 20upx 0;justify-content: center;"
v-for="(item,index) in openLists" :key='index'>
<image :src="item.image" style="width: 55upx;height: 55upx;border-radius: 50upx;">
</image>
<view style="font-size: 30upx;margin-left: 20upx;width: 70%;">
{{item.text}}
</view>
<radio-group name="openWay" style="margin-left: 45upx;" @tap='selectWay(item)'>
<label class="tui-radio">
<radio color="#1777FF" :checked="openWay === item.id ? true : false" />
</label>
</radio-group>
</view>
</view>
</view>
<view class="pay_btn" @click="pay()">确认支付</view>
</view>
</u-popup>
</view>
</view>
</template>
<script>
import * as websocketUtils from 'utils/websocketUtils.js';
import {
getXZX,
post,
} from "@/common/httpRequest.js";
export default {
// components: {
// CountDown,
// },
data() {
return {
goods: {},
startImgs: [],
startImg: '',
endImgs: [],
endImg: '',
latitude: '',
longitude: '',
loading: true,
customStyle: {
// backgroundColor: '#e5e5e5',
// color: '#FFFFFF',
// #ifdef MP-WEIXIN
width: "330upx",
// #endif
// #ifndef MP-WEIXIN
width: '111px',
// #endif
margin: '0 20upx',
},
customStyle2: {
backgroundColor: '#096f4b',
color: '#FFFFFF',
// #ifdef MP-WEIXIN
width: "330upx",
// #endif
// #ifndef MP-WEIXIN
width: '111px',
// #endif
margin: '0 20upx',
},
id: '',
order: {
user: {},
game: {}
},
isTrue: 0,
sumMoney: 0,
phone: '',
isVip: false,
birthDate: '',
age: '',
showpay: false,
openLists: [],
openWay: 1,
closeable: true,
startImgSel: '否',
pictureEcho: [],
formatEndTime: "",
endOfServiceTimer: null,
formatTimeStamp: null,
innerAudioContext: null,
orderIdSend: null,
homeMaterialPackageList: [],
currentPage: null,
pageSize: null,
}
},
watch: {
formatTimeStamp(newValue, oldValue) {
console.log(newValue);
},
},
onLoad(e) {
setInterval(() => {
this.getOrder();
}, 120000)
this.startImgSel = this.$queue.getData('startImgSel');
uni.showLoading({
title: '加载中......'
})
let that = this;
uni.getLocation({
type: 'wgs84',
success: function(res) {
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
that.$queue.setData('longitude', res.longitude);
that.$queue.setData('latitude', res.latitude);
that.latitude = res.latitude
that.longitude = res.longitude
}
});
// setTimeout(() => {
// // this.loading = false;
// }, 2000)
this.isTrue = e.isTrue
if (this.isTrue) {
uni.setNavigationBarTitle({
title: '订单详情'
})
}
this.ordersId = e.ordersId
this.orderIdSend = e.ordersId;
// this.getOrder()
},
onShow() {
let that = this;
this.getOrder()
this.token = uni.getStorageSync('token')
if (uni.getStorageSync('token')) {
this.getIsVip()
}
// #ifdef APP
this.openLists = [{
image: '../../static/images/icon_weixin.png',
text: '微信',
id: 2
}, {
image: '../../static/images/lingqian.png',
text: '零钱支付',
id: 1
}, {
image: '../../static/images/zhifubao.png',
text: '支付宝支付',
id: 3
}],
this.openWay = 1;
// #endif
// #ifdef MP-WEIXIN
this.openLists = [{
image: '../../static/images/icon_weixin.png',
text: '微信',
id: 2
}, {
image: '../../static/images/lingqian.png',
text: '零钱支付',
id: 1
}],
this.openWay = 1;
// #endif
// #ifdef H5
this.openLists = [{
image: '../../static/images/lingqian.png',
text: '零钱支付',
id: 1
}, {
image: '../../static/images/zhifubao.png',
text: '支付宝支付',
id: 3
}],
this.openWay = 1;
// #endif
},
onPullDownRefresh() {
this.getOrder();
},
destroyed() {
if (this.innerAudioContext) {
try {
this.innerAudioContext.pause();
this.innerAudioContext.destroy();
this.innerAudioContext = null;
} catch (e) {
}
}
},
methods: {
onCountdownChange(e) {
console.log(e, "23123ool");
if (e == 183) {
if (this.innerAudioContext) {
try {
this.innerAudioContext.pause();
this.innerAudioContext.destroy();
this.innerAudioContext = null;
} catch (e) {
}
}
this.innerAudioContext = uni.createInnerAudioContext();
this.innerAudioContext.autoplay = true;
this.innerAudioContext.src = "../../static/endServerTimer.mp3";
this.innerAudioContext.onPlay(() => {
console.log('开始播放');
});
this.innerAudioContext.onError((res) => {
console.log(res.errMsg);
console.log(res.errCode);
});
}
},
// 触发uni倒计时组件服务时间3分钟时播放提示音
timeFormat(param) {
return param < 10 ? '0' + param : param;
},
goBaoJing() {
uni.navigateTo({
url: '/pages/index/jinji'
});
},
goChat() {
let kefu = this.$queue.getData('kefu'); // 用户端联系方式 1 手机号 2企业微信
let kefuPhone = this.$queue.getData('kefuPhone');
if (uni.getStorageSync('token')) {
if (kefu == 1) {
uni.makePhoneCall({
phoneNumber: kefuPhone //仅为示例
});
} else {
// #ifdef MP-WEIXIN
let that = this
try {
wx.openCustomerServiceChat({
extInfo: {
url: that.$queue.getData('kefuUrl')
},
corpId: that.$queue.getData('kefuAppId'),
success(res) {},
fail(res) {
console.error(res)
}
})
} catch (error) {
console.error("catchcatch" + error)
uni.showToast({
title: '请更新至微信最新版本'
});
}
// #endif
// #ifndef MP-WEIXIN
let url = this.$queue.getData('kefuUrl');
if (url.indexOf('/pages/') !== -1 || url.indexOf('/my/') !== -1) {
uni.navigateTo({
url
});
} else {
//#ifndef H5
uni.navigateTo({
url: '/pages/index/webView?url=' + url
});
//#endif
//#ifdef H5
window.location.href = url;
//#endif
}
// #endif
}
} else {
uni.showModal({
title: '提示',
content: '您还未登录,请先登录',
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
uni.navigateTo({
url: '/pages/public/login'
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
})
}
},
copy(num) {
uni.setClipboardData({
data: num,
success: r => {
this.$queue.showToast('复制成功');
}
});
},
//支付选择
selectWay: function(item) {
this.openWay = item.id;
},
//换算年龄
getAge(e) {
console.log('出生日期:' + e)
this.birthDate = e
//创建系统日期
var today = new Date();
//把出生日期转换成日期
this.birthDate = new Date(this.birthDate);
//分别获取到年份后相减
this.age = today.getFullYear() - this.birthDate.getFullYear();
// console.log(this.age+'当前年龄')
},
// 修改订单地址
undateAdd(order) {
if (order.state == 0) {
uni.navigateTo({
url: '../address/address?order=' + order.ordersId + '&id=' + 3
})
}
},
copyAddress() {
uni.setClipboardData({
data: this.order.userName + '\n' + this.order.phone + '\n' + this.order.address,
success: r => {
this.$queue.showToast('复制成功');
}
});
},
// 一键导航
bindGps(latitude, longitude, name, detailsadd) {
console.log(latitude, longitude, name, detailsadd)
uni.openLocation({
latitude: latitude - 0, //要去的纬度-地址
longitude: longitude - 0, //要去的经度-地址
name: name, //地址名称
address: detailsadd, //详细地址名称
success: function() {
console.log('导航成功');
},
fail: function(error) {
console.log(error)
}
});
},
// 拨打电话
bindphone(phone) {
let that = this
uni.showModal({
title: '提示',
content: '是否拨打电话',
success: function(res) {
if (res.confirm) {
console.log('用户点击确定', phone);
uni.makePhoneCall({
phoneNumber: phone //仅为示例
});
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
},
goNav(e) {
uni.navigateTo({
url: e
})
},
ysPhone(phoneA, phoneB) {
this.$Request.getT('/app/user/insertVirtualPhone?phoneA=' + phoneA + '&phoneB=' + phoneB).then(res => {
if (res.code == 0) {
this.order.phone = res.data;
}
});
},
getOrder() {
let data = {
ordersId: this.ordersId
}
this.$Request.get('/app/artificer/selectOrdersDetails', data).then(res => {
if (res.code == 0) {
this.goods = [];
this.loading = false
uni.hideLoading()
this.order = res.data
this.formatEndTime = res.data.endTime;
if (this.order.artificerTaxiMoney && this.order.sumArtificerMoney) {
this.sumMoney = parseFloat(parseFloat(this.order.sumArtificerMoney) - parseFloat(this
.order.artificerTaxiMoney)).toFixed(2);
} else {
this.sumMoney = this.order.sumArtificerMoney;
}
if (this.order.startImg) {
this.order.startImg = this.order.startImg.split(',')
}
if (this.order.endServiceImg) {
this.order.endServiceImg = this.order.endServiceImg.split(',')
}
let aliphone = this.$queue.getData('aliphone');
if (aliphone === '是' && this.order.artificer) {
this.ysPhone(this.order.phone, this.order.artificer.phone);
}
if (res.data.status == 6 && res.data.endTime) {
let afterTimeStamp = new Date(res.data.endTime).getTime() / 1000;
let currentTimeStamp = new Date().getTime() / 1000;
let formatTimeStamp = Math.floor(afterTimeStamp - currentTimeStamp);
console.log(currentTimeStamp);
this.endOfServiceTimer = formatTimeStamp;
}
this.goods = res.data;
// if (this.$refs.countDownEl) this.$refs.countDownEl.update();
uni.stopPullDownRefresh();
}
})
},
delOrder(e) {
let that = this
uni.showModal({
title: '提示',
content: '确定删除订单吗?',
success: function(res) {
if (res.confirm) {
let data = {
ordersId: e.ordersId,
}
that.$queue.showLoading('删除中...')
that.$Request.post('/app/artificer/removeOrders', data).then(res => {
uni.hideLoading();
if (res.code == 0) {
uni.showToast({
name: "删除成功"
})
uni.navigateBack()
} else {
that.$queue.showToast(res.msg);
}
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
},
getIsVip() {
this.$Request.get("/app/UserVip/isUserVip").then(res => {
if (res.code == 0) {
this.isVip = res.data
uni.setStorageSync('isVIP', res.data)
}
});
},
openpay() {
this.showpay = true
},
// 支付订单
pay() {
let that = this
if (that.openWay == 1) { //零钱支付
uni.showModal({
title: '付款提示',
content: '确认支付' + that.order.payMoney + '元吗?',
success: function(re) {
if (re.confirm) {
console.log('用户点击确定');
that.$queue.showLoading('支付中...')
that.$Request.post("/app/artificer/payOrders", {
ordersId: that.order.ordersId,
}).then(res => {
uni.hideLoading();
if (res.code == 0) {
uni.showToast({
title: '支付成功'
})
that.getOrder()
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
});
} else if (re.cancel) {
console.log('用户点击取消');
}
}
})
} else if (that.openWay == 2) { //微信支付
// #ifdef MP-WEIXIN
let data = {
orderId: that.order.ordersId,
// type: 3
}
that.$Request.post('/app/wxPay/wxPayMpOrder', data).then(ret => {
console.log(ret)
if (ret.code == 0) {
this.showpay = false
uni.requestPayment({
provider: 'wxpay',
timeStamp: ret.data.timestamp,
nonceStr: ret.data.noncestr,
package: ret.data.package,
signType: ret.data.signType,
paySign: ret.data.sign,
success: function(ret) {
console.log(ret)
uni.showToast({
title: '支付成功',
icon: 'none'
})
that.getOrder()
// this.$queue.showToast('支付成功');
// uni.switchTab({
// url: '/pages/my/index'
// })
},
fail: function(err) {
// this.$queue.showToast('支付失败');
uni.showToast({
title: '支付失败',
icon: 'nones'
});
that.getOrder()
}
});
}
});
// #endif
// #ifdef H5
let data = {
orderId: that.order.ordersId,
// type: 2
}
that.$Request.post('/app/wxPay/wxPayJsApiOrder', data).then(rea => {
that.showpay = false
that.callPay(rea);
});
// #endif
// #ifdef APP
let data = {
orderId: that.order.ordersId,
// type: 1
}
that.$Request.post('/app/wxPay/payAppOrder', data).then(rea => {
console.log(rea)
that.showpay = false
if (rea.code == 0) {
that.isCheckPay(rea.code, 'wxpay', JSON.stringify(rea.data));
}
});
// #endif
} else if (that.openWay == 3) { //支付宝支付
// #ifdef H5
let data = {
ordersId: that.order.ordersId,
type: 2
}
that.$Request.post('/app/aliPay/payOrder', data).then(
rea => {
that.showpay = false
const div = document.createElement('div')
div.innerHTML = rea.data //此处form就是后台返回接收到的数据
document.body.appendChild(div)
document.forms[0].submit()
});
// #endif
// #ifdef APP-PLUS
let data = {
ordersId: that.order.ordersId,
type: 1
}
that.$Request.post('/app/aliPay/payOrder', data).then(
rea => {
that.showpay = false
that.setPayment('alipay', rea.data);
});
// #endif
}
},
callPay: function(response) {
if (typeof WeixinJSBridge === "undefined") {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false);
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response));
document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response));
}
} else {
this.onBridgeReady(response);
}
},
onBridgeReady: function(response) {
let that = this;
if (!response.package) {
return;
}
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
"appId": response.appid, //公众号名称,由商户传入
"timeStamp": response.timestamp, //时间戳自1970年以来的秒数
"nonceStr": response.noncestr, //随机串
"package": response.package,
"signType": response.signType, //微信签名方式:
"paySign": response.sign //微信签名
},
function(res) {
if (res.err_msg === "get_brand_wcpay_request:ok") {
// 使用以上方式判断前端返回,微信团队郑重提示:
//res.err_msg将在用户支付成功后返回ok但并不保证它绝对可靠。
uni.hideLoading();
uni.showToast({
title: '支付成功',
icon: 'none'
})
that.getOrder()
} else {
uni.hideLoading();
}
WeixinJSBridge.log(response.err_msg);
}
);
},
isCheckPay(code, name, order) {
if (code == 0) {
this.setPayment(name, order);
} else {
uni.hideLoading();
uni.showToast({
title: '支付信息有误'
});
}
},
setPayment(name, order) {
let that = this
uni.requestPayment({
provider: name,
orderInfo: order, //微信、支付宝订单数据
success: function(res) {
uni.hideLoading();
uni.showToast({
title: '支付成功',
icon: 'none'
})
that.getOrder()
},
fail: function(err) {
uni.hideLoading();
},
complete() {
uni.hideLoading();
}
});
},
cxOrder(e) {
let contentName = '确认已经出发了吗?';
if (e.status == 7) {
contentName = '确认到达服务地点准备开始服务了吗?';
}
let that = this
uni.showModal({
title: '提示',
content: contentName,
success: function(res) {
if (res.confirm) {
let data = {
ordersId: e.ordersId
}
that.$queue.showLoading('提交中...')
that.$Request.post('/app/artificer/artificerStartOrEndTime', data).then(res => {
uni.hideLoading();
if (res.code == 0) {
that.getOrder()
} else {
that.$queue.showToast(res.msg);
}
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
},
fuwuOrder(e) {
let startImg = '';
if (this.startImgSel === '是') {
if (this.startImgs.length == 0) {
this.$queue.showToast('请上传开始服务图片!');
return;
} else {
startImg = this.startImgs.toString();
}
}
let that = this
uni.showModal({
title: '提示',
content: '确认开始服务吗?',
success: function(res) {
if (res.confirm) {
let data = {
ordersId: e.ordersId,
startLongitude: that.longitude,
startLatitude: that.latitude,
startImg: startImg,
}
that.$queue.showLoading('提交中...')
that.$Request.post('/app/artificer/startOrders', data).then(res => {
uni.hideLoading();
if (res.code == 0) {
that.getOrder()
websocketUtils.uploadAudioStart(); //开启音频录制
} else {
that.$queue.showToast(res.msg);
}
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
},
// 取消订单
cancelOrder(e) {
let that = this
uni.showModal({
title: '提示',
content: '确认取消订单吗?取消订单将会被扣除信用分!',
success: function(res) {
if (res.confirm) {
let data = {
ordersId: e.ordersId
}
that.$queue.showLoading('提交中...')
that.$Request.post('/app/artificer/deleteOrders', data).then(res => {
uni.hideLoading();
if (res.code == 0) {
that.getOrder()
} else {
that.$queue.showToast(res.msg);
}
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
},
// 查看图片
saveImg(imgs, index) {
if (this.LBSelect) {
if (index == this.LBIndex - 1) {
return;
}
}
// console.log(imgs)
let that = this;
let imgArr = imgs
// imgArr.push(imgs);
// //预览图片
uni.previewImage({
urls: imgArr,
current: imgArr[index],
});
},
removeImg(index, state) {
if (state == 1) {
this.startImgs.splice(index, 1)
} else if (state == 2) {
this.endImgs.splice(index, 1)
}
},
// 图片上传
addImage(e) {
let that = this;
uni.chooseImage({
count: 6,
sourceType: ['camera'],
success: res => {
// 用于拍照后回显
let urlName = "";
if (e == 1) {
urlName = websocketUtils.getBaseUrl() + '/alioss/uploadWatermark';
}
console.log(urlName);
if (res && res.tempFilePaths.length > 0) that.pictureEcho.push(res.tempFilePaths[0]);
for (let i = 0; i < res.tempFilePaths.length; i++) {
that.$queue.showLoading("上传中...");
uni.uploadFile({ // 上传接口
// url: websocketUtils.uploadFileUrl(), //真实的接口地址
url: urlName, //真实的接口地址
filePath: res.tempFilePaths[i],
name: 'file',
success: (uploadFileRes) => {
if (e == 1) {
console.log(JSON.parse(uploadFileRes.data).data)
that.startImgs.push(JSON.parse(uploadFileRes.data).data)
} else if (e == 2) {
that.endImgs.push(JSON.parse(uploadFileRes.data).data)
}
uni.hideLoading();
},
fail(err) {
console.log(err);
}
});
}
}
})
},
// 获取APP端当前物料包剩余数量及最小消耗数量判断如果剩余数量少于最小消耗数量时
getHomeMaterialPackageList() {
let artificerId = uni.getStorageSync("artificerId");
let that = this;
getXZX("/app/material/selectMaterialArtificer?artificerId=" + artificerId + "&page=" +
(this
.currentPage ? this
.currentPage : '') + "&limit=" + (this.pageSize ? this.pageSize : '')).then(async (res) => {
if (res && res.data && res.code === 0) {
that.homeMaterialPackageList = res?.data;
}
})
},
// 完成订单
cancel(e) {
let that = this
let artificerId = uni.getStorageSync("artificerId");
let jumpRootStatus = false;
uni.showModal({
title: '提示',
content: '如果服务未完成点击完成订单会遭到平台违规处理,请确认服务是否完毕?',
success: async function(res) {
if (res.confirm) {
let data = {
ordersId: e.ordersId,
accomplishLongitude: that.longitude,
accomplishLatitude: that.latitude
}
that.$queue.showLoading('提交中...')
let resA = await post('/app/artificer/accomplishOrders', data);
uni.hideLoading();
try {
if (resA.code == 0) {
websocketUtils.uploadAudioEnd(); //关闭音频上传
} else {
that.$queue.showToast(resA.msg);
}
} catch (e) {
//TODO handle the exception
}
let resB = await getXZX("/app/material/selectMaterialArtificer?artificerId=" +
artificerId + "&page=" +
(this
.currentPage ? this
.currentPage : '') + "&limit=" + (this.pageSize ? this.pageSize : ''));
console.log(resB);
if (resB && resB.data && resB.code == 0) {
that.homeMaterialPackageList = resB?.data;
}
let materialPackageCountFlag = that.homeMaterialPackageList.some((item) => item
.residue <= item
.materialMinimum);
if (materialPackageCountFlag) {
jumpRootStatus = false;
let resC = await post('/app/artificer/offline', );
if (resC && resC.code == 0) {
that.$queue.showToast("当前剩余物料包数量不足,已强制离线");
} else {
that.$queue.showToast(resC.msg);
}
}
setTimeout(() => {
uni.navigateBack();
}, 1600)
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
},
goMsg() {
let data = {
userId: uni.getStorageSync('userId'),
focusedUserId: this.order.user.userId
}
this.$Request.postJson('/app/chat/insertChatConversation ', data).then(res => {
if (res.code == 0) {
let id = this.order.user.userId == res.data.userId ? res.data.focusedUserId : this.order
.user.userId
uni.navigateTo({
url: '/pages/msg/im?chatConversationId=' + res.data.chatConversationId +
'&byUserId=' + id
})
}
})
},
}
}
</script>
<style>
page {
background: #f7f7f7;
}
.bgbox {
background: linear-gradient(to right, #223845, #00a85b);
font-size: 32upx;
color: #ffffff;
padding: 30rpx 30rpx 80rpx 30rpx;
}
.footer-btn {
padding: 0;
min-width: 30%;
margin-top: 20rpx;
color: white;
height: 80rpx;
}
.gdfsb {
width: 48%;
background: linear-gradient(to right, #223845, #00a85b);
color: #fff !important;
border: 0 !important;
font-size: 30rpx;
height: 42px;
line-height: 42px;
}
.lxkf {
width: 48%;
text-align: center;
background-color: #f7f7f7;
border: 1px #ccc solid;
color: #333;
border-radius: 53px !important;
height: 42px;
line-height: 42px;
font-size: 30rpx;
}
.footer-btn-group {
display: flex;
position: fixed;
bottom: 0;
width: 100vw;
height: 120rpx;
background-color: #FFF;
left: 0;
right: 0;
justify-content: space-between;
}
.bj_view {
width: 100rpx;
height: 100rpx;
border-radius: 100rpx;
position: fixed;
right: 30rpx;
bottom: 180rpx;
}
.bgImg {
background-image: url('https://wap.quanmindaojia.com/file/uploadPath/2023/01/03/02952e7260e553d0f3bb26a1cd154921.png');
background-size: 100% 1161rpx;
}
.bg {
background: #FFFFFF;
}
.tabber {
width: 100%;
background: #ffffff;
position: fixed;
bottom: 0;
left: 0;
right: 0;
justify-content: center;
height: 127rpx;
padding-right: 30rpx;
}
.box {
/* border: 1px solid #005dff; */
background: #E8FAE1;
border-radius: 4rpx;
color: #096f4b;
padding: 5upx 10upx;
font-size: 22rpx;
margin-top: 10rpx;
}
.popup_pay {
width: 100%;
position: relative;
padding-bottom: 45rpx;
/* height: 160px; */
/* #ifndef MP-WEIXIN */
/* height: 130px; */
/* #endif */
}
.pay_btn {
width: 90%;
margin: 0 auto;
text-align: center;
background: #096f4b;
height: 80rpx;
border-radius: 16rpx;
color: #ffffff;
line-height: 80rpx;
}
.countDown {
display: flex;
justify-content: center;
padding: 0;
}
</style>