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

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

View File

@ -1,12 +1,12 @@
{ {
"pages": [ "pages": [
"pages/home/index", "pages/home/index",
"pages/my/index",
"pages/handleLogin/index",
"pages/member/index", "pages/member/index",
"pages/login/index", "pages/login/index",
"pages/apply/index", "pages/apply/index",
"pages/qrCode/index", "pages/qrCode/index",
"pages/my/index",
"pages/handleLogin/index",
"pages/waitApprove/index", "pages/waitApprove/index",
"pages/rechargeRecord/index", "pages/rechargeRecord/index",
"pages/invoiceList/index", "pages/invoiceList/index",
@ -35,7 +35,7 @@
}, },
"window": { "window": {
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",
"navigationBarTitleText": "Weixin", "navigationBarTitleText": "华昌宝能用电管理",
"navigationBarBackgroundColor": "#ffffff" "navigationBarBackgroundColor": "#ffffff"
}, },
"sitemapLocation": "sitemap.json", "sitemapLocation": "sitemap.json",

View File

@ -8,7 +8,7 @@ page {
} }
.border { .border {
border: 1rpx solid #f0f0f0; border: 0.5rpx solid #f0f0f0;
} }
.radius12 { .radius12 {

View File

@ -1,7 +1,7 @@
/* components/avatar/index.wxss */ /* components/avatar/index.wxss */
.wrapper { .wrapper {
width: 100rpx; width: 150rpx;
height: 100rpx; height: 150rpx;
border-radius: 50%; border-radius: 50%;
background: radial-gradient(circle, var(--light-green), var(--middle-green),var(--deep-green) ); background: radial-gradient(circle, var(--light-green), var(--middle-green),var(--deep-green) );
display: flex; display: flex;

View File

@ -18,11 +18,11 @@
<view class="content"> <view class="content">
<template is="content" data="{{title, rightArrow}}" /> <template is="content" data="{{title, rightArrow}}" />
</view> </view>
<view class="borderBottom border" wx:if="{{borderBottom}}"></view> <view class="borderBottom" wx:if="{{borderBottom}}"></view>
</view> </view>
<view wx:else bind:tap="click"> <view wx:else bind:tap="click">
<button class="button" open-type="{{openType}}" plain="true"> <button class="button" open-type="{{openType}}" plain="true">
<template is="content" data="{{title, rightArrow}}" /> <template is="content" data="{{title, rightArrow}}" />
</button> </button>
<view class="borderBottom border" wx:if="{{borderBottom}}"></view> <view class="borderBottom" wx:if="{{borderBottom}}"></view>
</view> </view>

View File

@ -15,6 +15,7 @@
border-radius: 5rpx; border-radius: 5rpx;
box-sizing: border-box; box-sizing: border-box;
width: calc(100% - 64rpx); width: calc(100% - 64rpx);
max-height: 50vh;
} }
.option { .option {

View File

@ -1,3 +1,5 @@
import { alertInfo } from "../../utils/index";
// pages/home/index.js // pages/home/index.js
Page({ Page({
@ -5,15 +7,14 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
user: {} user: {},
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
const user = wx.getStorageSync('user')
this.setData({ user })
}, },
/** /**
@ -21,6 +22,23 @@ Page({
*/ */
onReady() { 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() { jumpToLogin() {
wx.navigateTo({ wx.navigateTo({
@ -31,7 +49,8 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
const user = wx.getStorageSync('user')
this.setData({ user })
}, },
/** /**

View File

@ -4,7 +4,8 @@
"van-icon": "@vant/weapp/icon/index", "van-icon": "@vant/weapp/icon/index",
"van-button": "@vant/weapp/button/index", "van-button": "@vant/weapp/button/index",
"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"
}, },
"navigationStyle": "custom" "navigationStyle": "custom"
} }

View File

@ -11,15 +11,19 @@
</view> </view>
</view> </view>
</view> </view>
<custom-status-bar />
<view class="chooseParkWrapper">
</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="info" 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="11" /> <avatar text="{{ user.tenement.name.slice(0,2) }}" />
<view> <view>
<van-button type="info" size="small" plain="{{true}}" class="loginBtn" bind:tap="jumpToLogin">{{user.tenement.name}}</van-button> <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></view> <view class="welcome"> 欢迎使用华昌宝能用电管理系统! </view>
</view> </view>
</view> </view>
<view class="rechargeWrapper"> <view class="rechargeWrapper">
@ -56,11 +60,21 @@
</view> </view>
<view class="recharge"> <view class="recharge">
<view> 请输入金额: </view> <view> 请输入金额: </view>
<view> <view class="moneyBox">
<view> ¥30 </view> <view class="money" bind:tap="changeMoney" data-money="30"> ¥30 </view>
<view> ¥50 </view> <view class="money" bind:tap="changeMoney" data-money="50"> ¥50 </view>
<view> ¥100 </view> <view class="money" bind:tap="changeMoney" data-money="100"> ¥100 </view>
<view> ¥200 </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> </view>
<view class="operate"> <view class="operate">

View File

@ -3,6 +3,11 @@
.top { .top {
background-color: var(--deep-green); background-color: var(--deep-green);
position: fixed;
left: 0;
top: 0;
width: 100vw;
z-index: 99;
} }
.chooseParkWrapper { .chooseParkWrapper {
@ -94,4 +99,28 @@
.operate { .operate {
margin-left: 46rpx; margin-left: 46rpx;
margin-right: 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;
}

View File

@ -39,19 +39,20 @@ Component({
}, },
async setAdmin(e) { async setAdmin(e) {
const { user, tenement } = e.currentTarget.dataset; const { user, tenement } = e.currentTarget.dataset;
await wxModal({ content: `你的管理员身份将转交给${user.nickName}` }) await wxModal({ content: `你的管理员身份将转交给${user.name}` })
const { code, message } = await approveUser({ userId: user.id, type: 2, tenement }) const { code, message } = await approveUser({ userId: user.id, type: 2, tenement })
if (code !== OK) { if (code !== OK) {
alertInfo(message) alertInfo(message)
return; return;
} }
alertSuccess("转交成功")
const newUser = wx.getStorageSync('user') const newUser = wx.getStorageSync('user')
newUser.isAdmin = false; newUser.isAdmin = false;
wx.setStorageSync('user', newUser) wx.setStorageSync('user', newUser)
wx.redirectTo({ wx.switchTab({
url: '/pages/home/index', url: '/pages/home/index',
}) })
alertSuccess("转交成功")
}, },
async remove(e) { async remove(e) {
const { user, tenement } = e.currentTarget.dataset; const { user, tenement } = e.currentTarget.dataset;

View File

@ -11,7 +11,7 @@
<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> <view class="nickName"> {{ ele.name }} </view>
<view class="operate"> <view class="operate" wx:if="{{!ele.isAdmin}}">
<view class="primaryTextBtn" data-user="{{ele}}" bind:tap="setAdmin" data-tenement="{{item.id}}"> 设为管理员 </view> <view class="primaryTextBtn" data-user="{{ele}}" bind:tap="setAdmin" data-tenement="{{item.id}}"> 设为管理员 </view>
<view class="disAgree dangerTextBtn" data-user="{{ele}}" bind:tap="remove" data-tenement="{{item.id}}"> 移除 </view> <view class="disAgree dangerTextBtn" data-user="{{ele}}" bind:tap="remove" data-tenement="{{item.id}}"> 移除 </view>
</view> </view>

View File

@ -1,3 +1,5 @@
import { alertInfo } from "../../utils/index";
import Dialog from '@vant/weapp/dialog/dialog';
// pages/my/index.js // pages/my/index.js
Page({ Page({
@ -5,17 +7,16 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
user: {} user: {},
visible: false,
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
const user = wx.getStorageSync('user');
this.setData({ user })
}, },
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
@ -41,9 +42,27 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
const user = wx.getStorageSync('user');
if (!user || !user.id) {
wx.switchTab({
url: '/pages/home/index',
})
alertInfo("请先登录");
return false;
}
this.setData({ user })
},
connect() {
Dialog.alert({
title: '提示',
message: '将进入咨询客服页面',
confirmButtonOpenType: "contact",
showCancelButton: true,
}).then(() => {
// on close
});
}, },
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */

View File

@ -1,7 +1,9 @@
{ {
"usingComponents": { "usingComponents": {
"van-cell": "@vant/weapp/cell/index", "van-cell": "@vant/weapp/cell/index",
"van-cell-group": "@vant/weapp/cell-group/index" "van-cell-group": "@vant/weapp/cell-group/index",
"cell": "/components/cell/index",
"van-dialog": "@vant/weapp/dialog/index"
}, },
"navigationBarTitleText": "我的" "navigationBarTitleText": "我的"
} }

View File

@ -4,9 +4,13 @@
<cell title="常见问题" bind:click="jumpToQuestions" /> --> <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:tap="connect" />
<van-cell wx:if="{{!!user.isAdmin}}" title="二维码" value="" is-link bind:click="jumpToQrCode" />
<van-cell wx:if="{{!!user.isAdmin}}" title="成员管理" value="" is-link bind:click="jumpToMember" /> <van-cell wx:if="{{!!user.isAdmin}}" title="成员管理" value="" is-link bind:click="jumpToMember" />
<!-- </van-cell-group> --> <!-- </van-cell-group> -->
<!-- <van-cell-group title=" "> <!-- <van-cell-group title=" ">
<van-cell title="单元格" value="内容" is-link /> <van-cell title="单元格" value="内容" is-link />
</van-cell-group> --> </van-cell-group> -->
<van-dialog id="van-dialog" />

View File

@ -1 +1 @@
/* pages/my/index.wxss */ /* pages/my/index.wxss */