From 6169b90c0d50d1ace56255e19ee4d9b706849aa2 Mon Sep 17 00:00:00 2001 From: szdot Date: Thu, 6 Jun 2024 01:44:07 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=B1=BB=09=E5=9E=8B=E3=80=91?= =?UTF-8?q?=EF=BC=9Afeat=20=E3=80=90=E4=B8=BB=09=E9=A2=98=E3=80=91?= =?UTF-8?q?=EF=BC=9A=E8=AE=A2=E5=8D=95=E7=9B=B8=E5=85=B3=20=E3=80=90?= =?UTF-8?q?=E6=8F=8F=09=E8=BF=B0=E3=80=91=EF=BC=9A=20=09[=E5=8E=9F?= =?UTF-8?q?=E5=9B=A0]=EF=BC=9A=20=09[=E8=BF=87=E7=A8=8B]=EF=BC=9A=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E9=A1=B5=E9=9D=A2=20=20vux=E8=AE=A2=E5=8D=95=E5=80=BC?= =?UTF-8?q?,=E8=AE=BE=E7=BD=AE=E5=80=BC=E6=96=B9=E6=B3=95=20,=E5=BC=82?= =?UTF-8?q?=E6=AD=A5=E6=8E=A5=E5=8F=A3=E8=8E=B7=E5=8F=96=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=88=97=E8=A1=A8=20=09[=E5=BD=B1=E5=93=8D]=EF=BC=9A=20?= =?UTF-8?q?=E3=80=90=E7=BB=93=09=E6=9D=9F=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动 --- pages/index/index.vue | 10 ++++++---- pages/main/order.vue | 37 +++++++++++++++++++++++++++++++++++-- store/index.js | 39 +++++++++++++++++++++++++++++++-------- utils/index.js | 4 ++-- 4 files changed, 74 insertions(+), 16 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index 238594a..c0d26b5 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -13,10 +13,12 @@ - - - 订单 - + + + + 订单 + + diff --git a/pages/main/order.vue b/pages/main/order.vue index b086607..5ad2fc3 100644 --- a/pages/main/order.vue +++ b/pages/main/order.vue @@ -6,6 +6,25 @@ + + + + + + + 订单号: {{item.order_sn}} + + + + + 订单号: {{item.order_sn}} + + + + + 订单号: {{item.order_sn}} + + @@ -13,11 +32,25 @@ export default { data() { return { - + list: ['未付款', '已付款', '申请售后'], + curNow: 0 + } + }, + computed: { + orderList() { + return this.$store.state.orderList } }, methods: { - + sectionChange(index) { + this.curNow = index; + } + }, + onLoad() { + this.$store.dispatch('fetchOrderList') + setTimeout(()=> { + console.log(this.orderList) + }, 2000); } } diff --git a/store/index.js b/store/index.js index e13d27e..809f0d0 100644 --- a/store/index.js +++ b/store/index.js @@ -30,6 +30,7 @@ const store = new Vuex.Store({ topic_prefix: null }, //用户信息 + orderList: [], //订单列表 siteList: [], //站点列表 menuList: [], //分类列表 spuList: [], //spu列表 @@ -44,16 +45,16 @@ const store = new Vuex.Store({ //修改状态 mutations: { //设置 列表页 购物车折叠显隐 - setCartShow(state,val){ - Vue.set(state,'cartShow', val) + setCartShow(state, val) { + Vue.set(state, 'cartShow', val) }, //设置 标记用户登录状态 - setMqttState(state,val){ - Vue.set(state,'mqttState', val) + setMqttState(state, val) { + Vue.set(state, 'mqttState', val) }, //设置tabbar当前激活像 - setTabbarCurrent(state,val){ - Vue.set(state,'tabbarCurrent', val) + setTabbarCurrent(state, val) { + Vue.set(state, 'tabbarCurrent', val) }, //把用户信息 从本地缓存 提取到内存当中 setUserInfo(state, obj) { @@ -73,6 +74,10 @@ const store = new Vuex.Store({ Vue.set(state.userInfo, 'token', null) Vue.set(state.userInfo, 'topic_prefix', null) }, + //设置订单列表 + setOrderList(state, list) { + state.orderList = list + }, //设置站点列表 setSiteList(state, list) { state.siteList = list @@ -94,8 +99,8 @@ const store = new Vuex.Store({ state.shopCon = obj }, //清空购物车 - clearCartList(state){ - Vue.set(state,'cartList', []) + clearCartList(state) { + Vue.set(state, 'cartList', []) }, // 设置购物车列表 setCartList(state, obj) { @@ -150,6 +155,24 @@ const store = new Vuex.Store({ }, //异步修改 actions: { + //获取订单列表 + fetchOrderList({ + state, + commit + }) { + uni.$u.http.get('/Api/Check/getOrderList', { + header:{ + 'Token': state.userInfo.token, + } + }).then(res => { + if (res.data.status === 1) { + //更新数据 + commit('setOrderList', res.data.orderList) + } else { + commit('setSiteList', []) + } + }) + }, //获取站点列表 fetchSiteList({ state, diff --git a/utils/index.js b/utils/index.js index 8427993..e6b9d3a 100644 --- a/utils/index.js +++ b/utils/index.js @@ -135,7 +135,7 @@ export function totalPrice(cartList) { * 检查用户信息登录 信息 */ export function checkUserInfo() { - //检查是否已经标记登录了 + //刚打开app token未赋值到内存时 if (store.state.userInfo.token === null) { //先从storage里调取token uni.getStorage({ @@ -165,7 +165,7 @@ export function checkUserInfo() { wxLogin() } }) - } else { + } else { //内存中已经赋值了token时 //验证token isTokenValid().then((isValid) => { if (isValid.data.status === -1) { //token验证失败或过期