index.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905
  1. <template>
  2. <view id="home" :data-theme="theme" :style="[pageStyle]">
  3. <tui-skeleton v-if="showSkeleton"></tui-skeleton>
  4. <!-- 有网内容 -->
  5. <view v-if="!errorNetwork">
  6. <view class="page-index tui-skeleton page_count" :class="{'bgf':navIndex >0}"
  7. :style="{visibility: showSkeleton ? 'hidden' : 'visible'}">
  8. <!-- 组合组件 -->
  9. <homeComb :bgInfo="bgInfo" v-if="showHomeComb" :dataConfig="homeCombData" @changeTab="changeTab"
  10. :isScrolled="isScrolled" :navIndex="navIndex"></homeComb>
  11. <!-- 顶部搜索框 -->
  12. <headerSearch :isScrolled="isScrolled" v-if="showHeaderSerch" :dataConfig="headerSerchCombData">
  13. </headerSearch>
  14. <!-- 分类 -->
  15. <cateNav v-if="showCateNav" :dataConfig="cateNavData" @changeTab="changeTab"></cateNav>
  16. <view class="page_content skeleton">
  17. <view v-if="navIndex === 0">
  18. <view v-for="(item, index) in styleConfig" :key="index">
  19. <!-- 新闻简报 -->
  20. <news v-if="item.name == 'news'" :dataConfig="item"></news>
  21. <!-- 导航组 -->
  22. <menus v-if="item.name == 'menus'" :dataConfig="item"></menus>
  23. <!-- 文章列表 -->
  24. <articleList v-if="item.name == 'homeArticle'" :dataConfig="item"></articleList>
  25. <!-- 秒杀 -->
  26. <seckill-data v-if="item.name == 'seckill'" :dataConfig="item"></seckill-data>
  27. <!-- 小程序直播 -->
  28. <!-- #ifdef MP -->
  29. <liveBroadcast v-if="item.name == 'liveBroadcast'" :dataConfig="item"></liveBroadcast>
  30. <!-- #endif -->
  31. <!-- 优惠券 -->
  32. <coupon v-if="item.name == 'homeCoupon'" :dataConfig="item"></coupon>
  33. <!-- 图片魔方 -->
  34. <pictureCube v-if="item.name == 'pictureCube'" :dataConfig="item"></pictureCube>
  35. <!-- 热区 -->
  36. <hotSpot v-if="item.name == 'homeHotspot'" :dataConfig="item"></hotSpot>
  37. <!-- 轮播图 -->
  38. <swiperBg v-if="item.name == 'swiperBg'" :dataConfig="item"></swiperBg>
  39. <!-- 视频 -->
  40. <shortVideo v-if="item.name == 'video'" :dataConfig="item"></shortVideo>
  41. <!-- 店铺街 -->
  42. <merchant-list v-if="item.name == 'homeMerchant'" :dataConfig="item"></merchant-list>
  43. <!-- 拼团 -->
  44. <group v-if="item.name == 'group'" :dataConfig="item"></group>
  45. <!-- 积分 -->
  46. <intergralShop v-if="item.name == 'intergral'" :dataConfig="item"></intergralShop>
  47. <!-- 辅助线 -->
  48. <guide v-if="item.name == 'guide'" :dataConfig="item"></guide>
  49. <!-- 富文本-->
  50. <rich-text-editor v-if="item.name == 'richTextEditor'"
  51. :dataConfig="item"></rich-text-editor>
  52. <!-- 辅助空白-->
  53. <blank-page v-if="item.name == 'blankPage'" :dataConfig="item"></blank-page>
  54. <!-- 标题 -->
  55. <home-title v-if="item.name == 'titles'" :dataConfig="item"></home-title>
  56. <!-- 逛逛 -->
  57. <discover v-if="item.name == 'homeDiscover'" :dataConfig="item" :isLogin="isLogin">
  58. </discover>
  59. <!-- 商品列表 -->
  60. <goodList v-if="item.name == 'goodList'" :dataConfig="item" @detail="goDetail"></goodList>
  61. <!-- 选项卡商品列表-->
  62. <homeTab v-if="item.name == 'homeTab'" :dataConfig="item" @detail="goDetail"></homeTab>
  63. </view>
  64. </view>
  65. <!-- 分类页-->
  66. <view class="productList" v-if="navIndex === 1 && sortList.length>0">
  67. <view class="sort acea-row" :class="sortList.length ? '' : 'no_pad'"
  68. :style="{ marginTop: sortMarTop + 'px' }">
  69. <navigator hover-class="none"
  70. :url="'/pages/goods/goods_list/index?cid=' + item.id + '&title=' + item.name"
  71. class="item" v-for="(item, index) in sortList" :key="index">
  72. <view class="pictrue">
  73. <image :src="item.icon" class='slide-image tui-skeleton-rect'></image>
  74. </view>
  75. <view class="text">{{ item.name }}</view>
  76. </navigator>
  77. <view class="item" @click="bindMore()" v-if="sortList.length >= 9">
  78. <view class="pictrues acea-row row-center-wrapper">
  79. <text class="iconfont icon-gengduo2"></text>
  80. </view>
  81. <view class="text">更多</view>
  82. </view>
  83. </view>
  84. </view>
  85. <!-- 推荐商品,分类商品列表-->
  86. <recommend v-if="categoryId>0" ref="recommendIndex" :categoryId='categoryId'
  87. :isShowTitle="isShowTitle" @getRecommendLength="getRecommendLength"></recommend>
  88. <view class='noCommodity' v-if="isNoCommodity&& navIndex > 0">
  89. <view class='pictrue'>
  90. <image :src="urlDomain+'crmebimage/presets/noShopper.png'"></image>
  91. </view>
  92. <text class="text-ccc">暂无商品</text>
  93. </view>
  94. </view>
  95. <!-- #ifdef MP -->
  96. <aTip :isCustom="true" :text="wxText" :borderR="5"></aTip>
  97. <!-- #endif -->
  98. </view>
  99. </view>
  100. <!-- 断网内容 -->
  101. <view v-else>
  102. <view class="error-network">
  103. <image class="img" src="./error-network.png"></image>
  104. <view class="title">网络连接断开</view>
  105. <view class="con">
  106. <view class="label">请检查情况:</view>
  107. <view class="item">· 在设置中是否已开启网络权限</view>
  108. <view class="item">· 当前是否处于弱网环境</view>
  109. <view class="item">· 版本是否过低,升级试试吧</view>
  110. </view>
  111. <view class="btn" @click="reconnect">重新连接</view>
  112. </view>
  113. </view>
  114. <!-- 备案号、授权信息 -->
  115. <!-- #ifdef H5 -->
  116. <view v-show="globalData.authorizeFilingNum || globalData.authorizeInfo" class="mt-40 mb-40rpx">
  117. <view @click="toInternet" class="text-center text-24rpx text--w111-666 mb-24">
  118. {{globalData.authorizeFilingNum}}
  119. </view>
  120. <view class="text-center text-24rpx text--w111-666">{{globalData.authorizeInfo}}</view>
  121. </view>
  122. <!-- #endif -->
  123. <!-- 底部导航距离,做兼容处理的-->
  124. <view v-if="bottomNavigationIsCustom" class="footerBottom"></view>
  125. <pageFooter></pageFooter>
  126. <!-- 优惠券弹窗 -->
  127. <coupon-dialog :urlDomain="urlDomain" v-if="couponModal" :couponModal="couponModal"
  128. @on-close="closeDialog"></coupon-dialog>
  129. </view>
  130. </template>
  131. <script>
  132. // +----------------------------------------------------------------------
  133. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  134. // +----------------------------------------------------------------------
  135. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  136. // +----------------------------------------------------------------------
  137. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  138. // +----------------------------------------------------------------------
  139. // | Author: CRMEB Team <admin@crmeb.com>
  140. // +----------------------------------------------------------------------
  141. import Cache from '../../../utils/cache.js';
  142. import tuiSkeleton from '@/components/base/tui-skeleton.vue';
  143. import liveBroadcast from '@/components/homeIndex/liveBroadcast';
  144. import merchantList from '@/components/homeIndex/merchant.vue'
  145. import homeComb from '@/components/homeIndex/homeComb';
  146. import recommend from "@/components/base/recommend.vue";
  147. import seckillData from "@/components/homeIndex/seckill.vue";
  148. import aTip from './components/addTips.vue';
  149. import couponDialog from "@/components/homeIndex/couponDialog.vue"
  150. import coupon from "@/components/homeIndex/coupon.vue";
  151. import menus from "@/components/homeIndex/menus.vue";
  152. import pictureCube from '@/components/homeIndex/pictureCube'
  153. import news from '@/components/homeIndex/news'
  154. import goodList from '@/components/homeIndex/goodList'
  155. import guide from '@/components/homeIndex/guide';
  156. import articleList from '@/components/homeIndex/articleList'
  157. import swiperBg from '@/components/homeIndex/swiperBg'
  158. import headerSearch from '@/components/homeIndex/headerSearch';
  159. import cateNav from '@/components/homeIndex/cateNav';
  160. import richTextEditor from '@/components/homeIndex/richTextEditor';
  161. import shortVideo from '@/components/homeIndex/video';
  162. import homeTab from '@/components/homeIndex/homeTab';
  163. import discover from '@/components/homeIndex/discover';
  164. import blankPage from '@/components/homeIndex/blankPage';
  165. import homeTitle from '@/components/homeIndex/title';
  166. import hotSpot from '@/components/homeIndex/hotSpot.vue';
  167. import group from "@/components/homeIndex/group.vue";
  168. import pageFooter from "@/components/pageFooter/index.vue";
  169. import intergralShop from "@/components/homeIndex/intergralShop.vue";
  170. import {
  171. getIndexData,
  172. getAppVersion,
  173. getCategoryThird,
  174. getDiy
  175. } from '@/api/api.js';
  176. // #ifdef MP-WEIXIN || APP-PLUS
  177. import {
  178. getTemlIds
  179. } from '@/api/api.js';
  180. // #endif
  181. import {
  182. mapGetters
  183. } from "vuex";
  184. import {
  185. silenceBindingSpread,
  186. } from '@/utils/index.js';
  187. import animationType from '@/utils/animationType.js'
  188. import {
  189. goProductDetail
  190. } from "@/libs/order";
  191. import onShare from "@/mixins/onShare";
  192. const arrTemp = ["beforePay", "afterPay", "createBargain", "pink"];
  193. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  194. let app = getApp();
  195. export default {
  196. mixins: [onShare],
  197. computed: mapGetters(['isLogin', 'uid', 'globalData', 'bottomNavigationIsCustom']),
  198. components: {
  199. aTip,
  200. merchantList,
  201. homeComb,
  202. recommend,
  203. tuiSkeleton,
  204. seckillData,
  205. pageFooter,
  206. liveBroadcast,
  207. couponDialog,
  208. coupon,
  209. menus,
  210. pictureCube,
  211. news,
  212. goodList,
  213. articleList,
  214. swiperBg,
  215. headerSearch,
  216. cateNav,
  217. guide,
  218. richTextEditor,
  219. shortVideo,
  220. homeTab,
  221. discover,
  222. blankPage,
  223. homeTitle,
  224. hotSpot,
  225. group,
  226. intergralShop
  227. },
  228. data() {
  229. return {
  230. urlDomain: this.$Cache.get("imgHost"),
  231. isNoCommodity: false,
  232. isScrolled: false, //是否开始滚动
  233. categoryId: 0,
  234. showSkeleton: true, //骨架屏显示隐藏
  235. isNodes: 0, //控制什么时候开始抓取元素节点,只要数值改变就重新抓取
  236. statusBarHeight: statusBarHeight,
  237. navIndex: 0, //判断首页显示内容,1显示分类页和商品,0首页
  238. listActive: 0, // 当前选中项
  239. theme: app.globalData.theme,
  240. imgHost: '', //图片域名地址
  241. appUpdate: {},
  242. wxText: "点击添加到我的小程序,微信首页下拉即可访问商城。",
  243. locationContent: '授权位置信息,提供完整服务',
  244. sortMpTop: 0,
  245. // #ifdef APP-PLUS || MP
  246. isFixed: true,
  247. // #endif
  248. // #ifdef H5
  249. isFixed: false,
  250. // #endif
  251. domOffsetTop: 50,
  252. sortList: [],
  253. sortMarTop: 0,
  254. domHeight: 0,
  255. cateNavActive: 0,
  256. couponModal: false,
  257. styleConfig: [], //DIY数据
  258. diyId: 0, //DIYID
  259. homeCombData: {}, //组合组件数据
  260. showCateNav: false, //是否显示分类导航组件
  261. cateNavData: {}, //分类导航组件数据
  262. showHomeComb: false, //是否显示组合
  263. showHeaderSerch: false, //是否显示搜索框
  264. headerSerchCombData: {}, //搜索框对象
  265. isShowTitle: false, //是否显示头部标题,同时也判断是否展示分类下的商品列表
  266. bgColor: '', //背景颜色
  267. bgPic: '', //背景图片
  268. bgTabVal: '', //背景图片样式
  269. windowHeight: 0,
  270. pageStyle: {},
  271. isDefault: 1, //是否首页,1是,0不是
  272. errorNetwork: false, //是否有网络
  273. bgInfo: {
  274. colorPicker: '#f5f5f5',
  275. isBgColor: 1,
  276. },
  277. }
  278. },
  279. //下拉刷新
  280. onPullDownRefresh() {
  281. // #ifdef APP-PLUS
  282. setTimeout(() => {
  283. uni.reLaunch({
  284. url: "/pages/index/index"
  285. });
  286. uni.stopPullDownRefresh();
  287. }, 1000)
  288. // #endif
  289. },
  290. onLoad(options) {
  291. // #ifdef APP-PLUS
  292. //app刚进入检测有无网络
  293. this.snycNetWork();
  294. //APP版本检测
  295. this.appVersionConfig();
  296. // #endif
  297. //获取浏览器id
  298. this.getOptionData(options)
  299. //首页数据加载
  300. this.getIndexConfig();
  301. let that = this;
  302. this.$nextTick(function() {
  303. uni.getSystemInfo({
  304. success: function(res) {
  305. that.windowHeight = res.windowHeight;
  306. }
  307. });
  308. })
  309. // #ifdef MP || APP-PLUS
  310. // this.getTemlIds()
  311. // #endif
  312. },
  313. onShow() {
  314. let self = this;
  315. // #ifdef APP-PLUS
  316. setTimeout(() => {
  317. if (self.appUpdate.openUpgrade == 'true') {
  318. self.appVersionConfig();
  319. }
  320. }, 1000)
  321. // #endif
  322. //新人礼的展示判断
  323. let newGift = self.$Cache.get('newGift') ? JSON.parse(self.$Cache.get('newGift')) : [];
  324. self.couponModal = newGift.length ? true : false;
  325. },
  326. // 滚动监听
  327. onPageScroll(e) {
  328. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  329. uni.$emit('scroll');
  330. if (e.scrollTop > this.domOffsetTop) {
  331. this.isScrolled = true;
  332. }
  333. if (e.scrollTop < this.domOffsetTop) {
  334. this.$nextTick(() => {
  335. this.isScrolled = false;
  336. });
  337. }
  338. },
  339. methods: {
  340. //获取扫码或者浏览器传来的值
  341. getOptionData(options) {
  342. let diyid = 0;
  343. if (options.hasOwnProperty('id') || options.scene) {
  344. if (options.scene) { // 仅仅小程序扫码进入
  345. let value = this.$util.getUrlParams(decodeURIComponent(options.scene));
  346. this.$store.commit('Change_Spread', value.sd);
  347. //分销绑定
  348. silenceBindingSpread(this.isLogin, value.sd);
  349. diyid = value.id ? value.id : 0;
  350. } else {
  351. diyid = options.id ? options.id : 0;
  352. this.$store.commit('Change_Spread', options.sd);
  353. //分销绑定
  354. silenceBindingSpread(this.isLogin, options.sd);
  355. }
  356. }
  357. //diy数据加载
  358. this.diyData(diyid, false);
  359. },
  360. //备案授权跳转
  361. toInternet() {
  362. window.open('https://beian.miit.gov.cn/#/Integrated/index')
  363. },
  364. //app刚进入检测有无网络
  365. snycNetWork() {
  366. uni.getNetworkType({
  367. success: res => {
  368. //res.networkType === 'none'无网络
  369. this.errorNetwork = res.networkType === 'none';
  370. //如果没有网络,清除骨架屏
  371. if (this.errorNetwork) this.reloadData();
  372. }
  373. });
  374. },
  375. // 断网后重新链接
  376. reconnect() {
  377. uni.getNetworkType({
  378. success: res => {
  379. this.errorNetwork = res.networkType === 'none';
  380. if (!this.errorNetwork) {
  381. setTimeout(() => {
  382. uni.reLaunch({
  383. url: "/pages/index/index"
  384. });
  385. }, 1000)
  386. }
  387. }
  388. });
  389. },
  390. /**
  391. * 获取DIY
  392. * @param {number} id
  393. * @param {boolean} type 区分是否是微页面
  394. */
  395. diyData(id, type) {
  396. let that = this;
  397. that.styleConfig = []
  398. uni.showLoading({
  399. title: '加载中...'
  400. });
  401. getDiy(id).then(res => {
  402. that.errorNetwork = false;
  403. uni.setNavigationBarTitle({
  404. title: res.data.title
  405. });
  406. uni.setNavigationBarColor({
  407. //必须要16进制小写
  408. frontColor: res.data.titleColor,
  409. backgroundColor: res.data.titleBgColor.toString().toLowerCase(),
  410. })
  411. let data = res.data;
  412. that.diyId = res.data.id;
  413. that.isDefault = data.isDefault; //是否是首页,1是,0不是
  414. that.styleConfig = that.$util.objToArr(res.data.value);
  415. this.bgInfo.isBgColor = data.isBgColor
  416. this.bgInfo.colorPicker = data.colorPicker
  417. that.pageStyle = {
  418. 'background-color': data.isBgColor === 1 ? res.data.colorPicker : '',
  419. 'background-image': data.isBgPic === 1 ? `url(${res.data.bgPic})` : '',
  420. 'background-repeat': res.data.bgTabVal === 1 ? 'repeat-y' : 'no-repeat',
  421. 'background-size': res.data.bgTabVal === 2 ? 'cover' : 'contain'
  422. };
  423. uni.hideLoading();
  424. if (type) {
  425. that.styleConfig.forEach((item) => {
  426. if (item.name == 'headerSerch' || item.name == 'homeComb' || item.name ==
  427. 'tabNav') {
  428. that.styleConfig.splice(index, 1);
  429. }
  430. });
  431. } else {
  432. that.styleConfig.forEach((item) => {
  433. if (item.name === 'tabNav') {
  434. that.showCateNav = true;
  435. that.cateNavData = item;
  436. }
  437. if (item.name === 'homeComb') {
  438. that.showHomeComb = true
  439. that.homeCombData = item;
  440. }
  441. if (item.name === 'headerSerch') {
  442. that.showHeaderSerch = true
  443. that.headerSerchCombData = item;
  444. }
  445. });
  446. }
  447. setTimeout(() => {
  448. that.isNodes++;
  449. }, 100);
  450. }).catch(err => {
  451. return that.$util.Tips({
  452. title: err
  453. });
  454. uni.hideLoading();
  455. });
  456. },
  457. bindMore() {
  458. uni.setStorageSync('cateNavActive', this.cateNavActive);
  459. uni.setStorageSync('categoryId', this.categoryId);
  460. uni.switchTab({
  461. url: `/pages/goods_cate/index`
  462. })
  463. },
  464. getRecommendLength(e) {
  465. this.isNoCommodity = e == 0 ? true : false;
  466. },
  467. // 导航分类切换
  468. changeTab(index, item) {
  469. //type=0微页面,1分类,2首页
  470. this.cateNavActive = index;
  471. if (item.type == 1) {
  472. this.navIndex = 1;
  473. if (!item.val) {
  474. this.sortList = [];
  475. this.categoryId = 0;
  476. this.$util.Tips({
  477. title: "请在平台端选择商品分类!确保加载商品分类数据。"
  478. });
  479. return;
  480. } else {
  481. getCategoryThird(item.val).then(res => {
  482. this.sortList = res.data;
  483. // #ifdef H5
  484. self.sortMarTop = 10;
  485. // #endif
  486. });
  487. this.categoryId = item.val;
  488. this.isShowTitle = false;
  489. }
  490. } else if (item.type == 0) {
  491. this.navIndex = 0;
  492. this.isShowTitle = true;
  493. this.categoryId = 0;
  494. if (!item.val) {
  495. return this.$util.Tips({
  496. title: "请在平台端选择微页面链接!确保加载微页面数据。"
  497. });
  498. } else {
  499. this.styleConfig = [];
  500. this.diyData(item.val, true);
  501. }
  502. } else {
  503. this.categoryId = 0;
  504. this.navIndex = 0;
  505. this.styleConfig = [];
  506. this.diyData(item.val, false);
  507. }
  508. },
  509. toNewsList() {
  510. uni.navigateTo({
  511. animationType: animationType.type,
  512. animationDuration: animationType.duration,
  513. url: '/pages/goods/news_list/index'
  514. })
  515. },
  516. //清除骨架屏
  517. reloadData() {
  518. this.showSkeleton = false;
  519. },
  520. getElementData(el, callback) {
  521. uni.createSelectorQuery().in(this).selectAll(el).boundingClientRect().exec((data) => {
  522. callback(data[0]);
  523. });
  524. },
  525. xieyiApp() {
  526. uni.navigateTo({
  527. url: '/pages/users/web_page/index?webUel=https://admin.java.crmeb.net/useragreement/xieyi.html&title=协议内容'
  528. })
  529. },
  530. // #ifdef APP-PLUS
  531. xieyiApp() {
  532. uni.navigateTo({
  533. animationType: animationType.type,
  534. animationDuration: animationType.duration,
  535. url: '/pages/users/web_page/index?webUel=https://admin.java.crmeb.net/useragreement/xieyi.html&title=协议内容'
  536. })
  537. },
  538. // #endif
  539. // #ifdef MP || APP-PLUS
  540. getTemlIds() {
  541. for (var i in arrTemp) {
  542. this.getTem(arrTemp[i]);
  543. }
  544. },
  545. getTem(data) {
  546. getTemlIds({
  547. type: data
  548. }).then(res => {
  549. if (res.data) {
  550. let arr = res.data.map((item) => {
  551. return item.tempId
  552. })
  553. wx.setStorageSync('tempID' + data, arr);
  554. }
  555. });
  556. },
  557. // #endif
  558. // 首页数据
  559. getIndexConfig: function() {
  560. let that = this;
  561. getIndexData().then(res => {
  562. let imgHost = res.data.logoUrl.split('crmebimage')[0];
  563. that.imgHost = imgHost;
  564. that.$Cache.set('imgHost', imgHost + '/');
  565. // #ifdef H5 || APP-PLUS
  566. that.$store.commit("SET_CHATURL", res.data.yzfUrl);
  567. Cache.set('chatUrl', res.data.yzfUrl);
  568. // #endif
  569. Cache.setItem({
  570. name: 'platChatConfig',
  571. value: {
  572. servicePhone: res.data.consumerHotline, //客服电话
  573. serviceLink: res.data.consumerH5Url, //云智服
  574. serviceType: res.data.consumerType //客服类型四选一
  575. }
  576. });
  577. this.reloadData();
  578. }).catch(err => {
  579. return this.$util.Tips({
  580. title: err
  581. });
  582. });
  583. },
  584. appVersionConfig() {
  585. var that = this;
  586. //app升级
  587. // 获取本地应用资源版本号
  588. getAppVersion().then(res => {
  589. that.$set(that.appUpdate, 'androidAddress', res.data.androidAddress);
  590. that.$set(that.appUpdate, 'appVersion', res.data.appVersion);
  591. that.$set(that.appUpdate, 'iosAddress', res.data.iosAddress);
  592. that.$set(that.appUpdate, 'openUpgrade', res.data.openUpgrade);
  593. plus.runtime.getProperty(plus.runtime.appid, function(inf) {
  594. let nowVersion = (inf.version).split('.').join('');
  595. let appVersion = (res.data.appVersion).split('.').join('');
  596. uni.getSystemInfo({
  597. success: (res) => {
  598. if (appVersion > nowVersion) {
  599. uni.showModal({
  600. title: '更新提示',
  601. content: '发现新版本,是否前去下载?',
  602. showCancel: that.appUpdate.openUpgrade == '1' ?
  603. true : false,
  604. cancelColor: '#eeeeee',
  605. confirmColor: '#FF0000',
  606. success(response) {
  607. if (response.confirm) {
  608. switch (res.platform) {
  609. case "android":
  610. plus.runtime.openURL(that
  611. .appUpdate
  612. .androidAddress);
  613. break;
  614. case "ios":
  615. plus.runtime.openURL(encodeURI(
  616. that.appUpdate
  617. .iosAddress));
  618. break;
  619. }
  620. }
  621. }
  622. });
  623. }
  624. }
  625. })
  626. });
  627. })
  628. },
  629. // 微信分享;
  630. setOpenShare: function(data) {
  631. let that = this;
  632. if (that.$wechat.isWeixin()) {
  633. let configAppMessage = {
  634. desc: this.globalData.companyName,
  635. title: this.globalData.companyName,
  636. link: location.href
  637. };
  638. that.$wechat.wechatEvevt(["updateAppMessageShareData", "updateTimelineShareData"],
  639. configAppMessage);
  640. }
  641. },
  642. stopTouchMove() {
  643. return true //禁止新闻swiper手动滑动
  644. },
  645. closeDialog() {
  646. this.couponModal = false;
  647. this.$Cache.clear('newGift');
  648. },
  649. goDetail(item) {
  650. goProductDetail(item.id, 0, '')
  651. },
  652. },
  653. mounted() {
  654. let query = uni.createSelectorQuery().in(this);
  655. query.select("#home").boundingClientRect();
  656. query.exec(res => {
  657. this.domHeight = res[0].height;
  658. })
  659. },
  660. }
  661. </script>
  662. <style>
  663. page {
  664. height: auto;
  665. display: flex;
  666. flex-direction: column;
  667. height: 100%;
  668. /* #ifdef H5 */
  669. background-color: #fff;
  670. /* #endif */
  671. }
  672. </style>
  673. <style lang="scss" scoped>
  674. .error-network {
  675. position: fixed;
  676. left: 0;
  677. top: 0;
  678. display: flex;
  679. flex-direction: column;
  680. align-items: center;
  681. width: 100%;
  682. height: 100%;
  683. padding-top: 40rpx;
  684. background: #fff;
  685. padding-top: 30%;
  686. .img {
  687. width: 414rpx;
  688. height: 336rpx;
  689. }
  690. .title {
  691. position: relative;
  692. top: -40rpx;
  693. font-size: 32rpx;
  694. color: #666;
  695. }
  696. .con {
  697. font-size: 24rpx;
  698. color: #999;
  699. .label {
  700. margin-bottom: 20rpx;
  701. }
  702. .item {
  703. margin-bottom: 20rpx;
  704. }
  705. }
  706. .btn {
  707. display: flex;
  708. align-items: center;
  709. justify-content: center;
  710. width: 508rpx;
  711. height: 86rpx;
  712. margin-top: 100rpx;
  713. border: 1px solid #d74432;
  714. color: #e93323;
  715. font-size: 30rpx;
  716. border-radius: 120rpx;
  717. }
  718. }
  719. .ysize {
  720. background-size: 100%;
  721. }
  722. .fullsize {
  723. background-size: 100% 100%;
  724. }
  725. .repeat {
  726. background-repeat: repeat;
  727. }
  728. .noRepeat {
  729. background-repeat: no-repeat;
  730. }
  731. .noCommodity {
  732. margin-top: 30%;
  733. }
  734. .icon-gengduo1 {
  735. color: #F8F8F8;
  736. }
  737. .pageIndex {
  738. padding: 0 24rpx;
  739. }
  740. .productList {
  741. background-color: #F5F5F5;
  742. margin-top: 20rpx;
  743. // min-height: 70vh;
  744. .sort {
  745. width: 710rpx;
  746. max-height: 380rpx;
  747. background: rgba(255, 255, 255, 1);
  748. border-radius: 16rpx;
  749. padding: 0rpx 0rpx 20rpx 0rpx !important;
  750. flex-wrap: wrap;
  751. margin: 25rpx auto 0 auto;
  752. &.no_pad {
  753. padding: 0;
  754. }
  755. .item {
  756. width: 20%;
  757. margin-top: 20rpx;
  758. text-align: center;
  759. .pictrues {
  760. width: 90rpx;
  761. height: 90rpx;
  762. background: #F5F5F5;
  763. border-radius: 50%;
  764. margin: 0 auto;
  765. }
  766. .pictrue {
  767. width: 90rpx;
  768. height: 90rpx;
  769. background: #F5F5F5;
  770. border-radius: 50%;
  771. margin: 0 auto;
  772. }
  773. .slide-image {
  774. width: 90rpx;
  775. height: 90rpx;
  776. border-radius: 50%;
  777. overflow: hidden;
  778. }
  779. /deep/ .easy-loadimage,
  780. uni-image,
  781. .easy-loadimage {
  782. width: 90rpx;
  783. height: 90rpx;
  784. display: inline-block;
  785. }
  786. .text {
  787. color: #272727;
  788. font-size: 24rpx;
  789. margin-top: 10rpx;
  790. // overflow: hidden;
  791. white-space: nowrap;
  792. text-overflow: ellipsis;
  793. }
  794. }
  795. }
  796. }
  797. .productList .list {
  798. padding: 0 20rpx;
  799. }
  800. .productList .list.on {
  801. background-color: #fff;
  802. border-top: 1px solid #f6f6f6;
  803. }
  804. .productList .list .item {
  805. width: 345rpx;
  806. margin-top: 20rpx;
  807. background-color: #fff;
  808. border-radius: 10rpx;
  809. .name {
  810. display: flex;
  811. align-items: center;
  812. .name_text {
  813. display: inline-block;
  814. max-width: 200rpx;
  815. }
  816. }
  817. }
  818. .page-index {
  819. display: flex;
  820. flex-direction: column;
  821. min-height: 100%;
  822. .page_content {
  823. overflow-x: hidden;
  824. // background-color: #f5f5f5;
  825. .swiper {
  826. position: relative;
  827. width: 100%;
  828. height: 246rpx;
  829. margin: 0 auto;
  830. border-radius: 10rpx;
  831. overflow: hidden;
  832. margin-bottom: 25rpx;
  833. /* #ifdef MP */
  834. margin-top: 20rpx;
  835. /* #endif */
  836. swiper,
  837. swiper-item,
  838. .slide-image,
  839. image {
  840. width: 100%;
  841. height: 246rpx;
  842. border-radius: 10rpx;
  843. }
  844. }
  845. }
  846. }
  847. .fixed {
  848. z-index: 100;
  849. position: fixed;
  850. left: 0;
  851. top: 0;
  852. background: linear-gradient(90deg, red 50%, #ff5400 100%);
  853. }
  854. .menu-txt {
  855. font-size: 24rpx;
  856. color: #454545;
  857. }
  858. </style>