2312970463@qq.com há 3 anos atrás
pai
commit
182b40f81e

+ 13 - 2
api/product.js

@@ -36,15 +36,26 @@ export function goodsDetail(data, id) {
 // 		data
 // 	});
 // }
+
 // 加入购物车
+// export function cartAdd(data) {
+// 	return request({
+// 		url: '/api/cart/add',
+// 		method: 'post',
+// 		data
+// 	});
+// }
+// new 加入购物车
+
 export function cartAdd(data) {
 	return request({
-		url: '/api/cart/add',
+		url: '/api/user/cart/create',
 		method: 'post',
 		data
-	});
+	})
 }
 
+
 // 收藏商品
 export function collectAdd(data) {
 	return request({

+ 15 - 3
api/user.js

@@ -10,13 +10,25 @@ export function orderData(data) {
 	});
 }
 
-// 获取用户信息
+//获取用户信息
+// export function getUserInfo(data) {
+// 	return request({
+// 		url: '/api/userinfo',
+// 		method: 'get',
+// 		data
+// 	});
+// }
+/**
+ * 获取用户信息 new
+ * 
+ */
 export function getUserInfo(data) {
+	// return request.get('user');
 	return request({
-		url: '/api/userinfo',
+		url: '/api/user',
 		method: 'get',
 		data
-	});
+	})
 }
 
 // 用户分享图

+ 62 - 40
pages/product/groupBooking/productGroup.vue

@@ -249,7 +249,8 @@
 				show: false, // 是否显示底部按钮
 				recommendedlist: [], // 大家都在拼
 				specClass: 'none', //显示隐藏弹窗
-				groupInfo: {}
+				groupInfo: {},
+				product_type: 0
 			};
 
 		},
@@ -464,53 +465,74 @@
 						title: data.product.store_name,
 						stock: data.stock
 					}
-					// obj.goodsObjact.price = goods.price
-					// obj.goodsObjact.product_price = data.product.product_price
 					console.log(obj.goodsObjact, 88)
 					console.log(Array.isArray(data.productValue), 99)
 					obj.imgList = goods.slider_image; //保存轮播图
-					obj.actionPrice = goods.sku.image; //保存默认选中商品价格
+					obj.actionPrice = goods.price; //保存默认选中商品价格
 					obj.actionImage = goods.image; //保存默认选中商品图片
