瀏覽代碼

修改优惠价部分-添加-删除;跳转

付晓文。 2 月之前
父節點
當前提交
a35a0c864d
共有 5 個文件被更改,包括 66 次插入32 次删除
  1. 5 4
      pages/coupon/coupon.vue
  2. 24 9
      pages/coupon/couponDetail.vue
  3. 15 9
      pages/coupon/creatDiscount.vue
  4. 15 8
      pages/coupon/creatReduction.vue
  5. 7 2
      pages/coupon/usersList.vue

+ 5 - 4
pages/coupon/coupon.vue

@@ -82,7 +82,7 @@
 				<!-- 数量统计 -->
 				<view class="stats-section flex"
 					:class="currentTab == 0 ? 'backg-color2' : 'backg-color3'">
-					<text class="stat-item">已领取:{{ item.payNumber }}</text>
+					<text class="stat-item">已领取:{{ item.receivedCount }}</text>
 					<text class="stat-item">已使用:{{ item.useNumber }}</text>
 					<text class="stat-item">总库存:{{ item.number }}</text>
 				</view>
@@ -193,7 +193,7 @@
 				const requestId = this.listRequestId
 				this.$http.post('/merchant/localCouponInfo/list', {
 					merchantId: uni.getStorageSync(USER_INFO).merchantId,
-					type: tab + 1,
+					type: Number(tab) + Number(1),
 					pageSize: page.size,
 					pageNo: page.num
 				}).then(res => {
@@ -356,8 +356,8 @@
 			}
 		},
 		onLoad(options) {
-			if (options && options.tab) {
-				this.currentTab = options.tab
+			if (options && options.tab !== undefined && options.tab !== '') {
+				this.currentTab = Number(options.tab)
 			} else {
 				this.currentTab = 0
 			}
@@ -368,6 +368,7 @@
 				this.isFirstShow = false
 				return
 			}
+			this.dataList['couponList' + this.currentTab] = []
 			this.mescroll && this.mescroll.resetUpScroll()
 		},
 	}

+ 24 - 9
pages/coupon/couponDetail.vue

@@ -78,7 +78,7 @@
                 <view class="stats-section flex"
                     :class="currentTab == 0 ? 'backg-color1' : currentTab == 1 ? 'backg-color2' : 'backg-color3'">
                     <text class="stat-item" v-if="currentTab == 0">已购买:{{ couponList.payNumber }}</text>
-                    <text class="stat-item" v-else>已领取:{{ couponList.payNumber }}</text>
+                    <text class="stat-item" v-else>已领取:{{ couponList.receivedCount }}</text>
                     <text class="stat-item">已使用:{{ couponList.useNumber }}</text>
                     <text class="stat-item">总库存:{{ couponList.number }}</text>
                 </view>
@@ -185,6 +185,19 @@ export default {
                 delta: 1
             });
         },
