index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view class="content">
  3. <view class="home-banner" v-if="bannerData.length>0">
  4. <swiper class="swiper" circular :autoplay="false" :interval="2000" :duration="200">
  5. <swiper-item class="swiper-item" v-for="(item,idex) in bannerData" :key="idex"><image :src="item.cover" mode="widthFix"></image></swiper-item>
  6. </swiper>
  7. </view>
  8. <view class="" v-else>
  9. <view class="skeleton">
  10. <view class="skeleton-line max animate" style="height: 200upx;"></view>
  11. </view>
  12. </view>
  13. <view class="home-store">
  14. <view class="store-left" @click="showService(1)">
  15. <view class="left">
  16. <image src="/static/image/kefu.png"></image>
  17. <view class="name">联系客服</view>
  18. </view>
  19. <view class="right" v-if="storeData">
  20. <text class="status success">{{storeData.start_at}}-{{storeData.end_at}}</text>
  21. <image src="/static/image/right-black.png"></image>
  22. </view>
  23. </view>
  24. <!-- <view class="store-right"><image src="/static/image/search.png"></image></view> -->
  25. </view>
  26. <view class="home-search"></view>
  27. <view class="empty-body" v-if="goodsData.length == 0">
  28. <view class="img">
  29. <image src="/static/image/empty.png" mode="widthFix"></image>
  30. <view class="tip">没有更多数据啦</view>
  31. </view>
  32. </view>
  33. <view class="home-goods" v-if="goodsData.length > 0">
  34. <view class="goods-item" v-for="(item,index) in goodsData" :key="index" @click="$dialog.jumpUri('/pages/goods/detail?goods='+item.product_id+'&spm='+item.id,1)">
  35. <view class="image"><image :src="item.image_list[0].url" mode="widthFix"></image></view>
  36. <view class="info">
  37. <view class="title">{{item.product_name}}</view>
  38. <view class="desc-num">已售{{item.sale_stock}}</view>
  39. <view class="price">
  40. <view class="price-left">
  41. <view class="pay-price">{{$dialog.formatMoney(item.price)}}</view>
  42. <view class="line-price">{{$dialog.formatMoney(item.line_price)}}</view>
  43. <view class="sale">{{$dialog.disFormat(item.price,item.line_price)}}折</view>
  44. </view>
  45. <view class="price-right">立即抢购</view>
  46. </view>
  47. </view>
  48. </view>
  49. <!-- <view class="goods-more">查看更多>></view> -->
  50. </view>
  51. <uni-popup ref="userpopup" type="bottom" border-radius="10px 10px 0 0" background-color="#ffffff" :mask-click="false">
  52. <view class="service-popup">
  53. <view class="top">
  54. <view class="item">客服时间:{{storeData.start_at}}-{{storeData.end_at}}</view>
  55. <view class="item">
  56. <button class="btn" @click="$dialog.jumpUri('/pages/service/chat/chat?poi='+storeData.poi_id+'&source=home',1);showService(2)">在线咨询商家</button>
  57. </view>
  58. <view class="item" v-if="storeData.service_mobile" @click="callMobile(storeData.service_mobile)">商家客服电话</view>
  59. </view>
  60. <view class="foot" @click="showService(2)">取消</view>
  61. </view>
  62. </uni-popup>
  63. </view>
  64. </template>
  65. <script>
  66. var app;
  67. import * as Api from "@/static/api/home.js";
  68. export default {
  69. data() {
  70. return {
  71. bannerData:[],
  72. goodsData:{},
  73. storeId:"",
  74. storeData:null
  75. }
  76. },
  77. onLoad({store}) {
  78. app = this;
  79. var poiId = uni.getStorageSync("poiId");
  80. if (!poiId && !store) {
  81. app.storeId = "7644106137976965139";
  82. } else {
  83. app.storeId = poiId;
  84. }
  85. app.getData()
  86. },
  87. methods: {
  88. getData(){
  89. if (!app.storeId) return ;
  90. Api.data({"store":app.storeId}).then((res)=>{
  91. if (res.code !== 1) {
  92. return app.$dialog.showSuccess(res.msg)
  93. }
  94. uni.setStorageSync("poiId",res.data.store.poi_id);
  95. app.storeData = res.data.store;
  96. app.goodsData = res.data.goods;
  97. uni.setStorageSync("contact",res.data.store);
  98. app.bannerData = res.data.banner;
  99. })
  100. },
  101. callMobile(mobile){
  102. uni.makePhoneCall({
  103. phoneNumber:mobile,
  104. success(res) {
  105. console.log(res)
  106. },fail(res) {
  107. console.log(res)
  108. }
  109. })
  110. },
  111. showService(type){
  112. if (type == 1) {
  113. uni.hideTabBar()
  114. app.$refs.userpopup.open()
  115. } else {
  116. this.$nextTick(() => {
  117. uni.showTabBar()
  118. })
  119. app.$refs.userpopup.close()
  120. }
  121. }
  122. }
  123. }
  124. </script>
  125. <style>
  126. page{background-color: #f8f8f8;}
  127. .service-popup .item{height: 100upx;line-height: 100upx;text-align: center;font-size: 28upx;color: #333;border-bottom: 2upx solid #f8f8f8;}
  128. .service-popup .item .btn{background-color: #fff;border: 0;height: 100upx;line-height: 100upx;text-align: center;font-size: 28upx;color: #333;}
  129. .service-popup .item .btn::after{border: 0;}
  130. .service-popup .foot{height: 100upx;line-height: 100upx;text-align: center;font-size: 28upx;color: #333;border-top: 20upx solid #f8f8f8;}
  131. .goods-item{background-color: #fff;border-radius: 10upx;display: flex;align-items: center;margin-top: 20upx;}
  132. .goods-item .image{height: 200upx;overflow: hidden;}
  133. .goods-item .image image{width: 200upx;}
  134. .goods-item .info{margin-left: 20upx;padding: 20upx 0;flex: 1;}
  135. .goods-item .title{font-size: 28upx;display: -webkit-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical;overflow: hidden;}
  136. .goods-item .desc-num{color: #999;font-size: 24upx;margin: 10upx 0;}
  137. .goods-item .price{display: flex;align-items: center;}
  138. .goods-item .price .price-left{display: flex;align-items: center;}
  139. .goods-item .price .pay-price{color: #FF4747;font-size: 32rpx;font-weight: bold;margin-right: 10upx;}
  140. .goods-item .price .line-price{color: #999999;font-size: 22rpx;text-decoration-line: line-through;margin-right: 10upx;}
  141. .goods-item .price .sale{background-color: #FDEBE5;border: 4rpx;font-size: 22rpx;color: #FF4747;padding: 10rpx;}
  142. .goods-item .price .price-right{margin-left: auto;margin-right: 20upx;background-color: #EB3434;color: #fff;font-size: 24upx;padding: 10upx;border-radius: 10upx;}
  143. .content{padding: 20upx;}
  144. .home-banner image{width: 100%;border-radius: 20upx;height: auto;}
  145. .home-banner .swiper{height: 380upx;}
  146. .home-store{margin: 20upx auto;display: flex;align-items: center;gap: 20upx;}
  147. .home-store .store-left{background-color: #fff;border-radius: 10upx;display: flex;align-items: center;padding: 30upx;flex: 1;}
  148. .home-store .store-right{width: 120upx;height: 120upx;background-color: #fff;text-align: center;display: flex;align-items: center;justify-content: center;margin-left: auto;margin-right: 0;border-radius: 10upx;}
  149. .home-store .store-right image{width: 60upx;height: 60upx;}
  150. .home-store .left{display: flex;align-items: center;}
  151. .home-store .left image{width: 60upx;height: 60upx;margin-right: 20upx;}
  152. .home-store .right {margin-left: auto;margin-right: 0;display: flex;align-items: center;}
  153. .home-store .right image{width: 50upx;height: 50upx;}
  154. .home-store .name{font-size: 32upx;color: #000;font-weight: bold;}
  155. .home-store .desc{font-size: 26upx;color: #666;margin-top: 20upx;}
  156. .home-store .status{color: #333;font-size: 28upx;padding:5upx 15upx;border-radius: 10upx;margin-left: 10upx;}
  157. .home-store .status.error{background-color: #fef0f0;color: #f56c6c;}
  158. .goods-more{background-color: #fff;text-align: center;font-size: 24upx;font-weight: bold;margin-top: 20upx;border-radius: 10upx;padding: 20upx 0;}
  159. .empty-body{display: flex;align-items: center;justify-content: center;flex-direction: column;height: 40vh;}
  160. .empty-body .img{text-align: center;font-size: 28upx;color: #666;}
  161. .empty-body .img image{height: 160upx;width: 160upx;}
  162. .empty-body .img .tip{margin-top: 20upx;}
  163. .empty-body .re-btn{width: 180upx;height: 80upx;line-height: 80upx;text-align: center;font-size: 28upx;color: #fff;background-color: #007aff;border-radius: 10upx;margin-top: 60upx;}
  164. </style>