hotProduct.vue 8.6 KB

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