新增专区,调整分页bug
This commit is contained in:
59
pages/encyclopedia/components/item/index.js
Normal file
59
pages/encyclopedia/components/item/index.js
Normal file
@@ -0,0 +1,59 @@
|
||||
import { getEncyclopediaList } from "../../../../service/system";
|
||||
import { alertInfo, alertSuccess, loadingFunc, wxLogin } from "../../../../utils/index";
|
||||
import request from "../../../../utils/request"
|
||||
const { OK } = request;
|
||||
// pages/encyclopedia/components/item/index.js
|
||||
Component({
|
||||
|
||||
/**
|
||||
* 组件的属性列表
|
||||
*/
|
||||
properties: {
|
||||
id: String
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的初始数据
|
||||
*/
|
||||
data: {
|
||||
page: 1,
|
||||
list: [],
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
console.log('----------=========')
|
||||
this.getData();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 组件的方法列表
|
||||
*/
|
||||
methods: {
|
||||
async getData() {
|
||||
console.log(this.data.page, this.data.id, this.id)
|
||||
const page = this.data.page;
|
||||
const id = this.id;
|
||||
const { code, data, message, total } = await getEncyclopediaList(id, page);
|
||||
if (code !== OK) {
|
||||
alertInfo(message)
|
||||
return;
|
||||
}
|
||||
this.setData({ list: data, totalPage: Math.ceil(total / 20) });
|
||||
},
|
||||
jumpToDetail(e) {
|
||||
console.log('e', e)
|
||||
wx.navigateTo({
|
||||
url: `/pages/encyclopediaDetail/index?id=${e.currentTarget.dataset.data.id}`,
|
||||
})
|
||||
},
|
||||
async onChangePage(e) {
|
||||
const page = e.detail.currentIndex;
|
||||
const that = this;
|
||||
this.setData({
|
||||
page
|
||||
}, () => {
|
||||
that.getData();
|
||||
})
|
||||
},
|
||||
}
|
||||
})
|
9
pages/encyclopedia/components/item/index.json
Normal file
9
pages/encyclopedia/components/item/index.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"pagination": "/components/pagination/index",
|
||||
"navigator": "/components/navigator/index",
|
||||
"van-field": "@vant/weapp/field/index"
|
||||
},
|
||||
"navigationStyle": "custom"
|
||||
}
|
15
pages/encyclopedia/components/item/index.wxml
Normal file
15
pages/encyclopedia/components/item/index.wxml
Normal file
@@ -0,0 +1,15 @@
|
||||
<!--pages/encyclopedia/components/item/index.wxml-->
|
||||
<van-field
|
||||
wx:for="{{list}}"
|
||||
value="{{ item.title }}"
|
||||
readonly
|
||||
border="{{ true }}"
|
||||
wx:key="id"
|
||||
bind:tap="jumpToDetail"
|
||||
data-data="{{item}}"
|
||||
/>
|
||||
<pagination
|
||||
currentIndex="{{page}}"
|
||||
totalPage="{{totalPage}}"
|
||||
bind:pagingChange="onChangePage"
|
||||
/>
|
1
pages/encyclopedia/components/item/index.wxss
Normal file
1
pages/encyclopedia/components/item/index.wxss
Normal file
@@ -0,0 +1 @@
|
||||
/* pages/encyclopedia/components/item/index.wxss */
|
Reference in New Issue
Block a user