templateL.vue 9.2 KB

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