index-home.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. <template>
  2. <view class="index-home p-t-20">
  3. <!-- 轮播 -->
  4. <ad-swipers :pid="7" height="312rpx" padding="0 30rpx" radius="20rpx"></ad-swipers>
  5. <bubble-tips top="280rpx" :discharge="isDischarge"></bubble-tips>
  6. <!-- <view class="power-price">
  7. <image src="../../static/nl.png" mode="heightFix"></image>
  8. <view class="cont">
  9. 抵用券价格:<text>{{energyPrice}}</text>
  10. </view>
  11. </view> -->
  12. <view class="content">
  13. <!-- 导航入口 -->
  14. <view class="nav m-t-20" v-if="newNavList.length">
  15. <swiper :style="'height:' + navSwiperH + 'rpx;'" @change="swiperChange">
  16. <swiper-item v-for="(items, index) in newNavList" :key="index">
  17. <view class="nav-list flex flex-wrap">
  18. <view v-for="(item, index2) in items" :key="index2" class="nav-item m-t-30"
  19. @tap="menuJump(item)">
  20. <view class="flex-col col-center">
  21. <image class="nav-icon m-b-15" :src="item.image"></image>
  22. <view class="name xs">{{ item.name }}</view>
  23. </view>
  24. </view>
  25. </view>
  26. </swiper-item>
  27. </swiper>
  28. <view class="dots" v-if="newNavList.length > 1">
  29. <view v-for="(item, index) in newNavList" :key="index"
  30. :class="'dot ' + (index == currentSwiper ? 'active' : '')"></view>
  31. </view>
  32. </view>
  33. <!-- 直播 + 抢购 -->
  34. <!-- <hua-active-plate></hua-active-plate> -->
  35. <!-- #ifdef MP-WEIXIN -->
  36. <view><channel-live class="live radius10" finder-user-name="sphLep2LvoxvsPF"
  37. :feed-id="fid.feedId"></channel-live></view>
  38. <view class="xcxzb" @click="navTo('/pages/index/living')">
  39. <image src="https://shop.xianghuaqi.net.cn/images/living.png" mode=""></image>
  40. </view>
  41. <!-- #endif -->
  42. <!-- #ifndef MP-WEIXIN -->
  43. <view class="live radius10" @click="toLive">
  44. <view class="top d-flex align-items-center">
  45. <view class="title titColor">新品直播</view>
  46. <view class="sub">采一手新品</view>
  47. </view>
  48. <view class="live-box">
  49. <view class="status" v-if="appConfig.is_live == 1">直播中</view>
  50. <view class="status" v-else>未开启直播</view>
  51. <image src="https://shop.xianghuaqi.net.cn/images/live.png"></image>
  52. <view class="tips d-flex justify-content-between align-items-center">
  53. <image src="../../static/home/liveicon.png" mode=""></image>
  54. <text>享限时折扣</text>
  55. </view>
  56. <view class="title">直播看新品</view>
  57. </view>
  58. </view>
  59. <!-- #endif -->
  60. <!-- 中部广告 -->
  61. <ad-swipers :pid="8" height="222rpx" :is-swiper="false" padding="20rpx 0 0" radius="20rpx"></ad-swipers>
  62. <!-- 资讯 -->
  63. <!-- <router-link v-if="newsList.length" class="" :to="{path: '/pages/news_list/news_list'}">
  64. <view class="information bg-white flex m-t-20">
  65. <image class="icon-toutiao" src="/static/images/icon_toutiao.png"></image>
  66. <text class="gap-line"></text>
  67. <view class="news flex-1 flex">
  68. <view class="shade"></view>
  69. <swiper class="flex-1" autoplay="true" style="height: 76rpx;" vertical="true" circular="true"
  70. :interval="3000">
  71. <swiper-item v-for="(item, index) in newsList" :key="index" class="flex">
  72. <view class="flex-none">
  73. <u-tag v-if="item.is_new" shape="circle" text="最新" size="mini" type="primary"
  74. mode="plain" />
  75. </view>
  76. <view class="text-swiper m-l-10 line-1">{{item.title }}</view>
  77. </swiper-item>
  78. </swiper>
  79. </view>
  80. <u-icon name="arrow-right"></u-icon>
  81. </view>
  82. </router-link> -->
  83. <!-- 活动专区 -->
  84. <view class="activity-zone m-t-20" v-if="activityArea.length">
  85. <view class="flex p-20 row-center xxl bold white">活动专区</view>
  86. <view class="list flex flex-wrap row-between">
  87. <router-link
  88. :to="{ path: '/bundle/pages/activity_detail/activity_detail', query: { name: item.name, title: item.title, id: item.id } }"
  89. v-for="(item, index) in activityArea" :key="index">
  90. <view class="item flex bg-white m-b-20">
  91. <u-image width="120rpx" height="120rpx" :src="item.image"></u-image>
  92. <view class="m-l-20 flex-1">
  93. <view class="bold lg line-1 desc">{{ item.name }}</view>
  94. <view class="primary sm m-t-5 line-1 desc">{{ item.title }}</view>
  95. <view class="br60 bg-primary white xxs m-t-10 btn">前往查看</view>
  96. </view>
  97. </view>
  98. </router-link>
  99. </view>
  100. </view>
  101. <!-- 秒杀 -->
  102. <!-- <view class="seckill m-t-20" v-if="seckillGoods.length">
  103. <home-seckill :list="seckillGoods"></home-seckill>
  104. </view> -->
  105. <!-- 附近店铺 -->
  106. <!-- <view class="m-t-20" v-if="nearbyShop.length">
  107. <shop-recommend type="nearby-shops" title="附近店铺" :list="nearbyShop"
  108. url="/bundle_b/pages/nearby_shops/nearby_shops"></shop-recommend>
  109. </view> -->
  110. <!-- <view class="m-t-20" v-if="appConfig.index_setting.host_show && hotGoods.length">
  111. <active-area :list="hotGoods" type="hot" title="热销榜单" url="/pages/active_list/active_list?type=hot"></active-area>
  112. </view>
  113. <view class="m-t-20" v-if="appConfig.index_setting.new_show && newGoods.length">
  114. <active-area :list="newGoods" type="new" title="新品推荐" url="/pages/active_list/active_list?type=new"></active-area>
  115. </view> -->
  116. <!-- 种草社区 -->
  117. <!-- <view class="m-t-20" v-if="appConfig.index_setting.community_show && communityArticle.length">
  118. <community-recommend :list="communityArticle" title="种草社区" url="/pages/community/community"></community-recommend>
  119. </view> -->
  120. <!-- 店铺 -->
  121. <!-- <view class="m-t-20" v-if="appConfig.index_setting.shop_show && shopLists.length">
  122. <shop-recommend type="shop-recommends" title="店铺推荐" :list="shopLists"></shop-recommend>
  123. </view> -->
  124. <!-- <view class="m-t-20" v-if="appConfig.index_setting.shop_show && shopRecommend.length" v-for="(item, index) in shopRecommend" :key="index">
  125. <shop-item :item="item"></shop-item>
  126. </view> -->
  127. </view>
  128. </view>
  129. </template>
  130. <script>
  131. import {
  132. arraySlice,
  133. menuJump
  134. } from '@/utils/tools';
  135. import {
  136. mapGetters
  137. } from 'vuex';
  138. // import hua-active-plate from '@/components/hua-active-plate/hua-active-plate.vue';
  139. export default {
  140. props: {
  141. navList: {
  142. type: Array,
  143. default: () => []
  144. },
  145. list: {
  146. type: Array,
  147. default: () => []
  148. },
  149. homeData: {
  150. type: Object,
  151. default: () => ({})
  152. },
  153. energyPrice: {}
  154. },
  155. data() {
  156. return {
  157. newNavList: [],
  158. navSwiperH: '',
  159. currentSwiper: 0,
  160. isDischarge: false,
  161. goodsList: [],
  162. fid: ''
  163. };
  164. },
  165. mounted() {
  166. // #ifdef MP-WEIXIN
  167. wx.getChannelsLiveInfo({
  168. finderUserName: 'sphLep2LvoxvsPF',
  169. success: res => {
  170. this.fid = res;
  171. console.log(res, 'livingsuccess');
  172. },
  173. fail: res => {
  174. console.log(res, 'failsuccess');
  175. }
  176. });
  177. // #endif
  178. this.isDischarge = false;
  179. },
  180. destroyed() {
  181. this.isDischarge = true;
  182. },
  183. methods: {
  184. swiperChange(e) {
  185. console.log(e);
  186. this.currentSwiper = e.detail.current;
  187. },
  188. navTo(url) {
  189. uni.navigateTo({
  190. url
  191. })
  192. },
  193. menuJump(item) {
  194. // 解决分类使用redirectTo的问题
  195. if (item.link == '/pages/goods_cate/goods_cate') {
  196. uni.navigateTo({
  197. url: '/pages/goods_cate/goods_cate'
  198. });
  199. return;
  200. }
  201. if (item.link == '/bundle_b/pages/nearby_shops/nearby_shops') {
  202. uni.navigateTo({
  203. url: '/bundle_b/pages/nearby_shops/nearby_shops'
  204. });
  205. return;
  206. }
  207. if (item.link == '/bundle/pages/integral_mall/integral_mall') {
  208. uni.switchTab({
  209. url: '/pages/integral/integral'
  210. });
  211. } else {
  212. menuJump(item);
  213. }
  214. },
  215. toLive() {
  216. if (this.appConfig.is_live == 1) {
  217. uni.navigateTo({
  218. url: '/pages/videos/videos'
  219. });
  220. } else {
  221. uni.showToast({
  222. title: '未开启直播',
  223. icon: 'none'
  224. });
  225. }
  226. },
  227. goLive() {
  228. console.log(111);
  229. wx.openChannelsLive({
  230. finderUserName: 'sphLep2LvoxvsPF',
  231. feedId: this.fid.feeId,
  232. nonceId: this.fid.noceId,
  233. success: res => {
  234. console.log(res);
  235. },
  236. fail: res => {
  237. console.log(res);
  238. }
  239. });
  240. }
  241. },
  242. watch: {
  243. navList(val) {
  244. if (val.length <= 5) {
  245. this.navSwiperH = 200;
  246. } else if (val.length <= 10) {
  247. this.navSwiperH = 374;
  248. } else {
  249. this.navSwiperH = 520;
  250. }
  251. this.newNavList = arraySlice(val, [], 15);
  252. console.log(this.newNavList, '123456');
  253. },
  254. list(val) {
  255. this.goodsList = val;
  256. }
  257. },
  258. computed: {
  259. ...mapGetters(['appConfig']),
  260. newsList() {
  261. return this.homeData.headlines || [];
  262. },
  263. nearbyShop() {
  264. return this.homeData.nearby_shops || [];
  265. },
  266. hotGoods() {
  267. return this.homeData.hots || [];
  268. },
  269. newGoods() {
  270. return this.homeData.news || [];
  271. },
  272. communityArticle() {
  273. return this.homeData.community_article || [];
  274. },
  275. activityList() {
  276. return this.homeData.activity_area || [];
  277. },
  278. shopRecommend() {
  279. return this.homeData.shop_recommend || [];
  280. },
  281. shopLists() {
  282. return this.homeData.shop_lists || [];
  283. },
  284. seckillGoods() {
  285. return this.homeData.seckill_goods || [];
  286. },
  287. activityArea() {
  288. return this.homeData.activity_area || [];
  289. }
  290. }
  291. };
  292. </script>
  293. <style lang="scss" scoped>
  294. .index-home {
  295. .power-price {
  296. position: relative;
  297. margin: 20rpx 30rpx;
  298. background-color: #fff !important;
  299. display: flex;
  300. padding: 16rpx 24rpx;
  301. box-sizing: border-box;
  302. align-items: center;
  303. border-radius: 8rpx;
  304. image {
  305. height: 38rpx;
  306. margin-right: 20rpx;
  307. }
  308. .cont {
  309. font-size: 28rpx;
  310. color: #040404;
  311. flex: 1;
  312. position: relative;
  313. z-index: 10;
  314. text {
  315. color: #f73e33;
  316. }
  317. }
  318. }
  319. .content {
  320. padding: 0 30rpx 20rpx;
  321. .nav {
  322. position: relative;
  323. border-radius: 20rpx;
  324. .nav-item {
  325. width: 25%;
  326. .nav-icon {
  327. width: 82rpx;
  328. height: 82rpx;
  329. }
  330. }
  331. .dots {
  332. position: absolute;
  333. left: 50%;
  334. transform: translateX(-50%);
  335. bottom: 20rpx;
  336. display: flex;
  337. .dot {
  338. width: 10rpx;
  339. height: 6rpx;
  340. border-radius: 6rpx;
  341. margin-right: 10rpx;
  342. background-color: rgba(255, 44, 60, 0.4);
  343. &.active {
  344. width: 20rpx;
  345. background-color: $-color-primary;
  346. }
  347. }
  348. }
  349. }
  350. .information {
  351. height: 76rpx;
  352. box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.06);
  353. padding: 0 20rpx;
  354. border-radius: 20rpx;
  355. .news {
  356. position: relative;
  357. .shade {
  358. position: absolute;
  359. width: 100%;
  360. height: 100%;
  361. z-index: 100;
  362. }
  363. }
  364. .icon-toutiao {
  365. width: 114rpx;
  366. height: 34rpx;
  367. }
  368. .gap-line {
  369. height: 28rpx;
  370. width: 1px;
  371. background-color: #dcdddc;
  372. margin: 0 30rpx;
  373. }
  374. }
  375. .title-iamge {
  376. width: 200rpx;
  377. height: 100rpx;
  378. }
  379. .activity-zone {
  380. background-image: url(../../static/images/bg_activity_home.png);
  381. background-size: 100% auto;
  382. padding: 0 15rpx;
  383. border-radius: 14rpx;
  384. .item {
  385. border-radius: 14rpx;
  386. width: 324rpx;
  387. padding: 20rpx 16rpx;
  388. .desc {
  389. width: 160rpx;
  390. }
  391. .btn {
  392. display: inline-block;
  393. padding: 2rpx 20rpx;
  394. }
  395. }
  396. }
  397. }
  398. }
  399. .live {
  400. width: 100%;
  401. box-sizing: border-box;
  402. margin: 20rpx auto;
  403. position: relative;
  404. .status {
  405. position: absolute;
  406. right: 10rpx;
  407. top: 20rpx;
  408. z-index: 98;
  409. background: #f8352b;
  410. color: #fff;
  411. font-size: 28rpx;
  412. padding: 5rpx 10rpx;
  413. }
  414. .top {
  415. position: absolute;
  416. top: 20rpx;
  417. left: 16rpx;
  418. z-index: 98;
  419. height: 44rpx;
  420. .title {
  421. font-weight: 700;
  422. }
  423. .sub {
  424. font-size: 24rpx;
  425. color: #616161;
  426. margin-left: 10rpx;
  427. }
  428. }
  429. .live-box {
  430. width: 100%;
  431. height: 340rpx;
  432. position: relative;
  433. margin: 10rpx auto 0;
  434. image {
  435. width: 100%;
  436. height: 100%;
  437. }
  438. .tips {
  439. position: absolute;
  440. bottom: 60rpx;
  441. left: 14rpx;
  442. padding: 0 10rpx;
  443. height: 34rpx;
  444. background: linear-gradient(142deg, #f16d60 0%, #f8352b 100%);
  445. border-radius: 4rpx;
  446. image {
  447. width: 22rpx;
  448. height: 16rpx;
  449. margin-right: 4rpx;
  450. }
  451. text {
  452. color: #fff;
  453. font-size: 20rpx;
  454. }
  455. }
  456. .title {
  457. position: absolute;
  458. bottom: 20rpx;
  459. left: 14rpx;
  460. color: #fff;
  461. font-size: 24rpx;
  462. }
  463. }
  464. .goods {
  465. position: relative;
  466. width: 146rpx;
  467. height: 126rpx;
  468. image {
  469. position: relative;
  470. width: 100%;
  471. height: 100%;
  472. }
  473. .name {
  474. position: absolute;
  475. color: #f8352b;
  476. font-size: 20rpx;
  477. padding: 2rpx 4rpx;
  478. bottom: 0;
  479. left: 50%;
  480. transform: translateX(-50%);
  481. box-sizing: border-box;
  482. background-color: #ffe4e3;
  483. border-radius: 16rpx;
  484. text-align: center;
  485. font-weight: 500;
  486. }
  487. }
  488. }
  489. .xcxzb {
  490. margin: 40rpx auto;
  491. width: 690rpx;
  492. height: 180rpx;
  493. image {
  494. width: 100%;
  495. height: 100%;
  496. }
  497. }
  498. </style>