Quellcode durchsuchen

拼团版本bug处理优化

喻文俊 vor 3 Jahren
Ursprung
Commit
0053e81611

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

@@ -88,7 +88,7 @@ export default {
                 1: '活动券',
                 2: '用户专享券',
                 3: '新用户券',
-                4: '好友分享券',
+                4: '好友邀请券',
                 5: '好友消费券'
             }
             return tags[val] || '未知券'

+ 2 - 2
components/cm-module/cm-goods-nav/cm-goods-nav.vue

@@ -103,8 +103,8 @@ export default {
             return this.productInfo.collageProduct || {}
         },
         maxCount(){
-            // unlimitedFlag  0 限购  1 不限购
-            if(this.collageProduct.unlimitedFlag === 0){
+            // unlimitedFlag  0 限购  1 不限购  handleClickType : 0 单独购买 1 拼团购买
+            if(this.collageProduct.unlimitedFlag === 0 && this.handleClickType === 1){
                 return this.collageProduct.limitedNum
             }else{
                 return this.productInfo.stock

+ 7 - 7
components/cm-module/cm-order-control-nav/cm-order-control-nav.vue

@@ -1,7 +1,8 @@
 <template>
     <view class="cm-order-control-nav">
+        <view class="btn type2" v-if="btnState.cancel" @click.stop="handleClick('cancel')">取消订单</view>
         <view class="btn type2" v-if="btnState.fightDetail" @click.stop="handleClick('fightDetail')">拼团详情</view>
-       <!-- <button
+        <!-- <button
             class="btn type1"
             id="fightShare"
             v-if="btnState.fightShare"
@@ -12,7 +13,6 @@
             邀好友拼团
         </button> -->
         <view class="btn type1" v-if="btnState.fightShare" @click.stop="handleClick('fightShare')">邀好友拼团</view>
-        <view class="btn type2" v-if="btnState.cancel" @click.stop="handleClick('cancel')">取消订单</view>
         <view class="btn type2" v-if="btnState.delete" @click.stop="handleClick('delete')">删除订单</view>
         <view class="btn type2" v-if="btnState.query" @click.stop="handleClick('query')">查看物流</view>
         <view class="btn type1" v-if="btnState.pay" @click.stop="handleClick('pay')">付款</view>
@@ -29,7 +29,7 @@ export default {
             type: Object,
             default: () => {}
         },
-        hasBottom:{
+        hasBottom: {
             type: Boolean,
             default: false
         }
@@ -37,13 +37,13 @@ export default {
     data() {
         return {
             mapState: {
-                fightDetail: [82],
+                fightDetail: [82, 83],
                 fightShare: [81],
-                query: [4, 5, 12, 13, 33, 22, 23, 32, 77],
+                query: [4, 5, 12, 13, 33, 22, 23, 32, 77, 83],
                 delete: [6],
                 cancel: [0, 111],
-                confirm: [33],
-                again: [33, 81, 82],
+                confirm: [33, 83],
+                again: [33],
                 pay: [11, 12, 13, 21, 22, 23, 111]
             },
             buttonCount: 0

+ 1 - 1
components/cm-module/cm-order-prodcut/cm-order-prodcut.vue

@@ -8,7 +8,7 @@
                 <template v-if="tagsList.length > 0">
                     <view class="tag type4" v-for="(tag, index) in tagsList" :key="index">{{ tag }}</view>
                 </template>
-                <view class="tag type3" v-if="goodsData.collagePriceFlag">拼团价</view> 
+                <view class="tag type3" v-if="goodsData.collagePriceFlag === 1 || goodsData.collageStatus === 1">拼团价</view> 
                 <template v-if="goodsData.activeStatus">
                     <view class="tag type1" v-if="userId === goodsData.heUserId">促销</view>
                     <view class="tag type1" v-else>自营</view>

+ 1 - 1
components/cm-module/cm-product-price/cm-product-price.vue

@@ -4,7 +4,7 @@
         <view class="price">
             <text class="small">¥</text> <text class="big">{{ bigPrice }}</text>
             <text class="small">{{ smallPrice }}</text>
-            <text class="delete" v-if="showDeletedPrice">{{ productInfo.normalPrice }}</text>
+            <text class="delete" v-if="showDeletedPrice">{{ productInfo.normalPrice }}</text>
         </view>
         <view class="tags">
             <view class="tag type1" v-if="productInfo.heUserId !== 0">促销</view>

+ 1 - 1
components/uni-components/uni-goods-nav/uni-goods-nav.vue

@@ -79,7 +79,7 @@
                         class="flex uni-tab__cart-button-right"
                         @click="buttonClick(index, item)"
                     >
-                        <text :style="{ color: item.color }" class="uni-tab__cart-button-right-text has-price">{{ item.price | formatPrice}}</text>
+                        <text :style="{ color: item.color }" class="uni-tab__cart-button-right-text has-price">{{ item.price | formatPrice}}</text>
                         <text :style="{ color: item.color }" class="uni-tab__cart-button-right-text has-price">{{ item.text }}</text>
                     </view>
                 </template>

+ 39 - 16
pages/fight-order/components/user-list.vue

@@ -1,22 +1,37 @@
 <template>
     <view class="user-list">
-        <view class="user first">
-            <image src="https://picsum.photos/100/100?random=1" class="user-head"></image> <text>拼主</text>
-        </view>
-        <view class="user"> <image v-if="status" src="https://picsum.photos/100/100?random=2" class="user-head"></image> </view>
+        <scroll-view :scroll-x="true" class="scroll-box">
+            <view class="user-box">
+                <view class="user first">
+                    <image :src="avatar" class="user-head"></image> <text>拼主</text>
+                </view>
+            </view>
+            <view class="user-box" v-for="i in memberNum - 1" :key="i">
+                <view class="user">
+                    <image v-if="i < existNum - 1" :src="avatar" class="user-head"></image>
+                </view>
+            </view>
+        </scroll-view>
     </view>
 </template>
 
 <script>
 export default {
     props: {
-        userList: {
-            type: Object,
-            default: () => ({})
+        // 总人数
+        memberNum: {
+            type: Number,
+            default: 0
         },
-        status: {
-            type: Boolean,
-            default: false
+        // 已有人数
+        existNum:{
+            type: Number,
+            default: 0
+        }
+    },
+    computed:{
+        avatar(){
+            return this.$Static + 'icon-default-avatar.png'
         }
     }
 }
@@ -30,7 +45,19 @@ export default {
 }
 
 .user-list {
-    @extend .flex-center-box;
+    padding: 0 24rpx;
+    
+    .scroll-box {
+        white-space: nowrap;
+        text-align: center;
+    }
+
+    .user-box {
+        display: inline-block;
+        margin: 12rpx 12rpx;
+    }
+
+    // @extend .flex-center-box;
     .user {
         @extend .flex-center-box;
         position: relative;
@@ -49,10 +76,6 @@ export default {
             color: #999999;
         }
 
-        &.first {
-            margin-right: 32rpx;
-        }
-
         .user-head {
             position: absolute;
             left: -2rpx;
@@ -67,7 +90,7 @@ export default {
         text {
             @extend .flex-center-box;
             position: absolute;
-            left: -20rpx;
+            left: -12rpx;
             top: 0;
             z-index: 2;
             width: 56rpx;

+ 5 - 3
pages/fight-order/fight-detail.vue

@@ -12,7 +12,7 @@
 
             <!-- 成功 -->
             <template v-if="success">
-                <user-list :status="success"></user-list>
+                <user-list :memberNum="collageData.memberNum" :existNum="collageData.existNum"></user-list>
             </template>
             <!-- 等待完成 -->
             <template v-else>
@@ -34,7 +34,7 @@
             <template v-if="!success">
                 <view class="grid"></view>
                 <!-- 拼单用户列表 -->
-                <user-list :status="success"></user-list>
+                <user-list :memberNum="collageData.memberNum" :existNum="collageData.existNum"></user-list>
                 <view class="line"></view>
                 <view class="goods-info">
                     <image :src="collageData.productImage" class="cover"></image>
@@ -83,7 +83,7 @@ export default {
         this.fetchOrderDetails()
     },
     onShow() {
-      !isRequest && this.countDown()  
+      !this.isRequest && this.countDown()  
     },
     onShareAppMessage(e) {
         const shareData = {
@@ -93,6 +93,8 @@ export default {
         }
 
         const state_str = encodeURIComponent(this.$crypto.encrypt(shareData))
+        console.log(state_str)
+        
         return {
             title: '哈喽,赶快来参团吧!这件商品拼团买更便宜~',
             path: `/pages/tabBar/index/index?state_str=${state_str}`,

+ 70 - 21
pages/fight-order/fight-share-entry.vue

@@ -18,7 +18,10 @@
 
             <view class="grid t0b48"></view>
 
-            <view class="fight-tip">还差<text>1</text>人,赶快邀请好友来拼单吧!</view>
+            <view class="fight-tip"
+                >还差<text>{{ collageData.needNum }}</text
+                >人,赶快邀请好友来拼单吧!</view
+            >
             <!-- 倒计时 -->
             <countdown-box :countDownTime="countDownTime"></countdown-box>
 
@@ -27,7 +30,7 @@
 
             <view class="grid t48b48"></view>
             <!-- 拼单用户列表 -->
-            <user-list></user-list>
+            <user-list :memberNum="collageData.memberNum" :existNum="collageData.existNum"></user-list>
             <view class="line"></view>
             <view class="goods-info">
                 <image :src="collageData.productImage" class="cover"></image>
@@ -43,7 +46,12 @@
                     <view class="right">
                         <view class="number">
                             <text>数量:</text>
-                            <cm-number-box v-model="count" :min="1" :max="2"></cm-number-box>
+                            <cm-number-box
+                                v-model="count"
+                                :min="1"
+                                :max="collageData.limitedNum"
+                                :defaultVal="count"
+                            ></cm-number-box>
                         </view>
                         <view class="single-price">
                             <text>单价:¥</text> <text class="price">{{ collageData.price | formatPrice }}</text>
@@ -53,6 +61,18 @@
                 <view class="btn" @click="buyGroupNow">确认</view>
             </view>
         </cm-drawer>
+
+        <!-- 操作弹窗 -->
+        <tui-modal
+            :show="modal"
+            :content="modalText"
+            :size="32"
+            :maskClosable="false"
+            color="#333"
+            shape="circle"
+            @click="handleModalConfirm"
+            :button="modalButton"
+        ></tui-modal>
     </view>
 </template>
 
@@ -72,7 +92,11 @@ export default {
         CmNumberBox
     },
     computed: {
-        ...mapGetters(['userId', 'hasLogin'])
+        ...mapGetters(['userId', 'hasLogin']),
+        // 自定义标签
+        tagsList() {
+            return [`${this.collageData.memberNum}人拼团价`]
+        }
     },
     data() {
         return {
@@ -80,14 +104,32 @@ export default {
             collageId: '',
             initiatorId: '',
             collageData: {},
-            // 自定义标签
-            tagsList: ['2人拼团价'],
             // 倒计时
             countDownTime: {},
             timer: null,
             // 商品数量
             count: 1,
-            countVisible: false
+            countVisible: false,
+
+            modal: false,
+            modalText: '您已经参加过该拼团活动了,请前往订单详情查看订单',
+            modalButton: [
+                {
+                    text: '取消',
+                    type: 'danger',
+                    plain: true //是否空心
+                },
+                {
+                    text: '前往查看',
+                    type: 'danger',
+                    plain: false
+                }
+            ]
+        }
+    },
+    watch: {
+        hasLogin() {
+            this.fetchOrderDetails()
         }
     },
     beforeDestroy() {
@@ -124,12 +166,11 @@ export default {
     onLoad(options) {
         this.collageId = options.collageId
         this.initiatorId = options.initiatorId
-        setTimeout(()=>{
-            this.fetchOrderDetails()
-        }, 2000)
+        this.fetchOrderDetails()
     },
     onShow() {
-      !this.isRequest && this.countDown()  
+        !this.isRequest && this.countDown()
+        this.fetchOrderDetails()
     },
     methods: {
         handleClick(type) {
@@ -145,14 +186,22 @@ export default {
                 return
             }
 
-            if (this.userId == this.initiatorId) {
-                this.$util.msg('您不能参与自己发起的拼团')
+            if (this.collageData.orderId > 0) {
+                this.modal = true
                 return
             }
 
             this.countVisible = true
         },
 
+        handleModalConfirm(e) {
+            if (!e.index) return (this.modal = false)
+            console.log('查看订单')
+            uni.redirectTo({
+                url: `/pages/order/order-detail?orderId=${this.collageData.orderId}`
+            })
+        },
+
         // 拼团购买
         buyGroupNow() {
             console.log('拼团购买')
@@ -166,7 +215,7 @@ export default {
                 collageId: this.collageId
             }
             uni.setStorageSync('commitProductInfo', productStp)
-            this.$api.navigateTo('/pages/order/create-order?type=prodcut')
+            uni.redirectTo({ url: '/pages/order/create-order?type=prodcut' })
             this.countVisible = false
         },
 
@@ -189,13 +238,13 @@ export default {
             }).then(res => {
                 this.collageData = res.data
                 // 拼团已完成
-                if (this.collageData.orderId) {
-                    this.$util.msg('拼团已结束')
-                    setTimeout(() => {
-                        uni.switchTab({ url: '/pages/tabBar/index/index' })
-                    }, 2000)
-                    return
-                }
+                // if (this.collageData.status === 2) {
+                //     this.$util.msg('拼团已结束')
+                //     setTimeout(() => {
+                //         uni.switchTab({ url: '/pages/tabBar/index/index' })
+                //     }, 2000)
+                //     return
+                // }
                 // 拼团未完成
                 this.countDown()
                 this.isRequest = false

+ 2 - 1
pages/order/create-order.vue

@@ -244,7 +244,7 @@ export default {
 		orderPaySuccess(){
 			this.$on('orderPaySuccess', ()=>{
 			    if(this.collageFlag === 1){
-			        uni.redirectTo({ url: '/pages/fight-order/fight-detail' })
+			        uni.redirectTo({ url: `/pages/fight-order/fight-detail?collageId=${this.collageId}` })
 			    }else{
 			        uni.redirectTo({ url: '/pages/order/success' })
 			    }
@@ -423,6 +423,7 @@ export default {
                 .then(response => {
                     const data = response.data
                     this.hanldOrder.order = response.data
+                    this.collageId = data.collageId
                     if (parseFloat(data.payableAmount) === 0) {
                         uni.setStorageSync('orderInfo', this.hanldOrder.order)
                         uni.redirectTo({ url: '/pages/user/order/success' })

+ 13 - 0
pages/order/error.vue

@@ -41,6 +41,7 @@ export default {
 	},
 	onLoad() {
 		this.initOrderInfo()
+        this.orderPaySuccess()
 	},
 	computed: {
 		...mapGetters(['isIphoneX']),
@@ -51,6 +52,18 @@ export default {
 		}
 	},
 	methods: {
+        // 支付回调执行函数
+        orderPaySuccess(){
+        	this.$on('orderPaySuccess', ()=>{
+                const orderInfo = this.hanldOrder.order
+        	    if(orderInfo.collageId > 0){
+        	        uni.redirectTo({ url: `/pages/fight-order/fight-detail?collageId=${orderInfo.collageId}` })
+        	    }else{
+        	        uni.redirectTo({ url: '/pages/order/success' })
+        	    }
+        	})
+        },
+        
 		initOrderInfo() {
 			this.orderInfo = uni.getStorageSync('orderInfo')
 			uni.removeStorageSync('orderInfo')

+ 3 - 1
pages/order/mixins/wechatPay.js

@@ -56,12 +56,14 @@ const wechatPay = {
                 // 处理支付信息 调用微信支付
                 const payment = JSON.parse(response.data.data.payInfo)
                 const payFlag = await wxRequestPayment(payment)
+                // debugger
+                // console.log(this.hanldOrder)
                 // 支付成功重定向
                 uni.setStorageSync('orderInfo', this.hanldOrder.order)
                 
                 if (payFlag) {
                     // 微信支付成功回调 在页面onload中通过this.$on监听orderPaySuccess事件回调
-                    this.$emit('orderPaySuccess')
+                    this.$emit('orderPaySuccess', this.hanldOrder.order)
                 } else {
                     uni.reLaunch({ url: '/pages/order/error' })
                 }

+ 15 - 0
pages/order/order-detail.vue

@@ -125,11 +125,26 @@ export default {
 		this.$on('orderAction', () => {
 			this.getOrderDetail()
 		})
+        this.orderPaySuccess()
 	},
 	beforeDestroy(){
 		this.$off('orderAction')
 	},
 	methods: {
+        // 支付回调执行函数
+        orderPaySuccess(){
+        	this.$on('orderPaySuccess', ()=>{
+                const orderInfo = this.hanldOrder.order
+                this.getOrderDetail()
+        	    if(orderInfo.collageFlag){
+        	        uni.navigateTo({ url: `/pages/fight-order/fight-detail?collageId=${orderInfo.collageId}` })
+        	    }else{
+        	        uni.redirectTo({ url: '/pages/order/success' })
+        	    }
+        	})
+        },
+        
+        
 		getOrderDetail() {
 			this.OrderService.QueryOrderDetails({ orderId: this.orderId })
 				.then(res => {

+ 18 - 2
pages/order/order-list.vue

@@ -86,7 +86,7 @@
 							<view class="total">
 								<view class="count">共{{ orderInfo.productCount }}件商品</view>
 								<view class="status">
-									<template v-if="['31', '32', '33', '82', '83'].includes(orderInfo.status)">
+									<template v-if="['31', '32', '33', '81', '82', '83'].includes(orderInfo.status)">
 										<text class="label">已支付:</text>
 										<text>¥{{ orderInfo.receiptAmount | formatPrice }}</text>
 									</template>
@@ -250,12 +250,16 @@ export default {
 			}
 		}
 	},
+    onShow() {
+        this.resetOrderList()
+    },
 	onLoad(options) {
 		this.currentTab = options.state
 		this.fetchOrderData()
 		this.$on('orderAction', () => {
 			this.resetOrderList()
 		})
+        this.orderPaySuccess()
 	},
 	// 下拉刷新
 	onPullDownRefresh() {
@@ -265,8 +269,20 @@ export default {
 		this.$off('orderAction')
 	},
     
-    
 	methods: {
+        // 支付回调执行函数
+        orderPaySuccess(){
+        	this.$on('orderPaySuccess', ()=>{
+                const orderInfo = this.hanldOrder.order
+                this.resetOrderList()
+        	    if(orderInfo.collageFlag){
+        	        uni.navigateTo({ url: `/pages/fight-order/fight-detail?collageId=${orderInfo.collageId}` })
+        	    }else{
+        	        uni.redirectTo({ url: '/pages/order/success' })
+        	    }
+        	})
+        },
+        
 		// 导航栏初始化
 		headerNavInit(info){
 			this.headerNavHeight = info.height

+ 1 - 3
pages/order/order-search.vue

@@ -193,9 +193,7 @@ export default {
 		this.fetchOrderData()
 	},
 	onLoad() {
-		setTimeout(() => {
-			this.fetchSerachRecord()
-		}, 2000)
+		this.fetchSerachRecord()
 		this.$on('orderAction', () => {
 			this.resetOrderList()
 		})