Commit ab6bcc51 by 严立

增加全局报错异常捕获

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