homeIndex.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. <template>
  2. <view id="home" :data-theme="theme" :style="[pageStyle]">
  3. <tui-skeleton v-if="showSkeleton"></tui-skeleton>
  4. <!-- 有网内容 -->
  5. <view class="page-index tui-skeleton page_count" :class="{'bgf':navIndex >0}"
  6. :style="{visibility: showSkeleton ? 'hidden' : 'visible'}">
  7. <!-- 组合组件 -->
  8. <merHomeComb :bgInfo="bgInfo" v-if="showHomeComb" :dataConfig="homeCombData" :isScrolled="isScrolled" :navIndex="navIndex"
  9. :merId="merId">
  10. </merHomeComb>
  11. <!-- 顶部搜索框 -->
  12. <headerSearch :isScrolled="isScrolled" v-if="showHeaderSerch" :dataConfig="headerSerchCombData" :merId="merId"></headerSearch>
  13. <view class="page_content skeleton">
  14. <view v-if="navIndex === 0">
  15. <view v-for="(item, index) in styleConfig" :key="index">
  16. <!-- 导航组 -->
  17. <merHome v-if="item.name == 'homeStore'" :dataConfig="item" class="tui-skeleton-rect"
  18. :merchantInfo="merchantAPPInfo" :merId="merId" :isHome="true"></merHome>
  19. <!-- 导航组 -->
  20. <menus v-if="item.name == 'menus'" :dataConfig="item"></menus>
  21. <!-- 秒杀 -->
  22. <seckill-data v-if="item.name == 'seckill'" :dataConfig="item" :merId="merId"></seckill-data>
  23. <!-- 小程序直播 -->
  24. <!-- #ifdef MP -->
  25. <liveBroadcast v-if="item.name == 'liveBroadcast'" :dataConfig="item"></liveBroadcast>
  26. <!-- #endif -->
  27. <!-- 优惠券 -->
  28. <coupon v-if="item.name == 'homeCoupon'" :dataConfig="item" :merId="merId"></coupon>
  29. <!-- 图片魔方 -->
  30. <pictureCube v-if="item.name == 'pictureCube'" :dataConfig="item"></pictureCube>
  31. <!-- 热区 -->
  32. <hotSpot v-if="item.name == 'homeHotspot'" :dataConfig="item"></hotSpot>
  33. <!-- 轮播图 -->
  34. <swiperBg v-if="item.name == 'swiperBg'" :dataConfig="item"></swiperBg>
  35. <!-- 视频 -->
  36. <shortVideo v-if="item.name == 'video'" :dataConfig="item"></shortVideo>
  37. <!-- 拼团 -->
  38. <group v-if="item.name == 'group'" :dataConfig="item" :merId="merId"></group>
  39. <!-- 辅助线 -->
  40. <guide v-if="item.name == 'guide'" :dataConfig="item"></guide>
  41. <!-- 富文本-->
  42. <rich-text-editor v-if="item.name == 'richTextEditor'" :dataConfig="item"></rich-text-editor>
  43. <!-- 辅助空白-->
  44. <blank-page v-if="item.name == 'blankPage'" :dataConfig="item"></blank-page>
  45. <!-- 标题 -->
  46. <home-title v-if="item.name == 'titles'" :dataConfig="item"></home-title>
  47. <!-- 商品列表 -->
  48. <goodList v-if="item.name == 'goodList'" :dataConfig="item" @detail="goDetail" :merId="merId">
  49. </goodList>
  50. <!-- 选项卡商品列表-->
  51. <homeTab v-if="item.name == 'homeTab'" :dataConfig="item" @detail="goDetail" :merId="merId">
  52. </homeTab>
  53. </view>
  54. </view>
  55. <!-- 底部导航距离,做兼容处理的-->
  56. <view class="footerBottom"></view>
  57. </view>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. // +----------------------------------------------------------------------
  63. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  64. // +----------------------------------------------------------------------
  65. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  66. // +----------------------------------------------------------------------
  67. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  68. // +----------------------------------------------------------------------
  69. // | Author: CRMEB Team <admin@crmeb.com>
  70. // +----------------------------------------------------------------------
  71. // import Cache from '../../utils/cache';
  72. import tuiSkeleton from '@/components/base/tui-skeleton.vue';
  73. import liveBroadcast from '@/components/homeIndex/liveBroadcast';
  74. import merHomeComb from '@/components/homeIndex/merHomeComb.vue';
  75. import recommend from "@/components/base/recommend.vue";
  76. import seckillData from "@/components/homeIndex/seckill.vue";
  77. import coupon from "@/components/homeIndex/coupon.vue";
  78. import menus from "@/components/homeIndex/menus.vue";
  79. import pictureCube from '@/components/homeIndex/pictureCube'
  80. import goodList from '@/components/homeIndex/goodList'
  81. import guide from '@/components/homeIndex/guide';
  82. import swiperBg from '@/components/homeIndex/swiperBg'
  83. import headerSearch from '@/components/homeIndex/headerSearch';
  84. import richTextEditor from '@/components/homeIndex/richTextEditor';
  85. import shortVideo from '@/components/homeIndex/video';
  86. import homeTab from '@/components/homeIndex/homeTab';
  87. import blankPage from '@/components/homeIndex/blankPage';
  88. import homeTitle from '@/components/homeIndex/title';
  89. import hotSpot from '@/components/homeIndex/hotSpot.vue';
  90. import group from "@/components/homeIndex/group.vue";
  91. import pageFooter from "@/components/pageFooter/index.vue";
  92. import merHome from '@/components/merHome/index.vue'
  93. import {
  94. getMerDiyInfoApi,
  95. } from '@/api/merchant.js';
  96. import {
  97. mapGetters
  98. } from "vuex";
  99. import {
  100. goProductDetail
  101. } from "@/libs/order";
  102. let app = getApp();
  103. export default {
  104. computed: mapGetters(['isLogin', 'uid', 'globalData', 'bottomNavigationIsCustom', 'merchantAPPInfo']),
  105. components: {
  106. merHomeComb,
  107. recommend,
  108. tuiSkeleton,
  109. seckillData,
  110. pageFooter,
  111. liveBroadcast,
  112. coupon,
  113. menus,
  114. pictureCube,
  115. goodList,
  116. swiperBg,
  117. headerSearch,
  118. guide,
  119. richTextEditor,
  120. shortVideo,
  121. homeTab,
  122. blankPage,
  123. homeTitle,
  124. hotSpot,
  125. group,
  126. merHome
  127. },
  128. props: {
  129. merId: { // 商户id
  130. type: Number,
  131. default: 0
  132. },
  133. isScrolled: { //是否开始滚动
  134. type: Boolean,
  135. default: false
  136. },
  137. diyId: { //模板 Id
  138. type: Number,
  139. default: 0
  140. }
  141. },
  142. watch: {
  143. merId: {
  144. handler(newValue, oldValue) {
  145. this.diyData();
  146. },
  147. immediate: true
  148. }
  149. },
  150. data() {
  151. return {
  152. showSkeleton: true, //骨架屏显示隐藏
  153. isNodes: 0, //控制什么时候开始抓取元素节点,只要数值改变就重新抓取
  154. navIndex: 0, //判断首页显示内容,1显示分类页和商品,0首页
  155. theme: app.globalData.theme,
  156. styleConfig: [], //DIY数据
  157. homeCombData: {}, //组合组件数据
  158. showHomeComb: false, //是否显示组合
  159. showHeaderSerch: false, //是否显示搜索框
  160. headerSerchCombData: {}, //搜索框对象
  161. bgPic: '', //背景图片
  162. bgTabVal: '', //背景图片样式
  163. windowHeight: 0,
  164. pageStyle: {},
  165. where: {
  166. keyword: '',
  167. priceOrder: '',
  168. salesOrder: '',
  169. page: 1,
  170. limit: 10,
  171. cid: 0,
  172. merId: 0,
  173. maxPrice: 0,
  174. minPrice: 0
  175. },
  176. loading: false,
  177. loadend: false,
  178. bgInfo:{
  179. colorPicker:'#f5f5f5',
  180. isBgColor:1,
  181. },
  182. }
  183. },
  184. onLoad(options) {
  185. //diy数据加载
  186. this.diyData();
  187. let that = this;
  188. this.$nextTick(function() {
  189. uni.getSystemInfo({
  190. success: function(res) {
  191. that.windowHeight = res.windowHeight;
  192. }
  193. });
  194. })
  195. },
  196. methods: {
  197. /**
  198. * 获取DIY
  199. * @param {number} id
  200. * @param {boolean} type 区分是否是微页面
  201. */
  202. diyData() {
  203. let that = this;
  204. that.styleConfig = []
  205. uni.showLoading({
  206. title: '加载中...'
  207. });
  208. getMerDiyInfoApi(this.merId, this.diyId).then(res => {
  209. uni.setNavigationBarTitle({
  210. title: res.data.title
  211. });
  212. let data = res.data;
  213. this.reloadData();
  214. that.styleConfig = that.$util.objToArr(res.data.value);
  215. this.bgInfo.isBgColor=data.isBgColor
  216. this.bgInfo.colorPicker=data.colorPicker
  217. that.pageStyle = {
  218. 'background-color': data.isBgColor === 1 ? res.data.colorPicker : '',
  219. 'background-image': data.isBgPic === 1 ? `url(${res.data.bgPic})` : '',
  220. 'background-repeat': res.data.bgTabVal === 1 ? 'repeat-y' : 'no-repeat',
  221. 'background-size': res.data.bgTabVal === 2 ? 'cover' : 'contain'
  222. };
  223. uni.hideLoading();
  224. that.styleConfig.forEach((item) => {
  225. if (item.name === 'tabNav') {
  226. that.showCateNav = true;
  227. that.cateNavData = item;
  228. }
  229. if (item.name === 'homeComb') {
  230. that.showHomeComb = true
  231. that.homeCombData = item;
  232. }
  233. if (item.name === 'headerSerch') {
  234. that.showHeaderSerch = true
  235. that.headerSerchCombData = item;
  236. }
  237. });
  238. setTimeout(() => {
  239. that.isNodes++;
  240. }, 100);
  241. }).catch(err => {
  242. return that.$util.Tips({
  243. title: err
  244. });
  245. uni.hideLoading();
  246. });
  247. },
  248. //清除骨架屏
  249. reloadData() {
  250. this.showSkeleton = false;
  251. },
  252. clear() {
  253. this.loading = false;
  254. this.loadend = false;
  255. this.where = {
  256. keyword: '',
  257. priceOrder: '',
  258. salesOrder: '',
  259. page: 1,
  260. limit: 20,
  261. cid: 0
  262. };
  263. this.productList = [];
  264. },
  265. // 微信分享;
  266. setOpenShare: function(data) {
  267. let that = this;
  268. if (that.$wechat.isWeixin()) {
  269. let configAppMessage = {
  270. desc: data.synopsis,
  271. title: data.title,
  272. link: location.href,
  273. imgUrl: data.img
  274. };
  275. that.$wechat.wechatEvevt(["updateAppMessageShareData", "updateTimelineShareData"],
  276. configAppMessage);
  277. }
  278. },
  279. stopTouchMove() {
  280. return true //禁止新闻swiper手动滑动
  281. },
  282. goDetail(item) {
  283. goProductDetail(item.id, 0, '')
  284. },
  285. },
  286. }
  287. </script>
  288. <style>
  289. page {
  290. height: auto;
  291. display: flex;
  292. flex-direction: column;
  293. height: 100%;
  294. /* #ifdef H5 */
  295. background-color: #fff;
  296. /* #endif */
  297. }
  298. </style>
  299. <style lang="scss" scoped>
  300. .error-network {
  301. position: fixed;
  302. left: 0;
  303. top: 0;
  304. display: flex;
  305. flex-direction: column;
  306. align-items: center;
  307. width: 100%;
  308. height: 100%;
  309. padding-top: 40rpx;
  310. background: #fff;
  311. padding-top: 30%;
  312. .img {
  313. width: 414rpx;
  314. height: 336rpx;
  315. }
  316. .title {
  317. position: relative;
  318. top: -40rpx;
  319. font-size: 32rpx;
  320. color: #666;
  321. }
  322. .con {
  323. font-size: 24rpx;
  324. color: #999;
  325. .label {
  326. margin-bottom: 20rpx;
  327. }
  328. .item {
  329. margin-bottom: 20rpx;
  330. }
  331. }
  332. .btn {
  333. display: flex;
  334. align-items: center;
  335. justify-content: center;
  336. width: 508rpx;
  337. height: 86rpx;
  338. margin-top: 100rpx;
  339. border: 1px solid #d74432;
  340. color: #e93323;
  341. font-size: 30rpx;
  342. border-radius: 120rpx;
  343. }
  344. }
  345. .ysize {
  346. background-size: 100%;
  347. }
  348. .fullsize {
  349. background-size: 100% 100%;
  350. }
  351. .repeat {
  352. background-repeat: repeat;
  353. }
  354. .noRepeat {
  355. background-repeat: no-repeat;
  356. }
  357. .noCommodity {
  358. margin-top: 30%;
  359. }
  360. .icon-gengduo1 {
  361. color: #F8F8F8;
  362. }
  363. .pageIndex {
  364. padding: 0 24rpx;
  365. }
  366. .productList {
  367. background-color: #F5F5F5;
  368. margin-top: 20rpx;
  369. // min-height: 70vh;
  370. .sort {
  371. width: 710rpx;
  372. max-height: 380rpx;
  373. background: rgba(255, 255, 255, 1);
  374. border-radius: 16rpx;
  375. padding: 0rpx 0rpx 20rpx 0rpx !important;
  376. flex-wrap: wrap;
  377. margin: 25rpx auto 0 auto;
  378. &.no_pad {
  379. padding: 0;
  380. }
  381. .item {
  382. width: 20%;
  383. margin-top: 20rpx;
  384. text-align: center;
  385. .pictrues {
  386. width: 90rpx;
  387. height: 90rpx;
  388. background: #F5F5F5;
  389. border-radius: 50%;
  390. margin: 0 auto;
  391. }
  392. .pictrue {
  393. width: 90rpx;
  394. height: 90rpx;
  395. background: #F5F5F5;
  396. border-radius: 50%;
  397. margin: 0 auto;
  398. }
  399. .slide-image {
  400. width: 90rpx;
  401. height: 90rpx;
  402. border-radius: 50%;
  403. overflow: hidden;
  404. }
  405. /deep/ .easy-loadimage,
  406. uni-image,
  407. .easy-loadimage {
  408. width: 90rpx;
  409. height: 90rpx;
  410. display: inline-block;
  411. }
  412. .text {
  413. color: #272727;
  414. font-size: 24rpx;
  415. margin-top: 10rpx;
  416. // overflow: hidden;
  417. white-space: nowrap;
  418. text-overflow: ellipsis;
  419. }
  420. }
  421. }
  422. }
  423. .productList .list {
  424. padding: 0 20rpx;
  425. }
  426. .productList .list.on {
  427. background-color: #fff;
  428. border-top: 1px solid #f6f6f6;
  429. }
  430. .productList .list .item {
  431. width: 345rpx;
  432. margin-top: 20rpx;
  433. background-color: #fff;
  434. border-radius: 10rpx;
  435. .name {
  436. display: flex;
  437. align-items: center;
  438. .name_text {
  439. display: inline-block;
  440. max-width: 200rpx;
  441. }
  442. }
  443. }
  444. .page-index {
  445. display: flex;
  446. flex-direction: column;
  447. min-height: 100%;
  448. .page_content {
  449. // background-color: #f5f5f5;
  450. .swiper {
  451. position: relative;
  452. width: 100%;
  453. height: 246rpx;
  454. margin: 0 auto;
  455. border-radius: 10rpx;
  456. overflow: hidden;
  457. margin-bottom: 25rpx;
  458. /* #ifdef MP */
  459. margin-top: 20rpx;
  460. /* #endif */
  461. swiper,
  462. swiper-item,
  463. .slide-image,
  464. image {
  465. width: 100%;
  466. height: 246rpx;
  467. border-radius: 10rpx;
  468. }
  469. }
  470. }
  471. }
  472. .fixed {
  473. z-index: 100;
  474. position: fixed;
  475. left: 0;
  476. top: 0;
  477. background: linear-gradient(90deg, red 50%, #ff5400 100%);
  478. }
  479. .menu-txt {
  480. font-size: 24rpx;
  481. color: #454545;
  482. }
  483. </style>