store.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. })
  68. },
  69. checkStore(index){
  70. app.checkIndex = index;
  71. },
  72. tel(){
  73. },
  74. locaJump(longitude,latitude){
  75. uni.openLocation({
  76. latitude:latitude,
  77. longitude:longitude,
  78. fail() {
  79. app.$dialog.showSuccess("打开地图失败");
  80. }
  81. })
  82. },
  83. getStoreData(){
  84. uni.getLocation({
  85. type:"gcj02",
  86. success(res) {
  87. console.log(res)
  88. app.location = res.longitude+","+res.latitude;
  89. app.getStore();
  90. },
  91. fail() {
  92. app.location = "117.172398,34.226209";
  93. app.getStore();
  94. app.$dialog.showSuccess("获取定位信息失败");
  95. }
  96. })
  97. },
  98. getStore(){
  99. Api.store({"order":app.order,"location":app.location,"keyword":app.keyword}).then((res)=>{
  100. if (res.code == 0) {
  101. return app.$dialog.showSuccess(res.msg,"none",function(){
  102. uni.navigateBack()
  103. })
  104. }
  105. app.storeData = res.data.data;
  106. app.storeInfo = res.data.store;
  107. })
  108. }
  109. }
  110. }
  111. </script>
  112. <style>
  113. .search{padding: 20upx;display: flex;align-items: center;background-color: #fff;width: calc(95% - 60upx);margin: 20upx auto;border-radius: 60upx;}
  114. .search image{width: 50upx;height: 46upx;}
  115. .search .search-input{border-radius: 30upx;font-size: 28upx;height: 60upx;margin-left: 20upx;}
  116. .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;}
  117. .store-item.active{border: 2upx solid #224d7a;}
  118. .store-item .check{display: none;position: absolute;top: 0;right: 0;background-color: #224d7a;width: 40upx;height: 40upx;border-radius: 0 20upx 0 20upx;}
  119. .store-item .check image{width: 30upx;height: 30upx;display: flex;align-items: center;justify-content: center;padding: 5upx;}
  120. .store-item.active .check{display: block;}
  121. .store-item .item-left{flex: 1;}
  122. .store-item .name{font-size: 32upx;color: #333;line-height: 48upx;font-weight: bold;}
  123. .store-item .desc{font-size: 24upx;color: #666;line-height: 36upx;margin-top: 10upx;}
  124. .store-item .item-right{text-align: center;}
  125. .store-item .item-right .footer{font-size: 24upx;color: #666;}
  126. .store-item .item-right .top{display: flex;align-items: center;gap: 20upx;margin-bottom: 20upx;}
  127. .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;}
  128. .store-item .item-right .top .icon-img image{width: 40upx;height: 40upx;}
  129. .flx-footer{position: fixed;bottom: 0;background-color: #fff;padding: 20upx;border-top: 2upx solid #f8f8f8;left: 0;right: 0;}
  130. .flx-footer .footer-safe {height: env(safe-area-inset-bottom);width: 100%;}
  131. .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;}
  132. .flx-footer .btn[disabled],.flx-footer .btn.disabled{background-color: rgba(34, 77, 122, 0.3);}
  133. </style>