index.vue 6.9 KB

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