hotProduct.vue 11 KB

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