尝试解决问题

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({ App({
onLaunch: function () { onLaunch: function () {
var that = this var that = this
//that.mplogin() that.mplogin()
setInterval(that.reflesh,10*60*1000) setInterval(that.reflesh,10*60*1000)
}, },
mplogin: function () { mplogin: function ( redirect = 0) {
var that = this; var that = this;
wx.showLoading({ wx.showLoading({
title: '账号自动登录中...', title: '账号自动登录中...',
@ -37,19 +37,6 @@ App({
that.globalData.userInfo.perms = res.data.rights //拉取权限 that.globalData.userInfo.perms = res.data.rights //拉取权限
that.globalData.userInfo.companyid = res.data.companyid that.globalData.userInfo.companyid = res.data.companyid
that.globalData.userInfo.openid = res.data.openid 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({ wx.request({
url: that.globalData.serverUrl + 'api/user?a=checkaqy', url: that.globalData.serverUrl + 'api/user?a=checkaqy',
@ -65,20 +52,22 @@ App({
} }
}); });
wx.hideLoading() wx.hideLoading()
wx.reLaunch({ if(redirect==1){
url: '/pages/main/main', wx.reLaunch({
}) url: '/pages/main/main',
})
}
} else { } else {
wx.hideLoading() wx.hideLoading()
wx.showToast({ wx.showToast({
title: '未绑定账号,请手动登录', title: '未绑定账号,请手动登录',
icon:'none' icon:'none'
}) })
that.globalData.userInfo.mpopenid = res.data.mpopenid that.globalData.userInfo.mpopenid = res.data.mpopenid
// wx.reLaunch({ wx.reLaunch({
// url: '/pages/bind/binduser?mpopenid=' + res.data.mpopenid, 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: { globalData: {
userInfo: { userInfo: {
userid:0, userid:0,

View File

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

View File

@ -3,7 +3,7 @@
"setting": { "setting": {
"urlCheck": false, "urlCheck": false,
"es6": true, "es6": true,
"enhance": false, "enhance": true,
"postcss": true, "postcss": true,
"preloadBackgroundData": false, "preloadBackgroundData": false,
"minified": true, "minified": true,
@ -18,15 +18,13 @@
"checkSiteMap": true, "checkSiteMap": true,
"uploadWithSourceMap": true, "uploadWithSourceMap": true,
"compileHotReLoad": false, "compileHotReLoad": false,
"useMultiFrameRuntime": true, "useMultiFrameRuntime": false,
"useApiHook": true, "useApiHook": true,
"useApiHostProcess": false,
"babelSetting": { "babelSetting": {
"ignore": [], "ignore": [],
"disablePlugins": [], "disablePlugins": [],
"outputPath": "" "outputPath": ""
}, },
"enableEngineNative": false,
"bundle": false, "bundle": false,
"useIsolateContext": true, "useIsolateContext": true,
"useCompilerModule": false, "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) => { let promise = new Promise((resolve, reject) => {
wx.showNavigationBarLoading(); wx.showNavigationBarLoading();
wx.request({ wx.request({
@ -6,7 +7,7 @@ function request(url, method, data) {
method: method, method: method,
data: data, data: data,
header: { header: {
'content-type': 'application/json', // 默认值 'content-type': type, // 默认值
'Cookie': getApp().globalData.sessionId, 'Cookie': getApp().globalData.sessionId,
}, },
success: (res => { success: (res => {
@ -16,6 +17,9 @@ function request(url, method, data) {
icon: 'none' icon: 'none'
}) })
}else{ }else{
if(re==1){
resolve(res)
}
resolve(res.data); resolve(res.data);
} }