Browse Source

no message

featrue/v4.5
xpz2018 4 years ago
parent
commit
56d7ccb137
6 changed files with 83 additions and 31 deletions
  1. 35
      pages/moment/attention/index.js
  2. 39
      pages/moment/attention/index.wxml
  3. 6
      pages/moment/fragment/index.js
  4. 2
      pages/moment/fragment/index.wxml
  5. 28
      pages/moment/recommend/index.js
  6. 4
      pages/moment/theall/index.js

35
pages/moment/attention/index.js

@ -1,6 +1,7 @@
// pages/message/index.js // pages/message/index.js
import { getInformationList } from "../../../api/moment" import { getInformationList } from "../../../api/moment"
const util = require('../../../utils/util') const util = require('../../../utils/util')
const event = require('../../../utils/event')
const app = getApp() const app = getApp()
Component({ Component({
@ -18,9 +19,18 @@ Component({
pageNum: 1, pageNum: 1,
pageSize: 10 pageSize: 10
}, },
loading: true,
requesting: false, requesting: 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.firstShow){ if(!this.firstShow){
@ -31,12 +41,23 @@ Component({
} }
this.firstShow = true this.firstShow = true
}, },
onEvent: function (message) {
if(message.what == 888){
if(!app.globalData.userInfo){
this.setData({ orderList: [], ['form.pageNum']: 1, finished: false })
} else {
this.onRefreshList()
}
} else if(message.what == 444 && this.firstShow){
this.onRefreshList()
}
},
onRefreshList: function(){ onRefreshList: function(){
if (this.data.requesting) { if (this.data.requesting) {
return return
} }
this.setData({ orderList: [], ['form.pageNum']: 1, finished: false })
this.fetchOrderList()
this.setData({ orderList: [], ['form.pageNum']: 1, finished: false, loading: true })
this.fetchList()
}, },
fetchList: function(){ fetchList: function(){
if (this.data.requesting) { if (this.data.requesting) {
@ -44,18 +65,18 @@ Component({
} }
this.data.requesting = true this.data.requesting = true
getInformationList(this.data.form).then(result => { getInformationList(this.data.form).then(result => {
if (result.data.records.length) {
if (result.data && result.data.records.length) {
var respList = result.data.records var respList = result.data.records
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 })
this.setData({ [nowList]: respList, ['form.pageNum']: (num + 1), finished, requesting: false, loading: false })
} else { } else {
this.setData({ finished: true, requesting: false })
this.setData({ finished: true, requesting: false, loading: false })
} }
}).catch(err => { }).catch(err => {
//异常回调
this.setData({ requesting: false })
console.log(err)
this.setData({ requesting: false, loading: false })
util.showToast(err) util.showToast(err)
}) })
} }

39
pages/moment/attention/index.wxml

@ -1,26 +1,31 @@
<!--pages/message/index.wxml--> <!--pages/message/index.wxml-->
<scroll-view scroll-y style="height: {{height}}rpx;" bind:scrolltolower="fetchList"> <scroll-view scroll-y style="height: {{height}}rpx;" bind:scrolltolower="fetchList">
<wux-skeleton active wx:if="{{!orderList.length}}">
<wux-skeleton active wx:if="{{loading}}">
<view class="flex item-content"> <view class="flex item-content">
<wux-skeleton-paragraph rounded rows="8" wux-class="case3-class" />
<wux-skeleton-paragraph rounded rows="12" wux-class="case3-class" />
</view> </view>
</wux-skeleton> </wux-skeleton>
<view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{orderList}}" wx:key="pageIndex">
<view wx:for="{{pageItem}}" wx:key="index">
<view class="bg-white" style="padding: 0rpx 32rpx" wx:if="{{pageIndex != 0 || index != 0 }}">
<wux-divider show-text="{{ false }}"></wux-divider>
</view>
<moment-item item="{{item}}"></moment-item>
</view>
<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>
<view class="text-empty">暂无数据,点击加载</view>
</view> </view>
<!--加载更多的UI-->
<view wx:if="{{form.pageNum > 1}}" style="padding:20rpx">
<wux-divider>
<view class="loadmore">
<text class="icon--refresher" wx:if="{{!finished}}"></text>
<text class="text-sm" style="margin-left:8rpx">{{finished?'到底啦~':'加载中...'}}</text>
<view wx:else>
<view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{orderList}}" wx:key="pageIndex">
<view wx:for="{{pageItem}}" wx:key="index">
<view class="bg-white" style="padding: 0rpx 32rpx" wx:if="{{pageIndex != 0 || index != 0 }}">
<wux-divider show-text="{{ false }}"></wux-divider>
</view>
<moment-item item="{{item}}"></moment-item>
</view> </view>
</wux-divider>
</view>
<!--加载更多的UI-->
<view wx:if="{{form.pageNum > 1}}" style="padding:20rpx">
<wux-divider>
<view class="loadmore">
<text class="icon--refresher" wx:if="{{!finished}}"></text>
<text class="text-sm" style="margin-left:8rpx">{{finished?'到底啦~':'加载中...'}}</text>
</view>
</wux-divider>
</view>
</view> </view>
</scroll-view> </scroll-view>

6
pages/moment/fragment/index.js

@ -29,7 +29,6 @@ Component({
}, },
lifetimes: { lifetimes: {
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
attached: function () { attached: function () {
event.on('EventMessage', this, this.onEvent) event.on('EventMessage', this, this.onEvent)
}, },
@ -68,7 +67,10 @@ Component({
this.triggerEvent("picker", {type: 1}) this.triggerEvent("picker", {type: 1})
}, },
onCalendarChange: function(date){ onCalendarChange: function(date){
console.log(date)
var fragment = this.selectComponent('#recommend')
if(fragment && fragment.calendarChange){
fragment.calendarChange(date)
}
}, },
chooseCity: function(){ chooseCity: function(){
wx.navigateTo({url: `/pages/home/city-select/index?type=1` }) wx.navigateTo({url: `/pages/home/city-select/index?type=1` })

2
pages/moment/fragment/index.wxml

@ -17,7 +17,7 @@
</view> </view>
<view class="bg-white flex flex-center" style="height:80rpx;padding:16rpx 24rpx;background-color: #FFFBE8"> <view class="bg-white flex flex-center" style="height:80rpx;padding:16rpx 24rpx;background-color: #FFFBE8">
<image src="/assets/image/icon-notice.png" style="height: 24rpx;width: 32rpx;"></image>
<image src="/assets/image/icon-notice.png" style="height: 24rpx;width: 32rpx;" wx:if="{{noticeList.length}}"></image>
<swiper vertical="{{true}}" autoplay="{{true}}" circular="{{true}}" interval="3000" class="tui-swiper"> <swiper vertical="{{true}}" autoplay="{{true}}" circular="{{true}}" interval="3000" class="tui-swiper">
<swiper-item wx:for="{{noticeList}}" wx:key="index" class="flex flex-center" catchtouchmove="stopTouchMove" style="justify-content: flex-start"> <swiper-item wx:for="{{noticeList}}" wx:key="index" class="flex flex-center" catchtouchmove="stopTouchMove" style="justify-content: flex-start">
<view class="flex flex-justify" style="width: 100%;height: 100%;" data-index="{{index}}" bindtap="toNotice"> <view class="flex flex-justify" style="width: 100%;height: 100%;" data-index="{{index}}" bindtap="toNotice">

28
pages/moment/recommend/index.js

@ -1,6 +1,7 @@
// pages/message/index.js // pages/message/index.js
import { getInformationList } from "../../../api/moment" import { getInformationList } from "../../../api/moment"
const util = require('../../../utils/util') const util = require('../../../utils/util')
const event = require('../../../utils/event')
const app = getApp() const app = getApp()
Component({ Component({
@ -21,6 +22,14 @@ Component({
requesting: false, requesting: 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.firstShow){ if(!this.firstShow){
@ -32,12 +41,28 @@ Component({
} }
this.firstShow = true this.firstShow = true
}, },
onEvent: function (message) {
if(message.what == 888){
if(!app.globalData.userInfo){
this.setData({ orderList: [], ['form.pageNum']: 1, finished: false })
} else {
this.onRefreshList()
}
} else if(message.what == 444 && this.firstShow){
this.data.form.cityId = app.nowCity.cityCode
this.onRefreshList()
}
},
calendarChange: function(date){
this.data.form.date = date
this.onRefreshList()
},
onRefreshList: function(){ onRefreshList: function(){
if (this.data.requesting) { if (this.data.requesting) {
return return
} }
this.setData({ orderList: [], ['form.pageNum']: 1, finished: false }) this.setData({ orderList: [], ['form.pageNum']: 1, finished: false })
this.fetchOrderList()
this.fetchList()
}, },
fetchList: function(){ fetchList: function(){
if (this.data.requesting) { if (this.data.requesting) {
@ -55,7 +80,6 @@ Component({
this.setData({ finished: true, requesting: false }) this.setData({ finished: true, requesting: false })
} }
}).catch(err => { }).catch(err => {
//异常回调
this.setData({ requesting: false }) this.setData({ requesting: false })
util.showToast(err) util.showToast(err)
}) })

4
pages/moment/theall/index.js

@ -1,4 +1,5 @@
// pages/message/index.js // pages/message/index.js
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 app = getApp() const app = getApp()
@ -73,7 +74,7 @@ Component({
} }
this.setData({ requesting: true }) this.setData({ requesting: true })
getInformationList(this.data.form).then(result => { getInformationList(this.data.form).then(result => {
if (result.data.records.length) {
if (result.data && result.data.records.length) {
var respList = result.data.records var respList = result.data.records
let nowList = `orderList[${this.data.orderList2.length}]` let nowList = `orderList[${this.data.orderList2.length}]`
var num = this.data.form.pageNum var num = this.data.form.pageNum
@ -83,7 +84,6 @@ Component({
this.setData({ finished: true, requesting: false }) this.setData({ finished: true, requesting: false })
} }
}).catch(err => { }).catch(err => {
//异常回调
this.setData({ requesting: false }) this.setData({ requesting: false })
util.showToast(err) util.showToast(err)
}) })

Loading…
Cancel
Save