index.vue 5.6 KB

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