store.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view>
  3. <view class="search">
  4. <image src="/static/image/search.png"></image>
  5. <input type="text" placeholder="请输入关键字" v-model="keyword" @confirm="getStore" class="search-input" />
  6. </view>
  7. <view class="store-list">
  8. <view :class="checkIndex==indx?'store-item active':'store-item'" @click="checkStore(indx)" v-for="(item,indx) in storeData" :key="indx">
  9. <view class="item-left">
  10. <view class="name">{{item.poi_name}}</view>
  11. <view class="desc">{{item.poi_address}}</view>
  12. <view class="desc" v-if="storeInfo.status==1">{{ storeInfo.service_at_start }}-{{ storeInfo.service_at_end }}</view>
  13. <view class="desc" v-else>休息中</view>
  14. </view>
  15. <view class="item-right">
  16. <view class="top">
  17. <view class="icon-img" @click="tel()"><image src="/static/image/tel.png"></image></view>
  18. <view class="icon-img" @click="locaJump(item.longitude,item.latitude)"><image src="/static/image/map.png"></image></view>
  19. </view>
  20. <view class="footer">距离{{ item.juli }}公里</view>
  21. </view>
  22. <view class="check"><image src="/static/image/check.png"></image></view>
  23. </view>
  24. </view>
  25. <view class="flx-footer">
  26. <view class="check-btn"><button class="btn" :disabled="disabled" @click="checkOrder">{{disabled?'处理中...':'确 认'}}</button></view>
  27. <view class="footer-safe"></view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. var app;
  33. import * as Api from "@/static/api/order.js";
  34. export default {
  35. data() {
  36. return {
  37. checkIndex:null,
  38. order:"",
  39. location:"",
  40. storeData:[],
  41. storeInfo:null,
  42. keyword:"",
  43. disabled:false,
  44. type:1
  45. }
  46. },
  47. onLoad({order,type}) {
  48. app = this;
  49. if (!order) {
  50. return app.$dialog.showSuccess("参数错误","none",function(){
  51. uni.navigateBack()
  52. })
  53. }
  54. app.type = type;
  55. app.order = order;
  56. app.getStoreData();
  57. },
  58. methods: {
  59. checkOrder(){
  60. if (app.checkIndex==null) {
  61. return app.$dialog.showSuccess("请选择门店");
  62. }
  63. app.disabled = true;
  64. var poi = app.storeData[app.checkIndex];
  65. uni.navigateTo({
  66. url:"/pages/order/confirm?order="+app.order+"&poi_id="+poi.poi_id+"&poi_name="+poi.poi_name+"&juli="+poi.juli,
  67. success() {
  68. app.disabled = false;
  69. }
  70. })
  71. },
  72. checkStore(index){
  73. app.checkIndex = index;
  74. },
  75. tel(){
  76. if (!app.storeInfo.service_mobile){
  77. return app.$dialog.showSuccess("客服电话尚未配置")
  78. }
  79. uni.makePhoneCall({
  80. phoneNumber:app.storeInfo.service_mobile
  81. })
  82. },
  83. locaJump(longitude,latitude){
  84. uni.openLocation({
  85. latitude:latitude,
  86. longitude:longitude,
  87. fail() {
  88. app.$dialog.showSuccess("打开地图失败");
  89. }
  90. })
  91. },
  92. getStoreData(){
  93. uni.getLocation({
  94. type:"gcj02",
  95. success(res) {
  96. console.log(res)
  97. app.location = res.longitude+","+res.latitude;
  98. app.getStore();
  99. },
  100. fail() {
  101. app.location = "117.172398,34.226209";
  102. app.getStore();
  103. app.$dialog.showSuccess("获取定位信息失败");
  104. }
  105. })
  106. },
  107. getStore(){
  108. Api.store({"order":app.order,"location":app.location,"keyword":app.keyword}).then((res)=>{
  109. if (res.code == 0) {
  110. return app.$dialog.showSuccess(res.msg,"none",function(){
  111. uni.navigateBack()
  112. })
  113. }
  114. app.storeData = res.data.data;
  115. app.storeInfo = res.data.store;
  116. })
  117. }
  118. }
  119. }
  120. </script>
  121. <style>
  122. .search{padding: 20upx;display: flex;align-items: center;background-color: #fff;width: calc(95% - 60upx);margin: 20upx auto;border-radius: 60upx;}
  123. .search image{width: 50upx;height: 46upx;}
  124. .search .search-input{border-radius: 30upx;font-size: 28upx;height: 60upx;margin-left: 20upx;}
  125. .store-item{background-color: #fff;width: calc(95% - 40upx);padding: 20upx;border-radius: 20upx;display: flex;align-items: center;justify-content: space-between;margin: 20upx auto;position: relative;}
  126. .store-item.active{border: 2upx solid #224d7a;}
  127. .store-item .check{display: none;position: absolute;top: 0;right: 0;background-color: #224d7a;width: 40upx;height: 40upx;border-radius: 0 20upx 0 20upx;}
  128. .store-item .check image{width: 30upx;height: 30upx;display: flex;align-items: center;justify-content: center;padding: 5upx;}
  129. .store-item.active .check{display: block;}
  130. .store-item .item-left{flex: 1;}
  131. .store-item .name{font-size: 32upx;color: #333;line-height: 48upx;font-weight: bold;}
  132. .store-item .desc{font-size: 24upx;color: #666;line-height: 36upx;margin-top: 10upx;}
  133. .store-item .item-right{text-align: center;}
  134. .store-item .item-right .footer{font-size: 24upx;color: #666;}
  135. .store-item .item-right .top{display: flex;align-items: center;gap: 20upx;margin-bottom: 20upx;}
  136. .store-item .item-right .top .icon-img{width: 60upx;height: 60upx;background-color: #f8f8f8;border-radius: 60upx;display: flex;align-items: center;justify-content: center;}
  137. .store-item .item-right .top .icon-img image{width: 40upx;height: 40upx;}
  138. .flx-footer{position: fixed;bottom: 0;background-color: #fff;padding: 20upx;border-top: 2upx solid #f8f8f8;left: 0;right: 0;}
  139. .flx-footer .footer-safe {height: env(safe-area-inset-bottom);width: 100%;}
  140. .flx-footer .btn{font-size: 28rpx;height: 80upx;border-radius: 10upx;line-height: 80upx;text-align: center;width: 100%;color: #333;background-color: #224d7a;color: #fff;border:2upx solid #224d7a;}
  141. .flx-footer .btn[disabled],.flx-footer .btn.disabled{background-color: rgba(34, 77, 122, 0.3);}
  142. </style>