templateH.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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. <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. initData(data) {
  141. this.$api
  142. .getStorage()
  143. .then(resolve => {
  144. this.shopId = resolve.shopId ? resolve.shopId : 0
  145. })
  146. .catch(err => {
  147. console.log('err', err)
  148. })
  149. this.productCount = data.floorImageList.length
  150. if (this.productCount > 0) {
  151. this.productList.splice(0, this.productList.length)
  152. for (var i = 0, j = data.floorImageList.length; i < j; i += this.pageSize) {
  153. this.productList.push(data.floorImageList.slice(i, i + this.pageSize))
  154. }
  155. }
  156. },
  157. PromotionsFormat(promo) {
  158. //促销活动类型数据处理
  159. if (promo != null) {
  160. if (promo.type == 1 && promo.mode == 1) {
  161. return true
  162. } else {
  163. return false
  164. }
  165. }
  166. return false
  167. },
  168. tabClick(index) {
  169. //轮播图切换
  170. this.current = index
  171. },
  172. swiperChange(e) {
  173. //轮播切换
  174. const index = e.detail.current
  175. this.swiperCurrent = index
  176. },
  177. navToDetailPage(pros) {
  178. //跳转商品详情页
  179. this.$api.FlooryNavigateTo(pros)
  180. }
  181. }
  182. }
  183. </script>
  184. <style lang="scss">
  185. .section_page_main {
  186. width: 100%;
  187. height: auto;
  188. box-sizing: border-box;
  189. .recommend-list {
  190. width: 100%;
  191. height: 1100rpx;
  192. position: relative;
  193. padding-bottom: 20rpx;
  194. .tui-banner-swiper {
  195. width: 100%;
  196. margin: 0 auto;
  197. height: 1100rpx;
  198. overflow: hidden;
  199. transform: translateY(0);
  200. .floor-item {
  201. width: 339rpx;
  202. height: 516rpx;
  203. margin-right: 20rpx;
  204. font-size: $font-size-24;
  205. color: $text-color;
  206. background: #ffffff;
  207. line-height: 36rpx;
  208. border-radius: 16rpx;
  209. margin-bottom: 20rpx;
  210. float: left;
  211. box-sizing: border-box;
  212. position: relative;
  213. &:nth-child(2n) {
  214. margin-right: 0;
  215. }
  216. .item-img {
  217. width: 339rpx;
  218. height: 339rpx;
  219. border-radius: 16rpx 16rpx 0 0;
  220. display: block;
  221. margin-bottom: 8rpx;
  222. }
  223. .floor-item_tag {
  224. width: 100%;
  225. height: 32rpx;
  226. float: left;
  227. margin: 20rpx 0;
  228. padding: 0 20rpx;
  229. box-sizing: border-box;
  230. text {
  231. display: inline-block;
  232. padding: 0 8rpx;
  233. border: 1px solid #e3ebf7;
  234. border-radius: 8rpx;
  235. color: #9aa5b5;
  236. font-size: $font-size-22;
  237. line-height: 32rpx;
  238. text-align: center;
  239. float: left;
  240. }
  241. }
  242. .floor-item-content {
  243. width: 100%;
  244. padding: 0 20rpx;
  245. box-sizing: border-box;
  246. }
  247. .floor-item-act {
  248. display: block;
  249. width: 100%;
  250. height: 32rpx;
  251. text-align: center;
  252. box-sizing: border-box;
  253. }
  254. .title-none {
  255. font-size: $font-size-26;
  256. color: #ff2a2a;
  257. line-height: 54rpx;
  258. }
  259. .title {
  260. width: 100%;
  261. height: 70rpx;
  262. display: flex;
  263. line-height: 35rpx;
  264. flex-direction: column;
  265. margin: 8rpx 0;
  266. padding: 0;
  267. position: relative;
  268. .mclap {
  269. width: 100%;
  270. line-height: 35rpx;
  271. text-overflow: ellipsis;
  272. display: -webkit-box;
  273. word-break: break-all;
  274. -webkit-box-orient: vertical;
  275. -webkit-line-clamp: 2;
  276. overflow: hidden;
  277. font-size: 26rpx;
  278. &.indent {
  279. text-indent: 95rpx;
  280. }
  281. }
  282. .mclap-tag {
  283. display: block;
  284. width: 84rpx;
  285. height: 32rpx;
  286. background-image: linear-gradient(270deg, #f9c023 0%, #f83600 100%);
  287. border-radius: 4rpx 48rpx 4px 4px;
  288. line-height: 32rpx;
  289. font-size: $font-size-22;
  290. color: #ffffff;
  291. text-align: center;
  292. position: absolute;
  293. left: 0;
  294. top: 0;
  295. }
  296. }
  297. .no-price {
  298. height: 54rpx;
  299. line-height: 54rpx;
  300. display: flex;
  301. box-sizing: border-box;
  302. .p-no {
  303. font-size: $font-size-28;
  304. color: $text-color;
  305. display: block;
  306. float: left;
  307. }
  308. .p-stars {
  309. float: left;
  310. }
  311. }
  312. .price {
  313. color: #ff2a2a;
  314. line-height: 54rpx;
  315. &.none {
  316. text-decoration: line-through;
  317. color: #999999;
  318. }
  319. .sm {
  320. font-size: $font-size-24;
  321. }
  322. .big {
  323. font-size: $font-size-28;
  324. }
  325. }
  326. }
  327. }
  328. }
  329. .swiper__recommenddots-box {
  330. position: absolute;
  331. bottom: 0;
  332. left: 0;
  333. right: 0;
  334. /* #ifndef APP-NVUE */
  335. display: flex;
  336. /* #endif */
  337. flex: 1;
  338. flex-direction: row;
  339. justify-content: center;
  340. align-items: center;
  341. height: 60rpx;
  342. .swiper__dots-item {
  343. width: 8rpx;
  344. height: 8rpx;
  345. border-radius: 100%;
  346. margin-left: 6px;
  347. background-color: rgba(225, 86, 22, 0.3);
  348. }
  349. .swiper__dots-long {
  350. width: 32rpx;
  351. height: 8rpx;
  352. border-radius: 4rpx;
  353. background-color: #FF5B00;
  354. transition: all 0.4s;
  355. }
  356. }
  357. }
  358. </style>