From 997036b27927bcc1e9207a40b7a69c106a10f30c Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期三, 31 七月 2024 15:49:52 +0800
Subject: [PATCH] Merge branch 'master' of http://139.186.142.91:10010/r/productDev/zbomyoujia

---
 wechat_staff/app.js                           |   44 ++++----------
 wechat_staff/utils/config.js                  |    4 
 wechat_staff/pages/login/index.js             |   59 ++++++++++++++++---
 wechat_staff/api/index.js                     |    4 +
 wechat_staff/components/detailFooter/index.js |    3 
 wechat_staff/utils/request.js                 |   14 +++-
 6 files changed, 76 insertions(+), 52 deletions(-)

diff --git a/wechat_staff/api/index.js b/wechat_staff/api/index.js
index c7d07d3..603175d 100644
--- a/wechat_staff/api/index.js
+++ b/wechat_staff/api/index.js
@@ -11,6 +11,7 @@
 }
 // 楠岃瘉鐮佺櫥褰�
 export const loginByPhone = (data) => {
+  console.log(data)
   return request({
     url: '/web/personnel/loginByPhone',
     data
@@ -56,9 +57,10 @@
   })
 }
 // 鑾峰彇浼氬憳淇℃伅
-export const getMemberInfo = () => {
+export const getMemberInfo = (data) => {
   return request({
     url: '/web/personnel/getUserDetail',
+    data:data
   })
 }
 // 鏇存柊浼氬憳淇℃伅
diff --git a/wechat_staff/app.js b/wechat_staff/app.js
index d83da7c..553e978 100644
--- a/wechat_staff/app.js
+++ b/wechat_staff/app.js
@@ -1,5 +1,6 @@
 import {
-  wxLoginCustomer
+  wxLoginCustomer,
+  getMemberInfo
 } from './api/index'
 App({
   globalData: {
@@ -12,35 +13,14 @@
     if (WindowInfo.safeArea.top > 20) {
       this.globalData.bottomLift = WindowInfo.screenHeight - WindowInfo.safeArea.bottom;
     }
-    wx.login({
-      timeout: 5000,
-      success(res) {
-        if (res.code) {
-          //鍙戣捣缃戠粶璇锋眰
-          wxLoginCustomer({
-            code: res.code
-          }).then(res => {
-            if (res && res.data) {
-              wx.setStorageSync('member', res.data.users || '')
-              wx.setStorageSync('sessionKey', res.data.sessionKey)
-              wx.setStorageSync('token', res.data.token || '')
-            } else {
-              wx.navigateTo({
-                url: '/pages/login/index',
-              })
-              console.log('鐧诲綍澶辫触锛�')
-            }
-          })
-        } else {
-          wx.navigateTo({
-            url: '/pages/login/index',
-          })
-          console.log('鐧诲綍澶辫触锛�' + res)
-        }
-      },
-      fail(err) {
-        console.log(err)
-      }
-    })
-  }
+    let users =  wx.getStorageSync('token') 
+    if(users ==null){
+      wx.navigateTo({
+        url: '/pages/login/index',
+      })
+    }else{
+      getMemberInfo({goLogin:true}).then(res => {  
+      }) 
+    }
+  }, 
 })
\ No newline at end of file
diff --git a/wechat_staff/components/detailFooter/index.js b/wechat_staff/components/detailFooter/index.js
index a8410a0..6d78a1a 100644
--- a/wechat_staff/components/detailFooter/index.js
+++ b/wechat_staff/components/detailFooter/index.js
@@ -78,8 +78,7 @@
           isShowPoster: true,
           showShare: false,
           posterUrl: res.data
