zory 6 часов назад
Родитель
Сommit
23e72dbc24
6 измененных файлов с 162 добавлено и 70 удалено
  1. 46 27
      pages/auth/login.vue
  2. 69 16
      pages/goods/detail.vue
  3. 15 1
      pages/order/detail.vue
  4. 13 24
      pages/service/chat/chat.vue
  5. 9 1
      static/api/auth.js
  6. 10 1
      static/api/goods.js

+ 46 - 27
pages/auth/login.vue

@@ -10,9 +10,10 @@
 			<textarea v-model="loginInfo" maxlength="-1" style="height: 120upx;"></textarea>
 		</view>
 		<view class="logi-btn">
-			<button class="u-button full" @click="getUserInfo" v-if="checkTrueState">快捷一键登录</button>
-			<!-- <button class="u-button full" open-type="getPhoneNumber" @getphonenumber="toLogin" v-if="checkTrueState">手机号一键登录</button> -->
+			<!-- <button class="u-button full" @click="getUserInfo" v-if="checkTrueState">快捷一键登录</button> -->
+			<button class="u-button full" open-type="getPhoneNumber" @getphonenumber="toLogin" v-if="checkTrueState">手机号一键登录</button>
 			<button class="u-button full" @click="toLoginCheck" v-else>快捷登录</button>
+			<!-- <button class="u-button" @click="popState(1)">展示</button> -->
 			<button class="u-button" @click="reback">返回</button>
 		</view>
 		<view class="login-footer">
@@ -20,7 +21,16 @@
 			<view @click="checkTrue">我已阅读并同意</view>
 			<text @click="toWeb('privacy')">用户协议、</text><text @click="toWeb('privacy')">隐私协议</text>
 		</view>
-		
+		
+		<uni-popup ref="userpopup" type="bottom" border-radius="10px 10px 0 0" background-color="#ffffff" :mask-click="false">
+			<view class="user-pop">
+				<view class="title">登录提醒</view>
+				<view class="pop-body">为了更好的区分完善信息,还需授权获取到您的头像、昵称信息</view>
+				<view class="pop-btn">
+					<button class="u-button full" open-type="getUserInfo" @click="getUserInfo">授权头像、昵称信息</button>
+				</view>
+			</view>
+		</uni-popup>
 	</view>
 </template>
 
