templateL.vue 9.2 KB

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