hotProduct.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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: 1160rpx;
  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: 1160rpx;
  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. position: relative;
  219. &:nth-child(2n){
  220. margin-right: 0;
  221. }
  222. .item-icon-type{
  223. width: 48rpx;
  224. height: 62rpx;
  225. display: block;
  226. position: absolute;
  227. top: 20rpx;
  228. right: 20rpx;
  229. }
  230. .item-img{
  231. width: 341rpx;
  232. height: 341rpx;
  233. border-radius: 2rpx 2rpx 0 0;
  234. display: block;
  235. margin-bottom: 20rpx;
  236. }
  237. .floor-item-content{
  238. width: 311rpx;
  239. padding: 0 20rpx;
  240. }
  241. .floor-item-act{
  242. display: block;
  243. width: 100%;
  244. height: 32rpx;
  245. text-align: center;
  246. box-sizing: border-box;
  247. }
  248. .floor-tags{
  249. height: 28rpx;
  250. border-radius: 6rpx;
  251. background-color: #FFFFFF;
  252. line-height: 28rpx;
  253. color: $color-system;
  254. text-align: center;
  255. display: inline-block;
  256. padding:0 16rpx;
  257. font-size: $font-size-20;
  258. border: 1px solid #E15616;
  259. float: left;
  260. }
  261. .title-none{
  262. font-size: $font-size-26;
  263. color: #FF2A2A;
  264. line-height: 70rpx;
  265. .btn{
  266. display: inline-block;
  267. float: right;
  268. width: 112rpx;
  269. height: 44rpx;
  270. background: $btn-confirm;
  271. line-height: 44rpx;
  272. font-size: $font-size-24;
  273. color: #FFFFFF;
  274. text-align: center;
  275. border-radius: 22rpx;
  276. margin-top: 17rpx;
  277. }
  278. }
  279. .title{
  280. width: 100%;
  281. height: 72rpx;
  282. display: flex;
  283. line-height: 36rpx;
  284. flex-direction: column;
  285. margin-bottom: 15rpx;
  286. padding: 0;
  287. .mclap{
  288. width: 100%;
  289. line-height:40rpx;
  290. text-overflow:ellipsis;
  291. display: -webkit-box;
  292. word-break: break-all;
  293. -webkit-box-orient: vertical;
  294. -webkit-line-clamp: 2;
  295. overflow: hidden;
  296. font-size: 26rpx;
  297. }
  298. }
  299. .no-price{
  300. height: 70rpx;
  301. line-height: 70rpx;
  302. display: flex;
  303. box-sizing: border-box;
  304. .p-no{
  305. font-size: $font-size-30;
  306. color: $text-color;
  307. display: block;
  308. float: left;
  309. }
  310. .p-stars{
  311. float: left;
  312. }
  313. }
  314. .price{
  315. color: #FF2A2A;
  316. line-height:70rpx;
  317. &.none{
  318. text-decoration: line-through;
  319. color: #999999;
  320. }
  321. .sm{
  322. font-size: $font-size-24;
  323. }
  324. .big{
  325. font-size: $font-size-28;
  326. }
  327. }
  328. }
  329. }
  330. }
  331. .swiper__recommenddots-box{
  332. position: absolute;
  333. bottom: 0;
  334. left: 0;
  335. right: 0;
  336. /* #ifndef APP-NVUE */
  337. display: flex;
  338. /* #endif */
  339. flex: 1;
  340. flex-direction: row;
  341. justify-content: center;
  342. align-items: center;
  343. height: 60rpx;
  344. .swiper__dots-item{
  345. width: 8rpx;
  346. height: 8rpx;
  347. border-radius: 100%;
  348. margin-left: 6px;
  349. background-color:rgba(225,86,22,.3);
  350. }
  351. .swiper__dots-long{
  352. width: 32rpx;
  353. height: 8rpx;
  354. border-radius: 4rpx;
  355. background-color: #e15616;
  356. transition: all 0.4s;
  357. }
  358. }
  359. }
  360. </style>