| xqd
@@ -71,7 +71,7 @@
|
|
|
|
|
|
<view class="flex align-center justify-center" style="margin-top: 50rpx;">
|
|
|
<button size="default" :class="" style="border: 1rpx solid #84BB43;box-shadow: 0px 0px 16px 0px rgba(0, 0, 0, 0.08);border-radius: 60rpx;border: 0.3rpx solid #dedede;margin: 0;width: 100%;"
|
|
|
- open-type="getUserInfo" @getuserinfo="getinfo">
|
|
|
+ open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
|
|
|
<view :class="rotate_loop" style="font-size: 28rpx;color: #84BB43;">
|
|
|
<slot name="icon">
|
|
|
<u-icon name="weixin-fill" style="margin-right: 20rpx;" size="30"></u-icon>
|
| xqd
@@ -86,11 +86,10 @@
|
|
|
<view class="text-xl text-bold" style="position: absolute;top:30rpx">
|
|
|
提示
|
|
|
</view>
|
|
|
- <view class="text-gray margin-top-sm text-lg">
|
|
|
- 请授权手机号方便注册!
|
|
|
+ <view class="text-gray margin-top-sm text-df">
|
|
|
+ 请授权个人资料方便体验后续功能!
|
|
|
</view>
|
|
|
- <button style="width: 100%;font-size: 32rpx;position: absolute;bottom: 0;" open-type="getPhoneNumber"
|
|
|
- @getphonenumber="getPhoneNumber">确认授权</button>
|
|
|
+ <button style="width: 100%;font-size: 32rpx;position: absolute;bottom: 0;" open-type="getUserInfo" @getuserinfo="getinfo">确认授权</button>
|
|
|
</view>
|
|
|
</u-popup>
|
|
|
</view>
|
| xqd
@@ -123,7 +122,7 @@
|
|
|
//一键登录按钮样式
|
|
|
customStyle: {
|
|
|
boxShadow: '0px 0px 16px 0px rgba(0, 0, 0, 0.08)',
|
|
|
- backgroundColor:'#0C74B9'
|
|
|
+ backgroundColor: '#0C74B9'
|
|
|
},
|
|
|
//logo图片 base64
|
|
|
phoneData: '', // 用户/电话
|
| xqd
@@ -356,19 +355,16 @@
|
|
|
// 一键登录
|
|
|
getinfo: async function(e) {
|
|
|
let that = this;
|
|
|
- let meToken = user.loginByWeixin(e.detail.userInfo).then(res => {
|
|
|
- console.log('返回的res', res)
|
|
|
+ user.loginByWeixin(e.detail.userInfo, uni.getStorageSync('phone')).then(res => {
|
|
|
+ that.show = false
|
|
|
if (res.status == 0) {
|
|
|
- uni.showToast({
|
|
|
- title: "登录成功",
|
|
|
- icon: "none",
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
- console.log(res.data);
|
|
|
+ // uni.showToast({
|
|
|
+ // title: "登录成功",
|
|
|
+ // icon: "none",
|
|
|
+ // duration: 2000
|
|
|
+ // })
|
|
|
+ // console.log(res.data);
|
|
|
if (typeof res.data.token != 'undefined') {
|
|
|
-
|
|
|
- console.log('我登录来 !');
|
|
|
- console.log(res.data)
|
|
|
getApp().globalData.imService = new IMService();
|
|
|
let loginResult = getApp().globalData.imService.login({
|
|
|
uuid: res.data.data.flag,
|
| xqd
@@ -385,66 +381,59 @@
|
|
|
uni.showToast({
|
|
|
title: "登录成功",
|
|
|
icon: "none",
|
|
|
- duration: 2000
|
|
|
+ duration: 1000
|
|
|
})
|
|
|
setTimeout(function() {
|
|
|
- uni.navigateBack({
|
|
|
- delta: 1
|
|
|
- })
|
|
|
uni.switchTab({
|
|
|
- url: "../index/index"
|
|
|
+ url:'../index/index'
|
|
|
})
|
|
|
- }, 2000)
|
|
|
- } else {
|
|
|
- that.session_key = res.data.session_key
|
|
|
- that.openid = res.data.openid
|
|
|
- that.show = true
|
|
|
+ }, 1000)
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
|
|
|
- getPhoneNumber: async function(e) {
|
|
|
- let res = await this.$request.post("common/getPhoneNumber", {
|
|
|
- iv: e.detail.iv,
|
|
|
- encryptedData: e.detail.encryptedData,
|
|
|
- session_key: this.session_key,
|
|
|
- openid: this.openid
|
|
|
- })
|
|
|
- this.show = false
|
|
|
- if (res.status == 0) {
|
|
|
- if (res.data.token) {
|
|
|
- store.commit('setJwt', res.data.token);
|
|
|
- store.commit('setUser', res.data);
|
|
|
- store.commit('login');
|
|
|
- uni.showToast({
|
|
|
- title: "登录成功",
|
|
|
- icon: "none",
|
|
|
- duration: 2000
|
|
|
+ getPhoneNumber: function(e) {
|
|
|
+ uni.login({
|
|
|
+ success: (data) => {
|
|
|
+ console.log(data.code)
|
|
|
+ this.$request.post("common/getPhoneNumber", {
|
|
|
+ wechat_code: data.code,
|
|
|
+ iv: e.detail.iv,
|
|
|
+ encryptedData: e.detail.encryptedData,
|
|
|
+ // session_key: this.session_key,
|
|
|
+ // openid: this.openid
|
|
|
+ }).then(res => {
|
|
|
+ console.log(res)
|
|
|
+ if (res.status == 0) {
|
|
|
+ uni.setStorageSync('phone', res.data.phoneNumber)
|
|
|
+ this.show = true
|
|
|
+ // uni.showToast({
|
|
|
+ // title: "登录成功",
|
|
|
+ // icon: "none",
|
|
|
+ // duration: 1000
|
|
|
+ // })
|
|
|
+ // getApp().globalData.imService = new IMService();
|
|
|
+ // let loginResult = getApp().globalData.imService.login({
|
|
|
+ // uuid: res.data.data.flag,
|
|
|
+ // name: res.data.data.name,
|
|
|
+ // avatar: res.data.data.avatar
|
|
|
+ // });
|
|
|
+ // if (loginResult) {
|
|
|
+ // //连接IM
|
|
|
+ // getApp().globalData.imService.connectIM();
|
|
|
+ // }
|
|
|
+ // // 写一个跳转到首页
|
|
|
+ // setTimeout(function() {
|
|
|
+ // uni.navigateBack({
|
|
|
+ // delta: 1
|
|
|
+ // })
|
|
|
+ // }, 1000)
|
|
|
+ }
|
|
|
})
|
|
|
-
|
|
|
- console.log('我登录来 !');
|
|
|
- console.log(res.data)
|
|
|
- getApp().globalData.imService = new IMService();
|
|
|
- let loginResult = getApp().globalData.imService.login({
|
|
|
- uuid: res.data.data.flag,
|
|
|
- name: res.data.data.name,
|
|
|
- avatar: res.data.data.avatar
|
|
|
- });
|
|
|
- if (loginResult) {
|
|
|
- //连接IM
|
|
|
- getApp().globalData.imService.connectIM();
|
|
|
- }
|
|
|
- // 写一个跳转到首页
|
|
|
- setTimeout(function() {
|
|
|
- uni.navigateBack({
|
|
|
- delta: 1
|
|
|
- })
|
|
|
-
|
|
|
- }, 2000)
|
|
|
}
|
|
|
- }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|