Skip to content

Commit

Permalink
fix: get third_part_login fail
Browse files Browse the repository at this point in the history
  • Loading branch information
yigger committed Jul 19, 2020
1 parent e5cf06a commit 13b7704
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 34 deletions.
8 changes: 4 additions & 4 deletions src/components/charts/overview.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
总计(收入-支出-还款):<text class="expend">{{ header.total }}</text>
</view>

<view class="overview__category-chart">
<!-- <view class="overview__category-chart">
<view class="ovweview-title">预算使用情况</view>
<view class="budget-chart-item" wx:for="{{categories}}">
<canvas canvas-id="category-chart-{{ item.id }}" disable-scroll="true" style="width: 120px; height: 120px;"></canvas>
<view>{{ item.name }}</view>
</view>
</view>
</view> -->

<view class="overview__statements">
<view class="ovweview-title">账单列表</view>
Expand Down Expand Up @@ -63,7 +63,7 @@ export default class OverviewComponent extends wepy.component {
onLoad() {
this.getHeader()
this.getStatementList()
this.categoryChart()
// this.categoryChart()
}

async getHeader() {
Expand Down Expand Up @@ -121,7 +121,7 @@ export default class OverviewComponent extends wepy.component {
date() {
this.getHeader()
this.getStatementList()
this.categoryChart()
// this.categoryChart()
}
};
}
Expand Down
49 changes: 19 additions & 30 deletions src/utils/wxRequest/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const getOpenId = async () => {
method: 'POST',
header: { 'X-WX-Code': wxLogin.code, 'X-WX-APP-ID': Host.appid }
})
Session.set(loginKey, res.data.session)
resolve(res.data.session)
})
}
Expand All @@ -49,6 +50,7 @@ const doRequest = async (url, method, params, options = {}, callback) => {
}

const thirdSession = await getOpenId()
getAuthPromise = null
return wepy.request({
url: url,
method: method,
Expand All @@ -61,38 +63,25 @@ const doRequest = async (url, method, params, options = {}, callback) => {
},
}).then((response) => {
const statusCode = response.statusCode
if (statusCode !== 200) {
if (url === `${Host.url}/error_upload`) {
return false
}
let message = null
if (statusCode != 500 && statusCode != 404) {
message = e.errMsg
}
Session.pushError({ url: url, method: method, params: params, err: message, statusCode: statusCode, time: new Date().toLocaleString()})
wx.showToast({
title: '网络请求超时..',
icon: 'none',
duration: 3000
})
const result = response.data
// key 过期尝试重连
if ((statusCode !== 200 || result.status === 301) && retryCount <= 6) {
Session.clear(loginKey)
retryCount += 1
return doRequest(url, method, params)
} else {
const result = response.data
// key 过期尝试重连
if (result.status === 301 && retryCount <= 3) {
Session.clear(loginKey)
retryCount += 1
return doRequest(url, method, params)
}

Session.set(loginKey, thirdSession)
if(cacheKey != '') setByCache(cacheKey, result)

if (typeof callback !== 'undefined') {
callback(result)
}

return result
retryCount = 0
}

if(cacheKey != '') {
setByCache(cacheKey, result)
}

if (typeof callback !== 'undefined') {
callback(result)
}

return result
}, (err) => {
Session.pushError({ url: url, method: method, params: params, err: err.message, time: new Date().toLocaleString()})
wx.showToast({
Expand Down

0 comments on commit 13b7704

Please sign in to comment.