新增专区,调整分页bug

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

View File

@ -18,7 +18,10 @@
"pages/rechargeDetail/index",
"pages/updateInvoice/index",
"pages/rechargeWay/index",
"pages/publicTransfer/index"
"pages/publicTransfer/index",
"pages/special/index",
"pages/encyclopedia/index",
"pages/encyclopediaDetail/index"
],
"subPackages": [
{
@ -38,6 +41,12 @@
"iconPath": "/assets/tabbar/home.png",
"selectedIconPath": "/assets/tabbar/home_select.png"
},
{
"pagePath": "pages/special/index",
"text": "专区",
"iconPath": "/assets/tabbar/special.png",
"selectedIconPath": "/assets/tabbar/special_select.png"
},
{
"pagePath": "pages/my/index",
"text": "我的",

BIN
assets/tabbar/special.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -14,4 +14,3 @@
</view>
</view>
</view>
{{totalPage}}

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 */

View File

@ -0,0 +1,87 @@
// pages/encyclopedia/index.js
import { getCategoryList } from '../../service/system'
import { alertInfo, alertSuccess, loadingFunc, wxLogin } from "../../utils/index";
import request from "../../utils/request"
const { OK } = request;
Page({
/**
* 页面的初始数据
*/
data: {
categoryList: [],
active: 0,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.init();
},
async init() {
const { data, code, message } = await getCategoryList();
if (code !== OK) {
alertInfo(message);
return
}
this.setData({
categoryList: data
})
},
onChange(e) {
console.log('e', e)
this.setData({
active: e.detail.index,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

View File

@ -0,0 +1,9 @@
{
"usingComponents": {
"navigator": "/components/navigator/index",
"van-tab": "@vant/weapp/tab/index",
"van-tabs": "@vant/weapp/tabs/index",
"item": "./components/item/index"
},
"navigationStyle": "custom"
}

View File

@ -0,0 +1,7 @@
<!--pages/encyclopedia/index.wxml-->
<navigator title="电力百科" canBack="{{true}}" />
<van-tabs active="{{ active }}" bind:change="onChange">
<van-tab wx:for="{{categoryList}}" wx:key="id" title="{{item.name}}">
<item id="{{item.id}}" wx:if="{{index === active}}" />
</van-tab>
</van-tabs>

View File

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

View File

@ -0,0 +1,77 @@
// pages/encyclopediaDetail/index.js
import { getEncyclopediaDetail } from "../../service/system";
import { alertInfo, alertSuccess, loadingFunc, wxLogin } from "../../utils/index";
import request from "../../utils/request"
const { OK } = request;
Page({
/**
* 页面的初始数据
*/
data: {
detail: {},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.init(options.id)
},
async init(id) {
const { code, data, message } = await getEncyclopediaDetail(id);
if (code !== OK) {
alertInfo(message)
return;
}
this.setData({ detail: data });
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

View File

@ -0,0 +1,6 @@
{
"usingComponents": {
"navigator": "/components/navigator/index"
},
"navigationStyle": "custom"
}

View File

@ -0,0 +1,6 @@
<!--pages/encyclopediaDetail/index.wxml-->
<navigator title="百科详情" canBack="{{true}}" />
<view class="contentWrapper">
<view class="title">{{detail.title}}</view>
<view class="content">{{detail.content}}</view>
</view>

View File

@ -0,0 +1,14 @@
/* pages/encyclopediaDetail/index.wxss */
.contentWrapper {
padding: 30rpx
}
.title {
margin-top: 12rpx;
font-weight: 600;
font-size: 48rpx;
}
.content {
margin-top: 40rpx;
}

View File

@ -22,11 +22,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const { canBack } = options
console.log('cnaback', canBack)
if (canBack === 'false') {
this.setData({ canBack: false })
}
},
onChangeName(e) {
this.setData({

View File

@ -1,6 +1,6 @@
<!--pages/handleLogin/index.wxml-->
<!-- <topbar /> -->
<navigator title="绑定商户" canBack="{{canBack}}" />
<navigator title="绑定商户" canBack="{{true}}" />
<van-tabs>
<van-tab title="扫码绑定">
<view class="codeContent">

View File

@ -269,9 +269,11 @@ Page({
}
if (!data?.length) {
alertInfo("尚无信息")
setTimeout(() => {
wx.clearStorageSync()
wx.redirectTo({
url: '/pages/handleLogin/index?back=false',
url: '/pages/login/index',
})
}, 500)
return;

96
pages/special/index.js Normal file
View File

@ -0,0 +1,96 @@
// pages/special/index.js
import { getServicesList } from '../../service/system'
import request from '../../utils/request'
import { alertInfo } from '../../utils/index'
const { OK } = request;
Page({
/**
* 页面的初始数据
*/
data: {
servicesList: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
async init() {
const { code, message, data } = await getServicesList()
if (code !== OK) {
alertInfo(message);
return;
}
this.setData({ servicesList: data })
},
clickService(e) {
console.log('e', e)
const { type, value } = e.currentTarget.dataset.data;
switch(type) {
case 0:
const [appId, path] = value.split(",")
wx.navigateToMiniProgram({
appId: appId,
path: path
})
break;
case 1:
wx.navigateTo({
url: value,
})
break;
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.init()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

9
pages/special/index.json Normal file
View File

@ -0,0 +1,9 @@
{
"usingComponents": {
"navigator": "/components/navigator/index",
"van-row": "@vant/weapp/row/index",
"van-col": "@vant/weapp/col/index",
"van-image": "@vant/weapp/image/index"
},
"navigationStyle": "custom"
}

11
pages/special/index.wxml Normal file
View File

@ -0,0 +1,11 @@
<!--pages/special/index.wxml-->
<navigator title="专区" />
<view class="servicesWrapper">
<van-row>
<van-col span="8" wx:for="{{ servicesList }}" wx:key="id">
<view class="image" bind:tap="clickService" data-data="{{item}}">
<van-image width="200rpx" height="200rpx" src="{{item.url}}" />
</view>
</van-col>
</van-row>
</view>

6
pages/special/index.wxss Normal file
View File

@ -0,0 +1,6 @@
/* pages/special/index.wxss */
.image {
width: 100%;
height: auto;
padding: 40rpx;
}

View File

@ -29,4 +29,24 @@ export const deleteOption = async function() {
// 提交意见反馈
export const aboutUs = async function() {
return await GET(`/wx/aboutUs`);
}
// 获取特色服务列表
export const getServicesList = async function() {
return await GET(`/wx/getServicesList?status=2`);
}
// 获取分类列表
export const getCategoryList = async function() {
return await GET(`/wx/getCategoryList?status=2`);
}
// 获取分类列表
export const getEncyclopediaList = async function(categoryId, page) {
return await GET(`/wx/getEncyclopedia?status=2&page=${page}&categoryId=${categoryId}`);
}
// 获取分类列表
export const getEncyclopediaDetail = async function(id) {
return await GET(`/wx/getEncyclopediaDetail/${id}`);
}