Przeglądaj źródła

修改优惠券。

付晓文。 2 miesięcy temu
rodzic
commit
5bc0625dce

+ 74 - 103
pages/coupon/coupon.vue

@@ -25,18 +25,18 @@
 				</view>
 			</view>
 		</view>
-		<mescroll-uni class="list" :fixed="false" ref="mescrollRef" @up="getList" @init="mescrollInit" :use="false">
+		<mescroll-uni class="list" :fixed="false" ref="mescrollRef" @up="getList1" @down="downCallback" @init="mescrollInit" :use="false">
 
 			<!-- 代金券列表 -->
 			<view class="coupon-card" v-for="(item, index) in dataList[`couponList${currentTab}`]" :key="item.id"
 				@click="handleDetail(item.id)" :class="{ 'disabled': item.status === 'expired' }">
 				<!-- 顶部标题栏 -->
 				<view class="card-header"
-					:style="currentTab == 0 ? 'background: #EFFFFE' : currentTab == 1 ? 'background: #F4FAFF ' : 'background: #FFF7F3'">
+					:style="currentTab == 0 ? 'background: #F4FAFF ' : 'background: #FFF7F3'">
 					<image style=" vertical-align: top" :src="`/static/coupon/titlebg${currentTab + 1}.png`" mode="">
 					</image>
 					<view class="status" v-if="item.delFlag == '1'"
-						:style="currentTab == 0 ? 'color: #2DAC9F' : currentTab == 1 ? 'color: #4183BC' : 'color: #DB6332'">
+						:style="currentTab == 0 ? 'color: #4183BC' : 'color: #DB6332'">
 						销售中
 					</view>
 					<view class="status" v-else>{{ item.delFlag == '0' ? '待上架' : item.delFlag == '3' ? '已失效' : '' }}
@@ -45,19 +45,15 @@
 				<view class="flex" style="padding: 14rpx 18rpx;">
 					<!-- 优惠券金额 -->
 					<view class="amount-section">
