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.
121 lines
2.4 KiB
121 lines
2.4 KiB
import { inputSync, nextTick } from "@utils/tools";
|
|
import { wxRequestPost } from "@utils/promise-wx-api";
|
|
import validate from "@utils/validate/index.js";
|
|
|
|
const app = getApp();
|
|
|
|
Component({
|
|
properties: {
|
|
issueId: String,
|
|
},
|
|
|
|
data: {
|
|
iniLoaded: false,
|
|
|
|
fmData: {
|
|
publicFlag: true,
|
|
suggestion: "",
|
|
},
|
|
|
|
submitBtnIsAllowed: false,
|
|
},
|
|
|
|
lifetimes: {
|
|
attached() {
|
|
this.init();
|
|
},
|
|
},
|
|
|
|
methods: {
|
|
async init() {
|
|
await app.doAfterLogin();
|
|
|
|
this.setData({
|
|
iniLoaded: true,
|
|
});
|
|
},
|
|
|
|
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,
|
|
});
|
|
|
|
this.triggerEvent("success", {});
|
|
}
|
|
},
|
|
},
|
|
});
|
|
|