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}){ onAttention: function({detail}){
this.onRefreshList() 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 return
} }
this.data.dataIndex = 0 this.data.dataIndex = 0

15
pages/moment/recommend/index.js

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

17
pages/moment/theall/index.js

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

Loading…
Cancel
Save