fxy 3 tahun lalu
induk
melakukan
fb66784c38

+ 2 - 2
pages/index/index.vue

@@ -535,9 +535,9 @@
 										¥{{item.low_price}}
 										<text>¥{{item.low_original}}</text>
 									</view>
-									<button type="default" class="product-item-column2-btn" @tap.stop="addTrolley()">
+								<!-- 	<button type="default" class="product-item-column2-btn" @tap.stop="addTrolley()">
 										<image src="../../static/add-icon.png" mode=""></image>
-									</button>
+									</button> -->
 								</view>
 							</view>
 						</view>

+ 4 - 4
pages/index/product-details/product-details.css

@@ -521,7 +521,7 @@ page {
 	position: fixed;
 	bottom: 0;
 	left: 0;
-	z-index: 99999999;
+	z-index: 999;
 	background-color: #FFFFFF;
 	padding: 0 24rpx;
 	box-sizing: border-box;
@@ -651,7 +651,7 @@ page {
 	top: 0;
 	height: 100vh;
 	background-color: rgba(0, 0, 0, 0.38);
-	z-index: 999999999;
+	z-index: 998;
 }
 
 .window-box {
@@ -666,7 +666,7 @@ page {
 	padding: 0 24rpx;
 	box-sizing: border-box;
 	border-radius: 40rpx 40rpx 0 0;
-	z-index: 9999999999999999;
+	z-index: 999;
 }
 
 .window-title {
@@ -739,7 +739,7 @@ page {
 	padding: 22rpx 22rpx 0;
 	box-sizing: border-box;
 	border-radius: 40rpx 40rpx 0 0;
-	z-index: 9999999999999999;
+	z-index: 9999;
 }
 
 .product-module {

+ 158 - 41
pages/index/product-details/product-details.vue

@@ -35,9 +35,9 @@
 				</swiper-item>
 			</swiper>
 			<view class="diandian">
-				<view class="diandiandian" :class="(swiperCurrent == index ? 'diandiandian_active' : '')"
+				<!-- <view class="diandiandian" :class="(swiperCurrent == index ? 'diandiandian_active' : '')"
 					v-for="(item, index) in swiperList">
-				</view>
+				</view> -->
 			</view>
 		</view>
 
@@ -161,7 +161,17 @@
 			</view>
 
 			<view class="module">
-				<view class="module-row">
+				<view class="module-row" v-for="(item, index) in info.goods_param || []">
+					<view class="module-label">
+						{{item.title}}
+					</view>
+					<view class="module-right-row">
+						<view class="msg">
+							{{item.value}}
+						</view>
+					</view>
+				</view>
+				<!-- <view class="module-row">
 					<view class="module-label">
 						配送
 					</view>
@@ -170,7 +180,7 @@
 							嘉兴南湖区旭辉广场2号楼
 						</view>
 					</view>
-				</view>
+				</view> -->
 				<view class="module-row">
 					<view class="module-label">
 						发货
@@ -179,10 +189,10 @@
 						<view class="msg">
 							北京携手熊猫总部
 						</view>
-						<text class="express-shipping">快递:免运费</text>
+						<text class="express-shipping">快递:{{info.postage > 0 ? info.postage + '元' : '免运费'}}</text>
 					</view>
 				</view>
-				<view class="module-row">
+				<!-- <view class="module-row">
 					<view class="module-label">
 						源头
 					</view>
@@ -202,7 +212,7 @@
 							6月/7月/8月
 						</view>
 					</view>
-				</view>
+				</view> -->
 				<view class="module-row">
 					<view class="module-label">
 						时令
@@ -328,21 +338,22 @@
 				<button type="default">
 					<image src="../../../static/foot-tab1.png" mode="heightFix"></image>
 					客服
-				</button>
-				<button type="default" @tap="collect">
+				</button>
+				 <!-- @tap="userCollect(info.id)" -->
+				<button type="default" @tap="userCollect(info.id, info.first_classify)">
 					<image :src="select ? '../../../static/foot-tab3active.png' : '../../../static/foot-tab3.png'"
 						mode="heightFix"></image>
 					{{select ? '已收藏' : '收藏'}}
 				</button>
 			</view>
 			<view class="footer-rightsidebar">
-				<button type="default" class="footer-rightsidebar-btn" @tap="addCartSuccess">
+				<button type="default" class="footer-rightsidebar-btn" @tap="showPreSaleSelectSpecification('addCart')">
 					<image src="../../../static/btn-bg1.png" mode=""></image>
 					<view class="footer-rightsidebar-btn-container">
 						加入购物车
 					</view>
 				</button>
-				<button type="default" class="footer-rightsidebar-btn2">
+				<button type="default" class="footer-rightsidebar-btn2" @tap="showPreSaleSelectSpecification('buy')">
 					<image src="../../../static/btn-bg2.png" mode=""></image>
 					<view class="footer-rightsidebar-btn-container2">
 						立即购买
@@ -506,13 +517,13 @@
 			<view class="mask" @tap="closePreSaleSelectSpecification"></view>
 			<view class="selectSpecification-box">
 				<view class="product-module">
-					<image src="../../../static/img-4.png" class="product-img" mode="aspectFill"></image>
+					<image :src="itemSelect.cover || info.cover" class="product-img" mode="aspectFill"></image>
 					<view class="product-module-sidebar">
 						<view class="price-row">
-							¥394.00
-							<text class="del-price">¥34.00</text>
+							¥{{itemSelect.sell_price}}
+							<text class="del-price">¥{{itemSelect.original_price}}</text>
 						</view>
-						<view class="product-module-title">陶太萌油蟠桃(黄肉蟠桃)</view>
+						<view class="product-module-title">{{itemSelect.goods_title || info.name}}</view>
 					</view>
 				</view>
 				<view class="delivery-address-box">
@@ -525,32 +536,26 @@
 						</view>
 					</view>
 				</view>
-				<view class="taste-row">
-					<view class="taste-label">
-						净含量
-					</view>
-					<view class="specification-list">
-						<view v-for="(item, index) in list3" :key="index">
-							<view :class="'type2 ' + [choose == index ? 'active' : '']" @click="chooseItem(index)">
-								{{ item.name }}
-							</view>
-						</view>
-					</view>
-				</view>
-				<view class="taste-row">
+				<view class="taste-row" v-for="(item, index) in itemList.list">
 					<view class="taste-label">
-						规格
+						{{item[0]}}
 					</view>
 					<view class="specification-list">
-						<view v-for="(item, index) in list2" :key="index">
-							<view :class="'type2 ' + [selected == index ? 'active' : '']" @click="selectedItem(index)">
-								{{ item.name }}
+						<view v-for="(item2, index2) in item[1]" :key="index2">
+							<view :class="'type2 ' + [itemListSelect[item[0]] == item2 ? 'active' : '']" @click="chooseItem(item[0], item2)">
+								{{ item2 }}
 							</view>
 						</view>
 					</view>
 				</view>
 				<view class="number-box-between">
-					<view class="number-label">购买数量<text>(限购10件)库存1899件</text></view>
+					<view class="number-label">
+						购买数量
+						<text>
+							<!-- (限购10件) -->
+							库存{{itemSelect.stock}}件
+						</text>
+					</view>
 					<view class="calc_box">
 						<view class="calc_btn">
 							<image src="../../../static/less.png" mode="widthFix" />
@@ -562,7 +567,7 @@
 					</view>
 				</view>
 				<view class="window-bottom">
-					<button type="default">确定</button>
+					<button type="default" @tap="addCartOrBuy()">确定</button>
 				</view>
 			</view>
 		</view>
@@ -572,7 +577,13 @@
 </template>
 
 <script>
-	import { expediteGetGoodsDetail, expediteGetGoodsComment } from '../../../common/service.js';
+	import {
+		expediteGetGoodsDetail,
+		expediteGetGoodsComment,
+		collectUserCollect,
+		trolleyGetTrolleyByGoodsId,
+		trolleyAddTrolley,
+	} from '../../../common/service.js';
 	import HeaderViewBar from '../../../components/header-view-bar/header-view-bar.vue';
 	import popupMessage from '../../../components/addSuccess.vue';
 	export default {
@@ -662,7 +673,22 @@
 				
 				commentList: [],
 				page: 1,
-				page_num: 20,
+				page_num: 20,
+				
+				trolley: [],
+				
+				// 规格
+				itemList: {
+					itemMap: {},
+					itemIdMap: {},
+					list: [],
+				},
+				// 每个规格选中的
+				itemListSelect: {},
+				// 当前选择的规格
+				itemSelect: {},
+				// 规格选择类型 addCart 加购物车 buy 购买
+				selectType: '',
 			}
 		},
 		onLoad(option) {
@@ -671,6 +697,7 @@
 				this.info.id = id;
 				this.getGoodsDetail();
 				this.getGoodsComment();
+				this.getTrolleyByGoodsId();
 			}
 		},
 		onShow() {
@@ -680,6 +707,72 @@
 			}, 20);
 		},
 		methods: {
+			addCartOrBuy() {
+				const selectType = this.selectType;
+				if (selectType == 'addCart') {
+					this.addCart();
+				} else if (selectType == 'buy') {
+					this.buy();
+				}
+			},
+			addCart() {
+				const data = {
+					goods_id: this.info.id,  // 商品id
+					spec_id: this.itemSelect.id,  // 规格id
+				}
+				trolleyAddTrolley({
+					data,
+					success: ({code, msg, data}) => {
+						if (code == 1) {
+							this.getTrolleyByGoodsId();
+						}
+						console.log(msg);
+						uni.showToast({
+							icon: 'none',
+							title: msg,
+						});
+					},
+				});
+			},
+			buy() {
+				
+			},
+			getTrolleyByGoodsId() {
+				trolleyGetTrolleyByGoodsId({
+					data: {
+						goods_id: this.info.id
+					},
+					success: ({code, msg, data}) => {
+						if (code == 1) {
+							this.trolley = data.list;
+						} else {
+							uni.showToast({
+								icon: 'none',
+								title: msg,
+							});
+						}
+					}
+				});
+			},
+			userCollect(id, first_classify) {
+				const params = {
+					coll_type: 1,  // 类型(1商品2资讯3视频)
+					coll_id: id,  // 收藏id
+					cate_id: first_classify,  // 收藏分类id(多个分类传顶级分类id)
+				}
+				collectUserCollect({
+					data: params,
+					success: ({code, msg, data}) => {
+						if (code == 1) {
+							console.log(data);
+						}
+						uni.showToast({
+							icon: 'none',
+							title: msg,
+						});
+					}
+				});
+			},
 			getGoodsDetail() {
 				expediteGetGoodsDetail({
 					data: {
@@ -687,7 +780,29 @@
 					},
 					success: ({code, msg, data}) => {
 						if (code == 1) {
-							this.info = data.good;
+							const info = data.goods_info;
+							const itemList = info.item_list.reduce((a, b, index) => {
+								const item = b.goods_spec.split(';;').map(i => i.split('::'));
+								let idKey = '';
+								if (index == 0) {
+									item.forEach(([key, val]) => {
+										this.itemListSelect[key] = val;
+									});
+									this.itemSelect = b;
+								}
+								item.forEach(([key, val]) => {
+									a.itemMap[key] = [...(new Set([...(a.itemMap[key] || []), val]))];
+									idKey += val;
+								});
+								a.itemIdMap[idKey] = b;
+								return a;
+							}, {
+								itemMap: {},
+								itemIdMap: {},
+							});
+							itemList['list'] = Object.entries(itemList.itemMap);
+							this.info = data.goods_info;
+							this.itemList = itemList;
 						} else {
 							uni.showToast({
 								icon: 'none',
@@ -782,7 +897,8 @@
 			},
 
 			//限源预售-选择规格-弹窗
-			showPreSaleSelectSpecification() {
+			showPreSaleSelectSpecification(type) {
+				this.selectType = type;
 				this.isShowPreSaleSelectSpecification = true;
 			},
 			closePreSaleSelectSpecification() {
@@ -796,9 +912,10 @@
 			},
 
 			//限源预售-净含量-单选
-			chooseItem: function(index) {
-				// console.log(index)
-				this.choose = index;
+			chooseItem(key, val) {
+				this.itemListSelect[key] = val;
+				const key2 = Object.values(this.itemListSelect).join('');
+				this.itemSelect = this.itemList.itemIdMap[key2];
 			},
 			
 			//倒计时