新增专区,调整分页bug

This commit is contained in:
2024-09-05 14:05:14 +08:00
parent b990456593
commit 9a6c4d30f4
24 changed files with 448 additions and 9 deletions

View 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();
})
},
}
})

View File

@@ -0,0 +1,9 @@
{
"component": true,
"usingComponents": {
"pagination": "/components/pagination/index",
"navigator": "/components/navigator/index",
"van-field": "@vant/weapp/field/index"
},
"navigationStyle": "custom"
}

View 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"
/>

View File

@@ -0,0 +1 @@
/* pages/encyclopedia/components/item/index.wxss */