调整登录逻辑
This commit is contained in:
parent
61bcbf6f69
commit
049782f96b
4
app.json
4
app.json
|
@ -1,17 +1,17 @@
|
||||||
{
|
{
|
||||||
"pages": [
|
"pages": [
|
||||||
|
"pages/home/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/my/index",
|
||||||
"pages/home/index",
|
|
||||||
"pages/handleLogin/index",
|
"pages/handleLogin/index",
|
||||||
"pages/waitApprove/index",
|
"pages/waitApprove/index",
|
||||||
"pages/rechargeRecord/index",
|
"pages/rechargeRecord/index",
|
||||||
"pages/invoiceList/index",
|
"pages/invoiceList/index",
|
||||||
"pages/meterList/index",
|
"pages/meterList/index",
|
||||||
"pages/recharge/index",
|
"pages/recharge/index",
|
||||||
"pages/member/index",
|
|
||||||
"pages/questions/index",
|
"pages/questions/index",
|
||||||
"pages/index/index",
|
"pages/index/index",
|
||||||
"pages/invoiceDetail/index",
|
"pages/invoiceDetail/index",
|
||||||
|
|
24
components/avatar/index.js
Normal file
24
components/avatar/index.js
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
// components/avatar/index.js
|
||||||
|
Component({
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件的属性列表
|
||||||
|
*/
|
||||||
|
properties: {
|
||||||
|
text: String,
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件的初始数据
|
||||||
|
*/
|
||||||
|
data: {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件的方法列表
|
||||||
|
*/
|
||||||
|
methods: {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
4
components/avatar/index.json
Normal file
4
components/avatar/index.json
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"component": true,
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
2
components/avatar/index.wxml
Normal file
2
components/avatar/index.wxml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<!--components/avatar/index.wxml-->
|
||||||
|
<view class="wrapper">{{text}}</view>
|
11
components/avatar/index.wxss
Normal file
11
components/avatar/index.wxss
Normal 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;
|
||||||
|
}
|
|
@ -19,8 +19,12 @@ Page({
|
||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
|
console.log('options', options)
|
||||||
const querys = decodeURIComponent(options.scene)
|
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.setData({ id, name })
|
||||||
this.getInfo(id);
|
this.getInfo(id);
|
||||||
},
|
},
|
||||||
|
@ -67,6 +71,11 @@ Page({
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getPhoneNumber(e) {
|
getPhoneNumber(e) {
|
||||||
|
const { nickName } = this.data;
|
||||||
|
if (!nickName) {
|
||||||
|
alertInfo("请填写你的名字")
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { errno, code: phoneCode } = e.detail;
|
const { errno, code: phoneCode } = e.detail;
|
||||||
switch(errno) {
|
switch(errno) {
|
||||||
case 103:
|
case 103:
|
||||||
|
|
|
@ -15,7 +15,6 @@ Page({
|
||||||
*/
|
*/
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
const { id } = options;
|
const { id } = options;
|
||||||
console.log('options', options)
|
|
||||||
if (id !== "-1") {
|
if (id !== "-1") {
|
||||||
this.init(id);
|
this.init(id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,14 +5,15 @@ Page({
|
||||||
* 页面的初始数据
|
* 页面的初始数据
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
|
user: {}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
|
const user = wx.getStorageSync('user')
|
||||||
|
this.setData({ user })
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +22,11 @@ Page({
|
||||||
onReady() {
|
onReady() {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
jumpToLogin() {
|
||||||
|
wx.navigateTo({
|
||||||
|
url: '/pages/login/index',
|
||||||
|
})
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面显示
|
* 生命周期函数--监听页面显示
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
"custom-status-bar": "/components/customStatusBar/index",
|
"custom-status-bar": "/components/customStatusBar/index",
|
||||||
"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"
|
||||||
},
|
},
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
|
@ -13,7 +13,14 @@
|
||||||
</view>
|
</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">请登录</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>
|
||||||
<view class="rechargeWrapper">
|
<view class="rechargeWrapper">
|
||||||
<view class="card">
|
<view class="card">
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.notLoginWrapper {
|
.notLoginWrapper, .logined {
|
||||||
padding: 30rpx 32rpx;
|
padding: 30rpx 32rpx;
|
||||||
background-color: var(--middle-green);
|
background-color: var(--middle-green);
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
@ -38,9 +38,9 @@ Component({
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
async setAdmin(e) {
|
async setAdmin(e) {
|
||||||
const { user } = e.currentTarget.dataset;
|
const { user, tenement } = e.currentTarget.dataset;
|
||||||
await wxModal({ content: `你的管理员身份将转交给${user.nickName}` })
|
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) {
|
if (code !== OK) {
|
||||||
alertInfo(message)
|
alertInfo(message)
|
||||||
return;
|
return;
|
||||||
|
@ -54,9 +54,9 @@ Component({
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
async remove(e) {
|
async remove(e) {
|
||||||
const { user } = e.currentTarget.dataset;
|
const { user, tenement } = e.currentTarget.dataset;
|
||||||
await wxModal({ content: `将移除${user.nickName}?` })
|
await wxModal({ content: `将移除${user.name}?` })
|
||||||
const { code, message } = await removeUser(user.id)
|
const { code, message } = await removeUser(user.id, tenement)
|
||||||
if (code !== OK) {
|
if (code !== OK) {
|
||||||
alertInfo(message)
|
alertInfo(message)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
{
|
{
|
||||||
"component": true,
|
"component": true,
|
||||||
"usingComponents": {}
|
"usingComponents": {
|
||||||
|
"van-tab": "@vant/weapp/tab/index",
|
||||||
|
"van-tabs": "@vant/weapp/tabs/index"
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,20 @@
|
||||||
<!--pages/member/components/memberManage/index.wxml-->
|
<!--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="nickName"> {{ item.nickName }} </view>
|
||||||
<view class="operate">
|
<view class="operate">
|
||||||
<view class="primaryTextBtn" data-user="{{item}}" bind:tap="setAdmin"> 设为管理员 </view>
|
<view class="primaryTextBtn" data-user="{{item}}" bind:tap="setAdmin"> 设为管理员 </view>
|
||||||
<view class="disAgree dangerTextBtn" data-user="{{item}}" bind:tap="remove"> 移除 </view>
|
<view class="disAgree dangerTextBtn" data-user="{{item}}" bind:tap="remove"> 移除 </view>
|
||||||
</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>
|
|
@ -1,3 +1,4 @@
|
||||||
|
@import "/app.wxss";
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
@ -6,5 +6,18 @@
|
||||||
"urlCheck": false,
|
"urlCheck": false,
|
||||||
"skylineRenderEnable": true
|
"skylineRenderEnable": true
|
||||||
},
|
},
|
||||||
"libVersion": "development"
|
"libVersion": "development",
|
||||||
|
"condition": {
|
||||||
|
"miniprogram": {
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"name": "pages/apply/index",
|
||||||
|
"pathName": "pages/apply/index",
|
||||||
|
"query": "id=sssss",
|
||||||
|
"launchMode": "default",
|
||||||
|
"scene": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -27,8 +27,8 @@ export const approveUser = async function(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移除用户
|
// 移除用户
|
||||||
export const removeUser = async function(uid) {
|
export const removeUser = async function(uid, tid) {
|
||||||
return await DELETE(`/wx/removeUser/${uid}`);
|
return await DELETE(`/wx/removeUser/${tid}/${uid}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户最新信息
|
// 获取用户最新信息
|
||||||
|
|
|
@ -30,7 +30,6 @@ const request = async function (options, config = {}) {
|
||||||
"env": envVersion,
|
"env": envVersion,
|
||||||
...config
|
...config
|
||||||
};
|
};
|
||||||
console.log('config', config)
|
|
||||||
let response;
|
let response;
|
||||||
try {
|
try {
|
||||||
response = await requestWithoutCookie(options);
|
response = await requestWithoutCookie(options);
|
||||||
|
@ -47,12 +46,10 @@ const request = async function (options, config = {}) {
|
||||||
|
|
||||||
if (localCookieString) {
|
if (localCookieString) {
|
||||||
const localCookies = localCookieString.split('; ');
|
const localCookies = localCookieString.split('; ');
|
||||||
|
|
||||||
for (const localCookie of localCookies) {
|
for (const localCookie of localCookies) {
|
||||||
const matchResult = localCookie.match(/^([^=]+)=(.+)/);
|
const matchResult = localCookie.match(/^([^=]+)=(.+)/);
|
||||||
cookieMap[matchResult[1]] = matchResult[2];
|
cookieMap[matchResult[1]] = matchResult[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const matchResultSet = setCookie.match(/^([^=]+)=([^;]+);/);
|
const matchResultSet = setCookie.match(/^([^=]+)=([^;]+);/);
|
||||||
|
@ -76,7 +73,6 @@ const request = async function (options, config = {}) {
|
||||||
alertInfo(err.errMsg)
|
alertInfo(err.errMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,8 +107,6 @@ const GET = async function (uri) {
|
||||||
const response = await request({
|
const response = await request({
|
||||||
url: `${SERVER}${uri}`,
|
url: `${SERVER}${uri}`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
}, {
|
|
||||||
"content-type": "image/png"
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return parseResponse(response);
|
return parseResponse(response);
|
||||||
|
@ -120,9 +114,7 @@ const GET = async function (uri) {
|
||||||
|
|
||||||
// 创建、更新和删除请求
|
// 创建、更新和删除请求
|
||||||
const CUD = async function (method, uri, data = null) {
|
const CUD = async function (method, uri, data = null) {
|
||||||
|
|
||||||
// 没有CSRF Token就前往获取
|
// 没有CSRF Token就前往获取
|
||||||
|
|
||||||
// 请求参数
|
// 请求参数
|
||||||
const options = {
|
const options = {
|
||||||
url: `${SERVER}${uri}`,
|
url: `${SERVER}${uri}`,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user