From db6d253898c0da73229fa484c402245a63c0afa1 Mon Sep 17 00:00:00 2001 From: qiaomu <3520484422@qq.com> Date: Tue, 2 Apr 2024 17:32:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=A7=8B=E5=81=9A=E5=85=85=E5=80=BC?= =?UTF-8?q?=EF=BC=8C=EF=BC=8C=E8=B0=83=E6=95=B4=E4=BA=86=E9=A6=96=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.json | 20 ++--- app.wxss | 8 ++ components/avatar/index.wxss | 1 + components/customStatusBar/index.wxml | 3 +- components/customStatusBar/index.wxss | 5 +- components/navigator/index.js | 2 +- components/navigator/index.json | 3 +- components/navigator/index.wxml | 20 +++-- components/navigator/index.wxss | 14 +++- components/navigatorWrapper/index.js | 36 +++++++++ components/navigatorWrapper/index.json | 4 + components/navigatorWrapper/index.wxml | 2 + components/navigatorWrapper/index.wxss | 1 + components/picker/index.js | 3 +- components/picker/index.wxml | 12 ++- pages/handleLogin/index.js | 14 ++++ pages/handleLogin/index.json | 6 +- pages/handleLogin/index.wxml | 80 ++++++++++++------- pages/handleLogin/index.wxss | 14 ++++ pages/home/index.js | 70 +++++++++++++--- pages/home/index.json | 4 +- pages/home/index.wxml | 23 ++++-- pages/home/index.wxss | 7 ++ pages/login/index.js | 26 +++--- pages/member/components/memberManage/index.js | 7 +- .../member/components/memberManage/index.json | 4 +- .../member/components/memberManage/index.wxml | 13 ++- .../member/components/memberManage/index.wxss | 38 ++++++++- pages/member/index.json | 6 +- pages/member/index.wxml | 1 + pages/rechargeDetail/index.js | 80 +++++++++++++++++++ pages/rechargeDetail/index.json | 8 ++ pages/rechargeDetail/index.wxml | 69 ++++++++++++++++ pages/rechargeDetail/index.wxss | 8 ++ pages/rechargeRecord/index.js | 72 ++++++++++++++--- pages/rechargeRecord/index.json | 7 +- pages/rechargeRecord/index.wxml | 37 ++++++--- pages/rechargeRecord/index.wxss | 43 +++++++++- project.private.config.json | 2 +- service/meter.js | 5 ++ service/recharge.js | 4 +- utils/data.js | 9 +++ utils/index.js | 9 ++- utils/request.js | 17 ++-- 44 files changed, 676 insertions(+), 141 deletions(-) create mode 100644 components/navigatorWrapper/index.js create mode 100644 components/navigatorWrapper/index.json create mode 100644 components/navigatorWrapper/index.wxml create mode 100644 components/navigatorWrapper/index.wxss create mode 100644 pages/rechargeDetail/index.js create mode 100644 pages/rechargeDetail/index.json create mode 100644 pages/rechargeDetail/index.wxml create mode 100644 pages/rechargeDetail/index.wxss create mode 100644 utils/data.js diff --git a/app.json b/app.json index 781a6ec..a30484f 100644 --- a/app.json +++ b/app.json @@ -1,21 +1,22 @@ { "pages": [ - "pages/home/index", - "pages/handleLogin/index", - "pages/my/index", - "pages/member/index", - "pages/login/index", - "pages/apply/index", - "pages/qrCode/index", - "pages/waitApprove/index", "pages/rechargeRecord/index", + "pages/home/index", "pages/invoiceList/index", + "pages/waitApprove/index", + "pages/my/index", + "pages/apply/index", + "pages/member/index", + "pages/handleLogin/index", + "pages/login/index", + "pages/qrCode/index", "pages/meterList/index", "pages/recharge/index", "pages/questions/index", "pages/index/index", "pages/invoiceDetail/index", - "pages/editInvoice/index" + "pages/editInvoice/index", + "pages/rechargeDetail/index" ], "tabBar": { "list": [ @@ -40,6 +41,5 @@ }, "sitemapLocation": "sitemap.json", "rendererOptions": {}, - "navigationStyle": "custom", "lazyCodeLoading": "requiredComponents" } \ No newline at end of file diff --git a/app.wxss b/app.wxss index 4520ae1..6cf0a1b 100644 --- a/app.wxss +++ b/app.wxss @@ -31,3 +31,11 @@ page { color: #ee0a24; } +/* 全局组件库样式 */ +.van-button--info { + background-color: var(--middle-green) !important; + border: 0 !important; + color: #fff !important; +} + + diff --git a/components/avatar/index.wxss b/components/avatar/index.wxss index a023ed7..1147be5 100644 --- a/components/avatar/index.wxss +++ b/components/avatar/index.wxss @@ -13,4 +13,5 @@ .text { max-width: 100rpx; overflow: hidden; + white-space: nowrap; } diff --git a/components/customStatusBar/index.wxml b/components/customStatusBar/index.wxml index f595d33..4e50b89 100644 --- a/components/customStatusBar/index.wxml +++ b/components/customStatusBar/index.wxml @@ -1,2 +1,3 @@ - \ No newline at end of file + + diff --git a/components/customStatusBar/index.wxss b/components/customStatusBar/index.wxss index 9ede41e..cae7116 100644 --- a/components/customStatusBar/index.wxss +++ b/components/customStatusBar/index.wxss @@ -1 +1,4 @@ -/* components/customStatusBar/index.wxss */ \ No newline at end of file +/* components/customStatusBar/index.wxss */ +.background { + background-color: var(--deep-green); +} \ No newline at end of file diff --git a/components/navigator/index.js b/components/navigator/index.js index a86a1d7..61e24b9 100644 --- a/components/navigator/index.js +++ b/components/navigator/index.js @@ -35,7 +35,7 @@ Component({ */ methods: { back() { - wx.navigateBack(); + this.triggerEvent("back") } } }) \ No newline at end of file diff --git a/components/navigator/index.json b/components/navigator/index.json index 4a42478..3ac933c 100644 --- a/components/navigator/index.json +++ b/components/navigator/index.json @@ -1,6 +1,7 @@ { "component": true, "usingComponents": { - + "customStatusBar": "/components/customStatusBar/index", + "van-icon": "@vant/weapp/icon/index" } } \ No newline at end of file diff --git a/components/navigator/index.wxml b/components/navigator/index.wxml index c755c00..bfd99fb 100644 --- a/components/navigator/index.wxml +++ b/components/navigator/index.wxml @@ -1,9 +1,13 @@ - - - - {{title}} + + + + + {{title}} + + + + - - - - \ No newline at end of file + + + \ No newline at end of file diff --git a/components/navigator/index.wxss b/components/navigator/index.wxss index f1912fb..b90ce4e 100644 --- a/components/navigator/index.wxss +++ b/components/navigator/index.wxss @@ -4,14 +4,21 @@ display: flex; align-items: flex-end; position: relative; + background-color: var(--deep-green); + color: #fff; + position: fixed; + left: 0; + right: 0; + top: 0; } .navigatorTitle { display: flex; justify-content: center; align-items: center; + text-align: center; height: 46px; - width: 100%; + width: 100vw; } .back { @@ -25,10 +32,15 @@ .backWrapper { display: flex; width: 100%; + width: 100rpx; background-color: transparent; height: 46px; position: absolute; bottom: 0; left: 0; align-items:center; +} + +.navigator { + display: flex; } \ No newline at end of file diff --git a/components/navigatorWrapper/index.js b/components/navigatorWrapper/index.js new file mode 100644 index 0000000..458e158 --- /dev/null +++ b/components/navigatorWrapper/index.js @@ -0,0 +1,36 @@ +// components/navigatorWrapper/index.js +Component({ + + /** + * 组件的属性列表 + */ + properties: { + statusBarHeight: 0, + }, + attached: function() { + const that = this; + wx.getSystemInfo({ + success: function (res) { + that.setData({ + statusBarHeight : res.statusBarHeight, + navBarHeight : res.statusBarHeight , // 顶部导航栏高度为 44px + jiaonangheight: wx.getMenuButtonBoundingClientRect().height, // 胶囊高度 + jiaonangwidth:wx.getMenuButtonBoundingClientRect().width, + }) + }, + }) + }, + /** + * 组件的初始数据 + */ + data: { + + }, + + /** + * 组件的方法列表 + */ + methods: { + + } +}) \ No newline at end of file diff --git a/components/navigatorWrapper/index.json b/components/navigatorWrapper/index.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/components/navigatorWrapper/index.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/components/navigatorWrapper/index.wxml b/components/navigatorWrapper/index.wxml new file mode 100644 index 0000000..9988d66 --- /dev/null +++ b/components/navigatorWrapper/index.wxml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/components/navigatorWrapper/index.wxss b/components/navigatorWrapper/index.wxss new file mode 100644 index 0000000..f03c1a9 --- /dev/null +++ b/components/navigatorWrapper/index.wxss @@ -0,0 +1 @@ +/* components/navigatorWrapper/index.wxss */ \ No newline at end of file diff --git a/components/picker/index.js b/components/picker/index.js index 4ad086c..4babf45 100644 --- a/components/picker/index.js +++ b/components/picker/index.js @@ -11,7 +11,8 @@ Component({ }, show: Boolean, columns: Array, - type: String + type: String, + title: String, }, /** diff --git a/components/picker/index.wxml b/components/picker/index.wxml index 9c78a7f..40b5c64 100644 --- a/components/picker/index.wxml +++ b/components/picker/index.wxml @@ -3,9 +3,17 @@ show="{{ show }}" position="bottom" bind:close="onClose" + > - + \ No newline at end of file diff --git a/pages/handleLogin/index.js b/pages/handleLogin/index.js index cd79641..a3f2c6a 100644 --- a/pages/handleLogin/index.js +++ b/pages/handleLogin/index.js @@ -93,6 +93,20 @@ Page({ }) }) }, + scan() { + wx.scanCode({ + scanType: "qrCode", + success: ({ path }) => { + wx.navigateTo({ + url: '/' + path, + }) + }, + fail: err => { + console.log('scan code err', err) + alertInfo("扫码失败,请稍后重试") + } + }) + }, /** * 生命周期函数--监听页面初次渲染完成 */ diff --git a/pages/handleLogin/index.json b/pages/handleLogin/index.json index b337e88..445dc6d 100644 --- a/pages/handleLogin/index.json +++ b/pages/handleLogin/index.json @@ -4,7 +4,9 @@ "select": "/components/select/index", "van-button": "@vant/weapp/button/index", "van-field": "@vant/weapp/field/index", - "van-icon": "@vant/weapp/icon/index" + "van-icon": "@vant/weapp/icon/index", + "van-tab": "@vant/weapp/tab/index", + "van-tabs": "@vant/weapp/tabs/index" }, - "navigationBarTitleText": "手动绑定" + "navigationBarTitleText": "绑定商户" } \ No newline at end of file diff --git a/pages/handleLogin/index.wxml b/pages/handleLogin/index.wxml index c637051..de7e4da 100644 --- a/pages/handleLogin/index.wxml +++ b/pages/handleLogin/index.wxml @@ -1,33 +1,53 @@ - - - - - - - 提交 - - + + + + + + 您可以联系贵司在系统中预留的手机号联系人 + + + 登录本系统-我的-二维码 + + + 使用微信扫一扫,直接绑定 + + + 去扫码 + + + + - 不知道预留的手机号?可联系后台管理员查询! + + + + + 提交 + + + + 不知道预留的手机号?可联系后台管理员查询! + + + 13266911877 + + - - 13266911877 - - - \ No newline at end of file + + diff --git a/pages/handleLogin/index.wxss b/pages/handleLogin/index.wxss index 263ba06..5df7a14 100644 --- a/pages/handleLogin/index.wxss +++ b/pages/handleLogin/index.wxss @@ -18,4 +18,18 @@ margin-top: 30rpx; color: var(--middle-green); display: inline-block; +} + +.codeContent { + margin-top: 10vh; + margin-left: 36rpx; + margin-right: 36rpx; +} + +.codeContent .text { + margin: 30rpx; +} + +.scan { + margin-top: 8vh; } \ No newline at end of file diff --git a/pages/home/index.js b/pages/home/index.js index ebe264f..c7eebb8 100644 --- a/pages/home/index.js +++ b/pages/home/index.js @@ -1,6 +1,7 @@ +import { getMeterDetail, getMeterList, getTenementMeterList } from "../../service/meter"; import { getOwnTenementList } from "../../service/tenement"; import { getUserInfo } from "../../service/user"; -import { alertInfo } from "../../utils/index"; +import { alertError, alertInfo } from "../../utils/index"; import request from '../../utils/request'; const { OK } = request; // pages/home/index.js @@ -16,7 +17,9 @@ Page({ tenement: {}, show: false, columns: [], - pickerType: "" + pickerType: "", + meterList: [], + meterIndex: 0, }, /** @@ -46,9 +49,35 @@ Page({ */ onReady() { + }, + async changeMeter() { + const { meterList = [], meterIndex, tenement = {} } = this.data; + let newIndex = meterIndex + 1; + if (newIndex === meterList.length) { + newIndex = 0; + } + const { code, message, data } = getMeterDetail({ code: meterList[newIndex]?.code, tenement: tenement.id }) + if (code !== OK) { + alertInfo(message) + return + } + meterList[newIndex] = { ...data.meter, money: data.money }; + this.setData({ + meterIndex: newIndex, + meterList + }) + }, + async refreshMeter() { + const { meterIndex } = this.data; + const { code, message, data } = getMeterDetail({ code: meterList[newIndex].id, tenement: tenement.id }) + if (code !== OK) { + alertInfo(message) + return + } + meterList[meterIndex] = { ...data.meter, money: data.money }; + this.setData({ meterList }) }, onOk(e) { - // console.log('e', e) const { type, index, value } = e.detail; const currentPark = this.data.park; if (type === "park") { @@ -109,6 +138,7 @@ Page({ this.watchTenement(); }, watchTenement() { + const that = this; let value = this.data.tenement; // 获取被监听属性的当前值 // 使用 Object.defineProperty 方法在数据对象上定义属性的 getter 和 setter @@ -121,17 +151,30 @@ Page({ set: function (newVal) { const oldValue = value; value = newVal; + // that.getMeters(newVal); } }); }, - async setUser() { - const result = await getUserInfo(); - if (result.code !== OK) { - alertInfo(result.message) + async getMeters({ id }) { + const { code, message, data } = await getTenementMeterList(id); + if (code !== OK) { + alertError(message) return; } - this.setData({ user: result.data }) - wx.setStorageSync('user', result.data) + this.setData({ + meterList: data || [] + }) + }, + async setUser() { + // const result = await getUserInfo(); + // if (result.code !== OK) { + // alertInfo(result.message) + // return; + // } + // this.setData({ user: result.data }) + // wx.setStorageSync('user', result.data) + const user = wx.getStorageSync('user') + this.setData({ user: user }) }, async getAllList() { const { code, message, data } = await getOwnTenementList() @@ -157,7 +200,14 @@ Page({ ...updateDatas }) }, - + jumpToRecord() { + wx.navigateTo({ + url: '/pages/rechargeRecord/index', + }) + }, + jumpToOrder() { + alertInfo("尚未完成") + }, /** * 生命周期函数--监听页面隐藏 */ diff --git a/pages/home/index.json b/pages/home/index.json index e2bb39e..f87c4e7 100644 --- a/pages/home/index.json +++ b/pages/home/index.json @@ -6,7 +6,9 @@ "van-image": "@vant/weapp/image/index", "avatar": "/components/avatar/index", "van-field": "@vant/weapp/field/index", - "picker": "/components/picker/index" + "picker": "/components/picker/index", + "van-grid": "@vant/weapp/grid/index", + "van-grid-item": "@vant/weapp/grid-item/index" }, "navigationStyle": "custom" } \ No newline at end of file diff --git a/pages/home/index.wxml b/pages/home/index.wxml index 96091d9..1a37d3e 100644 --- a/pages/home/index.wxml +++ b/pages/home/index.wxml @@ -2,10 +2,10 @@ - + - 用电管理服务 · - + 用电管理服务 · + {{park.name}} @@ -19,7 +19,7 @@ @@ -34,7 +34,7 @@ 华昌宝能 - 软c307 - + 切换电表 @@ -52,7 +52,7 @@ 电表余额: 200 - + 刷新 @@ -82,6 +82,17 @@ 去缴费 + + + + + + + + + + + diff --git a/pages/home/index.wxss b/pages/home/index.wxss index 2596dae..906df4b 100644 --- a/pages/home/index.wxss +++ b/pages/home/index.wxss @@ -128,4 +128,11 @@ .moneyInput { margin-top: 30rpx; margin-bottom: 30rpx; +} + +.others { + margin-left: 46rpx; + margin-right: 46rpx; + margin-top: 40rpx; + margin-bottom: 40rpx; } \ No newline at end of file diff --git a/pages/login/index.js b/pages/login/index.js index 1e2d3a0..375c0ce 100644 --- a/pages/login/index.js +++ b/pages/login/index.js @@ -20,19 +20,19 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad() { - const user = wx.getStorageSync('user') - if (!user || !user.id) { - return; - } - if (user.status === 0 || user.status === 2) { - wx.redirectTo({ - url: '/pages/waitApprove/index', - }) - return - } - wx.switchTab({ - url: '/pages/home/index', - }) + // const user = wx.getStorageSync('user') + // if (!user || !user.id) { + // return; + // } + // if (user.status === 0 || user.status === 2) { + // wx.redirectTo({ + // url: '/pages/waitApprove/index', + // }) + // return + // } + // wx.switchTab({ + // url: '/pages/home/index', + // }) }, /** diff --git a/pages/member/components/memberManage/index.js b/pages/member/components/memberManage/index.js index 3374801..bf4eb37 100644 --- a/pages/member/components/memberManage/index.js +++ b/pages/member/components/memberManage/index.js @@ -33,8 +33,13 @@ Component({ methods: { async init() { const result = await getApproveList(1) + const { code, message, data } = result; + // if (code !== OK) { + // alertInfo(message) + // return; + // } this.setData({ - list: result.data + list: data }) }, async setAdmin(e) { diff --git a/pages/member/components/memberManage/index.json b/pages/member/components/memberManage/index.json index 5ef2c96..c99aa63 100644 --- a/pages/member/components/memberManage/index.json +++ b/pages/member/components/memberManage/index.json @@ -2,6 +2,8 @@ "component": true, "usingComponents": { "van-tab": "@vant/weapp/tab/index", - "van-tabs": "@vant/weapp/tabs/index" + "van-tabs": "@vant/weapp/tabs/index", + "avatar": "/components/avatar/index", + "van-button": "@vant/weapp/button/index" } } \ No newline at end of file diff --git a/pages/member/components/memberManage/index.wxml b/pages/member/components/memberManage/index.wxml index 53caf7c..4ba0a25 100644 --- a/pages/member/components/memberManage/index.wxml +++ b/pages/member/components/memberManage/index.wxml @@ -10,10 +10,15 @@ - {{ ele.name }} - - 设为管理员 - 移除 + + + {{ ele.name }} + {{ ele.phone }} + + + + 设为管理员 + 移除 diff --git a/pages/member/components/memberManage/index.wxss b/pages/member/components/memberManage/index.wxss index 16b6f72..2949e41 100644 --- a/pages/member/components/memberManage/index.wxss +++ b/pages/member/components/memberManage/index.wxss @@ -3,10 +3,15 @@ .item { display: flex; align-items: center; - padding-top: 24rpx; - padding-bottom: 24rpx; + /* padding-top: 24rpx; */ + /* padding-bottom: 24rpx; */ + padding: 24rpx; margin-left: 32rpx; margin-right: 32rpx; + margin-top: 30rpx; + margin-bottom: 15rpx; + background-color: #fff; + border-radius: 30rpx; } .nickName { @@ -14,9 +19,38 @@ } .operate { + /* display: flex; */ + height: 100%; display: flex; + flex-direction: column; + align-items: flex-end; + justify-content: space-between; +} +.admin button, .remove button { + width: 180rpx; } .disAgree { margin-left: 24rpx; +} + +.info { + margin-left: 32rpx; + flex: 1; +} + +.nickName { + max-width: 300rpx; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + margin-bottom: 30rpx; +} + +page, .van-tabs__scroll { + background-color: rgb(228,240,236) !important; +} + +.van-tabs__scroll { + background-color: rgb(228,240,236) !important; } \ No newline at end of file diff --git a/pages/member/index.json b/pages/member/index.json index 8f621e3..4cfe010 100644 --- a/pages/member/index.json +++ b/pages/member/index.json @@ -3,6 +3,8 @@ "van-tab": "@vant/weapp/tab/index", "van-tabs": "@vant/weapp/tabs/index", "approve-member": "./components/approveMember/index", - "member-manage": "./components/memberManage/index" - } + "member-manage": "./components/memberManage/index", + "navigator": "/components/navigator/index" + }, + "navigationStyle": "custom" } \ No newline at end of file diff --git a/pages/member/index.wxml b/pages/member/index.wxml index f71dcf2..378ebdb 100644 --- a/pages/member/index.wxml +++ b/pages/member/index.wxml @@ -4,6 +4,7 @@ --> + \ No newline at end of file diff --git a/pages/rechargeDetail/index.js b/pages/rechargeDetail/index.js new file mode 100644 index 0000000..5136df1 --- /dev/null +++ b/pages/rechargeDetail/index.js @@ -0,0 +1,80 @@ +import { getRechargeDetail } from "../../service/recharge"; +import request from "../../utils/request" +const { OK } = request +// pages/rechargeDetail/index.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + detail: {} + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + const { id } = options; + this.init(id) + }, + async init(id) { + const { code, message, data } = await getRechargeDetail(id) + this.setData({ + detail: data + }) + }, + back() { + // wx.navigateBack({ delta: 1 }); + wx.navigateBack(); + }, + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + const pages = getCurrentPages() + console.log('pages', pages) + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/rechargeDetail/index.json b/pages/rechargeDetail/index.json new file mode 100644 index 0000000..42e60d9 --- /dev/null +++ b/pages/rechargeDetail/index.json @@ -0,0 +1,8 @@ +{ + "usingComponents": { + "navigator": "/components/navigator/index", + "van-field": "@vant/weapp/field/index", + "van-button": "@vant/weapp/button/index" + }, + "navigationStyle": "custom" +} \ No newline at end of file diff --git a/pages/rechargeDetail/index.wxml b/pages/rechargeDetail/index.wxml new file mode 100644 index 0000000..28bf0ce --- /dev/null +++ b/pages/rechargeDetail/index.wxml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + 返回 + \ No newline at end of file diff --git a/pages/rechargeDetail/index.wxss b/pages/rechargeDetail/index.wxss new file mode 100644 index 0000000..03cd5c7 --- /dev/null +++ b/pages/rechargeDetail/index.wxss @@ -0,0 +1,8 @@ +/* pages/rechargeDetail/index.wxss */ +.operate { + margin-top: 60rpx; + margin-left: 36rpx; + margin-right: 36rpx; + padding-bottom: 50rpx; +} + diff --git a/pages/rechargeRecord/index.js b/pages/rechargeRecord/index.js index f723f91..6d00e0f 100644 --- a/pages/rechargeRecord/index.js +++ b/pages/rechargeRecord/index.js @@ -1,4 +1,5 @@ import { getRechargeList } from "../../service/recharge"; +import { getOwnTenementList } from "../../service/tenement"; import { getYears } from "../../utils/index"; // pages/rechargeRecord/index.js @@ -13,9 +14,30 @@ Page({ years: getYears(), list: [ - ] + ], + tenement: "", + tenementName: "", + show: false, + columns: [], + type: "", + title: "" + }, + clickYear() { + this.setData({ + type: "year", + columns: this.data.years, + show: true, + title: "年份" + }) + }, + onOk(e) { + console.log('e', e) + const { type, value = {} } = e.detail; + if (type === "year") { + this.onChangeYear(value.id) + return; + } }, - /** * 生命周期函数--监听页面加载 */ @@ -30,25 +52,51 @@ Page({ }, onChangeYear(e) { - const { years } = this.data; - const currentYear = years[Number(e.detail.value)] + const { years, tenement } = this.data; + const currentYear = years[Number(e)] this.setData({ - year: currentYear + year: currentYear, + type: "", + show: false, + title: "" }) - this.init(currentYear) + this.init(currentYear, tenement) }, /** * 生命周期函数--监听页面显示 */ onShow() { - const currentYear = this.data.year; - this.init(currentYear) + const { year, tenement } = this.data; + this.init(year, tenement) }, - async init(year) { - const { code, message, data } = await getRechargeList(year); - this.setData({ - list: data + async getTenementsList() { + const { code, message, data } = await getOwnTenementList() + if (code !== OK) { + alertInfo(message) + return + } + let tenements = []; + data.forEach(item => { + if (item.tenements) { + tenements = [...tenements, ...item.tenements] + } }) + this.setData({ tenements }) + }, + async init(year, tenement) { + const { code, message, data } = await getRechargeList(year, tenement); + this.setData({ + list: [...data, ...data] + }) + }, + jumpToDetail(e) { + const { id } = e.currentTarget.dataset; + wx.navigateTo({ + url: '/pages/rechargeDetail/index?id=' + id, + }) + }, + back() { + wx.navigateBack({delta: 1 }) }, /** * 生命周期函数--监听页面隐藏 diff --git a/pages/rechargeRecord/index.json b/pages/rechargeRecord/index.json index 04f64e5..8a9e30b 100644 --- a/pages/rechargeRecord/index.json +++ b/pages/rechargeRecord/index.json @@ -1,7 +1,10 @@ { "usingComponents": { "navigator": "/components/navigator/index", - "scrollPageWrapper": "/components/scrollPageWrapper/index" + "scrollPageWrapper": "/components/scrollPageWrapper/index", + "van-icon": "@vant/weapp/icon/index", + "custom-status-bar": "/components/customStatusBar/index", + "custom-picker": "/components/picker/index" }, - "navigationBarTitleText": "充值记录" + "navigationStyle": "custom" } \ No newline at end of file diff --git a/pages/rechargeRecord/index.wxml b/pages/rechargeRecord/index.wxml index 52f57f2..5f3623b 100644 --- a/pages/rechargeRecord/index.wxml +++ b/pages/rechargeRecord/index.wxml @@ -1,20 +1,35 @@ - - - - - {{ year }}年 - - - + + + + + {{ year }}年 + + + + + + {{ tenementName }} + 全部 + + + + + 合计: 3000元 + + - + + 充值 - 表号:{{ item.meter.code }} + {{ item.meter.address }} {{ item.time }} - {{ item.money }} + {{ item.money }}元 + + + \ No newline at end of file diff --git a/pages/rechargeRecord/index.wxss b/pages/rechargeRecord/index.wxss index 9381867..820aacc 100644 --- a/pages/rechargeRecord/index.wxss +++ b/pages/rechargeRecord/index.wxss @@ -1,4 +1,5 @@ /* pages/rechargeRecord/index.wxss */ + .yearPicker { display: flex; align-items: center; @@ -20,11 +21,12 @@ } .recordsItem { display: flex; - justify-content: space-between; + /* justify-content: space-between; */ padding: 16rpx 20rpx; border-left: 0; border-right: 0; border-top: 0; + align-items: center; } .recordsItem:last-child { border-bottom: 0; @@ -39,10 +41,49 @@ .money { font-size: 42rpx; font-weight: 600; + margin-right: 30rpx; } .wrapper { display: flex; flex-direction: column; flex: 1; +} + +.chooseWrapper { + display: flex; + align-items: center; + background-color: var(--middle-green); + padding: 30rpx 36rpx; +} + +.tenementPicker { + margin-left: 30rpx; + display: flex; + align-items: center; +} + +.allMoney { + flex: 1; + text-align: right; + color: #fff; + font-size: 32rpx; + /* display: flex; */ + /* justify-content: end; */ +} + +.type { + margin-right: 46rpx; + font-weight: 600; +} + +.codeTime { + flex: 1; +} + +.tenementName { + max-width: 200rpx; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; } \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json index efba64d..064c7f3 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -2,7 +2,7 @@ "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", "projectname": "electricity_bill_calc_wx", "setting": { - "compileHotReLoad": true, + "compileHotReLoad": false, "urlCheck": false, "skylineRenderEnable": true }, diff --git a/service/meter.js b/service/meter.js index c0a8f0c..888c69e 100644 --- a/service/meter.js +++ b/service/meter.js @@ -9,4 +9,9 @@ export const getMeterList = async function() { // 获取表计详情 export const getMeterDetail = async function({ tenement, code }) { return await GET(`/wx/getMeterDetail/${tenement}/${code}`); +} + +// 获取某一商户的电表列表 +export const getTenementMeterList = async function(tid) { + return await GET(`/wx/getMeterList/${tid}`); } \ No newline at end of file diff --git a/service/recharge.js b/service/recharge.js index 916a4fb..070f8e6 100644 --- a/service/recharge.js +++ b/service/recharge.js @@ -2,8 +2,8 @@ import apis from '../utils/request'; const { GET, POST, PUT, DELETE } = apis // 获取充值记录 -export const getRechargeList = async function(year) { - return await GET(`/wx/getRechargeList?year=${year}`); +export const getRechargeList = async function(year, tenement) { + return await GET(`/wx/getRechargeList?year=${year}&tenement=${tenement}`); } // 预备充值请求 diff --git a/utils/data.js b/utils/data.js new file mode 100644 index 0000000..3baa953 --- /dev/null +++ b/utils/data.js @@ -0,0 +1,9 @@ +export const getRechargeOperateType = (num) => { + const types = ["充值", "冲正", "退费"] + return types[num]; +} + +export const getRechargeOperateWay = (num) => { + const types = ["现金", "银行卡", "支付宝", "微信", "云闪付"] + return types[num]; +} \ No newline at end of file diff --git a/utils/index.js b/utils/index.js index adb98ac..fa494ac 100644 --- a/utils/index.js +++ b/utils/index.js @@ -43,8 +43,8 @@ export function getConfigByEnv() { switch (envVersion) { // 开发版 case 'develop': - api = "http://localhost:8000" - // api = "http://127.0.0.1:4523/m1/4143821-0-default" + // api = "http://localhost:8000" + api = "http://127.0.0.1:4523/m1/4143821-0-default" break; // 体验版 case 'trial': @@ -52,6 +52,7 @@ export function getConfigByEnv() { break; // 正式版 case 'release': + api = "https://zgd.hbhcbn.com/wxApi" break; } return { api, } @@ -105,9 +106,9 @@ export function showModal({ export function getYears() { const years = []; const currentYear = new Date().getFullYear(); - const minYear = 2023; + const minYear = 2024; for(let i = currentYear; i >= minYear; i--) { - years.push(i); + years.push({name: i, id: i}); } return years; } diff --git a/utils/request.js b/utils/request.js index b90524b..59e4e15 100644 --- a/utils/request.js +++ b/utils/request.js @@ -34,10 +34,10 @@ const request = async function (options, config = {}) { try { response = await requestWithoutCookie(options); // 服务器没有返回200直接报错 - if (!response || response.statusCode !== 200) { - alertError(response?.data?.message || "发生错误,请稍后重试") - return; - } + // if (!response || response.statusCode !== 200) { + // alertError(response?.data?.message || "发生错误,请稍后重试") + // return; + // } // 处理cookie const setCookie = response.header['set-cookie'] || response.header['Set-Cookie']; @@ -82,7 +82,7 @@ const parseResponse = function (response) { alertError("服务异常") return } - const { code: statusCode } = response; + const { statusCode } = response; if (statusCode === 401) { wx.redirectTo({ url: '/pages/login/index', @@ -95,10 +95,6 @@ const parseResponse = function (response) { if (500 <= statusCode && statusCode < 600) { return { code: 500, message: "服务错误" } } - - if (response.data.code !== 200) { - - } return response.data; } @@ -106,7 +102,8 @@ const parseResponse = function (response) { const GET = async function (uri) { const response = await request({ url: `${SERVER}${uri}`, - method: 'GET' + method: 'GET', + }); return parseResponse(response);