siteInspection.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="siteInspection-wrap">
  3. <!-- 搜索框 -->
  4. <view class="search-con">
  5. <u-search placeholder="查找全部门店" v-model="queryValue" @custom="queryHandle" @search="queryHandle" bg-color="#fff" :action-style="{background: '#2979ff',color: '#fff', borderRadius: '6upx',padding: '6upx 0', fontSize: '26upx'}"></u-search>
  6. </view>
  7. <!-- 定位 -->
  8. <view class="location-con" ref="location">
  9. <text class="location-tit">当前位置:</text>
  10. <view class="location-main" @click="getLocation">
  11. <text class="location-addr">{{location}}</text>
  12. <u-icon name="map" color="#2979ff" size="34" class="location-icon"></u-icon>
  13. </view>
  14. </view>
  15. <!-- 附近的门店 -->
  16. <view class="store-con">
  17. <text class="store-tit">附近的门店:</text>
  18. <scroll-view class="scroll-con" scroll-y :style="{'height': 'calc(100vh - ' + Height + 'px)'}">
  19. <!-- 列表数据 -->
  20. <view class="list-con">
  21. <view class="list-item" v-for="(item,index) in listdata" :key="index" @click="chooseStore(item)">
  22. <view class="item-main">
  23. <u-icon class="company-icon" name="mendian" custom-prefix="xd-icon" size="40" color="#888"></u-icon>
  24. <text>{{item.name}}</text>
  25. </view>
  26. <u-icon class="listData-item-r-icon" name="yuanchengxundian" custom-prefix="xd-icon" size="40" color="#2b85e4"></u-icon>
  27. </view>
  28. </view>
  29. <u-empty class="nodata" :text="noDataText" v-if="listdata.length==0 && status!='loading'" mode="list"></u-empty>
  30. </scroll-view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import { clzConfirm } from '@/libs/tools.js'
  36. import { findStoreList } from '@/api/store.js'
  37. import { queryCurrentTaskUsing } from '@/api/task.js'
  38. export default{
  39. data(){
  40. return{
  41. queryValue: '', // 查询门店
  42. location: '', // 位置
  43. noDataText: '未查找到附近门店', // 列表请求状态提示语
  44. status: 'loadmore', // 加载中状态
  45. listdata: [], // 列表数据
  46. Height: 200, // 滚动区域 元素dom高度
  47. lat: '', // 纬度
  48. lng: '', // 经度
  49. }
  50. },
  51. onReady() {
  52. this.init()
  53. },
  54. methods: {
  55. // 初始化
  56. init(){
  57. this.getLocation()
  58. },
  59. // 获取当前位置
  60. getLocation(){
  61. const _this = this
  62. uni.getLocation({
  63. type: 'gcj02',
  64. geocode: true,
  65. success: function (res) {
  66. console.log(res)
  67. _this.lng = res.longitude
  68. _this.lat = res.latitude
  69. _this.location = res.address.province + res.address.city + res.address.district + res.address.street + res.address.streetNum +'靠近' + res.address.poiName
  70. setTimeout(()=>{
  71. // 按照经纬度查询
  72. _this.searchHandle({lng:this.lng,lat:this.lat})
  73. }, 500)
  74. },
  75. fail: function(error){
  76. console.log(error)
  77. _this.searchHandle({})
  78. if(JSON.parse(error.errMsg.replace('getLocation:fail ','')).message){
  79. uni.showToast({
  80. icon: 'none',
  81. title: JSON.parse(error.errMsg.replace('getLocation:fail ','')).message
  82. })
  83. }
  84. }
  85. })
  86. },
  87. // 按名称查询
  88. queryHandle(){
  89. this.searchHandle({
  90. name: this.queryValue
  91. })
  92. },
  93. //查询门店列表
  94. searchHandle(params){
  95. this.status = "loading"
  96. findStoreList(params).then(res => {
  97. console.log(res)
  98. if (res.status == 200) {
  99. this.listdata = res.data || []
  100. this.noDataText = this.listdata.length == 0 && this.queryValue != '' ? '没有搜索到相关结果' : '未查找到附近门店'
  101. } else {
  102. this.listdata = []
  103. this.noDataText = res.message
  104. }
  105. this.status = "loadmore"
  106. })
  107. },
  108. // 选择门店
  109. chooseStore(item){
  110. // 校验是否有历史巡店记录
  111. // type VIDEO_INSPECTION:视频巡店、SPOT_INSPECTION:现场巡店、POINT_INSPECTION:点检任务
  112. queryCurrentTaskUsing({ storeId: item.id, type: 'SPOT_INSPECTION' }).then(res => {
  113. if(res.status == 200){
  114. if(res.data){ // 为true有历史巡店记录
  115. clzConfirm({
  116. title: '提示',
  117. content: '有进行中的巡店任务,是否继续?',
  118. confirmText: '继续巡店',
  119. cancelText: '重新开始',
  120. buttons: ['继续巡店','重新开始'],
  121. success: function (result) {
  122. if (result.confirm || result.index==0) { // 继续巡店
  123. uni.navigateTo({
  124. url: '/pages/shopTour/shopTour?storeId=' + item.id + '&taskId='+ res.data + '&restart=0&types=scene'
  125. })
  126. }else if(result.cancel || result.index==1){ // 重新开始
  127. uni.navigateTo({
  128. url:"/pages/signIn/signIn?item=" + encodeURIComponent(JSON.stringify(item))
  129. })
  130. }
  131. }
  132. })
  133. }else{
  134. uni.navigateTo({
  135. url:"/pages/signIn/signIn?item=" + encodeURIComponent(JSON.stringify(item))
  136. })
  137. }
  138. }else{
  139. uni.showToast({icon: 'none', title: res.message})
  140. }
  141. })
  142. }
  143. }
  144. }
  145. </script>
  146. <style lang="scss" scoped>
  147. .siteInspection-wrap{
  148. background-color: #f8f8f8;
  149. .search-con{
  150. padding: 30upx 30upx;
  151. }
  152. // 定位
  153. .location-con{
  154. padding: 0 30upx;
  155. .location-main{
  156. margin-top: 14upx;
  157. padding: 20upx;
  158. border-radius: 12upx;
  159. background-color: #fff;
  160. .location-icon{
  161. padding-left: 10upx;
  162. vertical-align: bottom;
  163. }
  164. }
  165. }
  166. // 附近的门店
  167. .store-con{
  168. .store-tit{
  169. display: block;
  170. padding: 30upx 30upx 20upx;
  171. }
  172. // 列表 44 62
  173. .scroll-con{
  174. height: calc(100vh - 215px);
  175. width: 100%;
  176. overflow: auto;
  177. .list-con{
  178. padding: 0 30upx;
  179. .list-item{
  180. background-color: #fff;
  181. padding: 20upx;
  182. display: flex;
  183. justify-content: space-between;
  184. align-items: center;
  185. border-bottom: 1px solid #F8F8F8;
  186. .item-main{
  187. font-size: 15px;
  188. color: rgb(48, 49, 51);
  189. display: flex;
  190. align-items: center;
  191. .company-icon{
  192. margin-right: 6upx;
  193. }
  194. }
  195. }
  196. }
  197. }
  198. }
  199. }
  200. </style>