templateH.vue 12 KB

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