喻文俊 пре 3 година
родитељ
комит
f84f5b822c

+ 59 - 33
common/couponUtil.js

@@ -1,55 +1,81 @@
 import { isIntersect } from '@/common/util.js'
-// 优惠商品统计价格
-export let countPrice = 0
 
 // 获取选中商品
 export function fetchSelectedProducts(goodsList) {
     const productList = []
-    goodsList.forEach(shop => {
-        shop.productList.forEach(prod => {
-            if (prod.productsChecked) {
-                productList.push(prod)
-            }
-        })
-    })
-    console.log(productList)
+    goodsList.forEach(shop => productList.push(...shop.productList.filter(prod => prod.productsChecked)))
     return productList
 }
 
 // 根据选中商品筛选可用优惠券并排序
 export function findCouponBySelected(ids, couponList) {
-    return couponList.filter(coupon => coupon.productType === 1 || isIntersect(ids, coupon.productIds.split(',')))
-        .sort((a, b) => b.couponAmount - a.couponAmount)
+    const list = couponList.filter(coupon => coupon.productType === 1 || isIntersect(ids, coupon.productIds.split(',')))
+    return couponSort(list)
 }
 
+/**
+ * 优惠券是否可用
+ * 1 无门槛
+ * 2 有门槛
+ *      1 全部商品可用
+ *          全部商品价格总计 >= 当前优惠券的触发金额
+ *      2 指定商品可用
+ *          当前优惠券可用的商品的价格总计 >= 当前优惠券的触发金额
+ * */
+
 // 判断可用优惠券是否满足使用条件
 export function canUseCoupon(current, productIds, canUseCouponList, selectedPoducts) {
     if (productIds.length <= 0) return -1
     const len = canUseCouponList.length
     if (current >= len) return len
     const currentCoupon = canUseCouponList[current]
-    // 无门槛
-    if (currentCoupon.noThresholdFlag === 1) return current
-    // 是否满足条件
-    if (currentCoupon.noThresholdFlag === 0) {
-        countPrice = selectedPoducts.reduce((countPrice, prod) => {
-            // 全部商品可用
-            if (currentCoupon.productType === 1) {
-                countPrice += prod.price * prod.productCount
-            } else {
-                // 部分商品可用
-                const couponProductIds = currentCoupon.productIds.split(',')
-                if (couponProductIds.includes(prod.productId.toString())) {
-                    countPrice += prod.price * prod.productCount
-                }
-            }
-            return countPrice
-        }, 0)
-        if (countPrice >= currentCoupon.touchPrice) return current
+    if (
+        currentCoupon.noThresholdFlag === 1 ||
+        (currentCoupon.productType === 1 && allProdoceUseCheck(selectedPoducts, currentCoupon)) ||
+        (currentCoupon.productType === 2 && someProductUseCheck(selectedPoducts, currentCoupon))
+    ) {
+        return current
+    } else {
+        return canUseCoupon(++current, productIds, canUseCouponList, selectedPoducts)
     }
-    return canUseCoupon(++current, productIds, canUseCouponList, selectedPoducts)
 }
 
-export function getCountPrice(){
+// 判断全部商品可用 (全部商品价格总计 是否大于 当前优惠券的触发金额)
+export function allProdoceUseCheck(productList, coupon) {
+    const countPrice = productList.reduce((countPrice, prod) => countPrice + prod.price * prod.productCount, 0)
+    return countPrice >= coupon.touchPrice
+}
+
+// 判断指定商品可用 (当前优惠券可用的商品的价格总计 是否大于 当前优惠券的触发金额)
+export function someProductUseCheck(productList, coupon) {
+    const countPrice = productList.reduce((countPrice, prod) => {
+        // 当前优惠券可用的商品总价
+        const isIncludes = coupon.productIds.indexOf(prod.productId.toString()) > -1
+        return isIncludes ? countPrice + prod.price * prod.productCount : countPrice
+    }, 0)
+    return countPrice >= coupon.touchPrice
+}
+
+// 统计当前优惠券商品可用的价格
+export function getCountPrice(productList, coupon) {
+    let countPrice = 0
+    // 针对全部商品
+    if (coupon.productType === 1) {
+        countPrice = productList.reduce((countPrice, prod) => countPrice + prod.price * prod.productCount, 0)
+    }
+    // 只针对优惠券可用商品
+    if (coupon.productType === 2) {
+        countPrice = productList.reduce((countPrice, prod) => {
+            // 当前优惠券可用的商品总价
+            const isIncludes = coupon.productIds.indexOf(prod.productId.toString()) > -1
+            return isIncludes ? countPrice + prod.price * prod.productCount : countPrice
+        }, 0)
+    }
     return countPrice
-}
+}
+
+
+// 将优惠券按金额从大到小排序
+export function couponSort(couponList) {
+    return couponList.sort((a, b) => b.couponAmount - a.couponAmount)
+}

+ 2 - 2
components/cm-module/cm-coupon/cm-coupon.vue

@@ -1,5 +1,5 @@
 <template>
-    <view class="coupon" :class="canUse ? 'on' : 'off'" v-if="couponData">
+    <view class="coupon" :class="canUse ? 'on' : 'off'" v-if="couponData" @click="choose">
         <view class="content" :class="[statusIcon, { 'cover-bg': showStatus }]">
             <view class="header">
                 <!-- 优惠券类别 -->
@@ -44,7 +44,6 @@
                     class="radio-flag iconfont "
                     :class="currentId === couponData.couponId ? 'icon-xuanze' : 'icon-weixuanze'"
                     v-if="couponData.canSelect"
-                    @click="choose"
                 ></text>
             </template>
         </view>
@@ -128,6 +127,7 @@ export default {
         ...mapActions('coupon', ['receiveCoupon']),
         // 点击勾选按钮
         choose() {
+            if(!this.chooseAble) return
             this.$emit('choose', this.couponData)
         },
         // 按钮点击

+ 29 - 0
components/cm-module/cm-loading/cm-loading.vue

@@ -0,0 +1,29 @@
+<template>
+    <view class="cm-loading" v-if="visible"> <tui-loading :text="text"></tui-loading> </view>
+</template>
+
+<script>
+export default {
+    props: {
+        text: {
+            type: String,
+            default: '正在加载...'
+        },
+        visible: {
+            type: Boolean,
+            default: false
+        }
+    }
+}
+</script>
+
+<style lang="scss" scoped>
+.cm-loading {
+    position: fixed;
+    left: 0;
+    top: 0;
+    z-index: 999;
+    width: 100%;
+    height: 100%;
+}
+</style>

+ 80 - 0
mixins/wechatPay.js

@@ -0,0 +1,80 @@
+import authorize from '@/common/authorize.js'
+
+// 调用微信支付
+function wxRequestPayment(payment) {
+    return new Promise((resolve, reject) => {
+        uni.requestPayment({
+            timeStamp: payment.timeStamp,
+            nonceStr: payment.nonceStr,
+            package: payment.package,
+            signType: payment.signType,
+            paySign: payment.paySign,
+            success: () => {
+                resolve(true)
+            },
+            fail: () => {
+                reject({ msg: 'error' })
+            }
+        })
+    })
+}
+
+// 微信支付
+const wechatPay = {
+    data() {
+        return {
+            loadingText: '请稍等...',
+            isSubLoading: false,
+        }
+    },
+    methods: {
+        // 验证微信支付是否可用
+        miniWxPayFor(data) {
+            this.isSubLoading = true
+            this.PayService.PayOrderOnLineSwitch().then(response => {
+                if (response.data === 1) {
+                    this.weChatMiniWxPay(data)
+                } else {
+                    this.isSubLoading = false
+                    this.$api.navigateTo(`/pages/user/order/order-payment?money=${data.payableAmount}`)
+                }
+            })
+        },
+        // 获取微信支付payment
+        async weChatMiniWxPay(data) {
+            if (this.loadingText) this.loadingText = '等待支付中'
+            try {
+                // 获取微信code
+                const wechatCode = await authorize.getCode('weixin')
+                // 微信支付请求 返回支付信息
+                const response = await this.PayService.WeChatMiniWxPay({
+                    payAmount: data.payableAmount * 100,
+                    payWay: 'WEIXIN',
+                    code: wechatCode,
+                    orderId: data.orderId
+                })
+                // 处理支付信息 调用微信支付
+                const payment = JSON.parse(response.data.data.payInfo)
+                const payFlag = await wxRequestPayment(payment)
+                // 支付重定向
+                uni.reLaunch({ url: '/pages/tabBar/index/index' })
+
+            } catch (error) {
+                // 微信支付失败
+                if (error.msg === 'error') this.payFaildRedirect()
+                else this.$util.msg(error.msg, 2000)
+            } finally {
+                this.isSubLoading = false
+            }
+        },
+        // 支付信息提示页面重定向
+        payFaildRedirect() {
+            setTimeout(() => {
+                const redirectData = JSON.stringify({ orderInfo: this.hanldOrder.order })
+                this.$api.redirectTo(`/pages/user/order/success?data=${redirectData}`)
+            }, 2000)
+        }
+    },
+}
+
+export default wechatPay

+ 5 - 4
pages/goods/cart.vue

@@ -135,7 +135,7 @@ import CmDrawer from '@/components/cm-module/cm-drawer/cm-drawer.vue'
 import CmCartProduct from '@/components/cm-module/cm-cart-product/cm-cart-product.vue'
 import HeaderCart from '@/components/cm-module/headerNavbar/header-cart.vue'
 import CmEmpty from '@/components/cm-module/cm-empty/cm-empty.vue'
-import { fetchSelectedProducts, findCouponBySelected, canUseCoupon, getCountPrice } from '@/common/couponUtil.js'
+import { fetchSelectedProducts, findCouponBySelected, canUseCoupon, getCountPrice, couponSort } from '@/common/couponUtil.js'
 
 import { mapGetters, mapActions, mapMutations } from 'vuex'
 
@@ -261,15 +261,16 @@ export default {
                 }
                 return `已享“满${this.currentCoupon.touchPrice}元减${this.currentCoupon.couponAmount}元”优惠券`
             }
-            return `还差¥${this.nextCoupon.touchPrice - getCountPrice()}元可用“满${this.nextCoupon.touchPrice}元减${
+            return `还差¥${this.nextCoupon.touchPrice - getCountPrice(this.selectedPoducts, this.nextCoupon)}元可用“满${this.nextCoupon.touchPrice}元减${
                 this.nextCoupon.couponAmount
             }元”优惠券`
         },
         couponList() {
             if (this.currentTabIndex === 0) {
-                return this.receiveCouponList
+                return couponSort(this.receiveCouponList)
+
             } else {
-                return this.ableCouponList
+                return couponSort(this.ableCouponList)
             }
         },
         couponListTabs() {

+ 4 - 4
pages/tabBar/cart/index.vue

@@ -128,7 +128,7 @@ import CmDrawer from '@/components/cm-module/cm-drawer/cm-drawer.vue'
 import CmCartProduct from '@/components/cm-module/cm-cart-product/cm-cart-product.vue'
 import CmEmpty from '@/components/cm-module/cm-empty/cm-empty.vue'
 import { mapGetters, mapActions, mapMutations } from 'vuex'
-import { fetchSelectedProducts, findCouponBySelected, canUseCoupon, getCountPrice } from '@/common/couponUtil.js'
+import { fetchSelectedProducts, findCouponBySelected, canUseCoupon, getCountPrice, couponSort } from '@/common/couponUtil.js'
 
 export default {
     components: {
@@ -213,15 +213,15 @@ export default {
                 }
                 return `已享“满${this.currentCoupon.touchPrice}元减${this.currentCoupon.couponAmount}元”优惠券`
             }
-            return `还差¥${this.nextCoupon.touchPrice - getCountPrice()}元可用“满${this.nextCoupon.touchPrice}元减${
+            return `还差¥${this.nextCoupon.touchPrice - getCountPrice(this.selectedPoducts, this.nextCoupon)}元可用“满${this.nextCoupon.touchPrice}元减${
                 this.nextCoupon.couponAmount
             }元”优惠券`
         },
         couponList() {
             if (this.currentTabIndex === 0) {
-                return this.receiveCouponList
+                return couponSort(this.receiveCouponList)
             } else {
-                return this.ableCouponList
+                return couponSort(this.ableCouponList)
             }
         },
         couponListTabs() {

+ 10 - 7
pages/tabBar/index/index.vue

@@ -1,7 +1,7 @@
 <template>
     <view class="home">
         <tui-skeleton v-if="isRequest" loadingType="2"></tui-skeleton>
-        <template v-if="!isRequest">
+        <template v-else>
             <!-- 首页自定义导航栏 -->
             <view class="search-input" :class="{ fixed: isSticky }">
                 <view class="search-content" @click="this.$api.navigateTo(clickPath)">
@@ -92,7 +92,7 @@ export default {
         this.init()
     },
     computed: {
-        ...mapGetters(['hasLogin', 'activePopupType', 'userId']),
+        ...mapGetters(['hasLogin', 'activePopupType', 'userId', 'otherCouponFlag', 'showCouponPopup']),
         couponActivityIcon() {
             let icon = 'news'
             switch (this.activePopupType) {
@@ -108,7 +108,7 @@ export default {
     },
     watch: {
         activePopupType(val) {
-            if (val === 0) return
+            if (val === 0 || !this.showCouponPopup) return
             // 定时开启弹窗
             setTimeout(() => {
                 this.activePopupVisible = true
@@ -127,12 +127,15 @@ export default {
                 await this.GetHomeBanner() // 轮播图
                 await this.GetHomeProductList() // 楼层
                 this.isRequest = false
+                this.tipVisible = this.otherCouponFlag
             } catch (e) {
                 this.$util.msg(e.msg, 2000)
             }
-            setTimeout(() => {
-                this.tipVisible = false
-            }, 5000)
+            if (this.tipVisible) {
+                setTimeout(() => {
+                    this.tipVisible = false
+                }, 5000)
+            }
         },
         //初始化首页数据
         GetHomeBanner() {
@@ -147,7 +150,7 @@ export default {
                 this.productFloor = response.data
             })
         },
-        handleSelectorClick(){
+        handleSelectorClick() {
             this.$api.navigateTo('/pages/user/activity/coupon-find-list')
         },
         //跳转楼层

+ 72 - 125
pages/user/order/create-order.vue

@@ -1,53 +1,52 @@
 <template>
     <view class="container order clearfix" :style="{ paddingBottom: isIphoneX ? '170rpx' : '134rpx' }">
-        <!-- 地址选择 v-if="isAddress" -->
-        <choice-address ref="choiceAddress" :addressData="addressData"></choice-address>
-        <!-- 商品 -->
-        <goodsList
-            ref="goods"
-            v-if="isRequest"
-            :goodsData="goodsData"
-            @handleGoodList="handChangeInputGoodsList"
-        ></goodsList>
-        <!-- 选择优惠券 TODO-->
-        <view class="select-coupon" @click="couponVisible = true" v-if="receiveCouponList.length > 0">
-            <view class="left-title">优惠券</view>
-            <view class="right-content">
-                <view class="coupon-amount">-¥{{ couponAmount | NumFormat }}</view>
-                <view class="iconfont icon-chakangengduo"></view>
-            </view>
-        </view>
-        <!-- 优惠券列表 TODO-->
-        <cm-coupon-list
-            title="优惠券"
-            listType="use"
-            :visible="couponVisible"
-            @close="closeCouponList"
-            :chooseAble="true"
-            :showStatus="false"
-            :couponList="receiveCouponList"
-            @chooseCoupon="chooseCoupon"
-            :currentId="currentCouponId"
-        ></cm-coupon-list>
-        <!-- 运费 -->
-        <seller-freight ref="freight" v-if="isRequest" :freightDatas="freightData"> </seller-freight>
-        <!-- 底部 -->
-        <view class="footer" :style="{ paddingBottom: isIphoneX ? '68rpx' : '0rpx' }">
-            <view class="footer-le">
-                <view class="footer-count">
-                    <text>共{{ allCount }}件商品</text>
+        <tui-skeleton v-if="isRequest" loadingType="2"></tui-skeleton>
+        <template v-else>
+            <!-- 地址选择 v-if="isAddress" -->
+            <choice-address ref="choiceAddress" :addressData="addressData"></choice-address>
+            <!-- 商品 -->
+            <goodsList ref="goods" :goodsData="goodsData" @handleGoodList="handChangeInputGoodsList"></goodsList>
+            <!-- 选择优惠券 TODO-->
+            <view class="select-coupon" @click="couponVisible = true" v-if="receiveCouponList.length > 0">
+                <view class="left-title">优惠券</view>
+                <view class="right-content">
+                    <view class="coupon-amount">-¥{{ couponAmount | NumFormat }}</view>
+                    <view class="iconfont icon-chakangengduo"></view>
                 </view>
-                <view class="footer-price">
-                    <view class="sum" :class="totalFullReduction == 0 ? 'none' : ''">
-                        <view class="price">总价:¥{{ payAllPrice | NumFormat }}</view>
-                        <view class="discount">共减 ¥{{ discountedPrice | NumFormat }}</view>
+            </view>
+            <!-- 优惠券列表 TODO-->
+            <cm-coupon-list
+                title="优惠券"
+                listType="use"
+                :visible="couponVisible"
+                @close="closeCouponList"
+                :chooseAble="true"
+                :showStatus="false"
+                :couponList="receiveCouponList"
+                @chooseCoupon="chooseCoupon"
+                :currentId="currentCouponId"
+            ></cm-coupon-list>
+            <!-- 运费 -->
+            <seller-freight ref="freight" :freightDatas="freightData"> </seller-freight>
+            <!-- 底部 -->
+            <view class="footer" :style="{ paddingBottom: isIphoneX ? '68rpx' : '0rpx' }">
+                <view class="footer-le">
+                    <view class="footer-count">
+                        <text>共{{ allCount }}件商品</text>
+                    </view>
+                    <view class="footer-price">
+                        <view class="sum" :class="totalFullReduction == 0 ? 'none' : ''">
+                            <view class="price">总价:¥{{ payAllPrice | NumFormat }}</view>
+                            <view class="discount">共减 ¥{{ discountedPrice | NumFormat }}</view>
+                        </view>
                     </view>
                 </view>
+                <view class="footer-submit" @click.stop="orderSubmitMit">
+                    <view class="btn" :class="isSubLoading ? 'disabled' : ''">提交订单</view>
+                </view>
             </view>
-            <view class="footer-submit" @click.stop="orderSubmitMit">
-                <view class="btn" :class="isSubLoading ? 'disabled' : ''">提交订单</view>
-            </view>
-        </view>
+        </template>
+        <cm-loading :visible="isSubLoading" :text="loadingText"></cm-loading>
     </view>
 </template>
 
@@ -57,33 +56,34 @@ import choiceAddress from '@/components/cm-module/createOrder/address'
 import goodsList from '@/components/cm-module/createOrder/goodsList'
 import sellerFreight from '@/components/cm-module/createOrder/sellerFreight'
 import CmCouponList from '@/components/cm-module/cm-coupon-list/cm-coupon-list'
+import CmLoading from '@/components/cm-module/cm-loading/cm-loading.vue'
+import { allProdoceUseCheck, someProductUseCheck, couponSort } from '@/common/couponUtil.js'
 import { mapGetters } from 'vuex'
+import wechatPay from '@/mixins/wechatPay.js'
 export default {
     components: {
         choiceAddress,
         goodsList,
         sellerFreight,
-        CmCouponList
+        CmCouponList,
+        CmLoading
     },
+    // 混入
+    mixins: [wechatPay],
     data() {
         return {
             couponVisible: false,
-            isSubLoading: false,
             productIds: '', //获取上一级页面商品信息
             productCount: '', //获取上一级页面商品数量
             allCount: 1, //订单提交总数量
-            totalOriginalPrice: 0, //订单总原价(划线部分)
             totalFullReduction: 0, //满减金额
             allPrice: 0.0, //订单总金额
             townId: '', //区ID
-            isRequest: false, //是否加载完成渲染子组件
-            isFreight: false, //是否加载完成渲染子组件
+            isRequest: true, //是否加载完成渲染子组件
             isAddress: false, //是否加载完成地址
-            ischecked: false, //是否勾选余额
             addressData: {}, //初始化地址信息
             goodsData: [], //初始化商品信息
             freightData: {}, //邮费数据
-            isIphoneX: this.$store.getters.isIphoneX,
             productsList: [],
             params: {
                 userId: 0
@@ -100,7 +100,8 @@ export default {
             orderInfo: '',
             receiveCouponList: [],
             currentCouponId: -1,
-            currentCoupon: null
+            currentCoupon: null,
+            loadingText: '正在创建订单'
         }
     },
     onLoad(option) {
@@ -123,7 +124,7 @@ export default {
         this.getInitCrearOrder(this.params)
     },
     computed: {
-        ...mapGetters(['userId']),
+        ...mapGetters(['userId', 'isIphoneX']),
         // 选中的优惠券的金额
         couponAmount() {
             return this.currentCoupon ? this.currentCoupon.couponAmount : 0
@@ -135,6 +136,11 @@ export default {
         // 支付金额
         payAllPrice() {
             return this.allPrice - this.couponAmount
+        },
+        hanldOrder() {
+            return {
+                order: this.orderInfo
+            }
         }
     },
     filters: {
@@ -158,13 +164,13 @@ export default {
         filterCouponList() {
             const productList = []
             this.goodsData.forEach(shop => productList.push(...shop.productList.map(prod => prod)))
-            let canUseCouponList = []
-            let notUseCouponList = []
-            this.list = this.receiveCouponList.forEach(coupon => {
+            let canUseCouponList = [] // 可以使用的优惠券
+            let notUseCouponList = [] // 需要凑单使用的优惠券
+            this.receiveCouponList.forEach(coupon => {
                 if (
                     coupon.noThresholdFlag === 1 ||
-                    (coupon.productType === 1 && this.allProdoceUseCheck(productList, coupon)) ||
-                    (coupon.productType === 2 && this.someProductUseCheck(productList, coupon))
+                    (coupon.productType === 1 && allProdoceUseCheck(productList, coupon)) ||
+                    (coupon.productType === 2 && someProductUseCheck(productList, coupon))
                 ) {
                     coupon.canSelect = true
                     canUseCouponList.push(coupon)
@@ -173,27 +179,15 @@ export default {
                     notUseCouponList.push(coupon)
                 }
             })
-            // 金额高的拍前面
-            canUseCouponList = canUseCouponList.sort((a, b) => b.couponAmount - a.couponAmount)
-            notUseCouponList = notUseCouponList.sort((a, b) => b.couponAmount - a.couponAmount)
-            this.receiveCouponList = [...canUseCouponList, ...notUseCouponList]
+            // 金额高的排前面
+            this.receiveCouponList = [...couponSort(canUseCouponList), ...couponSort(notUseCouponList)]
             // 当有可用优惠券时 默认选取第一个最优惠的
             if (this.receiveCouponList.length > 0) {
                 this.currentCouponId = this.receiveCouponList[0].couponId
                 this.currentCoupon = this.receiveCouponList[0]
             }
-        },
-        // 判断全部商品可用 是否可勾选使用
-        allProdoceUseCheck(productList, coupon) {
-            return productList.some(prod => prod.price * prod.productCount >= coupon.couponAmount)
-        },
-        // 判断指定商品可用 是否可勾选使用
-        someProductUseCheck(productList, coupon) {
-            return productList.some(
-                prod =>
-                    coupon.productIds.indexOf(prod.productId.toString()) > -1 &&
-                    prod.price * prod.productCount >= coupon.couponAmount
-            )
+            // 显示界面
+            this.isRequest = false
         },
         // 选中优惠券
         chooseCoupon(coupon) {
@@ -205,17 +199,14 @@ export default {
                 this.currentCouponId = -1
             }
             this.couponVisible = false
-            console.log(coupon)
         },
         //确认订单初始化信息
         getInitCrearOrder(params) {
             this.OrderService.QueryOrderConfirm(params)
                 .then(response => {
                     let data = response.data
-                    this.isRequest = true
                     this.goodsData = data.shopList
                     this.allPrice = data.totalPrice
-                    
                     this.fetchCouponList()
                 })
                 .catch(error => {
@@ -243,6 +234,8 @@ export default {
         orderSubmitMit() {
             //提交订单
             if (this.isSubLoading) return
+            this.isSubLoading = true
+            this.loadingText = '正在创建订单...'
             if (this.subParams.addressId == '') return this.$util.msg('请先添加收货地址~', 2000)
             // 选中的优惠券id
             this.subParams.couponId = this.currentCouponId === -1 ? '' : this.currentCouponId
@@ -259,62 +252,16 @@ export default {
                 })
                 return { shopId: el.shopId, note: el.note ? el.note : '', productInfo: productInfo }
             })
-            debugger
-            this.isSubLoading = true
             this.OrderService.CreatedOrderSubmit(this.subParams)
                 .then(response => {
                     const data = response.data
                     this.orderInfo = response.data
-                    setTimeout(() => {
-                        this.isSubLoading = false
-                    }, 2000)
-                    this.MiniWxPayFor(data)
-                })
-                .catch(error => {
-                    this.$util.msg(error.msg, 2000)
-                })
-        },
-        MiniWxPayFor(data) {
-            this.PayService.PayOrderOnLineSwitch().then(response => {
-                if (response.data === 1) {
-                    this.WeChatMiniWxPay(data)
-                } else {
-                    this.$api.navigateTo(`/pages/user/order/order-payment?money=${data.payableAmount}`)
-                }
-            })
-        },
-        async WeChatMiniWxPay(data) {
-            const wechatCode = await authorize.getCode('weixin')
-            this.PayService.WeChatMiniWxPay({
-                payAmount: data.payableAmount * 100,
-                payWay: 'WEIXIN',
-                code: wechatCode,
-                orderId: data.orderId
-            })
-                .then(response => {
-                    let PayInfo = JSON.parse(response.data.data.payInfo)
-                    this.WxRequestPayment(PayInfo)
+                    this.miniWxPayFor(data)
                 })
                 .catch(error => {
                     this.$util.msg(error.msg, 2000)
+                    this.isSubLoading = false
                 })
-        },
-        WxRequestPayment(data) {
-            let self = this
-            wx.requestPayment({
-                timeStamp: data.timeStamp,
-                nonceStr: data.nonceStr,
-                package: data.package,
-                signType: data.signType,
-                paySign: data.paySign,
-                success: function(res) {
-                    wx.reLaunch({ url: '/pages/tabBar/index/index' })
-                },
-                fail: function(res) {
-                    self.$api.redirectTo(`/pages/user/order/success?data=${JSON.stringify({ data: self.orderInfo })}`)
-                },
-                complete: function(res) {}
-            })
         }
     },
     onShow() {

+ 12 - 50
pages/user/order/order-details.vue

@@ -75,6 +75,8 @@
         </tui-modal>
         <!-- 促销活动弹窗 -->
         <activi-popup :Promotion="handlerPros" :popupShow="popupShow"></activi-popup>
+        <!-- 加载中 -->
+        <cm-loading :visible="isSubLoading" :text="loadingText"></cm-loading>
     </view>
 </template>
 
@@ -88,18 +90,22 @@ import transfeRecord from '@/components/cm-module/orderDetails/transfeRecord' //
 import paymentRecord from '@/components/cm-module/orderDetails/paymentRecord' //支付记录
 import refundRecord from '@/components/cm-module/orderDetails/refundRecord' //退款记录
 import orderButton from '@/components/cm-module/orderDetails/orderButton' //底部按钮
-
+import CmLoading from '@/components/cm-module/cm-loading/cm-loading.vue'
+import wechatPay from '@/mixins/wechatPay.js'
 export default {
     components: {
         HeaderOrder,
         orderInformation,
         orderAddress,
         goodsList,
+        CmLoading,
         transfeRecord,
         paymentRecord,
         refundRecord,
         orderButton
     },
+    // 混入
+    mixins: [wechatPay],
     data() {
         return {
             state: 0,
@@ -150,7 +156,7 @@ export default {
                     type: 'danger'
                 }
             ],
-            invalidList: []
+            invalidList: [],
         }
     },
     onLoad(option) {
@@ -274,7 +280,7 @@ export default {
                     this.handBuyAgainInfo()
                     break
                 case 'pay':
-                    this.MiniWxPayFor(data.order)
+                    this.miniWxPayFor(data.order)
                     break
             }
         },
@@ -371,7 +377,9 @@ export default {
                 .then(response => {
                     this.$util.msg(response.msg, 2000, true, 'success')
                     setTimeout(() => {
-                        this.GetOrderDetaileData(this.currentTab)
+                        uni.navigateBack({
+                            delta: 1
+                        })
                     }, 2000)
                 })
                 .catch(error => {
@@ -391,52 +399,6 @@ export default {
                     this.$util.msg(error.msg, 2000)
                 })
         },
-        MiniWxPayFor(data) {
-            this.PayService.PayOrderOnLineSwitch().then(response => {
-                if (response.data === 1) {
-                    this.WeChatMiniWxPay(data)
-                } else {
-                    this.$api.navigateTo(`/pages/user/order/order-payment?money=${data.payableAmount}`)
-                }
-            })
-        },
-        async WeChatMiniWxPay(data) {
-            const wechatCode = await authorize.getCode('weixin')
-            this.PayService.WeChatMiniWxPay({
-                payAmount: data.payableAmount * 100,
-                payWay: 'WEIXIN',
-                code: wechatCode,
-                orderId: data.orderId
-            })
-                .then(response => {
-                    let PayInfo = JSON.parse(response.data.data.payInfo)
-                    this.WxRequestPayment(PayInfo)
-                })
-                .catch(error => {
-                    this.$util.msg(error.msg, 2000)
-                })
-        },
-        WxRequestPayment(data) {
-            let self = this
-            wx.requestPayment({
-                timeStamp: data.timeStamp,
-                nonceStr: data.nonceStr,
-                package: data.package,
-                signType: data.signType,
-                paySign: data.paySign,
-                success: function(res) {
-                    wx.reLaunch({ url: '/pages/tabBar/index/index' })
-                },
-                fail: function(res) {
-                    console.log(res)
-                    console.log('ORDERiD', self.hanldOrder)
-                    self.$api.redirectTo(
-                        `/pages/user/order/success?data=${JSON.stringify({ data: self.hanldOrder.order })}`
-                    )
-                },
-                complete: function(res) {}
-            })
-        },
         hanldePopupFn(data) {
             //监听活动内容
             this.popupShow = true

+ 10 - 72
pages/user/order/order-list-retail.vue

@@ -193,6 +193,7 @@
         </tui-modal>
         <!-- 透明模态层 -->
         <modal-layer v-if="isModalLayer"></modal-layer>
+        <cm-loading :visible="isSubLoading" :text="loadingText"></cm-loading>
     </view>
 </template>
 
@@ -202,15 +203,19 @@ 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 { mapGetters } from 'vuex'
+import wechatPay from '@/mixins/wechatPay.js'
 
 export default {
     components: {
         HeaderOrder,
         empty,
         orderButton,
-        modalLayer
+        modalLayer,
+        CmLoading
     },
+    mixins: [wechatPay],
     data() {
         return {
             CustomBar: this.CustomBar, // 顶部导航栏高度
@@ -234,7 +239,6 @@ export default {
             currentTab: 0, //预设当前项的值
             screenTab: 0, //筛选预设当前项的值
             scrollLeft: 0, //tab标题的滚动条位置
-            orderData: [],
             btnoRderID: 0, //点击按钮传入的的订单ID
             pageNum: 1, //页数
             pageSize: 10, //条数
@@ -243,15 +247,11 @@ export default {
             isDelete: false,
             isClickChange: false,
             isModalLayer: false,
-            isPayModel: false,
             loadding: false,
             pullUpOn: true,
             hasNextPage: false,
             pullFlag: true,
             navbarHeight: '',
-            payModelData: {},
-            hanldOrderData: {},
-            modelType: 0,
             nomoreText: '上拉显示更多',
             isOnloadFlag: false,
             modal: false,
@@ -265,7 +265,8 @@ export default {
                     type: 'danger'
                 }
             ],
-            invalidList: []
+            invalidList: [],
+            hanldOrder: {}
         }
     },
     computed: {
@@ -302,9 +303,6 @@ export default {
         // console.log(this.orderTabBar)
     },
     methods: {
-        goShophome(id) {
-            this.$api.navigateTo(`/supplier/pages/user/my-shop?shopId=${id}`)
-        },
         // 滚动切换标签样式
         onChange: function(e) {
             let index = e.target.current || e.detail.current
@@ -458,6 +456,7 @@ export default {
             this.hanldOrder = data
             this.btnoRderID = data.orderId
             this.OperationType = data.type
+            this.orderInfo = data.order
             this.handShowAlert(data)
         },
         handShowAlert(data) {
@@ -483,7 +482,7 @@ export default {
                     this.handBuyAgainInfo()
                     break
                 case 'pay':
-                    this.MiniWxPayFor(data.order)
+                    this.miniWxPayFor(data.order)
                     break
             }
         },
@@ -599,59 +598,9 @@ export default {
                     this.$util.msg(error.msg, 2000)
                 })
         },
-        MiniWxPayFor(data) {
-            this.PayService.PayOrderOnLineSwitch().then(response => {
-                if (response.data === 1) {
-                    this.WeChatMiniWxPay(data)
-                } else {
-                    this.$api.navigateTo(`/pages/user/order/order-payment?money=${data.payableAmount}`)
-                }
-            })
-        },
-        async WeChatMiniWxPay(data) {
-            const wechatCode = await authorize.getCode('weixin')
-            this.PayService.WeChatMiniWxPay({
-                payAmount: data.payableAmount * 100,
-                payWay: 'WEIXIN',
-                code: wechatCode,
-                orderId: data.orderId
-            })
-                .then(response => {
-                    let PayInfo = JSON.parse(response.data.data.payInfo)
-                    this.WxRequestPayment(PayInfo)
-                })
-                .catch(error => {
-                    this.$util.msg(error.msg, 2000)
-                })
-        },
-        WxRequestPayment(data) {
-            let self = this
-            wx.requestPayment({
-                timeStamp: data.timeStamp,
-                nonceStr: data.nonceStr,
-                package: data.package,
-                signType: data.signType,
-                paySign: data.paySign,
-                success: function(res) {
-                    wx.reLaunch({ url: '/pages/tabBar/index/index' })
-                },
-                fail: function(res) {
-                    console.log(res)
-                    self.$api.redirectTo(
-                        `/pages/user/order/success?data=${JSON.stringify({ data: self.hanldOrder.order })}`
-                    )
-                },
-                complete: function(res) {}
-            })
-        },
         handlSearchPath() {
             this.$api.navigateTo('/pages/user/order/search-order')
         },
-        orderPriceToFixed(n) {
-            let price = ''
-            price = n.toFixed(2)
-            return price
-        },
         getHeaderTopHeight() {
             // 状态栏高度
             let statusBarHeight = this.systeminfo.statusBarHeight
@@ -684,17 +633,6 @@ export default {
             })
             return systeminfo
         },
-        PromotionsFormat(promo) {
-            //促销活动类型数据处理
-            if (promo != null) {
-                if (promo.type == 1 && promo.mode == 1) {
-                    return true
-                } else {
-                    return false
-                }
-            }
-            return false
-        },
         StateExpFormat(state) {
             //订单状态文字和颜色
             var HtmlStateText = '',

+ 12 - 59
pages/user/order/order-list.vue

@@ -37,7 +37,6 @@
             :style="{ height: winHeight + 'px' }"
         >
             <swiper-item v-for="(tabItem, index) in orderTabBar" :key="index">
-                
                 <scroll-view scroll-y class="scoll-y" @scrolltolower="scrolltolower">
                     <view :class="{ 'tui-order-list': scrollTop >= 0 }" class="clearfix">
                         <!-- 空白页 -->
@@ -63,9 +62,7 @@
                                         <view class="order-title-btxt"
                                             ><text class="text">下单时间:</text>{{ order.orderTime }}</view
                                         >
-                                        <view class="order-title-tip">{{
-                                            StateExpFormat(order.status)
-                                        }}</view>
+                                        <view class="order-title-tip">{{ StateExpFormat(order.status) }}</view>
                                     </view>
                                 </view>
                                 <block v-for="(shop, sindex) in order.shopOrderList" :key="sindex">
@@ -80,14 +77,10 @@
                                         @click.stop="detail(order.orderId)"
                                     >
                                         <view class="goods-pros-t">
-                                            <view class="pros-img">
-                                                <image :src="pros.productImage" alt="" />
-                                            </view>
+                                            <view class="pros-img"> <image :src="pros.productImage" alt="" /> </view>
                                             <view class="pros-product clearfix">
                                                 <view class="producttitle">{{ pros.name }}</view>
-                                                <view
-                                                    class="productspec"
-                                                    v-if="pros.productCategory != 2"
+                                                <view class="productspec" v-if="pros.productCategory != 2"
                                                     >规格:{{ pros.productUnit }}</view
                                                 >
                                                 <view class="floor-item-act" v-if="pros.ladderPriceFlag == 1">
@@ -185,6 +178,7 @@
         </tui-modal>
         <!-- 透明模态层 -->
         <modal-layer v-if="isModalLayer"></modal-layer>
+        <cm-loading :visible="isSubLoading" :text="loadingText"></cm-loading>
     </view>
 </template>
 
@@ -194,14 +188,18 @@ 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'
 export default {
     components: {
         HeaderOrder,
         empty,
         orderButton,
-        modalLayer
+        modalLayer,
+        CmLoading
     },
+    // 混入
+    mixins: [wechatPay],
     data() {
         return {
             CustomBar: this.CustomBar, // 顶部导航栏高度
@@ -255,7 +253,7 @@ export default {
                     type: 'danger'
                 }
             ],
-            invalidList: []
+            invalidList: [],
         }
     },
     onLoad(e) {
@@ -464,7 +462,7 @@ export default {
                     this.handBuyAgainInfo()
                     break
                 case 'pay':
-                    this.MiniWxPayFor(data.order)
+                    this.miniWxPayFor(data.order)
                     break
             }
         },
@@ -580,51 +578,6 @@ export default {
                     this.$util.msg(error.msg, 2000)
                 })
         },
-        MiniWxPayFor(data) {
-            this.PayService.PayOrderOnLineSwitch().then(response => {
-                if (response.data === 1) {
-                    this.WeChatMiniWxPay(data)
-                } else {
-                    this.$api.navigateTo(`/pages/user/order/order-payment?money=${data.payableAmount}`)
-                }
-            })
-        },
-        async WeChatMiniWxPay(data) {
-            const wechatCode = await authorize.getCode('weixin')
-            this.PayService.WeChatMiniWxPay({
-                payAmount: data.payableAmount * 100,
-                payWay: 'WEIXIN',
-                code: wechatCode,
-                orderId: data.orderId
-            })
-                .then(response => {
-                    let PayInfo = JSON.parse(response.data.data.payInfo)
-                    this.WxRequestPayment(PayInfo)
-                })
-                .catch(error => {
-                    this.$util.msg(error.msg, 2000)
-                })
-        },
-        WxRequestPayment(data) {
-            let self = this
-            wx.requestPayment({
-                timeStamp: data.timeStamp,
-                nonceStr: data.nonceStr,
-                package: data.package,
-                signType: data.signType,
-                paySign: data.paySign,
-                success: function(res) {
-                    wx.reLaunch({ url: '/pages/tabBar/index/index' })
-                },
-                fail: function(res) {
-                    console.log(res)
-                    self.$api.redirectTo(
-                        `/pages/user/order/success?data=${JSON.stringify({ data: self.hanldOrder.order })}`
-                    )
-                },
-                complete: function(res) {}
-            })
-        },
         handlSearchPath() {
             this.$api.navigateTo('/pages/user/order/search-order')
         },

+ 9 - 48
pages/user/order/search-order.vue

@@ -204,6 +204,7 @@
         </tui-modal>
         <!-- 透明模态层 -->
         <modal-layer v-if="isModalLayer"></modal-layer>
+        <cm-loading :visible="isSubLoading" :text="loadingText"></cm-loading>
     </view>
 </template>
 
@@ -212,11 +213,16 @@ 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 authorize from '@/common/authorize.js'
+import CmLoading from '@/components/cm-module/cm-loading/cm-loading.vue'
+import wechatPay from '@/mixins/wechatPay.js'
 export default {
     components: {
         orderButton,
-        empty
+        empty,
+        CmLoading
     },
+    // 混入
+    mixins: [wechatPay],
     data() {
         return {
             themeClass: 'block',
@@ -255,7 +261,7 @@ export default {
                     type: 'danger'
                 }
             ],
-            invalidList: []
+            invalidList: [],
         }
     },
     onLoad() {
@@ -458,7 +464,7 @@ export default {
                     this.handBuyAgainInfo()
                     break
                 case 'pay':
-                    this.MiniWxPayFor(data.order)
+                    this.miniWxPayFor(data.order)
                     break
             }
         },
@@ -574,51 +580,6 @@ export default {
                     this.$util.msg(error.msg, 2000)
                 })
         },
-        MiniWxPayFor(data) {
-            this.PayService.PayOrderOnLineSwitch().then(response => {
-                if (response.data === 1) {
-                    this.WeChatMiniWxPay(data)
-                } else {
-                    this.$api.navigateTo(`/pages/user/order/order-payment?money=${data.payableAmount}`)
-                }
-            })
-        },
-        async WeChatMiniWxPay(data) {
-            const wechatCode = await authorize.getCode('weixin')
-            this.PayService.WeChatMiniWxPay({
-                payAmount: data.payableAmount * 100,
-                payWay: 'WEIXIN',
-                code: wechatCode,
-                orderId: data.orderId
-            })
-                .then(response => {
-                    let PayInfo = JSON.parse(response.data.data.payInfo)
-                    this.WxRequestPayment(PayInfo)
-                })
-                .catch(error => {
-                    this.$util.msg(error.msg, 2000)
-                })
-        },
-        WxRequestPayment(data) {
-            let self = this
-            wx.requestPayment({
-                timeStamp: data.timeStamp,
-                nonceStr: data.nonceStr,
-                package: data.package,
-                signType: data.signType,
-                paySign: data.paySign,
-                success: function(res) {
-                    wx.reLaunch({ url: '/pages/tabBar/index/index' })
-                },
-                fail: function(res) {
-                    console.log(res)
-                    self.$api.redirectTo(
-                        `/pages/user/order/success?data=${JSON.stringify({ data: self.hanldOrder.order })}`
-                    )
-                },
-                complete: function(res) {}
-            })
-        },
         handlSearchPath() {
             this.$api.navigateTo('/pages/user/order/search-order')
         },

+ 21 - 54
pages/user/order/success.vue

@@ -20,7 +20,7 @@
                 <view class="money">¥{{ orderInfo.payableAmount | NumFormat }}</view>
             </view>
             <view class="container-button">
-                <view class="btn btn-pay" @click="MiniWxPayFor(orderInfo)">重新支付</view>
+                <view class="btn btn-pay" @click="miniWxPayFor(orderInfo)">重新支付</view>
                 <view
                     class="btn btn-open"
                     @click="
@@ -30,19 +30,27 @@
                 >
             </view>
         </view>
+        <cm-loading :visible="isSubLoading" :text="loadingText"></cm-loading>
     </view>
 </template>
 
 <script>
 import HeaderPay from '@/components/cm-module/headerNavbar/header-pay'
 import authorize from '@/common/authorize.js'
+import CmLoading from '@/components/cm-module/cm-loading/cm-loading.vue'
+import wechatPay from '@/mixins/wechatPay.js'
+import { mapGetters } from 'vuex'
 export default {
     components: {
-        HeaderPay
+        HeaderPay,
+        CmLoading
     },
+    // 混入支付
+    mixins: [wechatPay],
     data() {
         return {
             StaticUrl: this.$Static,
+            CustomBar: this.CustomBar, // 顶部导航栏高度
             orderId: '',
             nvabarData: {
                 //顶部自定义导航
@@ -54,25 +62,28 @@ export default {
             },
             headerBtnPosi: this.setHeaderBtnPosi(), //获取设备顶部胶囊高度
             systeminfo: this.setSysteminfo(), //获取设备信息
-            isIphoneX: this.$store.getters.isIphoneX,
-            CustomBar: this.CustomBar, // 顶部导航栏高度
             successText: '订单支付失败',
             orderInfo: {}
         }
     },
     onLoad(option) {
-        console.log(option)
         let data = JSON.parse(option.data)
-        this.orderInfo = data.data
-        console.log(this.orderInfo)
+        this.orderInfo = data.orderInfo
     },
     filters: {
         NumFormat(value) {
             //处理金额
-            console.log(value)
             return Number(value).toFixed(2)
         }
     },
+    computed: {
+        ...mapGetters(['isIphoneX']),
+        hanldOrder() {
+            return {
+                order: this.orderInfo
+            }
+        }
+    },
     methods: {
         setHeaderBtnPosi() {
             // 获得胶囊按钮位置信息
@@ -88,56 +99,12 @@ export default {
                 }
             })
             return systeminfo
-        },
-        MiniWxPayFor(data) {
-            this.PayService.PayOrderOnLineSwitch().then(response => {
-                if (response.data === 1) {
-                    this.WeChatMiniWxPay(data)
-                } else {
-                    this.$api.navigateTo(`/pages/user/order/order-payment?money=${data.payableAmount}`)
-                }
-            })
-        },
-        async WeChatMiniWxPay(data) {
-            const wechatCode = await authorize.getCode('weixin')
-            this.PayService.WeChatMiniWxPay({
-                payAmount: data.payableAmount * 100,
-                payWay: 'WEIXIN',
-                code: wechatCode,
-                orderId: data.orderId
-            })
-                .then(response => {
-                    let PayInfo = JSON.parse(response.data.data.payInfo)
-                    this.WxRequestPayment(PayInfo)
-                })
-                .catch(error => {
-                    this.$util.msg(error.msg, 2000)
-                })
-        },
-        WxRequestPayment(data) {
-            let self = this
-            wx.requestPayment({
-                timeStamp: data.timeStamp,
-                nonceStr: data.nonceStr,
-                package: data.package,
-                signType: data.signType,
-                paySign: data.paySign,
-                success: function(res) {
-                    wx.reLaunch({ url: '/pages/tabBar/index/index' })
-                },
-                fail: function(res) {
-                    console.log(res)
-                    self.$api.redirectTo(`/pages/user/order/success?data=${JSON.stringify({ data: self.orderInfo })}`)
-                },
-                complete: function(res) {}
-            })
         }
-    },
-    onShow() {}
+    }
 }
 </script>
 
-<style lang="scss">
+<style lang="scss" scoped>
 page {
     background-color: #f7f7f7;
     height: auto !important;

+ 3 - 3
services/order.service.js

@@ -11,7 +11,7 @@ export default class OrderService {
         return this.AjaxService.get({
             url: '/order/confirm',
             data,
-            isLoading: true,
+            isLoading: false,
         })
     }
     /* 提交订单 */
@@ -35,7 +35,7 @@ export default class OrderService {
         return this.AjaxService.get({
             url: '/order/dealer/list',
             data,
-            isLoading: true,
+            isLoading: false,
         })
     }
     /* 查询订单详情 */
@@ -141,7 +141,7 @@ export default class OrderService {
         return this.AjaxService.post({
             url: '/order/submit',
             data,
-            isLoading: true,
+            isLoading: false,
         })
     }
 }

+ 2 - 2
services/pay.service.js

@@ -18,7 +18,7 @@ export default class PayService {
         return this.AjaxService.post({
             url: '/PayOrder/miniWxPay',
             data,
-            isLoading: true,
+            isLoading: false,
         })
     }
     /**
@@ -28,7 +28,7 @@ export default class PayService {
         return this.AjaxService.get({
             url: '/PayOrder/onLineSwitch',
             data,
-            isLoading: true,
+            isLoading: false,
         })
     }
 }

+ 2 - 0
store/getters.js

@@ -20,6 +20,8 @@ const getters = {
     productIds: state => state.cart.productIds,
     // 优惠券
     activePopupType: state => state.coupon.activePopupType,
+    otherCouponFlag: state => state.coupon.otherCouponFlag,
+    showCouponPopup: state => state.coupon.showCouponPopup,
     expiredNum: state => state.coupon.expiredNum,
     unusedNum: state => state.coupon.unusedNum,
     usedNum: state => state.coupon.usedNum

+ 15 - 3
store/modules/coupon.js

@@ -7,6 +7,7 @@ import { msg as showMsg } from '@/common/util.js'
 const state = {
     showCouponPopup: true, // 是否显示优惠券入口弹窗
     activePopupType: 0, // 0 禁用 1 老用户 2 新用户
+    otherCouponFlag: false,
     expiredNum: 0,
     unusedNum: 0,
     usedNum: 0
@@ -25,6 +26,10 @@ const mutations = {
     // 设置优惠券弹窗是否显示
     setCouponPopupStatus(state, status) {
         state.showCouponPopup = status
+    },
+    // 设置是否有优惠券领取提示
+    setOtherCouponFlag(state, value) {
+        state.otherCouponFlag = value === 1
     }
 }
 const actions = {
@@ -44,12 +49,11 @@ const actions = {
         })
     },
     // 优惠券活动弹窗信息
-    getCouponActivity({ commit, rootGetters, state }) {
-        if (!state.showCouponPopup) return
+    getCouponActivity({ commit, rootGetters, state, dispatch }) {
         couponService.CouponActivityPopup({
             userId: rootGetters.userId
         }).then(response => {
-            const { newUserCouponFlag, actCouponFlag } = response.data
+            const { newUserCouponFlag, actCouponFlag, otherCouponFlag } = response.data
             // 全部用户弹窗
             if (actCouponFlag !== 0) {
                 commit('updatePopupType', 1)
@@ -58,6 +62,14 @@ const actions = {
             if (newUserCouponFlag !== 0) {
                 commit('updatePopupType', 2)
             }
+            // 是否有新的优惠券可领取
+            commit('setOtherCouponFlag', otherCouponFlag)
+            // 每次10分钟刷新一次 
+            if (rootGetters.hasLogin) {
+                setTimeout(() => {
+                    dispatch('getCouponActivity')
+                }, 10 * 60 * 1000)
+            }
         })
     }
 }