activity.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view :style="[mainStyle]" v-if="isShow">
  3. <view class="act-list" v-if="pageList && pageList.length > 0">
  4. <view class="li" v-for="(item, index) in pageList" :key="index" @click="toActivity(item)">
  5. <view class="imgbox"><image :src="item.pic" mode="aspectFill"></image></view>
  6. <view class="infos fflex">
  7. <view class="act-tit tovers">{{ item.title }}</view>
  8. <view class="stas ddflex">
  9. <view class="fflex">
  10. <view class="tag-box tovers">{{ item.brief }}</view>
  11. <view class="area">
  12. <!-- <block>报名截止时间:{{ item.enlistEndTime.replace(/\-/g, ".") }}</block> -->
  13. 活动结束时间:{{ getTimeText(item.endTime,'',true) }}
  14. </view>
  15. <view class="money" v-if="userinfovip.levelGrade>0&& !userinfovip.end"><text v-if="item.vipMoney > 0">¥</text>{{item.vipMoney > 0 ? item.vipMoney : '免费'}}</view>
  16. <view class="money" v-else><text v-if="item.money > 0">¥</text>{{item.money > 0 ? item.money : '免费'}}</view>
  17. </view>
  18. <view class="act-btn end" @click.stop="jumpUrl('/match/activitys/activity')" v-if="item.isEnlist">我已报名</view>
  19. <block v-else>
  20. <view class="act-btn" @click.stop="toActivity(item)" v-if="item.state == 2">立即报名</view>
  21. <view class="act-btn" @click.stop="toActivity(item)" v-if="item.state == 3">报名结束</view>
  22. <view class="act-btn" @click.stop="toActivity(item)" v-if="item.state == 4">活动中</view>
  23. <view class="act-btn end" @click.stop="toActivity(item)" v-if="item.state == 5">活动结束</view>
  24. </block>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="nodata" v-else>
  30. <image :src="picUrlss + 'empty_dd.png'"></image>
  31. <text>暂无记录~</text>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. const req = require('../../utils/request.js');
  37. const api = require('../../utils/api.js');
  38. const util = require('../../utils/util.js');
  39. const app = getApp();
  40. export default {
  41. components: {},
  42. data() {
  43. return {
  44. mainStyle: app.globalData.mainStyle,
  45. picUrlss: req.public.picUrls,
  46. isShow: false,
  47. pageList: [],
  48. isLoad: true,
  49. form: {
  50. page: 1,
  51. limit: 10
  52. },
  53. isLogin: false,
  54. userinfovip: {}
  55. };
  56. },
  57. onLoad(opt) {
  58. if(opt.appId) req.setStorage('appId',opt.appId);
  59. if(opt.title){
  60. uni.setNavigationBarTitle({
  61. title: opt.title
  62. })
  63. }
  64. },
  65. onShow() {
  66. this.isLogin = req.isAuth();
  67. this.getPageList(true);
  68. if (this.isLogin) {
  69. this.getuserVip();
  70. }
  71. },
  72. onReachBottom: function() {
  73. this.form.page++;
  74. this.getPageList(false);
  75. },
  76. onShareAppMessage: function() {
  77. let path = '';
  78. let isSolution = req.env[req.env.NODE_ENV].isSolution;
  79. let userInfo = req.getStorage('userInfo');
  80. if(isSolution){
  81. path = '/share/home/index?appId='+req.getStorage('appId')+'&userId='+userInfo.id;
  82. }else{
  83. path = '/match/activity/activity'
  84. }
  85. return {
  86. path: path
  87. };
  88. },
  89. onShareTimeline() {
  90. },
  91. methods: {
  92. getTimeText(startTime,endTime,isText){
  93. return util.getTimeText(startTime,endTime,isText);
  94. },
  95. jumpUrl(url) {
  96. if (!req.isLogins(true)) {
  97. return;
  98. }
  99. uni.navigateTo({
  100. url: url
  101. });
  102. },
  103. getPageList(isShow) {
  104. if (!this.isLoad) return false;
  105. this.isLoad = false;
  106. let form = this.form;
  107. uni.showLoading();
  108. req.getRequest(
  109. '/api/match/list',
  110. form,
  111. res => {
  112. this.isShow = true;
  113. if (res && res.length == 10) {
  114. this.isLoad = true;
  115. }
  116. if (this.form.page > 1) {
  117. res = this.pageList.concat(res);
  118. }
  119. this.pageList = res;
  120. uni.hideLoading();
  121. },
  122. isShow
  123. );
  124. },
  125. getuserVip() {
  126. req.getRequest('/api/user/levelDetails', {}, data => {
  127. let expireTime = Array;
  128. if (data.expireTime) {
  129. expireTime = data.expireTime.split(' ');
  130. data.expireTime = data.expireTime.replace(/-/g, '/');
  131. } // 解决苹果不兼容---日期
  132. let nowTime = new Date().getTime();
  133. let endTime = new Date(data.expireTime).getTime();
  134. let times = parseInt((endTime - nowTime) / 1000); // var expireTime= new Date(data.expireTime)
  135. // console.log(times, nowTime, endTime, data.expireTime);
  136. this.userinfovip = data;
  137. if (times <= 0) {
  138. this.userinfovip.end = true;
  139. } else {
  140. this.userinfovip.end = false;
  141. }
  142. });
  143. },
  144. toActivity(item) {
  145. uni.navigateTo({
  146. url: '/match/activityDetail/activityDetail?id=' + item.id
  147. });
  148. }
  149. }
  150. };
  151. </script>
  152. <style>
  153. @import './activity.css';
  154. </style>