59 lines
1.2 KiB
JavaScript
59 lines
1.2 KiB
JavaScript
import request from "../../utils/request"
|
|
import { getWxCode } from "../../service/user"
|
|
import { alertInfo, loadingFunc } from "../../utils/index";
|
|
import { getOwnTenementList } from "../../service/tenement";
|
|
|
|
const { OK } = request;
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
url: "",
|
|
tenement: ""
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
loadingFunc(async () => {
|
|
await this.getCode()
|
|
})
|
|
},
|
|
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({
|
|
list: [...tenements]
|
|
})
|
|
},
|
|
async getCode() {
|
|
const tenement = wx.getStorageSync('tenement');
|
|
const { code, message, data } = await getWxCode(tenement.id)
|
|
if (code !== OK) {
|
|
alertInfo(message)
|
|
return;
|
|
}
|
|
this.setData({
|
|
url: data,
|
|
tenement: tenement
|
|
})
|
|
},
|
|
look(e) {
|
|
const that = this;
|
|
loadingFunc(async () => {
|
|
await this.getCode(e, that)
|
|
})
|
|
},
|
|
}) |