zs %!s(int64=2) %!d(string=hai) anos
pai
achega
05da159d61
Modificáronse 3 ficheiros con 312 adicións e 36 borrados
  1. 1 1
      pages/home/index.vue
  2. 248 7
      pagesHome/order/detail.vue
  3. 63 28
      pagesHome/order/parts/banner_1.vue

+ 1 - 1
pages/home/index.vue

@@ -90,7 +90,7 @@
 									<text class="label" v-for="(tag,index) in item.p_act" :key="index">{{tag}}</text>
 								</view>
 								<view class="acttags">
-									<text v-for="i in item.actTagsShow" :key="i">{{i.label}}</text>
+									<text v-for="(i,indexx) in item.actTagsShow" :key="indexx">{{i.label}}</text>
 								</view>
 							</view>
 						</view>

+ 248 - 7
pagesHome/order/detail.vue

@@ -5,7 +5,8 @@
 				<scroll-view scroll-y="true" class="scroll-view">
 					<view class="list-scroll-view">
 						<view class="one_1">
-
+							<banner :goodsInfo="goodsInfo" :goodsColect="goodsColect" @toGoodscolect="toGoodscolect">
+							</banner>
 						</view>
 					</view>
 				</scroll-view>
@@ -19,9 +20,35 @@
 </template>
 
 <script>
