Browse Source

event

featrue/v4.5
xpz2018 4 years ago
parent
commit
0c0f768cd7
3 changed files with 31 additions and 9 deletions
  1. 8
      pages/moment/attention/index.js
  2. 15
      pages/moment/recommend/index.js
  3. 17
      pages/moment/theall/index.js

8
pages/moment/attention/index.js

@ -69,8 +69,12 @@ Component({
onAttention: function({detail}){
this.onRefreshList()
},
onRefreshList: function(){
if(!app.globalData.userInfo || this.data.requesting){
onRefreshList: function(e){
if(!app.globalData.userInfo && e){
wx.navigateTo({ url: '/pages/login/index' })
return
}
if(this.data.requesting){
return
}
this.data.dataIndex = 0

15
pages/moment/recommend/index.js

@ -17,9 +17,8 @@ Component({
pageNum: 1,
pageSize: 10
},
loading: false,
loading: true,
requesting: false,
token: true,
finished: false,
dataIndex: 0,
orderList: []
@ -37,7 +36,6 @@ Component({
if(!this.firstShow){
var min = new Date()
min.setHours(0, 0, 0)
this.data.token = app.globalData.userInfo ? true : false
this.data.form.date = util.formatDate(min, 'Y-M-D')
if(app.nowCity){
this.data.form.cityId = app.nowCity.cityCode
@ -47,8 +45,11 @@ Component({
this.firstShow = true
},
onEvent: function (message) {
if(!this.firstShow){
return
}
if(message.what == 888){
this.setData({ token: app.globalData.userInfo ? true : false })
this.onRefreshList()
} else if(message.what == 444 && this.firstShow){
this.data.form.cityId = app.nowCity.cityCode
this.onRefreshList()
@ -107,13 +108,13 @@ Component({
let nowList = `orderList[${this.data.orderList.length}]`
var num = this.data.form.pageNum
var finished = this.data.form.pageNum >= result.data.pages
this.setData({ [nowList]: respList, ['form.pageNum']: (num + 1), finished, requesting: false, loading: false, token: this.data.token })
this.setData({ [nowList]: respList, ['form.pageNum']: (num + 1), finished, requesting: false, loading: false })
} else {
this.setData({ finished: true, requesting: false, loading: false, token: this.data.token })
this.setData({ finished: true, requesting: false, loading: false })
}
}).catch(err => {
console.log(err)
this.setData({ requesting: false, loading: false, token: this.data.token })
this.setData({ requesting: false, loading: false })
util.showToast(err)
})
}

17
pages/moment/theall/index.js

@ -2,6 +2,7 @@
import { getInformationList } from "../../../api/moment"
const util = require('../../../utils/util')
const area = require("../../../const/area.js")
const event = require('../../../utils/event')
const app = getApp()
Component({
@ -29,6 +30,14 @@ Component({
finished: false,
orderList: []
},
lifetimes: {
attached: function () {
event.on('EventMessage', this, this.onEvent)
},
detached: function () {
event.remove('EventMessage', this)
}
},
methods: {
onRestart: function () {
if(!this.data.firstShow){
@ -41,6 +50,14 @@ Component({
this.fetchList()
}
},
onEvent: function (message) {
if(!this.data.firstShow){
return
}
if(message.what == 888){
this.onRefreshList()
}
},
getProviceListByIndex: function(tabIndex){
var proviceList = []
for (let index = 0; index < area.list[tabIndex].data.length; index++) {

Loading…
Cancel
Save