hotProduct.vue 8.2 KB

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