Commit 5128e50c by 胡悦

修改

1 parent 35ec0d53
...@@ -24,6 +24,8 @@ class Request { ...@@ -24,6 +24,8 @@ class Request {
let header = RequestMethods === 'POST' ? { let header = RequestMethods === 'POST' ? {
'content-type': 'application/x-www-form-urlencoded' 'content-type': 'application/x-www-form-urlencoded'
} : {} } : {}
const merchantId = wx.$util.getStorageSync('srcm_shopmall_merchant_id')
if (merchantId) header.merchantId = merchantId
let projectName = this.getRopProject(params.method) let projectName = this.getRopProject(params.method)
if (!projectName) projectName = this.getRopProject(params.method) if (!projectName) projectName = this.getRopProject(params.method)
const path = pathEnum[projectName] const path = pathEnum[projectName]
...@@ -37,6 +39,45 @@ class Request { ...@@ -37,6 +39,45 @@ class Request {
responseType: 'text', responseType: 'text',
success(response) { success(response) {
/**业务代码 */ /**业务代码 */
let {
data: {
code,
message
},
data
} = response
if (code == 20 || code == 21) {
wx.hideLoading()
const thisPage = wx.$router.getPageInstance()
if (thisPage && thisPage.pageRefresh) thisPage.pageRefresh()
if (!wx.$authStatus) {
if (INTERRUPT) return
INTERRUPT = true
wx.showLoading()
getApp().login().then(() => {
if (thisPage.init && thisPage.data.userInfo) thisPage.init()
if (thisPage.loginCallBack && thisPage.data.userInfo) thisPage.loginCallBack(thisPage.data.userInfo)
if (thisPage.onRoute) thisPage.onRoute()
thisPage.onLoad()
thisPage.onShow()
INTERRUPT = false
})
}
} else {
if (returnAll) {
resolve(data)
return
}
if (code == '0') {
resolve(data.data)
} else {
console.log(data)
wx.showToast({
title: message || '系统异常',
icon: 'none'
})
}
}
}, },
fail(error) { fail(error) {
wx.hideLoading() wx.hideLoading()
...@@ -82,5 +123,22 @@ class Request { ...@@ -82,5 +123,22 @@ class Request {
const projectName = method.split('.')[2] const projectName = method.split('.')[2]
return projectName return projectName
} }
getMock() {
let url = 'https://oss-config.dev.glsx.com.cn/mock/6264ff4760f415276f6dfe62/config'
if (index == 3) url = 'https://oss-config.test.glsx.com.cn/mock/6274e3050da5034a58680aa6/config'
return new Promise((resolve) => {
wx.request({
url,
data: {},
method: 'GET',
header: {},
dataType: 'json',
responseType: 'text',
success(response) {
resolve(response.data)
}
})
})
}
} }
export default new Request() export default new Request()
\ No newline at end of file \ No newline at end of file
...@@ -10,6 +10,7 @@ App({ ...@@ -10,6 +10,7 @@ App({
/**挂载到wx对象 */ /**挂载到wx对象 */
wx.$util = util wx.$util = util
wx.$router = router wx.$router = router
wx.$imgUrl = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/'
const systemInfo = wx.getStorageSync('srcm_shopmall_system_info') const systemInfo = wx.getStorageSync('srcm_shopmall_system_info')
if (!systemInfo) wx.getSystemInfo({ if (!systemInfo) wx.getSystemInfo({
success(res) { success(res) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!