templateH.vue 11 KB

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