二、C端小程序电费扣款记录

This commit is contained in:
2025-07-17 15:33:22 +08:00
parent ac0a4b02c7
commit f9aedf7d79
5 changed files with 152 additions and 4 deletions

View File

@@ -1,4 +1,8 @@
import dayjs from "../../utils/dayjs"
import { getDayCalcList } from "../../service/calc"
import { alertError } from "../../utils/index";
import request from "../../utils/request"
const { OK } = request
// pages/meterBalanceRecord/index.js
Page({
@@ -9,6 +13,9 @@ Page({
data: {
time: "",
timeStamp: undefined,
list: [],
page: 1,
size: 999,
},
/**
@@ -16,11 +23,13 @@ Page({
*/
onLoad(options) {
const { id } = options
console.log("id---", id)
const that = this;
this.setData({
id,
time: dayjs().format("YYYY-MM"),
timeStamp: Date.now()
}, () => {
that.getList()
})
},
clickTime() {
@@ -28,13 +37,35 @@ Page({
timeVisible: true
})
},
async getList() {
const { id, time, page, size } = this.data;
const { code, message, data } = await getDayCalcList({
page,
size,
startTime: dayjs(time).subtract(1, 'month').endOf('month').format("YYYY-MM-DD"),
endTime: dayjs(time).endOf('month').format("YYYY-MM-DD"),
codeId: id,
})
if (code !== OK) {
alertError(message)
return
}
this.setData({
list: data?.map(item => {
item.day = dayjs(item.endTime).format("DD日")
return item;
})
})
},
onTimeConfirm(e) {
console.log('e', e)
const { time } = e.detail;
const that = this;
this.setData({
time,
timeStamp: new Date(time).getTime(),
timeVisible: false,
}, () => {
that.getList()
})
},
onTimeCancel() {