开始做充值和发票

This commit is contained in:
qiaomu 2024-03-20 11:10:52 +08:00
parent e5c9a96353
commit 7648ace524
59 changed files with 1091 additions and 199 deletions

View File

@ -1,13 +1,17 @@
{
"pages": [
"pages/login/index",
"pages/my/index",
"pages/recharge/index",
"pages/invoiceList/index",
"pages/rechargeRecord/index",
"pages/questions/index",
"pages/meterList/index",
"pages/recharge/index",
"pages/login/index",
"pages/handleLogin/index",
"pages/member/index",
"pages/my/index",
"pages/questions/index",
"pages/home/index",
"pages/index/index"
"pages/index/index",
"pages/qrCode/index"
],
"tabBar": {
"list": [
@ -27,8 +31,6 @@
"navigationBarBackgroundColor": "#ffffff"
},
"sitemapLocation": "sitemap.json",
"rendererOptions": {
},
"rendererOptions": {},
"navigationStyle": "custom"
}

View File

@ -17,5 +17,13 @@ page {
page {
font-size: 36rpx;
background-color: #f0f0f0;
/* background-color: #f0f0f0; */
}
.primaryTextBtn {
color: #1989fa;
}
.dangerTextBtn {
color: #ee0a24;
}

BIN
assets/images/logo-l.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

BIN
assets/images/logo.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -1,3 +1,8 @@
import { getParkList } from "../../service/park";
import { getTenementList } from "../../service/tenement";
import request from '../../utils/request'
const { OK } = request
// components/select/index.js
Component({
@ -5,7 +10,11 @@ Component({
* 组件的属性列表
*/
properties: {
label: String,
type: Number,
park: String,
parkName: String,
required: Boolean
},
/**
@ -13,19 +22,39 @@ Component({
*/
data: {
list: [],
visible: false
visible: false,
},
/**
* 组件的方法列表
*/
methods: {
onInput(e) {
console.log('e', e)
this.setData({
visible: true,
list: [e.detail, e.detail, e.detail]
})
async onInput(e) {
console.log('this.type', this.data.type)
// this.setData({
// visible: true,
// list: [e.detail, e.detail, e.detail]
// })
switch(this.data.type) {
case 0:
const { data = [], code, message } = await getParkList({ keyword: e.detail });
this.setData({
list: data,
visible: true,
})
break;
case 1:
const park = this.data.park;
if (!park) {
return;
}
const { data: tenementData = [], code: tenementCode, message: tenementMessage } = await getTenementList({ park, keyword: e.detail });
this.setData({
list: tenementData,
visible: true,
})
break;
}
},
close() {
this.setData({
@ -35,11 +64,11 @@ Component({
},
onChoose(e) {
const { data = {} } = e.currentTarget.dataset;
console.log('data', data)
this.setData({
visible: false
visible: false,
value: data.name
})
this.triggerEvent("choose", data)
}
this.triggerEvent("choose", {type: this.data.type, data})
},
}
})

View File

@ -2,16 +2,16 @@
<view class="content">
<van-field
value="{{ value }}"
placeholder="请输入用户名"
placeholder="{{'请选择' + label}}"
border="{{ false }}"
label="用户名"
label="{{label}}"
custom-style="height:100rpx"
bind:change="onChange"
bind:input="onInput"
required="{{required}}"
/>
<view class="modal" wx:if="{{visible}}">
<view class="options" >
<view wx:for="{{list}}" class="option" bind:tap="onChoose" data-data="{{item}}">{{item}}</view>
<view class="options">
<view wx:for="{{list}}" class="option" bind:tap="onChoose" data-data="{{item}}" wx:key="id">{{item.name}}</view>
</view>
<view class="other" bind:tap="close"></view>
</view>

View File

@ -8,7 +8,13 @@
background-color: #fff;
padding: 20rpx;
margin-left: 32rpx;
margin-right: 32rpx;
width: 100%;
border: 1rpx solid #ccc;
border-radius: 5rpx;
box-sizing: border-box;
width: calc(100% - 64rpx);
}
.option {

View File

@ -0,0 +1,24 @@
// components/topbar/index.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})

View File

@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"van-image": "@vant/weapp/image/index"
}
}

View File

@ -0,0 +1,5 @@
<!--components/topbar/index.wxml-->
<view class="wrapper">
<van-image width="100rpx" height="100rpx" src="/assets/images/logo-l.png" />
<view class="content"> 华昌宝能用电管理服务 </view>
</view>

View File

@ -0,0 +1,12 @@
/* components/topbar/index.wxss */
.wrapper {
padding: 12rpx 32rpx;
display: flex;
align-items: center;
}
.content {
margin-left: 50rpx;
}

138
pages/handleLogin/index.js Normal file
View File

@ -0,0 +1,138 @@
import { userValidate } from "../../service/user";
import { alertInfo, alertSuccess, loadingFunc, wxLogin } from "../../utils/index";
import request from "../../utils/request"
const { OK } = request;
// pages/handleLogin/index.js
Page({
/**
* 页面的初始数据
*/
data: {
phone: "",
name: "",
parkName: "",
park: "",
tenementName: "",
tenement: ""
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
onChangeName(e) {
this.setData({
name: e.detail
})
},
onChangePhone(e) {
this.setData({
phone: e.detail
})
},
onChoosePark(e) {
const { data } = e.detail;
this.setData({
park: data.id,
parkName: data.name
})
},
onChooseTenement(e) {
const { data } = e.detail;
this.setData({
tenement: data.id,
tenementName: data.name
})
},
handleSubmit() {
const { park, tenement, name, phone } = this.data;
if (!park) {
alertInfo("请选择园区")
return
}
if (!tenement) {
alertInfo("请选择商户")
return
}
if (!phone) {
alertInfo("请输入联系人手机号")
return
}
if (!name) {
alertInfo("请输入你的昵称")
return
}
loadingFunc(async () => {
const wxLoginCode = await wxLogin()
const { code, message, data } = await userValidate({ park, tenement, phone, name, code: wxLoginCode })
// if (code !== OK) {
// alertInfo(message)
// return
// }
const { exist, user } = data;
if (!exist) {
alertInfo("绑定失败,请检查信息")
return
}
alertSuccess("绑定成功")
const { token, ...currentUser } = user;
wx.setStorageSync('user', currentUser)
wx.setStorageSync('token', token)
wx.switchTab({
url: '/pages/home/index',
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

View File

@ -0,0 +1,9 @@
{
"usingComponents": {
"topbar": "/components/topbar/index",
"select": "/components/select/index",
"van-button": "@vant/weapp/button/index",
"van-field": "@vant/weapp/field/index"
},
"navigationBarTitleText": "手动绑定"
}

View File

@ -0,0 +1,25 @@
<!--pages/handleLogin/index.wxml-->
<topbar />
<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="{{ false }}"
bind:change="onChangePhone"
/>
<van-field
required
value="{{ name }}"
label="你的昵称"
placeholder="请输入你的昵称"
border="{{ false }}"
bind:change="onChangeName"
/>
<view class="submit">
<van-button type="info" block bind:click="handleSubmit"> 提交 </van-button>
</view>
</view>

View File

@ -0,0 +1,5 @@
/* pages/handleLogin/index.wxss */
.submit {
margin-top: 40rpx;
padding: 0 32rpx;
}

View File

@ -1,2 +1,2 @@
<!--pages/home/index.wxml-->
111111111111111
首页

View File

@ -9,13 +9,13 @@ Page({
staffC: {firstName: 'Gideon', lastName: 'Lin'}
},
onLoad() {
console.log('---', this.renderer)
},
onShow() {
},
test: throttle(function() {
console.log('test', this.data.motto)
}, 500),
payment: function() {
wx.requestPayment({

View File

@ -0,0 +1,66 @@
// pages/invoiceList/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

View File

@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "开票信息"
}

View File

@ -0,0 +1,2 @@
<!--pages/invoiceList/index.wxml-->
<text>pages/invoiceList/index.wxml</text>

View File

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

View File

@ -1,6 +1,9 @@
import { login } from "../../service/user"
import { alertError, alertInfo, loadingFunc, wxLogin } from "../../utils/index"
import { OK } from "../../utils/request"
import { login } from "../../service/user";
import { alertError, alertInfo, alertSuccess, loadingFunc, wxLogin } from "../../utils/index";
import request from "../../utils/request";
import Dialog from '@vant/weapp/dialog/dialog';
const { OK } = request;
// pages/login/index.js
Page({
@ -8,14 +11,22 @@ Page({
* 页面的初始数据
*/
data: {
input: ""
input: "",
disabled: false,
show: false,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
onLoad() {
const user = wx.getStorageSync('user')
if (!user || !user.id) {
return;
}
wx.switchTab({
url: '/pages/home/index',
})
},
/**
@ -27,40 +38,67 @@ Page({
onClose() {
// wx.exitMiniProgram()
},
// onConfirm() {
// this.handleLogin()
// },
onConfirm() {
// this.handleLogin()
},
async handleLogin(phoneCode) {
loadingFunc(async () => {
const wxLoginCode = await wxLogin()
const { code, message, data } = await login({ code: wxLoginCode, phoneCode })
const result = await login({ code: wxLoginCode, phoneCode })
const { code, message, data } = result;
if (code !== OK) {
alertError(message)
return
}
console.log('data', data)
if (!data?.id) {
this.noPermission()
return;
}
alertSuccess("登录成功")
const { token, ...user } = data
wx.setStorageSync('user', user)
wx.setStorageSync('token', data?.token)
})
},
getPhoneNumber(e) {
const { errno, code: phoneCode } = e.detail;
console.log('errno', errno, 'phoneCode', phoneCode)
switch(errno) {
case 103:
alertInfo("已拒绝");
setTimeout(() => {
wx.exitMiniProgram()
}, 100)
return;
break;
case 1400001:
alertInfo("服务达到上限")
setTimeout(() => {
wx.exitMiniProgram()
}, 100)
return;
break;
default:
this.handleLogin(phoneCode)
return;
}
this.handleLogin(phoneCode)
},
onChangeAgree(e) {
this.setData({
agree: e.detail
})
},
beforeClose(e) {
return false;
},
noPermission() {
Dialog.confirm({
title: '提示',
message: '当前手机号不是用电管理联系账号',
confirmButtonText: '手动绑定',
cancelButtonText: '取消',
})
.then(() => {
// on confirm
wx.navigateTo({
url: '/pages/handleLogin/index',
})
})
.catch(() => {
// on cancel
});
},
/**
* 生命周期函数--监听页面显示

View File

@ -1,6 +1,11 @@
{
"usingComponents": {
"van-dialog": "@vant/weapp/dialog/index",
"select": "/components/select/index"
}
"select": "/components/select/index",
"topbar": "/components/topbar/index",
"van-image": "@vant/weapp/image/index",
"van-button": "@vant/weapp/button/index",
"van-checkbox": "@vant/weapp/checkbox/index"
},
"navigationBarTitleText": ""
}

View File

@ -1,19 +1,20 @@
<!--pages/login/index.wxml-->
<topbar />
<view class="content">
<van-dialog
use-slot
title="提示"
show="{{ true }}"
show-cancel-button
bind:close="onClose"
bind:confirm="onConfirm"
confirm-button-open-type="getPhoneNumber"
bind:getphonenumber="getPhoneNumber"
>
<view class="confirmWrapper">
<view class="logo">
<van-image width="200rpx" height="200rpx" src="/assets/images/logo-l.png" />
</view>
<view class="logoBtn">
<van-button type="info" block disabled="{{!agree}}" open-type="getPhoneNumber" bind:getphonenumber="getPhoneNumber">手机号快速登录</van-button>
</view>
<view class="agreement">
<view class="checkbox">
<van-checkbox value="{{ agree }}" bind:change="onChangeAgree"></van-checkbox>
</view>
<view>
使用本系统,代表您已阅读并同意 <text class="agreementText">《用电管理服务条款》</text>、<text class="agreementText">《用电管理登录政策》</text><text class="agreementText">《隐私政策》</text>。
</view>
</van-dialog>
<!-- <select />
<select /> -->
</view>
</view>
</view>
<van-dialog id="van-dialog" />

View File

@ -1,15 +1,7 @@
/* pages/login/index.wxss */
.content {
/* width: 600rpx;
height: 500rpx;
page {
background-color: #fff;
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
padding: 20rpx 24rpx; */
}
.confirmWrapper {
@ -18,4 +10,25 @@
.agreementText {
color: rgb(211, 155, 52);
}
.logo {
display: flex;
justify-content: center;
margin-top: 15vh;
margin-bottom: 15vh;
}
.content {
margin-left: 32rpx;
margin-right: 32rpx;
}
.agreement {
margin-top: 32rpx;
display: flex;
}
.checkbox {
margin-top: 6rpx;
}

View File

@ -0,0 +1,64 @@
import { approveUser, getApproveList } from "../../../../service/user"
import { alertInfo, alertSuccess, wxModal } from "../../../../utils/index";
import request from "../../../../utils/request"
const { OK } = request;
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
list: []
},
lifetimes: {
attached: function() {
// this.setData({
// list: []
// })
this.init();
}
},
/**
* 组件的方法列表
*/
methods: {
async init() {
const result = await getApproveList()
this.setData({
list: result.data
})
},
async agree(e) {
const { user } = e.currentTarget.dataset;
console.log('user', user)
await wxModal({ content: `同意${user.nickName}的申请?` })
const { code, message } = await approveUser({ userId: user.id, type: 1 })
if (code !== OK) {
alertInfo(message)
return;
}
alertSuccess("已同意")
this.init()
},
async disAgree(e) {
const { user } = e.currentTarget.dataset;
await wxModal({ content: `拒绝${user.nickName}的申请?` })
const { code, message } = await approveUser({ userId: user.id, type: 0 })
if (code !== OK) {
alertInfo(message)
return;
}
alertSuccess("已拒绝")
this.init()
}
}
})

View File

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

View File

@ -0,0 +1,8 @@
<!--pages/member/components/approveMember/index.wxml-->
<view wx:for="{{list}}" wx:key="index" wx:for-item="item" class="item">
<view class="nickName"> {{ item.nickName }} </view>
<view class="operate">
<view class="primaryTextBtn" data-user="{{item}}" bind:tap="agree"> 同意 </view>
<view class="disAgree dangerTextBtn" data-user="{{item}}" bind:tap="disAgree"> 拒绝 </view>
</view>
</view>

View File

@ -0,0 +1,21 @@
/* pages/member/components/approveMember/index.wxss */
.item {
display: flex;
align-items: center;
padding-top: 24rpx;
padding-bottom: 24rpx;
margin-left: 32rpx;
margin-right: 32rpx;
}
.nickName {
flex: 1;
}
.operate {
display: flex;
}
.disAgree {
margin-left: 24rpx;
}

View File

@ -0,0 +1,65 @@
import { approveUser, getApproveList } from "../../../../service/user"
import { alertInfo, alertSuccess, wxModal } from "../../../../utils/index";
import request from "../../../../utils/request"
const { OK } = request;
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
list: []
},
lifetimes: {
attached: function() {
// this.setData({
// list: []
// })
this.init();
}
},
/**
* 组件的方法列表
*/
methods: {
async init() {
const result = await getApproveList()
this.setData({
list: result.data
})
},
async setAdmin(e) {
const { user } = e.currentTarget.dataset;
console.log('user', user)
await wxModal({ content: `你的管理员身份将转交给${user.nickName}` })
const { code, message } = await approveUser({ userId: user.id, type: 2 })
if (code !== OK) {
alertInfo(message)
return;
}
alertSuccess("转交成功")
wx.clearStorageSync()
wx.exitMiniProgram()
},
async disAgree(e) {
const { user } = e.currentTarget.dataset;
await wxModal({ content: `拒绝${user.nickName}的申请?` })
const { code, message } = await approveUser({ userId: user.id, type: 0 })
if (code !== OK) {
alertInfo(message)
return;
}
alertSuccess("已拒绝")
this.init()
}
}
})

View File

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

View File

@ -0,0 +1,8 @@
<!--pages/member/components/memberManage/index.wxml-->
<view wx:for="{{list}}" wx:key="index" wx:for-item="item" class="item">
<view class="nickName"> {{ item.nickName }} </view>
<view class="operate">
<view class="primaryTextBtn" data-user="{{item}}" bind:tap="setAdmin"> 设为管理员 </view>
<view class="disAgree dangerTextBtn" data-user="{{item}}" bind:tap="remove"> 移除 </view>
</view>
</view>

View File

@ -0,0 +1,21 @@
.item {
display: flex;
align-items: center;
padding-top: 24rpx;
padding-bottom: 24rpx;
margin-left: 32rpx;
margin-right: 32rpx;
}
.nickName {
flex: 1;
}
.operate {
display: flex;
}
.disAgree {
margin-left: 24rpx;
}

70
pages/member/index.js Normal file
View File

@ -0,0 +1,70 @@
// pages/member/index.js
Page({
/**
* 页面的初始数据
*/
data: {
active: 0
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
onChangeTab(e) {
this.setData({
active: e.detail.index
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

8
pages/member/index.json Normal file
View File

@ -0,0 +1,8 @@
{
"usingComponents": {
"van-tab": "@vant/weapp/tab/index",
"van-tabs": "@vant/weapp/tabs/index",
"approve-member": "./components/approveMember/index",
"member-manage": "./components/memberManage/index"
}
}

9
pages/member/index.wxml Normal file
View File

@ -0,0 +1,9 @@
<!--pages/member/index.wxml-->
<van-tabs active="{{ active }}" bind:change="onChangeTab">
<van-tab title="申请人员">
<approve-member />
</van-tab>
<van-tab title="人员管理">
<member-manage />
</van-tab>
</van-tabs>

1
pages/member/index.wxss Normal file
View File

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

View File

@ -1,3 +1,5 @@
import { getMeterList } from "../../service/meter";
// pages/meterList/index.js
Page({
@ -5,11 +7,7 @@ Page({
* 页面的初始数据
*/
data: {
codes: [
{ code: "2331242324", money: 510 },
{ code: "4234234134", money: 10 },
{ code: "2354245345", money: 50 },
{ code: "5365457642", money: 150 },
list: [
]
},
@ -18,9 +16,20 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getList();
},
async getList() {
const { code, message, data = [] } = await getMeterList()
this.setData({
list: data
})
},
jumpToRecharge(e) {
const { code, tenement } = e.currentTarget.dataset;
wx.navigateTo({
url: `/pages/recharge/index?code=${code}&tenement=${tenement}`,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/

View File

@ -2,5 +2,6 @@
"usingComponents": {
"navigator": "/components/navigator/index",
"scrollPageWrapper": "/components/scrollPageWrapper/index"
}
},
"navigationBarTitleText": "表计列表"
}

View File

@ -1,12 +1,24 @@
<!--pages/meterList/index.wxml-->
<scrollPageWrapper>
<navigator title="表计列表" />
<view class="content">
<scroll-view type="list" scroll-y style="display: flex; flex-direction: column; flex: 1; width: 100%; overflow: auto;">
<view wx:for="{{codes}}" list-item class="listItem">
<view class="code"> {{ item.code }} </view>
<view class="money"> {{ item.money }} </view>
<view class="wrapper">
<view wx:for="{{list}}" wx:key="index" class="listItem">
<view class="tenementName"> {{ item.tenement.name }} :</view>
<view class="meter" wx:for="{{item.meter}}" wx:for-item="ele" wx:key="code">
<view class="content">
<view class="code"> 表{{ ele.code }}:余额为 </view>
<view class="money"> {{ ele.money }} </view>
<view
class="primaryTextBtn"
bind:tap="jumpToRecharge"
data-tenement="{{item.tenement.id}}"
data-code="{{ele.code}}"
> 充值 </view>
</view>
</scroll-view>
<view class="address">
表计地址: {{ ele.address }}
</view>
</view>
</view>
</scrollPageWrapper>
</view>

View File

@ -1,20 +1,40 @@
/* pages/meterList/index.wxss */
.content {
/* .content {
flex: 1;
padding: 16rpx 24rpx 20rpx;
box-sizing: border-box;
display: flex;
overflow: hidden;
}
} */
.listItem {
display: flex;
/* display: flex;
align-items: center;
justify-content: space-between;
justify-content: space-between; */
margin: 12rpx 0;
}
.money {
font-size: 36rpx;
font-weight: 600;
margin-left: 20rpx;
flex: 1;
}
.content {
display: flex;
align-items: center;
margin-left: 30rpx;
margin-right: 20rpx;
}
.address {
margin-left: 30rpx;
margin-right: 20rpx;
}
.tenementName {
font-size: 42rpx;
font-weight: 600;
margin-bottom: 20rpx;
}

View File

@ -26,6 +26,16 @@ Page({
url: '/pages/questions/index',
})
},
jumpToMember() {
wx.navigateTo({
url: '/pages/member/index',
})
},
jumpToQrCode() {
wx.navigateTo({
url: '/pages/qrCode/index',
})
},
/**
* 生命周期函数--监听页面显示
*/

View File

@ -3,9 +3,10 @@
<!-- <cell open-type="contact" title="联系客服" borderBottom="{{true}}" />
<cell title="常见问题" bind:click="jumpToQuestions" /> -->
<van-cell-group title=" ">
<!-- <van-cell-group title=" "> -->
<van-cell title="二维码" value="" is-link bind:click="jumpToQrCode" />
<van-cell title="成员管理" value="" is-link bind:click="jumpToMember" />
<!-- </van-cell-group> -->
<!-- <van-cell-group title=" ">
<van-cell title="单元格" value="内容" is-link />
</van-cell-group>
<van-cell-group title=" ">
<van-cell title="单元格" value="内容" is-link />
</van-cell-group>
</van-cell-group> -->

66
pages/qrCode/index.js Normal file
View File

@ -0,0 +1,66 @@
// pages/qrCode/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

3
pages/qrCode/index.json Normal file
View File

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

5
pages/qrCode/index.wxml Normal file
View File

@ -0,0 +1,5 @@
<!--pages/qrCode/index.wxml-->
<view class="wrapper">
<view class="text"> 扫码二维码,管理员同意后可进入 </view>
<van-icon name="qr" />
</view>

13
pages/qrCode/index.wxss Normal file
View File

@ -0,0 +1,13 @@
/* pages/qrCode/index.wxss */
.wrapper {
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.text {
text-align: center;
margin-bottom: 10vh;
}

View File

@ -1,3 +1,4 @@
import { getMeterDetail } from "../../service/meter";
import { getGlobalData, showModal } from "../../utils/index";
// pages/recharge/index.js
@ -7,22 +8,29 @@ Page({
* 页面的初始数据
*/
data: {
code: "",
money: 0,
moneyIndex: -1,
primaryColor: getGlobalData().primaryColor,
codes: ['105465640', '46845132', '1645468'],
defaultMoneyArray: [100, 200, 500, 1000, 2000],
customFlag: false,
detail: {}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const { tenement, code } = options
console.log('options', options)
this.init({ tenement, code })
},
async init(options) {
const { code, message, data = {}} = await getMeterDetail(options)
console.log('data', data)
this.setData({
detail: data
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
@ -38,7 +46,6 @@ Page({
},
chooseMoney(e) {
const { money, index } = e.currentTarget.dataset;
console.log('index', index, typeof index)
this.setData({
money,
moneyIndex: Number(index),
@ -59,19 +66,17 @@ Page({
})
},
onChangeCustomMoney(e) {
console.log('onChangeCustomMoney', e)
const money = e.detail.value;
this.setData({
money: money,
})
},
async recharge() {
const { code, money } = this.data;
const confirmResult = await showModal({ title: "充值确认", content: `确认充值表号为${code}的表计${money}元吗?` });
const { detail = {}, money } = this.data;
const confirmResult = await showModal({ title: "充值确认", content: `确认充值表号为${detail?.meter?.code}的表计${money}元吗?` });
if (!confirmResult) {
return;
}
console.log('确认')
},
/**
* 生命周期函数--监听页面隐藏

View File

@ -1,5 +1,10 @@
{
"usingComponents": {
"navigator": "/components/navigator/index"
}
"navigator": "/components/navigator/index",
"van-grid": "@vant/weapp/grid/index",
"van-grid-item": "@vant/weapp/grid-item/index",
"van-row": "@vant/weapp/row/index",
"van-col": "@vant/weapp/col/index"
},
"navigationBarTitleText": "充值"
}

View File

@ -1,42 +1,76 @@
<!--pages/recharge/index.wxml-->
<navigator title="充值" />
<view class="wrapper">
<!-- 账单周期 T13561356146548465815313 创新风华 -->
<view style="display: flex;align-items: center;font-size: 24rpx;">
<view style="margin-right: 20rpx;">
<view> 电费账单 </view>
<view> 2024年02月 </view>
</view>
<view style="flex: 1;display: flex;">
<view style="margin-right: 20rpx;">
<view>商户编号</view>
<view> T00062102047096834 </view> </view>
<view>
<!-- <van-grid column-num="2" center="{{false}}">
<van-grid-item icon="photo-o" text="文字" use-slot>
<view>
商户名称
<view class="gridTitle"> 充值表号: </view>
<view class="gridContent"> {{ detail.meter.code }} </view>
</view>
</van-grid-item>
<van-grid-item icon="photo-o" text="文字" use-slot>
<view>
创新风华</view>
</view>
</view>
</view>
<!-- <view class="chooseMeter">
充值表号
<view class="selectMeter">
<picker bindchange="onChangeCode" value="{{index}}" range="{{codes}}">
<view class="picker">
<view class="input border" wx:if="{{code}}">{{code}}</view>
<view class="input border" style="color: rgb(116, 109, 109)" wx:else>请选择</view>
</view>
</picker>
</view>
</view>
<view class="gridTitle"> 表计地址: </view>
<view class="gridContent"> {{ detail.meter.address }} </view>
</view>
</van-grid-item>
<van-grid-item icon="photo-o" text="文字" use-slot>
<view>
<view class="gridTitle"> 剩余金额: </view>
<view class="gridContent"> {{ detail.money }} </view>
</view>
</van-grid-item>
<van-grid-item icon="photo-o" text="文字" use-slot>
<view>
<view class="gridTitle"> 公司名称: </view>
<view class="gridContent"> {{ detail.tenement.name }} </view>
</view>
</van-grid-item>
</van-grid> -->
<van-row gutter="10">
<van-col span="12">
<view class="title">充值表号:</view>
<view class="content">{{ detail.meter.code }}</view>
</van-col>
<van-col span="12">
<view class="title">表计地址:</view>
<view class="content">{{ detail.meter.address }}</view>
</van-col>
<van-col span="12" custom-class="colBottom">
<view class="title">剩余金额:</view>
<view class="content">{{ detail.money }}</view>
</van-col>
<van-col span="12" custom-class="colBottom">
<view class="title">公司名称:</view>
<view class="content">{{ detail.tenement.name }}</view>
</van-col>
</van-row>
<view class="moneyBoxs">
<view wx:for="{{defaultMoneyArray}}" class="moneyBox border radius12" style="background-color: {{moneyIndex === index ? primaryColor : ''}};" bind:tap="chooseMoney" data-money="{{item}}" data-index="{{index}}"> {{item}} </view>
<view
wx:for="{{defaultMoneyArray}}"
class="moneyBox border radius12"
style="background-color: {{moneyIndex === index ? primaryColor : ''}};"
wx:key="index"
bind:tap="chooseMoney"
data-money="{{item}}"
data-index="{{index}}"
> {{item}} </view>
<view class="moneyBox border radius12" bind:tap="custom"> 自定义 </view>
</view>
<view class="customInput border radius12" wx:if="{{customFlag}}" > <input type="number" focus placeholder="请输入要充值的金额" bindinput="onChangeCustomMoney"/> </view>
<view
class="customInput border radius12"
wx:if="{{customFlag}}"
>
<input
type="number"
focus
placeholder="请输入要充值的金额"
bindinput="onChangeCustomMoney"
/>
</view>
<view class="operate">
<button type="primary" bind:tap="recharge" disabled="{{!code || !money}}"> 充值 </button>
</view> -->
<button type="primary" bind:tap="recharge" disabled="{{!money}}"> 充值 </button>
</view>
</view>

View File

@ -41,4 +41,22 @@
.customInput {
padding: 16rpx 24rpx;
}
.gridTitle {
margin-bottom: 24rpx;
}
.colBottom {
margin-top: 40rpx;
}
.title {
font-weight: 600;
font-size: 40rpx;
margin-bottom: 20rpx;
}
.content {
font-size: 32rpx;
}

View File

@ -1,3 +1,4 @@
import { getRechargeList } from "../../service/recharge";
import { getYears } from "../../utils/index";
// pages/rechargeRecord/index.js
@ -11,22 +12,7 @@ Page({
month: new Date().getMonth() + 1,
years: getYears(),
list: [
{ code: '165146513', money: 100, time: "2024-02-20 18:56:15" },
{ code: '466541651', money: 200, time: "2024-02-28 18:56:15" },
{ code: '165146513', money: 100, time: "2024-02-20 18:56:15" },
{ code: '466541651', money: 200, time: "2024-02-28 18:56:15" },
{ code: '165146513', money: 100, time: "2024-02-20 18:56:15" },
{ code: '466541651', money: 200, time: "2024-02-28 18:56:15" },
{ code: '165146513', money: 100, time: "2024-02-20 18:56:15" },
{ code: '466541651', money: 200, time: "2024-02-28 18:56:15" },
{ code: '165146513', money: 100, time: "2024-02-20 18:56:15" },
{ code: '466541651', money: 200, time: "2024-02-28 18:56:15" },
{ code: '165146513', money: 100, time: "2024-02-20 18:56:15" },
{ code: '466541651', money: 200, time: "2024-02-28 18:56:15" },
{ code: '165146513', money: 100, time: "2024-02-20 18:56:15" },
{ code: '466541651', money: 200, time: "2024-02-28 18:56:15" },
{ code: '165146513', money: 100, time: "2024-02-20 18:56:15" },
{ code: '466541651', money: 200, time: "2024-02-28 18:56:15" }
]
},
@ -45,17 +31,26 @@ Page({
},
onChangeYear(e) {
const { years } = this.data;
const currentYear = years[Number(e.detail.value)]
this.setData({
year: years[Number(e.detail.value)]
year: currentYear
})
this.init(currentYear)
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
const currentYear = this.data.year;
this.init(currentYear)
},
async init(year) {
const { code, message, data } = await getRechargeList(year);
console.log('data', data)
this.setData({
list: data
})
},
/**
* 生命周期函数--监听页面隐藏
*/

View File

@ -2,5 +2,6 @@
"usingComponents": {
"navigator": "/components/navigator/index",
"scrollPageWrapper": "/components/scrollPageWrapper/index"
}
},
"navigationBarTitleText": "充值记录"
}

View File

@ -1,25 +1,20 @@
<!--pages/rechargeRecord/index.wxml-->
<scrollPageWrapper>
<navigator title="充值记录" />
<scroll-view type="list" scroll-y style="display: flex; flex-direction: column; flex: 1; width: 100%; overflow: auto;">
<view class="wrapper" list-item>
<view>
<picker bindchange="onChangeYear" value="{{index}}" range="{{years}}">
<view class="yearPicker">
{{ year }}年
<image src="/assets/images/down.png" mode="" class="down" />
</view>
</picker>
<view class="wrapper" list-item>
<view>
<picker bindchange="onChangeYear" value="{{index}}" range="{{years}}">
<view class="yearPicker">
{{ year }}年
<image src="/assets/images/down.png" mode="" class="down" />
</view>
<view class="recordsWrapper">
<view class="recordsItem border" wx:for="{{list}}">
<view class="codeTime">
<view class="code"> 表号:{{ item.code }} </view>
<view class="time"> {{ item.time }} </view>
</view>
<view class="money"> {{ item.money }} </view>
</view>
</picker>
</view>
<view class="recordsWrapper">
<view class="recordsItem border" wx:for="{{list}}" wx:key="index">
<view class="codeTime">
<view class="code"> 表号:{{ item.meter.code }} </view>
<view class="time"> {{ item.time }} </view>
</view>
<view class="money"> {{ item.money }} </view>
</view>
</scroll-view>
</scrollPageWrapper>
</view>
</view>

View File

@ -7,6 +7,6 @@ export const getMeterList = async function() {
}
// 获取表计详情
export const getMeterDetail = async function() {
export const getMeterDetail = async function({ tenement, code }) {
return await GET(`/wx/getMeterDetail/${tenement}/${code}`);
}

View File

@ -2,6 +2,6 @@ import apis from '../utils/request';
const { GET, POST, PUT, DELETE } = apis
// 获取园区列表
export const getParkList = async function() {
return await GET(`/wx/getParkList`);
export const getParkList = async function({ keyword }) {
return await GET(`/wx/getParkList?keyword=${keyword}`);
}

View File

@ -2,6 +2,6 @@ import apis from '../utils/request';
const { GET, POST, PUT, DELETE } = apis
// 获取园区id模糊搜索商户列表
export const getParkList = async function({ park, keyword }) {
export const getTenementList = async function({ park, keyword }) {
return await GET(`/wx/getTenementList?park=${park}&keyword=${keyword}`);
}

View File

@ -43,7 +43,8 @@ export function getConfigByEnv() {
switch (envVersion) {
// 开发版
case 'develop':
api = "http://localhost:8000"
// api = "http://localhost:8000"
api = "http://127.0.0.1:4523/m1/4143821-0-default"
break;
// 体验版
case 'trial':
@ -195,4 +196,21 @@ export const wxLogin = () => {
}
})
})
}
export const wxModal = (data) => {
const { title = '提示', content } = data;
return new Promise((resolve, reject) => {
wx.showModal({
title,
content,
success (res) {
if (res.confirm) {
resolve()
} else if (res.cancel) {
reject()
}
}
})
})
}

View File

@ -85,19 +85,18 @@ const parseResponse = function (response) {
wx.redirectTo({
url: '/pages/login/index',
})
return { code: 1, message: '未登录状态' }
return { code: 401, message: '未登录状态' }
}
if (statusCode === 404) {
return { code: 1, message: "服务故障" }
return { code: 404, message: "服务故障" }
}
if (500 <= statusCode < 600) {
return { code: 1, message: "服务错误" }
if (500 <= statusCode && statusCode < 600) {
return { code: 500, message: "服务错误" }
}
if (response.data.code !== 0) {
if (response.data.code !== 200) {
}
return response.data;
}