index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <view class="content">
  3. <view class="store-info" v-if="loading">
  4. <view class="store-header">
  5. <view class="logo"><view class="skeleton-line animate"></view></view>
  6. <view class="info">
  7. <view class="skeleton-line animate"></view>
  8. <view class="skeleton-line animate mt15"></view>
  9. </view>
  10. </view>
  11. <view class="store-detail">
  12. <view class="detail-left">
  13. <view class="skeleton-line animate"></view>
  14. <view class="skeleton-line animate mt15"></view>
  15. </view>
  16. </view>
  17. <view class="store-goods">
  18. <view class="goods-item" v-for="(item,index) in 3" :key="index">
  19. <view class="image"><view class="skeleton-line animate"></view></view>
  20. <view class="info">
  21. <view class="skeleton-line animate"></view>
  22. <view class="skeleton-line animate mt15"></view>
  23. <view class="skeleton-line animate mt15"></view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="store-info" v-else>
  29. <view class="store-header">
  30. <view class="logo"><image :src="storeData.poi_logo" class="animate"></image></view>
  31. <view class="info">
  32. <view class="title">{{ storeData.poi_name }}</view>
  33. <view class="time">营业时间:{{ storeData.start_at }} - {{ storeData.end_at }}</view>
  34. </view>
  35. <view class="right-item" @click="showService(1)">
  36. <view class="icon"><image src="/static/image/kf.svg"></image></view>
  37. <view class="name">联系商家</view>
  38. </view>
  39. </view>
  40. <view class="store-detail" @click="toMap">
  41. <view class="detail-left">
  42. <view class="city">{{ storeData.poi_city }}</view>
  43. <view class="address">{{ storeData.poi_address }}</view>
  44. </view>
  45. <view class="detail-arrow"><image src="/static/image/right.png"></image></view>
  46. </view>
  47. <view class="empty-body" v-if="goodsData.length == 0">
  48. <view class="img">
  49. <image src="/static/image/empty.png" mode="widthFix"></image>
  50. <view class="tip">没有更多数据啦</view>
  51. </view>
  52. </view>
  53. <view class="store-goods" v-else>
  54. <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)">
  55. <view class="image"><image :src="item.image_list[0].url"></image></view>
  56. <view class="info">
  57. <view class="title">{{item.product_name}}</view>
  58. <view class="desc-num">
  59. <view class="sale">{{$dialog.disFormat(item.price,item.line_price)}}折</view>
  60. <view class="number-desc">已售{{item.sale_stock}}</view>
  61. </view>
  62. <view class="price">
  63. <view class="price-left">
  64. <view class="pay-price">{{$dialog.formatMoney(item.price)}}</view>
  65. <view class="line-price">{{$dialog.formatMoney(item.line_price)}}</view>
  66. </view>
  67. <view class="price-right">抢购</view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. <view class="goods-more" v-if="goodsParam.isMore" @click="getGoods">{{ goodsParam.loading?'努力加载中...':'查看更多' }}</view>
  73. </view>
  74. <uni-popup ref="userpopup" type="bottom" border-radius="10px 10px 0 0" background-color="#ffffff" :mask-click="false">
  75. <view class="service-popup">
  76. <view class="top">
  77. <view class="item">客服时间:{{storeData.start_at}}-{{storeData.end_at}}</view>
  78. <view class="item">
  79. <button class="btn" @click="$dialog.jumpUri('/pages/service/chat/chat?poi='+storeData.poi_id+'&source=home',1);showService(2)">在线咨询商家</button>
  80. </view>
  81. <view class="item" v-if="storeData.service_mobile" @click="callMobile(storeData.service_mobile)">商家客服电话</view>
  82. </view>
  83. <view class="foot" @click="showService(2)">取消</view>
  84. </view>
  85. </uni-popup>
  86. </view>
  87. </template>
  88. <script>
  89. var app;
  90. import * as Api from "@/static/api/home.js";
  91. export default {
  92. data() {
  93. return {
  94. loading:false,
  95. bannerData:[],
  96. goodsData:[],
  97. storeId:"",
  98. storeData:null,
  99. goodsParam:{
  100. page:1,
  101. size:10,
  102. loading:false,
  103. isMore:false
  104. }
  105. }
  106. },
  107. onLoad({store}) {
  108. app = this;
  109. var poiId = uni.getStorageSync("poiId");
  110. if (!poiId && !store) {
  111. app.storeId = "7644106137976965139";
  112. } else {
  113. app.storeId = poiId;
  114. }
  115. app.getData()
  116. },
  117. methods: {
  118. toMap(){
  119. var poi = app.storeData;
  120. uni.openLocation({
  121. latitude:poi.latitude,
  122. longitude:poi.longitude,
  123. name:poi.poi_name,
  124. address:poi.poi_address,
  125. success() {
  126. console.log("open success")
  127. },
  128. fail(err) {
  129. app.$dialog.showSuccess("打开导航失败")
  130. console.log(err)
  131. }
  132. })
  133. },
  134. getGoods(){
  135. if (!app.storeId) return ;
  136. app.goodsParam.loading = true;
  137. Api.goods({"store":app.storeId,"page":app.goodsParam.page,"size":app.goodsParam.size}).then((res)=>{
  138. app.goodsParam.loading = false;
  139. if (res.code !== 200) {
  140. return app.$dialog.showSuccess(res.msg)
  141. }
  142. if (res.data.rows.length > 0) {
  143. app.goodsParam.page++;
  144. if (res.data.total <= res.data.pageSize) {
  145. app.goodsParam.isMore = false;
  146. } else {
  147. app.goodsParam.isMore = true;
  148. }
  149. } else {
  150. app.goodsParam.isMore = false;
  151. }
  152. app.goodsData = app.goodsData.concat(res.data.rows);
  153. })
  154. },
  155. getData(){
  156. if (!app.storeId) return ;
  157. app.loading = true;
  158. Api.data({"store":app.storeId}).then((res)=>{
  159. app.loading = false;
  160. if (res.code !== 1) {
  161. return app.$dialog.showSuccess(res.msg)
  162. }
  163. uni.setStorageSync("poiId",res.data.store.poi_id);
  164. app.storeData = res.data.store;
  165. uni.setStorageSync("contact",res.data.store);
  166. app.bannerData = res.data.banner;
  167. app.getGoods();
  168. })
  169. },
  170. callMobile(mobile){
  171. uni.makePhoneCall({
  172. phoneNumber:mobile,
  173. success(res) {
  174. console.log(res)
  175. },fail(res) {
  176. console.log(res)
  177. }
  178. })
  179. },
  180. showService(type){
  181. if (type == 1) {
  182. this.$nextTick(() => {
  183. uni.hideTabBar()
  184. })
  185. app.$refs.userpopup.open()
  186. } else {
  187. this.$nextTick(() => {
  188. uni.showTabBar()
  189. })
  190. app.$refs.userpopup.close()
  191. }
  192. }
  193. }
  194. }
  195. </script>
  196. <style>
  197. page{background-color: #f8f8f8;}
  198. .loading-empty{background-color: #fff;border-top: 2upx solid #f8f8f8;padding: 20upx;}
  199. .store-info{}
  200. .store-header{display: flex;gap: 20upx;border-bottom: 2upx solid #f8f8f8;border-top: 2upx solid #f8f8f8;align-items: center;padding: 20upx;background-color: #fff;}
  201. .store-header .logo{width: 100upx;height: 100upx;border: 2upx solid #ddd;border-radius: 10upx;display: flex;align-items: center;justify-content: center;}
  202. .store-header .logo image{width: 90upx;height: 90upx;border-radius: 10upx;}
  203. .store-header .info{flex: 1;}
  204. .store-header .title{font-size: 32upx;font-weight: bold;}
  205. .store-header .time{font-size: 24upx;color: #666;margin-top: 15upx;}
  206. .store-header .right-item {text-align: center;display: flex;align-items: center;justify-content: center;flex-direction: column;margin-left: auto;margin-right: 0;}
  207. .store-header .right-item .name{font-size: 24upx;color: #666;margin-bottom: 10upx;}
  208. .store-header .right-item .icon{background-color: #f8f8f8;border-radius: 60upx;display: flex;align-items: center;justify-content: center;width: 60upx;height: 60upx;}
  209. .store-header .right-item image{width: 40upx;height: 40upx;}
  210. .goods-more{background-color: #fff;text-align: center;font-size: 24upx;font-weight: bold;border-radius: 10upx;padding: 20upx 0;width: 55%;margin: 20upx auto;}
  211. .store-detail{display: flex;padding: 20upx;gap: 40upx;align-items: center;background-color: #fff;border-radius: 0 0 20upx 20upx;}
  212. .store-detail .detail-left{font-size: 28upx;color: #000;flex: 1;}
  213. .store-detail .detail-left .address{font-size: 24upx;color: #666;margin-top: 10upx;}
  214. .store-detail .detail-arrow{margin-left: auto;margin-right: 0;}
  215. .store-detail .detail-arrow image{width: 40upx;height: 40upx;}
  216. .store-detail .detail-right{margin-left: auto;margin-right: 0;display: flex;align-items: center;gap: 20upx;}
  217. .store-detail .detail-right .right-item {text-align: center;display: flex;align-items: center;justify-content: center;flex-direction: column;}
  218. .store-detail .detail-right .right-item .name{font-size: 24upx;color: #666;}
  219. .store-detail .detail-right .right-item .icon{background-color: #f8f8f8;border-radius: 60upx;display: flex;align-items: center;justify-content: center;width: 60upx;height: 60upx;}
  220. .store-detail .detail-right .right-item image{width: 40upx;height: 40upx;}
  221. .store-goods{background-color: #fff;padding: 0 20upx;margin-top: 20upx;border-radius: 20upx 20upx 0 0;}
  222. .goods-item{background-color: #fff;border-radius: 10upx;border-bottom: 2upx solid #f8f8f8;display: flex;align-items: center;gap: 20upx;padding: 20upx 0;}
  223. .goods-item:last-child{border-bottom: 0;}
  224. .goods-item .image{height: 180upx;overflow: hidden;display: flex;align-items: center;min-width: 180upx;}
  225. .goods-item .image image{width: 180upx;border-radius: 10upx;height: 100%;}
  226. .goods-item .info{flex: 1;}
  227. .goods-item .title{font-size: 28upx;display: -webkit-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical;overflow: hidden;font-weight: bold;}
  228. .goods-item .desc-num{color: #999;font-size: 24upx;margin: 10upx 0;display: flex;align-items: center;gap: 20upx;justify-content: space-between;}
  229. .goods-item .desc-num .sale{background-color: #FDEBE5;border-radius: 4rpx;font-size: 22rpx;color: #FF4747;padding: 5rpx 15rpx;}
  230. .goods-item .price{display: flex;align-items: center;}
  231. .goods-item .price .price-left{display: flex;align-items: center;flex: 1;}
  232. .goods-item .price .pay-price{color: #FF4747;font-size: 32rpx;font-weight: bold;margin-right: 10upx;}
  233. .goods-item .price .line-price{color: #999999;font-size: 22rpx;text-decoration-line: line-through;margin-right: 10upx;}
  234. .goods-item .price .sale{background-color: #FDEBE5;border: 4rpx;font-size: 22rpx;color: #FF4747;padding: 10rpx;}
  235. .goods-item .price .price-right{margin-left: auto;margin-right: 0;color: #fff;font-size: 24upx;padding: 10upx 30upx;border-radius: 8upx;background-image: linear-gradient(to right, #EB3434, #ff7e5f);}
  236. .service-popup .item{height: 100upx;line-height: 100upx;text-align: center;font-size: 28upx;color: #333;border-bottom: 2upx solid #f8f8f8;}
  237. .service-popup .item:last-child{border-bottom: 0;}
  238. .service-popup .item .btn{background-color: #fff;border: 0;height: 100upx;line-height: 100upx;text-align: center;font-size: 28upx;color: #333;}
  239. .service-popup .item .btn::after{border: 0;}
  240. .service-popup .foot{height: 100upx;line-height: 100upx;text-align: center;font-size: 28upx;color: #333;border-top: 20upx solid #f8f8f8;}
  241. </style>