-					obj.goodsNumberMax = 1; //保存默认选中最大可购买商品数量
-					if (Array.isArray(data.productValue) != true) {
-						obj.many = 2;
-						obj.specList = data.productAttr; //保存产品属性
-						obj.productValue = data.productValue; //保存属性值
-						obj.specSelected = []; //初始化默认选择对象
-						for (let i = 0; i < obj.specList.length; i++) {
-							// 设置默认数据
-							let attrValue = obj.specList[i].attr_value[0];
-							attrValue.check = true;
-							obj.specSelected.push(attrValue.attr);
+					obj.goodsNumberMax = data.once_pay_count; //保存默认选中最大可购买商品数量
+					obj.product_type = data.product.product_type
+					if(goods.content.content != null) {
+						obj.description = goods.content.content.replace(/\<img/gi, '<img class="rich-img"');
+					}
+					if( goods.attr.length !== 0){
+						console.log('多规格')
+						obj.many = 2
+						obj.specList = goods.attr
+						obj.productValue = goods.sku
+						obj.specSelected = []
+						for(let i = 0 ; i < obj.specList.length; i++ ) {
+							let attrValue = obj.specList[i].attr_value[0]
+							attrValue.check = true
+							obj.specSelected.push(attrValue.attr)
 						}
 						let str = obj.specSelected.join(',');
-						console.log(str, 'str')
-						// 设置默认值
-
-						obj.actionPrice = obj.productValue[str].price;
-						obj.goodsNumberMax = obj.productValue[str].stock;
-						obj.actionImage = obj.productValue[str].image;
-						obj.uniqueId = obj.productValue[str].unique;
-						obj.goodsStore = obj.productValue[str].quota;
-					} else {
+						console.log(str)
+						
+					}else {
+						console.log("单规格")
 						obj.many = 1;
 					}
-					console.log(obj.many, 'obj.many')
-					if (obj.goodsObjact.description != null) {
-						obj.description = obj.goodsObjact.description.replace(/\<img/gi, '<img class="rich-img"');
-					}
+					// console.log()
+					// if (Array.isArray(data.productValue) != true) {
+					// 	obj.many = 2;
+					// 	obj.specList = data.productAttr; //保存产品属性
+					// 	obj.productValue = data.productValue; //保存属性值
+					// 	obj.specSelected = []; //初始化默认选择对象
+					// 	for (let i = 0; i < obj.specList.length; i++) {
+					// 		// 设置默认数据
+					// 		let attrValue = obj.specList[i].attr_value[0];
+					// 		attrValue.check = true;
+					// 		obj.specSelected.push(attrValue.attr);
+					// 	}
+					// 	let str = obj.specSelected.join(',');
+					// 	console.log(str, 'str')
+					// 	// 设置默认值
+
+					// 	obj.actionPrice = obj.productValue[str].price;
+					// 	obj.goodsNumberMax = obj.productValue[str].stock;
+					// 	obj.actionImage = obj.productValue[str].image;
+					// 	obj.uniqueId = obj.productValue[str].unique;
+					// 	obj.goodsStore = obj.productValue[str].quota;
+					// } else {
+					// 	obj.many = 1;
+					// }
+					// console.log(obj.many, 'obj.many')
+					// if (obj.goodsObjact.description != null) {
+					// 	obj.description = obj.goodsObjact.description.replace(/\<img/gi, '<img class="rich-img"');
+					// }
 					
-					if (obj.goodsObjact.pink_type == 'AA团') {
-						obj.pink_type = 1;
-					} else {
-						obj.pink_type = 2;
-					}
-					// obj.pinkTlist = data.pink;
-					obj.pinkTlist = data.groupBuying;
-					obj.showlist = obj.pinkTlist.slice(0, 2);
-					if (obj.pinkTlist.length <= 2) {
-						obj.more = false;
-					}
+					// if (obj.goodsObjact.pink_type == 'AA团') {
+					// 	obj.pink_type = 1;
+					// } else {
+					// 	obj.pink_type = 2;
+					// }
+					// // obj.pinkTlist = data.pink;
+					// obj.pinkTlist = data.groupBuying;
+					// obj.showlist = obj.pinkTlist.slice(0, 2);
+					// if (obj.pinkTlist.length <= 2) {
+					// 	obj.more = false;
+					// }
 
 					// 保存结束时间
 					obj.seckillObj.stopTime = goods.stop_time * 1000;
@@ -605,7 +627,7 @@
 		top: 0;
 		right: 0;
 		bottom: 0;
-		z-index: 99;
+		z-index: 999;
 
 		&.show {
 			display: block;

+ 29 - 16
pages/product/product.vue

@@ -206,7 +206,8 @@ export default {
 			},
 			product_id: 0,
 			sckillGoodInfo: {}, //秒杀商品信息
-			shopInfo: {} //店铺信息
+			shopInfo: {}, //店铺信息
+			product_type: 0
 		};
 	},
 	filters: {
@@ -488,17 +489,21 @@ export default {
 			let obj = this;
 			// 创建传值对象
 			let goodId = obj.goodsid;
-			if (obj.isSckill) {
-				goodId = obj.product_id;
-			}
 			console.log('添加的数量', obj.goodsNumber);
+			// let data = {
+			// 	cartNum: obj.goodsNumber, //商品数量
+			// 	new: 1,
+			// 	productId: goodId, //商品编号
+			// 	uniqueId: obj.uniqueId
+			// };
 			let data = {
-				cartNum: obj.goodsNumber, //商品数量
-				new: 1,
-				productId: goodId, //商品编号
-				uniqueId: obj.uniqueId
-			};
-			console.log(data);
+				product_id: goodId,
+				product_attr_unique: obj.uniqueId,
+				cart_num: obj.goodsNumber,
+				product_type: obj.product_type,
+				is_new: 1 
+			}
+			console.log("立即购买++++++",data);
 			if (obj.type == 2) {
 				data.new = 0;
 			}
@@ -551,6 +556,7 @@ export default {
 				obj.stopTimes = timeComputed(data.stop * 1000); //设置结束时间
 				obj.shopInfo.name = data.merchant.mer_name; //保存店铺名称
 				obj.shopInfo.logo = data.merchant.mer_avatar; //保存店铺logo
+				obj.product_type = data.product_type//保存商品类型
 				//小程序商品详情图超出屏幕问题
 				if (data.content.content !== null) {
 					obj.description = data.content.content.replace(/\<img/gi, '<img class="rich-img"');
@@ -562,7 +568,8 @@ export default {
 				});
 				// 获取商品属性
 				obj.specList = data.attr; //保存分类列表
-				if (Array.isArray(data.attr) == true) {
+				if (data.attr.length != 0) {
+					console.log("有好多属性")
 					obj.many = 2;
 					obj.specList = data.attr; //保存产品属性
 					obj.productValue = data.sku; //保存属性值
@@ -580,16 +587,22 @@ export default {
 					obj.goodsNumberMax = obj.productValue[str].stock;
 					obj.actionImage = obj.productValue[str].image;
 					obj.uniqueId = obj.productValue[str].unique;
-					obj.goodsStore = obj.productValue[str].quota;
+					obj.goodsStore = obj.productValue[str].stock;
 				} else {
+					console.log("zhiyou yige shuxing")
 					obj.many = 1;
 
-					obj.productValue = data.sku; //保存分类查询数据
-					obj.actionPrice = data.price; //保存默认选中商品价格
-					obj.actionImage = data.image; //保存默认选中商品图片
+					obj.productValue = data.sku[''];
+					console.log(obj.productValue,'obj.productValue11111111111')//保存分类查询数据
+					obj.actionPrice =obj.productValue.price; //保存默认选中商品价格
+					obj.actionImage = obj.productValue.image; //保存默认选中商品图片
 					obj.goodsNumberMax = data.stock; //保存默认选中最大可购买商品数量
-					obj.shopId = data.mer_id; //保存商店id
+					// obj.shopId = data.mer_id; //保存商店id
 					obj.goodsStore = data.stock
+					obj.uniqueId = obj.productValue.unique
+					
+					console.log(obj.uniqueId)
+					
 				}
 			});
 		}

+ 4 - 2
pages/product/seckill.vue

@@ -368,9 +368,11 @@ page,
 }
 // 列表样式
 .list-Box {
-	height: calc(100% - 60px);
+	height: calc(100vh - 104px);
+	// height: calc(100vh- 60px);
 	.list {
-		height: calc(100% - 55px);
+		height: calc(100vh - 104px);
+		// background-color: pink;
 	}
 }
 // 商品列表

+ 48 - 3
pages/public/login.vue

@@ -45,7 +45,7 @@
 </template>
 
 <script>
-import { mapMutations } from 'vuex';
+import { mapMutations,mapState } from 'vuex';
 import { login, jiaMobile } from '@/api/login.js';
 import { getUserInfo } from '@/api/user.js';
 // #ifdef APP-PLUS
@@ -85,6 +85,9 @@ export default {
 		});
 		// #endif
 	},
