hotProduct.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template name="hotProduct">
  2. <view>
  3. <view class="container clearfix">
  4. <view class="title">推荐专区</view>
  5. <view class="recommend-list">
  6. <swiper class="tui-banner-swiper" :autoplay="false" :interval="5000" :duration="500" :circular="true" @change="swiperChange">
  7. <swiper-item v-for="(product,index) in hotProductList" :key="index">
  8. <view class="floor-item" v-for="(item, idx) in product" :key="idx" @click.stop="navToDetailPage(item.id)">
  9. <image class="item-img tui-skeleton-fillet" :src="item.image" mode="aspectFill"></image>
  10. <view class="floor-item-content">
  11. <view class="title tui-skeleton-rect">
  12. <text class="mclap">{{item.name}}</text>
  13. </view>
  14. <view class="" v-if="hasLogin">
  15. <view v-if="userIdentity == 4">
  16. <view class="title-none" v-show="item.price1TextFlag == '1'">
  17. <text class="p big">¥未公开价格</text>
  18. </view>
  19. <view class="title-none" v-show="item.price1TextFlag == '2'">
  20. <text class="p big">¥价格仅会员可见</text>
  21. </view>
  22. <view class="price tui-skeleton-rect" v-show="item.price1TextFlag == '0'" :class="PromotionsFormat(item.promotions) ? 'none' : ''">
  23. <text class="p sm">¥</text>
  24. <text class="p big">{{ (PromotionsFormat(item.promotions) ? item.originalPrice : item.price ) | NumFormat}}</text>
  25. <template v-if="item.actStatus==1">
  26. <view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
  27. {{item.promotions.name}}<text v-if="hasLogin && item.price1TextFlag != '1'">:¥{{item.price | NumFormat}}</text>
  28. </view>
  29. <view class="floor-tags" v-else>{{item.promotions.name}}</view>
  30. </template>
  31. <template v-if="item.actStatus ==0 && item.ladderPriceFlag==1">
  32. <view class="floor-tags">阶梯价格</view>
  33. </template>
  34. </view>
  35. </view>
  36. <view v-else>
  37. <view class="title-none" v-if="item.price1TextFlag == '1'">
  38. <text class="p big">未公开价格</text>
  39. </view>
  40. <view class="price tui-skeleton-rect" v-else :class="PromotionsFormat(item.promotions) ? 'none' : ''">
  41. <text class="p sm">¥</text>
  42. <text class="p big">{{ (PromotionsFormat(item.promotions) ? item.originalPrice : item.price ) | NumFormat}}</text>
  43. <template v-if="item.actStatus==1">
  44. <view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
  45. {{item.promotions.name}}<text v-if="hasLogin && item.price1TextFlag != '1'">:¥{{item.price | NumFormat}}</text>
  46. </view>
  47. <view class="floor-tags" v-else>{{item.promotions.name}}</view>
  48. </template>
  49. <template v-if="item.actStatus ==0 && item.ladderPriceFlag==1">
  50. <view class="floor-tags">阶梯价格</view>
  51. </template>
  52. </view>
  53. </view>
  54. </view>
  55. <view v-else class="no-price">
  56. <view class="p-stars">
  57. <text class="p-no">¥</text>
  58. <uni-grader :grade="Number(item.priceGrade)"></uni-grader>
  59. <!-- <uni-stars :stars="parseInt()" :fontSize="36" :widthInfo="180"></uni-stars> -->
  60. <template v-if="item.actStatus==1">
  61. <view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
  62. {{item.promotions.name}}<text v-if="hasLogin && item.price1TextFlag != '1'">:¥{{item.price | NumFormat}}</text>
  63. </view>
  64. <view class="floor-tags" v-else>{{item.promotions.name}}</view>
  65. </template>
  66. <template v-if="item.actStatus ==0 && item.ladderPriceFlag==1">
  67. <view class="floor-tags">阶梯价格</view>
  68. </template>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </swiper-item>
  74. </swiper>
  75. <view class="swiper__recommenddots-box" v-if="hotProductList.length > 1">
  76. <view v-for="(item,idx) in hotProductList"
  77. :key="idx"
  78. :class="[idx===swiperCurrent?'swiper__dots-long':'none']"
  79. :data-index="swiperCurrent" class="swiper__dots-item">
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </template>
  86. <script>
  87. import { mapState,mapMutations} from 'vuex';
  88. import uniGrader from '@/components/uni-grade/uni-grade.vue'
  89. export default{
  90. name:"hotProduct",
  91. components:{
  92. uniGrader
  93. },
  94. props:{
  95. list:{
  96. type:Array
  97. },
  98. userIdentity:{
  99. type:Number
  100. }
  101. },
  102. data() {
  103. return{
  104. current:100,
  105. swiperCurrent:0,
  106. hotProductList:[],
  107. pageSize:4,
  108. }
  109. },
  110. filters: { NumFormat:function(text) {//处理金额 return Number(text).toFixed(2); }, },
  111. created(){
  112. this.initData(this.list)
  113. },
  114. computed: {
  115. ...mapState(['hasLogin','userInfo','isActivity'])
  116. },
  117. methods:{
  118. initData(res){
  119. if(res.length>0){
  120. for (var i = 0, j = res.length; i < j; i += this.pageSize) {
  121. this.hotProductList.push(res.slice(i, i + this.pageSize));
  122. }
  123. }
  124. },
  125. PromotionsFormat(promo){//促销活动类型数据处理
  126. if(promo!=null){
  127. if(promo.type == 1 && promo.mode == 1){
  128. return true
  129. }else{
  130. return false
  131. }
  132. }
  133. return false
  134. },
  135. tabClick(index) {//轮播图切换
  136. this.current = index;
  137. },
  138. swiperChange(e) {//轮播切换
  139. const index = e.detail.current;
  140. this.swiperCurrent = index;
  141. },
  142. navToDetailPage(id) {//跳转商品详情页
  143. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  144. }
  145. }
  146. }
  147. </script>
  148. <style lang="scss">
  149. .container{
  150. width: 100%;
  151. height: auto;
  152. box-sizing: border-box;
  153. .title{
  154. width: 100%;
  155. height: 80rpx;
  156. line-height: 80rpx;
  157. text-align: left;
  158. font-weight: bold;
  159. font-size: $font-size-34;
  160. color: $text-color;
  161. padding: 0 24rpx;
  162. box-sizing: border-box;
  163. }
  164. .recommend-list{
  165. width: 100%;
  166. height: 1080rpx;
  167. position: relative;
  168. padding-bottom: 20rpx;
  169. .tui-banner-swiper {
  170. width: 702rpx;
  171. margin: 0 auto;
  172. background: #F7F7F7;
  173. padding: 0 24rpx 0 24rpx;
  174. height: 1080rpx;
  175. overflow: hidden;
  176. transform: translateY(0);
  177. .floor-item{
  178. width: 341rpx;
  179. height: auto;
  180. margin-right: 20rpx;
  181. font-size: $font-size-24;
  182. color: $text-color;
  183. background: #FFFFFF;
  184. line-height: 36rpx;
  185. border-radius: 2rpx;
  186. margin-bottom: 20rpx;
  187. float: left;
  188. box-sizing: border-box;
  189. padding-bottom: 10rpx;
  190. &:nth-child(2n){
  191. margin-right: 0;
  192. }
  193. .item-img{
  194. width: 341rpx;
  195. height: 341rpx;
  196. border-radius: 2rpx 2rpx 0 0;
  197. display: block;
  198. margin-bottom: 20rpx;
  199. }
  200. .floor-item-content{
  201. width: 311rpx;
  202. padding: 0 15rpx;
  203. }
  204. .floor-item-act{
  205. display: block;
  206. width: 100%;
  207. height: 68rpx;
  208. text-align: center;
  209. box-sizing: border-box;
  210. padding: 16rpx 0;
  211. margin-top: 8rpx;
  212. }
  213. .floor-tags{
  214. height: 36rpx;
  215. border-radius: 6rpx;
  216. background-color: #FFFFFF;
  217. line-height: 36rpx;
  218. color: $color-system;
  219. text-align: center;
  220. display: inline-block;
  221. padding:0 16rpx;
  222. font-size: $font-size-20;
  223. margin-left: 15rpx;
  224. border: 1px solid #E15616;
  225. }
  226. .title-none{
  227. font-size: $font-size-26;
  228. color: #FF2A2A;
  229. line-height: 44rpx;
  230. .btn{
  231. display: inline-block;
  232. float: right;
  233. width: 112rpx;
  234. height: 44rpx;
  235. background: $btn-confirm;
  236. line-height: 44rpx;
  237. font-size: $font-size-24;
  238. color: #FFFFFF;
  239. text-align: center;
  240. border-radius: 22rpx;
  241. margin-top: 17rpx;
  242. }
  243. }
  244. .title{
  245. width: 100%;
  246. height: 72rpx;
  247. display: flex;
  248. flex-direction: column;
  249. margin-bottom: 15rpx;
  250. .mclap{
  251. width: 100%;
  252. line-height:40rpx;
  253. text-overflow:ellipsis;
  254. display: -webkit-box;
  255. word-break: break-all;
  256. -webkit-box-orient: vertical;
  257. -webkit-line-clamp: 2;
  258. overflow: hidden;
  259. font-size: 26rpx;
  260. }
  261. }
  262. .no-price{
  263. height: 54rpx;
  264. line-height: 54rpx;
  265. display: flex;
  266. box-sizing: border-box;
  267. .p-no{
  268. font-size: $font-size-30;
  269. color: $text-color;
  270. display: block;
  271. float: left;
  272. }
  273. .p-stars{
  274. float: left;
  275. }
  276. }
  277. .price{
  278. color: #FF2A2A;
  279. line-height:70rpx;
  280. &.none{
  281. text-decoration: line-through;
  282. color: #999999;
  283. }
  284. .sm{
  285. font-size: $font-size-24;
  286. }
  287. .big{
  288. font-size: $font-size-28;
  289. }
  290. }
  291. }
  292. }
  293. }
  294. .swiper__recommenddots-box{
  295. position: absolute;
  296. bottom: 0;
  297. left: 0;
  298. right: 0;
  299. /* #ifndef APP-NVUE */
  300. display: flex;
  301. /* #endif */
  302. flex: 1;
  303. flex-direction: row;
  304. justify-content: center;
  305. align-items: center;
  306. height: 60rpx;
  307. .swiper__dots-item{
  308. width: 8rpx;
  309. height: 8rpx;
  310. border-radius: 100%;
  311. margin-left: 6px;
  312. background-color:rgba(225,86,22,.3);
  313. }
  314. .swiper__dots-long{
  315. width: 32rpx;
  316. height: 8rpx;
  317. border-radius: 4rpx;
  318. background-color: #e15616;
  319. transition: all 0.4s;
  320. }
  321. }
  322. }
  323. </style>