小程序源码
This commit is contained in:
91
source/wx/xzs-student/pages/exam/index/index.js
Normal file
91
source/wx/xzs-student/pages/exam/index/index.js
Normal file
@@ -0,0 +1,91 @@
|
||||
// pages/exam/index/index.js
|
||||
let app = getApp()
|
||||
Page({
|
||||
data: {
|
||||
paperType: 1,
|
||||
spinShow: false,
|
||||
loadMoreLoad: false,
|
||||
loadMoreTip: '暂无数据',
|
||||
queryParam: {
|
||||
paperType: 1,
|
||||
pageIndex: 1,
|
||||
pageSize: app.globalData.pageSize
|
||||
},
|
||||
tableData: [],
|
||||
total: 1
|
||||
},
|
||||
onLoad: function(options) {
|
||||
this.setData({
|
||||
spinShow: true
|
||||
});
|
||||
this.search(true)
|
||||
},
|
||||
tabChange({
|
||||
detail
|
||||
}) {
|
||||
this.setData({
|
||||
spinShow: true
|
||||
});
|
||||
let size = app.globalData.pageSize
|
||||
this.setData({
|
||||
paperType: detail.key,
|
||||
queryParam: {
|
||||
paperType: detail.key,
|
||||
pageIndex: 1,
|
||||
pageSize: app.globalData.pageSize
|
||||
}
|
||||
});
|
||||
this.search(true)
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
this.setData({
|
||||
spinShow: true
|
||||
});
|
||||
if (!this.loading) {
|
||||
this.setData({
|
||||
['queryParam.pageIndex']: 1
|
||||
});
|
||||
this.search(true)
|
||||
}
|
||||
},
|
||||
onReachBottom() {
|
||||
if (!this.loading && this.data.queryParam.pageIndex < this.data.total) {
|
||||
this.setData({
|
||||
loadMoreLoad: true,
|
||||
loadMoreTip: '正在加载'
|
||||
});
|
||||
this.setData({
|
||||
['queryParam.pageIndex']: this.data.queryParam.pageIndex + 1
|
||||
});
|
||||
this.search(false)
|
||||
}
|
||||
},
|
||||
search: function(override) {
|
||||
let _this = this
|
||||
app.formPost('/api/wx/student/exampaper/pageList', this.data.queryParam).then(res => {
|
||||
_this.setData({
|
||||
spinShow: false
|
||||
});
|
||||
wx.stopPullDownRefresh()
|
||||
if (res.code === 1) {
|
||||
const re = res.response
|
||||
_this.setData({
|
||||
['queryParam.pageIndex']: re.pageNum,
|
||||
tableData: override ? re.list : this.data.tableData.concat(re.list),
|
||||
total: re.pages
|
||||
});
|
||||
if (re.pageNum >= re.pages) {
|
||||
this.setData({
|
||||
loadMoreLoad: false,
|
||||
loadMoreTip: '暂无数据'
|
||||
});
|
||||
}
|
||||
}
|
||||
}).catch(e => {
|
||||
_this.setData({
|
||||
spinShow: false
|
||||
});
|
||||
app.message(e, 'error')
|
||||
})
|
||||
}
|
||||
})
|
||||
13
source/wx/xzs-student/pages/exam/index/index.json
Normal file
13
source/wx/xzs-student/pages/exam/index/index.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"i-tabs": "/component/iView/tabs/index",
|
||||
"i-tab": "/component/iView/tab/index",
|
||||
"i-cell-group": "/component/iView/cell-group/index",
|
||||
"i-cell": "/component/iView/cell/index",
|
||||
"i-load-more": "/component/iView/load-more/index",
|
||||
"i-button": "/component/iView/button/index",
|
||||
"i-message": "/component/iView/message/index",
|
||||
"i-spin": "/component/iView/spin/index"
|
||||
},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
15
source/wx/xzs-student/pages/exam/index/index.wxml
Normal file
15
source/wx/xzs-student/pages/exam/index/index.wxml
Normal file
@@ -0,0 +1,15 @@
|
||||
<!--pages/exam/index/index.wxml-->
|
||||
<view>
|
||||
<i-tabs current="{{ paperType }}" bindchange="tabChange" fixed="true">
|
||||
<i-tab key="1" title="固定试卷" />
|
||||
<i-tab key="4" title="时段试卷" />
|
||||
</i-tabs>
|
||||
<view class="exam-tab-view">
|
||||
<i-cell-group>
|
||||
<i-cell wx:for="{{tableData}}" data-item="item" wx:key="{{item.id}}" title="{{item.name}}" is-link url="/pages/exam/do/index?id={{item.id}}" value="{{item.subjectName}}"></i-cell>
|
||||
</i-cell-group>
|
||||
</view>
|
||||
<i-load-more tip="{{loadMoreTip}}" loading="{{loadMoreLoad}}" i-class="xzs-load-more" />
|
||||
<i-spin size="large" fix wx:if="{{ spinShow }}"></i-spin>
|
||||
<i-message id="message" />
|
||||
</view>
|
||||
7
source/wx/xzs-student/pages/exam/index/index.wxss
Normal file
7
source/wx/xzs-student/pages/exam/index/index.wxss
Normal file
@@ -0,0 +1,7 @@
|
||||
.exam-tab-view {
|
||||
margin-top: 42px;
|
||||
}
|
||||
|
||||
.xzs-load-more {
|
||||
margin-top: 60px !important;
|
||||
}
|
||||
Reference in New Issue
Block a user