index.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912
  1. <template>
  2. <view>
  3. <!-- <view :class="'top-fixed' + (skinNotColor ? ' not-color' : '')" :style="'height: '+ systems.barHeight + 'rpx;'">
  4. <block v-if="about.CONFIG_PROJECT_TITLE_BG || about.CONFIG_PROJECT_TITLE_PIC">
  5. <image :src="about.CONFIG_PROJECT_TITLE_BG" class="topbg" v-if="about.CONFIG_PROJECT_TITLE_BG"></image>
  6. <view class="top-title" :style="'height: '+ systems.navigationHeight + 'rpx;top:' + systems.ktxStatusHeight + 'rpx;'" v-if="about.CONFIG_PROJECT_TITLE_PIC">
  7. <image :src="about.CONFIG_PROJECT_TITLE_PIC" mode="heightFix"></image>
  8. </view>
  9. </block>
  10. <view class="top-title" :style="'line-height: '+ systems.navigationHeight + 'rpx;top:' + systems.ktxStatusHeight + 'rpx;'" v-else>
  11. {{about.CONFIG_PROJECT_TITLE?about.CONFIG_PROJECT_TITLE:''}}
  12. </view>
  13. </view>
  14. <view :style="'height: '+ systems.barHeight + 'rpx;'"></view> -->
  15. <!-- <view @click="saoma()" style="z-index: 999;position: relative;">扫码</view> -->
  16. <view class="bg">
  17. <image :src="about.INDEX_PIC"></image>
  18. </view>
  19. <view class="service-person" :style="'top:' + systems.ktxStatusHeight + 'rpx;'">
  20. <view class="ddflex" @click="jumpUrl('/card/index/index')">
  21. <image class="service-person-header" src="../../static/pages/images/userimg.png"></image>
  22. <view>
  23. <view class="service-person-name ddflex">
  24. <view>杜平的微页</view>
  25. <image src="/static/images/rico2.png" class="rico"></image>
  26. </view>
  27. <view class="service-person-number">(工号:106547) 欢迎您来到我的微页</view>
  28. </view>
  29. </view>
  30. <view style="margin: 20rpx 30rpx 0;justify-content: space-between;" class="ddflex">
  31. <view>
  32. <view class="ddflex">
  33. <view class="service-person-tag">中国人寿湖南</view>
  34. <view class="service-person-tag">高级组经理</view>
  35. <view class="service-person-tag">入司10年</view>
  36. </view>
  37. <view class="service-person-options ddflex">
  38. <view class="service-person-option ddflex">
  39. <image src="/static/pages/images/dz.png"></image>
  40. <view>96%</view>
  41. </view>
  42. <view class="service-person-option ddflex">
  43. <image src="/static/pages/images/cy.png"></image>
  44. <view>从业21.6年</view>
  45. </view>
  46. <view class="service-person-option ddflex">
  47. <image src="/static/pages/images/fw.png"></image>
  48. <view>为1678人服务</view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="ddflex">
  53. <view class="service-person-phone">
  54. <image src="../../static/pages/images/dh.png"></image>
  55. <view>电话</view>
  56. </view>
  57. <view class="service-person-phone">
  58. <image src="../../static/pages/images/wx.png"></image>
  59. <view>微信</view>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <view style="height: 610rpx;"></view>
  65. <view v-for="(item, index) in contact" :key="index">
  66. <!-- 弹窗广告 -->
  67. <view style="position: absolute;top:290rpx;left: 0;right: 0;">
  68. <banner v-if="item == 'ad' && bannerShow" :bannerList="bannerList" :url="site" :web="url" :config="about" :couponList="couponList" :officeList="officeList" :districtTemplate="districtTemplate"></banner>
  69. </view>
  70. <district v-if="item == 'king_kong_district' && districtShow" :url="site" :web="url" :districtTemplate="districtTemplate"></district>
  71. </view>
  72. <view class="index-box" style="margin-top: 10rpx;" v-if="hotActivityList.length>0">
  73. <view class="index-box-title">热门活动</view>
  74. <view class="ddflex" style="margin-top: 20rpx;">
  75. <view style="margin-right: 20rpx;">
  76. <image class="pic230" :src="hotActivityList[0].pic"></image>
  77. <image class="pic230" style="margin-top: 20rpx;" :src="hotActivityList[1].pic"></image>
  78. </view>
  79. <image class="pic480" :src="hotActivityList[2].pic"></image>
  80. </view>
  81. </view>
  82. <!-- 参与活动 -->
  83. <view class="index-box" style="margin-top: 50rpx;" v-if="matchList.length>0">
  84. <view class="index-box-title">更多活动</view>
  85. <view class="map-ac">
  86. <scroll-view scroll-x="true" class="map-acs" >
  87. <view class="li" v-for="(item,index) in matchList" :key="index" @click="jumpUrl('/match/activityDetail/activityDetail?id='+item.id)">
  88. <view style="position: relative;border-radius: 20rpx;overflow: hidden;">
  89. <image :src="item.pic ? item.pic : '/static/images/def_zw1.png'" mode="aspectFill"></image>
  90. <view class="ac-type" v-if="item.categoryName">{{ item.categoryName }}</view>
  91. </view>
  92. <view class="ac-title tovers">{{ item.title }}</view>
  93. </view>
  94. </scroll-view>
  95. </view>
  96. </view>
  97. <!-- 投保案例 -->
  98. <view class="index-box" style="margin:0;padding: 30rpx;background-color: #f5f5f5;" v-if="tbalList.length>0">
  99. <view class="index-box-title">投保案例</view>
  100. <view>
  101. <view class="tbal-nav ddflex">
  102. <view :class="'tbal-nav-item '+(tbalIndex==index?'tbal-nav-item-active':'' )" v-for="item,index in tbalList" @click="changeTbalTab(index)">
  103. <view>{{item.name}}</view>
  104. <view class="tbal-nav-label">20~30岁</view>
  105. </view>
  106. <!-- <view class="tbal-nav-item">
  107. <view>形成期</view>
  108. <view class="tbal-nav-label">20~30岁</view>
  109. </view>
  110. <view class="tbal-nav-item">
  111. <view>成长期</view>
  112. <view class="tbal-nav-label">20~30岁</view>
  113. </view>
  114. <view class="tbal-nav-item">
  115. <view>成熟期</view>
  116. <view class="tbal-nav-label">20~30岁</view>
  117. </view> -->
  118. </view>
  119. <block v-if="tbalList[tbalIndex].contentList">
  120. <view class="tbal-item ddflex" v-for="it in tbalList[tbalIndex].contentList" @click="jumpUrl('/topic/alContent/alContent?id='+it.id)">
  121. <image class="tbal-pic" :src="it.pic?it.pic:'/static/images/lj_img.png'"></image>
  122. <view class="flex">
  123. <view class="tbal-title">{{it.title}}</view>
  124. <view class="ddflex">
  125. <view class="ddflex flex">
  126. <view class="tbal-price" >{{it.fieldValues&&it.fieldValues.yearMoney?it.fieldValues.yearMoney:'0'}}</view>
  127. <view class="tbal-price-text">年缴费</view>
  128. </view>
  129. <view class="tbal-line"></view>
  130. <view class="ddflex flex">
  131. <view class="tbal-price" >{{it.fieldValues&&it.fieldValues.allMoney?it.fieldValues.allMoney:'0'}}</view>
  132. <view class="tbal-price-text">总保额 </view>
  133. </view>
  134. </view>
  135. <view class="tbal-btn">去看看</view>
  136. </view>
  137. <view class="tbal-tag" v-if="it.fieldValues&&it.fieldValues.version">{{it.fieldValues.version}}</view>
  138. </view>
  139. </block>
  140. </view>
  141. </view>
  142. <!-- 真实理赔故事 -->
  143. <view class="index-box" v-if="lpalList.length>0">
  144. <view class="index-box-title">真实理赔故事</view>
  145. <view class="map-ac">
  146. <scroll-view scroll-x="true" class="map-acs ddflex" style="height: 430rpx;">
  147. <view class="lpgs-item" v-for="items,indexs in lpalList ">
  148. <image class="lpgs-icon" src="../../static/images/lpgs_icon.png"></image>
  149. <view :class="'lpgs-header '+(indexs%2==0?'lpgs-header-c':'')">
  150. <view>{{items.name}}</view>
  151. </view>
  152. <view class="lpgs-content">
  153. <view class="lpgs-item-content ddflex" v-for="item in items.contentList" @click="jumpUrl('/topic/content/content?id='+item.id)">
  154. <view class="flex" style="min-width: 0;">
  155. <view class="lpgs-item-content-title tovers">{{item.title}}</view>
  156. <view class="lpgs-item-content-look ddflex">
  157. <image src="/static/images/eyes.png"></image>
  158. <view>{{unitFormat(item.browse)}}</view>
  159. </view>
  160. </view>
  161. <image class="lpgs-item-content-pic" :src="item.pic?item.pic:'/static/images/lj_img.png'"></image>
  162. </view>
  163. </view>
  164. </view>
  165. </scroll-view>
  166. </view>
  167. </view>
  168. <!-- 发现 -->
  169. <view class="index-box" style="margin:0;padding: 30rpx;background-color: #f5f5f5;" v-if="fxList.length>0">
  170. <view class="map-ac">
  171. <scroll-view scroll-x="true" class="map-acs ddflex" style="height: 70rpx;">
  172. <view :class="'fx-nav '+(fxIndex==index?'fx-nav-active':'')" v-for="item,index in fxList" @click="changeFxTab(index)">{{item.name}}</view>
  173. </scroll-view>
  174. </view>
  175. <view class="fx-bar">
  176. <view class="fx-header ddflex">
  177. <view class="ddflex">
  178. <view class="fx-header-title">{{fxList[fxIndex].name}}</view>
  179. <view class="fx-header-more">2.2万人转发</view>
  180. </view>
  181. <view class="fx-header-more ddflex" @click="jumpUrl('/topic/contentList/contentList?code='+fxList[fxIndex].code+'&title='+fxList[fxIndex].name)">
  182. 更多
  183. <image src="/static/pages/images/more.png"></image>
  184. </view>
  185. </view>
  186. <view>
  187. <view class="fx-item ddflex" v-for="item in fxContentList" @click="jumpUrl('/topic/content/content?id='+item.id)">
  188. <view class="flex" style="min-width: 0;">
  189. <view class="fx-item-title tovers">{{item.title}}</view>
  190. <view class="ddflex" style="margin-top: 24rpx;">
  191. <view class="fx-item-time">{{formatTime(item.createDate)}}</view>
  192. <view class="fx-item-look ddflex">
  193. <image src="/static/images/eyes.png"></image>
  194. <view>{{unitFormat(item.browse)}}</view>
  195. </view>
  196. </view>
  197. </view>
  198. <image class="fx-item-pic" :src="item.pic?item.pic:'../../static/images/lj_img.png'"></image>
  199. </view>
  200. </view>
  201. </view>
  202. </view>
  203. <switchStore v-if="switchStoreShow && contact.length > 0 && merchant.id" :first="first" :merchant="merchant" :storeShow="storeShow" @onFather="click"></switchStore>
  204. <!-- <component v-for="(item,index) in contact" ></component> -->
  205. <!-- <ad></ad> -->
  206. <block v-if="contactShow">
  207. <view class="spinner">
  208. <view class="spinner-container container1">
  209. <view class="circle1"></view>
  210. <view class="circle2"></view>
  211. <view class="circle3"></view>
  212. <view class="circle4"></view>
  213. </view>
  214. <view class="spinner-container container2">
  215. <view class="circle1"></view>
  216. <view class="circle2"></view>
  217. <view class="circle3"></view>
  218. <view class="circle4"></view>
  219. </view>
  220. <view class="spinner-container container3">
  221. <view class="circle1"></view>
  222. <view class="circle2"></view>
  223. <view class="circle3"></view>
  224. <view class="circle4"></view>
  225. </view>
  226. </view>
  227. <view class="lond">加载中···</view>
  228. </block>
  229. <view class="foot-logo">
  230. <image src="/static/images/zgrs_logo.png"></image>
  231. </view>
  232. <!-- <footer-copyright v-if="logo"></footer-copyright> -->
  233. <contact-button img-url="/static/pages/images/kfico1_1.png" class-name="contact_index" button-text="客服"></contact-button>
  234. <view class="guide" @tap="hideGuide" v-if="first"><image src="/static/pages/images/guide.png" mode="widthFix"></image></view>
  235. <!-- <view class="placeholder-view" :style="'height:' + (bottomBlankHeight + 115) + 'rpx'"></view> -->
  236. <foot channel="home" :isUpdate="isUpdate"></foot>
  237. </view>
  238. </template>
  239. <script>
  240. //index.js
  241. //获取应用实例
  242. const app = getApp();
  243. const req = require('../../utils/request.js');
  244. const api = require('../../utils/api.js');
  245. const utils = require('../../utils/util.js');
  246. const mes = require('../../utils/requestmessage.js');
  247. const route = require('../../utils/route');
  248. const QQMapWX = require("../../utils/qqmap.js");
  249. import foot from '../../components/nav-bar/index';
  250. import footerCopyright from '../../components/footer-copyright/footer-copyright';
  251. import popAd from '../../template/popAd/popAd';
  252. import group from '../../template/activityGroup/activityGroup';
  253. import banner from '../../template/banner/banner';
  254. import bargain from '../../template/bargain/bargain';
  255. import customers from '../../template/customers/customers';
  256. import homecolumn from '../../template/homecolumn/homecolumn';
  257. import joingroup from '../../template/joingroup/joingroup';
  258. import pCategoryList from '../../template/pCategoryList/pCategoryList';
  259. import recommend from '../../template/recommend/recommend';
  260. import seckill from '../../template/seckill/seckill';
  261. import selected from '../../template/selected/selected';
  262. import arrivals from '../../template/arrivals/arrivals';
  263. import hot from '../../template/hot/hot';
  264. import specialTopic from '../../template/specialTopic/specialTopic';
  265. import storeOptions from '../../template/store_options/store_options';
  266. import redEnvelopes from '../../template/red_envelopes/index';
  267. import supplier from '../../template/supplier/supplier';
  268. import district from '../../template/king_kong_district/king_kong_district';
  269. import switchStore from '../../template/switchStore/switchStore';
  270. import suppliers from '../../template/suppliers/suppliers';
  271. import single from '../../template/single/single';
  272. export default {
  273. data() {
  274. return {
  275. skinNotColor: req.public.skinNotColor,
  276. systems: {},
  277. header: req.header,
  278. bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
  279. bannerList: [],
  280. //产品分类列表
  281. page: 1,
  282. //产品列表
  283. merchant: {},
  284. activityGroup: {
  285. products: []
  286. },
  287. couponList: {},//优惠券,
  288. isUpdate: false,
  289. // 是否更新消息
  290. first: true,
  291. //是否显示提示加入我的小程序
  292. isLayerAd: true,
  293. //广告
  294. homeTemplate: [],
  295. //首页栏目配置
  296. pCategoryList: [],
  297. storeShow: true,
  298. templateType: {
  299. module_ad: 'ad',
  300. //广告
  301. module_type_district: 'type_district',
  302. //分类导航
  303. module_king_kong_district: 'king_kong_district', //金刚区
  304. },
  305. isNotice: false,
  306. joingroupList: {
  307. products: []
  308. },
  309. //拼团
  310. bargainList: {
  311. products: []
  312. },
  313. //砍价
  314. customersList: {
  315. products: []
  316. },
  317. //新客
  318. freshen: true,
  319. url: '',
  320. web: '',
  321. site: '',
  322. districtTemplate: {},
  323. contact: [],
  324. seckillList: {
  325. products: []
  326. },
  327. about: {},
  328. Is_Store_Price_Stock: '',
  329. guarantee: [],
  330. animationData: '',
  331. content: '',
  332. popAdList: {},
  333. iscouponAd: false,
  334. logo: false,
  335. top: Boolean,
  336. top_type: Boolean,
  337. switchStoreShow: Boolean,
  338. contactShow: true,
  339. districtShow: false,
  340. bannerShow: false,
  341. officeList: [],//互动
  342. hotActivityList:[],//热门活动
  343. matchList:[],//活动列表
  344. tbalList:[],//投保案例
  345. tbalIndex:0,//投保案例tab
  346. lpalList:[],//理赔案例
  347. fxList:[],//发现
  348. fxIndex:0,
  349. fxContentList:[]
  350. };
  351. },
  352. components: {
  353. foot,
  354. footerCopyright,
  355. banner,
  356. group,
  357. bargain,
  358. popAd,
  359. customers,
  360. homecolumn,
  361. joingroup,
  362. pCategoryList,
  363. recommend,
  364. seckill,
  365. selected,
  366. arrivals,
  367. hot,
  368. specialTopic,
  369. storeOptions,
  370. redEnvelopes,
  371. supplier,
  372. district,
  373. switchStore,
  374. suppliers,
  375. single
  376. },
  377. props: {},
  378. onLoad: async function(options) {
  379. // console.log("扫码进去参数===" + JSON.stringify(options));
  380. // if (options.scene) {
  381. // // this.scene = options.scene || '1290926887903780865';
  382. // this.scene = options.scene;
  383. // await this.loadCodeParams();
  384. // }
  385. // wx.setNavigationBarColor({
  386. // frontColor: '#ffffff',
  387. // backgroundColor: req.public.titleTopBgColor,
  388. // })
  389. // this.getPopAd()
  390. this.query = options;
  391. req.silenceLogin(options.userId, '');
  392. if (options.custom_params) {
  393. let obj = decodeURIComponent(opt.custom_params);
  394. obj = JSON.parse(obj);
  395. // console.log(obj)
  396. req.setStorage('pidCode', obj.userId);
  397. }
  398. if (options.isShare) {
  399. if (options.userId) {
  400. req.setStorage('pidCode', options.userId);
  401. }
  402. }
  403. setInterval(() => {
  404. this.setData({
  405. isNotice: true
  406. });
  407. }, 10000); // this.init();
  408. QQMapWX.initMap();
  409. req.getLocation(res => {
  410. const to = {
  411. latitude: res.latitude,
  412. longitude: res.longitude
  413. };
  414. QQMapWX.reverseGeocoder(to, resp => {
  415. });
  416. });
  417. },
  418. async onShow() {
  419. let _ts = this;
  420. await this.getConfig().then(res => {
  421. });
  422. await this.getHomeTemplateConfig();
  423. uni.setNavigationBarColor({
  424. frontColor: this.skinNotColor?'#000':'#ffffff',
  425. backgroundColor: req.public.titleTopBgColor
  426. });
  427. _ts.setData({
  428. isUpdate: !_ts.isUpdate
  429. });
  430. this.getHotActivity()
  431. this.getMatchList()
  432. this.getTbal()
  433. this.getLpal()
  434. this.getFx()
  435. // console.log('this.freshen=='+this.freshen)
  436. let first = req.getStorage('first');
  437. if (first !== false)
  438. _ts.setData({
  439. first: true
  440. });
  441. else
  442. _ts.setData({
  443. first: false
  444. });
  445. },
  446. onUnload() {
  447. // this.isShowTime = false;
  448. this.clearAllTimer(1);
  449. this.clearAllTimer(2);
  450. this.clearAllTimer(3);
  451. this.clearAllTimer(4);
  452. },
  453. onHide() {
  454. // this.isShowTime = false;
  455. this.clearAllTimer(1);
  456. this.clearAllTimer(2);
  457. this.clearAllTimer(3);
  458. this.clearAllTimer(4);
  459. },
  460. onShareAppMessage: function() {
  461. },
  462. onShareTimeline() {
  463. },
  464. onReachBottom() {},
  465. methods: {
  466. jumpUrl(url){
  467. if(req.isLogins(false)){
  468. uni.navigateTo({
  469. url:url
  470. })
  471. }
  472. },
  473. // 获取热门活动
  474. getHotActivity(){
  475. req.getRequest('/api/banner',{code:'index_hot_activity'},res=>{
  476. this.hotActivityList = res
  477. })
  478. },
  479. // 获取更多活动
  480. getMatchList(){
  481. req.getRequest('/api/match/list',{page:1,limit:10},res=>{
  482. this.matchList = res
  483. })
  484. },
  485. // 获取投保案例
  486. async getTbal(){
  487. this.tbalList = await this.getContentList('toubaoanli')
  488. this.tbalList[this.tbalIndex].contentList = await this.getContentPageList(this.tbalList[this.tbalIndex].code)
  489. this.$forceUpdate()
  490. },
  491. // 获取理赔案例
  492. async getLpal(){
  493. this.lpalList = await this.getContentList('lipeianli')
  494. this.lpalList.map(async item=>{
  495. item.contentList = await this.getContentPageList(item.code)
  496. this.$forceUpdate()
  497. })
  498. },
  499. // 获取发现
  500. async getFx(){
  501. this.fxList = await this.getContentList('faxian')
  502. this.getFxContenteList(this.fxList[this.fxIndex].code)
  503. },
  504. // 获取文章栏目列表
  505. getContentList(code){
  506. return new Promise((r,j)=>{
  507. req.getRequest('/api/content/category/list',{parentCode:code},res=>{
  508. r(res?res:[])
  509. })
  510. })
  511. },
  512. // 获取文章列表
  513. getContentPageList(code){
  514. return new Promise((r,j)=>{
  515. req.getRequest('/api/content/list',{code:code,page:1,limit:2},res=>{
  516. r(res?res:[])
  517. })
  518. })
  519. },
  520. // 获取发现文章列表
  521. getFxContenteList(code){
  522. return new Promise((r,j)=>{
  523. req.getRequest('/api/content/list',{code:code,page:1,limit:10},res=>{
  524. this.fxContentList = res?res:[]
  525. r(res?res:[])
  526. })
  527. })
  528. },
  529. // 投保案例tab切换
  530. async changeTbalTab(index){
  531. if(this.tbalIndex==index) return false;
  532. this.tbalIndex = index
  533. this.tbalList[this.tbalIndex].contentList = await this.getContentPageList(this.tbalList[this.tbalIndex].code)
  534. },
  535. // 发现tab切换
  536. changeFxTab(index){
  537. if(this.fxIndex==index) return false;
  538. this.fxIndex = index
  539. this.getFxContenteList(this.fxList[this.fxIndex].code)
  540. },
  541. async getRqeDatas() {
  542. console.log('getRqeDatas');
  543. let that = this; //多门店
  544. // 金刚区
  545. let district = that.homeTemplate.filter(it => it.module == that.templateType.module_king_kong_district);
  546. if (district && district.length > 0 && district[0].state == 0) {
  547. let data = district[0];
  548. data.content = JSON.parse(district[0].content);
  549. that.districtTemplate = data;
  550. if (data.contentId == 2) {
  551. that.districtShow = true;
  552. }
  553. console.log(that.districtTemplate, '=============');
  554. }
  555. //顶部banner
  556. let ad = that.homeTemplate.filter(it => it.module == that.templateType.module_ad);
  557. if (ad && ad.length > 0 && ad[0].state == 0) {
  558. if (that.freshen) {
  559. await that.getBannerList(ad[0].module, ad[0].contentId);
  560. }
  561. }
  562. that.logo = true;
  563. },
  564. getUrl2(e) {
  565. // 2 普通产品详情 4社区团购产品详情 5优惠券列表 6直播列表 7社区团购列表 9分类列表 10直播间 11拼团列表 12秒杀列表 13砍价列表 14新客列表 15新客详情 16秒杀详情 17砍价详情 18 拼团详情
  566. var dt = e.currentTarget.dataset;
  567. var url = '';
  568. var id = '';
  569. var acid = '';
  570. if (dt.content != '') {
  571. let conunt = dt.content.split('_');
  572. id = conunt[1];
  573. acid = conunt[0];
  574. }
  575. if (dt.type * 1 == 2 && dt.content != '') {
  576. url = 'product/detail/detail?id=' + dt.content;
  577. } else if (dt.type * 1 == 4) {
  578. url = 'product/groupDetail/groupDetail?acid=' + acid + '&id=' + id;
  579. } else if (dt.type * 1 == 5) {
  580. url = 'product/coupon/coupon';
  581. } else if (dt.type * 1 == 6) {
  582. url = 'pages/live/live';
  583. } else if (dt.type * 1 == 7) {
  584. url = 'product/groupList/groupList' + dt.merchant;
  585. } else if (dt.type * 1 == 9 && dt.content != '') {
  586. url = 'product/list/list?id=' + dt.content;
  587. } else if (dt.type * 1 == 10) {
  588. url = 'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=' + dt.content;
  589. // console.log(
  590. // url); // url=`plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${dt.content}`
  591. } else if (dt.type * 1 == 11) {
  592. url = 'activity/group/index/index' + dt.merchant;
  593. } else if (dt.type * 1 == 12) {
  594. url = 'activity/seckill/seckill' + dt.merchant;
  595. } else if (dt.type * 1 == 13) {
  596. url = 'activity/bargain/index/index' + dt.merchant;
  597. } else if (dt.type * 1 == 14) {
  598. url = 'activity/newbornZone/newbornZone' + dt.merchant;
  599. } else if (dt.type * 1 == 15 && dt.content != '') {
  600. url = 'activity/newbornDetails/newbornDetails?acid=' + acid + '&id=' + id;
  601. } else if (dt.type * 1 == 16 && dt.content != '') {
  602. url = 'activity/seckillDetails/seckillDetails?acid=' + acid + '&id=' + id;
  603. } else if (dt.type * 1 == 17 && dt.content != '') {
  604. url = 'activity/bargain/detail/detail?acid=' + acid + '&id=' + id;
  605. } else if (dt.type * 1 == 18 && dt.content != '') {
  606. url = 'activity/group/detail/detail?acid=' + acid + '&id=' + id;
  607. } else {
  608. url = '';
  609. }
  610. if (dt.type * 1 == 6) app.globalData.switchTab(url);
  611. else app.globalData.openPage(url);
  612. this.hideAd();
  613. },
  614. //获取首页模板配置
  615. getHomeTemplateConfig() {
  616. let _ts = this;
  617. let page = 'index';
  618. //荣康模板配置、小店产品==门店产品
  619. // if (this.merchant && this.merchant.type == 5 || this.shopId && this.merchantId) page = 'shopIndex'
  620. req.getRequest(
  621. '/api/template/getTemplate',
  622. {
  623. page: page
  624. },
  625. data => {
  626. let arr = [];
  627. data.forEach(it => {
  628. arr.push(it.module);
  629. });
  630. this.setData({
  631. contact: [...new Set(arr)],
  632. contactShow: false
  633. });
  634. if (this.contact.indexOf('sou') != -1 && this.contact.indexOf('store_options') != -1) {
  635. this.top = false;
  636. } else {
  637. this.top = true;
  638. }
  639. if (this.contact.indexOf('sou') != -1 && this.contact.indexOf('type_district') != -1) {
  640. this.top_type = false;
  641. } else {
  642. this.top_type = true;
  643. }
  644. console.log(this.contact.indexOf('sou') != -1, this.contact.indexOf('store_options') != -1, this.contact.indexOf('type_district') != -1, this.top);
  645. console.log(this.contact);
  646. this.setData({
  647. homeTemplate: data
  648. });
  649. this.getRqeDatas();
  650. }
  651. );
  652. },
  653. getConfig() {
  654. var _this = this;
  655. return new Promise((res, rej) => {
  656. req.g(
  657. '/api/other/config',
  658. data => {
  659. req.setStorage('configRes', JSON.stringify(data));
  660. this.about = data;
  661. if (!data.Index_Store_Confirm || data.Index_Store_Confirm == 0) {
  662. _this.setData({
  663. switchStoreShow: false,
  664. storeShow: false
  665. });
  666. } else {
  667. _this.setData({
  668. switchStoreShow: true
  669. });
  670. }
  671. // console.log(data.Index_Store_Confirm, "====", !data.Index_Store_Confirm, typeof(res
  672. // .Index_Store_Confirm))
  673. uni.setNavigationBarTitle({
  674. // title: res['CONFIG_PROJECT_TITLE'],
  675. title: data['CONFIG_PROJECT_TITLE']
  676. });
  677. // console.log(data.Is_Store_Price_Stock);
  678. if (data.Is_Store_Price_Stock) {
  679. this.Is_Store_Price_Stock = data.Is_Store_Price_Stock;
  680. }
  681. this.setData({
  682. Is_Store_Price_Stock: data.Is_Store_Price_Stock
  683. });
  684. if (data.b2c_service_guarantee && data.b2c_service_guarantee != null) {
  685. this.setData({
  686. guarantee: data.b2c_service_guarantee.split(';').filter(it => {
  687. return (it = it && it.trim());
  688. })
  689. });
  690. }
  691. req.setStorage('appName', data['CONFIG_PROJECT_TITLE']);
  692. req.setStorage('productDiy', data['Product_Foot-Diy']);
  693. res(data);
  694. },
  695. true
  696. );
  697. });
  698. },
  699. merchantFun() {
  700. app.globalData.openPage('pages/nearby/nearby');
  701. },
  702. saoma() {
  703. var _this = this; // 允许从相机和相册扫码
  704. uni.scanCode({
  705. success: res => {
  706. uni.navigateTo({
  707. url: '/' + res.path
  708. }); // this.scene = '1290926887903780865';
  709. this.loadCodeParams();
  710. }
  711. });
  712. },
  713. update(content) {
  714. var that = this;
  715. var animation = uni.createAnimation(); // 旧消息向上平移
  716. animation.translateY(-50).step({
  717. duration: 1000,
  718. timingFunction: 'ease-in'
  719. }); // 为了实现下一条新内容向上平移的效果,必须把内容很快平移到下方,并且不能被用户看见,这里其原理类似轮播图的思路。
  720. // 实现方法:动画时间设置为1ms,过渡效果设置为’动画第一帧就跳至结束状态直到结束‘
  721. animation
  722. .opacity(0)
  723. .translateY(50)
  724. .step({
  725. duration: 1000,
  726. timingFunction: 'step-start'
  727. }); // 新消息向上平移的同时恢复透明
  728. animation
  729. .opacity(1)
  730. .translateY(0)
  731. .step({
  732. duration: 1000,
  733. timingFunction: 'ease-out'
  734. });
  735. that.setData({
  736. animationData: animation.export()
  737. }); // 更新内容的延时必须大于第一步动画时间
  738. setTimeout(() => {
  739. that.setData({
  740. content: content
  741. });
  742. }, 500000);
  743. },
  744. loadCodeParams() {
  745. let _ts = this;
  746. return new Promise((resolve, reject) => {
  747. if (!_ts.scene) {
  748. resolve();
  749. return false;
  750. }
  751. req.getRequest(
  752. '/api/code/params',
  753. {
  754. scene: _ts.scene
  755. },
  756. data => {
  757. req.setStorage('pidCode', data.userId);
  758. resolve();
  759. }
  760. );
  761. });
  762. },
  763. getBannerList(module, contentId) {
  764. //banner图
  765. let that = this;
  766. return new Promise((resolve,reject)=>{
  767. req.getRequest(
  768. '/api/banner',
  769. {
  770. groupId: contentId
  771. },
  772. data => {
  773. if (module == that.templateType.module_ad) {
  774. that.setData({
  775. bannerList: data,
  776. bannerShow: true
  777. });
  778. } else {
  779. that.setData({
  780. popAdList: data[0]
  781. });
  782. }
  783. resolve();
  784. }
  785. );
  786. })
  787. },
  788. clearAllTimer(type) {
  789. // console.log(this.activityGroup, this.joingroupList, this.bargainList, this.customersList);
  790. if (type == 1) {
  791. this.activityGroup.products.forEach(it => clearInterval(it.timer));
  792. this.activityGroup.products.forEach(it => clearInterval(it.times));
  793. } else if (type == 2) {
  794. this.joingroupList.products.forEach(it => clearInterval(it.timer));
  795. this.joingroupList.products.forEach(it => clearInterval(it.times));
  796. } else if (type == 3) {
  797. this.bargainList.products.forEach(it => clearInterval(it.timer));
  798. this.bargainList.products.forEach(it => clearInterval(it.times));
  799. } else if (type == 4) {
  800. this.customersList.products.forEach(it => clearInterval(it.timer));
  801. this.customersList.products.forEach(it => clearInterval(it.times));
  802. } else if (type == 5) {
  803. this.seckillList.products.forEach(it => clearInterval(it.timer));
  804. this.seckillList.products.forEach(it => clearInterval(it.times));
  805. }
  806. },
  807. hideGuide() {
  808. //关闭提示加入我的小程序
  809. this.setData({
  810. first: false
  811. });
  812. req.setStorage('first', false);
  813. },
  814. hideAd() {
  815. //关闭广告
  816. // if(this.data.first==false){
  817. this.setData({
  818. isLayerAd: false
  819. }); // }
  820. app.globalData.isLayerAd = false;
  821. },
  822. click(e) {
  823. // console.log(e)
  824. this.storeShow = e;
  825. },
  826. goUrl(event) {
  827. //跳转链接
  828. let url = event.currentTarget.dataset.url;
  829. app.globalData.openPage(url);
  830. },
  831. unitFormat(data){
  832. return req.unitConverter(data).text
  833. },
  834. formatTime(date){
  835. date = new Date(date.replace(/-/g, '/'))
  836. return utils.formatTime(date).t3
  837. }
  838. },
  839. mounted() {
  840. const systemInfo = uni.getSystemInfoSync();
  841. // px转换到rpx的比例
  842. let pxToRpxScale = 750 / systemInfo.windowWidth;
  843. let systems = {
  844. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  845. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  846. };
  847. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  848. this.systems = systems;
  849. }
  850. };
  851. </script>
  852. <style>
  853. @import './index.css';
  854. </style>