开始做充值,,调整了首页

This commit is contained in:
qiaomu 2024-04-02 17:32:28 +08:00
parent 3284bea475
commit db6d253898
44 changed files with 676 additions and 141 deletions

View File

@ -1,21 +1,22 @@
{ {
"pages": [ "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/rechargeRecord/index",
"pages/home/index",
"pages/invoiceList/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/meterList/index",
"pages/recharge/index", "pages/recharge/index",
"pages/questions/index", "pages/questions/index",
"pages/index/index", "pages/index/index",
"pages/invoiceDetail/index", "pages/invoiceDetail/index",
"pages/editInvoice/index" "pages/editInvoice/index",
"pages/rechargeDetail/index"
], ],
"tabBar": { "tabBar": {
"list": [ "list": [
@ -40,6 +41,5 @@
}, },
"sitemapLocation": "sitemap.json", "sitemapLocation": "sitemap.json",
"rendererOptions": {}, "rendererOptions": {},
"navigationStyle": "custom",
"lazyCodeLoading": "requiredComponents" "lazyCodeLoading": "requiredComponents"
} }

View File

@ -31,3 +31,11 @@ page {
color: #ee0a24; color: #ee0a24;
} }
/* 全局组件库样式 */
.van-button--info {
background-color: var(--middle-green) !important;
border: 0 !important;
color: #fff !important;
}

View File

@ -13,4 +13,5 @@
.text { .text {
max-width: 100rpx; max-width: 100rpx;
overflow: hidden; overflow: hidden;
white-space: nowrap;
} }

View File

@ -1,2 +1,3 @@
<!--components/customStatusBar/index.wxml--> <!--components/customStatusBar/index.wxml-->
<view class="wrapper" style="height: {{height}}px;"></view> <view wx:if="{{transparent}}" class="wrapper" style="height: {{height}}px;"></view>
<view wx:else class="wrapper background" style="height: {{height}}px;"></view>

View File

@ -1 +1,4 @@
/* components/customStatusBar/index.wxss */ /* components/customStatusBar/index.wxss */
.background {
background-color: var(--deep-green);
}

View File

@ -35,7 +35,7 @@ Component({
*/ */
methods: { methods: {
back() { back() {
wx.navigateBack(); this.triggerEvent("back")
} }
} }
}) })

View File

@ -1,6 +1,7 @@
{ {
"component": true, "component": true,
"usingComponents": { "usingComponents": {
"customStatusBar": "/components/customStatusBar/index",
"van-icon": "@vant/weapp/icon/index"
} }
} }

View File

@ -1,9 +1,13 @@
<view class="navigator" style="height: {{(statusBarHeight + 46)}}px;"> <!-- 使用fixed定位 -->
<view class="navigatorTitle"> <view class="navigator">
<view class="navigator" style="height: {{statusBarHeight + 46}}px;">
{{title}} <view class="navigatorTitle">
{{title}}
</view>
<view class="backWrapper" bind:tap="back">
<van-icon name="arrow-left" wx:if="{{canBack}}" class="back" />
</view>
</view> </view>
<view class="backWrapper"> </view>
<image src="/assets/images/left.png" bind:tap="back" wx:if="{{canBack}}" class="back" /> <!-- 填充fixed定位页面被覆盖的组件 -->
</view> <view class="wrapper" style="height: {{statusBarHeight + 46}}px"></view>
</view>

View File

@ -4,14 +4,21 @@
display: flex; display: flex;
align-items: flex-end; align-items: flex-end;
position: relative; position: relative;
background-color: var(--deep-green);
color: #fff;
position: fixed;
left: 0;
right: 0;
top: 0;
} }
.navigatorTitle { .navigatorTitle {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
text-align: center;
height: 46px; height: 46px;
width: 100%; width: 100vw;
} }
.back { .back {
@ -25,10 +32,15 @@
.backWrapper { .backWrapper {
display: flex; display: flex;
width: 100%; width: 100%;
width: 100rpx;
background-color: transparent; background-color: transparent;
height: 46px; height: 46px;
position: absolute; position: absolute;
bottom: 0; bottom: 0;
left: 0; left: 0;
align-items:center; align-items:center;
}
.navigator {
display: flex;
} }

View File

@ -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: {
}
})

