From 94324e1e382535100063a333fead1a46267b5e84 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 27 May 2021 22:45:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E8=A7=A3=E5=86=B3=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 42 ++++++++++++++++++++---------------------- pages/bind/binduser.js | 3 ++- project.config.json | 6 ++---- utils/request.js | 8 ++++++-- 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/app.js b/app.js index 4a016d6..a7c63db 100644 --- a/app.js +++ b/app.js @@ -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, diff --git a/pages/bind/binduser.js b/pages/bind/binduser.js index 2c481ff..090dba7 100644 --- a/pages/bind/binduser.js +++ b/pages/bind/binduser.js @@ -141,7 +141,8 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - getApp().mplogin() + + // getApp().mplogin('/pages/main/main') }, /** diff --git a/project.config.json b/project.config.json index cb57fc4..9f566ca 100644 --- a/project.config.json +++ b/project.config.json @@ -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, diff --git a/utils/request.js b/utils/request.js index eb36082..0de91ac 100644 --- a/utils/request.js +++ b/utils/request.js @@ -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); }