Browse Source

发布团购bug优化

zhanghui 1 year ago
parent
commit
00859e7230
2 changed files with 34 additions and 52 deletions
  1. 16 33
      pages/groupbuying/publish_good_list/index.vue
  2. 18 19
      pages/groupbuying/publish_group/index.vue

+ 16 - 33
pages/groupbuying/publish_good_list/index.vue

@@ -16,31 +16,6 @@
 					style="height: 100%;" class="conterScroll">
 					<block>
 						<view class='listw' :id="'b' + index">
-							<!-- <view class='title acea-row row-center-wrapper'>
-								<view class='line'></view>
-								<view class='name'>{{ $t(item.cate_name) }}</view>
-								<view class='line'></view>
-							</view> -->
-							<!-- <view class='list acea-row'>
-								<block v-for="(itemn, indexn) in goodsList" :key="indexn">
-									<view hover-class='none' @click="choice(itemn)" class='item acea-row-item row-column row-middle'>
-										<view class='picture'>
-											<image :src='itemn.goodsCover' v-if="itemn.goodsCover"></image>
-											<image src="/static/images/sort-img.png" v-else></image>
-										</view>
-										<view class="p-r">
-											<view class='name line1'>{{ $t(itemn.goodsName) }}</view>
-											<view class="acea-row-item-bArea">
-												<view class='jiage line1'>¥{{itemn.discountPrice}}</view>
-												<view :class="[itemn.selected ? 'selde' : 'noselde']">{{ itemn.selected ? "已选择" : "选择" }}<text
-														:class="[itemn.selected ? 'selde-q' : 'noselde-q']"></text></view>
-											</view>
-										</view>
-									</view>
-								</block>
-							</view> -->
-
-
 							<view class="all-products-body" v-for="(itemn, indexn) in goodsList" :key="indexn">
 						<view class="all-products-item"  @click="choice(itemn)">
 							<image :src='itemn.goodsCover' v-if="itemn.goodsCover"></image>
@@ -117,6 +92,7 @@ export default {
 	},
 	data () {
 		return {
+			vGoodsIdList:[],
 			goodsList: [],
 			selectItem: [],
 			src: 'http://www.gzzhsckj.com:9000/bladex/upload/20221026/5956cfd37ebc31cd2e00797909987482.jpg',
@@ -168,16 +144,23 @@ export default {
 		// #endif
 	},
 	methods: {
-		choice (item) {
 
+		/**
+		 * 父组件调用这个方法,返回选中的商品id数组
+		 * @returns {[]}
+		 */
+		returnVGoodIds(){
+			return this.vGoodsIdList
+		},
+
+		choice (item) {
 			item.selected = !item.selected
-			this.goodsList.splice(0, 0)
-			console.log("item ", item.selected)
-			let data = this.goodsList.filter(e => {
-				return e.selected
-			})
-			// console.log("data ", data)
-			this.$emit('getSelectData', data);
+			if (this.vGoodsIdList.indexOf(item.id) ===-1){
+				this.vGoodsIdList.push(item.id)
+			}else {
+				this.vGoodsIdList = this.vGoodsIdList.filter(iter => iter !== item.id)
+			}
+			console.log(this.vGoodsIdList)
 		},
 		getCategoryOne () {
 			getCategoryOne({

+ 18 - 19
pages/groupbuying/publish_group/index.vue

@@ -44,7 +44,7 @@
 					<view class='item acea-row row-between-wrapper'>
 						<view class='name'>自提点</view>
 						<view @click="openSelfTakeTable()">
-							<input type='text' placeholder='请选择提自提点' name='mainTitle' disabled v-model="ztd"
+							<input type='text' placeholder='请选择提自提点' disabled v-model="ztd"
 								   placeholder-class='placeholder'></input>
 						</view>
 					</view>
@@ -85,13 +85,9 @@
 						</view>
 					</view>
 				</view>
-				<button class="button_1 flex-col" @click="addGood">
+				<button class="button_1 flex-col justify-center" @click="addGood">
 					<text class="text_15">添加商品</text>
 				</button>
-
-
-
-
 				<button class='keepBnt' form-type="submit">保存并提交</button>
 
 			</view>
@@ -103,9 +99,9 @@
 		<home></home>
 		<!-- #endif -->
 
-		<u-popup :show="addGoodPopupShow" @close="close" @open="	">
+		<u-popup :show="addGoodPopupShow" @close="close" @open="">
 			<view>
-				<publish_good_list @getSelectData="getSelectData" v-if="addGoodPopupShow"></publish_good_list>
+				<publish_good_list ref="publish_good_list" @getSelectData="getSelectData" v-if="addGoodPopupShow"></publish_good_list>
 			</view>
 		</u-popup>
 
@@ -258,19 +254,20 @@ export default {
 		},
 		closeTrue(){
 			this.selfTakeShow = false;
+			let _ztd=''
 			console.log(this.grouponReqData.selfTakeIds)
 			this.selfTakeList.forEach(e =>{
 				this.grouponReqData.selfTakeIds.forEach(ee =>{
 					if (e.id === ee){
-						if (this.ztd){
-							this.ztd=this.ztd +','+e.name
+						if (_ztd){
+							_ztd=_ztd +','+e.name
 						}else {
-							this.ztd=e.name
+							_ztd=e.name
 						}
 					}
 				})
 			})
-
+			this.ztd = _ztd
 			console.log(this.ztd)
 
 		},
@@ -306,6 +303,7 @@ export default {
 			this.$refs.mySon.show();
 		},
 		openSelfTakeTable () {
+			this.grouponReqData.selfTakeIds = []
 			getAllSelfTake({
 				current: 1,
 				size: 50
@@ -329,7 +327,8 @@ export default {
 		},
 		close () {
 			this.addGoodPopupShow = false
-			// console.log('close');
+			this.grouponReqData.goodsIds =this.$refs.publish_good_list.returnVGoodIds();
+			 console.log('close',this.grouponReqData.goodsIds);
 		},
 		addGood () {
 			this.addGoodPopupShow = true
@@ -403,16 +402,16 @@ export default {
 					title: that.$t(`请选择自提点`)
 				});
 			}
-			if (this.selectGoodList.length < 1) {
+			if (this.grouponReqData.goodsIds.length < 1) {
 				return that.$util.Tips({
 					title: that.$t(`请添加商品`)
 				});
 			}
-			let goodsIds = [];
-			this.selectGoodList.forEach(e => {
-				goodsIds.push(e.id);
-				that.grouponReqData.goodsIds = goodsIds;
-			})
+			// let goodsIds = [];
+			// this.selectGoodList.forEach(e => {
+			// 	goodsIds.push(e.id);
+			// 	that.grouponReqData.goodsIds = goodsIds;
+			// })
 			uni.showLoading({
 				title: that.$t(`发布中`),
 				mask: true