View File

@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

View File

@ -0,0 +1,2 @@
<!-- 由于自定义navigator使用了固定定位所以需要一个同等高度的东西填充这段空白防止内容被遮挡 -->
<view class="wrapper" style="height: {{statusBarHeight + 46}}px"></view>

View File

@ -0,0 +1 @@
/* components/navigatorWrapper/index.wxss */

View File

@ -11,7 +11,8 @@ Component({
}, },
show: Boolean, show: Boolean,
columns: Array, columns: Array,
type: String type: String,
title: String,
}, },
/** /**

View File

@ -3,9 +3,17 @@
show="{{ show }}" show="{{ show }}"
position="bottom" position="bottom"
bind:close="onClose" bind:close="onClose"
> >
<view style="width: 100vw;"> <view style="width: 100vw;">
<van-picker show-toolbar <van-picker
title="标题" columns="{{ columns }}" bind:change="onChange" value-key="name" bind:confirm="confirm" bind:cancel="cancel" /> show-toolbar
title="{{title}}"
columns="{{ columns }}"
bind:change="onChange"
value-key="name"
bind:confirm="confirm"
bind:cancel="cancel"
/>
</view> </view>
</van-popup> </van-popup>

View File

@ -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("扫码失败,请稍后重试")
}
})
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */

View File

@ -4,7 +4,9 @@
"select": "/components/select/index", "select": "/components/select/index",
"van-button": "@vant/weapp/button/index", "van-button": "@vant/weapp/button/index",
"van-field": "@vant/weapp/field/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": "绑定商户"
} }

View File

@ -1,33 +1,53 @@
<!--pages/handleLogin/index.wxml--> <!--pages/handleLogin/index.wxml-->
<topbar /> <!-- <topbar /> -->
<view> <van-tabs>
<select label="园区" type="0" bind:choose="onChoosePark" park="{{park}}" parkName="{{parkName}}" required="{{true}}" /> <van-tab title="扫码绑定">
<select label="公司名称" type="1" bind:choose="onChooseTenement" park="{{park}}" tenement="{{tenement}}" tenementName="{{tenementName}}" required="{{true}}" /> <view class="codeContent">
<van-field <view class="text">
required 您可以联系贵司在系统中预留的手机号联系人
value="{{ phone }}" </view>
label="联系人手机号" <view class="text">
placeholder="请输入联系人手机号" 登录本系统-我的-二维码
border="{{ true }}" </view>
bind:change="onChangePhone" <view class="text">
/> 使用微信扫一扫,直接绑定
<van-field </view>
required <view class="scan">
value="{{ name }}" <van-button type="info" block bind:click="scan"> 去扫码 </van-button>
label="你的昵称" </view>
placeholder="请输入你的昵称" </view>
border="{{ true }}" </van-tab>
bind:change="onChangeName" <van-tab title="手动绑定">
/>
<view class="submit">
<van-button type="info" block bind:click="handleSubmit"> 提交 </van-button>
</view>
<view class="way">
<view> <view>
不知道预留的手机号?可联系后台管理员查询! <select label="园区" type="0" bind:choose="onChoosePark" park="{{park}}" parkName="{{parkName}}" required="{{true}}" />
<select label="公司名称" type="1" bind:choose="onChooseTenement" park="{{park}}" tenement="{{tenement}}" tenementName="{{tenementName}}" required="{{true}}" />
<van-field
required
value="{{ phone }}"
label="联系人手机号"
placeholder="请输入联系人手机号"
border="{{ true }}"
bind:change="onChangePhone"
/>
<van-field
required
value="{{ name }}"
label="你的昵称"
placeholder="请输入你的昵称"
border="{{ true }}"
bind:change="onChangeName"
/>
<view class="submit">
<van-button type="info" block bind:click="handleSubmit"> 提交 </van-button>
</view>
<view class="way">
<view>
不知道预留的手机号?可联系后台管理员查询!
</view>
<view class="phone" bind:tap="callPhone" data-phone="13266911877">
<van-icon name="phone-o" class="phoneIcon" /> 13266911877
</view>
</view>
</view> </view>
<view class="phone" bind:tap="callPhone" data-phone="13266911877"> </van-tab>
<van-icon name="phone-o" class="phoneIcon" /> 13266911877 </van-tabs>
</view>
</view>
</view>

