- 封装请求时要获取token,怎么在拿到token后才做请求?
自己封装了request请求,通过storage拿token值,但是封装的文件加载特别快,当时还没有拿到token,导致后期所有请求都失败,需要重新刷页面才能获取token,有思路可以帮忙说一下,感谢
2019-08-28 - 调用后台接口返回数据后,滚动页面到底部数据清空?
调用后台接口后,数据返回渲染成功,但是滚动页面到底部后数据自动清空,有遇到这个问题的麻烦解答一下,谢谢[图片] [图片] 页面代码如下:麻烦帮忙看下 <template> <view class="container"> <!-- header个人信息 --> <mti-header></mti-header> <view class="cyList"> <view class="list-item" wx:for="{{tableList}}" wx:key="{{item.id}}" @tap="todetails" data-taskId="{{item.taskId}}" > <view class="cyitem-l fl"> <view class="cy-t"> <text class="yuandian"></text><text class="tit">{{item.orderNo}}</text><text class="time">{{item.callingTime}}</text> </view> <view class="info">{{item.content}}</view> </view> <view class="cyitem-r fr"> <text>{{item.status}}</text> </view> </view> <view class="plete">列表显示完成</view> </view> </view> </template> <script> import wepy from 'wepy'; import header from '../../components/header' var wxrequest = require('../../util/request'); export default class homepage extends wepy.page { config = { navigationBarTitleText: '接诉即办综合管理平台' } components={ "mti-header":header } data = { tableList:[], authorize: false, avatarUrl: '', username: '', requestUrl:'', orderStatus:[], page:{ size:20, current:1 } } computed = { } methods = { todetails(e) { let taskId = e.currentTarget.dataset.taskid; wx.navigateTo({ url: `../agency/cyDetails?taskId=${taskId}` }) }, } getList(page){ let that = this; let tmp = [] for(let key in page){ tmp.push(`${key}=${page[key]}`) } let url = `${this.requestUrl}/act/task/todo?${tmp.join("&")}` wxrequest.fetchList(this.page) .then(response => { let records = response.data.data.records; records = records.map(function(item,index,arr){ for(let j=0;j<that.orderStatus.length;j++){ if(item.status === that.orderStatus[j].value){ item.status = that.orderStatus[j].label; break; } } return item; }) that.setData({"tableList":JSON.parse(JSON.stringify(records))}); // this.tableList = JSON.parse(JSON.stringify(records)); }) } onLoad(option) { let that = this; wxrequest.dictory("order_status") .then(response =>{ that.orderStatus = response.data.data; }) } onShow(){ this.getList(this.page); } } </script>
2019-08-09