templateH.vue 12 KB

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