templateH.vue 11 KB

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