123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675 |
- var util = require('../../../utils/util.js');
- var api = require('../../../config/api.js');
- Page({
- data: {
- excludeAxb: '',
- //订单不包含安心包,才可以退款
- orderId: 0,
- payOverTime: 0,
- timer: '',
- remainTimes: '',
- orderInfo: {},
- dyDetails: [],
- afterSale: null,
- orderGoods: [],
- expressInfo: {},
- flag: false,
- handleOption: {},
- orderType: 0, //如果是1表示从引荐人的订单列表过来的,需要隐藏操作按钮
- shopPhone: '',
- complainTips: false,
- ticketTips: false, //投诉工单 处理结果回收
- ticketId: '', //投诉id
- satisfaction: 0, //投诉处理满意度
- satisfactionTips: {},
- satisfactionLow: {
- tips: '非常抱歉,我们会立即安排专属客服跟进了解具体问题!',
- notice: '您的评价是对我们最大的鼓励和鞭策,感谢您的评价。'
- },
- satisfactionMid: {
- tips: '我们会持续了解问题,为您提供更好的服务',
- notice: '感谢您的评价,我们会持续收集顾客的建议,优化服务!'
- },
- satisfactionHigh: {
- tips: '感谢您的认可,我们将为您持续提供优质服务',
- notice: '感谢您的认可,我们将持续为您提供更加优质的服务!'
- },
- star: '/static/images/new/star.png',
- starYellow: '/static/images/new/star_yellow.png',
- starRed: '/static/images/new/star_red.png',
- msgShow: false, //客户追加备注
- message: '', //备注信息
- cancelList: [{
- id: 19,
- value: "临时有事,暂时不预约"
- },
- {
- id: 20,
- value: "先屯着后面预约"
- },
- {
- id: 21,
- value: "服务商原因,保洁师无法上门"
- }
- ], //取消页面
- cancelShow: false,
- cancelDetailId: '',
- cancelReason: '', //选中的取消原因项
- isShowPL: false //是否台数的商品 直接显示上门时间和服务内容
- },
- cancelItemConfirm() {
- let that = this;
- if (that.data.cancelReason == '') {
- util.showErrorToast("请选择取消原因");
- return;
- }
- wx.showLoading({
- title: '提交中'
- });
- util.request(api.OrderBookCancel, {
- detailId: that.data.cancelDetailId,
- cancelReason: that.data.cancelReason
- }, "POST").then(res => {
- wx.hideLoading();
- if (res.errno === 0) {
- wx.showToast({
- title: "提交成功"
- });
- let items = that.data.dyDetails;
- items.forEach(item => {
- if (item.id == that.data.cancelDetailId) {
- item.isCancel = false;
- item.statusVal = "已取消";
- item.status = 6;
- }
- })
- this.setData({
- cancelShow: false,
- dyDetails: items,
- 'orderInfo.handleOption.book': true,
- 'orderInfo.detailId': res.data
- })
- }else{
- util.showErrorToast(res.errmsg);
- }
- })
- },
- goCancelBook(e) { //取消工单预约
- this.setData({
- cancelDetailId: e.currentTarget.dataset.id,
- cancelShow: true
- })
- },
- cancelItemSelect(e) {
- this.setData({
- cancelReason: e.currentTarget.dataset.id
- })
- },
- onCancelPopupClose() {
- this.setData({
- cancelShow: false
- })
- },
- onCancelClick() {
- //无实际意义 防止冒泡
- },
- cancelTicketTips() {
- this.setData({
- ticketTips: false,
- })
- },
- showMsg() {
- this.setData({
- msgShow: true
- })
- },
- onMsgClose() {
- this.setData({
- msgShow: false
- })
- },
- confirmMsg() {
- if (this.data.message == '') {
- util.showErrorToast("请输入备注");
- return;
- }
- let that = this;
- wx.showLoading({
- title: '提交中'
- });
- util.request(api.OrderMsg, {
- orderId: that.data.orderId,
- message: that.data.message
- }, "POST").then(function (res) {
- wx.hideLoading();
- if (res.errno === 0) {
- wx.showToast({
- title: "提交成功"
- });
- //赋值给所有工单
- let dyDetails = that.data.dyDetails;
- dyDetails.forEach(item => {
- item.customerRemark = that.data.message
- })
- that.setData({
- msgShow: false,
- dyDetails: dyDetails
- })
- }
- })
- },
- bindMsgInput(e) {
- this.setData({
- message: e.detail.value
- });
- },
- showTicketTips(e) {
- let ticketId = parseInt(e.currentTarget.dataset.id);
- this.setData({
- ticketTips: true,
- ticketId: ticketId
- })
- },
- selectTicketValue(e) { //点击星号
- let id = parseInt(e.currentTarget.dataset.id);
- this.setData({
- satisfaction: id
- })
- let tips = this.data.satisfactionLow;
- if (id >= 3 && id < 5)
- tips = this.data.satisfactionMid
- else if (id == 5)
- tips = this.data.satisfactionHigh
- this.setData({
- satisfactionTips: tips
- })
- },
- confTicketTips() {
- if (this.data.satisfaction == 0) {
- util.showErrorToast("请选择满意度");
- return;
- }
- let that = this;
- wx.showLoading({
- title: '提交中'
- });
- util.request(api.TicketSatisfaction, {
- id: that.data.ticketId,
- satisfaction: that.data.satisfaction
- }, "POST").then(function (res) {
- if (res.errno === 0) {
- wx.hideLoading();
- //隐藏弹框并设置工单为已评论过
- let dyDetails = that.data.dyDetails;
- dyDetails.forEach(detail => {
- if (detail.ticketVo && detail.ticketVo.ticketId == that.data.ticketId) {
- detail.ticketVo.isSatisfaction = false;
- console.info("进入")
- console.info(detail)
- }
- });
- that.setData({
- ticketTips: false,
- dyDetails: dyDetails
- });
- wx.showToast({
- title: that.data.satisfactionTips.notice,
- icon: 'none',
- duration: 2000
- });
- }
- });
- },
- onLoad: function (options) {
- // 页面初始化 options为页面跳转所带来的参数
- this.setData({
- orderId: options.id,
- orderType: options.orderType
- });
- // this.getOrderDetail();
- },
- onShow: function () {
- // 页面显示
- this.getOrderDetail();
- },
- onPullDownRefresh() {
- wx.showNavigationBarLoading(); //在标题栏中显示加载
- this.getOrderDetail();
- wx.hideNavigationBarLoading(); //完成停止加载
- wx.stopPullDownRefresh(); //停止下拉刷新
- },
- expandDetail: function () {
- let that = this;
- this.setData({
- flag: !that.data.flag
- });
- },
- getOrderDetail: function () {
- wx.showLoading({
- title: '加载中'
- });
- setTimeout(function () {
- wx.hideLoading();
- }, 2000);
- let that = this;
- util.request(api.OrderDetail, {
- orderId: that.data.orderId
- }).then(function (res) {
- if (res.errno === 0) {
- wx.hideLoading();
- console.log(11)
- //获取预约开始时间
- res.data.dyDetails.forEach(item => {
- if (item.bookTime)
- item.bookStartTime = item.bookTime.substring(0, 16);
- });
- that.setData({
- orderInfo: res.data,
- dyDetails: res.data.dyDetails,
- afterSale: res.data.afterSale,
- payOverTime: res.data.payOverTime,
- remainTimes: res.data.serviceTimes - res.data.servedTimes,
- message: res.data.message
- // orderGoods: res.data.orderGoods,
- // handleOption: res.data.orderInfo.handleOption,
- // expressInfo: res.data.expressInfo
- });
- //是否为按台服务的商品--按台服务商品 展示服务内容 通过关键字:空调、油烟机、洗衣机、冰箱
- if (res.data.goodsName.indexOf('空调') >= 0 || res.data.goodsName.indexOf('油烟机') >= 0 ||
- res.data.goodsName.indexOf('洗衣机') >= 0 || res.data.goodsName.indexOf('冰箱') >= 0) {
- that.setData({
- isShowPL: true
- })
- }
- if (that.data.payOverTime > 0) {
- let timer = setInterval(() => {
- let newTime = that.data.payOverTime - 1;
- if (newTime >= 0) {
- that.setData({
- payOverTime: newTime
- });
- } else {
- clearInterval(that.data.timer);
- }
- }, 1000);
- that.setData({
- timer: timer
- });
- }
- }
- // let excludeAxb = res.data.orderGoods.every(item => {
- // return item.goodsSn != '1036016';
- // });
- // that.setData({
- // excludeAxb: excludeAxb
- // });
- });
- },
- // “去付款”按钮点击效果
- payOrder: function () {
- let that = this;
- util.request(api.OrderPayCheck, {
- orderId: that.data.orderInfo.id
- }, 'POST').then(function (res) {
- if (res.errno === 0) {
- const outOrderNo = res.data;
- console.log(res);
- wx.continueToPay({
- // orderId: this.data.orderId, // 内部订单号
- outOrderNo: outOrderNo, // 外部订单号 2个订单号必填一个
- success: res => {
- console.log(res);
- const {
- orderId,
- outOrderNo
- } = res;
- console.log('success res', res);
- console.log('orderId', orderId, 'outOrderNo', outOrderNo);
- wx.redirectTo({
- url: '/pages/ucenter/order/order'
- });
- },
- fail: res => {
- console.log(res);
- const {
- orderId,
- outOrderNo,
- errNo,
- errMsg,
- errLogId
- } = res;
- if (errLogId) {
- console.log('查询订单信息失败', errNo, errMsg, errLogId);
- }
- if (orderId || outOrderNo) {
- console.log('支付失败', errNo, errMsg, orderId, outOrderNo);
- }
- util.showErrorToast('支付失败');
- },
- });
- }
- });
- },
- payOrder() {
- let that = this;
- util.request(api.OrderPrepay, {
- orderId: this.data.orderId
- }, 'POST').then(function (res) {
- if (res.errno === 0) {
- const payParam = res.data;
- console.log("支付过程开始")
- wx.requestPayment({
- 'timeStamp': payParam.timeStamp,
- 'nonceStr': payParam.nonceStr,
- 'package': payParam.packageValue,
- 'signType': payParam.signType,
- 'paySign': payParam.paySign,
- 'success': function (res) {
- console.log("支付过程成功")
- that.getOrderDetail();
- },
- 'fail': function (res) {
- console.log("支付过程失败")
- util.showErrorToast('支付失败');
- },
- 'complete': function (res) {
- console.log("支付过程结束")
- }
- });
- }else{
- wx.showToast({
- title: res.errmsg,
- icon: 'none'
- });
- }
- });
- },
- // “取消订单”点击效果
- cancelOrder: function () {
- let that = this;
- let orderInfo = that.data.orderInfo;
- wx.showModal({
- title: '',
- content: '确定要取消此订单?',
- success: function (res) {
- if (res.confirm) {
- util.request(api.OrderCancel, {
- orderId: orderInfo.id
- }, 'POST').then(function (res) {
- if (res.errno === 0) {
- wx.showToast({
- title: '取消订单成功'
- });
- util.redirect('/pages/ucenter/order/order');
- } else {
- util.showErrorToast(res.errmsg);
- }
- });
- }
- }
- });
- },
- // “取消订单并退款”点击效果
- refundOrder: function () {
- let that = this;
- let orderInfo = that.data.orderInfo;
- wx.showModal({
- title: '',
- content: '确定要取消此订单?',
- success: function (res) {
- if (res.confirm) {
- util.request(api.OrderRefund, {
- orderId: orderInfo.id
- }, 'POST').then(function (res) {
- if (res.errno === 0) {
- wx.showToast({
- title: '取消订单成功'
- });
- util.redirect('/pages/ucenter/order/order');
- } else {
- util.showErrorToast(res.errmsg);
- }
- });
- }
- }
- });
- },
- // “删除”点击效果
- deleteOrder: function () {
- let that = this;
- let orderInfo = that.data.orderInfo;
- wx.showModal({
- title: '',
- content: '确定要删除此订单?',
- success: function (res) {
- if (res.confirm) {
- util.request(api.OrderDelete, {
- orderId: orderInfo.id
- }, 'POST').then(function (res) {
- if (res.errno === 0) {
- wx.showToast({
- title: '删除订单成功'
- });
- util.redirect('/pages/ucenter/order/order');
- } else {
- util.showErrorToast(res.errmsg);
- }
- });
- }
- }
- });
- },
- // “待上门”点击效果
- confirmOrder: function () {
- let that = this;
- let orderInfo = that.data.orderInfo;
- wx.showModal({
- title: '',
- content: '确认上门服务?',
- success: function (res) {
- if (res.confirm) {
- util.request(api.OrderConfirm, {
- orderId: orderInfo.id
- }, 'POST').then(function (res) {
- if (res.errno === 0) {
- wx.showToast({
- title: '确认上门成功!'
- });
- util.redirect('/pages/ucenter/order/order');
- } else {
- util.showErrorToast(res.errmsg);
- }
- });
- }
- }
- });
- },
- // “申请售后”点击效果
- aftersaleOrder: function () {
- wx.navigateTo({
- url: '/pages/ucenter/applyRefund/applyRefund?id=' + this.data.orderId,
- });
- // 0没申请 1申请没审核 2 客服审核通过 3 退款成功 4审核拒绝 5 用户取消 6退款中
- // util.redirect('/pages/ucenter/aftersale/aftersale?id=' + this.data.orderId);
- // if (this.data.orderInfo.afterSaleStatus === 0||this.data.orderInfo.afterSaleStatus === 4) {
- // wx.navigateTo({
- // url:'/pages/ucenter/applyRefund/applyRefund?id=' + this.data.orderId ,
- // });
- // } else {
- // util.redirect('/pages/ucenter/aftersaleDetail/aftersaleDetail?id=' + this.data.orderId);
- // }
- },
- viewService() {
- wx.navigateTo({
- url: '../serviceDetail/serviceDetail?orderId=' + this.data.orderId
- });
- },
- buyAgain(e) {
- let id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: '/pages/goods/goods?id=' + id,
- });
- },
- copyOrder() {
- wx.setClipboardData({
- data: this.data.orderInfo.orderSn,
- success: function (res) {
- wx.getClipboardData({
- success: function (res) {
- wx.showToast({
- title: '订单编号复制成功',
- icon: 'success',
- duration: 2000
- });
- }
- });
- }
- });
- },
- onReady: function () {
- // 页面渲染完成
- },
- onHide: function () {
- console.log('onHide');
- // clearInterval(this.data.timer);
- },
- onUnload: function () {
- console.log('onunload');
- clearInterval(this.data.timer);
- },
- cancelRefund() {
- let that = this;
- let afterSale = that.data.afterSale;
- wx.showModal({
- title: '',
- content: '确认取消退款?',
- success: function (res) {
- if (res.confirm) {
- util.request(api.AftersaleCancel, {
- orderId: afterSale.orderId,
- id: afterSale.id
- }, 'POST').then(function (res) {
- if (res.errno === 0) {
- wx.showToast({
- title: '操作成功!'
- });
- that.getOrderDetail();
- } else {
- util.showErrorToast(res.errmsg);
- }
- });
- }
- }
- });
- },
- goReVisit(e) {
- let id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: '/pages/extra/newRevisit/newRevisit?id=' + id,
- success: (res) => {
- },
- fail: (res) => {
- },
- });
- },
- goComplain(e) {
- let phone = e.currentTarget.dataset.phone;
- this.setData({
- shopPhone: phone,
- complainTips: true
- })
- },
- cancelComplain() {
- this.setData({
- complainTips: false
- })
- },
- confComplain() {
- wx.makePhoneCall({
- phoneNumber: this.data.shopPhone
- });
- },
- goEditAppoint(e) {
- let id = e.currentTarget.dataset.id;
- let status = e.currentTarget.dataset.status;
- // if (status == 1) {
- // let time = e.currentTarget.dataset.time;
- // let str = time.substr(0, 16).replace(/-/g, '/');
- // let isNear = new Date(str).getTime() - new Date().getTime() - 2 * 60 * 60 * 1000;
- // console.log(isNear);
- // if (isNear < 0) {
- // wx.showToast({
- // title: '服务时间小于2小时,不能修改预约',
- // icon: 'none',
- // duration: 2000
- // });
- // return false;
- // }
- // }
- wx.navigateTo({
- url: '/pages/ucenter/appointOrder/appointOrder?serviceId=' + id + '&orderId=' + this.data.orderInfo.id,
- success: (res) => {
- },
- fail: (res) => {
- },
- });
- },
- // goAppoint() {
- // console.log(this.data.orderId );
- // wx.navigateTo({
- // url: '/pages/ucenter/appointOrder/appointOrder?orderId=' + this.data.orderId + '&serviceId=' + this.data.orderId,
- // });
- // },
- makeStorePhone(e) {
- wx.makePhoneCall({
- phoneNumber: e.currentTarget.dataset.phone
- });
- },
- goAppoint(e) {
- let id = e.currentTarget.dataset.id;
- let detailId = e.currentTarget.dataset.detail;
- wx.navigateTo({
- url: '/pages/ucenter/appointOrder/appointOrder?orderId=' + this.data.orderId + '&serviceId=' + detailId
- })
- },
- goIm(){
- wx.navigateTo({
- url: '/pages/im/im'
- });
- },
- });
|