From 05bd41aab8c9dba2cf7afcd78493415761f11d9d Mon Sep 17 00:00:00 2001
From: xuxueyang <xuxy@fengyuntec.com>
Date: 星期四, 26 九月 2024 08:54:08 +0800
Subject: [PATCH] update 供应商刷新问题

---
 sub_pages/customer/coupon/good-self.vue |  174 +++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 149 insertions(+), 25 deletions(-)

diff --git a/sub_pages/customer/coupon/good-self.vue b/sub_pages/customer/coupon/good-self.vue
index 0813670..99322d7 100644
--- a/sub_pages/customer/coupon/good-self.vue
+++ b/sub_pages/customer/coupon/good-self.vue
@@ -1,42 +1,70 @@
 <template>
 	<view class="coupon-container">
-		<view class="p10">
+		<view class="p10" v-if="source!=='shopping'">
 			<top-tabs :tabs="tabs" :flg="flg" @change="changeTab" type="coupon">
 
 			</top-tabs>
 		</view>
-		<view class="">
-			<no-data v-if="!list||list.length==0" style="width: 100%;"></no-data>
+		<no-data v-if="!list||list.length==0" style="width: 100%;"></no-data>
 
-			<view v-for="(item,index) of list" :key="index" class="coupont-item" :class="[query.status]">
-				<view class="flex container img100">
+		<view class="p10">
+
+			<view v-for="(item,index) of list" :key="index" class="good-item" :class="[query.status]">
+				<view class="flex container img100 flex-wrap-normal" @click="selectItem(item)">
 					<view class="info-price">
 						<image :lazy-load="true" :src="item.cover" class="cover" mode="scaleToFill"></image>
 					</view>
-					<view class="info flex1">
-						<view class="title">
-							{{item.name||''}}
+					<view class="info flex1 ">
+						<view class="title flex description">
+							<view style="max-width: 420rpx;word-break: break-all;" class="word-e" >{{item.name||''}}</view>
+							<!-- <radio :checked="isIngood(item)" @click.stop="updateSelectGood(item)" v-if="source==='shopping'" class="select-coupon"></radio> -->
+
+							<view :style="{ 'margin-right': '20rpx'}" class="component-radio m-l-a "
+								:class="[isIngood(item)?'cur':'']" v-if="source==='shopping'">
+
+							</view>
+
 						</view>
-						<view class="time word-e">
+						<view class="time word-e" style="word-break: break-all;max-width: 360rpx;">
 							{{item.description||''}}
 						</view>
-						<view class="button" @click="getPointGood(item)">
+						<view class="time word-e" style="font-size: 22rpx;" v-if="item.expireTime">
+							截止:{{item.expireTime||'-'}}
+						</view>
+						
+						<view class="button m-l-a m-r-10" v-if="source!=='shopping'">
 							查看详情
 						</view>
+						<!-- 		<view class="button" @click="updateSelectGood(item)" v-if="source=='shopping'">
+							{{isIngood(item)?'移除':'添加'}}
+						</view> -->
 					</view>
 				</view>
-				<view class="tip">
-					<span class="t-red">*</span>此券每人限领1张。仅限用于花满芜鲜花交易平台鲜切花花款满额使用,不可与其他优惠同享、不可叠加使用
-				</view>
+				<!-- 	<view class="tip">
+					<span class="t-red">*</span>此券每人限领1张。仅限用于花满芫鲜花交易平台鲜切花花款满额使用,不可与其他优惠同享、不可叠加使用
+				</view> -->
 			</view>
 		</view>
-		<!-- <view style="min-height: 130rpx;"></view> -->
+		<view style="min-height: 140rpx;" v-if="source=='shopping'"></view>
+		<view class="bottom-button" @click="backpage()" v-if="source=='shopping'">确定选择</view>
+
 		<!-- <view class="bottom-button" @click="toGoodAll">前往兑换</view> -->
 	</view>
 </template>
 
 <script>
