From 2a92106251a96712ebb2c879909eeb28c56f2d1e Mon Sep 17 00:00:00 2001 From: taiwan Date: Wed, 12 Jan 2022 09:31:16 +0800 Subject: [PATCH] 订单列表增加卡项(暂时隐藏) --- pages/user/order_list/order_list.js | 433 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------ pages/user/order_list/order_list.wxml | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ pages/user/order_list/order_list.wxss | 3 +++ 3 files changed, 551 insertions(+), 24 deletions(-) diff --git a/pages/user/order_list/order_list.js b/pages/user/order_list/order_list.js index 33661b6..c5058a1 100644 --- a/pages/user/order_list/order_list.js +++ b/pages/user/order_list/order_list.js @@ -1,4 +1,5 @@ const app = getApp(); +let self = null; var t = function(t) { return t && t.__esModule ? t : { default: t @@ -36,6 +37,16 @@ Page({ name: "待评价", id: 4 }], + tab_serviceCard: [{ + name: "全部", + id: 0, + },{ + name: "待付款", + id: 1, + },{ + name: "待评价", + id: 2, + }], activeCategoryId: 0, orderList: null, currentPage: 1, @@ -50,6 +61,7 @@ Page({ back_goods_arr:null, //返回商品的列表 currentIndex: 0, + tabIndex: 0, startDate: '', endDate: '', @@ -60,11 +72,12 @@ Page({ is_no_data2: 0, is_no_more2: 0, - + cardList: [], // 搜索内容 searchContent: '', }, onLoad: function(t) { + self = this; // 设置日期选择器的结束时间为当前日期 var now=new Date(); var nowDate = now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate(); @@ -329,6 +342,7 @@ Page({ wx.stopPullDownRefresh(); }, null, {store_id: os.stoid, user_id: oo.user_id}); }, + //滑倒底部 onReachBottom: function() { if(this.data.currentIndex == 0) { @@ -339,13 +353,23 @@ Page({ } s.canloadMore() && this.requestOrderList(this.data.activeCategoryId); } else { - this.request_list({ - store_id: os.stoid, - user_id: oo.user_id, + if(this.data.currentIndex == 1) { + this.request_list({ + store_id: os.stoid, + user_id: oo.user_id, page: this.data.currentPage2, - }); + }); + } else { // 卡项订单 + this.request_list({ + store_id: os.stoid, + user_id: oo.user_id, + page: this.data.currentPage2, + }); + } + } }, + onPullDownRefresh: function(t) { // sty取消 // this.resetData(), this.requestOrderList(this.data.activeCategoryId); @@ -1799,8 +1823,16 @@ Page({ // var req_data = { // page:th.data.currentPage2 // } - - app.request.promiseGet("/api/weshop/order/pagePosOrder", { + let currentIndex = this.data.currentIndex; + let url = ''; + if(currentIndex == 1) { + url = '/api/weshop/order/pagePosOrder'; + }; + if(currentIndex == 2) { + url = '/api/weshop/recharge/user/page'; + }; + + app.request.promiseGet(url, { data: data }).then(res=>{ // 关闭加载状态 @@ -1812,9 +1844,20 @@ Page({ var data = res.data.data.pageData; // 判断有无更多数据可以加载,如果大于则没有更多数据,反之则有 if(res.data.data.page*res.data.data.pageSize > res.data.data.total){th.setData({is_no_more2:1});} - var list=th.data.list2; - list=list.concat(data); - th.setData({list2:list}); + let list= []; + + if(currentIndex == 1) { + list = th.data.list2; + list = list.concat(data); + th.setData({list2:list}); + }; + if(currentIndex == 2) { // 卡项订单 + list = th.data.cardList; + list = list.concat(data); + th.setData({cardList:list}); + console.log('currentCard', list); + }; + } else { if(th.data.currentPage2==1){ th.setData({is_no_data2:1}); @@ -1839,7 +1882,7 @@ Page({ this.setData({ currentIndex: currentIndex }); - console.log(this.data.currentIndex); + this.setData({ is_no_data2: 0, is_no_more2: 0, @@ -1852,7 +1895,8 @@ Page({ startDate: '选择开始时间', endDate: '选择结束时间', });--*/ - } else if(currentIndex == 1) { + }; + if(currentIndex == 1) { console.log('线下订单'); this.request_list({ store_id: os.stoid, @@ -1862,6 +1906,43 @@ Page({ EndDate: this.data.endDate }); }; + if(currentIndex == 2) { + console.log('卡项订单'); + // this.setData({ + // orderList: null, + // }); + // 默认请求全部卡项订单 + this.request_list({ + store_id: os.stoid, + user_id: oo.user_id, + }); + // let url = '/api/weshop/recharge/user/page'; + // let data = { + // store_id: os.stoid, + // user_id: oo.user_id, + // }; + // app.promiseGet(url, { + // data: data, + // }).then(res => { + // if(res.data.code == 0) { + // console.log('卡项订单请求成功', res); + // this.setData({ + // orderList: res.data.data.pageData, + // }); + // } else { + // throw(res); + // }; + // }).catch(err => { + // console.log('卡项订单请求失败', err); + // this.setData({ + // orderList: null, + // }); + // wx.showToast({ + // title: err.data.data, + // icon: 'error', + // }); + // }); + }; }, bindDateChange1: function(e) { @@ -1883,10 +1964,46 @@ Page({ }, searchOnline() { - console.log('online',this.data.searchContent); + let currentIndex = this.data.currentIndex; + console.log('online',this.data.searchContent, currentIndex); if(this.data.searchContent) { console.log(this.data.searchContent); - this.resetData(), this.requestOrderList(this.data.activeCategoryId); + if(currentIndex == 0) { + this.resetData(), this.requestOrderList(this.data.activeCategoryId); + }; + if(currentIndex == 2) { // 卡项订单 + let url = '/api/weshop/recharge/user/page'; + let data = { + store_id: os.stoid, + user_id: oo.user_id, + keyWord: this.data.searchContent, + }; + this.setData({ + tabIndex: 0, + }); + // 请求数据 + app.promiseGet(url, { + data: data, + }).then(res => { + if(res.data.code == 0) { + // console.log('卡项订单请求成功', res); + this.setData({ + cardList: res.data.data, + }); + } else { + throw(res); + }; + }).catch(err => { + // console.log('卡项订单请求失败', err); + this.setData({ + cardList: null, + }); + wx.showToast({ + title: err.data.data, + icon: 'error', + }); + }); + }; } else { wx.showToast({ title: '您还没有输入搜索内容~', @@ -1980,10 +2097,290 @@ Page({ }) }, - go_url(e){ - var url=e.currentTarget.dataset.url; - getApp().goto(url); - } + go_url(e){ + var url=e.currentTarget.dataset.url; + getApp().goto(url); + }, + + // 点击卡项订单二级tabbar + clickTab(e) { + console.log('服务卡项index', e.target.dataset.index); + let currentIndex = e.target.dataset.index; + + let url = '/api/weshop/recharge/user/page'; + let data = { + store_id: os.stoid, + user_id: oo.user_id, + }; + this.setData({ + tabIndex: currentIndex, + is_no_data2: 0, + is_no_more2: 0, + cardList: [], + }); + + + switch(currentIndex) { + case 0: { // 全部 + delete data.order_status; + break; + }; + case 1: { // 待支付 + data.order_status = 0; + break; + }; + case 2: { // 待评价 + data.order_status = 1; + break; + }; + }; + // 请求数据 + this.request_list(data); + + // app.promiseGet(url, { + // data: data, + // }).then(res => { + // if(res.data.code == 0) { + // console.log('卡项订单请求成功', res); + // this.setData({ + // orderList: res.data.data.pageData, + // }); + // } else { + // throw(res); + // }; + // }).catch(err => { + // console.log('卡项订单请求失败', err); + // this.setData({ + // orderList: null, + // }); + // wx.showToast({ + // title: err.data.data, + // icon: 'error', + // }); + // }); + }, + + // 卡项订单 - 查看详情 + viewDetails() { + let url = '/packageA/pages/details_serviceCard/details_serviceCard'; + app.goto(url); + }, + + // 卡项订单 - 立即支付 + pay(e) { + let index = e.currentTarget.dataset.index; + let item = this.data.cardList[index]; + let order_sn = item.order_sn; + let store_id = app.globalData.setting.stoid; + console.log('go1!!!!!!!!!!!!!!!!!!!!!!!!!',index,item,order_sn,store_id); + + app.request.post('/api/weshop/order/pay/createRechargeOrder', { + data: { + parentSn: order_sn, + store_id: store_id, + }, + + success: function(res) { + var n = res.data.data; + self.weixinPay(n, function() { + app.showWarning('支付成功'); + // setTimeout(function() { + // wx.reLaunch({ + // url: '/pages/user/my_service/i_service', + // }) + // }, 1000) + }, function() { + app.showWarning('支付失败'); + // setTimeout(function() { + // wx.reLaunch({ + // url: '/packageA/pages/cardList/cardList', + // }) + // }, 1000) + }); + } + }) + }, + + //------调起支付框-------- + weixinPay: function(n, success, fail) { + if (!n) return false; + wx.requestPayment({ + timeStamp: String(n.timeStamp), + nonceStr: n.nonceStr, + package: n.packageValue, + signType: n.signType, + paySign: n.paySign, + success: function(n) { + console.log(n), getApp().showSuccess("支付成功!"); + "function" == typeof success && success(); + wx.redirectTo({ + url: "../deposit/deposit" + }); + }, + fail: function(n) { + console.log(n), "requestPayment:fail" == n.errMsg ? getApp().showWarning("支付失败") : + "requestPayment:fail cancel" == n.errMsg ? getApp().showWarning("您已取消支付") : getApp().showWarning("支付失败:" + n + .errMsg.substr("requestPayment:fail ".length)), + "function" == typeof fail && fail(); + } + }); + }, + + // 卡项订单 - 取消订单 + // api/weshop/recharge/update?store_id=&order_id=&order_status=3 + cancle(e) { + wx.showModal({ + title: '提示', + content: '确定取消订单吗?', + success (res) { + if (res.confirm) { + console.log('取消订单~'); + let order_id = e.currentTarget.dataset.orderid; + let order_sn = e.currentTarget.dataset.ordersn; + app.request.put('/api/weshop/recharge/update', { + data: { + store_id: os.stoid, + order_id: order_id, + order_sn: order_sn, + order_status: 3, + }, + success: function(res) { + wx.showToast({ + title: '取消成功', + success: function() { + + // 这里还可以优化不刷新,后面有时间再优化 + self.setData({ + is_no_data2: 0, + is_no_more2: 0, + }); + + // 这里还可以优化不刷新,后面有时间再优化 + self.clickTab(e); + }, + }); + + // let index = e.currentTarget.dataset.index; + // let cardList = self.data.cardList; + // cardList.splice(index, 1); + // self.setData({ + // cardList, + // }); + + //self.request_list(self.data.currentRequestData); + }, + }) + } else if (res.cancel) { + console.log('用户点击取消'); + } + } + }); + }, + + + // 卡项订单 - 再来一单 + addCart: function(t) { + var th = this; + var ind = t.currentTarget.dataset.openSpecModal_ind; + var action= t.currentTarget.dataset.action; + if(!ind) ind = t.currentTarget.dataset.openspecmodal_ind; + + th.setData({ + open_ind_store: ind + }); + + if(!th.data.sto_sele_name){ + getApp().my_warnning('请选择门店', 1, th, 450); + return false; + } + + + if(action=="buy"){ + //--------------此时操作的数据------------ + var newd = { + id: th.data.data.id, + goods_num: th.data.goodsInputNum, + pick_id: th.data.sto_sele_id, + keyid: th.data.sto_sele_keyid, + }; + newd['pick_name'] = th.data.sto_sele_name; + newd['guide_id'] = getApp().globalData.guide_id; + newd['guide_type']=0; + th.buyNow(newd); + }else{ + + var newd = { + service_id: th.data.data.id, + service_sn:th.data.data.service_sn, + service_name:th.data.data.goods_name, + goods_num: th.data.goodsInputNum, + pick_id: th.data.sto_sele_id, + user_id:oo.user_id, + store_id:os.stoid, + money:th.data.data.shop_price + }; + if(getApp().globalData.guide_id){ + newd['guide_id'] = getApp().globalData.guide_id; + newd['guide_type']=0; + } + + //----先看会员在购物车中是否加入了该商品----- + getApp().request.get("/api/weshop/cartService/page", { + data: { + store_id: os.stoid, + user_id: oo.user_id, + service_id: th.data.data.id, + pick_id: th.data.sto_sele_id, + }, + success: function(re) { + + //-------如果购物车中有相关的数据--------- + if (re.data.data.total > 0) { + var item = re.data.data.pageData[0]; + var updata = { + id: item.id, + goods_num: th.data.goodsInputNum + item.goods_num, + money: th.data.data.shop_price, + store_id: os.stoid, + }; + + if (getApp().globalData.guide_id) { + updata['guide_id'] = getApp().globalData.guide_id; + updata['guide_type'] = 1; + } + getApp().request.put("/api/weshop/cartService/update", { + data: updata, + success: function(t) { + getApp().my_warnning('加入购物车成功', 1, th, 450); + var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; + th.setData({ + cartGoodsNum: c_num + }); + th.closeSpecModal(); + } + }); + } else { + + getApp().request.post("/api/weshop/cartService/save", { + data: newd, + success: function(t) { + getApp().my_warnning('加入购物车成功', 1, th, 450); + var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; + th.setData({ + cartGoodsNum: c_num + }); + th.closeSpecModal(); + } + }); + } + } + }); + + } + }, + + + }); \ No newline at end of file diff --git a/pages/user/order_list/order_list.wxml b/pages/user/order_list/order_list.wxml index 9bc26c9..f5230d8 100644 --- a/pages/user/order_list/order_list.wxml +++ b/pages/user/order_list/order_list.wxml @@ -1,13 +1,20 @@ + + 线上订单 + 线下订单 - + + + 搜索 + + @@ -15,6 +22,8 @@ + + @@ -30,7 +39,17 @@ 注:读取时段内近10笔记录 + + + + + + {{item.name}} + + + + @@ -260,8 +279,115 @@ + + + + + + + + + 订单编号:{{item.order_sn}} + + + 待支付 + 待评价 + 已评价 + 已取消 + 已作废 + + + + + + + + + + + + + + + + + + {{goods.service_name}} + + + + + + + + + + + + + + + + + + {{filters.toFix(goods.price,2)}} + + + x{{goods.qty}} + + + + + + + + + + 共{{filters.count(item.list)}}件商品 + + + + + 合计(改): + + {{filters.toFix(item.account,2)}} + + + + + + + + + + + + 取消订单 + + + 订单详情 + + + + 评价 + 评价 + + + 立即支付 + + + + + + + + + + - + @@ -295,14 +421,14 @@ - - + + ——— 到底了 ——— - + - + @@ -313,5 +439,6 @@ + diff --git a/pages/user/order_list/order_list.wxss b/pages/user/order_list/order_list.wxss index 0fabe65..8ba96b0 100644 --- a/pages/user/order_list/order_list.wxss +++ b/pages/user/order_list/order_list.wxss @@ -617,5 +617,8 @@ page { border-bottom-left-radius: 8rpx; } +.bg-orange { + background-color: #ff9000; +} -- libgit2 0.21.4