123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704 |
- var util = require('../../../utils/util.js');
- var api = require('../../../config/api.js');
- var app = getApp();
- Page({
- data: {
- timer: '',
- orderList: [],
- showType: 2,
- page: 1,
- limit: 10,
- totalPages: 1,
- myqr_show: false,
- //我的分享二维码
- myqr_url: null,
- myqr_blur: 0,
- //背景模糊值
- myqr_width: 0,
- hasLogin: false,
- goodsId: '',
- tipsList:[],
- refundTipShow:false,
- refundId:'',
- serModifyList:[],
- serviceId:'',
- appointOrderId:'',
- appointDiaType:'',//1修改预约 2取消预约
- appointDiaShow:false,
- cancelShow:false,
- cancelList: [{
- id: 19,
- value: '【个人原因】临时有事暂时不预约'
- },
- {
- id: 20,
- value: '【个人原因】先囤着以后再约'
- },
- {
- id: 22,
- value: '【个人原因】计划有变不需要了'
- },
- {
- id: 21,
- value: '【商家原因】保洁师无法上门服务'
- },
- {
- id: 23,
- value: ' 其他'
- }
- ],
- cancelReason: '',
- cancelFirstShow:false,
-
- },
- onLoad: function (options) {
- // 页面初始化 options为页面跳转所带来的参数
- if (options.tab) {
- this.setData({
- showType: options.tab
- });
- }
- },
- getOrderList() {
- wx.showLoading({
- title: '加载中'
- });
- let that = this;
- util.request(api.OrderList, {
- showType: that.data.showType,
- page: that.data.page,
- limit: that.data.limit
- }).then(res => {
- wx.hideLoading();
- if (res.errno === 0) {
- console.log(res.data);
- that.setData({
- orderList: that.data.orderList.concat(res.data.data),
- totalPages: res.data.pages
- });
- clearInterval(this.data.timer);
- // 如果有未支付订单,倒计时定时器
- let isHasOver = this.data.orderList.some(item => {
- return item.payOverTime > 0;
- });
- console.log(isHasOver);
- if (isHasOver) {
- let timer = setInterval(() => {
- let list = this.data.orderList;
- let newList = [];
- list.forEach(item => {
- let obj = item;
- if (item.payOverTime > 0) {
- obj.payOverTime = item.payOverTime - 1;
- }
- newList.push(obj);
- });
- this.setData({
- orderList: newList
- });
- }, 1000);
- this.setData({
- timer: timer
- });
- }
- }
- });
- },
- onHide: function () {
- console.log('onHide');
- clearInterval(this.data.timer);
- },
- onUnload: function () {
- console.log('onunload');
- clearInterval(this.data.timer);
- },
- onReachBottom() {
- if (this.data.totalPages > this.data.page) {
- this.setData({
- page: this.data.page + 1
- });
- this.getOrderList();
- } else if (this.data.orderList.length > 0) {
- wx.showToast({
- title: '没有更多订单了',
- icon: 'none',
- duration: 2000
- });
- return false;
- }
- },
- orderDetail(e) {
- let id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: '/pages/ucenter/orderDetail/orderDetail?id=' + id
- });
- },
- switchTab: function (event) {
- let showType = event.currentTarget.dataset.index;
- this.setData({
- orderList: [],
- showType: showType,
- page: 1,
- // limit: 10,
- totalPages: 1
- });
- this.getOrderList();
- },
- onTabChange(e) {
- // let showType = e.detail.name;
- let showType = e.currentTarget.dataset.tab;
- this.setData({
- orderList: [],
- showType: showType,
- page: 1,
- // limit: 10,
- totalPages: 1
- });
- this.getOrderList();
- },
- appointServiceOld(e) {
- let id = e.currentTarget.dataset.id;
- let addressId = e.currentTarget.dataset.aid;
- let type = e.currentTarget.dataset.type;
- if (type && type == 5) {
- wx.navigateTo({
- url: "/pages/ucenter/coupon/couponGoods?id=1"
- });
- return;
- }
- if (addressId == null || addressId == 0)
- wx.navigateTo({
- url: '/pages/ucenter/appointOrder/appointOrder?orderId=' + id
- });
- else //买约分离 没有地址的预约
- wx.navigateTo({
- url: '/pages/ucenter/serviceDetail/serviceDetail?orderId=' + id
- });
- },
- appointService(e) {
- let id = e.currentTarget.dataset.id;
- let addressId = e.currentTarget.dataset.aid;
- let type = e.currentTarget.dataset.type;
- let detailId = e.currentTarget.dataset.detail;
- wx.navigateTo({
- url: '/pages/ucenter/appointOrder/appointOrder?orderId=' + id + '&serviceId=' + detailId
- });
- },
- qrtouchstart: function () {
- this.setData({
- myqr_blur: 0,
- myqr_show: false
- });
- },
- shareFriendOrCircle: function (e) {
- // let that = this;
- // if (!app.globalData.hasLogin) {
- // wx.navigateTo({
- // url: "/pages/auth/login/login"
- // });
- // return;
- // }
- // //获取分享id 用来追踪链接
- // //引荐人和非引荐人的 链接不同
- // let imgUrl = that.data.goods.shareWxUrl ? that.data.goods.shareWxUrl : that.data.goods.gallery[0];
- // var path = '/pages/goods/goods?id=' + that.data.id + '&rId=' + that.data.userInfo.id;
- // if (that.data.userInfo.isDis) { //是引荐人
- // path = '/pages/goods/goods?id=' + that.data.id + '&shareId=' + that.data.wxShareId;
- // }
- // this.hidePoster();
- // return {
- // title: that.data.goods.name,
- // desc: that.data.myqr_ads,
- // path: path,
- // imageUrl: imgUrl
- // }
- },
- // 保存分享图
- saveShare: function () {
- let that = this;
- wx.showLoading({
- title: '图片保存中'
- });
- console.log(that.data);
- wx.downloadFile({
- url: that.data.myqr_url,
- success: function (res) {
- console.log(res);
- wx.saveImageToPhotosAlbum({
- filePath: res.tempFilePath,
- success: function (res) {
- wx.hideLoading();
- wx.showModal({
- title: '存图成功',
- content: '图片成功保存到相册了,可以分享到朋友圈了',
- showCancel: false,
- confirmText: '好的',
- confirmColor: '#a78845',
- success: function (res) {
- if (res.confirm) {
- console.log('用户点击确定');
- that.setData({
- myqr_show: false,
- myqr_blur: 0
- });
- }
- }
- });
- },
- fail: function (res) {
- wx.hideLoading();
- wx.showModal({
- title: '警告',
- content: '不授权无法保存',
- showCancel: false
- });
- that.setData({
- myqr_show: false,
- myqr_blur: 0
- });
- }
- });
- },
- fail: function (res) {
- wx.hideLoading();
- console.log(res);
- }
- });
- },
- // “去付款”按钮点击效果
- payOrder: function (e) {
- let that = this;
- let id = e.currentTarget.dataset.id;
- let ordern = e.currentTarget.dataset.sn;
- util.request(api.OrderPayCheck, {
- orderId: 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);
- console.log('订单号' + outOrderNo);
- // wx.navigateTo({
- // url: '/pages/ucenter/orderDetail/orderDetail?id='+outOrderNo
- // });
- }
- util.showErrorToast('支付失败');
- },
- });
- }
- });
- },
- payOrder(e) {
- let that = this;
- let id = e.currentTarget.dataset.id;
- util.request(api.OrderPrepay, {
- orderId: id
- }, '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("支付过程成功")
- wx.redirectTo({
- url: '/pages/ucenter/order/order'
- });
- },
- 'fail': function (res) {
- console.log("支付过程失败")
- util.showErrorToast('支付失败');
- },
- 'complete': function (res) {
- console.log("支付过程结束")
- }
- });
- }else{
- wx.showToast({
- title: res.errmsg,
- icon: 'none'
- });
- }
- });
- },
- // “删除”点击效果
- deleteOrder: function (e) {
- let that = this;
- let id = e.currentTarget.dataset.id;
- wx.showModal({
- title: '',
- content: '确定要删除此订单?',
- success: function (res) {
- if (res.confirm) {
- util.request(api.OrderDelete, {
- orderId: id
- }, 'POST').then(function (res) {
- if (res.errno === 0) {
- wx.showToast({
- title: '删除订单成功'
- });
- util.redirect('/pages/ucenter/order/order');
- } else {
- util.showErrorToast(res.errmsg);
- }
- });
- }
- }
- });
- },
- // “取消订单”点击效果
- cancelOrder: function (e) {
- let that = this;
- let id = e.currentTarget.dataset.id;
- wx.showModal({
- title: '',
- content: '确定要取消此订单?',
- success: function (res) {
- if (res.confirm) {
- util.request(api.OrderCancel, {
- orderId: 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 (e) {
- let that = this;
- let id = e.currentTarget.dataset.id;
- wx.showModal({
- title: '',
- content: '确认上门服务?',
- success: function (res) {
- if (res.confirm) {
- util.request(api.OrderConfirm, {
- orderId: id
- }, 'POST').then(function (res) {
- if (res.errno === 0) {
- wx.showToast({
- title: '确认上门成功!'
- });
- util.redirect('/pages/ucenter/order/order');
- } else {
- util.showErrorToast(res.errmsg);
- }
- });
- }
- }
- });
- },
- // “取消订单并退款”点击效果
- refundOrderOld: function (e) {
- let that = this;
- let id = e.currentTarget.dataset.id;
- wx.showModal({
- title: '',
- content: '确定要取消此订单?',
- success: function (res) {
- if (res.confirm) {
- util.request(api.OrderRefund, {
- orderId: id
- }, 'POST').then(function (res) {
- if (res.errno === 0) {
- wx.showToast({
- title: '取消订单成功'
- });
- util.redirect('/pages/ucenter/order/order');
- } else {
- util.showErrorToast(res.errmsg);
- }
- });
- }
- }
- });
- },
- refundOrderOld: function (e) {
- let id = e.currentTarget.dataset.id;
- },
- refundOrder: function (e) {
- let id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: '/pages/ucenter/applyRefund/applyRefund?id=' + id,
- });
- },
- onReady: function () {
- // 页面渲染完成
- },
- onShow: function () {
- // 页面显示
- this.setData({
- orderList: [],
- page: 1,
- });
- // wx.pageScrollTo({
- // scrollTop: 0,
- // duration: 1000,
- // });
- this.getOrderList();
- },
- buyAgain(e) {
- let id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: '/pages/goods/goods?id=' + id,
- });
- },
- goCheck(e) {
- let id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: '/pages/ucenter/orderDetail/orderDetail?id=' + id
- });
- },
- handleInit(event) {
- const {
- status
- } = event.detail;
- console.log(status);
- },
- handleSuccess(event) {
- const {
- result
- } = event.detail;
- // 团购订单不支持查看评价,此时可决定按钮是否展示
- console.log(result);
- },
- handleError(event) {
- const {
- errMsg,
- errNo
- } = event.detail;
- // errNo(错误码,对应某种具体报错原因)
- // errMsg(报错信息)
- console.log(errMsg, errNo);
- },
- goAppoint(e) {
- let id = e.currentTarget.dataset.id;
- let detailId = e.currentTarget.dataset.detail;
- wx.navigateTo({
- url: '/pages/ucenter/appointOrder/appointOrder?orderId=' + id + '&serviceId=' + detailId
- });
- },
-
- switchSer(e){
- let serid = e.currentTarget.dataset.serid;
- this.setData({
- serviceId:serid
- });
- },
- appointModifyConf(){
- if(this.data.serviceId==''||this.data.serviceId==null){
- wx.showToast({
- title: '请选择要修改的服务',
- icon:'none'
- });
- return false;
-
- }else{
- this.setData({
- appointDiaShow:false
- });
- wx.navigateTo({
- url: '/pages/ucenter/appointOrder/appointOrder?orderId=' + this.data.appointOrderId + '&serviceId=' +
- this.data.serviceId
- });
- }
- },
- closeModify(){
- this.setData({
- appointDiaShow:false
- });
- },
- modifyAppoint(e){
- let id = e.currentTarget.dataset.id;
- let serid = e.currentTarget.dataset.serid;
- let times = e.currentTarget.dataset.times;
- this.setData({
- appointOrderId:id
- });
- if(times>1){
- this.setData({
- appointDiaShow:true,
- serviceId:''
- });
- util.request(
- api.getBooked,
- {orderId: id},
- 'GET'
- ).then(res=> {
- if (res.errno === 0) {
- this.setData({
- serModifyList:res.data
- })
-
- }
- });
-
- }else{
- wx.navigateTo({
- url: '/pages/ucenter/appointOrder/appointOrder?orderId=' + id + '&serviceId=' +serid
- });
-
- }
- },
- onCancelClick() {
-
- },
-
- cancelAppoint(e){
- let id = e.currentTarget.dataset.id;
- let serid = e.currentTarget.dataset.serid;
- let times = e.currentTarget.dataset.times;
- this.setData({
- appointOrderId:id
- });
- if(times>1){
- this.setData({
- cancelFirstShow:true,
- serviceId:''
- });
- util.request(
- api.getBooked,
- {orderId: id},
- 'GET'
- ).then(res=> {
- if (res.errno === 0) {
- this.setData({
- serModifyList:res.data
- })
-
- }
- });
-
- }else{
- this.setData({
- cancelShow:true,
- serviceId:serid
- });
-
- }
-
- },
- cancelItemSelect(e) {
- this.setData({
- cancelReason: e.currentTarget.dataset.id
- });
- },
-
- onCancelPopupClose() {
- this.setData({
- cancelShow: false
- });
- },
- onCancelPopupCloseFir(){
- this.setData({
- cancelFirstShow: false
- });
-
- },
- cancelFirstConfirm(){
- if(this.data.serviceId==''||this.data.serviceId==null){
- wx.showToast({
- title: '请选择要取消的服务',
- icon:'none'
- });
- return false;
- }
- this.setData({
- cancelFirstShow: false,
- cancelShow: true
- });
- },
- cancelItemConfirm() {
- let that = this;
- if (that.data.cancelReason == '') {
- util.showErrorToast('请选择取消原因');
- return;
- }
- wx.showLoading({
- title: '提交中'
- });
- util.request(
- api.OrderBookCancel, {
- detailId: this.data.serviceId,
- cancelReason: this.data.cancelReason
- },
- 'POST'
- ).then((res) => {
- wx.hideLoading();
- if (res.errno === 0) {
- wx.showToast({
- title: '提交成功'
- });
-
- this.setData({
- cancelShow: false,
- orderList: [],
- page: 1
-
- });
- this.getOrderList();
-
- }else{
- util.showErrorToast(res.errmsg);
- }
- });
- },
- });
|