View File

@ -18,4 +18,18 @@
margin-top: 30rpx; margin-top: 30rpx;
color: var(--middle-green); color: var(--middle-green);
display: inline-block; display: inline-block;
}
.codeContent {
margin-top: 10vh;
margin-left: 36rpx;
margin-right: 36rpx;
}
.codeContent .text {
margin: 30rpx;
}
.scan {
margin-top: 8vh;
} }

View File

@ -1,6 +1,7 @@
import { getMeterDetail, getMeterList, getTenementMeterList } from "../../service/meter";
import { getOwnTenementList } from "../../service/tenement"; import { getOwnTenementList } from "../../service/tenement";
import { getUserInfo } from "../../service/user"; import { getUserInfo } from "../../service/user";
import { alertInfo } from "../../utils/index"; import { alertError, alertInfo } from "../../utils/index";
import request from '../../utils/request'; import request from '../../utils/request';
const { OK } = request; const { OK } = request;
// pages/home/index.js // pages/home/index.js
@ -16,7 +17,9 @@ Page({
tenement: {}, tenement: {},
show: false, show: false,
columns: [], columns: [],
pickerType: "" pickerType: "",
meterList: [],
meterIndex: 0,
}, },
/** /**
@ -46,9 +49,35 @@ Page({
*/ */
onReady() { 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) { onOk(e) {
// console.log('e', e)
const { type, index, value } = e.detail; const { type, index, value } = e.detail;
const currentPark = this.data.park; const currentPark = this.data.park;
if (type === "park") { if (type === "park") {
@ -109,6 +138,7 @@ Page({
this.watchTenement(); this.watchTenement();
}, },
watchTenement() { watchTenement() {
const that = this;
let value = this.data.tenement; // 获取被监听属性的当前值 let value = this.data.tenement; // 获取被监听属性的当前值
// 使用 Object.defineProperty 方法在数据对象上定义属性的 getter 和 setter // 使用 Object.defineProperty 方法在数据对象上定义属性的 getter 和 setter
@ -121,17 +151,30 @@ Page({
set: function (newVal) { set: function (newVal) {
const oldValue = value; const oldValue = value;
value = newVal; value = newVal;
// that.getMeters(newVal);
} }
}); });
}, },
async setUser() { async getMeters({ id }) {
const result = await getUserInfo(); const { code, message, data } = await getTenementMeterList(id);
if (result.code !== OK) { if (code !== OK) {
alertInfo(result.message) alertError(message)
return; return;
} }
this.setData({ user: result.data }) this.setData({
wx.setStorageSync('user', result.data) 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() { async getAllList() {
const { code, message, data } = await getOwnTenementList() const { code, message, data } = await getOwnTenementList()
@ -157,7 +200,14 @@ Page({
...updateDatas ...updateDatas
}) })
}, },
jumpToRecord() {
wx.navigateTo({
url: '/pages/rechargeRecord/index',
})
},
jumpToOrder() {
alertInfo("尚未完成")
},
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */

View File

@ -6,7 +6,9 @@
"van-image": "@vant/weapp/image/index", "van-image": "@vant/weapp/image/index",
"avatar": "/components/avatar/index", "avatar": "/components/avatar/index",
"van-field": "@vant/weapp/field/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" "navigationStyle": "custom"
} }

View File

@ -2,10 +2,10 @@
<page-meta page-style="{{ show ? 'overflow: hidden;' : '' }}" /> <page-meta page-style="{{ show ? 'overflow: hidden;' : '' }}" />
<view> <view>
<view class="top"> <view class="top">
<custom-status-bar /> <custom-status-bar transparent="{{true}}" />
<view class="chooseParkWrapper"> <view class="chooseParkWrapper">
用电管理服务 · 用电管理服务 ·
<view class="parkContent" bind:tap="choosePark"> <view class="parkContent" bind:tap="choosePark" wx:if="{{park.id}}">
<view class="park"> <view class="park">
{{park.name}} {{park.name}}
</view> </view>
@ -19,7 +19,7 @@
</view> </view>
<view class="login" wx:if="{{!user || !user.id}}" class="notLoginWrapper"> <view class="login" wx:if="{{!user || !user.id}}" class="notLoginWrapper">
<van-image width="100rpx" height="100rpx" src="/assets/images/defaultAvatar.png" class="defaultAvatar"/> <van-image width="100rpx" height="100rpx" src="/assets/images/defaultAvatar.png" class="defaultAvatar"/>
<van-button type="info" size="small" plain="{{true}}" class="loginBtn" bind:tap="jumpToLogin">请登录</van-button> <van-button type="primary" size="small" plain="{{true}}" class="loginBtn" bind:tap="jumpToLogin">请登录</van-button>
</view> </view>
<view class="logined" wx:else> <view class="logined" wx:else>
<avatar text="{{ user.nickName }}" /> <avatar text="{{ user.nickName }}" />
@ -34,7 +34,7 @@
<view class="cardTopLeft"> <view class="cardTopLeft">
<view> 华昌宝能 - 软c307 </view> <view> 华昌宝能 - 软c307 </view>
</view> </view>
<van-button type="info" size="small" plain="{{true}}" class="loginBtn"> <van-button type="info" size="small" plain="{{true}}" class="loginBtn" bind:click="changeMeter">
<van-icon name="exchange" /> <van-icon name="exchange" />
切换电表 切换电表
</van-button> </van-button>
@ -52,7 +52,7 @@
<view class="cardItemLabel"> 电表余额: </view> <view class="cardItemLabel"> 电表余额: </view>
<view class="cardItemValue"> <view class="cardItemValue">
<view class="text"> 200 </view> <view class="text"> 200 </view>
<van-button type="info" size="small" plain="{{true}}"> <van-button type="info" size="small" plain="{{true}}" bind:click="refreshMeter">
<van-icon name="replay" /> <van-icon name="replay" />
刷新 刷新
</van-button> </van-button>
@ -82,6 +82,17 @@
<view class="operate"> <view class="operate">
<van-button color="rgb(88, 165, 141)" block>去缴费</van-button> <van-button color="rgb(88, 165, 141)" block>去缴费</van-button>
</view> </view>
<view class="others">
<van-grid direction="horizontal" column-num="2">
<van-grid-item icon="balance-list-o" text="电费账单" bind:click="jumpToOrder">
<!-- <view slot="icon"> 111 </view> -->
<!-- <van-icon slot="icom" name="balance-list-o" /> -->
</van-grid-item>
<van-grid-item icon="after-sale" text="缴费记录" bind:click="jumpToRecord" />
<van-grid-item icon="bar-chart-o" text="用电查询" />
<van-grid-item icon="bill-o" text="去开票" />
</van-grid>
</view>
</view> </view>
</view> </view>

View File

@ -128,4 +128,11 @@
.moneyInput { .moneyInput {
margin-top: 30rpx; margin-top: 30rpx;
margin-bottom: 30rpx; margin-bottom: 30rpx;
}
.others {
margin-left: 46rpx;
margin-right: 46rpx;
margin-top: 40rpx;
margin-bottom: 40rpx;
} }

View File

@ -20,19 +20,19 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad() { onLoad() {
const user = wx.getStorageSync('user') // const user = wx.getStorageSync('user')
if (!user || !user.id) { // if (!user || !user.id) {
return; // return;
} // }
if (user.status === 0 || user.status === 2) { // if (user.status === 0 || user.status === 2) {
wx.redirectTo({ // wx.redirectTo({
url: '/pages/waitApprove/index', // url: '/pages/waitApprove/index',
}) // })
return // return
} // }
wx.switchTab({ // wx.switchTab({
url: '/pages/home/index', // url: '/pages/home/index',
}) // })
}, },
/** /**

View File

@ -33,8 +33,13 @@ Component({
methods: { methods: {
async init() { async init() {
const result = await getApproveList(1) const result = await getApproveList(1)
const { code, message, data } = result;
// if (code !== OK) {
// alertInfo(message)
// return;
// }
this.setData({ this.setData({
list: result.data list: data
}) })
}, },
async setAdmin(e) { async setAdmin(e) {

View File

@ -2,6 +2,8 @@
"component": true, "component": true,
"usingComponents": { "usingComponents": {
"van-tab": "@vant/weapp/tab/index", "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"
} }
} }

View File

@ -10,10 +10,15 @@
<van-tabs active="{{ active }}" bind:change="onChange"> <van-tabs active="{{ active }}" bind:change="onChange">
<van-tab wx:for="{{list}}" wx:key="index" title="{{item.name}}"> <van-tab wx:for="{{list}}" wx:key="index" title="{{item.name}}">
<view wx:for="{{item.users}}" wx:key="index" wx:for-item="ele" class="item"> <view wx:for="{{item.users}}" wx:key="index" wx:for-item="ele" class="item">
<view class="nickName"> {{ ele.name }} </view> <avatar text="{{ele.name}}" />
<view class="operate" wx:if="{{!ele.isAdmin}}"> <view class="info">
<view class="primaryTextBtn" data-user="{{ele}}" bind:tap="setAdmin" data-tenement="{{item.id}}"> 设为管理员 </view> <view class="nickName"> {{ ele.name }} </view>
<view class="disAgree dangerTextBtn" data-user="{{ele}}" bind:tap="remove" data-tenement="{{item.id}}"> 移除 </view> <view class="phone"> {{ ele.phone }} </view>
</view>
<!-- <view class="operate" wx:if="{{!ele.isAdmin}}"> -->
<view class="operate">
<van-button type="info" size="small" data-user="{{ele}}" bind:click="setAdmin" data-tenement="{{item.id}}" style="margin-bottom: 16rpx;" class="admin">设为管理员</van-button>
<van-button type="danger" size="small" data-user="{{ele}}" bind:click="remove" data-tenement="{{item.id}}" class="remove">移除</van-button>
</view> </view>
</view> </view>
</van-tab> </van-tab>

View File

@ -3,10 +3,15 @@
.item { .item {
display: flex; display: flex;
align-items: center; align-items: center;
padding-top: 24rpx; /* padding-top: 24rpx; */
padding-bottom: 24rpx; /* padding-bottom: 24rpx; */
padding: 24rpx;
margin-left: 32rpx; margin-left: 32rpx;
margin-right: 32rpx; margin-right: 32rpx;
margin-top: 30rpx;
margin-bottom: 15rpx;
background-color: #fff;
border-radius: 30rpx;
} }
.nickName { .nickName {
@ -14,9 +19,38 @@
} }
.operate { .operate {
/* display: flex; */
height: 100%;
display: flex; display: flex;
flex-direction: column;
align-items: flex-end;
justify-content: space-between;
}
.admin button, .remove button {
width: 180rpx;
} }
.disAgree { .disAgree {
margin-left: 24rpx; 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;
} }

