diff --git a/api/order.js b/api/order.js index eaa3b26..eb99775 100644 --- a/api/order.js +++ b/api/order.js @@ -18,11 +18,12 @@ export default { }, buildingList:(community_id,status)=>request.get('/api/order/community_building/count',{community_id,status}), - list:(data)=>request.get('/api/order/deliveryman/list',data,{delayLoading:true}), + list:(data)=>request.get('/api/order/deliveryman/list',data), detail:(orderid)=>request.get(`/api/order/${orderid}`), statusDetail:(community_id)=>request.get('/api/order/status/count',{community_id}), receive:(orderid)=>request.post(`/api/order/${orderid}/deliveryman/receive`), pickup:(orderid)=>request.post(`/api/order/${orderid}/deliveryman/pickup`), - complete:(orderid,images)=>request.post(`/api/order/${orderid}/deliveryman/complete`,{images:images}) + complete:(orderid,images)=>request.post(`/api/order/${orderid}/deliveryman/complete`,{images:images}), + cancel:(orderid,reason)=>request.post(`/api/order/${orderid}/deliveryman/cancel`,{reason}) } \ No newline at end of file diff --git a/api/request.js b/api/request.js index 0c7bdbf..5d31577 100644 --- a/api/request.js +++ b/api/request.js @@ -3,22 +3,16 @@ let app = getApp(); const sendRequest = (options)=>{ if(!app)app = getApp(); - let timer; - if(options.options.delayLoading){ - timer = setTimeout(()=>{ - wx.showLoading({ - title: '加载中...', - }) - },800) + if(options.method!='get'){ + wx.showLoading({ + title: '请等待...', + }) } return new Promise((rs,rj)=>{ wx.request({ url: `${baseUrl}${options.url}`, success:(result)=>{ - if(timer){ - clearTimeout(timer); - wx.hideLoading(); - } + wx.hideLoading(); if(result.statusCode==200){ if(result.data.code==200){ rs(result.data.data); @@ -27,7 +21,7 @@ const sendRequest = (options)=>{ if(!options.options.noTips){ wx.showToast({ icon:'error', - title: result.data.message, + title: result.data.message||'发生错误', }); } rj(result.data); @@ -38,6 +32,12 @@ const sendRequest = (options)=>{ }) }else{ rj(result.data); + if(!options.options.noTips){ + wx.showToast({ + icon:'error', + title: result.data.message||'发生错误', + }); + } } }, @@ -48,6 +48,7 @@ const sendRequest = (options)=>{ "content-type":options.data&&options.data.file?'application/x-www-form-urlencoded':'application/json' }, fail:(res)=>{ + wx.hideLoading(); wx.showToast({ title: 'Request Error', }) diff --git a/api/user.js b/api/user.js index 2daf611..fbedb0e 100644 --- a/api/user.js +++ b/api/user.js @@ -11,7 +11,7 @@ export default { summary:()=>request.get('/api/account/summary'), orderSummary:()=>request.get('/api/order/deliveryman/summary'), incomeList:(data)=>request.get('/api/account/details',data), - getRNAuth:()=>request.get('/api/user/auth',{noTips:true}), + getRNAuth:()=>request.get('/api/user/auth',{},{noTips:true}), setRNAuth:(data)=>request.post('/api/user/auth',data), bankCard:{ diff --git a/app.js b/app.js index a4864ab..5daca23 100644 --- a/app.js +++ b/app.js @@ -6,7 +6,7 @@ App({ verifyCodeWaitingTime:60, onLaunch() { if(!token){ - wx.navigateTo({ + wx.reLaunch({ url: '/pages/login/index', }) } @@ -16,6 +16,9 @@ App({ } }) }, + resetUserInfoUpdateTag(){ + this.globalData.userInfoGetTime = null; + }, forceGetUserInfo(){ this.globalData.userInfoGetTime = null; return this.getUserInfo(); @@ -53,16 +56,25 @@ App({ for(var key in rules){ ((rules[key] instanceof Array)?rules[key]:[rules[key]]).map((item)=>{ let valid = true; + let value = page.data[key].trim(); //非空 if(item.required){ - if(page.data[key].trim()==''){ + if(value==''){ valid = false; } }else if(item.length){ //绝对长度 - if(page.data[key].trim().length!=item.length){ + if(value.length!=item.length){ valid = false; } + }else if(item.type=='phone'){ + if(value.length!=11){ + valid = false; + } + }else if(item.maxLength||item.minLength){ + if(value.length>(item.maxLength||Infinity)||value.lengthitem.autoFocus); + if(focusInput){ + page.setData({ + [`${focusInput.key}Focus`]:true + }) } - return true; + const shakeInput = result.find((item)=>item.shake); + if(shakeInput){ + if(!shakeInput.animation){ + shakeInput.animation = wx.createAnimation({ + duration: 20, + }) + } + shakeInput.animation.translateX(10).step(); + shakeInput.animation.translateX(-10).step(); + shakeInput.animation.translateX(10).step(); + shakeInput.animation.translateX(-10).step(); + shakeInput.animation.translateX(5).step(); + shakeInput.animation.translateX(0).step(); + // needSetData[`${key}Animation`] = item.animation.export(); + page.setData({ + [`${shakeInput.key}Animation`]:shakeInput.animation.export() + }) + } + return result; }, globalData: { userInfo: null, diff --git a/app.wxss b/app.wxss index e505b22..c60315b 100644 --- a/app.wxss +++ b/app.wxss @@ -9,6 +9,9 @@ page{ background-color:var(--main-bgclolor); overflow: hidden; } +.main-color{ + color:var(--main-color); +} button{ border-radius: 12rpx; diff --git a/components/listView/index.wxml b/components/listView/index.wxml index 3b044a7..4fe856a 100644 --- a/components/listView/index.wxml +++ b/components/listView/index.wxml @@ -1,4 +1,4 @@ - + diff --git a/pages/index/index.js b/pages/index/index.js index 1a469a5..c7cef68 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -46,14 +46,16 @@ Page({ deliverStatusKV:orderApi.deliverStatusKV, - genderKV:userApi.genderKV + genderKV:userApi.genderKV, + + completing:false }, onLoad(){ const windowInfo = wx.getWindowInfo(); this.setData({ statusBarHeight:windowInfo.statusBarHeight, - scrollViewHeight:windowInfo.windowHeight-windowInfo.statusBarHeight-44 - 125 + scrollViewHeight:windowInfo.windowHeight-windowInfo.statusBarHeight-44 - 91 }); this.getUserInfo().then(()=>{ @@ -117,6 +119,9 @@ Page({ }, async loadStatusDetail(){ const data = await orderApi.statusDetail(this.data.userInfo.community_id); + this.data.statusDetail.created.value = 0; + this.data.statusDetail.received.value = 0; + this.data.statusDetail.delivering.value = 0; this.data.statusDetail.completed.value = 0; data.map((item)=>{ if(item.status==this.data.orderStatus.unpaid||item.status==this.data.orderStatus.completed){ @@ -132,6 +137,7 @@ Page({ statusDetail:this.data.statusDetail }) }, + //加载楼栋 async loadBuilding(){ const cid = this.data.userInfo.community_id; const status = this.data.statusDetail[this.data.statusDetailKey]; @@ -139,7 +145,12 @@ Page({ if(status.key==this.data.orderStatus.completed){ _status = `${this.data.orderStatus.unpaid},${this.data.orderStatus.completed}`; } - const data = await orderApi.buildingList(cid,_status); + let data = await orderApi.buildingList(cid,_status); + let totalCount = 0; + (data||[]).map((item)=>{ + totalCount+=item.order_count; + }) + data = [{building_name:'全部',order_count:totalCount}].concat(data); this.setData({ buildingList:data }); @@ -152,10 +163,13 @@ Page({ "pager.loading":true }); let params = { - building_id:this.data.buildingList[this.data.buildingIndex].building_id, skip:this.data.pager.pageIndex*this.data.pager.limit, limit:this.data.pager.limit, } + const buildingId = this.data.buildingList[this.data.buildingIndex].building_id; + if(buildingId){ + params.building_id = buildingId; + } if(this.data.statusDetailKey=='completed'){ params.status = `${this.data.orderStatus.unpaid},${this.data.orderStatus.completed}` }else{ @@ -191,6 +205,7 @@ Page({ openLeftPanel(){ + this.getUserInfo(); this.setData({ isShowLeftPanel:true, }); @@ -212,7 +227,10 @@ Page({ }) },400) }, - refund(){ + refund(event){ + const item = event.currentTarget.dataset.item; + const index = event.currentTarget.dataset.index; + if(item.receiving)return; wx.showModal({ title: '取消订单需联系客户说明原因', content: '', @@ -220,7 +238,16 @@ Page({ editable:true, complete: (res) => { if (res.confirm) { - + this.setData({ + [`list[${index}].receiving`]:true + }) + orderApi.cancel(item.orderid,res.content).then((data)=>{ + wx.showToast({ + title: '取消成功', + icon:'success' + }); + this.refreshList(); + }) } } }) @@ -248,7 +275,11 @@ Page({ //接单 getOrder(event){ const item = event.currentTarget.dataset.item; - + const index = event.currentTarget.dataset.index; + if(item.receiving)return; + this.setData({ + [`list[${index}].receiving`]:true + }) orderApi.receive(item.orderid).then((data)=>{ wx.showToast({ icon:'success', @@ -277,7 +308,6 @@ Page({ }, //完成配送 uploadAndConfirmSend(){ - console.log(this.currentOrder); if(this.data.tempImgs.length==0){ wx.showToast({ icon:'error', @@ -285,6 +315,9 @@ Page({ }) return; } + this.setData({ + completing:true + }) this.uploadImages().then(()=>{ let urls = []; this.data.tempImgs.map((item)=>{ @@ -292,7 +325,9 @@ Page({ }) orderApi.complete(this.currentOrder.orderid,urls).then((data)=>{ this.setData({ - isShowConfirm:false + isShowConfirm:false, + completing:false, + tempImgs:[] }) this.refreshList(); wx.showToast({ @@ -300,6 +335,10 @@ Page({ title: '订单已完成', }) }) + }).catch(()=>{ + this.setData({ + completing:false + }) }); }, async uploadImages(){ @@ -353,5 +392,6 @@ Page({ }) } }) - } + }, + emptyFun(){} }) diff --git a/pages/index/index.wxml b/pages/index/index.wxml index f531644..6b04a6d 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -53,12 +53,18 @@ - - + + - - + +