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

4 months ago
4 months ago
2 weeks ago
4 months ago
2 weeks ago
4 months ago
2 weeks ago
4 months ago
2 weeks ago
4 months ago
2 weeks ago
4 months ago
2 weeks ago
4 months ago
2 weeks ago
4 months ago
3 months ago
4 months ago
2 weeks ago
3 months ago
4 months ago
2 weeks ago
4 months ago
2 weeks ago
3 months ago
4 months ago
2 weeks ago
4 months ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
4 months ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
4 months ago
2 weeks ago
4 months ago
  1. "use strict";
  2. const common_vendor = require("../../../../common/vendor.js");
  3. const config_api = require("../../../../config/api.js");
  4. if (!Array) {
  5. const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
  6. const _easycom_oneBtn2 = common_vendor.resolveComponent("oneBtn");
  7. (_easycom_u_icon2 + _easycom_oneBtn2)();
  8. }
  9. const _easycom_u_icon = () => "../../../../uni_modules/uview-plus/components/u-icon/u-icon.js";
  10. const _easycom_oneBtn = () => "../../../../components/oneBtn/oneBtn.js";
  11. if (!Math) {
  12. (topInfo + _easycom_u_icon + _easycom_oneBtn)();
  13. }
  14. const topInfo = () => "./comp/topInfo.js";
  15. const _sfc_main = {
  16. __name: "vote",
  17. setup(__props) {
  18. let voteId = "";
  19. common_vendor.ref([
  20. { name: "测试标题", subOption: [
  21. { name: "选项一", isCheck: 1 },
  22. { name: "选项一", isCheck: 0 },
  23. { name: "选项一", isCheck: 0 }
  24. ] },
  25. { name: "测试标题二", subOption: [
  26. { name: "选项二", isCheck: 1 },
  27. { name: "选项二", isCheck: 0 },
  28. { name: "选项二", isCheck: 0 }
  29. ] }
  30. ]);
  31. common_vendor.ref(false);
  32. function chooseVoteType3(list, item2) {
  33. if (item2.isCheck) {
  34. item2.isCheck = 0;
  35. } else {
  36. list.forEach((val) => {
  37. val.isCheck = 0;
  38. });
  39. item2.isCheck = 1;
  40. }
  41. }
  42. const detailInfo = common_vendor.ref({});
  43. async function voteDetailFn() {
  44. const { data: res } = await config_api.voteDetail({ voteId });
  45. if (!res.attachmentList)
  46. res.attachmentList = [];
  47. console.log(res);
  48. detailInfo.value = res;
  49. }
  50. const voteItemId = common_vendor.ref([]);
  51. function chooseItem(item) {
  52. if (detailInfo.value.voteType == 1) {
  53. voteItemId.value = [{ voteItemId: item.itemId, voteId }];
  54. return;
  55. }
  56. let index = voteItemId.value.findIndex((val) => val.voteItemId == item.itemId);
  57. if (index == -1) {
  58. console.log(voteItemId.value.length, "nnnn");
  59. voteItemId.value.push({ voteItemId: item.itemId, voteId });
  60. } else {
  61. voteItemId.value.splice(index, 1);
  62. }
  63. console.log(voteItemId.value);
  64. }
  65. async function articleVoteFn() {
  66. if (detailInfo.value.voteType == 3) {
  67. let arr = detailInfo.value.voteMultipleInfoList.map((item) => {
  68. let obj = {
  69. "name": item.name,
  70. "multipleVoteId": item.multipleVoteId,
  71. optionList: item.optionList.filter((item2) => item2.isCheck == 1)
  72. };
  73. return obj;
  74. });
  75. console.log(arr);
  76. const { data: res } = await config_api.vote_multiple({ voteId, voteMultipleList: arr });
  77. if (res)
  78. common_vendor.index.$u.toast("投票成功");
  79. } else {
  80. if (!voteItemId.value.length)
  81. return;
  82. const { data: res } = await config_api.articleVote(voteItemId.value);
  83. if (res)
  84. common_vendor.index.$u.toast("投票成功");
  85. }
  86. setTimeout(() => {
  87. common_vendor.index.redirectTo({
  88. url: "/pages/subPage/ballots/vote/voteReslut?voteId=" + voteId
  89. });
  90. }, 1500);
  91. }
  92. common_vendor.onLoad((option) => {
  93. voteId = option.voteId;
  94. voteDetailFn();
  95. });
  96. common_vendor.onPullDownRefresh(async () => {
  97. await voteDetailFn();
  98. common_vendor.index.stopPullDownRefresh();
  99. });
  100. return (_ctx, _cache) => {
  101. return common_vendor.e({
  102. a: common_vendor.p({
  103. detailInfo: detailInfo.value
  104. }),
  105. b: detailInfo.value.voteType == 3
  106. }, detailInfo.value.voteType == 3 ? {
  107. c: common_vendor.f(detailInfo.value.voteMultipleInfoList, (item, index, i0) => {
  108. return {
  109. a: common_vendor.t(item.name),
  110. b: common_vendor.f(item.optionList, (item2, index2, i1) => {
  111. return common_vendor.e({
  112. a: item2.isCheck
  113. }, item2.isCheck ? {
  114. b: "49022e38-1-" + i0 + "-" + i1,
  115. c: common_vendor.p({
  116. name: "checkmark-circle-fill",
  117. color: "#DE3A26",
  118. size: "20"
  119. })
  120. } : {}, {
  121. d: common_vendor.t(item2.itemName),
  122. e: common_vendor.o(($event) => chooseVoteType3(item.optionList, item2))
  123. });
  124. }),
  125. c: index
  126. };
  127. })
  128. } : {
  129. d: common_vendor.f(detailInfo.value.voteItems, (item, index, i0) => {
  130. return {
  131. a: common_vendor.t(item.itemName),
  132. b: voteItemId.value.find((val) => val.voteItemId == item.itemId) ? 1 : "",
  133. c: index,
  134. d: common_vendor.o(($event) => chooseItem(item), index)
  135. };
  136. })
  137. }, {
  138. e: detailInfo.value.voteType == 3
  139. }, detailInfo.value.voteType == 3 ? {
  140. f: common_vendor.o(articleVoteFn),
  141. g: common_vendor.p({
  142. text: "投 票"
  143. })
  144. } : {
  145. h: common_vendor.o(articleVoteFn),
  146. i: common_vendor.p({
  147. text: "投 票",
  148. disabled: !voteItemId.value.length
  149. })
  150. });
  151. };
  152. }
  153. };
  154. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-49022e38"]]);
  155. wx.createPage(MiniProgramPage);