themeVote.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view class="container theme-vote-container">
  3. <block v-if="Object.keys(detailDate).length > 0">
  4. <view class="content-top">
  5. <view class="title"> {{ detailDate.ActivityTypeName }}</view>
  6. <view class="time">
  7. <view class=""> 最多可选{{ detailDate.MaxChooseTotal }}项</view>
  8. <view class="">截止时间:{{ detailDate.EndTime }} </view>
  9. </view>
  10. <view class="radio-content">
  11. <van-checkbox-group v-model="result" @change="onChange">
  12. <view class="radio-li" v-for="(item, index) in listTheme" :key="item.QuestionnaireThemeId">
  13. <van-checkbox :class="[`checkboxes${index}`]" :disabled="item.DisabledRadio" :name="item.QuestionnaireThemeId" checked-color="#FBD979"> {{ item.ActivityTheme }} </van-checkbox>
  14. </view>
  15. </van-checkbox-group>
  16. </view>
  17. </view>
  18. <view class="text-box">
  19. <textarea v-model="advice_content" :clearable="false" placeholder="点击输入其余感兴趣的主题活动" class="ipt" />
  20. </view>
  21. <view class="sed-btn" @click="submitBtn"> 提交 </view>
  22. </block>
  23. <Loading />
  24. </view>
  25. </template>
  26. <script>
  27. import { purchaserApi } from "@/config/modules/purchaser.js";
  28. export default {
  29. data() {
  30. return {
  31. advice_content: "",
  32. result: [],
  33. listTheme: [],
  34. detailDate: {},
  35. id: "",
  36. };
  37. },
  38. methods: {
  39. onChange(event) {
  40. if (event.detail.length >= this.detailDate.MaxChooseTotal) {
  41. this.listTheme.forEach((item) => {
  42. if (!event.detail.includes(item.QuestionnaireThemeId + "")) {
  43. item.DisabledRadio = true;
  44. }
  45. });
  46. this.result = event.detail;
  47. } else {
  48. this.result = event.detail;
  49. this.listTheme.forEach((item) => {
  50. item.DisabledRadio = false;
  51. });
  52. }
  53. },
  54. //
  55. async submitBtn() {
  56. const res = await purchaserApi.questionnaireVote_add({
  57. QuestionnaireId: this.detailDate.QuestionnaireId ? this.detailDate.QuestionnaireId : "",
  58. QuestionnaireThemeIds: this.result.map((item) => Number(item)),
  59. Content: this.advice_content,
  60. });
  61. if (res.Ret === 200) {
  62. uni.navigateBack({
  63. fail() {
  64. uni.switchTab({
  65. url: "/pages/index/index",
  66. });
  67. },
  68. });
  69. }
  70. },
  71. // 获取详情
  72. async getDetails() {
  73. const res = await purchaserApi.questionnaireDetail({
  74. IsBestNew: this.id ? false : true,
  75. QuestionnaireId: +this.id,
  76. });
  77. if (res.Ret === 200) {
  78. this.detailDate = res.Data.Detail;
  79. this.listTheme = res.Data.Detail.ListTheme || [];
  80. }
  81. },
  82. },
  83. onLoad(options) {
  84. this.id = options.id || "";
  85. console.log(this.id);
  86. this.getDetails();
  87. },
  88. };
  89. </script>
  90. <style lang="scss" scoped>
  91. .theme-vote-container {
  92. background-color: #376cbb;
  93. padding: 60rpx 35rpx 35rpx;
  94. .content-top {
  95. width: 100%;
  96. height: 854rpx;
  97. border-radius: 16rpx;
  98. background-color: #fff;
  99. padding: 30rpx;
  100. overflow: hidden;
  101. overflow-y: auto;
  102. .title {
  103. font-size: 34rpx;
  104. font-weight: 500;
  105. line-height: 42rpx;
  106. }
  107. .time {
  108. display: flex;
  109. justify-content: space-between;
  110. color: #999;
  111. font-size: 28rpx;
  112. }
  113. .radio-content {
  114. .radio-li {
  115. display: flex;
  116. align-items: center;
  117. width: 100%;
  118. height: 74rpx;
  119. border: 2rpx solid #ffe8a8;
  120. margin-top: 20rpx;
  121. padding-left: 15rpx;
  122. }
  123. /deep/ .van-checkbox__icon {
  124. border: 1px solid #ffe8a8 !important;
  125. }
  126. }
  127. }
  128. .text-box {
  129. margin: 30rpx 0;
  130. padding: 30rpx 40rpx;
  131. height: 297rpx;
  132. width: 100%;
  133. border: 2rpx solid #ffe8a8;
  134. background-color: #fff;
  135. border-radius: 16rpx;
  136. .ipt {
  137. height: 100%;
  138. border: 2px solid #ffe8a8;
  139. padding: 20rpx;
  140. box-sizing: border-box;
  141. }
  142. }
  143. .sed-btn {
  144. width: 100%;
  145. height: 80rpx;
  146. border-radius: 16rpx;
  147. display: flex;
  148. align-items: center;
  149. justify-content: center;
  150. background-color: #fbd879;
  151. font-size: 28rpx;
  152. font-weight: 600;
  153. }
  154. view {
  155. box-sizing: border-box;
  156. }
  157. }
  158. </style>