hotProduct.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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. this.initData(this.list)
  135. },
  136. computed: {
  137. ...mapState(['hasLogin','userInfo','isActivity'])
  138. },
  139. methods:{
  140. initData(res){
  141. this.$api.getStorage().then((resolve) =>{
  142. this.shopId = resolve.shopID
  143. })
  144. if(res.length>0){
  145. for (var i = 0, j = res.length; i < j; i += this.pageSize) {
  146. this.hotProductList.push(res.slice(i, i + this.pageSize));
  147. }
  148. }
  149. },
  150. PromotionsFormat(promo){//促销活动类型数据处理
  151. if(promo!=null){
  152. if(promo.type == 1 && promo.mode == 1){
  153. return true
  154. }else{
  155. return false
  156. }
  157. }
  158. return false
  159. },
  160. tabClick(index) {//轮播图切换
  161. this.current = index;
  162. },
  163. swiperChange(e) {//轮播切换
  164. const index = e.detail.current;
  165. this.swiperCurrent = index;
  166. },
  167. navToDetailPage(id) {//跳转商品详情页
  168. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  169. }
  170. }
  171. }
  172. </script>
  173. <style lang="scss">
  174. .container{
  175. width: 100%;
  176. height: auto;
  177. box-sizing: border-box;
  178. .title-header{
  179. width: 100%;
  180. height: 80rpx;
  181. line-height: 80rpx;
  182. text-align: left;
  183. font-weight: bold;
  184. font-size: $font-size-34;
  185. color: $text-color;
  186. padding: 0 24rpx;
  187. box-sizing: border-box;
  188. }
  189. .recommend-list{
  190. width: 100%;
  191. height: 1140rpx;
  192. position: relative;
  193. padding-bottom: 20rpx;
  194. .tui-banner-swiper {
  195. width: 702rpx;
  196. margin: 0 auto;
  197. background: #F7F7F7;
  198. padding: 0 24rpx 0 24rpx;
  199. height: 1140rpx;
  200. overflow: hidden;
  201. transform: translateY(0);
  202. .floor-item{
  203. width: 341rpx;
  204. height: auto;
  205. margin-right: 20rpx;
  206. font-size: $font-size-24;
  207. color: $text-color;
  208. background: #FFFFFF;
  209. line-height: 36rpx;
  210. border-radius: 2rpx;
  211. margin-bottom: 20rpx;
  212. float: left;
  213. box-sizing: border-box;
  214. padding-bottom: 10rpx;
  215. position: relative;
  216. &:nth-child(2n){
  217. margin-right: 0;
  218. }
  219. .item-icon-type{
  220. width: 48rpx;
  221. height: 62rpx;
  222. display: block;
  223. position: absolute;
  224. top: 20rpx;
  225. right: 20rpx;
  226. }
  227. .item-img{
  228. width: 341rpx;
  229. height: 341rpx;
  230. border-radius: 2rpx 2rpx 0 0;
  231. display: block;
  232. margin-bottom: 20rpx;
  233. }
  234. .floor-item-content{
  235. width: 311rpx;
  236. padding: 0 20rpx;
  237. }
  238. .floor-item-act{
  239. display: block;
  240. width: 100%;
  241. height: 32rpx;
  242. text-align: center;
  243. box-sizing: border-box;
  244. }
  245. .floor-tags{
  246. height: 28rpx;
  247. border-radius: 6rpx;
  248. background-color: #FFFFFF;
  249. line-height: 28rpx;
  250. color: $color-system;
  251. text-align: center;
  252. display: inline-block;
  253. padding:0 16rpx;
  254. font-size: $font-size-20;
  255. border: 1px solid #E15616;
  256. float: left;
  257. }
  258. .title-none{
  259. font-size: $font-size-26;
  260. color: #FF2A2A;
  261. line-height: 70rpx;
  262. .btn{
  263. display: inline-block;
  264. float: right;
  265. width: 112rpx;
  266. height: 44rpx;
  267. background: $btn-confirm;
  268. line-height: 44rpx;
  269. font-size: $font-size-24;
  270. color: #FFFFFF;
  271. text-align: center;
  272. border-radius: 22rpx;
  273. margin-top: 17rpx;
  274. }
  275. }
  276. .title{
  277. width: 100%;
  278. height: 72rpx;
  279. display: flex;
  280. line-height: 36rpx;
  281. flex-direction: column;
  282. margin-bottom: 15rpx;
  283. padding: 0;
  284. .mclap{
  285. width: 100%;
  286. line-height:40rpx;
  287. text-overflow:ellipsis;
  288. display: -webkit-box;
  289. word-break: break-all;
  290. -webkit-box-orient: vertical;
  291. -webkit-line-clamp: 2;
  292. overflow: hidden;
  293. font-size: 26rpx;
  294. }
  295. }
  296. .no-price{
  297. height: 54rpx;
  298. line-height: 54rpx;
  299. display: flex;
  300. box-sizing: border-box;
  301. .p-no{
  302. font-size: $font-size-30;
  303. color: $text-color;
  304. display: block;
  305. float: left;
  306. }
  307. .p-stars{
  308. float: left;
  309. }
  310. }
  311. .price{
  312. color: #FF2A2A;
  313. line-height:54rpx;
  314. &.none{
  315. text-decoration: line-through;
  316. color: #999999;
  317. }
  318. .sm{
  319. font-size: $font-size-24;
  320. }
  321. .big{
  322. font-size: $font-size-28;
  323. }
  324. }
  325. }
  326. }
  327. }
  328. .swiper__recommenddots-box{
  329. position: absolute;
  330. bottom: 0;
  331. left: 0;
  332. right: 0;
  333. /* #ifndef APP-NVUE */
  334. display: flex;
  335. /* #endif */
  336. flex: 1;
  337. flex-direction: row;
  338. justify-content: center;
  339. align-items: center;
  340. height: 60rpx;
  341. .swiper__dots-item{
  342. width: 8rpx;
  343. height: 8rpx;
  344. border-radius: 100%;
  345. margin-left: 6px;
  346. background-color:rgba(225,86,22,.3);
  347. }
  348. .swiper__dots-long{
  349. width: 32rpx;
  350. height: 8rpx;
  351. border-radius: 4rpx;
  352. background-color: #e15616;
  353. transition: all 0.4s;
  354. }
  355. }
  356. }
  357. </style>