日照项目的居民端小程序
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.
 
 
 

118 lines
2.2 KiB

import { inputSync, nextTick } from "@utils/tools";
import { wxRequestPost } from "@utils/promise-wx-api";
import validate from "@utils/validate/index.js";
const app = getApp();
Page({
data: {
iniLoaded: false,
issueId: "",
fmData: {
publicFlag: true,
suggestion: "",
},
submitBtnIsAllowed: false,
},
async onLoad(query) {
this.setData({
issueId: query.issueId,
});
await app.doAfterLogin();
this.setData({
iniLoaded: true,
});
},
async onShow() {},
inputSync,
// 切换匿名
switchPublicFlag() {
this.setData({
"fmData.publicFlag": !this.data.fmData.publicFlag,
});
},
// 更新data数据后需主动触发
$afterUpdateData() {
this.computeSubmitBtnIsAllowed();
},
computeSubmitBtnIsAllowed(isQuiet = true) {
const { fmData } = this.data,
vlt = validate(fmData, {
suggestion: [
{
rule: "required",
message: "请先输入您对议题的意见和建议",
},
],
});
if (!vlt.valid) {
if (!isQuiet) {
wx.showToast({
title: vlt.error,
icon: "none",
duration: 1500,
});
}
this.setData({
submitBtnIsAllowed: false,
});
return false;
} else {
this.setData({
submitBtnIsAllowed: true,
});
return true;
}
},
// 注册
async submit() {
if (!this.computeSubmitBtnIsAllowed(false)) return;
wx.showLoading({
title: "提交中",
mask: true,
});
const { fmData, issueId } = this.data;
const {
data: {
data: { code, data },
},
msg,
} = await wxRequestPost(
"resi/hall/issue/publishsuggestion",
{
issueId,
...fmData,
},
{
// isMock: true,
isQuiet: false,
}
);
wx.hideLoading();
if (msg === "success" && code === 0) {
wx.showToast({
title: "提交成功",
duration: 1500,
mask: true,
});
await nextTick(1500);
wx.navigateBack();
}
},
});