Explorar o código

普通用户订单修改,优惠券领取后的数据回显

喻文俊 %!s(int64=3) %!d(string=hai) anos
pai
achega
37763c8efc

+ 17 - 10
mixins/shareEntry.js

@@ -19,16 +19,23 @@ const shareEntry = {
         ...mapMutations('user', ['setInviteUserId']),
         // 处理分享参数
         shareHandle(option) {
-            const state_str = decodeURIComponent(option.state_str)
+            let state_str = option.state_str
             if (!state_str) return
-            // 解密参数
-            this.shareData = {
-                ...this.shareData,
-                ...JSON.parse(this.$crypto.decrypt(state_str))
+            state_str = decodeURIComponent(state_str)
+            try {
+                const decrypt = this.$crypto.decrypt(state_str)
+                // 解密参数
+                this.shareData = {
+                    ...this.shareData,
+                    ...JSON.parse(decrypt)
+                }
+                // 保存分享者的用户id
+                this.setInviteUserId(this.shareData.inviteUserId)
+                this.jumpTopSharePage()
+            } catch (e) {
+                console.log(e)
+                return
             }
-            // 保存分享者的用户id
-            this.setInviteUserId(this.shareData.inviteUserId)
-            this.jumpTopSharePage()
         },
         // 跳转到对应的分享页面
         jumpTopSharePage() {
@@ -39,10 +46,10 @@ const shareEntry = {
                 2: `/pages/goods/search?type=share&keyWord=${this.shareData.keyWord}`, // 搜索页面
                 3: `/pages/user/activity/activity?type=share&activityId=${this.shareData.activityId}&userId=${this.shareData.userId}` //活动商品列表
             }
-            // 200 ms后跳转
+            // 1000 ms后跳转
             setTimeout(() => {
                 this.$api.navigateTo(path[this.shareData.type])
-            }, 200)
+            }, 1000)
         }
     }
 }

+ 1 - 0
pages/goods/product-detail.vue

@@ -178,6 +178,7 @@ export default {
         }
         // 加密
         const state_str = encodeURIComponent(this.$crypto.encrypt(shareData))
