From 28cde0020f9a5566fc6a92e3023e5687459bd48f Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期二, 16 七月 2024 17:32:27 +0800
Subject: [PATCH] wxmini
---
wechat_jiaxuan/pages/auth/auth.js | 51 ++++++++++++++++++++-------------------------------
1 files changed, 20 insertions(+), 31 deletions(-)
diff --git a/wechat_jiaxuan/pages/auth/auth.js b/wechat_jiaxuan/pages/auth/auth.js
index 7557404..15defe7 100644
--- a/wechat_jiaxuan/pages/auth/auth.js
+++ b/wechat_jiaxuan/pages/auth/auth.js
@@ -1,7 +1,7 @@
import {
- wxLoginCustomer,
getDictData,
- getWxMiniPhone
+ getWxMiniPhone,
+ binDingPhone
} from '../../api/index'
Page({
@@ -36,6 +36,14 @@
})
})
},
+ loginIn() {
+ const { agreementFalg } = this.data
+ if(!agreementFalg) return wx.showToast({
+ title: '璇峰厛闃呰骞跺悓鎰忕浉鍏冲崗璁�',
+ icon: 'none',
+ duration: 2000
+ })
+ },
getPhoneNumber (e) {
console.log(e.detail)
console.log(e.detail.iv)
@@ -44,37 +52,18 @@
getWxMiniPhone({
encryptedData: data.encryptedData,
iv: data.iv,
- sessionKey: wx.getStorageSync('sessionKey'),
- })
- },
- loginIn() {
- const { agreementFalg } = this.data
- if(!agreementFalg) return wx.showToast({
- title: '璇峰厛闃呰骞跺悓鎰忕浉鍏冲崗璁�',
- icon: 'none',
- duration: 2000
- })
- wx.login({
- success: (res) => {
- if (res.code) {
- // 鑾峰彇鍒扮敤鎴风櫥褰曞嚟璇� code
- const code = res.code;
- wx.setStorageSync('code', res.code)
- // 灏� code 鍙戦�佺粰鍚庣鏈嶅姟鍣�
- wxLoginCustomer({code}).then(ress => {
- wx.setStorageSync('token', ress.data.token)
- wx.setStorageSync('member', ress.data.member)
- wx.redirectTo({
- url: '/pages/index/index',
- })
+ sessionKey: wx.getStorageSync('sessionKey') || data.iv,
+ }).then(res => {
+ binDingPhone({
+ phone: res.data
+ }).then((res) => {
+ if(res.code == 200){
+ wx.setStorageSync('member', res.data)
+ wx.switchTab({
+ url: '/pages/index/index',
})
- } else {
- console.error('鑾峰彇鐢ㄦ埛鐧诲綍鍑瘉澶辫触', res.errMsg);
}
- },
- fail: (err) => {
- console.error('璋冪敤 wx.login 澶辫触', err);
- },
+ })
})
},
onOpen(e){
--
Gitblit v1.9.3