From f6ea728ea50706b1dfa75bc0d266fb6b5f13ef7f Mon Sep 17 00:00:00 2001
From: jazz <jazzxhunter@163.com>
Date: 星期二, 09 一月 2024 19:29:29 +0800
Subject: [PATCH] Merge branch 'xio_dev'

---
 src/utils/jun_login.js |  160 ++++++++++++++++++++++++++---------------------------
 1 files changed, 78 insertions(+), 82 deletions(-)

diff --git a/src/utils/jun_login.js b/src/utils/jun_login.js
index 7eef385..eff9513 100644
--- a/src/utils/jun_login.js
+++ b/src/utils/jun_login.js
@@ -9,35 +9,35 @@
 import Config from '../config'
 // import { Message } from 'element-ui'
 
-let config = {
-	// 鐧诲綍璇锋眰鎺ュ彛閾炬帴
-	url: 'weixin!ajaxGetInfoByCode',
-	// 2灏忔椂杩囨湡
-	expire: 7.2e6,
+const config = {
+  // 鐧诲綍璇锋眰鎺ュ彛閾炬帴
+  url: 'weixin!ajaxGetInfoByCode',
+  // 2灏忔椂杩囨湡
+  expire: 7.2e6
 }
 
 /**
  * 妫�鏌ョ櫥褰曠紦瀛樿繃鏈燂紝榛樿涓嶈繃鏈�
  * @param {object} we_session 缂撳瓨瀵硅薄
  */
-function checkExpire(we_session){
-	// if ((we_session && Date.now() >= we_session.expire) || !we_session) {
-	// 	// 鍒犻櫎store缂撳瓨
-	//  Store.commit('unLogined')
-	// 	// wx.removeStorageSync('we_session')
-	// 	localStorage.removeItem('we_session')
-	// 	return true
-	// }
-	return false
+function checkExpire(we_session) {
+  // if ((we_session && Date.now() >= we_session.expire) || !we_session) {
+  // 	// 鍒犻櫎store缂撳瓨
+  //  Store.commit('unLogined')
+  // 	// wx.removeStorageSync('we_session')
+  // 	localStorage.removeItem('we_session')
+  // 	return true
+  // }
+  return false
 }
 
 /**
  * 杩涘叆寰俊闀块摼锛屽彲鑾峰彇code
  */
-function toLongUrl () {
-	// fn.urlReplace(Config.codeUrl)
-	// location.href = Config.codeUrl
-	location.href = Config.createCodeUrl()
+function toLongUrl() {
+  // fn.urlReplace(Config.codeUrl)
+  // location.href = Config.codeUrl
+  location.href = Config.createCodeUrl()
 }
 
 /**
@@ -46,80 +46,76 @@
  * @param {boolean}  option.force 鏄惁寮哄埗閲嶆柊鐧诲綍
  * @param {function} option.callback 鐧诲綍鎴愬姛鍚庡洖璋�
  */
-function checkLogin(option={}){
-	loginReq(option).then(()=>{
-		if (typeof option.callback === 'function') {
-			option.callback()
-		}
-	})
+function checkLogin(option = {}) {
+  loginReq(option).then(() => {
+    if (typeof option.callback === 'function') {
+      option.callback()
+    }
+  })
 }
 
 /**
  * 鐧诲綍璇锋眰
- * @param {object} option 
+ * @param {object} option
  * @param {object} option.data 璇锋眰鍙傛暟
  */
-function loginReq(option){
-	
-	if (Config.ismock || Config.istest) {
-		option.data.code = '011h5c000ySdaK1lbw000ubdtm2h5c00'
-	}
+function loginReq(option) {
+  if (Config.ismock || Config.istest) {
+    option.data.code = '011h5c000ySdaK1lbw000ubdtm2h5c00'
+  }
 
-	return new Promise((resolve, reject)=>{
-		// 鍓嶇疆鍒ゆ柇
-		let userData = Store.getters.getUserData
-		if (userData.key) {
-			resolve(userData)
-			return
-		}
+  return new Promise((resolve, reject) => {
+    // 鍓嶇疆鍒ゆ柇
+    const userData = Store.getters.getUserData
+    if (userData.key) {
+      resolve(userData)
+      return
+    }
 
-		if (!option || !option.data) {
-			reject()
-			console.error('璋冪敤loginReq锛岀己澶� option')
-			return
-		}
-		if (!option.data.code) {
-			console.error('璋冪敤loginReq锛岀己澶� code')
-			reject()
-			return
-		}
-		Req.http3.post({
-			url: config.url,
-			data: option.data
-		}).then((res)=>{
-			// 缂撳瓨key鍊�
-			fn.setLocalStorage('we_session', {
-				we_session: res.inf.key,
-				expire: Date.now() + config.expire
-			})
-			// 缂撳瓨鐢ㄦ埛鏁版嵁
-			Store.commit('setUserData', res.inf)
-			console.log(res.inf)
+    if (!option || !option.data) {
+      reject()
+      console.error('璋冪敤loginReq锛岀己澶� option')
+      return
+    }
+    if (!option.data.code) {
+      console.error('璋冪敤loginReq锛岀己澶� code')
+      reject()
+      return
+    }
+    Req.http3.post({
+      url: config.url,
+      data: option.data
+    }).then((res) => {
+      // 缂撳瓨key鍊�
+      fn.setLocalStorage('we_session', {
+        we_session: res.inf.key,
+        expire: Date.now() + config.expire
+      })
+      // 缂撳瓨鐢ㄦ埛鏁版嵁
+      Store.commit('setUserData', res.inf)
+      console.log(res.inf)
 
-			// if (res.inf.name) {
-			// 	Store.commit('setNickName', res.inf.name)
-			// }
-	
-			// 澶勭悊鐧诲綍瀹屾垚 store
-			// getUserInfo().then(_res=>{
-			// 	// Store.commit('setLogined', _res.inf)
-			// 	resolve(res)
-			// })
-			// Store.commit('setLogined')
+      // if (res.inf.name) {
+      // 	Store.commit('setNickName', res.inf.name)
+      // }
 
-			resolve(res)
-			
-		}).catch((res)=>{
-			console.log(res)
-			reject(res)
-		})
-	})
+      // 澶勭悊鐧诲綍瀹屾垚 store
+      // getUserInfo().then(_res=>{
+      // 	// Store.commit('setLogined', _res.inf)
+      // 	resolve(res)
+      // })
+      // Store.commit('setLogined')
+
+      resolve(res)
+    }).catch((res) => {
+      console.log(res)
+      reject(res)
+    })
+  })
 }
 
-
-
 export default {
-	checkLogin,
-	loginReq,
-	toLongUrl
-}
\ No newline at end of file
+  checkLogin,
+  loginReq,
+  toLongUrl
+}

--
Gitblit v1.8.0