调整首页

This commit is contained in:
qiaomu 2024-03-26 17:38:31 +08:00
parent 756f567dba
commit 3b5525a2a2
18 changed files with 247 additions and 34 deletions

1
app.js
View File

@ -8,6 +8,7 @@ App({
onLaunch() {
const { api } = getConfigByEnv();
this.globalData = { ...this.globalData, api, }
},
globalData: {
primaryColor: '#52c41a'

View File

@ -1,15 +1,15 @@
{
"pages": [
"pages/login/index",
"pages/home/index",
"pages/handleLogin/index",
"pages/apply/index",
"pages/qrCode/index",
"pages/waitApprove/index",
"pages/home/index",
"pages/rechargeRecord/index",
"pages/invoiceList/index",
"pages/meterList/index",
"pages/recharge/index",
"pages/handleLogin/index",
"pages/member/index",
"pages/my/index",
"pages/questions/index",

View File

@ -17,6 +17,9 @@ page {
page {
font-size: 36rpx;
--deep-green: #15755e;
--middle-green: rgb(75, 151, 131);
--light-green: rgb(174,218,203);
/* background-color: #f0f0f0; */
}
@ -26,4 +29,5 @@ page {
.dangerTextBtn {
color: #ee0a24;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

@ -0,0 +1,31 @@
// components/customStatusBar/index.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
height: 0,
},
lifetimes: {
attached() {
const { statusBarHeight } = wx.getSystemInfoSync();
this.setData({
height: statusBarHeight
})
}
},
/**
* 组件的方法列表
*/
methods: {
}
})

View File

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

View File

@ -0,0 +1,2 @@
<!--components/customStatusBar/index.wxml-->
<view class="wrapper" style="height: {{height}}px;"></view>

View File

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

View File

@ -17,7 +17,8 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const { id, name } = options;
const querys = decodeURIComponent(options.scene)
const { id, name } = querys;
this.setData({ id, name })
},
exit() {
@ -25,12 +26,15 @@ Page({
},
async join() {
const { id } = this.data;
const { code, message } = await userApply({ id })
const { code, message, data } = await userApply({ id })
if (code !== OK) {
alertInfo(message)
return;
}
alertSuccess("加入成功")
const { token, ...currentUser } = data;
wx.setStorageSync('user', currentUser)
wx.setStorageSync('token', token)
setTimeout(() => {
wx.switchTab({
url: '/pages/home/index',

View File

@ -68,10 +68,10 @@ Page({
loadingFunc(async () => {
const wxLoginCode = await wxLogin()
const { code, message, data } = await userValidate({ park, tenement, phone, name, code: wxLoginCode })
// if (code !== OK) {
// alertInfo(message)
// return
// }
if (code !== OK) {
alertInfo(message)
return
}
const { exist, user } = data;
if (!exist) {
alertInfo("绑定失败,请检查信息")

View File

@ -1,3 +1,9 @@
{
"usingComponents": {}
"usingComponents": {
"custom-status-bar": "/components/customStatusBar/index",
"van-icon": "@vant/weapp/icon/index",
"van-button": "@vant/weapp/button/index",
"van-image": "@vant/weapp/image/index"
},
"navigationStyle": "custom"
}

View File

@ -1,2 +1,62 @@
<!--pages/home/index.wxml-->
首页
<view class="top">
<custom-status-bar />
<view class="chooseParkWrapper">
用电管理服务 ·
<view class="parkContent">
<view class="park">
金石工业园
</view>
<van-icon name="arrow-down" style="margin-left: 16rpx;" />
</view>
</view>
</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">请登录</van-button>
</view>
<view class="rechargeWrapper">
<view class="card">
<view class="cardTop">
<view class="cardTopLeft">
<view> 华昌宝能 - 软c307 </view>
</view>
<van-button type="info" size="small" plain="{{true}}" class="loginBtn">
<van-icon name="exchange" />
切换电表
</van-button>
</view>
<view class="cardContent">
<view class="cardItem">
<view class="cardItemLabel"> 电表编号: </view>
<view class="cardItemValue"> 15151515 </view>
</view>
<view class="cardItem">
<view class="cardItemLabel"> 电表地址: </view>
<view class="cardItemValue"> 软C307 </view>
</view>
<view class="cardItem">
<view class="cardItemLabel"> 电表余额: </view>
<view class="cardItemValue">
<view class="text"> 200 </view>
<van-button type="info" size="small" plain="{{true}}">
<van-icon name="replay" />
刷新
</van-button>
</view>
</view>
</view>
</view>
<view class="recharge">
<view> 请输入金额: </view>
<view>
<view> ¥30 </view>
<view> ¥50 </view>
<view> ¥100 </view>
<view> ¥200 </view>
</view>
</view>
<view class="operate">
<van-button color="rgb(88, 165, 141)" block>去缴费</van-button>
</view>
</view>

View File

@ -1 +1,97 @@
/* pages/home/index.wxss */
/* pages/home/index.wxss */
@import "/app.wxss";
.top {
background-color: var(--deep-green);
}
.chooseParkWrapper {
height: 46px;
display: flex;
align-items: center;
padding: 0 32rpx;
color: #fff;
font-size: 34rpx;
}
.park {
margin-left: 30rpx;
}
.parkContent {
display: flex;
align-items: center;
}
.notLoginWrapper {
padding: 30rpx 32rpx;
background-color: var(--middle-green);
display: flex;
align-items: center;
}
.loginBtn {
margin-left: 30rpx;
}
.rechargeWrapper {
background: linear-gradient(to bottom, var(--middle-green), #fff );
overflow: hidden;
}
.card {
margin-top: 1vh;
margin-left: 46rpx;
margin-right: 46rpx;
border-radius: 30rpx;
padding: 28rpx 30rpx;
/* background-color: rgb(173, 217, 203); */
background: linear-gradient(to bottom right, rgb(212, 240, 231), rgb(145, 206, 185));
}
.cardTop {
display: flex;
align-items: center;
}
.cardTopLeft {
display: flex;
align-items: center;
flex: 1;
}
.cardContent {
margin: 30rpx 20rpx 0;
}
.cardItem {
display: flex;
align-items: center;
margin-bottom: 30rpx;
font-size: 34rpx;
}
.cardItemValue {
display: flex;
flex: 1;
align-items: center;
}
.cardItemValue .text {
flex: 1;
}
.recharge {
background: #fff;
padding: 20rpx 30rpx;
margin-top: 30rpx;
margin-left: 46rpx;
margin-right: 46rpx;
margin-bottom: 40rpx;
border-radius: 30rpx;
}
.operate {
margin-left: 46rpx;
margin-right: 46rpx;
}

View File

@ -1,4 +1,4 @@
import { approveUser, getApproveList } from "../../../../service/user"
import { approveUser, getApproveList, removeUser } from "../../../../service/user"
import { alertInfo, alertSuccess, wxModal } from "../../../../utils/index";
import request from "../../../../utils/request"
@ -46,18 +46,22 @@ Component({
return;
}
alertSuccess("转交成功")
wx.clearStorageSync()
wx.exitMiniProgram()
const newUser = wx.getStorageSync('user')
newUser.isAdmin = false;
wx.setStorageSync('user', newUser)
wx.redirectTo({
url: '/pages/home/index',
})
},
async disAgree(e) {
async remove(e) {
const { user } = e.currentTarget.dataset;
await wxModal({ content: `拒绝${user.nickName}的申请?` })
const { code, message } = await approveUser({ userId: user.id, type: 0 })
await wxModal({ content: `将移除${user.nickName}` })
const { code, message } = await removeUser(user.id)
if (code !== OK) {
alertInfo(message)
return;
}
alertSuccess("已拒绝")
alertSuccess("已移除")
this.init()
}
}

View File

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

View File

@ -20,13 +20,9 @@ Page({
this.getCode()
},
async getCode() {
const { code, message, data } = await getWxCode()
if (code !== OK) {
alertInfo(message)
return
}
const data = await getWxCode()
this.setData({
url: data
url: wx.arrayBufferToBase64(data)
})
},
/**

View File

@ -27,7 +27,7 @@ export const approveUser = async function(data) {
}
// 移除用户
export const removeUser = async function(data) {
export const removeUser = async function(uid) {
return await DELETE(`/wx/removeUser/${uid}`);
}

View File

@ -18,7 +18,7 @@ const ok = 200;
const requestWithoutCookie = promisify(wx.request);
// 考虑了Cookie的请求
const request = async function (options) {
const request = async function (options, config = {}) {
let token = wx.getStorageSync('token');
const result = wx.getAccountInfoSync();
const { envVersion } = result.miniProgram;
@ -26,8 +26,10 @@ const request = async function (options) {
Accept: 'application/json',
'content-type': 'application/json; charset=utf-8',
"Authorization": token,
"env": envVersion
"env": "trial",
...config
};
console.log('config', config)
let response;
try {
response = await requestWithoutCookie(options);
@ -83,7 +85,7 @@ const parseResponse = function (response) {
alertError("服务异常")
return
}
const { code: statusCode } = response.data;
const { code: statusCode } = response;
if (statusCode === 401) {
wx.redirectTo({
url: '/pages/login/index',
@ -108,6 +110,8 @@ const GET = async function (uri) {
const response = await request({
url: `${SERVER}${uri}`,
method: 'GET'
}, {
"content-type": "image/png"
});
return parseResponse(response);