You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

926 lines
25 KiB

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