View File

@ -3,6 +3,8 @@
"van-tab": "@vant/weapp/tab/index", "van-tab": "@vant/weapp/tab/index",
"van-tabs": "@vant/weapp/tabs/index", "van-tabs": "@vant/weapp/tabs/index",
"approve-member": "./components/approveMember/index", "approve-member": "./components/approveMember/index",
"member-manage": "./components/memberManage/index" "member-manage": "./components/memberManage/index",
} "navigator": "/components/navigator/index"
},
"navigationStyle": "custom"
} }

View File

@ -4,6 +4,7 @@
<approve-member /> <approve-member />
</van-tab> </van-tab>
<van-tab title="人员管理"> --> <van-tab title="人员管理"> -->
<navigator canBack="{{true}}" title="成员管理" />
<member-manage /> <member-manage />
<!-- </van-tab> --> <!-- </van-tab> -->
<!-- </van-tabs> --> <!-- </van-tabs> -->

View File

@ -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() {
}
})

View File

@ -0,0 +1,8 @@
{
"usingComponents": {
"navigator": "/components/navigator/index",
"van-field": "@vant/weapp/field/index",
"van-button": "@vant/weapp/button/index"
},
"navigationStyle": "custom"
}

View File

@ -0,0 +1,69 @@
<!--pages/rechargeDetail/index.wxml-->
<navigator title="充值详情" canBack="{{true}}" bind:back="back" />
<van-cell-group>
<van-field
value="{{detail.tenement.name}}"
label="商户名称"
readonly
border="{{ false }}"
/>
<van-field
value="{{detail.meter.code}}"
label="电表编号"
readonly
border="{{ false }}"
/>
<van-field
value="{{detail.meter.address}}"
label="电表地址"
readonly
border="{{ false }}"
/>
<van-field
value="{{detail.time}}"
label="操作时间"
readonly
border="{{ false }}"
/>
<van-field
value="{{detail.account}}"
label="充值账号"
readonly
border="{{ false }}"
/>
<van-field
value="{{detail.money}}"
label="充值金额"
readonly
border="{{ false }}"
/>
<van-field
value="{{detail.tenement.name}}"
label="操作类型"
readonly
border="{{ false }}"
/>
<van-field
value="{{detail.tenement.name}}"
label="付款方式"
readonly
border="{{ false }}"
/>
<van-field
value="{{detail.voucherNo}}"
label="订单号"
readonly
border="{{ false }}"
/>
<van-field
value="{{detail.serialNumber}}"
label="流水号"
readonly
border="{{ false }}"
/>
</van-cell-group>
<view class="operate">
<van-button type="default" block bind:tap="back">返回</van-button>
</view>

