index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <view v-if="isShow">
  3. <view :class="(about.greyTheme==1?' grayTheme':'')">
  4. <view style="width: 100%;">
  5. <view v-for="(item, index) in contact" :key="index">
  6. <!-- 弹窗广告 -->
  7. <view v-if="bannerList&&bannerList.length>0">
  8. <banner v-if="item == 'ad' && bannerShow" :bannerList="bannerList" :url="site" :web="url"
  9. :config="about" :couponList="[]" :officeList="[]"
  10. :districtTemplate="districtTemplate"></banner>
  11. </view>
  12. <district v-if="item == 'king_kong_district' && districtShow" :url="site" :web="url"
  13. :districtTemplate="districtTemplate"></district>
  14. </view>
  15. </view>
  16. <!-- <view class="ddflex" style="margin: 0 60rpx;">
  17. <view class="fflex">
  18. <image style="width: 86rpx;height: 86rpx;margin: 0 auto 20rpx;" src="/static/images/rmhd.png"></image>
  19. <view style="font-size: 24rpx;color: #302222;text-align: center;">热门活动</view>
  20. </view>
  21. <view class="fflex">
  22. <image style="width: 86rpx;height: 86rpx;margin: 0 auto 20rpx;" src="/static/images/ttcj.png"></image>
  23. <view style="font-size: 24rpx;color: #302222;text-align: center;">天天抽奖</view>
  24. </view>
  25. <view class="fflex">
  26. <image style="width: 86rpx;height: 86rpx;margin: 0 auto 20rpx;" src="/static/images/zxzq.png"></image>
  27. <view style="font-size: 24rpx;color: #302222;text-align: center;">赠险专区</view>
  28. </view>
  29. </view> -->
  30. <view class="act-list" v-if="pageList && pageList.length > 0">
  31. <view class="li" v-for="(item, index) in pageList" :key="index" @click="toActivity(item)">
  32. <view class="imgbox"><image :src="item.pic" mode="aspectFill"></image></view>
  33. <view class="infos fflex">
  34. <view class="act-tit tovers">{{ item.title }}</view>
  35. <view class="stas ddflex">
  36. <view class="fflex">
  37. <view class="tag-box tovers">{{ item.brief }}</view>
  38. <view class="area">
  39. <block v-if="item.state < 4">报名截止时间:{{ item.enlistEndTime }}</block>
  40. <block v-else>活动结束时间:{{ item.endTime }}</block>
  41. </view>
  42. <!-- <view class="money" v-if="userinfovip.levelGrade>0&& !userinfovip.end"><text>¥</text>{{item.vipMoney}}</view>
  43. <view class="money" v-else><text>¥</text>{{item.money}}</view> -->
  44. </view>
  45. <view class="act-btn" @click.stop="jumpUrl('/match/activity/activity')" v-if="item.isEnlist">我已报名</view>
  46. <block v-else>
  47. <view class="act-btn" @click.stop="toActivity(item)" v-if="item.state == 2">立即报名</view>
  48. <view class="act-btn" @click.stop="toActivity(item)" v-if="item.state == 3">报名结束</view>
  49. <view class="act-btn" @click.stop="toActivity(item)" v-if="item.state == 4">活动中</view>
  50. <view class="act-btn end" @click.stop="toActivity(item)" v-if="item.state == 5">活动结束</view>
  51. </block>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="nodata" v-else>
  57. <image :src="picUrlss + 'empty_dd.png'"></image>
  58. <text>暂无记录~</text>
  59. </view>
  60. </view>
  61. <foot channel="match" :isUpdate="isUpdate"></foot>
  62. </view>
  63. </template>
  64. <script>
  65. const req = require('../../utils/request.js');
  66. const api = require('../../utils/api.js');
  67. const util = require('../../utils/util.js');
  68. const app = getApp();
  69. import foot from '../../components/nav-bar/index';
  70. import banner from '../../template/banner/banner';
  71. import district from '../../template/king_kong_district/king_kong_district';
  72. export default {
  73. components: {
  74. foot,
  75. banner,
  76. district
  77. },
  78. data() {
  79. return {
  80. picUrlss: req.public.picUrls,
  81. isShow: false,
  82. pageList: [],
  83. isLoad: true,
  84. form: {
  85. page: 1,
  86. limit: 10
  87. },
  88. isLogin: false,
  89. userinfovip: {},
  90. about:'',
  91. bannerShow: false,
  92. bannerList: [],
  93. districtShow:false,
  94. districtTemplate: {},
  95. homeTemplate: [],//首页栏目配置
  96. templateType: {
  97. module_ad: 'ad',
  98. //广告
  99. module_type_district: 'type_district',
  100. //分类导航
  101. module_king_kong_district: 'king_kong_district', //金刚区
  102. },
  103. };
  104. },
  105. onLoad() {
  106. this.getHomeTemplateConfig()
  107. req.saveBehaviorNew('',12,4)
  108. },
  109. async onShow() {
  110. this.about = await req.getsysConfig()
  111. this.isLogin = req.isAuth();
  112. this.getPageList(true);
  113. if (this.isLogin) {
  114. this.getuserVip();
  115. }
  116. },
  117. onReachBottom: function() {
  118. this.form.page++;
  119. this.getPageList(false);
  120. },
  121. onShareAppMessage() {
  122. },
  123. onShareTimeline() {
  124. },
  125. methods: {
  126. jumpUrl(url) {
  127. if (!req.isLogins(true)) {
  128. return;
  129. }
  130. uni.navigateTo({
  131. url: url
  132. });
  133. },
  134. // 自定义
  135. getHomeTemplateConfig() {
  136. let _ts = this;
  137. let page = 'matchIndex';
  138. req.getRequest(
  139. '/api/template/getTemplate', {
  140. page: page
  141. },
  142. data => {
  143. let arr = [];
  144. data.forEach(it => {
  145. arr.push(it.module);
  146. });
  147. this.setData({
  148. contact: [...new Set(arr)],
  149. contactShow: false
  150. });
  151. this.setData({
  152. homeTemplate: data
  153. });
  154. this.getRqeDatas();
  155. }
  156. );
  157. },
  158. async getRqeDatas() {
  159. let that = this; //多门店
  160. // 金刚区
  161. let district = that.homeTemplate.filter(it => it.module == that.templateType
  162. .module_king_kong_district);
  163. if (district && district.length > 0 && district[0].state == 0) {
  164. let data = district[0];
  165. data.content = JSON.parse(district[0].content);
  166. that.districtTemplate = data;
  167. that.districtShow = true;
  168. }
  169. //顶部banner
  170. let ad = that.homeTemplate.filter(it => it.module == that.templateType.module_ad);
  171. if (ad && ad.length > 0 && ad[0].state == 0) {
  172. await that.getBannerList(ad[0].module, ad[0].contentId);
  173. }
  174. },
  175. getBannerList(module, contentId) {
  176. //banner图
  177. let that = this;
  178. return new Promise((resolve, reject) => {
  179. req.getRequest(
  180. '/api/banner', {
  181. groupId: contentId
  182. },
  183. data => {
  184. if (module == that.templateType.module_ad) {
  185. that.setData({
  186. bannerList: data,
  187. bannerShow: true
  188. });
  189. } else {
  190. that.setData({
  191. popAdList: data[0]
  192. });
  193. }
  194. resolve();
  195. }
  196. );
  197. })
  198. },
  199. getPageList(isShow) {
  200. if (!this.isLoad) return false;
  201. this.isLoad = false;
  202. let form = this.form;
  203. if(req.getStorage("shareId")){
  204. form.shareSaleNo = req.getStorage("shareId")
  205. }
  206. uni.showLoading();
  207. req.getRequest(
  208. '/api/match/list',
  209. form,
  210. res => {
  211. this.isShow = true;
  212. if (res && res.length == 10) {
  213. this.isLoad = true;
  214. }
  215. if (this.form.page > 1) {
  216. res = this.pageList.concat(res);
  217. }
  218. this.pageList = res;
  219. uni.hideLoading();
  220. },
  221. isShow
  222. );
  223. },
  224. getuserVip() {
  225. req.getRequest('/api/user/levelDetails', {}, data => {
  226. let expireTime = Array;
  227. if (data.expireTime) {
  228. expireTime = data.expireTime.split(' ');
  229. data.expireTime = data.expireTime.replace(/-/g, '/');
  230. } // 解决苹果不兼容---日期
  231. let nowTime = new Date().getTime();
  232. let endTime = new Date(data.expireTime).getTime();
  233. let times = parseInt((endTime - nowTime) / 1000); // var expireTime= new Date(data.expireTime)
  234. // console.log(times, nowTime, endTime, data.expireTime);
  235. this.userinfovip = data;
  236. if (times <= 0) {
  237. this.userinfovip.end = true;
  238. } else {
  239. this.userinfovip.end = false;
  240. }
  241. });
  242. },
  243. toActivity(item) {
  244. uni.navigateTo({
  245. url: '/match/activityDetail/activityDetail?id=' + item.id
  246. });
  247. }
  248. }
  249. };
  250. </script>
  251. <style>
  252. @import './index.css';
  253. </style>