HotProduct.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <view class="group-goods" v-if="detail.length>0">
  3. <view class="title-box x-bc" >
  4. <text class="title">热门榜单</text>
  5. <view class="group-people x-f" @tap="navTo('/pages/home/productList')">
  6. <text class="tip">更多</text>
  7. <text class="cuIcon-right"></text>
  8. </view>
  9. </view>
  10. <view class="goods-box swiper-box x-f">
  11. <swiper class="carousel" circular @change="swiperChange" :autoplay="true" interval="10000" duration="2000">
  12. <swiper-item v-for="(goods, index) in goodsList" :key="index" class="carousel-item">
  13. <view class="goods-list-box x-f" style="align-items: flex-start;">
  14. <block v-for="mgoods in goods" :key="mgoods.productId" >
  15. <view class="min-goods" @tap="showProduct(mgoods)" >
  16. <view class="img-box">
  17. <view class="tag">hot</view>
  18. <image class="img" :src="mgoods.image" mode="widthFix"></image>
  19. </view>
  20. <view class="price-box">
  21. <view class="y-f">
  22. <text class="seckill-current" v-if="userinfoa.isShow==1&&isuser==false">¥{{ mgoods.price }}</text>
  23. <text class="seckill-current" v-else >¥{{ mgoods.otPrice }}</text>
  24. <text class="original" v-if="userinfoa.isShow==1&&isuser==false">销量{{ mgoods.sales }}{{mgoods.unitName}}</text>
  25. </view>
  26. </view>
  27. <view class="title">
  28. <slot name="titleText"></slot>
  29. </view>
  30. </view>
  31. </block>
  32. </view>
  33. </swiper-item>
  34. </swiper>
  35. <view class="swiper-dots" v-if="goodsList.length > 1">
  36. <text :class="swiperCurrent === index ? 'dot-active' : 'dot'" v-for="(dot, index) in goodsList.length"
  37. :key="index"></text>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import {getUserInfo} from '@/api/user'
  44. export default {
  45. name: "HotProduct",
  46. data() {
  47. return {
  48. goodsList: [],
  49. swiperCurrent: 0,
  50. userinfoa:[],
  51. isuser:false,
  52. };
  53. },
  54. props: {
  55. detail: Array
  56. },
  57. computed: {},
  58. created() {},
  59. watch: {
  60. detail(next) {
  61. this.goodsList = this.sortData(next, 4);
  62. }
  63. },
  64. mounted() {
  65. if(uni.getStorageSync('AppToken')){
  66. this.getUserInfos()
  67. }else{
  68. this.isuser=true
  69. }
  70. },
  71. methods: {
  72. getUserInfos(){
  73. getUserInfo().then(res => {
  74. if(res.code==200){
  75. if(res.user!=null){
  76. // if(res.user.isPromoter==null||res.user.isPromoter==0){
  77. // this.tuiModalControl=true
  78. // }
  79. this.userinfoa=res.user
  80. console.log(this.userinfoa.isShow,78787)
  81. }
  82. }else{
  83. uni.showToast({
  84. icon:'none',
  85. title: "请求失败",
  86. });
  87. }
  88. },
  89. rej => {}
  90. );
  91. },
  92. swiperChange(e) {
  93. this.swiperCurrent = e.detail.current;
  94. },
  95. // 数据分层
  96. sortData(oArr, length) {
  97. console.log("=====")
  98. let arr = [];
  99. let minArr = [];
  100. oArr.forEach(c => {
  101. if (minArr.length === length) {
  102. minArr = [];
  103. }
  104. if (minArr.length === 0) {
  105. arr.push(minArr);
  106. }
  107. minArr.push(c);
  108. });
  109. return arr;
  110. },
  111. navTo(url){
  112. uni.navigateTo({
  113. url: url
  114. })
  115. },
  116. showProduct(item){
  117. uni.navigateTo({
  118. url: '/pages/shopping/productDetails?productId='+item.productId
  119. })
  120. },
  121. }
  122. }
  123. </script>
  124. <style lang="scss" scoped>
  125. .group-goods {
  126. position: relative;
  127. z-index: 1;
  128. background: #FFFFFF;
  129. border-radius: 16upx;
  130. margin-bottom: 20upx;
  131. margin-top: 20upx;
  132. padding: 20upx;
  133. }
  134. .swiper-box,
  135. .carousel {
  136. width: 700rpx;
  137. height: 240upx;
  138. position: relative;
  139. border-radius: 20rpx;
  140. .carousel-item {
  141. width: 100%;
  142. height: 100%;
  143. // padding: 0 28upx;
  144. overflow: hidden;
  145. }
  146. .swiper-image {
  147. width: 100%;
  148. height: 100%;
  149. // border-radius: 10upx;
  150. background: #ccc;
  151. }
  152. }
  153. .swiper-dots {
  154. display: flex;
  155. position: absolute;
  156. left: 50%;
  157. transform: translateX(-50%);
  158. bottom: 0rpx;
  159. z-index: 66;
  160. .dot {
  161. width: 45rpx;
  162. height: 3rpx;
  163. background: #eee;
  164. border-radius: 50%;
  165. margin-right: 10rpx;
  166. }
  167. .dot-active {
  168. width: 45rpx;
  169. height: 3rpx;
  170. background: #a8700d;
  171. border-radius: 50%;
  172. margin-right: 10rpx;
  173. }
  174. }
  175. // 今日必拼+限时抢购
  176. .group-goods {
  177. background: #fff;
  178. border-radius: 20rpx;
  179. overflow: hidden;
  180. .title-box {
  181. padding-bottom: 20rpx;
  182. .title {
  183. font-size: 32rpx;
  184. font-weight: bold;
  185. }
  186. .group-people {
  187. .time-box {
  188. font-size: 26rpx;
  189. color: #edbf62;
  190. .count-text-box {
  191. width: 30rpx;
  192. height: 34rpx;
  193. background: #edbf62;
  194. text-align: center;
  195. line-height: 34rpx;
  196. font-size: 24rpx;
  197. border-radius: 6rpx;
  198. color: rgba(#fff, 0.9);
  199. margin: 0 8rpx;
  200. }
  201. }
  202. .head-box {
  203. .head-img {
  204. width: 40rpx;
  205. height: 40rpx;
  206. border-radius: 50%;
  207. background: #ccc;
  208. }
  209. }
  210. .tip {
  211. font-size: 24rpx;
  212. padding-left: 30rpx;
  213. color: #999999;
  214. }
  215. .cuIcon-right {
  216. font-size: 30rpx;
  217. line-height: 28rpx;
  218. color: #666;
  219. }
  220. }
  221. }
  222. .goods-box {
  223. .goods-item {
  224. margin-right: 22rpx;
  225. &:nth-child(4n) {
  226. margin-right: 0;
  227. }
  228. }
  229. }
  230. .min-goods{
  231. margin-right: 22rpx;
  232. }
  233. }
  234. .min-goods {
  235. width: 152rpx;
  236. background: #fff;
  237. .img-box {
  238. width: 152rpx;
  239. height: 152rpx;
  240. overflow: hidden;
  241. position: relative;
  242. .tag {
  243. position: absolute;
  244. left: 0;
  245. bottom: 0rpx;
  246. z-index: 2;
  247. line-height: 35rpx;
  248. background: linear-gradient(132deg, rgba(243, 223, 177, 1), rgba(243, 223, 177, 1), rgba(236, 190, 96, 1));
  249. border-radius: 0px 18rpx 18rpx 0px;
  250. padding: 0 10rpx;
  251. font-size: 24rpx;
  252. font-family: PingFang SC;
  253. font-weight: bold;
  254. color: rgba(120, 79, 6, 1);
  255. }
  256. .img {
  257. width: 100%;
  258. background-color: #ccc;
  259. }
  260. }
  261. .price-box {
  262. width: 100%;
  263. margin-top: 10rpx;
  264. .seckill-current {
  265. font-size: 30rpx;
  266. font-weight: 500;
  267. color: rgba(225, 33, 43, 1);
  268. }
  269. .original {
  270. font-size: 20rpx;
  271. font-weight: 400;
  272. // text-decoration: line-through;
  273. color: rgba(153, 153, 153, 1);
  274. margin-left: 14rpx;
  275. }
  276. }
  277. .title {
  278. font-size: 26rpx;
  279. }
  280. }
  281. </style>