-						<text class="amount" v-if="currentTab == 0">{{ item.parValue }}</text>
-						<text class="amount" v-else :style="currentTab == 1 ? 'color: #278BE5' : 'color: #FB5308'">{{
+						<text class="amount" :style="currentTab == 0 ? 'color: #278BE5' : 'color: #FB5308'">{{
                             item.contentInfo }}</text>
-						<text class="unit" v-if="currentTab == 2">折</text>
+						<text class="unit" v-if="currentTab == 1">折</text>
 						<text class="unit" v-else>元</text>
-						<view class="use-condition" v-if="currentTab == 0 && item.voucherWay == '1'">售价{{
-                            item.voucherWayInfo
-                            }}元</view>
-						<view class="use-condition" v-if="currentTab == 1 && item.contentConditions !== '0'">满{{
+						<view class="use-condition" v-if="currentTab == 0 && item.contentConditions !== '0'">满{{
                             item.contentConditions }}元可抵扣</view>
-						<view class="use-condition" v-if="currentTab == 2 && item.contentConditions !== '0'">满{{
+						<view class="use-condition" v-if="currentTab == 1 && item.contentConditions !== '0'">满{{
                             item.contentConditions }}元可使用</view>
-						<view class="use-condition" v-if="currentTab !== 0 && item.contentConditions == '0'">不限制条件使用
+						<view class="use-condition" v-if="item.contentConditions == '0'">不限制条件使用
 						</view>
 					</view>
 
@@ -65,19 +61,13 @@
 					<view class="info-section">
 						<view class="info-item">
 							<text class="dot">•</text>
-							<text class="label" v-if="currentTab == 0">获取方式:</text>
-							<text class="label" v-else>领取限制:</text>
-							<text class="value" v-if="currentTab == 0">{{ item.voucherWay == '1' ? '购买' : '消费满' +
-                                item.voucherWayInfo + '元可领取' }}</text>
-							<text class="value" v-else>{{ item.couponWay == '1' ? '所有人可领取' : '本店消费可领' }}</text>
+							<text class="label">领取限制:</text>
+							<text class="value">{{ item.couponWay == '1' ? '所有人可领取' : '本店消费可领' }}</text>
 						</view>
 						<view class="info-item">
 							<text class="dot">•</text>
-							<text class="label" v-if="currentTab == 0">使用条件:</text>
-							<text class="label" v-else>适用范围:</text>
-							<text class="value" v-if="currentTab == 0">{{ item.conditions == '0' ? '不限制' : '最低消费' +
-                                item.conditions + '元' }}</text>
-							<text class="value" v-else>{{
+							<text class="label">适用范围:</text>
+							<text class="value">{{
                                 item.couponRange == '1' ? '本店可用' : item.couponRange == '2' ? '部分分类商品可用' : '部分分类商品不可用'
                                 }}</text>
 						</view>
@@ -91,9 +81,8 @@
 
 				<!-- 数量统计 -->
 				<view class="stats-section flex"
-					:class="currentTab == 0 ? 'backg-color1' : currentTab == 1 ? 'backg-color2' : 'backg-color3'">
-					<text class="stat-item" v-if="currentTab == 0 && item.voucherWay == '1'">已购买:{{ item.payNumber }}</text>
-					<text class="stat-item" v-else>已领取:{{ item.payNumber }}</text>
+					:class="currentTab == 0 ? 'backg-color2' : 'backg-color3'">
+					<text class="stat-item">已领取:{{ item.payNumber }}</text>
 					<text class="stat-item">已使用:{{ item.useNumber }}</text>
 					<text class="stat-item">总库存:{{ item.number }}</text>
 				</view>
@@ -103,7 +92,7 @@
 					<text class="action-btn" v-if="item.delFlag == '0' || item.delFlag == '3'"
 						@click.stop="handleAction('up', item)">上架</text>
 					<text class="action-btn" v-if="item.delFlag == '1'" @click.stop="handleAction('down', item)">下架</text>
-					<text class="action-btn" v-if="item.delFlag == '1' && item.voucherWay !== 1"
+					<text class="action-btn" v-if="item.delFlag == '1'"
 						@click.stop="handleAction('grant', item)">发放</text>
 					<text class="action-btn" v-if="item.delFlag == '0' || item.delFlag == '3'"
 						@click.stop="handleEdit(item.id)">编辑</text>
@@ -180,6 +169,8 @@
 				reductionList: [],
 				discountList: [],
 				selectRow: {},
+				listRequestId: 0,
+				isFirstShow: true,
 				upOption: {
 					page: {
 						num: 0,
@@ -196,45 +187,43 @@
 			closePaymentPopup() {
 				this.showPaymentPopup = false
 			},
-			getList(page) {
-				this.$http.post('/merchant/localVoucherInfo/list', {
+			getList1(page) {
+				const tab = this.currentTab
+				const listKey = 'couponList' + tab
+				const requestId = this.listRequestId
+				this.$http.post('/merchant/localCouponInfo/list', {
 					merchantId: uni.getStorageSync(USER_INFO).merchantId,
+					type: tab + 1,
 					pageSize: page.size,
 					pageNo: page.num
 				}).then(res => {
+					if (requestId !== this.listRequestId || tab !== this.currentTab) return
 					if (res.data.success) {
-						if (res.data.result.records == null && page.num == 1) {
-							this.dataList.couponList0 = []
+						const records = res.data.result.records || []
+						if (page.num === 1) {
+							this.dataList[listKey] = records
 						} else {
-							this.dataList.couponList0 = res.data.result.pages ? this.dataList.couponList0.concat(res.data.result
-								.records) : this.dataList.couponList0
+							this.dataList[listKey] = this.dataList[listKey].concat(records)
 						}
-
-						this.mescroll.endSuccess(res.data.result.records.length, res.data.result.total);
+						this.mescroll.endSuccess(records.length, res.data.result.total)
 						uni.showTabBar()
 					} else {
-						this.dataList.couponList0 = []
+						if (page.num === 1) {
+							this.dataList[listKey] = []
+						}
 						this.mescroll.endErr()
+						this.$tip.error(res.data.message)
 					}
 				}).catch(() => {
-					this.mescroll.endErr()
-				})
-			},
-			getList1(page) {
-				this.$http.post('/merchant/localCouponInfo/list', {
-					merchantId: uni.getStorageSync(USER_INFO).merchantId,
-					type: this.currentTab,
-					pageSize: page.size,
-					pageNo: page.num
-				}).then(res => {
-					if (res.data.success) {
-						this.dataList['couponList' + this.currentTab] = res.data.result.pages ? this.dataList['couponList' + this
-							.currentTab].concat(res.data.result.records) : this.dataList['couponList' + this.currentTab]
-					} else {
-						this.$tip.error(res.data.message);
+					if (requestId === this.listRequestId) {
+						this.mescroll.endErr()
 					}
 				})
 			},
+			downCallback() {
+				this.dataList['couponList' + this.currentTab] = []
+				this.mescroll.resetUpScroll()
+			},
 			//返回
 			back() {
 				uni.navigateBack({
@@ -252,27 +241,16 @@
 						content: type == 'up' ? '当前优惠券确定上架?' : '当前优惠券确定下架?',
 						success: (res) => {
 							if (res.confirm) {
-								let upDown = ['/merchant/localVoucherInfo/editUpper', '/merchant/localCouponInfo/editUpper',
-									'/merchant/localCouponInfo/editUpper'
-								]
-								this.$http.get(upDown[this.currentTab], {
+								this.$http.get('/merchant/localCouponInfo/editUpper', {
 									params: {
 										id: item.id,
 										delFlag: type == 'up' ? '1' : '0'
 									}
 								}).then(res => {
 									if (res.data.success) {
-										let page = {
-											num: 1,
-											size: 10
-										}
-										if (this.currentTab == 0) {
-											this.dataList.couponList0 = []
-											this.getList(page)
-										} else {
-											this.dataList['couponList' + this.currentTab] = []
-											this.getList1(page)
-										}
+										this.listRequestId++
+										this.dataList['couponList' + this.currentTab] = []
+										this.mescroll && this.mescroll.resetUpScroll()
 									} else {
 										if (res.data.message == "当前优惠卷上架需重新设置有效时间") {
 											this.showPaymentPopup = true
@@ -302,7 +280,7 @@
 					beginTime: this.selectRow.beginTime,
 					endTime: this.selectRow.endTime,
 					consumerId: this.selectRow.id,
-					type: this.currentTab == '0' ? '3' : this.currentTab
+					type: String(this.currentTab + 1)
 				}
 				if (e[0].value == 1) {
 					uni.navigateTo({
@@ -317,17 +295,29 @@
 			},
 			manage() {
 				
-				if (this.currentTab == '0') {
-					uni.navigateTo({
-						url: '/pages/coupon/creatcoupon'
-					})
-				}
-				if (this.currentTab == '1') {
+				// if (this.currentTab == '0') {
+				// 	uni.navigateTo({
+				// 		url: '/pages/coupon/creatcoupon'
+				// 	})
+				// }
+				// if (this.currentTab == '1') {
+				// 	uni.navigateTo({
+				// 		url: '/pages/coupon/creatReduction'
+				// 	})
+				// }
+				// if (this.currentTab == '2') {
+				// 	uni.navigateTo({
+				// 		url: '/pages/coupon/creatDiscount'
+				// 	})
+				// }
+				
+				
+				if (this.currentTab == 0) {
 					uni.navigateTo({
 						url: '/pages/coupon/creatReduction'
 					})
 				}
-				if (this.currentTab == '2') {
+				if (this.currentTab == 1) {
 					uni.navigateTo({
 						url: '/pages/coupon/creatDiscount'
 					})
@@ -336,22 +326,11 @@
 
 			},
 			onTabChange(index) {
-				this.dataList={
-					couponList0: [],
-					couponList1: [],
-					couponList2: [],
-				}
-				let page = {
-					num: 1,
-					size: 10
-				}
+				if (this.currentTab === index) return
+				this.listRequestId++
 				this.currentTab = index
-				if (index == 0) {
-					this.getList(page)
-				} else {
-					this.getList1(page)
-
-				}
+				this.dataList['couponList' + index] = []
+				this.mescroll && this.mescroll.resetUpScroll()
 			},
 			// 详情
 			handleDetail(id) {
@@ -363,18 +342,12 @@
 				this.mescroll = mescroll;
 			},
 			handleEdit(id) {
-				// TODO: 实现编辑逻辑
-				if (this.currentTab == '0') {
-					uni.navigateTo({
-						url: `/pages/coupon/creatcoupon?id=${id}`
-					})
-				}
-				if (this.currentTab == '1') {
+				if (this.currentTab == 0) {
 					uni.navigateTo({
 						url: `/pages/coupon/creatReduction?id=${id}`
 					})
 				}
-				if (this.currentTab == '2') {
+				if (this.currentTab == 1) {
 					uni.navigateTo({
 						url: `/pages/coupon/creatDiscount?id=${id}`
 					})
@@ -390,14 +363,12 @@
 			}
 		},
 		onShow() {
-			let page = {
-				num: 1,
-				size: 10
-			}
 			this.showPaymentPopup = false
-			// if (this.currentTab == 1 || this.currentTab == 2) {
-			// 	this.getList1(page)
-			// }
+			if (this.isFirstShow) {
+				this.isFirstShow = false
+				return
+			}
+			this.mescroll && this.mescroll.resetUpScroll()
 		},
 	}
 </script>

+ 15 - 7
pages/product/index.vue

@@ -313,7 +313,9 @@ export default {
 					if (item.select) {
 						this.sellProducts.push({
 							productId: item.productId,
-							productStatus: status
+							productStatus: status,
+							productType:this.tabIndex
+							// productType = 自有或者标品(1: 标品, 0: 自有
 						})
 					}
 
@@ -324,7 +326,9 @@ export default {
 					if (item.select) {
 						this.delistList.push({
 							productId: item.productId,
-							productStatus: status
+							productStatus: status,
+							productType:this.tabIndex
+							// productType = 自有或者标品(1: 标品, 0: 自有
 						})
 					}
 
@@ -414,7 +418,9 @@ export default {
 
 			this.delistList.push({
 				productId: item.productId,
-				productStatus: 0
+				productStatus: 0,
+				productType:this.tabIndex
+				// productType = 自有或者标品(1: 标品, 0: 自有
 			})
 			this.isDelist = true
 		},
@@ -426,7 +432,7 @@ export default {
 						this.getProductList()
 						this.getStatus()
 						uni.showToast({
-							title: '下架成功',
+							title: res.data.message,
 							duration: 2000,
 							icon: 'none'
 						});
@@ -455,8 +461,10 @@ export default {
 			// } else {
 				this.sellProducts.push({
 					productId: item.productId,
-					// productStatus: 1,
-					productStatus: 2
+					productStatus: 1,
+					// productStatus: 2
+					productType:this.tabIndex
+					// productType = 自有或者标品(1: 标品, 0: 自有
 				})
 				this.isSell = true
 			// }
@@ -469,7 +477,7 @@ export default {
 						this.getProductList()
 						this.getStatus()
 						uni.showToast({
-							title: '上架成功',
+							title: res.data.message,
 							duration: 2000,
 							icon: 'none'
 						});

BIN
static/coupon/titlebg1.png


BIN
static/coupon/titlebg2.png


BIN
static/coupon/titlebg3.png