index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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(query) {
  134. const scene = decodeURIComponent(query.scene);
  135. scene&&uni.setStorage({
  136. key:'scene',
  137. data:scene
  138. });
  139. // let userInfo = uni.getStorageSync('userInfo');
  140. // console.log('userInfo',userInfo);
  141. let that = this;
  142. this.swiperList();
  143. setTimeout(()=>{
  144. that.getCenterImg();
  145. },200);
  146. this.getSystemInfo();
  147. // console.log('statusBarHeight',this.statusBarHeight);
  148. // console.log('navigationBarHeight',this.navigationBarHeight);
  149. // console.log('windowHeight',this.windowHeight);
  150. // console.log('navHeight',this.navHeight);
  151. },
  152. onShow() {
  153. this.$refs.cartfixed.getCartList();
  154. this.getHotGoods();
  155. },
  156. methods: {
  157. swiperList(){
  158. this.$u.api.swiperList({postion:1}).then(res=>{
  159. this.bannerList = res.data.rows;
  160. // console.log('res',res.data.rows);
  161. }).catch(err=>{
  162. console.log('swiperList',err.data);
  163. })
  164. },
  165. getCenterImg(){
  166. this.$u.api.swiperList({postion:2}).then(res=>{
  167. this.centerImg = res.data.rows;
  168. // console.log('res',res.data.rows);
  169. }).catch(err=>{
  170. console.log('swiperList',err.data);
  171. })
  172. },
  173. bannerClick(e){
  174. // console.log('e',e);
  175. // console.log('bannerClick',this.bannerList[e]);
  176. let item = this.bannerList[e];
  177. uni.$u.route('/xushuo/dynamicdetails', {
  178. type: 'swiperDetail',
  179. id: item.id
  180. });
  181. },
  182. centerImgClick(e){
  183. let item = this.centerImg[e];
  184. uni.$u.route('/xushuo/dynamicdetails', {
  185. type: 'swiperDetail',
  186. id: item.id
  187. });
  188. },
  189. getHotGoods(){
  190. this.$u.api.topGoodList({pageNum:1,pageSize:20}).then(res=>{
  191. this.hotGoods = res.data.rows;
  192. console.log('res',res);
  193. }).catch(err=>{
  194. console.log('getHotGoods',err.data);
  195. })
  196. },
  197. addCart(id){
  198. // console.log('addCart',id);
  199. this.$u.api.addCart({goodsId:id}).then(res=>{
  200. this.$refs.cartfixed.getCartList('isAdd');
  201. console.log('res',res);
  202. }).catch(err=>{
  203. console.log('addCart',err.data);
  204. })
  205. },
  206. topSearch(){
  207. uni.$u.route('/shopping/productsearch', {
  208. goodsName: this.goodsName
  209. });
  210. // console.log('topSearch',this.goodsName);
  211. }
  212. }
  213. }
  214. </script>
  215. <style>
  216. page{
  217. background-color: #F9F9F9;
  218. padding-top: 0;
  219. }
  220. </style>
  221. <style lang="scss" scoped>
  222. .page-bg{
  223. .img{
  224. height: 100vh;
  225. }
  226. }
  227. .search-out{
  228. background-color: rgba(0,0,0,0.04);
  229. border-radius: 100rpx;
  230. margin-bottom: 20rpx;
  231. }
  232. .advantage{
  233. margin-top: 20rpx;
  234. margin-bottom: 50rpx;
  235. font-size: 22rpx;
  236. color: #ccc;
  237. /deep/ .u-icon{
  238. margin-right: 10rpx;
  239. }
  240. }
  241. .index-img{
  242. margin-bottom: 56rpx;
  243. }
  244. .hot-product{
  245. .product{
  246. padding: 30rpx;
  247. background-color: #fff;
  248. border: 0;
  249. }
  250. }
  251. </style>