Browse Source

no message

featrue/v4.5
xpz2018 4 years ago
parent
commit
673915f7f5
3 changed files with 21 additions and 8 deletions
  1. 22
      pages/moment/attention/index.js
  2. 2
      pages/moment/attention/index.wxml
  3. 5
      pages/moment/moment-item/index.js

22
pages/moment/attention/index.js

@ -21,6 +21,8 @@ Component({
}, },
loading: true, loading: true,
requesting: false, requesting: false,
token: true,
finished: false,
orderList: [] orderList: []
}, },
lifetimes: { lifetimes: {
@ -37,23 +39,29 @@ Component({
var min = new Date() var min = new Date()
min.setHours(0, 0, 0) min.setHours(0, 0, 0)
this.data.form.date = util.formatDate(min, 'Y-M-D') this.data.form.date = util.formatDate(min, 'Y-M-D')
this.fetchList()
var token = app.globalData.userInfo ? true : false
if(!app.globalData.userInfo){
this.setData({ loading: false, token })
} else {
this.fetchList()
}
} }
this.firstShow = true this.firstShow = true
}, },
onEvent: function (message) { onEvent: function (message) {
if(message.what == 888){ if(message.what == 888){
if(!app.globalData.userInfo){ if(!app.globalData.userInfo){
this.setData({ orderList: [], ['form.pageNum']: 1, finished: false })
this.setData({ orderList: [], ['form.pageNum']: 1, finished: false, token: false, loading: false })
} else { } else {
this.data.token = true
this.onRefreshList() this.onRefreshList()
} }
} else if(message.what == 444 && this.firstShow){
} else if(message.what == 444 && this.firstShow && app.globalData.userInfo){
this.onRefreshList() this.onRefreshList()
} }
}, },
onRefreshList: function(){ onRefreshList: function(){
if (this.data.requesting) {
if(!app.globalData.userInfo || this.data.requesting){
return return
} }
this.setData({ orderList: [], ['form.pageNum']: 1, finished: false, loading: true }) this.setData({ orderList: [], ['form.pageNum']: 1, finished: false, loading: true })
@ -72,11 +80,11 @@ Component({
var finished = this.data.form.pageNum >= result.data.pages var finished = this.data.form.pageNum >= result.data.pages
this.setData({ [nowList]: respList, ['form.pageNum']: (num + 1), finished, requesting: false, loading: false }) this.setData({ [nowList]: respList, ['form.pageNum']: (num + 1), finished, requesting: false, loading: false })
} else { } else {
this.setData({ finished: true, requesting: false, loading: false })
this.setData({ finished: true, requesting: false, loading: false, token: this.data.token })
} }
}).catch(err => { }).catch(err => {
console.log(err)
this.setData({ requesting: false, loading: false })
this.setData({ requesting: false, loading: false, token: this.data.token })
util.showToast(err) util.showToast(err)
}) })
} }

2
pages/moment/attention/index.wxml

@ -7,7 +7,7 @@
</wux-skeleton> </wux-skeleton>
<view class="bg-white list-empty" style="height:{{height}}rpx" bindtap="onRefreshList" wx:elif="{{!orderList.length && !loading}}"> <view class="bg-white list-empty" style="height:{{height}}rpx" bindtap="onRefreshList" wx:elif="{{!orderList.length && !loading}}">
<image class="img-empty" src="/assets/image/list_empty.png"></image> <image class="img-empty" src="/assets/image/list_empty.png"></image>
<view class="text-empty">暂无数据,点击加载</view>
<view class="text-empty">{{ token ? '暂无数据,点击重新加载' : '请登录后加载'}}</view>
</view> </view>
<view wx:else> <view wx:else>
<view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{orderList}}" wx:key="pageIndex"> <view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{orderList}}" wx:key="pageIndex">

5
pages/moment/moment-item/index.js

@ -2,6 +2,7 @@
const util = require('../../../utils/util') const util = require('../../../utils/util')
import { userPushFollowMill } from "../../../api/ztb" import { userPushFollowMill } from "../../../api/ztb"
import { getMillPaperList } from "../../../api/moment" import { getMillPaperList } from "../../../api/moment"
const app = getApp()
var requesting = false var requesting = false
Component({ Component({
@ -29,6 +30,10 @@ Component({
if (this.data.loading) { if (this.data.loading) {
return return
} }
if(!app.globalData.userInfo){
util.navigateTo('/pages/login/index')
return
}
this.setData({ loading: true }) this.setData({ loading: true })
userPushFollowMill({ paperMillId: 1, follow: true }).then(result => { userPushFollowMill({ paperMillId: 1, follow: true }).then(result => {
this.setData({ loading: false }) this.setData({ loading: false })

Loading…
Cancel
Save