+	computed: {
+		...mapState(['hasLogin'])
+	},
 	methods: {
 		...mapMutations('user', ['setUserInfo', 'login']),
 		// 微信登录
@@ -230,14 +233,56 @@ export default {
 			uni.navigateBack();
 		},
 		jiazuce() {
+			let obj = this
 			console.log(this.username);
 			jiaMobile({
 				phone: this.username,
-				sms_code: '',
+				sms_code: '1111',
 				spread: ''
 			})
 				.then(res => {
-					console.log(res);
+					console.log(res.data.token);
+					uni.setStorageSync('token', res.data.token);
+					// obj.$store.commit('hasLogin', true);
+					obj.login()
+					// 保存返回用户数据
+					obj.setUserInfo(res.data.user);
+					let ur = uni.getStorageSync('present') || '/pages/index/index';
+						uni.switchTab({
+							url: ur,
+							fail(e) {
+								uni.navigateTo({
+									url: ur,
+									fail(e) {
+										uni.navigateTo({
+											url: '/pages/index/index'
+										});
+									}
+								});
+							}
+						});
+					//成功跳转首页
+					// getUserInfo().then(res => {
+					// 	console.log(res)
+					// 	obj.login();
+					// 	// 保存返回用户数据
+					// 	obj.setUserInfo(e.data);
+					// 	let ur = uni.getStorageSync('present') || '/pages/index/index';
+					// 	//成功跳转首页
+					// 	uni.switchTab({
+					// 		url: ur,
+					// 		fail(e) {
+					// 			uni.navigateTo({
+					// 				url: ur,
+					// 				fail(e) {
+					// 					uni.navigateTo({
+					// 						url: '/pages/index/index'
+					// 					});
+					// 				}
+					// 			});
+					// 		}
+					// 	});
+					// });
 				})
 				.catch(err => {
 					console.log(err);

Diff do ficheiro suprimidas por serem muito extensas
+ 598 - 581
pages/user/user.vue


+ 3 - 2
utils/request.js

@@ -64,14 +64,15 @@ service.interceptors.response(
 service.interceptors.request(
 	config => {
 		let token = uni.getStorageSync('token') || '';
+		console.log(token)
 		// console.log(config);
 		if (!config.header) {
 			config.header = {
-				"Authori-zation": 'Bearer ' + token,
+				"X-Token": 'Bearer ' + token,
 			}
 		} else {
 			// 添加key请求头
-			config.header["Authori-zation"] = 'Bearer ' + token;
+			config.header["X-Token"] = 'Bearer ' + token;
 		}
 		return config
 	},

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff