themeVote.vue 4.9 KB

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