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.
155 lines
5.2 KiB
155 lines
5.2 KiB
"use strict";
|
|
const common_vendor = require("../../../../common/vendor.js");
|
|
const config_api = require("../../../../config/api.js");
|
|
if (!Array) {
|
|
const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
|
|
const _easycom_oneBtn2 = common_vendor.resolveComponent("oneBtn");
|
|
(_easycom_u_icon2 + _easycom_oneBtn2)();
|
|
}
|
|
const _easycom_u_icon = () => "../../../../uni_modules/uview-plus/components/u-icon/u-icon.js";
|
|
const _easycom_oneBtn = () => "../../../../components/oneBtn/oneBtn.js";
|
|
if (!Math) {
|
|
(topInfo + _easycom_u_icon + _easycom_oneBtn)();
|
|
}
|
|
const topInfo = () => "./comp/topInfo.js";
|
|
const _sfc_main = {
|
|
__name: "vote",
|
|
setup(__props) {
|
|
let voteId = "";
|
|
common_vendor.ref([
|
|
{ name: "测试标题", subOption: [
|
|
{ name: "选项一", isCheck: 1 },
|
|
{ name: "选项一", isCheck: 0 },
|
|
{ name: "选项一", isCheck: 0 }
|
|
] },
|
|
{ name: "测试标题二", subOption: [
|
|
{ name: "选项二", isCheck: 1 },
|
|
{ name: "选项二", isCheck: 0 },
|
|
{ name: "选项二", isCheck: 0 }
|
|
] }
|
|
]);
|
|
common_vendor.ref(false);
|
|
function chooseVoteType3(list, item2) {
|
|
if (item2.isCheck) {
|
|
item2.isCheck = 0;
|
|
} else {
|
|
list.forEach((val) => {
|
|
val.isCheck = 0;
|
|
});
|
|
item2.isCheck = 1;
|
|
}
|
|
}
|
|
const detailInfo = common_vendor.ref({});
|
|
async function voteDetailFn() {
|
|
const { data: res } = await config_api.voteDetail({ voteId });
|
|
if (!res.attachmentList)
|
|
res.attachmentList = [];
|
|
console.log(res);
|
|
detailInfo.value = res;
|
|
}
|
|
const voteItemId = common_vendor.ref([]);
|
|
function chooseItem(item) {
|
|
if (detailInfo.value.voteType == 1) {
|
|
voteItemId.value = [{ voteItemId: item.itemId, voteId }];
|
|
return;
|
|
}
|
|
let index = voteItemId.value.findIndex((val) => val.voteItemId == item.itemId);
|
|
if (index == -1) {
|
|
console.log(voteItemId.value.length, "nnnn");
|
|
voteItemId.value.push({ voteItemId: item.itemId, voteId });
|
|
} else {
|
|
voteItemId.value.splice(index, 1);
|
|
}
|
|
console.log(voteItemId.value);
|
|
}
|
|
async function articleVoteFn() {
|
|
if (detailInfo.value.voteType == 3) {
|
|
let arr = detailInfo.value.voteMultipleInfoList.map((item) => {
|
|
let obj = {
|
|
"name": item.name,
|
|
"multipleVoteId": item.multipleVoteId,
|
|
optionList: item.optionList.filter((item2) => item2.isCheck == 1)
|
|
};
|
|
return obj;
|
|
});
|
|
console.log(arr);
|
|
const { data: res } = await config_api.vote_multiple({ voteId, voteMultipleList: arr });
|
|
if (res)
|
|
common_vendor.index.$u.toast("投票成功");
|
|
} else {
|
|
if (!voteItemId.value.length)
|
|
return;
|
|
const { data: res } = await config_api.articleVote(voteItemId.value);
|
|
if (res)
|
|
common_vendor.index.$u.toast("投票成功");
|
|
}
|
|
setTimeout(() => {
|
|
common_vendor.index.redirectTo({
|
|
url: "/pages/subPage/ballots/vote/voteReslut?voteId=" + voteId
|
|
});
|
|
}, 1500);
|
|
}
|
|
common_vendor.onLoad((option) => {
|
|
voteId = option.voteId;
|
|
voteDetailFn();
|
|
});
|
|
common_vendor.onPullDownRefresh(async () => {
|
|
await voteDetailFn();
|
|
common_vendor.index.stopPullDownRefresh();
|
|
});
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.p({
|
|
detailInfo: detailInfo.value
|
|
}),
|
|
b: detailInfo.value.voteType == 3
|
|
}, detailInfo.value.voteType == 3 ? {
|
|
c: common_vendor.f(detailInfo.value.voteMultipleInfoList, (item, index, i0) => {
|
|
return {
|
|
a: common_vendor.t(item.name),
|
|
b: common_vendor.f(item.optionList, (item2, index2, i1) => {
|
|
return common_vendor.e({
|
|
a: item2.isCheck
|
|
}, item2.isCheck ? {
|
|
b: "49022e38-1-" + i0 + "-" + i1,
|
|
c: common_vendor.p({
|
|
name: "checkmark-circle-fill",
|
|
color: "#DE3A26",
|
|
size: "20"
|
|
})
|
|
} : {}, {
|
|
d: common_vendor.t(item2.itemName),
|
|
e: common_vendor.o(($event) => chooseVoteType3(item.optionList, item2))
|
|
});
|
|
}),
|
|
c: index
|
|
};
|
|
})
|
|
} : {
|
|
d: common_vendor.f(detailInfo.value.voteItems, (item, index, i0) => {
|
|
return {
|
|
a: common_vendor.t(item.itemName),
|
|
b: voteItemId.value.find((val) => val.voteItemId == item.itemId) ? 1 : "",
|
|
c: index,
|
|
d: common_vendor.o(($event) => chooseItem(item), index)
|
|
};
|
|
})
|
|
}, {
|
|
e: detailInfo.value.voteType == 3
|
|
}, detailInfo.value.voteType == 3 ? {
|
|
f: common_vendor.o(articleVoteFn),
|
|
g: common_vendor.p({
|
|
text: "投 票"
|
|
})
|
|
} : {
|
|
h: common_vendor.o(articleVoteFn),
|
|
i: common_vendor.p({
|
|
text: "投 票",
|
|
disabled: !voteItemId.value.length
|
|
})
|
|
});
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-49022e38"]]);
|
|
wx.createPage(MiniProgramPage);
|