templateH.vue 8.3 KB

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