templateL.vue 9.1 KB

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