接着做首页的充值,,调试接口

This commit is contained in:
2024-03-28 16:49:49 +08:00
parent 4713116996
commit c9abd2cfa0
15 changed files with 125 additions and 35 deletions

View File

@@ -1,3 +1,5 @@
import { alertInfo } from "../../utils/index";
// pages/home/index.js
Page({
@@ -5,15 +7,14 @@ Page({
* 页面的初始数据
*/
data: {
user: {}
user: {},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const user = wx.getStorageSync('user')
this.setData({ user })
},
/**
@@ -21,6 +22,23 @@ Page({
*/
onReady() {
},
changeMoney(e) {
const { money } = e.currentTarget.dataset;
this.setData({
money
})
},
onChangeMoney(e) {
console.log('e', e)
this.setData({ money: Number(e.detail) })
},
recharge() {
const { user, money } = this.data;
if (!user || !user.id) {
alertInfo("请先登录")
return
}
},
jumpToLogin() {
wx.navigateTo({
@@ -31,7 +49,8 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
const user = wx.getStorageSync('user')
this.setData({ user })
},
/**

View File

@@ -4,7 +4,8 @@
"van-icon": "@vant/weapp/icon/index",
"van-button": "@vant/weapp/button/index",
"van-image": "@vant/weapp/image/index",
"avatar": "/components/avatar/index"
"avatar": "/components/avatar/index",
"van-field": "@vant/weapp/field/index"
},
"navigationStyle": "custom"
}

View File

@@ -11,15 +11,19 @@
</view>
</view>
</view>
<custom-status-bar />
<view class="chooseParkWrapper">
</view>
<view class="login" wx:if="{{!user || !user.id}}" class="notLoginWrapper">
<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>
</view>
<view class="logined" wx:else>
<avatar text="11" />
<avatar text="{{ user.tenement.name.slice(0,2) }}" />
<view>
<van-button type="info" size="small" plain="{{true}}" class="loginBtn" bind:tap="jumpToLogin">{{user.tenement.name}}</van-button>
<view></view>
<van-button type="info" size="small" plain="{{true}}" class="loginBtn" >{{user.tenement.name}} <van-icon name="arrow-down" style="margin-left: 16rpx;" /></van-button>
<view class="welcome"> 欢迎使用华昌宝能用电管理系统! </view>
</view>
</view>
<view class="rechargeWrapper">
@@ -56,11 +60,21 @@
</view>
<view class="recharge">
<view> 请输入金额: </view>
<view>
<view> ¥30 </view>
<view> ¥50 </view>
<view> ¥100 </view>
<view> ¥200 </view>
<view class="moneyBox">
<view class="money" bind:tap="changeMoney" data-money="30"> ¥30 </view>
<view class="money" bind:tap="changeMoney" data-money="50"> ¥50 </view>
<view class="money" bind:tap="changeMoney" data-money="100"> ¥100 </view>
<view class="money" style="margin-right: 0;" bind:tap="changeMoney" data-money="200"> ¥200 </view>
</view>
<view class="moneyInput">
<van-field
value="{{ money }}"
placeholder="请输入充值金额"
border="{{true}}"
bind:change="onChangeMoney"
size="large"
type="number"
/>
</view>
</view>
<view class="operate">

View File

@@ -3,6 +3,11 @@
.top {
background-color: var(--deep-green);
position: fixed;
left: 0;
top: 0;
width: 100vw;
z-index: 99;
}
.chooseParkWrapper {
@@ -94,4 +99,28 @@
.operate {
margin-left: 46rpx;
margin-right: 46rpx;
margin-bottom: 40rpx;
}
.welcome {
margin-top: 20rpx;
margin-left: 30rpx;
font-size: 32rpx;
color: #fff;
}
.moneyBox {
display: flex;
justify-content: space-between;
margin-top: 30rpx;
}
.money {
flex: 1;
padding: 16rpx;
display: flex;
justify-content: center;
align-items: center;
border: 1rpx solid #ccc;
margin-right: 30rpx;
}