+        goCouponList() {
+            const listTab = Number(this.currentTab) > 0 ? Number(this.currentTab) - 1 : 0
+            setTimeout(() => {
+                const pages = getCurrentPages()
+                if (pages.length > 1) {
+                    uni.navigateBack()
+                } else {
+                    uni.redirectTo({
+                        url: `/pages/coupon/coupon?tab=${listTab}`
+                    })
+                }
+            }, 500)
+        },
         deleteFun() {
             uni.showModal({
                 title: '删除优惠券',
@@ -194,10 +207,11 @@ export default {
                         if (this.currentTab == 0) {
                             this.$http.get('/merchant/localVoucherInfo/delete?id=' + this.productId).then(res => {
                                 if (res.data.success) {
-                                    this.$tip.error(res.data.message || '删除成功');
-                                    uni.navigateTo({
-                                        url: `/pages/coupon/coupon`
+                                    uni.showToast({
+                                        title: res.data.message || '删除成功',
+                                        icon: 'none'
                                     })
+                                    this.goCouponList()
                                 }
                                 else {
                                     this.$tip.error(res.data.message);
@@ -205,12 +219,13 @@ export default {
                             })
                         }
                         else {
-                            this.$http.delete('/merchant/localCouponInfo/delete?id=' + this.productId).then(res => {
+                            this.$http.delete(`/merchant/localCouponInfo/delete?id=${this.productId}&type=${this.currentTab}`).then(res => {
                                 if (res.data.success) {
-                                    this.$tip.error(res.data.message || '删除成功');
-                                    uni.navigateTo({
-                                        url: `/pages/coupon/coupon?tab=${this.currentTab}`
+                                    uni.showToast({
+                                        title: res.data.message || '删除成功',
+                                        icon: 'none'
                                     })
+                                    this.goCouponList()
                                 }
                                 else {
                                     this.$tip.error(res.data.message);
@@ -233,7 +248,7 @@ export default {
     onLoad(options) {
         if (options) {
             this.productId = options.id
-            this.currentTab = options.tab
+            this.currentTab = Number(options.tab) || 0
         }
     },
     onShow() {

+ 15 - 9
pages/coupon/creatDiscount.vue

@@ -238,6 +238,19 @@ export default {
 		}
 	},
 	methods: {
+		goBackToList(listTab = 1) {
+			this.$store.state.shopSelectedIds = []
+			setTimeout(() => {
+				const pages = getCurrentPages()
+				if (pages.length > 1) {
+					uni.navigateBack()
+				} else {
+					uni.redirectTo({
+						url: `/pages/coupon/coupon?tab=${listTab}`
+					})
+				}
+			}, 500)
+		},
 		//上传详情图
 		detailsSuccess(res, index, lists) {
 			this.xqImage = lists
@@ -495,11 +508,7 @@ export default {
 								title: '添加成功',
 								icon: 'none'
 							});
-							this.$store.state.shopSelectedIds=[]
-
-							uni.navigateTo({
-								url: '/pages/coupon/coupon'
-							})
+							this.goBackToList(1)
 						}
 						else {
 							this.$tip.error(res.data.message);
@@ -513,10 +522,7 @@ export default {
 								title: '编辑成功',
 								icon: 'none'
 							});
-							this.$store.state.shopSelectedIds=[]
-							uni.navigateTo({
-								url: '/pages/coupon/coupon'
-							})
+							this.goBackToList(1)
 						}
 						else {
 							this.$tip.error(res.data.message);

+ 15 - 8
pages/coupon/creatReduction.vue

@@ -234,6 +234,19 @@ export default {
 		}
 	},
 	methods: {
+		goBackToList(listTab = 0) {
+			this.$store.state.shopSelectedIds = []
+			setTimeout(() => {
+				const pages = getCurrentPages()
+				if (pages.length > 1) {
+					uni.navigateBack()
+				} else {
+					uni.redirectTo({
+						url: `/pages/coupon/coupon?tab=${listTab}`
+					})
+				}
+			}, 500)
+		},
 		 // 阻止键盘弹出
 		    preventKeyboard(e) {
 					 e.preventDefault(); 
@@ -441,10 +454,7 @@ export default {
 								icon: 'none'
 							});
 
-							this.$store.state.shopSelectedIds=[]
-							uni.navigateTo({
-								url: '/pages/coupon/coupon'
-							})
+							this.goBackToList(0)
 						}
 					})
 				} else {
@@ -455,10 +465,7 @@ export default {
 								title: '编辑成功',
 								icon: 'none'
 							});
-							this.$store.state.shopSelectedIds=[]
-							uni.navigateTo({
-								url: '/pages/coupon/coupon'
-							})
+							this.goBackToList(0)
 
 						}
 					})

+ 7 - 2
pages/coupon/usersList.vue

@@ -7,7 +7,7 @@
             :style="currentTab == '0' ? 'background: #EFFFFE' : currentTab == '1' ? 'background: #F4FAFF;' : 'background: #FFF7F3;'">
             <image :src="`/static/coupon/userBg${Number(currentTab) + 1}.png`" mode="">
             </image>
-            <text class="">{{ name }}</text>
+            <text class="coupon-name">{{ name }}</text>
         </view>
 
         <view class="coupon-header">
@@ -154,7 +154,7 @@ position: relative;
         width: 347rpx;
         height: 56rpx;
     }
-    text{
+    .coupon-name {
         position: absolute;
         color: #FFFFFF;
         left: 22rpx;
@@ -162,6 +162,11 @@ position: relative;
         height: 56rpx;
         line-height: 56rpx;
         text-align: center;
+        overflow: hidden;
+        white-space: nowrap;
+        text-overflow: ellipsis;
+        padding: 0 16rpx;
+        box-sizing: border-box;
     }
 }