环境token
This commit is contained in:
parent
5130ea5c7a
commit
28d49809e6
@ -118,7 +118,13 @@ Page({
|
||||
app.imLogout();
|
||||
url = "/Pages/yaoshi/home/home";
|
||||
}
|
||||
let token = wx.getStorageSync('AUTH_TOKEN_'+usertype);
|
||||
let token = '';
|
||||
const { envVersion } = wx.getAccountInfoSync().miniProgram;
|
||||
if(envVersion=='release'){
|
||||
token= wx.getStorageSync('AUTH_TOKEN_'+usertype)
|
||||
}else{
|
||||
token= wx.getStorageSync('DEV_AUTH_TOKEN_'+usertype)
|
||||
}
|
||||
console.log(token);
|
||||
console.log(url);
|
||||
if(token){
|
||||
|
||||
@ -35,7 +35,14 @@ Page({
|
||||
success (res) {
|
||||
if (res.confirm) {
|
||||
console.log('用户点击确定')
|
||||
wx.setStorageSync('AUTH_TOKEN_'+usertype, "");
|
||||
//wx.setStorageSync('AUTH_TOKEN_'+usertype, "");
|
||||
const { envVersion } = wx.getAccountInfoSync().miniProgram;
|
||||
if(envVersion=='release'){
|
||||
wx.setStorageSync('AUTH_TOKEN_'+usertype, '');
|
||||
}else{
|
||||
wx.setStorageSync('DEV_AUTH_TOKEN_'+usertype,'');
|
||||
|
||||
}
|
||||
wx.setStorageSync('user_id_'+usertype, "");
|
||||
wx.setStorageSync('client_user_id_'+usertype, "");
|
||||
app.globalData.isLogin=false;
|
||||
|
||||
@ -87,7 +87,8 @@
|
||||
</view>
|
||||
<view class="content_4" wx:if="{{ item.inquiry_status == 3 }}">
|
||||
<text wx:if="{{item.inquiry_type ==2 || item.inquiry_type ==4}}">不接诊5分钟后自动取消</text>
|
||||
<text wx:elif="{{item.inquiry_type ==3 || item.inquiry_type ==1}}">不接诊24小时后自动取消</text>
|
||||
<text wx:elif="{{item.inquiry_type ==3 || (item.inquiry_type ==1 && item.inquiry_mode!=8 && item.inquiry_mode!=9)}}">不接诊24小时后自动取消</text>
|
||||
<text wx:elif="{{item.inquiry_type ==1 && (item.inquiry_mode==8 || item.inquiry_mode==9)}}">不接诊72小时后自动取消</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- aa -->
|
||||
|
||||
9
app.js
9
app.js
@ -49,6 +49,7 @@ App({
|
||||
if(userID == ""){
|
||||
return;
|
||||
}
|
||||
|
||||
this.globalData.config.userID = userID;
|
||||
// let sign = genTestUserSig(this.globalData.config);
|
||||
// console.log("sign: ", sign);
|
||||
@ -170,7 +171,13 @@ App({
|
||||
onKickedOut(){
|
||||
// console.log("onKickedOutonKickedOutonKickedOutonKickedOut");
|
||||
let usertype = wx.getStorageSync('usertype');
|
||||
wx.setStorageSync('AUTH_TOKEN_'+usertype, "");
|
||||
// wx.setStorageSync('AUTH_TOKEN_'+usertype, "");
|
||||
const { envVersion } = wx.getAccountInfoSync().miniProgram;
|
||||
if(envVersion=='release'){
|
||||
wx.setStorageSync('AUTH_TOKEN_'+usertype, '');
|
||||
}else{
|
||||
wx.setStorageSync('DEV_AUTH_TOKEN_'+usertype, '');
|
||||
}
|
||||
wx.setStorageSync('user_id_'+usertype, "");
|
||||
wx.setStorageSync('client_user_id_'+usertype, "");
|
||||
if(wx.$TUIKit){
|
||||
|
||||
@ -145,8 +145,15 @@ Page({
|
||||
wx_code: res.code
|
||||
}
|
||||
api.wechatMobileLogin(params).then(response => {
|
||||
console.log(response);
|
||||
wx.setStorageSync('AUTH_TOKEN_'+usertype, response.data.token);
|
||||
// console.log(response);
|
||||
const { envVersion } = wx.getAccountInfoSync().miniProgram;
|
||||
if(envVersion=='release'){
|
||||
wx.setStorageSync('AUTH_TOKEN_'+usertype, response.data.token);
|
||||
}else{
|
||||
wx.setStorageSync('DEV_AUTH_TOKEN_'+usertype, response.data.token);
|
||||
|
||||
}
|
||||
|
||||
wx.setStorageSync('user_id_'+usertype, response.data.user_id);
|
||||
wx.setStorageSync('client_user_id_'+usertype, response.data.client_user_id);
|
||||
app.globalData.config.userID = response.data.user_id;
|
||||
|
||||
@ -138,8 +138,14 @@ Page({
|
||||
|
||||
api.mobileLogin(params).then(response => {
|
||||
app.globalData.isLogin=true;
|
||||
console.log(response);
|
||||
wx.setStorageSync('AUTH_TOKEN_'+usertype, response.data.token);
|
||||
const { envVersion } = wx.getAccountInfoSync().miniProgram;
|
||||
if(envVersion=='release'){
|
||||
wx.setStorageSync('AUTH_TOKEN_'+usertype, response.data.token);
|
||||
}else{
|
||||
wx.setStorageSync('DEV_AUTH_TOKEN_'+usertype, response.data.token);
|
||||
|
||||
}
|
||||
// wx.setStorageSync('AUTH_TOKEN_'+usertype, response.data.token);
|
||||
wx.setStorageSync('user_id_'+usertype, response.data.user_id);
|
||||
wx.setStorageSync('client_user_id_'+usertype, response.data.client_user_id);
|
||||
app.globalData.config.userID = response.data.user_id;
|
||||
|
||||
@ -35,7 +35,13 @@ Page({
|
||||
success (res) {
|
||||
if (res.confirm) {
|
||||
console.log('用户点击确定')
|
||||
wx.setStorageSync('AUTH_TOKEN_'+usertype, "");
|
||||
const { envVersion } = wx.getAccountInfoSync().miniProgram;
|
||||
if(envVersion=='release'){
|
||||
wx.setStorageSync('AUTH_TOKEN_'+usertype, '');
|
||||
}else{
|
||||
wx.setStorageSync('DEV_AUTH_TOKEN_'+usertype, '');
|
||||
}
|
||||
// wx.setStorageSync('AUTH_TOKEN_'+usertype, "");
|
||||
wx.setStorageSync('user_id_'+usertype, "");
|
||||
wx.setStorageSync('client_user_id_'+usertype, "");
|
||||
app.globalData.isLogin=false;
|
||||
|
||||
@ -51,7 +51,13 @@ Page({
|
||||
if (res.confirm) {
|
||||
console.log('用户点击确定')
|
||||
let usertype = wx.getStorageSync('usertype');
|
||||
wx.setStorageSync('AUTH_TOKEN_'+usertype, "");
|
||||
const { envVersion } = wx.getAccountInfoSync().miniProgram;
|
||||
if(envVersion=='release'){
|
||||
wx.setStorageSync('AUTH_TOKEN_'+usertype, '');
|
||||
}else{
|
||||
wx.setStorageSync('DEV_AUTH_TOKEN_'+usertype, '');
|
||||
}
|
||||
// wx.setStorageSync('AUTH_TOKEN_'+usertype, "");
|
||||
wx.setStorageSync('user_id_'+usertype, "");
|
||||
|
||||
wx.setStorageSync('client_user_id_'+usertype, "");
|
||||
|
||||
@ -28,19 +28,32 @@ class HTTP {
|
||||
_request(url, resolve, reject, data = {}, method = 'GET', contentType = 'application/json', showLoading = true) {
|
||||
if(showLoading) wx.showLoading();
|
||||
let usertype = wx.getStorageSync('usertype');
|
||||
let token='';
|
||||
const { envVersion } = wx.getAccountInfoSync().miniProgram;
|
||||
if(envVersion=='release'){
|
||||
token= wx.getStorageSync('AUTH_TOKEN_'+usertype)
|
||||
}else{
|
||||
token= wx.getStorageSync('DEV_AUTH_TOKEN_'+usertype)
|
||||
}
|
||||
wx.request({
|
||||
url: url,
|
||||
method: method,
|
||||
data: data,
|
||||
header: {
|
||||
'content-type': contentType,
|
||||
'Authorization': "Bearer " + wx.getStorageSync('AUTH_TOKEN_'+usertype)
|
||||
'Authorization': "Bearer " + token
|
||||
},
|
||||
success: (res) => {
|
||||
// console.log("header Authorization: ", res.header.Authorization);
|
||||
var Authorization_token = res.header.Authorization;
|
||||
if(Authorization_token){
|
||||
wx.setStorageSync('AUTH_TOKEN_'+usertype, Authorization_token);//当token快过期时,服务器会返回新token,本地刷新
|
||||
const { envVersion } = wx.getAccountInfoSync().miniProgram;
|
||||
if(envVersion=='release'){
|
||||
wx.setStorageSync('AUTH_TOKEN_'+usertype, Authorization_token);//当token快过期时,服务器会返回新token,本地刷新
|
||||
}else{
|
||||
wx.setStorageSync('DEV_AUTH_TOKEN_'+usertype, Authorization_token);//当token快过期时,服务器会返回新token,本地刷新
|
||||
}
|
||||
|
||||
}
|
||||
if (res.data) {
|
||||
const code = res.data.code;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user