index.vue 7.3 KB

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