hotProduct.vue 11 KB

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