瀏覽代碼

'2023年8月3日10:39:35'

yxb
wq 1 年之前
父節點
當前提交
a636152802
共有 4 個檔案被更改,包括 35 行新增9 行删除
  1. 1
    1
      login/login.vue
  2. 4
    1
      stores/user.js
  3. 1
    0
      utils/network/api.js
  4. 29
    7
      utils/network/request.js

+ 1
- 1
login/login.vue 查看文件

loginTime: loginTime, loginTime: loginTime,
}); });
} }
};
};


/* 执行登录 */ /* 执行登录 */
const reqLogin = (code : string, data : object) => { const reqLogin = (code : string, data : object) => {

+ 4
- 1
stores/user.js 查看文件

import { import {
appId, appId,
getToken, getToken,
wechatAppID
wechatAppID,
updateToken
} from "@/utils/network/api"; } from "@/utils/network/api";
import { import {
stringToJson stringToJson
}); });
}, },



/*退出登录*/ /*退出登录*/
loginOutNoConfirm() { loginOutNoConfirm() {
msg("退出登录成功!"); msg("退出登录成功!");

+ 1
- 0
utils/network/api.js 查看文件

export const loginCode = "1005"; //统一会员平台个人账号手机号验证码登录 export const loginCode = "1005"; //统一会员平台个人账号手机号验证码登录
export const resetPwd = "1009"; //会员平台个人账号修改密码手机号验证码接口 export const resetPwd = "1009"; //会员平台个人账号修改密码手机号验证码接口
export const getToken = "1006"; //统一会员平台登录确认接口(用于换取openId和token) export const getToken = "1006"; //统一会员平台登录确认接口(用于换取openId和token)
export const updateToken = "225aa780a91b40f0b44e7e5fe204fc9a"; //统一会员平台登录确认接口(用于换取openId和token)
export const checkCode = "966"; //校验验证码 export const checkCode = "966"; //校验验证码
export const register = "52de4029940f4e03b18c3a0b8d64c2db";//USER-无感注册登录(个人/企业) export const register = "52de4029940f4e03b18c3a0b8d64c2db";//USER-无感注册登录(个人/企业)

+ 29
- 7
utils/network/request.js 查看文件

} from '../util/sm4.js' } from '../util/sm4.js'
const s4 = new SM4Util() const s4 = new SM4Util()


function updateToken(){
let toole = 0;

/* 刷新token */
function updateToken() {
const options = { const options = {
type: 2, type: 2,
data: { data: {
mobilePhone: getItem("mobile")
openId: getItem("openId"),
accessToken: getItem("accessToken")
}, },
method: "POST", method: "POST",
showLoading: false, showLoading: false,
}; };
//刷新token //刷新token
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
const res = await request('225aa780a91b40f0b44e7e5fe204fc9a', options);
const res = await request(updateToken, options);
const data = stringToJson(res.bizContent); const data = stringToJson(res.bizContent);
console.log("data", data) console.log("data", data)
this.saveToken(data.accessToken);
this.saveOpenId(data.openId);
console.log('输出内容', data.openId)
setItem('accessToken', data.accessToken);
setItem('openId', data.openId);
resolve(data); resolve(data);
}).catch((error) => { }).catch((error) => {
reject(error); reject(error);


//请求 //请求
export function request(code, options = {}) { export function request(code, options = {}) {
// request(code,options)
//公参 //公参
const Common = { const Common = {
agentId: "52010106004", agentId: "52010106004",
} }
} }
}); });
} else if (res.data.statusCode == 34567) {
toole++
if (toole > 2) {
updateToken(result.code).then((data) => {
console.log("token刷新", data);
request(code, options)
});
} else {
uni.showModal({
title: '提示',
content: res.data.errorMsg,
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
} else { } else {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',

Loading…
取消
儲存