Browse Source

no message

feature/v1.4
xpz2018 5 years ago
parent
commit
4357a241e4
3 changed files with 68 additions and 2 deletions
  1. 45
      pages/agent/ability-list/index.js
  2. 4
      pages/agent/ability-list/index.json
  3. 21
      pages/agent/ability-list/index.wxml

45
pages/agent/ability-list/index.js

@ -1,17 +1,58 @@
// pages/message/detail/index.js
import Scene from '../../index/scene'
import { getActivityList } from "../../../api/ztb"
const app = getApp()
Scene({
/**
* 页面的初始数据
*/
data: {
height: app.globalData.fragmentHeight,
kg: app.globalData.kg,
loading: true,
requesting: false,
finished: false,
orderList: [],
form: {
pageNum: 1
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({ height: app.globalData.fragmentHeight })
this.fetchPapersList()
},
onRefreshList: function () {
if (this.data.requesting) {
return
}
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false })
this.fetchPapersList()
},
// 获取特价列表
fetchPapersList: function () {
if (this.data.requesting || this.data.finished) {
return
}
this.data.requesting = true
getActivityList(this.data.form).then(result => {
if (result.data.records.length) {
var respList = result.data.records
let nowList = `orderList[${this.data.orderList.length}]`
var num = result.data.current
var finished = result.data.current >= result.data.pages
this.setData({ [nowList]: respList, ['form.pageNum']: (num + 1), finished, requesting: false, loading: false })
} else {
this.setData({ requesting: false, finished: true, loading: false })
}
}).catch(err => {
this.setData({ requesting: false, finished: true, loading: false })
}).finally(() => {
this.refresh = this.refresh || this.selectComponent('#refresh')
this.refresh.setRefresh(false)
})
}
})

4
pages/agent/ability-list/index.json

@ -1,5 +1,9 @@
{
"usingComponents": {
"refresh-view": "/components/refresh-view/index",
"van-divider": "/components/divider/index",
"van-loading": "/components/loading/index",
"ability-item": "/pages/agent/ability-item/index",
"notification": "/pages/message/notification/index"
}
}

21
pages/agent/ability-list/index.wxml

@ -3,4 +3,25 @@
<view slot="content">消息情况</view>
</cu-custom>
<refresh-view id="refresh" bind:refresh="onRefreshList" height="{{height}}" bind:loadmore="fetchPapersList">
<view class="list-empty" style="height:{{height}}rpx" wx:if="{{!orderList.length}}">
<view style="margin-bottom:24px" wx:if="{{loading}}">
<van-loading type="spinner" size="32" />
</view>
<image class="img-empty" src="/assets/image/list_empty.png" wx:else></image>
<view class="text-empty">{{loading? '正在加载' : '暂无数据'}}</view>
</view>
<view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{orderList}}" wx:key="pageIndex">
<view wx:for="{{pageItem}}" wx:key="index">
<view style="height:16rpx" wx:if="{{pageIndex != 0 || index != 0 }}"></view>
<ability-item item="{{item}}"></ability-item>
</view>
</view>
<!--加载更多的UI-->
<van-divider content-position="center" wx:if="{{ form.pageNum > 1}}" custom-style="padding:0rpx 120rpx">
<van-loading type="spinner" size="16" wx:if="{{!finished}}" />
<text class="text-sm" style="margin-left:8rpx">{{finished?'到底啦~':'加载中...'}}</text>
</van-divider>
</refresh-view>
<notification id="qn-notification"/>
Loading…
Cancel
Save