Commit ab6bcc51 by 严立

增加全局报错异常捕获

parent efb140ad
......@@ -9,8 +9,6 @@ import iRule from './utils/rule/rule.js'
import iRequest from './utils/request/corvus.js'
import iEnvironmental from './environmental.js'
import iOption from './utils/request/option.js'
App({
modular: {
'rule': iRule,
......@@ -51,8 +49,14 @@ App({
this.setUserStatus()
},
onError (message) {
console.log('onError', message)
onError: function (error) {
console.log('onError')
console.log(error)
},
onUnhandledRejection: function (error) {
console.log('onUnhandledRejection')
console.log(error)
},
/**
......
......@@ -295,6 +295,7 @@ Page({
'id': App.globalData.shopId[i].id,
'name': App.globalData.shopId[i].name,
'logo': App.globalData.shopId[i].logo,
'cover': App.globalData.shopId[i].cover,
'shopType': Number(this.data.option.commodityType)
}
wx.setStorageSync('shopInfoBuffer', funcShopInfo)
......
......@@ -43,7 +43,7 @@ Page({
*/
queryBanner: function () {
App.request({
url: 'v1/banner/getList'
url: 'v1/banner/getList',
}).then((response) => {
let funcData = response.data
let funcList = []
......@@ -61,8 +61,6 @@ Page({
this.setData({
banner: funcList
})
}).catch((response) => {
console.log('resolve', response)
})
},
......@@ -97,8 +95,6 @@ Page({
this.setData({
notice: funcList
})
}).catch((response) => {
console.log('resolve', response)
})
},
......@@ -110,13 +106,11 @@ Page({
*/
queryBrand: function () {
App.request({
url: 'v1/common/getBrands'
url: 'v1/common/getBrands',
}).then((response) => {
this.setData({
history: response.data
})
}).catch((response) => {
console.log('resolve', response)
})
},
......
......@@ -23,6 +23,7 @@
"compileHotReLoad": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": false,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
......@@ -36,12 +37,11 @@
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"useApiHostProcess": false
"minifyWXSS": true
},
"compileType": "miniprogram",
"libVersion": "2.11.0",
"appid": "wx37a9b7a3d92029f2",
"libVersion": "2.10.0",
"appid": "wx7c468a29cb33a246",
"projectname": "%E4%B8%96%E8%8C%82%E5%B0%8F%E7%A8%8B%E5%BA%8F%E4%BA%8C%E6%9C%9F",
"debugOptions": {
"hidedInDevtools": []
......
......@@ -8,16 +8,19 @@ export default function host () {
// 根据小程序 appId 设置主域名
switch (appId) {
// 此处填写正式上线 appId
case 'wx7c468a29cb33a246':
domain = 'https://smbhyh-web.meiqicloud.com'
break
// 此处填写开发测试 appId
case 'wx37a9b7a3d92029f2':
domain = 'https://sm-web.meiqicloud.com'
break
}
// 根据环境设置相关业务地址
// 通常情况下三个版本路径一致,但不要修改此处代码格式,以免某些特殊情况需要区分配置。
switch (env) {
// 开发版
case 'develop':
......@@ -31,7 +34,7 @@ export default function host () {
// 体验版
case 'trial':
envOption = {
api: domain + '/',
api: domain + '/api/',
upload: domain + '/obpm/',
serverRes: domain + '/userfiles/appResourcesS2/',
}
......@@ -40,7 +43,7 @@ export default function host () {
// 正式版
case 'release':
envOption = {
api: domain + '/',
api: domain + '/api/',
upload: domain + '/obpm/',
serverRes: domain + '/userfiles/appResourcesS2/',
}
......@@ -48,6 +51,5 @@ export default function host () {
}
console.log('[host] ', domain)
console.log('[host] ', envOption)
return envOption
}
\ No newline at end of file
......@@ -29,12 +29,12 @@ let output = function (App) {
case 'invalid':
console.log('[login] invalid')
App.tryLogin()
App.userLogin()
break
case 'nothing':
console.log('[login] nothing')
App.tryLogin()
App.userLogin()
break
}
// console.log(funcTokenState)
......
......@@ -22,14 +22,38 @@ let Output = {
response: function (funcOption, funcResponse) {
// 请求错误处理
if (funcResponse.errMsg === 'request:fail ') {
console.log('request:fail - 1')
return false
return {
success: false,
response: {
code: funcResponse.statusCode,
data: {},
message: funcResponse
}
}
}
// 服务器错误处理
if (funcResponse.statusCode === 405) {
return {
success: false,
response: {
code: funcResponse.statusCode,
data: {},
message: funcResponse
}
}
}
// 服务器错误处理
if (funcResponse.statusCode === 504) {
console.log('request:fail - 2')
return false
return {
success: false,
response: {
code: funcResponse.statusCode,
data: {},
message: funcResponse
}
}
}
// 请求正常
// 此处可以根据后台返回数据,格式化返回数据。
......
if (wx.getAccountInfoSync().miniProgram.appId === 'wx7c468a29cb33a246') {
console.log('option')
console.log('https://smbhyh-web.meiqicloud.com/api/')
}
const output = {
baseUrl: 'https://sm-web.meiqicloud.com/api/',
// baseUrl: 'https://smbhyh-web.meiqicloud.com/api/',
}
export default output
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment