details.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. pointNeedPoint: false
  62. }
  63. },
  64. mounted() {
  65. this.query();
  66. },
  67. methods: {
  68. async query() {
  69. const res = await request.getdetails({ activityId: this.activityId });
  70. const statusInfo = await request.getstatus({ activityId: this.activityId });
  71. res.data.image = BASE_URL.fileUrl + res.data.image;
  72. this.info = res.data;
  73. this.statusInfo = statusInfo.status;
  74. this.pointNeedPoint = false;
  75. const newDateTime = new Date().getTime();
  76. const endTime = Date.parse(res.data.regEndTime);
  77. const startTime = Date.parse(res.data.regStartTime);
  78. const startActiveTime = Date.parse(res.data.startTime);
  79. const endActiveTime = Date.parse(res.data.endTime);
  80. // 报名按钮状态设置
  81. if (!statusInfo.status && newDateTime > startTime && newDateTime < endTime) {
  82. this.buttonGroup[0].backgroundColor = '#ff0000';
  83. this.buttonGroup[0].text = '报名活动';
  84. delete this.buttonGroup[0].status
  85. delete this.buttonGroup[0].disable
  86. this.buttonGroup[1].disable = true;
  87. this.buttonGroup[1].backgroundColor = '#999';
  88. }
  89. if (statusInfo.status && newDateTime > startTime && newDateTime < endTime) {
  90. this.buttonGroup[0].backgroundColor = '#ffa200';
  91. this.buttonGroup[0].text = '取消报名';
  92. this.buttonGroup[0].status = true;
  93. delete this.buttonGroup[1].disable;
  94. this.buttonGroup[1].backgroundColor = '#ffa200';
  95. }
  96. if (newDateTime < startTime) {
  97. this.buttonGroup[0].backgroundColor = '#999';
  98. this.buttonGroup[0].text = '报名未开始';
  99. this.buttonGroup[0].disable = true;
  100. }
  101. if (newDateTime > endTime) {
  102. this.buttonGroup[0].backgroundColor = '#999';
  103. this.buttonGroup[0].text = '报名已结束';
  104. this.buttonGroup[0].disable = true;
  105. }
  106. // 活动状态及积分获取按钮状态
  107. if (res.data.status == 3) {
  108. this.buttonGroup[1].text = '活动已结束';
  109. this.buttonGroup[1].backgroundColor = '#999';
  110. this.buttonGroup[1].disable = true;
  111. this.buttonGroup[0].backgroundColor = '#999';
  112. this.buttonGroup[0].text = '报名已结束';
  113. this.buttonGroup[0].disable = true;
  114. }
  115. if(res.data.status == 0) {
  116. if(newDateTime < startActiveTime){
  117. this.buttonGroup[1].text = '活动未开始';
  118. this.buttonGroup[1].backgroundColor = '#999';
  119. this.buttonGroup[1].disable = true;
  120. }
  121. // if(newDateTime > endActiveTime){
  122. // this.buttonGroup[1].text = '活动已结束';
  123. // this.buttonGroup[1].backgroundColor = '#999';
  124. // this.buttonGroup[1].disable = true;
  125. // }
  126. if(statusInfo.status && newDateTime > startActiveTime){
  127. if(res.data.pointHowTo == '1'){
  128. this.buttonGroup[1].text = '获取积分';
  129. this.pointNeedPoint = true;
  130. }else{
  131. this.buttonGroup[1].text = '签到';
  132. }
  133. this.buttonGroup[1].backgroundColor = '#ffa200';
  134. delete this.buttonGroup[1].disable;
  135. }
  136. if (!statusInfo.status && newDateTime < endActiveTime && newDateTime > startActiveTime){
  137. this.buttonGroup[1].text = '活动进行中';
  138. this.buttonGroup[1].backgroundColor = '#999';
  139. this.buttonGroup[1].disable = true;
  140. }
  141. }
  142. },
  143. buttonClick(e) {
  144. if (e.index == 0){
  145. if (e.content.disable) return;
  146. if (e.content.status) {
  147. this.offReport();
  148. return;
  149. };
  150. this.report();
  151. } else {
  152. if (e.content.disable) return;
  153. console.log(e.content)
  154. if(this.pointNeedPoint)
  155. this.submitPhoto();
  156. else
  157. this.submitSignIn();
  158. }
  159. },
  160. async report() {
  161. const res = await request.report({ activityId: this.activityId });
  162. if (res.code == 200) {
  163. wx.showToast({
  164. title: '报名成功'
  165. })
  166. this.query();
  167. }
  168. },
  169. async offReport() {
  170. const res = await request.offReport({ activityId: this.activityId });
  171. if (res.code == 200) {
  172. wx.showToast({
  173. title: '取消报名成功'
  174. })
  175. this.query();
  176. }
  177. },
  178. async submitPhoto() {
  179. uni.navigateTo({ url: `/pages/activity/uploadFiel?activityId=${this.activityId}` })
  180. },
  181. async submitSignIn(){
  182. const res = await request.signIn({ activityId: this.activityId });
  183. if (res.code == 200) {
  184. wx.showToast({
  185. title: '签到成功'
  186. })
  187. this.query();
  188. }
  189. }
  190. }
  191. }
  192. </script>
  193. <style>
  194. .container {
  195. position: relative;
  196. padding-bottom: 12vw;
  197. background-color: #fff;
  198. }
  199. .banner {
  200. width: 100%;
  201. height: 50vw;
  202. }
  203. .content {
  204. display: block;
  205. width: 90%;
  206. margin: 10px auto;
  207. }
  208. .goodNav {
  209. width: 100%;
  210. height: 12vw;
  211. position: fixed;
  212. left: 0;
  213. bottom: 0;
  214. }
  215. </style>