details.vue 4.7 KB

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