1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- //app.js
- App({
- onLaunch: function () {
- console.log(wx.getStorageSync("token"))
- if (wx.getStorageSync("token") == '' || wx.getStorageSync("token") == undefined) {
- wx.reLaunch({
- url: '/pages/login/index',
- })
- } else {
- wx.reLaunch({
- url: '/pages/guanlian/guanlian',
- })
- }
- },
- globalData: {
- userInfo: null,
- // url:'https://bike.hanyiyun.com/app-api/', //域名
- url:'https://bike.saas.yufengjiayun.com/app-api/',
- title:'闪现出行',//项目名称
- },
- request(api, params, method) {
- if (true) {
- return new Promise((resolve, reject) => {
- wx.request({
- url: this.globalData.url + api,
- data: params,
- header: {
- 'content-type': 'application/x-www-form-urlencoded',
- 'Authorization': wx.getStorageSync('token'),
- },
- method: method,
- success: (res) => {
- resolve(res)
- // console.log(res)
- if (res.statusCode == 401) {
- wx.removeStorageSync('token')
- wx.showToast({
- title: '登陆过期请重新登陆~',
- icon: 'none',
- mask: true,
- success: function () {
- wx.redirectTo({
- url: '../login/index',
- })
- }
- })
- }
- },
- fail: (err) => {
- wx.showToast({
- title: err,
- icon: 'none',
- mask: true
- });
- reject("请求失败")
- }
- })
- })
- }
- },
- })
|