templateH.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. <template>
  2. <view class="section_page_main clearfix">
  3. <view class="recommend-list" :style="hasLessProduct ? 'height:269px' : ''">
  4. <swiper
  5. class="tui-banner-swiper"
  6. :autoplay="true"
  7. :interval="5000"
  8. :duration="500"
  9. :circular="true"
  10. @change="swiperChange"
  11. :style="hasLessProduct ? 'height:269px' : ''"
  12. >
  13. <swiper-item v-for="(product, index) in productList" :key="index">
  14. <view
  15. class="floor-item ad_04 clearfix"
  16. v-for="(item, idx) in product"
  17. :key="idx"
  18. @click.stop="navToDetailPage(item)"
  19. >
  20. <image class="item-img tui-skeleton-fillet" :src="item.image" mode="aspectFill"></image>
  21. <view class="floor-item_tag" v-if="item.listType == 2">
  22. <text>{{ item.label }}</text>
  23. </view>
  24. <view class="floor-item-content">
  25. <view class="title tui-skeleton-rect">
  26. <text class="mclap-tag" v-if="item.product.beautyActFlag == '1'">美博会</text>
  27. <text class="mclap" :class="item.product.beautyActFlag == '1' ? 'indent' : ''"
  28. >{{ item.name }}
  29. </text>
  30. </view>
  31. <view class="floor-item-price" v-if="item.listType == 1">
  32. <view class="floor-item-act">
  33. <view class="coupon-tags" v-if="item.product.couponsLogo">优惠券</view>
  34. <template v-if="userIdentity === 3">
  35. <template v-if="item.product.actStatus === 1">
  36. <view class="floor-tags" v-if="PromotionsFormat(item.product.promotions)">
  37. {{ item.product.promotions.name }}
  38. <text
  39. v-if="
  40. hasLogin &&
  41. item.product.priceFlag != 1 &&
  42. item.product.shopID == shopId
  43. "
  44. >:¥{{ item.product.price | NumFormat }}</text
  45. >
  46. </view>
  47. <view class="floor-tags" v-else>{{ item.product.promotions.name }}</view>
  48. </template>
  49. <template
  50. v-if="item.product.actStatus === 0 && item.product.ladderPriceFlag === 1"
  51. >
  52. <view class="floor-tags">阶梯价格</view>
  53. </template>
  54. </template>
  55. <template v-else>
  56. <template v-if="item.product.actStatus === 1">
  57. <view class="floor-tags" v-if="PromotionsFormat(item.product.promotions)">
  58. {{ item.product.promotions.name }}
  59. <text v-if="hasLogin && item.product.priceFlag != 1"
  60. >:¥{{ item.product.price | NumFormat }}</text
  61. >
  62. </view>
  63. <view class="floor-tags" v-else>{{ item.product.promotions.name }}</view>
  64. </template>
  65. <template
  66. v-if="item.product.actStatus === 0 && item.product.ladderPriceFlag === 1"
  67. >
  68. <view class="floor-tags">阶梯价格</view>
  69. </template>
  70. </template>
  71. </view>
  72. <view v-if="hasLogin">
  73. <template v-if="item.product.productCategory == 1">
  74. <template v-if="userIdentity == 3">
  75. <template v-if="item.product.shopID == shopId">
  76. <view class="title-none" v-if="item.product.priceFlag === 1">
  77. <text class="p big">¥未公开价格</text>
  78. </view>
  79. <view
  80. class="price tui-skeleton-rect"
  81. v-else
  82. :class="PromotionsFormat(item.product.promotions) ? 'none' : ''"
  83. >
  84. <text class="p sm">¥</text>
  85. <text class="p big">{{
  86. (PromotionsFormat(item.product.promotions)
  87. ? item.product.originalPrice
  88. : item.product.price) | NumFormat
  89. }}</text>
  90. </view>
  91. </template>
  92. <template v-else>
  93. <view class="no-price">
  94. <view class="p-stars">
  95. <text class="p-no">¥</text>
  96. <uni-grader
  97. :grade="Number(item.product.priceGrade)"
  98. :margin="14"
  99. ></uni-grader>
  100. </view>
  101. </view>
  102. </template>
  103. </template>
  104. <template v-else-if="userIdentity === 4">
  105. <view class="title-none" v-if="item.product.priceFlag === 1">
  106. <text class="p big">¥未公开价格</text>
  107. </view>
  108. <view class="title-none" v-if="item.product.priceFlag === 2">
  109. <text class="p big">¥价格仅会员可见</text>
  110. </view>
  111. <view
  112. class="price tui-skeleton-rect"
  113. v-if="item.product.priceFlag === 0"
  114. :class="PromotionsFormat(item.product.promotions) ? 'none' : ''"
  115. >
  116. <text class="p sm">¥</text>
  117. <text class="p big">{{
  118. (PromotionsFormat(item.product.promotions)
  119. ? item.product.originalPrice
  120. : item.product.price) | NumFormat
  121. }}</text>
  122. </view>
  123. </template>
  124. <template v-else>
  125. <view class="title-none" v-if="item.product.priceFlag === 1">
  126. <text class="p big">¥未公开价格</text>
  127. </view>
  128. <view
  129. class="price tui-skeleton-rect"
  130. v-else
  131. :class="PromotionsFormat(item.product.promotions) ? 'none' : ''"
  132. >
  133. <text class="p sm">¥</text>
  134. <text class="p big">{{
  135. (PromotionsFormat(item.product.promotions)
  136. ? item.product.originalPrice
  137. : item.product.price) | NumFormat
  138. }}</text>
  139. </view>
  140. </template>
  141. </template>
  142. <template v-else>
  143. <view class="price tui-skeleton-rect" v-if="item.product.detailTalkFlag == '2'">
  144. <text class="p sm">¥</text> <text class="p big">价格详聊</text>
  145. </view>
  146. <view class="price tui-skeleton-rect" v-else>
  147. <text class="p sm">¥</text>
  148. <text class="p big">{{ item.product.price | NumFormat }}</text>
  149. </view>
  150. </template>
  151. </view>
  152. <view v-else class="no-price">
  153. <template v-if="item.product.productCategory == 1">
  154. <view class="p-stars">
  155. <text class="p-no">¥</text>
  156. <uni-grader
  157. :grade="Number(item.product.priceGrade)"
  158. :margin="14"
  159. ></uni-grader>
  160. </view>
  161. </template>
  162. <template v-else>
  163. <view class="p-stars"> <text class="p-no">¥登录可见</text> </view>
  164. </template>
  165. </view>
  166. </view>
  167. </view>
  168. </view>
  169. </swiper-item>
  170. </swiper>
  171. <view class="swiper__recommenddots-box" v-if="productList.length > 1">
  172. <view
  173. v-for="(item, idx) in productList"
  174. :key="idx"
  175. :class="[idx === swiperCurrent ? 'swiper__dots-long' : 'none']"
  176. :data-index="swiperCurrent"
  177. class="swiper__dots-item"
  178. >
  179. </view>
  180. </view>
  181. </view>
  182. </view>
  183. </template>
  184. <script>
  185. import { mapState, mapMutations } from 'vuex'
  186. import uniGrader from '@/components/uni-grade/uni-grade.vue'
  187. export default {
  188. name: 'templateH',
  189. components: {
  190. uniGrader
  191. },
  192. props: {
  193. pageData: {
  194. type: Object
  195. },
  196. userIdentity: {
  197. type: Number
  198. }
  199. },
  200. data() {
  201. return {
  202. shopId: 0,
  203. productList: [],
  204. current: 100,
  205. swiperCurrent: 0,
  206. pageSize: 4,
  207. productCount: 0
  208. }
  209. },
  210. filters: {
  211. NumFormat: function(text) {
  212. //处理金额
  213. return Number(text).toFixed(2)
  214. }
  215. },
  216. created() {
  217. this.initData(this.pageData)
  218. },
  219. computed: {
  220. ...mapState(['hasLogin', 'userInfo', 'isActivity']),
  221. hasLessProduct() {
  222. return this.productCount <= 2
  223. }
  224. },
  225. watch: {
  226. pageData: {
  227. handler: function(el) {
  228. //监听对象的变换使用 function,箭头函数容易出现this指向不正确
  229. this.pageData = el
  230. this.initData(this.pageData)
  231. },
  232. deep: true
  233. }
  234. },
  235. methods: {
  236. initData(data) {
  237. this.$api
  238. .getStorage()
  239. .then(resolve => {
  240. this.shopId = resolve.shopId ? resolve.shopId : 0
  241. })
  242. .catch(err => {
  243. console.log('err', err)
  244. })
  245. this.productCount = data.floorImageList.length
  246. if (this.productCount > 0) {
  247. this.productList.splice(0, this.productList.length)
  248. for (var i = 0, j = data.floorImageList.length; i < j; i += this.pageSize) {
  249. this.productList.push(data.floorImageList.slice(i, i + this.pageSize))
  250. }
  251. }
  252. },
  253. PromotionsFormat(promo) {
  254. //促销活动类型数据处理
  255. if (promo != null) {
  256. if (promo.type == 1 && promo.mode == 1) {
  257. return true
  258. } else {
  259. return false
  260. }
  261. }
  262. return false
  263. },
  264. tabClick(index) {
  265. //轮播图切换
  266. this.current = index
  267. },
  268. swiperChange(e) {
  269. //轮播切换
  270. const index = e.detail.current
  271. this.swiperCurrent = index
  272. },
  273. navToDetailPage(pros) {
  274. //跳转商品详情页
  275. this.$api.FlooryNavigateTo(pros)
  276. }
  277. }
  278. }
  279. </script>
  280. <style lang="scss">
  281. .section_page_main {
  282. width: 100%;
  283. height: auto;
  284. box-sizing: border-box;
  285. .recommend-list {
  286. width: 100%;
  287. height: 1100rpx;
  288. position: relative;
  289. padding-bottom: 20rpx;
  290. .tui-banner-swiper {
  291. width: 100%;
  292. margin: 0 auto;
  293. background: #f7f7f7;
  294. height: 1100rpx;
  295. overflow: hidden;
  296. transform: translateY(0);
  297. .floor-item {
  298. width: 339rpx;
  299. height: 516rpx;
  300. margin-right: 20rpx;
  301. font-size: $font-size-24;
  302. color: $text-color;
  303. background: #ffffff;
  304. line-height: 36rpx;
  305. border-radius: 16rpx;
  306. margin-bottom: 20rpx;
  307. float: left;
  308. box-sizing: border-box;
  309. position: relative;
  310. &:nth-child(2n) {
  311. margin-right: 0;
  312. }
  313. .item-img {
  314. width: 339rpx;
  315. height: 339rpx;
  316. border-radius: 16rpx 16rpx 0 0;
  317. display: block;
  318. margin-bottom: 8rpx;
  319. }
  320. .floor-item_tag {
  321. width: 100%;
  322. height: 32rpx;
  323. float: left;
  324. margin: 20rpx 0;
  325. padding: 0 20rpx;
  326. box-sizing: border-box;
  327. text {
  328. display: inline-block;
  329. padding: 0 8rpx;
  330. border: 1px solid #e3ebf7;
  331. border-radius: 8rpx;
  332. color: #9aa5b5;
  333. font-size: $font-size-22;
  334. line-height: 32rpx;
  335. text-align: center;
  336. float: left;
  337. }
  338. }
  339. .floor-item-content {
  340. width: 100%;
  341. padding: 0 20rpx;
  342. box-sizing: border-box;
  343. }
  344. .floor-item-act {
  345. display: block;
  346. width: 100%;
  347. height: 32rpx;
  348. text-align: center;
  349. box-sizing: border-box;
  350. .coupon-tags {
  351. height: 32rpx;
  352. box-sizing: border-box;
  353. border-radius: 8rpx;
  354. background-color: #fff1eb;
  355. line-height: 28rpx;
  356. color: #f94b4b;
  357. text-align: center;
  358. display: inline-block;
  359. padding: 0 10rpx;
  360. font-size: $font-size-20;
  361. border: 1px solid #f94b4b;
  362. float: left;
  363. margin-right: 12rpx;
  364. }
  365. .floor-tags {
  366. height: 32rpx;
  367. box-sizing: border-box;
  368. border-radius: 8rpx;
  369. background-color: #ffffff;
  370. line-height: 28rpx;
  371. color: $color-system;
  372. text-align: center;
  373. display: inline-block;
  374. padding: 0 16rpx;
  375. font-size: $font-size-20;
  376. border: 1px solid #e15616;
  377. float: left;
  378. }
  379. }
  380. .title-none {
  381. font-size: $font-size-26;
  382. color: #ff2a2a;
  383. line-height: 54rpx;
  384. }
  385. .title {
  386. width: 100%;
  387. height: 70rpx;
  388. display: flex;
  389. line-height: 35rpx;
  390. flex-direction: column;
  391. margin: 8rpx 0;
  392. padding: 0;
  393. position: relative;
  394. .mclap {
  395. width: 100%;
  396. line-height: 35rpx;
  397. text-overflow: ellipsis;
  398. display: -webkit-box;
  399. word-break: break-all;
  400. -webkit-box-orient: vertical;
  401. -webkit-line-clamp: 2;
  402. overflow: hidden;
  403. font-size: 26rpx;
  404. &.indent {
  405. text-indent: 95rpx;
  406. }
  407. }
  408. .mclap-tag {
  409. display: block;
  410. width: 84rpx;
  411. height: 32rpx;
  412. background-image: linear-gradient(270deg, #f9c023 0%, #f83600 100%);
  413. border-radius: 4rpx 48rpx 4px 4px;
  414. line-height: 32rpx;
  415. font-size: $font-size-22;
  416. color: #ffffff;
  417. text-align: center;
  418. position: absolute;
  419. left: 0;
  420. top: 0;
  421. }
  422. }
  423. .no-price {
  424. height: 54rpx;
  425. line-height: 54rpx;
  426. display: flex;
  427. box-sizing: border-box;
  428. .p-no {
  429. font-size: $font-size-28;
  430. color: $text-color;
  431. display: block;
  432. float: left;
  433. }
  434. .p-stars {
  435. float: left;
  436. }
  437. }
  438. .price {
  439. color: #ff2a2a;
  440. line-height: 54rpx;
  441. &.none {
  442. text-decoration: line-through;
  443. color: #999999;
  444. }
  445. .sm {
  446. font-size: $font-size-24;
  447. }
  448. .big {
  449. font-size: $font-size-28;
  450. }
  451. }
  452. }
  453. }
  454. }
  455. .swiper__recommenddots-box {
  456. position: absolute;
  457. bottom: 0;
  458. left: 0;
  459. right: 0;
  460. /* #ifndef APP-NVUE */
  461. display: flex;
  462. /* #endif */
  463. flex: 1;
  464. flex-direction: row;
  465. justify-content: center;
  466. align-items: center;
  467. height: 60rpx;
  468. .swiper__dots-item {
  469. width: 8rpx;
  470. height: 8rpx;
  471. border-radius: 100%;
  472. margin-left: 6px;
  473. background-color: rgba(225, 86, 22, 0.3);
  474. }
  475. .swiper__dots-long {
  476. width: 32rpx;
  477. height: 8rpx;
  478. border-radius: 4rpx;
  479. background-color: #e15616;
  480. transition: all 0.4s;
  481. }
  482. }
  483. }
  484. </style>