hotProduct.vue 10 KB

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