-        })
-
+        }) 
       })
     },
     saveCard() {
diff --git a/wechat_staff/pages/login/index.js b/wechat_staff/pages/login/index.js
index 084b641..98dbf50 100644
--- a/wechat_staff/pages/login/index.js
+++ b/wechat_staff/pages/login/index.js
@@ -3,7 +3,8 @@
   getDictData,
   getWxMiniPhone,
   loginByPhone,
-  bindingOpenid
+  bindingOpenid,
+  wxLoginCustomer
 } from '../../api/index'
 Page({
 
@@ -16,6 +17,7 @@
     status: '0', // 鏍囪瘑
     countDown: 0,
     phone: '',
+    openid:'',
     code: '',
     showModal: false,
     activeHtml: '',
@@ -62,7 +64,8 @@
   loginPhone() {
     const {
       code,
-      phone
+      phone,
+      openid
     } = this.data
     if (!this.data.agreementFalg) {
       return wx.showToast({
@@ -85,17 +88,18 @@
 
     loginByPhone({
       code,
+      openid,
       phone
     }).then(res => {
       if (res.data && res.data.token) {
-        wx.login({
-          timeout: 5000,
-          success: (loginRes) =>  {
-            if (loginRes.code) {
-              this.bindingOpenid(loginRes.code, res.data.token)
-            }
-          }
-        })
+        // wx.login({
+        //   timeout: 5000,
+        //   success: (loginRes) =>  {
+        //     if (loginRes.code) {
+        //       this.bindingOpenid(loginRes.code, res.data.token)
+        //     }
+        //   }
+        // })
         if(res.data.phone){
           res.data.users.phone = res.data.phone || res.data.users.phone
         }
@@ -132,8 +136,43 @@
       primary: app.primary,
       bottomLift: app.bottomLift
     })
+    this.autoLogin()
     this.initData()
   },
+  autoLogin(){
+    var that =this
+    wx.login({
+      timeout: 5000,
+      success(res) {
+        if (res.code) {
+          //鍙戣捣缃戠粶璇锋眰
+          wxLoginCustomer({
+            code: res.code
+          }).then(res => {
+            console.log(res)
+            wx.setStorageSync('sessionKey', res.data.sessionKey)
+            that.setData({openid:res.data.openid})
+            if (res && res.data !=null && res.data.token!=null) { 
+              console.log(res)
+              wx.setStorageSync('member', res.data.users || '')
+              wx.setStorageSync('token', res.data.token || '')
+              wx.switchTab({
+                url: '/pages/index/index',
+              }) 
+            } 
+          })
+        } else {
+          wx.navigateTo({
+            url: '/pages/login/index',
+          })
+          console.log('鐧诲綍澶辫触锛�' + res)
+        }
+      },
+      fail(err) {
+        console.log(err)
+      }
+    })
+  },
   getPhoneNumber(e) {
     const data = {
       ...e.detail
diff --git a/wechat_staff/utils/config.js b/wechat_staff/utils/config.js
index e672602..a150c8d 100644
--- a/wechat_staff/utils/config.js
+++ b/wechat_staff/utils/config.js
@@ -1,5 +1,5 @@
-// export const baseUrl = 'http://192.168.0.135:10027' 
-export const baseUrl = 'https://dmtest.ahapp.net/web_interface' // 鏈湴
+export const baseUrl = 'http://192.168.0.135:10027' 
+// export const baseUrl = 'https://dmtest.ahapp.net/web_interface' // 鏈湴
 // export const baseUrl = 'http://zbtest.ahapp.net/zbom_interface/jx/wechat/' //娴嬭瘯鏈嶅姟鍣�
 
 // export const imageUrl = 'https://osswebcdn.zbom.com/jiaxuan/images/'
diff --git a/wechat_staff/utils/request.js b/wechat_staff/utils/request.js
index 87ecfb4..8751ff4 100644
--- a/wechat_staff/utils/request.js
+++ b/wechat_staff/utils/request.js
@@ -6,7 +6,7 @@
     wx.showLoading()
     number++
   }
-  return new Promise(resolve => {
+  return new Promise(resolve=> {
     wx.request({
       url: baseUrl + options.url,
       data: options.data || {},
@@ -21,10 +21,14 @@
           resolve(res.data || true)
         } else {
           if (res.data.code && (res.data.code == 5112 || res.data.code == 5111)) {
-            wx.navigateTo({
-              url: '/pages/login/index',
-            })
-          }
+            if(options.data && options.data.goLogin){
+              console.log("==================")
+              wx.navigateTo({
+                        url: '/pages/login/index',
+              })
+            } 
+          } 
+          resolve(res) 
           res.data.message && wx.showToast({
             title: res.data.message || '鍙戠敓閿欒',
             icon: 'none'

--
Gitblit v1.9.3