Browse Source

2021-6-4 余额,地址

hwq 3 years ago
parent
commit
3998f35402

+ 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({

+ 18 - 6
api/user.js

@@ -4,19 +4,31 @@ import { upFilse} from '@/utils/request';
 // 订单统计信息
 export function orderData(data) {
 	return request({
-		url: '/api/order/data',
+		url: '/api/order/number',
 		method: 'get',
 		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
-	});
+	})
 }
 
 // 用户分享图
@@ -31,7 +43,7 @@ export function spreadBanner(data) {
 // 获取地址列表
 export function getAddressList(data) {
 	return request({
-		url: '/api/address/list',
+		url: '/api/user/address/lst',
 		method: 'get',
 		data
 	});
@@ -39,7 +51,7 @@ export function getAddressList(data) {
 // 修改地址
 export function addressEdit(data) {
 	return request({
-		url: '/api/address/edit',
+		url: '/api/user/address/create',
 		method: 'post',
 		data
 	});

+ 2 - 2
api/wallet.js

@@ -1,9 +1,9 @@
 import request from '@/utils/request'
 
 // 获取用户消费记录
-export function spreadCommission(data,state) {
+export function spreadCommission(data) {
 	return request({
-		url: '/api/spread/commission/'+state,
+		url: '/api/user/bill',
 		method: 'get',
 		data
 	});

+ 13 - 17
pages/money/wallet.vue

@@ -3,7 +3,7 @@
 		<view class="content-money">
 			<view class="money-box">
 				<!-- <view class="text">可提现金额(元)</view> -->
-				<view class="money"><text class="money-icon">¥</text>{{ money | getMoneyStyle }}</view>
+				<view class="money"><text class="money-icon">¥</text>{{ userInfo.now_money | getMoneyStyle }}</view>
 			</view>
 			<!-- <view class="moneyTx" @click="navto('/pages/money/recharge')">充值</view>
 			<view class="flex buttom-box">
@@ -34,7 +34,7 @@
 								<text>{{ item.title }}</text>
 							</view>
 							<view class="time">
-								<text>{{ item.add_time }}</text>
+								<text>{{ item.create_time }}</text>
 							</view>
 						</view>
 						<view class="money">
@@ -51,6 +51,7 @@
 </template>
 
 <script>
+import { mapState, mapMutations } from 'vuex';
 import { spreadCommission, userBalance } from '@/api/wallet.js';
 import { getMoneyStyle } from '@/utils/rocessor.js';
 import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
@@ -87,14 +88,6 @@ export default {
 			maxheight:'',
 			tabCurrentIndex: 1,
 			navList: [
-				{
-					state: 0,
-					text: '全部',
-					loadingType: 'more',
-					orderList: [],
-					page: 1, //当前页数
-					limit: 10 //每次信息条数
-				},
 				{
 					state: 1,
 					text: '支出',
@@ -119,13 +112,14 @@ export default {
 			money: ''
 		};
 	},
+	computed: {
+		...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
+	},
 	onLoad(options) {},
 	onShow() {
 		this.loadData();
 		// 获取用户余额
-		userBalance({}).then(({ data }) => {
-			this.money = data.now_money;
-		});
+		
 	},
 	methods: {
 		// 页面跳转
@@ -154,13 +148,15 @@ export default {
 			spreadCommission(
 				{
 					page: navItem.page,
-					limit: navItem.limit
+					limit: navItem.limit,
+					type: state
 				},
-				state
+				
 			)
 				.then(({ data }) => {
-					if (data.length > 0) {
-						navItem.orderList = navItem.orderList.concat(data[0].list);
+					console.log(data);
+					if (data.count > 0) {
+						navItem.orderList = navItem.orderList.concat(data.list);
 						console.log(navItem.orderList);
 						navItem.page++;
 					}

+ 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;

+ 16 - 10
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"');

+ 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);

+ 2 - 1
pages/set/address.vue

@@ -52,7 +52,8 @@ export default {
 				page: 1,
 				limit: 100
 			}).then(({ data }) => {
-				this.addressList = data;
+				console.log(data)
+				this.addressList = data.list;
 			});
 		},
 		// 设为默认地址

+ 34 - 39
pages/set/addressManage.vue

@@ -10,7 +10,7 @@
 		</view>
 		<view class="row b-b">
 			<text class="tit">地址</text>
-			<pickerAddress class="input" @change="onCityClick">{{addressDetail||'请选择地址'}}</pickerAddress>
+			<pickerAddress class="input" @change="onCityClick">{{ addressDetail || '请选择地址' }}</pickerAddress>
 			<text class="iconfont iconlocation"></text>
 		</view>
 		<view class="row b-b">
@@ -28,9 +28,7 @@
 				@switchChange="switchChange"
 			></uni-list-item>
 		</uni-list>
-    <view class="del-btn" v-if="showDel">
-      <text @click="delAddr">删除地址</text>
-    </view>
+		<view class="del-btn" v-if="showDel"><text @click="delAddr">删除地址</text></view>
 		<button class="add-btn" @click="confirm">提交</button>
 	</view>
 </template>
@@ -39,7 +37,7 @@
 import uniList from '@/components/uni-list/uni-list.vue';
 import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
 import uniPopup from '@/components/uni-popup/uni-popup.vue';
-import  pickerAddress from '@/components/wangding-pickerAddress/wangding-pickerAddress.vue';
+import pickerAddress from '@/components/wangding-pickerAddress/wangding-pickerAddress.vue';
 import { addressEdit, addressDel } from '@/api/user.js';
 export default {
 	components: {
@@ -61,19 +59,19 @@ export default {
 				},
 				area: '',
 				default: false,
-        showDel: false
+				showDel: false
 			}
 		};
 	},
 	onLoad(option) {
-    this.showDel = false
+		this.showDel = false;
 		let title = '新增收货地址';
 		if (option.type === 'edit') {
 			title = '编辑收货地址';
 			let data = JSON.parse(option.data);
 			console.log(data);
-      
-      this.showDel = true
+
+			this.showDel = true;
 			this.addressData = {
 				name: data.real_name,
 				mobile: data.phone,
@@ -95,7 +93,7 @@ export default {
 	},
 	methods: {
 		// 选中城市切换
-		onCityClick({data}) {
+		onCityClick({ data }) {
 			let address = this.addressData.address;
 			address.province = data[0];
 			address.city = data[1];
@@ -116,17 +114,16 @@ export default {
 		switchChange(e) {
 			this.addressData.default = e.value;
 		},
-    //删除地址
-    delAddr() {
-      addressDel({id:this.addressData.id}).then(({data})=>{
-				this.$api.msg('删除成功')
-        setTimeout(()=>{
-          uni.redirectTo({url:'/pages/set/address'})
-        },1000)
-        
-			})
-      console.log('删除')
-    },
+		//删除地址
+		delAddr() {
+			addressDel({ id: this.addressData.id }).then(({ data }) => {
+				this.$api.msg('删除成功');
+				setTimeout(() => {
+					uni.redirectTo({ url: '/pages/set/address' });
+				}, 1000);
+			});
+			console.log('删除');
+		},
 		//提交
 		confirm() {
 			let obj = this;
@@ -152,20 +149,18 @@ export default {
 			addressEdit({
 				real_name: data.name,
 				phone: data.mobile,
-				address: {
-					province: data.address.province,
-					city: data.address.city,
-					district: data.address.district
-				},
+				province: data.address.province,
+				city: data.address.city,
+				district: data.address.district,
 				detail: data.area,
 				is_default: data.default,
-				id: data.id||"",
-				type:1
+				address_id: data.id || '',
+				type: 1
 			}).then(function(e) {
 				obj.$api.prePage().refreshList();
 				uni.showToast({
-					title:'提交成功',
-					duration:2000
+					title: '提交成功',
+					duration: 2000
 				});
 				setTimeout(function() {
 					uni.navigateBack();
@@ -216,15 +211,15 @@ page {
 	}
 }
 .del-btn {
-  width: 750rpx;
-  height: 99rpx;
-  margin-top: 28rpx;
-  font-size: 30rpx;
-  font-weight: 500;
-  color: #901B21;
-  background-color: #fff;
-  line-height: 99rpx;
-  padding-left: 42rpx;
+	width: 750rpx;
+	height: 99rpx;
+	margin-top: 28rpx;
+	font-size: 30rpx;
+	font-weight: 500;
+	color: #901b21;
+	background-color: #fff;
+	line-height: 99rpx;
+	padding-left: 42rpx;
 }
 .add-btn {
 	display: flex;

File diff suppressed because it is too large
+ 601 - 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
 	},

Some files were not shown because too many files changed in this diff