修改二维码登录逻辑
This commit is contained in:
parent
3b5525a2a2
commit
61bcbf6f69
7
app.json
7
app.json
@ -1,22 +1,21 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/login/index",
|
||||
"pages/home/index",
|
||||
"pages/handleLogin/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/my/index",
|
||||
"pages/questions/index",
|
||||
"pages/index/index",
|
||||
"pages/invoiceDetail/index",
|
||||
"pages/editInvoice/index"
|
||||
|
||||
],
|
||||
"tabBar": {
|
||||
"list": [
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { getTenementDetail } from "../../service/tenement";
|
||||
import { userApply } from "../../service/user";
|
||||
import { alertInfo, alertSuccess } from "../../utils/index";
|
||||
import request from '../../utils/request'
|
||||
@ -10,7 +11,8 @@ Page({
|
||||
*/
|
||||
data: {
|
||||
id: "",
|
||||
name: "",
|
||||
tenement: {},
|
||||
nickName: ""
|
||||
},
|
||||
|
||||
/**
|
||||
@ -18,12 +20,67 @@ Page({
|
||||
*/
|
||||
onLoad(options) {
|
||||
const querys = decodeURIComponent(options.scene)
|
||||
const { id, name } = querys;
|
||||
this.setData({ id, name })
|
||||
const { id } = querys;
|
||||
// this.setData({ id, name })
|
||||
this.getInfo(id);
|
||||
},
|
||||
async getInfo(id) {
|
||||
const { code, message, data } = await getTenementDetail(id);
|
||||
if (code !== OK) {
|
||||
alertInfo(message)
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
tenement: data,
|
||||
id
|
||||
})
|
||||
},
|
||||
exit() {
|
||||
wx.exitMiniProgram()
|
||||
},
|
||||
onChangeName(e) {
|
||||
this.setData({
|
||||
nickName: e.detail
|
||||
})
|
||||
},
|
||||
async handleLogin(phoneCode) {
|
||||
const { id, nickName } = this.data;
|
||||
loadingFunc(async () => {
|
||||
const wxLoginCode = await wxLogin()
|
||||
const result = await userApply({ code: wxLoginCode, phoneCode, id, name: nickName })
|
||||
const { code, message, data } = result;
|
||||
if (code !== OK) {
|
||||
alertError(message)
|
||||
return
|
||||
}
|
||||
if (!data?.id) {
|
||||
this.noPermission()
|
||||
return;
|
||||
}
|
||||
alertSuccess("登录成功")
|
||||
const { token, ...user } = data
|
||||
wx.setStorageSync('user', user)
|
||||
wx.setStorageSync('token', data?.token)
|
||||
wx.switchTab({
|
||||
url: '/pages/home/index',
|
||||
})
|
||||
})
|
||||
},
|
||||
getPhoneNumber(e) {
|
||||
const { errno, code: phoneCode } = e.detail;
|
||||
switch(errno) {
|
||||
case 103:
|
||||
alertInfo("已拒绝");
|
||||
|
||||
return;
|
||||
case 1400001:
|
||||
alertInfo("服务达到上限")
|
||||
return;
|
||||
default:
|
||||
this.handleLogin(phoneCode)
|
||||
return;
|
||||
}
|
||||
},
|
||||
async join() {
|
||||
const { id } = this.data;
|
||||
const { code, message, data } = await userApply({ id })
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"van-button": "@vant/weapp/button/index"
|
||||
"van-button": "@vant/weapp/button/index",
|
||||
"van-field": "@vant/weapp/field/index"
|
||||
}
|
||||
}
|
@ -1,11 +1,21 @@
|
||||
<!--pages/apply/index.wxml-->
|
||||
|
||||
<view class="content">
|
||||
<view class="text"> 即将加入{{tenement.name}} </view>
|
||||
<view class="nickName">
|
||||
<van-field
|
||||
required
|
||||
value="{{ name }}"
|
||||
label="你的昵称"
|
||||
placeholder="请输入你的昵称"
|
||||
border="{{ false }}"
|
||||
bind:change="onChangeName"
|
||||
/>
|
||||
</view>
|
||||
<view class="contentWrapper">
|
||||
<view class="text"> 确定要加入{{name}}吗? </view>
|
||||
<view class="operate">
|
||||
<van-button type="default" block style="flex: 1;" bind:click="exit">退出</van-button>
|
||||
<van-button type="info" block style="flex:1;margin-left: 20rpx;">确认</van-button>
|
||||
<van-button type="info" block style="flex:1;margin-left: 20rpx;" open-type="getPhoneNumber" bind:getphonenumber="getPhoneNumber">确认</van-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
@ -6,6 +6,7 @@
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.text {
|
||||
@ -24,3 +25,10 @@
|
||||
margin-right: 40rpx;
|
||||
}
|
||||
|
||||
.nickName {
|
||||
width: 95vw;
|
||||
margin-bottom: 60rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import request from "../../utils/request"
|
||||
import { getWxCode } from "../../service/user"
|
||||
import { alertInfo } from "../../utils/index";
|
||||
import { alertInfo, loadingFunc } from "../../utils/index";
|
||||
import { getOwnTenementList } from "../../service/tenement";
|
||||
|
||||
const { OK } = request;
|
||||
|
||||
@ -10,19 +11,52 @@ Page({
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
url: ""
|
||||
list: [],
|
||||
urls: [],
|
||||
indexs: [],
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
this.getCode()
|
||||
this.getList()
|
||||
},
|
||||
async getCode() {
|
||||
const data = await getWxCode()
|
||||
async getList() {
|
||||
const { code, message, data } = await getOwnTenementList()
|
||||
if (code !== OK) {
|
||||
alertInfo(message)
|
||||
return;
|
||||
}
|
||||
let tenements = [];
|
||||
data?.forEach(item => {
|
||||
const { tenements: ts = [] } = item;
|
||||
tenements = [...tenements, ...ts];
|
||||
})
|
||||
this.setData({
|
||||
url: wx.arrayBufferToBase64(data)
|
||||
list: [...tenements]
|
||||
})
|
||||
},
|
||||
async getCode(e, that) {
|
||||
const { index, id } = e.currentTarget.dataset;
|
||||
const { code, message, data } = await getWxCode(id)
|
||||
if (code !== OK) {
|
||||
alertInfo(message)
|
||||
return;
|
||||
}
|
||||
const newUrls = that.data.urls;
|
||||
newUrls[index] = data;
|
||||
const newIndexs = that.data.indexs;
|
||||
newIndexs[index] = true;
|
||||
that.setData({
|
||||
urls: newUrls,
|
||||
indexs: newIndexs,
|
||||
})
|
||||
},
|
||||
look(e) {
|
||||
const that = this;
|
||||
loadingFunc(async () => {
|
||||
await this.getCode(e, that)
|
||||
})
|
||||
},
|
||||
/**
|
||||
|
@ -1,7 +1,12 @@
|
||||
<!--pages/qrCode/index.wxml-->
|
||||
<view class="wrapper">
|
||||
<view style="margin-bottom: 10vh;">
|
||||
<van-image width="400rpx" height="400rpx" src="{{url}}" />
|
||||
<view class="item" wx:for="{{list}}" wx:key="index">
|
||||
<view class="tenement" >
|
||||
<view class="name">{{item.name}}</view>
|
||||
<view class="primaryTextBtn" data-index="{{index}}" data-id="{{item.id}}" bind:tap="look"> 查看二维码 </view>
|
||||
</view>
|
||||
<view class="image" wx:if="{{indexs[index] == true}}">
|
||||
<van-image width="400rpx" height="400rpx" src="{{urls[index]}}" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="text"> 扫码二维码,管理员同意后可进入 </view>
|
||||
</view>
|
@ -1,14 +1,37 @@
|
||||
/* pages/qrCode/index.wxss */
|
||||
.wrapper {
|
||||
width: 100vw;
|
||||
/* width: 100vw;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
flex-direction: column; */
|
||||
/* margin-top: 20rpx; */
|
||||
margin-left: 32rpx;
|
||||
margin-right: 32rpx;
|
||||
}
|
||||
|
||||
.text {
|
||||
text-align: center;
|
||||
margin-bottom: 15vh;
|
||||
}
|
||||
|
||||
.item {
|
||||
margin: 20rpx 0;
|
||||
}
|
||||
|
||||
.tenement {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
}
|
||||
|
||||
.name {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.image {
|
||||
margin: 50rpx 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
@ -5,3 +5,13 @@ const { GET, POST, PUT, DELETE } = apis
|
||||
export const getTenementList = async function({ park, keyword }) {
|
||||
return await GET(`/wx/getTenementList?park=${park}&keyword=${keyword}`);
|
||||
}
|
||||
|
||||
// 获取名下所有的商户
|
||||
export const getOwnTenementList = async function() {
|
||||
return await GET(`/wx/getOwnTenements`);
|
||||
}
|
||||
|
||||
// 获取商户详情
|
||||
export const getTenementDetail = async function(id) {
|
||||
return await GET(`/wx/getTenementDetail/${id}`);
|
||||
}
|
@ -12,8 +12,8 @@ export const userValidate = async function(data) {
|
||||
}
|
||||
|
||||
// 获取用户邀请二维码
|
||||
export const getWxCode = async function(data) {
|
||||
return await GET('/wx/getWxCode', data);
|
||||
export const getWxCode = async function(id) {
|
||||
return await GET(`/wx/getWxCode?id=${id}`);
|
||||
}
|
||||
|
||||
// 获取扫描二维码的列表
|
||||
@ -41,7 +41,7 @@ export const reApprove = async function() {
|
||||
return await POST('/wx/reApprove');
|
||||
}
|
||||
|
||||
// 非管理员重新提交申请
|
||||
// 非管理员扫码
|
||||
export const userApply = async function(data) {
|
||||
return await POST('/wx/apply', data);
|
||||
}
|
@ -26,7 +26,8 @@ const request = async function (options, config = {}) {
|
||||
Accept: 'application/json',
|
||||
'content-type': 'application/json; charset=utf-8',
|
||||
"Authorization": token,
|
||||
"env": "trial",
|
||||
// "env": "trial",
|
||||
"env": envVersion,
|
||||
...config
|
||||
};
|
||||
console.log('config', config)
|
||||
|
Loading…
x
Reference in New Issue
Block a user