修改二维码登录逻辑
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)
|
||||
})
|
||||
},
|
||||
/**
|
||||
|
Reference in New Issue
Block a user