+	import banner from './parts/banner_1.vue';
 	export default {
+		components: {
+			banner
+		},
 		data() {
 			return {
+				// 系统设置
+				config: {},
+				// 商品id
+				id: '',
+				// 分享人id
+				inviter: '',
+				// 当前用户信息
+				user: {},
+				// 是否关注商品
+				goodsColect: false,
+				// 是否关注店铺
+				shopColect: false,
+				// 评价数
+				evaluate_num: 0,
+				// 商品详情
+				info: {},
+				// 商品详情
+				goodsInfo: {},
+				// 规格
+				infospecs: {},
+				// 优惠
+				discount: {},
 				// 底部菜单
 				options: [{
 						icon: 'shop',
@@ -49,18 +76,220 @@
 						type: '1'
 					}
 				],
+				// 系统菜单
+				barList: [],
+				is_menu: false,
+				// 规格弹框
+				popupShow: '1',
+				// 规格信息
+				is_specs: 0,
+				btn_type: '1',
+				specsInfo: {},
+				// 是否零库存
+				is_zero: false,
+				// 商品设置
+				group_config: [],
+				// 限制说明
+				buyList: [],
+				// 购买数量
+				buy_num: 1,
+				// 规格弹出框
+				dialog: {
+					show: false,
+					type: '1'
+				},
 			};
 		},
-		onLoad: function(e) {
-
+		onLoad: async function(e) {
+			const that = this;
+			that.$set(that, `id`, e.id || '');
+			that.$set(that, `inviter`, e.inviter || '');
+			await that.searchConfig();
+			await that.search();
+			await that.configShare();
 		},
-		onShow: function() {
-
+		onShow: async function() {
+			const that = this;
+			await that.watchLogin();
 		},
 		onUnload: function() {
-
+			// 页面卸载,重新部署分享内容
+			const that = this;
+			if (that.config) {
+				// 赋值默认值
+				that.$config.share = {
+					title: that.config.title,
+					path: '/pages/index/index',
+					imageUrl: that.config.config.share[0].url
+				}
+			}
 		},
 		methods: {
+			// 查询系统设置
+			searchConfig() {
+				const that = this;
+				uni.getStorage({
+					key: 'config',
+					success: function(res) {
+						let data = res.data;
+						that.$set(that, `config`, data);
+						if (data.bottom_menu && data.bottom_menu.list.length > 0) {
+							let list = data.bottom_menu.list.sort((a, b) => {
+								return a.sort - b.sort
+							});
+							that.$set(that, `barList`, list)
+						}
+					}
+				})
+			},
+			// 查询用户信息
+			watchLogin() {
+				const that = this;
+				uni.getStorage({
+					key: 'token',
+					success: async function(res) {
+						let user = that.$jwt(res.data);
+						if (user) that.$set(that, `user`, user);
+					},
+					fail: function(err) {
+						console.log('暂无用户信息');
+					}
+				})
+			},
+			// 查询其他信息
+			async searchOther() {
+				const that = this;
+				let user = that.user;
+				let res;
+				// 是否关注商品
+				res = await that.$api(`/storeGoods/check`, `GET`, {
+					customer: user._id,
+					goods: that.id
+				});
+				if (res.errcode == '0') that.$set(that, `goodsColect`, res.data);
+				// 是否关注店铺
+				res = await that.$api(`/storeShop/check`, `GET`, {
+					customer: user._id,
+					shop: that.info?.shop?._id
+				});
+				if (res.errcode == '0') that.$set(that, `shopColect`, res.data);
+				// 商品设置
+				res = await that.$api(`/goodsConfig`, `GET`, {
+					goods: that.id,
+					shop: that.info?.shop?._id
+				}, 'group');
+				if (res.errcode == '0' && res.total > 0) that.$set(that, `group_config`, res.data);
+				// 限制说明
+				res = await that.$api(`/dictData`, 'GET', {
+					code: "buy_limit"
+				});
+				if (res.errcode == '0') that.$set(that, `buyList`, res.data)
+			},
+			// 查询商品信息
+			async search() {
+				const that = this;
+				let id = that.id;
+				if (id) {
+					let res;
+					res = await that.$api(`/viewGoods/goodsDetail`, `POST`, {
+						id: id
+					});
+					if (res.errcode == '0') {
+						let data = res.data;
+						if (data.goods.brief) data.goods.brief = data.goods.brief.replace(/\<img/gi,
+							'<img class="rich-img"');
+						// 特价
+						let act;
+						act = data.act.find(i => i.type == '3')
+						if (act) {
+							for (let val of act.list) {
+								for (let [index, arr] of data.specs.entries()) {
+									if (val.spec == arr._id) arr.price = val.price
+								}
+							}
+						}
+						// 显示最低价格的规格信息,不考虑库存问题
+						if (data.specs && data.specs.length > 0) {
+							// 规格排序
+							let indexSpecs = data.specs.sort(function(a, b) {
+								let i, j;
+								if (a.price) i = 'price'
+								else i = 'sell_money'
+								if (b.price) j = 'price'
+								else j = 'sell_money'
+								return a[i] - b[j];
+							})
+							that.$set(that, `infospecs`, indexSpecs[0])
+						}
+						that.$set(that, `info`, data);
+						that.$set(that, `goodsInfo`, data?.goods);
+						// 优惠
+						act = data.act.find(i => i.type == '5')
+						if (act) that.$set(that.discount, `full_decrement`, act.text.split(';'));
+						act = data.act.find(i => i.type == '6')
+						if (act) that.$set(that.discount, `full_fold`, act.text.split(';'));
+						await that.searchOther();
+						// 查询规格
+						await that.searchSpecs(data.specs);
+						// 查询评价数
+						await that.searchRate(data);
+					}
+				} else {
+					uni.showToast({
+						title: '暂无商品信息',
+						icon: 'none'
+					})
+				}
+			},
+			// 查询规格
+			searchSpecs(e) {
+				const that = this;
+				if (e.length > 0) {
+					let data = e.find(i => i.num > 0);
+					let dataIndex = e.findIndex(i => i._id == data._id);
+					if (data) {
+						let specsInfo = that.group_config.find(i => i.spec._id == data._id)
+						if (specsInfo?._id && that.user.is_leader == '0') data.can_group = '0'
+						else data.can_group = '1'
+						let limit = that.buyList.find((i) => i.value == data.buy_limit);
+						if (limit) data.buy_name = limit.label
+						that.$set(that, `specsInfo`, data);
+						that.$set(that, `is_specs`, dataIndex);
+					}
+				}
+			},
+			// 查询评价数
+			async searchRate(e) {
+				const that = this;
+				let res = await that.$api(`/goodsRate`, `GET`, {
+					limit: 1,
+					goods: e.goods._id
+				})
+				if (res.errcode == '0') that.$set(that, `evaluate_num`, res.total);
+			},
+			// 关注商品
+			async toGoodscolect() {
+				const that = this;
+				let user = that.user;
+				if (user && user._id) {
+					let res = await that.$api(`/storeGoods`, `POST`, {
+						customer: user._id,
+						goods: that.id
+					});
+					if (res.errcode == '0') {
+						uni.showToast({
+							title: res.data.msg,
+							icon: 'none'
+						})
+						that.$set(that, `goodsColect`, res.data.result)
+					}
+				} else {
+					uni.showToast({
+						title: '暂无账号,无法收藏商品',
+						icon: 'none'
+					})
+				}
+			},
 			// 店铺,购物车
 			toNavleft(e) {
 				const that = this;
@@ -80,7 +309,19 @@
 				that.$set(that, `btn_type`, e.content.type);
 				that.$refs.specShow.open();
 			},
-
+			// 配置分享内容
+			configShare() {
+				const that = this;
+				let id = that.id;
+				let inviter = that.user && that.user._id ? that.user._id : '';
+				let title = that.info && that.info.goods ? that.info.goods.name : '';
+				let imageUrl = that.info && that.info.goods ? that.info.goods.file[0].url : '';
+				that.$config.share = {
+					title: title,
+					path: `/pagesHome/order/detail?id=${id}&inviter=${inviter}`,
+					imageUrl: imageUrl
+				}
+			},
 		}
 	}
 </script>

+ 63 - 28
pagesHome/order/parts/banner_1.vue

@@ -4,7 +4,7 @@
 			<view class="banner_1">
 				<swiper class="swiper" circular :indicator-dots="true" indicator-color="#ffffff"
 					indicator-active-color="#FB1438" :interval="3000" :duration="1000">
-					<swiper-item class="list" v-for="(item,index) in info.goods.file" :key="index">
+					<swiper-item class="list" v-for="(item,index) in goodsInfo.file" :key="index">
 						<image class="image" :src="item.url" mode="aspectFit">
 						</image>
 					</swiper-item>
@@ -14,8 +14,8 @@
 					<text @tap="toGoodscolect"
 						:class="['iconfont',goodsColect?'icon-yduishoucangshixin-copy':'icon-yduishoucangkongxin']"></text>
 				</view>
-				<view class="acttags" v-if="info.goods.act_tags&&info.goods.act_tags.length>0">
-					<text v-for="i in info.goods.act_tags" :key="i">{{i.label}}</text>
+				<view class="acttags" v-if="goodsInfo.act_tags&&goodsInfo.act_tags.length>0">
+					<text v-for="(i,indexx) in goodsInfo.act_tags" :key="indexx">{{i.label}}</text>
 				</view>
 			</view>
 		</view>
@@ -24,6 +24,14 @@
 
 <script>
 	export default {
+		props: {
+			goodsInfo: {
+				type: Object,
+			},
+			goodsColect: {
+				type: Boolean
+			}
+		},
 		data() {
 			return {};
 		},
@@ -36,39 +44,66 @@
 		onUnload: function() {
 
 		},
-		methods: {}
+		methods: {
+			toGoodscolect() {
+				const that = this;
+				that.$emit('toGoodscolect')
+			}
+		}
 	}
 </script>
 
 <style lang="scss">
-	.main {
-		display: flex;
-		flex-direction: column;
-		width: 100vw;
-		height: 100vh;
+	.banner {
+		.banner_1 {
 
-		.one {
-			position: relative;
-			flex-grow: 1;
-		}
+			border-bottom: 0.5vw solid var(--f9Color);
 
-		.two {
-			width: 100vw;
-			height: 8vh;
-			overflow: hidden;
-		}
-	}
+			swiper {
+				height: 44vh !important;
+			}
+
+			.list {
+				border-radius: 5px;
+
+				.image {
+					width: 100%;
+					height: 100%;
+					border-radius: 5px;
+					background-color: #fff;
+				}
+			}
+
+			.goodsColect {
+				position: fixed;
+				top: 2vw;
+				right: 3vw;
+				z-index: 99;
+				background-color: #858585;
+				border-radius: 90px;
+
+				text {
+					font-size: 30px;
+				}
+			}
+
+			.acttags {
+				position: absolute;
+				top: 1vw;
+				left: 1vw;
+				width: 97%;
 
-	.scroll-view {
-		position: absolute;
-		top: 0;
-		left: 0;
-		right: 0;
-		bottom: 0;
+				text {
+					display: inline-block;
+					background-color: #ff0000;
+					color: #fff;
+					border-radius: 1vw;
+					padding: 0.5vw;
+					font-size: 12px;
 
-		.list-scroll-view {
-			display: flex;
-			flex-direction: column;
+					margin: 0 1vw 0 0;
+				}
+			}
 		}
 	}
 </style>