+        console.log(state_str)
         return {
             title: this.productInfo.name,
             path: `pages/tabBar/index/index?state_str=${state_str}`,

+ 10 - 12
pages/tabBar/user/index.vue

@@ -64,7 +64,8 @@
                 <view class="place-menu-cell" @click="navigator('/pages/user/activity/coupon-list')">
                     <view class="place-left">
                         <image class="place-menu-icon" :src="StaticUrl + 'icon-coupon.png'" mode=""></image>
-                        <text class="place-menu-title">优惠券</text> <text class="coupons-count" v-if="unusedNum > 0">{{ unusedNum }}</text>
+                        <text class="place-menu-title">优惠券</text>
+                        <text class="coupons-count" v-if="unusedNum > 0">{{ unusedNum }}</text>
                     </view>
                     <text class="iconfont icon-chakangengduo"></text>
                 </view>
@@ -96,7 +97,7 @@
             </view>
             <!-- 菜单导航区域END -->
             <!-- 底部 -->
-            <view class="user-support" :class="userIdentity == 2 ? 'top' : ''">
+            <view class="user-support">
                 <image class="user-support-image" :src="StaticUrl + 'icon-logo@1x.png'" mode=""></image>
                 <view class="user-support-text">采美365网提供商品技术服务</view>
             </view>
@@ -166,15 +167,12 @@ export default {
             console.log(e.detail.query)
         },
         OrderNavigator(state) {
+            if (!this.hasLogin) return this.$api.navigateTo('/pages/login/login')
             // 栏目跳转
-            if (this.hasLogin) {
-                if (this.userIdentity == 2) {
-                    this.$api.navigateTo(`/pages/user/order/order-list-retail?state=${state}`)
-                } else {
-                    this.$api.navigateTo(`/pages/user/order/order-list?state=${state}`)
-                }
+            if (this.userIdentity == 2) {
+                this.$api.navigateTo(`/pages/user/order/order-list-retail?state=${state}`)
             } else {
-                this.$api.navigateTo('/pages/login/login')
+                this.$api.navigateTo(`/pages/user/order/order-list?state=${state}`)
             }
         },
         navigator(url) {
@@ -382,15 +380,15 @@ export default {
     }
 }
 .user-support {
+    position: fixed;
+    bottom: 30rpx;
     width: 100%;
     float: left;
     display: flex;
     flex-direction: column;
     align-items: center;
     justify-content: center;
-    &.top {
-        margin-top: 100rpx;
-    }
+
     .user-support-image {
         width: 54rpx;
         height: 46rpx;

+ 44 - 33
pages/user/activity/coupon-list.vue

@@ -71,38 +71,7 @@ export default {
             currentTab: 0,
             pageSize: 6,
             timer: null,
-            couponData: {
-                // 已领取/未使用
-                0: {
-                    type: 'received',
-                    pageNum: 1,
-                    status: 1,
-                    hasNextPage: false,
-                    couponList: [],
-                    showStatus: false,
-                    total: 0
-                },
-                // 已使用
-                1: {
-                    type: 'used',
-                    pageNum: 1,
-                    status: 2,
-                    hasNextPage: false,
-                    couponList: [],
-                    showStatus: true,
-                    total: 0
-                },
-                // 已过期
-                2: {
-                    type: 'expired',
-                    pageNum: 1,
-                    status: 3,
-                    hasNextPage: false,
-                    couponList: [],
-                    showStatus: true,
-                    total: 0
-                }
-            }
+            couponData: null
         }
     },
     computed: {
@@ -116,9 +85,11 @@ export default {
         },
         // 当前选中tab对应的优惠券列表信息
         queryInfo() {
+            if (!this.couponData) return
             return this.couponData[this.currentTab]
         },
         loadingText() {
+            if (!this.couponData) return '没有更多了'
             return this.queryInfo.hasNextPage ? '上拉加载更多' : '没有更多了'
         },
         // tabs列表
@@ -137,9 +108,14 @@ export default {
         }
     },
     onLoad() {
+        this.couponData = this.resetCouponData()
         this.getWindowHeight()
         this.initCouponList()
     },
+    onShow() {
+        this.couponData = this.resetCouponData()
+        this.initCouponList()
+    },
     methods: {
         // tab文字提示
         makeTabText(number, text) {
@@ -206,7 +182,42 @@ export default {
                 this.fetchCouponList()
             }, 200)
         },
-        couponClick(){}
+        couponClick() {},
+        // 初始化优惠券分类查询信息
+        resetCouponData() {
+            return {
+                // 已领取/未使用
+                0: {
+                    type: 'received',
+                    pageNum: 1,
+                    status: 1,
+                    hasNextPage: false,
+                    couponList: [],
+                    showStatus: false,
+                    total: 0
+                },
+                // 已使用
+                1: {
+                    type: 'used',
+                    pageNum: 1,
+                    status: 2,
+                    hasNextPage: false,
+                    couponList: [],
+                    showStatus: true,
+                    total: 0
+                },
+                // 已过期
+                2: {
+                    type: 'expired',
+                    pageNum: 1,
+                    status: 3,
+                    hasNextPage: false,
+                    couponList: [],
+                    showStatus: true,
+                    total: 0
+                }
+            }
+        }
     }
 }
 </script>

+ 38 - 39
pages/user/order/order-list.vue

@@ -183,13 +183,13 @@
 </template>
 
 <script>
-import authorize from '@/common/authorize.js'
 import HeaderOrder from '@/components/cm-module/headerNavbar/header-order' //自定义导航
 import orderButton from '@/components/cm-module/orderDetails/orderListButton' //按钮
 import modalLayer from '@/components/cm-module/modal-layer/modal-layer'
 import empty from '@/components/cm-module/empty/empty'
 import CmLoading from '@/components/cm-module/cm-loading/cm-loading.vue'
 import wechatPay from '@/mixins/wechatPay.js'
+import { mapGetters } from 'vuex'
 export default {
     components: {
         HeaderOrder,
@@ -221,7 +221,6 @@ export default {
             winHeight: '', //窗口高度
             currentTab: 0, //预设当前项的值
             scrollLeft: 0, //tab标题的滚动条位置
-            userId: 0,
             orderData: [],
             btnoRderID: 0, //点击按钮传入的的订单ID
             pageNum: 1, //页数
@@ -253,9 +252,12 @@ export default {
                     type: 'danger'
                 }
             ],
-            invalidList: [],
+            invalidList: []
         }
     },
+    computed: {
+        ...mapGetters(['userId'])
+    },
     onLoad(e) {
         let self = this
         if (e.type === 'detele') {
@@ -349,44 +351,41 @@ export default {
                 return
             }
             setTimeout(() => {
-                this.$api.getStorage().then(resolve => {
-                    this.userId = resolve.userId
-                    this.OrderService.QueryOrderList({
-                        orderState: index,
-                        userId: resolve.userId,
-                        pageNum: 1,
-                        pageSize: this.pageSize
-                    })
-                        .then(response => {
-                            let data = response.data
-                            //loaded新字段用于表示数据加载完毕,如果为空可以显示空白页
-                            let orderList = data.list.filter(item => {
-                                //添加不同状态下订单的表现形式
-                                item = Object.assign(item, this.StateExpFormat(item.state))
-                                return item
-                            })
-                            orderItem.orderList = []
-                            orderList.forEach(item => {
-                                orderItem.orderList.push(item)
-                            })
-                            this.$set(orderItem, 'loaded', true)
-                            this.hasNextPage = data.hasNextPage
-                            if (this.hasNextPage) {
-                                this.pullUpOn = false
-                                this.nomoreText = '上拉显示更多'
-                            } else {
-                                if (orderItem.orderList.length < 2) {
-                                    this.pullUpOn = true
-                                } else {
-                                    this.pullUpOn = false
-                                    this.nomoreText = '已至底部'
-                                }
-                            }
+                this.OrderService.QueryOrderList({
+                    orderState: index,
+                    userId: this.userId,
+                    pageNum: 1,
+                    pageSize: this.pageSize
+                })
+                    .then(response => {
+                        let data = response.data
+                        //loaded新字段用于表示数据加载完毕,如果为空可以显示空白页
+                        let orderList = data.list.filter(item => {
+                            //添加不同状态下订单的表现形式
+                            item = Object.assign(item, this.StateExpFormat(item.state))
+                            return item
                         })
-                        .catch(error => {
-                            this.$util.msg(error.msg, 2000)
+                        orderItem.orderList = []
+                        orderList.forEach(item => {
+                            orderItem.orderList.push(item)
                         })
-                })
+                        this.$set(orderItem, 'loaded', true)
+                        this.hasNextPage = data.hasNextPage
+                        if (this.hasNextPage) {
+                            this.pullUpOn = false
+                            this.nomoreText = '上拉显示更多'
+                        } else {
+                            if (orderItem.orderList.length < 2) {
+                                this.pullUpOn = true
+                            } else {
+                                this.pullUpOn = false
+                                this.nomoreText = '已至底部'
+                            }
+                        }
+                    })
+                    .catch(error => {
+                        this.$util.msg(error.msg, 2000)
+                    })
             }, 600)
         },
         getOnReachBottomData(index) {