From 39613118a5bae23c45498c4f5a939e83595f99f5 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期二, 16 七月 2024 16:05:00 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 wechat_jiaxuan/pages/auth/auth.js |   88 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 85 insertions(+), 3 deletions(-)

diff --git a/wechat_jiaxuan/pages/auth/auth.js b/wechat_jiaxuan/pages/auth/auth.js
index 208eec1..7557404 100644
--- a/wechat_jiaxuan/pages/auth/auth.js
+++ b/wechat_jiaxuan/pages/auth/auth.js
@@ -1,4 +1,8 @@
-// pages/auth/auth.js
+import {
+  wxLoginCustomer,
+  getDictData,
+  getWxMiniPhone
+} from '../../api/index'
 Page({
 
   /**
@@ -6,9 +10,86 @@
    */
   data: {
     agreementFalg: false,
-    primary: ''
-  },
+    primary: '',
 
+    showModal: false,
+    serviceHtml: '',
+    title: '',
+    privacyHtml: '',
+    activeHtml: ''
+  },
+  initData(){
+    getDictData({
+      code: 'ZBOM_CUSTOMIZED',
+      label: 'SERVER_AGREEMENT'
+    }).then(res => {
+      this.setData({
+        serviceHtml: res.data.code
+      })
+    })
+    getDictData({
+      code: 'ZBOM_CUSTOMIZED',
+      label: 'PRIVACY_AGREEMENT'
+    }).then(res => {
+      this.setData({
+        privacyHtml: res.data.code
+      })
+    })
+  },
+  getPhoneNumber (e) {
+    console.log(e.detail)
+    console.log(e.detail.iv)
+    console.log(e.detail.encryptedData)
+    const data = { ...e.detail }
+    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',
+            })
+          })
+        } else {
+          console.error('鑾峰彇鐢ㄦ埛鐧诲綍鍑瘉澶辫触', res.errMsg);
+        }
+      },
+      fail: (err) => {
+        console.error('璋冪敤 wx.login 澶辫触', err);
+      },
+    })
+  },
+  onOpen(e){
+    console.log('e', e);
+    const { serviceHtml, privacyHtml } = this.data
+    const { index } = e.target.dataset
+    let activeHtml = index == '0' ? serviceHtml : privacyHtml
+    this.setData({
+      activeHtml,
+      showModal: true
+    })
+  },
+  onClose(){
+    this.setData({showModal: false})
+  },
   agreementChange(e) {
     this.setData({
       agreementFalg: e.detail,
@@ -19,6 +100,7 @@
     this.setData({
       primary: app.primary
     })
+    this.initData()
   },
 
   /**

--
Gitblit v1.9.3