View File

@ -0,0 +1,8 @@
/* pages/rechargeDetail/index.wxss */
.operate {
margin-top: 60rpx;
margin-left: 36rpx;
margin-right: 36rpx;
padding-bottom: 50rpx;
}

View File

@ -1,4 +1,5 @@
import { getRechargeList } from "../../service/recharge"; import { getRechargeList } from "../../service/recharge";
import { getOwnTenementList } from "../../service/tenement";
import { getYears } from "../../utils/index"; import { getYears } from "../../utils/index";
// pages/rechargeRecord/index.js // pages/rechargeRecord/index.js
@ -13,9 +14,30 @@ Page({
years: getYears(), years: getYears(),
list: [ 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) { onChangeYear(e) {
const { years } = this.data; const { years, tenement } = this.data;
const currentYear = years[Number(e.detail.value)] const currentYear = years[Number(e)]
this.setData({ this.setData({
year: currentYear year: currentYear,
type: "",
show: false,
title: ""
}) })
this.init(currentYear) this.init(currentYear, tenement)
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
const currentYear = this.data.year; const { year, tenement } = this.data;
this.init(currentYear) this.init(year, tenement)
}, },
async init(year) { async getTenementsList() {
const { code, message, data } = await getRechargeList(year); const { code, message, data } = await getOwnTenementList()
this.setData({ if (code !== OK) {
list: data 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 })
}, },
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏

View File

@ -1,7 +1,10 @@
{ {
"usingComponents": { "usingComponents": {
"navigator": "/components/navigator/index", "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"
} }

View File

@ -1,20 +1,35 @@
<!--pages/rechargeRecord/index.wxml--> <!--pages/rechargeRecord/index.wxml-->
<view class="wrapper" list-item> <navigator title="缴费记录" canBack="{{true}}" bind:back="back" />
<view> <view class="chooseWrapper">
<picker bindchange="onChangeYear" value="{{index}}" range="{{years}}"> <!-- <picker bindchange="onChangeYear" value="{{index}}" range="{{years}}"> -->
<view class="yearPicker"> <view class="yearPicker" bind:tap="clickYear">
{{ year }}年 {{ year }}年
<image src="/assets/images/down.png" mode="" class="down" /> <image src="/assets/images/down.png" mode="" class="down" />
</view> </view>
</picker> <!-- </picker> -->
<picker bindchange="onChangeYear" value="{{index}}" range="{{years}}">
<view class="tenementPicker">
<view wx:if="{{tenementName}}" class="tenementName"> {{ tenementName }} </view>
<view wx:else> 全部 </view>
<image src="/assets/images/down.png" mode="" class="down" />
</view>
</picker>
<view class="allMoney">
合计: 3000元
</view> </view>
</view>
<view class="wrapper">
<view class="recordsWrapper"> <view class="recordsWrapper">
<view class="recordsItem border" wx:for="{{list}}" wx:key="index"> <view class="recordsItem border" wx:for="{{list}}" wx:key="index" bind:tap="jumpToDetail" data-id="{{item.id}}">
<view class="type"> 充值 </view>
<view class="codeTime"> <view class="codeTime">
<view class="code"> 表号:{{ item.meter.code }} </view> <view class="code"> {{ item.meter.address }} </view>
<view class="time"> {{ item.time }} </view> <view class="time"> {{ item.time }} </view>
</view> </view>
<view class="money"> {{ item.money }} </view> <view class="money"> {{ item.money }}元 </view>
<van-icon name="arrow" />
</view> </view>
</view> </view>
</view> </view>
<custom-picker title="{{title}}" show="{{show}}" valueKey="name" columns="{{columns}}" bind:ok="onOk" bind:cancel="onCancel" type="{{type}}" />

View File

@ -1,4 +1,5 @@
/* pages/rechargeRecord/index.wxss */ /* pages/rechargeRecord/index.wxss */
.yearPicker { .yearPicker {
display: flex; display: flex;
align-items: center; align-items: center;
@ -20,11 +21,12 @@
} }
.recordsItem { .recordsItem {
display: flex; display: flex;
justify-content: space-between; /* justify-content: space-between; */
padding: 16rpx 20rpx; padding: 16rpx 20rpx;
border-left: 0; border-left: 0;
border-right: 0; border-right: 0;
border-top: 0; border-top: 0;
align-items: center;
} }
.recordsItem:last-child { .recordsItem:last-child {
border-bottom: 0; border-bottom: 0;
@ -39,10 +41,49 @@
.money { .money {
font-size: 42rpx; font-size: 42rpx;
font-weight: 600; font-weight: 600;
margin-right: 30rpx;
} }
.wrapper { .wrapper {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
flex: 1; 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;
} }

View File

@ -2,7 +2,7 @@
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "electricity_bill_calc_wx", "projectname": "electricity_bill_calc_wx",
"setting": { "setting": {
"compileHotReLoad": true, "compileHotReLoad": false,
"urlCheck": false, "urlCheck": false,
"skylineRenderEnable": true "skylineRenderEnable": true
}, },

View File

@ -9,4 +9,9 @@ export const getMeterList = async function() {
// 获取表计详情 // 获取表计详情
export const getMeterDetail = async function({ tenement, code }) { export const getMeterDetail = async function({ tenement, code }) {
return await GET(`/wx/getMeterDetail/${tenement}/${code}`); return await GET(`/wx/getMeterDetail/${tenement}/${code}`);
}
// 获取某一商户的电表列表
export const getTenementMeterList = async function(tid) {
return await GET(`/wx/getMeterList/${tid}`);
} }

View File

@ -2,8 +2,8 @@ import apis from '../utils/request';
const { GET, POST, PUT, DELETE } = apis const { GET, POST, PUT, DELETE } = apis
// 获取充值记录 // 获取充值记录
export const getRechargeList = async function(year) { export const getRechargeList = async function(year, tenement) {
return await GET(`/wx/getRechargeList?year=${year}`); return await GET(`/wx/getRechargeList?year=${year}&tenement=${tenement}`);
} }
// 预备充值请求 // 预备充值请求

9
utils/data.js Normal file
View File

@ -0,0 +1,9 @@
export const getRechargeOperateType = (num) => {
const types = ["充值", "冲正", "退费"]
return types[num];
}
export const getRechargeOperateWay = (num) => {
const types = ["现金", "银行卡", "支付宝", "微信", "云闪付"]
return types[num];
}

View File

@ -43,8 +43,8 @@ export function getConfigByEnv() {
switch (envVersion) { switch (envVersion) {
// 开发版 // 开发版
case 'develop': case 'develop':
api = "http://localhost:8000" // api = "http://localhost:8000"
// api = "http://127.0.0.1:4523/m1/4143821-0-default" api = "http://127.0.0.1:4523/m1/4143821-0-default"
break; break;
// 体验版 // 体验版
case 'trial': case 'trial':
@ -52,6 +52,7 @@ export function getConfigByEnv() {
break; break;
// 正式版 // 正式版
case 'release': case 'release':
api = "https://zgd.hbhcbn.com/wxApi"
break; break;
} }
return { api, } return { api, }
@ -105,9 +106,9 @@ export function showModal({
export function getYears() { export function getYears() {
const years = []; const years = [];
const currentYear = new Date().getFullYear(); const currentYear = new Date().getFullYear();
const minYear = 2023; const minYear = 2024;
for(let i = currentYear; i >= minYear; i--) { for(let i = currentYear; i >= minYear; i--) {
years.push(i); years.push({name: i, id: i});
} }
return years; return years;
} }

View File

@ -34,10 +34,10 @@ const request = async function (options, config = {}) {
try { try {
response = await requestWithoutCookie(options); response = await requestWithoutCookie(options);
// 服务器没有返回200直接报错 // 服务器没有返回200直接报错
if (!response || response.statusCode !== 200) { // if (!response || response.statusCode !== 200) {
alertError(response?.data?.message || "发生错误,请稍后重试") // alertError(response?.data?.message || "发生错误,请稍后重试")
return; // return;
} // }
// 处理cookie // 处理cookie
const setCookie = response.header['set-cookie'] || response.header['Set-Cookie']; const setCookie = response.header['set-cookie'] || response.header['Set-Cookie'];
@ -82,7 +82,7 @@ const parseResponse = function (response) {
alertError("服务异常") alertError("服务异常")
return return
} }
const { code: statusCode } = response; const { statusCode } = response;
if (statusCode === 401) { if (statusCode === 401) {
wx.redirectTo({ wx.redirectTo({
url: '/pages/login/index', url: '/pages/login/index',
@ -95,10 +95,6 @@ const parseResponse = function (response) {
if (500 <= statusCode && statusCode < 600) { if (500 <= statusCode && statusCode < 600) {
return { code: 500, message: "服务错误" } return { code: 500, message: "服务错误" }
} }
if (response.data.code !== 200) {
}
return response.data; return response.data;
} }
@ -106,7 +102,8 @@ const parseResponse = function (response) {
const GET = async function (uri) { const GET = async function (uri) {
const response = await request({ const response = await request({
url: `${SERVER}${uri}`, url: `${SERVER}${uri}`,
method: 'GET' method: 'GET',
}); });
return parseResponse(response); return parseResponse(response);