Przeglądaj źródła

Merge branch 'master' of http://git.cc-lotus.info/pointToNetwork/point-app

zs 2 lat temu
rodzic
commit
3623548a42
2 zmienionych plików z 112 dodań i 32 usunięć
  1. 49 11
      pagesHome/shop/index.vue
  2. 63 21
      pagesMy/collection/shop.vue

+ 49 - 11
pagesHome/shop/index.vue

@@ -10,7 +10,8 @@
 						<scroll-view scroll-y="true" class="scroll-view">
 							<view class="list-scroll-view">
 								<view class="list" v-for="(item,index) in shoplist" :key="index">
-									<image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''" mode=""></image>
+									<image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''"
+										mode=""></image>
 									<view class="name">
 										{{item.name}}
 									</view>
@@ -36,17 +37,20 @@
 						<scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
 							<view class="list-scroll-view">
 								<view class="second_1">
-									<view :class="['list',condActive==index?'activeList':'']" v-for="(item,index) in condList" :key="index" @tap="toCond(index,item)">
+									<view :class="['list',condActive==index?'activeList':'']"
+										v-for="(item,index) in condList" :key="index" @tap="toCond(index,item)">
 										<view class="name">
 											{{item.name}}
 										</view>
 										<view class="icon">
 											<view class="icon_1">
-												<text :class="['iconfont',item.shangActive]" v-if="condActive==index&&shang=='1'"></text>
+												<text :class="['iconfont',item.shangActive]"
+													v-if="condActive==index&&shang=='1'"></text>
 												<text :class="['iconfont',item.shang]" v-else></text>
 											</view>
 											<view class="icon_1">
-												<text :class="['iconfont', item.xiaActive]" v-if="condActive==index&&xia=='-1'"></text>
+												<text :class="['iconfont', item.xiaActive]"
+													v-if="condActive==index&&xia=='-1'"></text>
 												<text :class="['iconfont', item.xia]" v-else></text>
 											</view>
 										</view>
@@ -54,7 +58,8 @@
 								</view>
 								<view class="second_2">
 									<view class="list" v-for="(item,index) in list" :key="index">
-										<image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''" mode=""></image>
+										<image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''"
+											mode=""></image>
 										<view class="sale" v-if="item.is_sale==true">
 											<text>已售尽</text>
 										</view>
@@ -98,7 +103,8 @@
 						</view>
 						<view class="second_2">
 							<view class="second_2_bor">
-								<image class="image" :src="info.qrcode&&info.qrcode.length>0?info.qrcode[0].url:''" mode=""></image>
+								<image class="image" :src="info.qrcode&&info.qrcode.length>0?info.qrcode[0].url:''"
+									mode=""></image>
 							</view>
 							<view class="txt">
 								店铺二维码
@@ -129,7 +135,9 @@
 	export default {
 		data() {
 			return {
+				user: {},
 				id: '',
+
 				barActive: '0',
 				barList: [ //底部菜单
 					{
@@ -195,10 +203,23 @@
 		onLoad: function(e) {
 			const that = this;
 			that.$set(that, `id`, e.id || '');
+			that.watchLogin()
 			that.search()
 		},
 		onShow: function() {},
 		methods: {
+			// 监听用户是否登录
+			watchLogin() {
+				const that = this;
+				uni.getStorage({
+					key: 'token',
+					success: function(res) {
+						let user = that.$jwt(res.data);
+						that.$set(that, `user`, user);
+					},
+					fail: function(err) {}
+				})
+			},
 			// 查询信息
 			async search() {
 				const that = this;
@@ -206,6 +227,7 @@
 					// 查询店铺信息
 					const res = await that.$api(`/shop/${that.id}`, 'GET');
 					if (res.errcode == '0') that.$set(that, `info`, res.data);
+
 					// 查询店铺商品
 					that.searchShopMarket();
 					// 查询全部商品
@@ -315,14 +337,30 @@
 				that.searchAll();
 			},
 			// 收藏
-			toCollect() {
+			async toCollect() {
 				const that = this;
 				that.collection = !that.collection;
 				if (that.collection == true) {
-					uni.showToast({
-						title: `收藏成功`,
-						icon: 'none'
-					})
+					var params = {};
+					params = {
+						shop: that.info.id,
+						customer: that.user.id
+					}
+					const arr = await that.$api(`/storeShop`, 'POST', params)
+					if (arr.errcode == '0') {
+						const aee = await that.$api(`/storeShop/check`, 'POST', params)
+						if (aee.errcode == '0') {
+							console.log(aee.data);
+						}
+						uni.showToast({
+							title: `收藏成功`,
+							icon: 'none'
+						})
+					} else {
+						uni.showToast({
+							title: arr.errmsg,
+						})
+					}
 				} else {
 					uni.showToast({
 						title: `取消成功`,

+ 63 - 21
pagesMy/collection/shop.vue

@@ -30,31 +30,73 @@
 	export default {
 		data() {
 			return {
-				list: [{
-						file: require('@/static/test.png'),
-						name: '官方自营店',
-						num: 2,
-						time: '2022-09-27'
-					},
-					{
-						file: require('@/static/test.png'),
-						name: '官方自营店',
-						num: 2,
-						time: '2022-09-27'
-					},
-					{
-						file: require('@/static/test.png'),
-						name: '官方自营店',
-						num: 2,
-						time: '2022-09-27'
-					}
-				]
+				user: {},
+				list: [],
+				total: 0,
+				skip: 0,
+				limit: 5,
+				page: 0
+				// list: [{
+				// 		file: require('@/static/test.png'),
+				// 		name: '官方自营店',
+				// 		num: 2,
+				// 		time: '2022-09-27'
+				// 	},
+				// 	{
+				// 		file: require('@/static/test.png'),
+				// 		name: '官方自营店',
+				// 		num: 2,
+				// 		time: '2022-09-27'
+				// 	},
+				// 	{
+				// 		file: require('@/static/test.png'),
+				// 		name: '官方自营店',
+				// 		num: 2,
+				// 		time: '2022-09-27'
+				// 	}
+				// ]
 			};
 		},
 		onShow: function() {
-
+			const that = this;
+			that.watchLogin()
 		},
 		methods: {
+			// 监听用户是否登录
+			watchLogin() {
+				const that = this;
+				uni.getStorage({
+					key: 'token',
+					success: function(res) {
+						let user = that.$jwt(res.data);
+						that.$set(that, `user`, user);
+						that.search()
+					},
+					fail: function(err) {
+						uni.reLaunch({
+							url: `/pages/login/index`
+						})
+					}
+				})
+			},
+			// 查询列表
+			async search() {
+				const that = this;
+				let user = that.user;
+				let info = {
+					skip: that.skip,
+					limit: that.limit,
+					customer: user._id
+				}
+				const res = await that.$api(`/storeShop`, 'GET', {
+					...info
+				})
+				if (res.errcode == '0') {
+					let list = [...that.list, ...res.data];
+					that.$set(that, `list`, list);
+					that.$set(that, `total`, res.total)
+				}
+			},
 			// 详细信息
 			toView(e) {
 				const that = this;
@@ -67,7 +109,7 @@
 			},
 			// 分页
 			toPage(e) {
-			
+
 			},
 		}
 	}