index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <view class="pages">
  3. <view class="page-bg">
  4. <img class="img" :src="staticUrl+'/img/index-bg.png'" alt="">
  5. </view>
  6. <view class="page-wrap">
  7. <u-swiper
  8. :list="bannerList"
  9. indicator
  10. indicatorMode="dot"
  11. @click="bannerClick"
  12. ></u-swiper>
  13. <view class="advantage u-flex u-row-around">
  14. <view class="u-flex">
  15. <u-icon :size="advantageSize" class="icon" :name="staticUrl+'/img/zheng.png'"></u-icon>
  16. 正品保证
  17. </view>
  18. <view class="u-flex">
  19. <u-icon :size="advantageSize" class="icon" :name="staticUrl+'/img/pei.png'"></u-icon>
  20. 假一赔十
  21. </view>
  22. <view class="u-flex">
  23. <u-icon :size="advantageSize" class="icon" :name="staticUrl+'/img/rmb.png'"></u-icon>
  24. 性价比高
  25. </view>
  26. </view>
  27. <view class="icon-nav u-flex u-row-around">
  28. <view class="nav-item" @click="$u.route('/shopping/productList',{typeId:1,typeName:'特价专区',type:'redirectTo'})">
  29. <u--image class="image" :src="staticUrl+'/img/index-nav-1.png'" width="101rpx" height="101rpx"></u--image>
  30. 特价专区
  31. </view>
  32. <view class="nav-item" @click="$u.route('/shopping/productList',{typeId:2,typeName:'爆款专区',type:'redirectTo'})">
  33. <u--image class="image" :src="staticUrl+'/img/index-nav-2.png'" width="101rpx" height="101rpx"></u--image>
  34. 爆款专区
  35. </view>
  36. <view class="nav-item">
  37. <u--image class="image" :src="staticUrl+'/img/index-nav-3.png'" width="101rpx" height="101rpx"></u--image>
  38. 积分商城
  39. </view>
  40. <view class="nav-item">
  41. <u--image class="image" :src="staticUrl+'/img/index-nav-4.png'" width="101rpx" height="101rpx"></u--image>
  42. 充值中心
  43. </view>
  44. </view>
  45. <view class="index-img">
  46. <u--image class="image" src="https://cdn.uviewui.com/uview/swiper/swiper2.png" width="100%" height="161rpx" radius="15rpx" @click="click"></u--image>
  47. </view>
  48. <view class="hot-product">
  49. <view class="single-til u-flex u-row-between">
  50. <text class="text">热销产品</text>
  51. <view class="u-flex" @click="$u.route('/shopping/productList',{typeId:1,typeName:'热销产品',type:'redirectTo'})">
  52. <text class="more-text">更多</text>
  53. <u-icon name="arrow-right" color="#676767" size="24rpx"></u-icon>
  54. </view>
  55. </view>
  56. <view class="product u-flex" @click="$u.route('/shopping/productdetails',{id:item.id})" v-for="item in hotGoods" :key="item.id">
  57. <u--image :showLoading="true" :src="item.mainImg" width="180rpx" height="180rpx"></u--image>
  58. <view class="text">
  59. <view class="name ellipsis-2">{{item.goodsName}}</view>
  60. <view class="u-flex u-row-between">
  61. <view class="left">
  62. <view class="up">
  63. <view class="" v-if="vuex_member_info.levelType>1">
  64. <text class="price">¥ <text class="price-num">{{item.vipPrice}}</text></text>
  65. <text class="vip-icon">VIP</text>
  66. </view>
  67. <view class="" v-else>
  68. <text class="price">¥ <text class="price-num">{{item.salePrice}}</text></text>
  69. </view>
  70. </view>
  71. <view class="down">
  72. <!-- <text class="discount">8.8折</text> -->
  73. <text v-if="vuex_member_info.levelType>1" class="original-price gray line-through">¥ {{item.salePrice}}</text>
  74. <!-- <text class="sales gray">销量 {{item.salePrice}}</text> -->
  75. </view>
  76. </view>
  77. <u--image :showLoading="false" @click.native.stop="addCart(item.id)" :src="staticUrl+'/img/add.png'" width="48rpx" height="48rpx"></u--image>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. <tabbar :tabbarIndexProps='0' />
  83. <cartfixed ref="cartfixed" @addToCart="addToCart" />
  84. </view>
  85. <u-toast ref="uToast"></u-toast>
  86. </view>
  87. </template>
  88. <script>
  89. import tabbar from "../../components/tabbar.vue";
  90. import cartfixed from "../../components/cartfixed.vue"
  91. export default {
  92. components:{
  93. tabbar,
  94. cartfixed
  95. },
  96. data() {
  97. return {
  98. staticUrl:this.$commonConfig.staticUrl,
  99. advantageSize:20,
  100. bannerList: [{
  101. url: 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
  102. title: '昨夜星辰昨夜风,画楼西畔桂堂东'
  103. },{
  104. url: 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
  105. title: '身无彩凤双飞翼,心有灵犀一点通'
  106. },{
  107. url: 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
  108. title: '谁念西风独自凉,萧萧黄叶闭疏窗,沉思往事立残阳'
  109. }],
  110. hotGoods:[]
  111. }
  112. },
  113. onLoad() {
  114. // let userInfo = uni.getStorageSync('userInfo');
  115. // console.log('userInfo',userInfo);
  116. this.getHotGoods()
  117. },
  118. methods: {
  119. bannerClick(e){
  120. console.log('bannerClick',e);
  121. },
  122. getHotGoods(){
  123. // {id:'111233',pageNum:1,pageSize:3,isExplode:1}
  124. this.$u.api.memberGoodList({pageNum:1,pageSize:3,isExplode:1}).then(res=>{
  125. this.hotGoods = res.data.rows;
  126. console.log('res',res);
  127. }).catch(err=>{
  128. console.log('err11111',err.data);
  129. })
  130. },
  131. addCart(id){
  132. // console.log('addCart',id);
  133. this.$u.api.addCart({goodsId:id}).then(res=>{
  134. this.$refs.uToast.show({
  135. type:"success",
  136. message:res.msg
  137. });
  138. this.$refs.cartfixed.addToCart(1);
  139. console.log('res',res);
  140. }).catch(err=>{
  141. console.log('addCart',err.data);
  142. })
  143. }
  144. }
  145. }
  146. </script>
  147. <style>
  148. page{
  149. background-color: #F9F9F9;
  150. }
  151. </style>
  152. <style lang="scss" scoped>
  153. .advantage{
  154. margin-top: 20rpx;
  155. margin-bottom: 50rpx;
  156. font-size: 20rpx;
  157. color: #ccc;
  158. /deep/ .u-icon{
  159. margin-right: 10rpx;
  160. }
  161. }
  162. .index-img{
  163. margin-bottom: 56rpx;
  164. }
  165. .hot-product{
  166. .product{
  167. padding: 30rpx;
  168. background-color: #fff;
  169. border: 0;
  170. }
  171. }
  172. </style>