+	import {
+		mapState
+	} from 'vuex'
 	export default {
+		computed: {
+			...mapState({
+				cache_goods: state => {
+					return state.cache.goods || []
+				},
+			}),
+		},
+
 		data() {
 			return {
 				flg: 0,
@@ -62,16 +90,77 @@
 				query: {
 					status: 'A'
 				},
-				list: []
+				list: [],
+				source: ''
+
 			}
 		},
-		async onLoad() {
-			this.listApi = '/api/customer/point/goods/exchange/list'
+		onReachBottom() {
+			this.getMore()
+		},
+		async onLoad(options) {
+			if (options.source) {
+				this.source = options.source || ''
+			}
+			if (this.source === 'shopping') {
+				//只展示可用的
+				this.page.size = 100
+				this.listApi = '/api/customer/point/goods/exchange/list'
+			} else {
+				this.listApi = '/api/customer/point/goods/exchange/list'
+			}
 
 			this.getList()
 		},
 
 		methods: {
+			selectItem(item) {
+				if (this.source === 'shopping') {
+					//选择
+					this.updateSelectGood(item)
+				} else {
+					//详情
+					this.getPointGood(item)
+				}
+			},
+			isIngood(item) {
+				for (var tmp of this.cache_goods) {
+					if (tmp.id == item.id) {
+						return true
+					}
+				}
+
+				return false
+			},
+			async updateSelectGood(item) {
+				var has = false
+				for (var tmp of this.cache_goods) {
+					if (tmp.id == item.id) {
+						has = true
+						break
+					}
+				}
+				var arr = []
+
+				if (has) {
+					//移除
+					var arr = []
+					for (var tmp of this.cache_goods) {
+						if (tmp.id == item.id) {} else {
+							arr.push(tmp)
+						}
+					}
+				} else {
+					//添加
+					for (var tmp of this.cache_goods) {
+						arr.push(tmp)
+					}
+					arr.push(item)
+				}
+				await this.$store.dispatch('cache_goods_select', arr)
+				this.$forceUpdate()
+
+			},
 			changeTab(flg) {
 				this.flg = '' + flg
 				this.query.status = this.tabs[flg].status
@@ -79,7 +168,7 @@
 			},
 			getPointGood(item) {
 				uni.navigateTo({
-					url: `/sub_pages/customer/coupon/good-detail?id=${item.id}`
+					url: `/sub_pages/customer/coupon/good-detail?id=${item.goodsId}`
 				})
 			},
 			toGoodAll() {
@@ -106,21 +195,52 @@
 	@import './coupon.scss';
 
 	.coupon-container {
-		.coupont-item {
+		.good-item {
+			height: unset;
+			padding: 20rpx;
+			margin-top: 0rpx;
+
 			.container {
-				background-image: unset;
+				background-color: #fff;
 
 				.info-price {
 					.cover {
-						width: 150rpx;
-						height: 150rpx;
+						width: 160rpx;
+						height: 160rpx;
 					}
 				}
 
 				.info {
-					.time {
-						margin-top: 0rpx;
+					margin-left: 20rpx;
+					position: relative;
+
+					.title {
+						font-weight: 600;
+						font-size: 32rpx;
+						color: #333333;
+						line-height: 40rpx;
+						text-align: left;
+						position: relative;
+						margin-top: 10rpx;
+
+						.select-coupon {
+							position: absolute;
+							right: 10rpx;
+							top: -6rpx;
+						}
 					}
+
+					.time {
+						font-weight: 400;
+						font-size: 28rpx;
+						color: #666666;
+						line-height: 40rpx;
+						text-align: left;
+						margin-top: 10rpx;
+						word-break: break-all;
+					}
+
+
 
 					.button {
 						width: 150rpx;
@@ -133,7 +253,10 @@
 						color: rgba(68, 119, 90, 1);
 						line-height: 46rpx;
 						text-align: center;
-						margin-top: 10rpx;
+						// margin-top: 10rpx;
+						position: absolute;
+						right: 10rpx;
+						bottom: 20rpx;
 					}
 				}
 			}
@@ -155,6 +278,7 @@
 			color: #20613D;
 			text-align: center;
 			line-height: 90rpx;
+			background-color: #fff;
 		}
 	}
 </style>
\ No newline at end of file

--
Gitblit v1.9.3