index.vue 6.6 KB

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