尝试解决问题

This commit is contained in:
caoqianming 2021-05-27 22:45:53 +08:00
parent d4c219aaec
commit 94324e1e38
4 changed files with 30 additions and 29 deletions

42
app.js
View File

@ -2,10 +2,10 @@
App({
onLaunch: function () {
var that = this
//that.mplogin()
that.mplogin()
setInterval(that.reflesh,10*60*1000)
},
mplogin: function () {
mplogin: function ( redirect = 0) {
var that = this;
wx.showLoading({
title: '账号自动登录中...',
@ -37,19 +37,6 @@ App({
that.globalData.userInfo.perms = res.data.rights //拉取权限
that.globalData.userInfo.companyid = res.data.companyid
that.globalData.userInfo.openid = res.data.openid
// if (that.callback) { //这个函数名字和你定义的一样即可
// that.callback() //执行定义的回调函数
// }
/**** KEY PART START ****/
// var pages = getCurrentPages() // get all current pages
// var currentPage = pages[pages.length - 1] // Get current loading page
// if (currentPage.callback){
// currentPage.callback(); // Callback
// that.oncallback = false; // Callback called
// }
/**** KEY PART END ****/
//获取是否是安全员
wx.request({
url: that.globalData.serverUrl + 'api/user?a=checkaqy',
@ -65,20 +52,22 @@ App({
}
});
wx.hideLoading()
wx.reLaunch({
url: '/pages/main/main',
})
if(redirect==1){
wx.reLaunch({
url: '/pages/main/main',
})
}
} else {
wx.hideLoading()
wx.showToast({
title: '未绑定账号,请手动登录',
icon:'none'
})
that.globalData.userInfo.mpopenid = res.data.mpopenid
// wx.reLaunch({
// url: '/pages/bind/binduser?mpopenid=' + res.data.mpopenid,
// })
wx.reLaunch({
url: '/pages/bind/binduser?mpopenid=' + res.data.mpopenid,
})
}
},
})
@ -100,6 +89,15 @@ App({
}
})
},
// wxlogin: function(){
// return new Promise(function(reslove,reject){
// wx.login({
// success (res) {
// reslove(res.code);
// }
// })
// })
// },
globalData: {
userInfo: {
userid:0,

View File

@ -141,7 +141,8 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
getApp().mplogin()
// getApp().mplogin('/pages/main/main')
},
/**

View File

@ -3,7 +3,7 @@
"setting": {
"urlCheck": false,
"es6": true,
"enhance": false,
"enhance": true,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
@ -18,15 +18,13 @@
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"useMultiFrameRuntime": true,
"useMultiFrameRuntime": false,
"useApiHook": true,
"useApiHostProcess": false,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"bundle": false,
"useIsolateContext": true,
"useCompilerModule": false,

View File

@ -1,4 +1,5 @@
function request(url, method, data) {
function request(url, method, data, type="application/json", re=0) {
let promise = new Promise((resolve, reject) => {
wx.showNavigationBarLoading();
wx.request({
@ -6,7 +7,7 @@ function request(url, method, data) {
method: method,
data: data,
header: {
'content-type': 'application/json', // 默认值
'content-type': type, // 默认值
'Cookie': getApp().globalData.sessionId,
},
success: (res => {
@ -16,6 +17,9 @@ function request(url, method, data) {
icon: 'none'
})
}else{
if(re==1){
resolve(res)
}
resolve(res.data);
}