zhengkaixin hai 4 meses
pai
achega
3f65aef2ea
Modificáronse 3 ficheiros con 74 adicións e 32 borrados
  1. 9 8
      apis/weixin.js
  2. 64 23
      components/componentLogin.vue
  3. 1 1
      config/.env.dev.js

+ 9 - 8
apis/weixin.js

@@ -34,6 +34,14 @@ export function findUserPhoneNumber(code) {
 	})
 }
 
+//根据code换取openid
+export function decryptData(data) {
+	return request({
+		url: '/wechatMini/decryptData/',
+		data: data,
+		method: 'post',
+	})
+}
 
 //////////////////////////////////////////////////////
 export function saveLoginRecord(data) {
@@ -74,14 +82,7 @@ export function findListByCatalogName(data) {
 }
 
 
-//根据code换取openid
-export function decryptData(data) {
-	return request({
-		url: '/wechat/decryptData/',
-		data: data,
-		method: 'post',
-	})
-}
+
 
 export function newsList(data) {
  	return request({

+ 64 - 23
components/componentLogin.vue

@@ -9,6 +9,13 @@
 					<view class="span">智泊e家</view>
 				</view>
 				<view>
+					<button class="login-btn" @click="decryptPhoneNumberTest" 
+						
+						
+						>
+						<u-icon name="phone-fill" size="46"></u-icon> <text>手机号码一键登录test</text>
+					</button>
+					
 					<button class="login-btn" @click="decryptPhoneNumberH5" open-type="getPhoneNumber"
 						@getphonenumber="decryptPhoneNumber"
 						
@@ -114,6 +121,32 @@
 					})
 				}
 			},
+			decryptPhoneNumberTest() {
+				
+				this.show = false
+				var _this = this
+				uni.showModal({
+					title: '输入手机号测试',
+					editable: true,
+					//content: '这是一个模态弹窗',
+					success: function(res) {
+			
+						if (res.confirm) {
+							//_this.createUser(res.content)
+							if (_this.userInfo.id) {
+								_this.changePhoneUser(res.content)
+								
+							} else{
+								_this.createUser(res.content)
+								
+							}
+						} else if (res.cancel) {
+							//.log('用户点击取消');
+						}
+					}
+				});
+				
+			},
 			decryptPhoneNumberH5() {
 				// #ifdef H5
 				this.show = false
@@ -181,34 +214,42 @@
 			
 			
 				} else {
-					uni.showLoading({
-						title: "加载中",
-						mask: true,
-					})
-					API_weixin.findUserPhoneNumber(e.detail.code).then((res) => {
-						if (res.data) {
-							this.createUser(res.data)
-			
-						} else {
-							uni.showToast({
-								icon: 'none',
-								title: "获取手机号失败,请检查"
+					if(e.detail.code){
+						uni.showLoading({
+								title: "加载中",
+								mask: true,
 							})
-						}
-			
-			
-			
-					}).catch(error => {
-			
+							API_weixin.findUserPhoneNumber(e.detail.code).then((res) => {
+								if (res.data) {
+									this.createUser(res.data)
+									
+								} else {
+									uni.showToast({
+										icon: 'none',
+										title: "获取手机号失败,请检查"
+									})
+								}
+									
+									
+									
+							}).catch(error => {
+									
+								uni.showToast({
+									icon: 'none',
+									title: error
+								})
+								//this.getPhone()
+									
+							})
+						
+					}else{
 						uni.showToast({
 							icon: 'none',
-							title: error
+							title: "获取手机号失败"
 						})
-						//this.getPhone()
-			
-					})
+					}
+					
 				}
-			
 			},
 			
 		}

+ 1 - 1
config/.env.dev.js

@@ -1,7 +1,7 @@
 const UNI_APP = {  
 	ProjectName :"智泊e家",
 	BASE_URL: 'http://192.168.8.162:8081/floorlock/',
-	//BASE_URL:" https://youdian-test.hbjp.com.cn/floorlock-server/",
+	BASE_URL:" https://youdian-test.hbjp.com.cn/floorlock-server/",
 	//BASE_URL:"https://equipment.hbjp.com.cn/jk-temporary-workers-server/",
 	
 	PREFIX : "jp-floorlock-phone",