调整登录逻辑

This commit is contained in:
qiaomu 2024-03-27 17:37:11 +08:00
parent 61bcbf6f69
commit 049782f96b
18 changed files with 113 additions and 30 deletions

View File

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

View File

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

View File

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

View File

@ -0,0 +1,2 @@
<!--components/avatar/index.wxml-->
<view class="wrapper">{{text}}</view>

View File

@ -0,0 +1,11 @@
/* components/avatar/index.wxss */
.wrapper {
width: 100rpx;
height: 100rpx;
border-radius: 50%;
background: radial-gradient(circle, var(--light-green), var(--middle-green),var(--deep-green) );
display: flex;
justify-content: center;
align-items: center;
color: #fff;
}

View File

@ -19,8 +19,12 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log('options', options)
const querys = decodeURIComponent(options.scene)
const { id } = querys;
console.log('querys', querys)
// const { id } = querys;
const id = querys.slice(querys.indexOf("=") + 1)
console.log('id', id)
// this.setData({ id, name })
this.getInfo(id);
},
@ -67,6 +71,11 @@ Page({
})
},
getPhoneNumber(e) {
const { nickName } = this.data;
if (!nickName) {
alertInfo("请填写你的名字")
return;
}
const { errno, code: phoneCode } = e.detail;
switch(errno) {
case 103:

View File

@ -15,7 +15,6 @@ Page({
*/
onLoad(options) {
const { id } = options;
console.log('options', options)
if (id !== "-1") {
this.init(id);
}

View File

@ -5,14 +5,15 @@ Page({
* 页面的初始数据
*/
data: {
user: {}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const user = wx.getStorageSync('user')
this.setData({ user })
},
/**
@ -21,7 +22,11 @@ Page({
onReady() {
},
jumpToLogin() {
wx.navigateTo({
url: '/pages/login/index',
})
},
/**
* 生命周期函数--监听页面显示
*/

View File

@ -3,7 +3,8 @@
"custom-status-bar": "/components/customStatusBar/index",
"van-icon": "@vant/weapp/icon/index",
"van-button": "@vant/weapp/button/index",
"van-image": "@vant/weapp/image/index"
"van-image": "@vant/weapp/image/index",
"avatar": "/components/avatar/index"
},
"navigationStyle": "custom"
}

View File

@ -13,7 +13,14 @@
</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>
<van-button type="info" size="small" plain="{{true}}" class="loginBtn" bind:tap="jumpToLogin">请登录</van-button>
</view>
<view class="logined" wx:else>
<avatar text="11" />
<view>
<van-button type="info" size="small" plain="{{true}}" class="loginBtn" bind:tap="jumpToLogin">{{user.tenement.name}}</van-button>
<view></view>
</view>
</view>
<view class="rechargeWrapper">
<view class="card">

View File

@ -23,7 +23,7 @@
align-items: center;
}
.notLoginWrapper {
.notLoginWrapper, .logined {
padding: 30rpx 32rpx;
background-color: var(--middle-green);
display: flex;

View File

@ -38,9 +38,9 @@ Component({
})
},
async setAdmin(e) {
const { user } = e.currentTarget.dataset;
const { user, tenement } = e.currentTarget.dataset;
await wxModal({ content: `你的管理员身份将转交给${user.nickName}` })
const { code, message } = await approveUser({ userId: user.id, type: 2 })
const { code, message } = await approveUser({ userId: user.id, type: 2, tenement })
if (code !== OK) {
alertInfo(message)
return;
@ -54,9 +54,9 @@ Component({
})
},
async remove(e) {
const { user } = e.currentTarget.dataset;
await wxModal({ content: `将移除${user.nickName}` })
const { code, message } = await removeUser(user.id)
const { user, tenement } = e.currentTarget.dataset;
await wxModal({ content: `将移除${user.name}` })
const { code, message } = await removeUser(user.id, tenement)
if (code !== OK) {
alertInfo(message)
return;

View File

@ -1,4 +1,7 @@
{
"component": true,
"usingComponents": {}
"usingComponents": {
"van-tab": "@vant/weapp/tab/index",
"van-tabs": "@vant/weapp/tabs/index"
}
}

View File

@ -1,8 +1,20 @@
<!--pages/member/components/memberManage/index.wxml-->
<view wx:for="{{list}}" wx:key="index" wx:for-item="item" class="item">
<!-- <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> -->
<van-tabs active="{{ active }}" bind:change="onChange">
<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 class="nickName"> {{ ele.name }} </view>
<view class="operate">
<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>
</view>
</van-tab>
</van-tabs>

View File

@ -1,3 +1,4 @@
@import "/app.wxss";
.item {
display: flex;

View File

@ -6,5 +6,18 @@
"urlCheck": false,
"skylineRenderEnable": true
},
"libVersion": "development"
"libVersion": "development",
"condition": {
"miniprogram": {
"list": [
{
"name": "pages/apply/index",
"pathName": "pages/apply/index",
"query": "id=sssss",
"launchMode": "default",
"scene": null
}
]
}
}
}

View File

@ -27,8 +27,8 @@ export const approveUser = async function(data) {
}
// 移除用户
export const removeUser = async function(uid) {
return await DELETE(`/wx/removeUser/${uid}`);
export const removeUser = async function(uid, tid) {
return await DELETE(`/wx/removeUser/${tid}/${uid}`);
}
// 获取用户最新信息

View File

@ -30,7 +30,6 @@ const request = async function (options, config = {}) {
"env": envVersion,
...config
};
console.log('config', config)
let response;
try {
response = await requestWithoutCookie(options);
@ -47,12 +46,10 @@ const request = async function (options, config = {}) {
if (localCookieString) {
const localCookies = localCookieString.split('; ');
for (const localCookie of localCookies) {
const matchResult = localCookie.match(/^([^=]+)=(.+)/);
cookieMap[matchResult[1]] = matchResult[2];
}
}
const matchResultSet = setCookie.match(/^([^=]+)=([^;]+);/);
@ -76,7 +73,6 @@ const request = async function (options, config = {}) {
alertInfo(err.errMsg)
}
return response;
}
@ -111,8 +107,6 @@ const GET = async function (uri) {
const response = await request({
url: `${SERVER}${uri}`,
method: 'GET'
}, {
"content-type": "image/png"
});
return parseResponse(response);
@ -120,9 +114,7 @@ const GET = async function (uri) {
// 创建、更新和删除请求
const CUD = async function (method, uri, data = null) {
// 没有CSRF Token就前往获取
// 请求参数
const options = {
url: `${SERVER}${uri}`,