hotProduct.vue 10 KB

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