修改二维码登录逻辑

This commit is contained in:
2024-03-27 14:44:59 +08:00
parent 3b5525a2a2
commit 61bcbf6f69
11 changed files with 173 additions and 25 deletions

View File

@@ -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)
})
},
/**