修改二维码登录逻辑
This commit is contained in:
@@ -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;
|
||||
}
|
Reference in New Issue
Block a user