details.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <view class="container">
  3. <image class="banner" :src="info.image" mode="scaleToFill"></image>
  4. <uni-section :title="info.topic" titleFontSize="18" type="line">
  5. <uni-list>
  6. <uni-list-item :show-extra-icon="true" :extra-icon="extraIcon[0]" title="报名时间" :rightText="`${info.regStartTime}至${info.regEndTime}`"></uni-list-item>
  7. <uni-list-item :show-extra-icon="true" :extra-icon="extraIcon[0]" title="活动时间" :rightText="`${info.startTime}至${info.endTime}`"></uni-list-item>
  8. <uni-list-item v-if="info.regMaxCount < 999" :show-extra-icon="true" :extra-icon="extraIcon[1]" title="招募人数" :rightText="info.regMaxCount || '不限' + '人'"></uni-list-item>
  9. <uni-list-item :show-extra-icon="true" :extra-icon="extraIcon[1]" title="负责人" :rightText="info.sponsorName"></uni-list-item>
  10. <uni-list-item :show-extra-icon="true" :extra-icon="extraIcon[2]" title="联系电话" :rightText="info.sponsorPhone"></uni-list-item>
  11. </uni-list>
  12. </uni-section>
  13. <uni-section title="活动详情" titleFontSize="18" type="line">
  14. <rich-text image-menu-prevent="true" :nodes="info.description" class="content"></rich-text>
  15. </uni-section>
  16. <uni-goods-nav class="goodNav" :fill="true" :options="options" :buttonGroup="buttonGroup" @buttonClick="buttonClick" />
  17. </view>
  18. </template>
  19. <script>
  20. import request from '../../api/activity.js';
  21. import { BASE_URL } from '../../env.js';
  22. export default {
  23. onLoad: function (option) {
  24. this.activityId = option.activityId;
  25. },
  26. data() {
  27. return {
  28. activityId: '',
  29. info: null,
  30. options: [],
  31. extraIcon: [
  32. {
  33. color: '#c60814',
  34. size: '22',
  35. type: 'calendar'
  36. },
  37. {
  38. color: '#c60814',
  39. size: '22',
  40. type: 'person-filled'
  41. },
  42. {
  43. color: '#c60814',
  44. size: '22',
  45. type: 'phone'
  46. }
  47. ],
  48. buttonGroup: [
  49. {
  50. text: '报名活动',
  51. backgroundColor: '#ff0000',
  52. color: '#fff'
  53. },
  54. {
  55. text: '获取积分',
  56. backgroundColor: '#ffa200',
  57. color: '#fff'
  58. }
  59. ],
  60. statusInfo: true
  61. }
  62. },
  63. mounted() {
  64. this.query();
  65. },
  66. methods: {
  67. async query() {
  68. const res = await request.getdetails({ activityId: this.activityId });
  69. const statusInfo = await request.getstatus({ activityId: this.activityId });
  70. res.data.image = BASE_URL.fileUrl + res.data.image;
  71. this.info = res.data;
  72. this.statusInfo = statusInfo.status
  73. const newDateTime = new Date().getTime();
  74. const endTime = Date.parse(res.data.regEndTime);
  75. const startTime = Date.parse(res.data.regStartTime);
  76. const startActiveTime = Date.parse(res.data.startTime);
  77. const endActiveTime = Date.parse(res.data.endTime);
  78. // 报名按钮状态设置
  79. if (!statusInfo.status && newDateTime > startTime && newDateTime < endTime) {
  80. this.buttonGroup[0].backgroundColor = '#ff0000';
  81. this.buttonGroup[0].text = '报名活动';
  82. delete this.buttonGroup[0].status
  83. delete this.buttonGroup[0].disable
  84. this.buttonGroup[1].disable = true;
  85. this.buttonGroup[1].backgroundColor = '#999';
  86. }
  87. if (statusInfo.status && newDateTime > startTime && newDateTime < endTime) {
  88. this.buttonGroup[0].backgroundColor = '#ffa200';
  89. this.buttonGroup[0].text = '取消报名';
  90. this.buttonGroup[0].status = true;
  91. delete this.buttonGroup[1].disable;
  92. this.buttonGroup[1].backgroundColor = '#ffa200';
  93. }
  94. if (newDateTime < startTime) {
  95. this.buttonGroup[0].backgroundColor = '#999';
  96. this.buttonGroup[0].text = '报名未开始';
  97. this.buttonGroup[0].disable = true;
  98. }
  99. if (newDateTime > endTime) {
  100. this.buttonGroup[0].backgroundColor = '#999';
  101. this.buttonGroup[0].text = '报名已结束';
  102. this.buttonGroup[0].disable = true;
  103. }
  104. // 活动状态及积分获取按钮状态
  105. if (res.data.status == 3) {
  106. this.buttonGroup[1].text = '活动已结束';
  107. this.buttonGroup[1].backgroundColor = '#999';
  108. this.buttonGroup[1].disable = true;
  109. this.buttonGroup[0].backgroundColor = '#999';
  110. this.buttonGroup[0].text = '报名已结束';
  111. this.buttonGroup[0].disable = true;
  112. }
  113. if(res.data.status == 0) {
  114. if(newDateTime < startActiveTime){
  115. this.buttonGroup[1].text = '活动未开始';
  116. this.buttonGroup[1].backgroundColor = '#999';
  117. this.buttonGroup[1].disable = true;
  118. }
  119. // if(newDateTime > endActiveTime){
  120. // this.buttonGroup[1].text = '活动已结束';
  121. // this.buttonGroup[1].backgroundColor = '#999';
  122. // this.buttonGroup[1].disable = true;
  123. // }
  124. if(statusInfo.status && newDateTime > startActiveTime){
  125. this.buttonGroup[1].text = '获取积分';
  126. this.buttonGroup[1].backgroundColor = '#ffa200';
  127. delete this.buttonGroup[1].disable;
  128. }
  129. if (!statusInfo.status && newDateTime < endActiveTime && newDateTime > startActiveTime){
  130. this.buttonGroup[1].text = '活动进行中';
  131. this.buttonGroup[1].backgroundColor = '#999';
  132. this.buttonGroup[1].disable = true;
  133. }
  134. }
  135. },
  136. buttonClick(e) {
  137. if (e.index == 0){
  138. if (e.content.disable) return;
  139. if (e.content.status) {
  140. this.offReport();
  141. return;
  142. };
  143. this.report();
  144. } else {
  145. if (e.content.disable) return;
  146. this.submitPhoto();
  147. }
  148. },
  149. async report() {
  150. const res = await request.report({ activityId: this.activityId });
  151. if (res.code == 200) {
  152. wx.showToast({
  153. title: '报名成功'
  154. })
  155. this.query();
  156. }
  157. },
  158. async offReport() {
  159. const res = await request.offReport({ activityId: this.activityId });
  160. if (res.code == 200) {
  161. wx.showToast({
  162. title: '取消报名成功'
  163. })
  164. this.query();
  165. }
  166. },
  167. async submitPhoto() {
  168. uni.navigateTo({ url: `/pages/activity/uploadFiel?activityId=${this.activityId}` })
  169. }
  170. }
  171. }
  172. </script>
  173. <style>
  174. .container {
  175. position: relative;
  176. padding-bottom: 12vw;
  177. background-color: #fff;
  178. }
  179. .banner {
  180. width: 100%;
  181. height: 50vw;
  182. }
  183. .content {
  184. display: block;
  185. width: 90%;
  186. margin: 10px auto;
  187. }
  188. .goodNav {
  189. width: 100%;
  190. height: 12vw;
  191. position: fixed;
  192. left: 0;
  193. bottom: 0;
  194. }
  195. </style>