index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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" v-if="item.enlistEndTime || item.endTime">
  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. <update-userinfonew :update-info="isUpdateInfo" :update-mobile="isUpdateMobile" v-if="isShowUpdate" @closeUpdate="closeUpdate" @updateInfo="updateInfo" @updateMobile="updateMobile"></update-userinfonew>
  63. </view>
  64. </template>
  65. <script>
  66. const req = require('../../utils/request.js');
  67. const api = require('../../utils/api.js');
  68. const util = require('../../utils/util.js');
  69. const app = getApp();
  70. import foot from '../../components/nav-bar/index';
  71. import banner from '../../template/banner/banner';
  72. import district from '../../template/king_kong_district/king_kong_district';
  73. export default {
  74. components: {
  75. foot,
  76. banner,
  77. district
  78. },
  79. data() {
  80. return {
  81. picUrlss: req.public.picUrls,
  82. isShow: false,
  83. pageList: [],
  84. isLoad: true,
  85. form: {
  86. page: 1,
  87. limit: 10
  88. },
  89. isLogin: false,
  90. userinfovip: {},
  91. about:'',
  92. bannerShow: false,
  93. bannerList: [],
  94. districtShow:false,
  95. districtTemplate: {},
  96. homeTemplate: [],//首页栏目配置
  97. templateType: {
  98. module_ad: 'ad',
  99. //广告
  100. module_type_district: 'type_district',
  101. //分类导航
  102. module_king_kong_district: 'king_kong_district', //金刚区
  103. },
  104. isShowUpdate: false, //是否显示更新信息弹窗
  105. isUpdateInfo: false,//更新用户信息
  106. isUpdateMobile: false,//绑定手机号
  107. };
  108. },
  109. onLoad() {
  110. this.getHomeTemplateConfig()
  111. req.saveBehaviorNew('',12,4)
  112. },
  113. async onShow() {
  114. this.about = await req.getsysConfig()
  115. this.isLogin = req.isAuth();
  116. this.getPageList(true);
  117. if (this.isLogin) {
  118. this.getuserVip();
  119. this.getUpdate()
  120. }
  121. },
  122. onReachBottom: function() {
  123. this.form.page++;
  124. this.getPageList(false);
  125. },
  126. onShareAppMessage() {
  127. },
  128. onShareTimeline() {
  129. },
  130. methods: {
  131. jumpUrl(url) {
  132. if (!req.isLogins(true)) {
  133. return;
  134. }
  135. uni.navigateTo({
  136. url: url
  137. });
  138. },
  139. // 自定义
  140. getHomeTemplateConfig() {
  141. let _ts = this;
  142. let page = 'matchIndex';
  143. req.getRequest(
  144. '/api/template/getTemplate', {
  145. page: page
  146. },
  147. data => {
  148. let arr = [];
  149. data.forEach(it => {
  150. arr.push(it.module);
  151. });
  152. this.setData({
  153. contact: [...new Set(arr)],
  154. contactShow: false
  155. });
  156. this.setData({
  157. homeTemplate: data
  158. });
  159. this.getRqeDatas();
  160. }
  161. );
  162. },
  163. async getRqeDatas() {
  164. let that = this; //多门店
  165. // 金刚区
  166. let district = that.homeTemplate.filter(it => it.module == that.templateType
  167. .module_king_kong_district);
  168. if (district && district.length > 0 && district[0].state == 0) {
  169. let data = district[0];
  170. data.content = JSON.parse(district[0].content);
  171. that.districtTemplate = data;
  172. that.districtShow = true;
  173. }
  174. //顶部banner
  175. let ad = that.homeTemplate.filter(it => it.module == that.templateType.module_ad);
  176. if (ad && ad.length > 0 && ad[0].state == 0) {
  177. await that.getBannerList(ad[0].module, ad[0].contentId);
  178. }
  179. },
  180. getBannerList(module, contentId) {
  181. //banner图
  182. let that = this;
  183. return new Promise((resolve, reject) => {
  184. req.getRequest(
  185. '/api/banner', {
  186. groupId: contentId
  187. },
  188. data => {
  189. if (module == that.templateType.module_ad) {
  190. that.setData({
  191. bannerList: data,
  192. bannerShow: true
  193. });
  194. } else {
  195. that.setData({
  196. popAdList: data[0]
  197. });
  198. }
  199. resolve();
  200. }
  201. );
  202. })
  203. },
  204. getPageList(isShow) {
  205. if (!this.isLoad) return false;
  206. this.isLoad = false;
  207. let form = this.form;
  208. if(req.getStorage("shareId")){
  209. form.shareSaleNo = req.getStorage("shareId")
  210. }
  211. uni.showLoading();
  212. req.getRequest(
  213. '/api/match/list',
  214. form,
  215. res => {
  216. this.isShow = true;
  217. if (res && res.length == 10) {
  218. this.isLoad = true;
  219. }
  220. if (this.form.page > 1) {
  221. res = this.pageList.concat(res);
  222. }
  223. this.pageList = res;
  224. uni.hideLoading();
  225. },
  226. isShow
  227. );
  228. },
  229. getuserVip() {
  230. req.getRequest('/api/user/levelDetails', {}, data => {
  231. let expireTime = Array;
  232. if (data.expireTime) {
  233. expireTime = data.expireTime.split(' ');
  234. data.expireTime = data.expireTime.replace(/-/g, '/');
  235. } // 解决苹果不兼容---日期
  236. let nowTime = new Date().getTime();
  237. let endTime = new Date(data.expireTime).getTime();
  238. let times = parseInt((endTime - nowTime) / 1000); // var expireTime= new Date(data.expireTime)
  239. // console.log(times, nowTime, endTime, data.expireTime);
  240. this.userinfovip = data;
  241. if (times <= 0) {
  242. this.userinfovip.end = true;
  243. } else {
  244. this.userinfovip.end = false;
  245. }
  246. });
  247. },
  248. toActivity(item) {
  249. uni.navigateTo({
  250. url: '/match/activityDetail/activityDetail?id=' + item.id
  251. });
  252. },
  253. closeUpdate(){
  254. this.isShowUpdate = false
  255. },
  256. updateInfo(e){
  257. this.isUpdateInfo = e;
  258. },
  259. updateMobile(e){
  260. this.isUpdateMobile = e;
  261. },
  262. getUpdate() {
  263. console.log('getUpdate')
  264. let userInfos = req.getStorage('userInfo')
  265. // if ((!userInfos.avatar || userInfos.avatar.indexOf('thirdwx.qlogo') > -1 || !userInfos.nickName || userInfos.nickName.indexOf('用户') > -1) ) {
  266. // console.log('没有昵称')
  267. // this.isShowUpdate = true;
  268. // this.isUpdateInfo = true;
  269. // return false;
  270. // }
  271. if(!userInfos.mobile){
  272. console.log('没有手机号')
  273. this.isShowUpdate = true
  274. this.isUpdateMobile = true
  275. return false;
  276. }
  277. return true;
  278. },
  279. }
  280. };
  281. </script>
  282. <style>
  283. @import './index.css';
  284. </style>