templateH.vue 12 KB

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