diff --git a/api/user.js b/api/user.js index 84160c2..2934823 100644 --- a/api/user.js +++ b/api/user.js @@ -6,7 +6,7 @@ const api = { assets: 'user/assets', bindMobile: 'user/bindMobile', personal: 'user/personal', -todoCounts: "order/todoCounts" + todoCounts: "order/todoCounts" } // 当前登录的用户信息 @@ -19,6 +19,11 @@ export const info = (param, option) => { return request.get(api.userInfo, param, options) } +// 订单数量 +export const actionCounts = (param, option) => { + return request.post('order/actionCounts', param, option) +} + // 订单数量 export const todoCounts = (param, option) => { return request.post(api.todoCounts, param, option) diff --git a/pages/user/index.vue b/pages/user/index.vue index db13cbf..36252cb 100644 --- a/pages/user/index.vue +++ b/pages/user/index.vue @@ -23,7 +23,7 @@ - + 消息 @@ -125,7 +125,7 @@ - 235 + {{actionCountsInfo.cart_number}} 购物车 @@ -133,7 +133,7 @@ - 2 + {{actionCountsInfo.view_number}} 浏览记录 @@ -141,7 +141,7 @@ - 235 + {{actionCountsInfo.reservation_number}} 预约记录 @@ -149,7 +149,7 @@ - 2 + {{actionCountsInfo.view_number}} 优惠券 @@ -167,28 +167,28 @@ - 2 + {{orderTodoInfo.goods_order.payment_number>=100?"99+":orderTodoInfo.goods_order.payment_number}} 待付款 - 2 + {{orderTodoInfo.goods_order.delivery_number>=100?"99+":orderTodoInfo.goods_order.delivery_number}} 待发货 - 2 + {{orderTodoInfo.goods_order.received_number>=100?"99+":orderTodoInfo.goods_order.received_number}} 待收货 - 2 + {{orderTodoInfo.goods_order.finish_number>=100?"99+":orderTodoInfo.goods_order.finish_number}} 已完成 @@ -204,28 +204,28 @@ - 2 + {{orderTodoInfo.service_order.confirm_number}} 待确认 - 2 + {{orderTodoInfo.service_order.service_number}} 待服务 - 2 + {{orderTodoInfo.service_order.payment_number}} 待支付 - 2 + {{orderTodoInfo.service_order.check_number}} 已完成 @@ -241,35 +241,35 @@ - 2 + {{orderTodoInfo.distribution_order.payment_number}} 待付款 - 2 + {{orderTodoInfo.distribution_order.delivery_number}} 待发货 - 2 + {{orderTodoInfo.distribution_order.received_number}} 待收货 - 2 + {{orderTodoInfo.distribution_order.finish_number}} 已完成 - 2 + {{orderTodoInfo.distribution_order.retund_number}} 退款中 @@ -501,6 +501,12 @@ background: 'url(https://www.royaum.com.cn/static/news/login-bg.png) center top no-repeat', backgroundSize: '100% auto', }, + orderTodoInfo: { + distribution_order: {}, + goods_order: {}, + service_order: {}, + }, + actionCountsInfo: {}, userType: 2, memberCode: false, isLogin: false, @@ -550,6 +556,7 @@ .then(result => { that.userInfo = result.data.userInfo that.getOrderInfo(); + that.getActionCountsInfo(); uni.setStorageSync('userInfo', that.userInfo) resolve(that.userInfo) }) @@ -563,6 +570,7 @@ }) }) }, + // 获取当前订单数量 getOrderInfo() { const that = this @@ -571,8 +579,29 @@ load: that.isFirstload }) .then(result => { - console.log(result.data) - resolve(that.userInfo) + that.orderTodoInfo = result.data + resolve(that.orderTodoInfo) + }) + .catch(err => { + if (err.result && err.result.status == 401) { + that.isLogin = false + resolve(null) + } else { + reject(err) + } + }) + }) + }, + // 获取当前用户行为 + getActionCountsInfo() { + const that = this + return new Promise((resolve, reject) => { + !that.isLogin ? resolve(null) : UserApi.actionCounts({}, { + load: that.isFirstload + }) + .then(result => { + that.actionCountsInfo = result.data + resolve(that.actionCountsInfo) }) .catch(err => { if (err.result && err.result.status == 401) { @@ -584,7 +613,6 @@ }) }) }, - toFuwu(type) { if (!uni.getStorageSync('AccessToken')) { uni.navigateTo({