You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
1.8 KiB
91 lines
1.8 KiB
import { wxRequestPost } from "@utils/promise-wx-api";
|
|
import { apiUrl } from "@config/config";
|
|
import joinUrl from "@npm/dai-mp/tools/jointUrl";
|
|
|
|
const app = getApp();
|
|
|
|
Component({
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
ki: String,
|
|
filled: {
|
|
type: Number,
|
|
default: 0,
|
|
},
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
iniLoaded: false,
|
|
permitted: true,
|
|
accessKey: "",
|
|
h5Url: "",
|
|
},
|
|
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
async onLoad() {
|
|
await app.doAfterLogin();
|
|
await this.getAccess();
|
|
|
|
const {
|
|
token,
|
|
orgInfo: { orgId, orgType, orgName },
|
|
userInfo: { realName },
|
|
} = app.globalData;
|
|
const { ki, accessKey } = this.data;
|
|
|
|
let baseUrl = apiUrl.slice(0, -4).replace('cloud','open') + "questionnaire/s/" + ki;
|
|
this.setData({
|
|
iniLoaded: true,
|
|
h5Url: joinUrl(baseUrl, {
|
|
clientType: "resi",
|
|
orgId,
|
|
orgName,
|
|
orgType,
|
|
realName,
|
|
accessKey,
|
|
token,
|
|
}),
|
|
});
|
|
},
|
|
|
|
async getAccess() {
|
|
const { ki } = this.data;
|
|
const { gridId } = app.globalData;
|
|
const {
|
|
data: {
|
|
data: { code, data },
|
|
},
|
|
msg,
|
|
} = await wxRequestPost(
|
|
"data/aggregator/questionnaire/permission-validate",
|
|
{
|
|
key: ki,
|
|
orgId: gridId,
|
|
orgType: "grid",
|
|
},
|
|
{
|
|
// isMock: true,
|
|
// isQuiet: true
|
|
}
|
|
);
|
|
if (msg === "success" && code === 0) {
|
|
this.setData({
|
|
permitted: data.permitted,
|
|
accessKey: data.accessKey,
|
|
});
|
|
}
|
|
},
|
|
|
|
handleError(e) {},
|
|
|
|
handleSuccess(e) {},
|
|
},
|
|
});
|
|
|