@@ -38,22 +48,31 @@ export default {
 			reType:"switchTab",
 			storeId:"",
 			loginCode:"",
-			loginInfo:""
+			loginInfo:"",
+			mobileData:null
 		}
 	},
 	onLoad({store,type,url}) {
 		app = this;
 		app.reType = type?type:"switchTab";
 		app.reUri = url?url:null;
-		uni.login({
+		// app.storeId = app.$dialog.shopId();
+		uni.login({
 			force:true,
-			success(res){
-				app.loginCode = res.code;
+			success(resp){
+				app.loginCode = resp.code;
 			}
 		})
-		// app.storeId = app.$dialog.shopId();
 	},
 	methods: {
+		popState(type){
+			if (type == 1) {
+				app.$refs.userpopup.open()
+			} else {
+				app.$refs.userpopup.close()
+			}
+			return ;
+		},
 		reback(){
 			uni.navigateBack();
 		},
@@ -78,11 +97,12 @@ export default {
 						var detail = {};
 						detail.avatar = resp.userInfo.avatarUrl
 						detail.nickname = resp.userInfo.nickName
-						detail.login = app.loginCode
-						Api.nickname(detail).then((res)=>{
+						detail.mobile = JSON.stringify(app.mobileData)
+						Api.nicknameAuth(detail).then((res)=>{
 							if (res.code == 0) {
 								return app.$dialog.showSuccess(res.msg);
-							}
+							}
+							app.popState(2)
 							uni.setStorageSync("user_token", res.data.access_token)
 							uni.navigateBack();
 						})
@@ -95,29 +115,27 @@ export default {
 		},
 		toLogin(e){
 			var detail = e.detail;
-			detail.login = app.loginCode;
-			uni.getUserProfile({
-				force: true,
-				success(resp) {
-					console.log("success",resp)
-				},
-				fail(e) {
-					console.log(e)
-				}
+			detail.login = app.loginCode;
+			Api.mobileAuth(detail).then((res)=>{
+				if (!res.data.mobile) {
+					return app.$dialog.showSuccess(res.msg);
+				}
+				app.mobileData = res.data;
+				app.popState(1)
 			})
-			// Api.login(detail).then((res)=>{
-			// 	if (res.code == 0) {
-			// 		return app.$dialog.showSuccess(res.msg);
-			// 	}
-			// 	uni.setStorageSync("user_token", res.data.access_token)
-			// 	uni.navigateBack();
-			// })
 		},
 	}
 }
 </script>
 
 <style>
+.user-pop .title{padding: 20upx;border-bottom: 2upx solid #f8f8f8;font-size: 28upx;font-weight: bold;color: #000;}
+.user-pop .pop-body{padding: 20upx;font-size: 24upx;color: #555;line-height: 60upx;text-align: center;}
+.user-pop .pop-btn{display: flex;align-items: center;margin-top: 20upx;justify-content: end;}
+.user-pop .u-button{font-size: 28upx;height: 80upx;border-radius: 40upx;line-height: 80upx;margin-bottom: 40upx;color: #333;border: 2upx solid #007aff;background-color: #fff;padding: 0 40upx;}
+.user-pop .u-button::after{border: 0;}
+.user-pop .u-button.full{background-color: #007aff;color: #fff;}
+
 .test{width: 80%;overflow: auto;height: 100upx;}
 .content{position: relative;height: 100vh;display: flex;flex-direction: column;}
 .login-logo{width: 80%;margin: 60upx auto;text-align: center;height: 40%;display: flex;align-items: center;justify-content: center;}
@@ -125,6 +143,7 @@ export default {
 .login-logo image{width: 180upx;height: 180upx;}
 .logi-btn{width: 50%;margin: 20upx auto;height: 40%;}
 .logi-btn .u-button{font-size: 28upx;height: 80upx;border-radius: 40upx;line-height: 80upx;margin-bottom: 40upx;color: #333;border: 2upx solid #007aff;background-color: #fff;}
+.logi-btn .u-button::after{border: 0;}
 .logi-btn .u-button.full{background-color: #007aff;color: #fff;}
 .login-footer{text-align: center;font-size: 28upx;color: #666;height: 20%;display: flex;align-items: center;justify-content: center;}
 .login-footer text{color: #007aff;}

+ 69 - 16
pages/goods/detail.vue

@@ -252,6 +252,17 @@
 					</view>
 				</view>
 			</view>
+		</uni-popup>
+		
+		
+		<uni-popup ref="userpopup" type="bottom" border-radius="10px 10px 0 0" background-color="#ffffff" :mask-click="false">
+			<view class="user-pop">
+				<view class="title">登录提醒</view>
+				<view class="pop-body">为了更好的区分完善信息,还需授权获取到您的头像、昵称信息</view>
+				<view class="pop-btn">
+					<button class="u-button full" open-type="getUserInfo" @click="getUserInfo">授权头像、昵称信息</button>
+				</view>
+			</view>
 		</uni-popup>
 	</view>
 </template>
@@ -277,7 +288,9 @@ export default {
 			loadingPayBtn:0,
 			currIndex: 0, // 当前索引
 			swiperHeight: 200,
-			userToken:null
+			userToken:null,
+			mobileData:null,
+			loginCode:null
 		}
 	},
 	created() {
@@ -286,29 +299,62 @@ export default {
 		this.$scope.onErrors = this.onErrors;
 		this.$scope.onPay = this.onPay;
 	},
-	onLoad({goods,spm}) {
+	onLoad(options) {
 		app = this;
 		app.storeData = uni.getStorageSync("contact");
 		app.userToken = uni.getStorageSync("user_token");
-		app.goodsId = goods;
-		app.spm = spm?spm:'0';
+		app.goodsId = options.goods?options.goods:0;
+		app.spm = options.spm?options.spm:'0';
 		app.getGoods();
+		uni.login({
+			force:true,
+			success(resp){
+				app.loginCode = resp.code;
+			}
+		})
 	},
 	methods: {
+		popState(type){
+			if (type == 1) {
+				app.$refs.userpopup.open()
+			} else {
+				app.$refs.userpopup.close()
+			}
+			return ;
+		},
+		getUserInfo(e){
+			uni.getUserProfile({
+				force: true,
+				success(resp) {
+					if (resp.errMsg == 'getUserProfile:ok') {
+						var detail = {};
+						detail.avatar = resp.userInfo.avatarUrl
+						detail.nickname = resp.userInfo.nickName
+						detail.mobile = JSON.stringify(app.mobileData)
+						Api.nicknameAuth(detail).then((res)=>{
+							if (res.code == 0) {
+								return app.$dialog.showSuccess(res.msg);
+							}
+							app.popState(2)
+							uni.setStorageSync("user_token", res.data.access_token)
+							app.userToken = res.data.access_token
+						})
+					}
+				},
+				fail(e) {
+					console.log(e)
+				}
+			})
+		},
 		toLogin(e){
-			uni.login({
-				force:true,
-				success(resp){
-					var detail = e.detail;
-					detail.login = resp.code;
-					Api.login(detail).then((res)=>{
-						if (res.code == 0) {
-							return app.$dialog.showSuccess(res.msg);
-						}
-						uni.setStorageSync("user_token", res.data.access_token)
-						app.userToken = res.data.access_token
-					})
+			var detail = e.detail;
+			detail.login = app.loginCode;
+			Api.mobileAuth(detail).then((res)=>{
+				if (!res.data.mobile) {
+					return app.$dialog.showSuccess(res.msg);
 				}
+				app.mobileData = res.data;
+				app.popState(1)
 			})
 		},
 		callMobile(mobile){
@@ -539,6 +585,13 @@ export default {
 <style>
 page{background-color: #f8f8f8;}
 
+.user-pop .title{padding: 20upx;border-bottom: 2upx solid #f8f8f8;font-size: 28upx;font-weight: bold;color: #000;}
+.user-pop .pop-body{padding: 20upx;font-size: 24upx;color: #555;line-height: 60upx;text-align: center;}
+.user-pop .pop-btn{display: flex;align-items: center;margin-top: 20upx;justify-content: end;}
+.user-pop .u-button{font-size: 28upx;height: 80upx;border-radius: 40upx;line-height: 80upx;margin-bottom: 40upx;color: #333;border: 2upx solid #007aff;background-color: #fff;padding: 0 40upx;}
+.user-pop .u-button::after{border: 0;}
+.user-pop .u-button.full{background-color: #007aff;color: #fff;}
+
 .popup-flex{display: flex;flex-direction: column;}
 .buy-godos-footer{padding: 20upx;display: flex;align-items: center;justify-content: space-between;gap: 20upx;}
 .buy-godos-footer .btn-item.fex1{flex: 1;}

+ 15 - 1
pages/order/detail.vue

@@ -338,7 +338,21 @@ export default {
 					return ;
 				}
 				uni.setStorageSync("poiId",res.data.poi_id);
-				app.poiData = res.data.poi;
+				app.poiData = res.data.poi;
+				const storeDataTemp = {
+					"end_at":app.poiData.end_at,
+					"latitude":app.poiData.latitude,
+					"longitude":app.poiData.longitude,
+					"poi_address":app.poiData.poi_address,
+					"poi_city":app.poiData.poi_city,
+					"poi_id":app.poiData.poi_id,
+					"poi_logo":app.poiData.poi_logo,
+					"poi_name":app.poiData.poi_name,
+					"service_mobile":app.poiData.service_mobile,
+					"start_at":app.poiData.start_at
+				};
+				uni.setStorageSync("contact",storeDataTemp);
+				app.storeData = storeDataTemp;
 				app.goodsData = res.data.product;
 				app.orderData = res.data;
 				app.orderTime = res.data.end_time

+ 13 - 24
pages/service/chat/chat.vue

@@ -157,6 +157,7 @@
 				<view class="order-body" v-else>
 					<view class="empty-body">暂无数据...</view>
 				</view>
+				<view class="view-more" v-if="orderMore" @click="showOrder(1)">{{orderLoading?'加载中...':'展开更多'}}</view>
 			</view>
 		</uni-popup>		
 	</view>
@@ -213,6 +214,8 @@ export default {
 				allLoaded: false
 			},
 			showOrderState:false,
+			orderMore:false,
+			orderLoading:false,
 			storeData:null,
 			sendId:null,
 			myid:"",
@@ -334,29 +337,12 @@ export default {
 					var payInfo = data.payload.pay;
 					if (payInfo.status == 1) {
 						return this.$dialog.showSuccess("已完成支付")
-					}
-					uni.showLoading({
-						title:"发起中..."
-					})
-					Api.pricePay({order:payInfo.order}).then((res)=>{
-						uni.hideLoading()
-						if (res.code == 0) {
-							return app.$dialog.showSuccess(res.msg)
-						}
-						uni.requestPayment({
-							orderInfo:res.data.pay,
-							service:5,
-							success(resp){
-								if (resp.code == 0) { // res.code=0时,才表示支付成功
-									app.$dialog.showSuccess("支付成功","none",function(){
-										app.getService(app.optionsData)
-									});
-								}
-							},
-							fail(resp) {
-								app.$dialog.showSuccess("支付失败,可再次重试","none");
-							}
-						})
+					}
+					uni.navigateToMiniProgram({
+						appId:payInfo.appid,
+						path:payInfo.path,
+						success(){},
+						fail(){}
 					})
 				break;
 				default:
@@ -396,13 +382,16 @@ export default {
 				this.$refs.orderpopup.close()
 				return ;
 			}
+			this.orderLoading = true;
 			Api.order({"size":this.size,"page":this.orderPage}).then((res)=>{
+				this.orderLoading = false;
 				if (res.code == 0) {
 					return this.$dialog.showSuccess(res.msg)
 				}
 				this.orderData = this.orderData.concat(res.data.rows);
 				this.$refs.orderpopup.open()
 				this.orderPage = res.data.page + 1;
+				this.orderMore = true;
 			})
 		},
 		getMoreMsg(){
@@ -817,7 +806,7 @@ export default {
 .order-popup .order-title{display: flex;align-items: center;justify-content: space-between;font-size: 28upx;padding: 20upx;}
 .order-popup .order-title image{width: 40upx;height: 40upx;}
 .order-popup .order-body{height: 40vh;overflow: auto;padding: 20upx;}
-
+.view-more{text-align: center;font-size: 24upx;color: #666;padding: 20upx;}
 .submit-btn{
 	background-color: #fff;
 	border-radius: 20upx 0;

+ 9 - 1
static/api/auth.js

@@ -4,7 +4,15 @@ const apiUri = {
 	login: '/auth/mobile',
 	nickname: '/auth/nickname',
 	check: '/auth/check',
-	save: '/user/save'
+	save: '/user/save',
+	mobileAuth: '/auth/mobile/auth',
+	nicknameAuth: '/auth/nickname/auth',
+}
+export function mobileAuth(param) {
+	return request.request(apiUri.mobileAuth,'POST', param,false,true,false)
+}
+export function nicknameAuth(param) {
+	return request.request(apiUri.nicknameAuth,'POST', param,false,true,false)
 }
 
 export function nickname(param) {

+ 10 - 1
static/api/goods.js

@@ -4,7 +4,16 @@ const apiUri = {
 	login: '/auth/mobile',
 	data: '/goods/data',
 	add: '/goods/add_order',
-	save: '/user/save'
+	save: '/user/save',
+	mobileAuth: '/auth/mobile/auth',
+	nicknameAuth: '/auth/nickname/auth',
+}
+
+export function mobileAuth(param) {
+	return request.request(apiUri.mobileAuth,'POST', param,false,true,false)
+}
+export function nicknameAuth(param) {
+	return request.request(apiUri.nicknameAuth,'POST', param,false,true,false)
 }
 
 export function login(param) {