siteInspection.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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="icon-xian-11" custom-prefix="xd-icon" size="24" 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, getGpsLocation, checkOpenGPSServiceByAndroid } from '@/libs/tools.js'
  36. import { findStoreList } from '@/api/store.js'
  37. import { queryCurrentTaskUsing, tencentAddressInfo } 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.getLocation()
  53. // this.getAddressInfo({lng:108.9657195398708,lat:34.30901776030821})
  54. },
  55. methods: {
  56. // 获取当前位置
  57. getLocation(){
  58. const _this = this
  59. checkOpenGPSServiceByAndroid()
  60. // 获取系统信息同步接口
  61. const res = uni.getSystemInfoSync()
  62. getGpsLocation(function(gps){
  63. console.log(gps)
  64. // 安卓手机需要转格式,ios不需要
  65. if(res.platform == 'android'){ // 安卓
  66. _this.getAddressInfo({ lng: gps[0], lat: gps[1] })
  67. // 按照经纬度查询
  68. _this.searchHandle({ lng: gps[0], lat: gps[1] })
  69. }else if(res.platform == 'ios'){ // ios
  70. const province = gps.address.province ? gps.address.province : '' // 省份名称
  71. const city = gps.address.city ? gps.address.city : '' // 城市名称
  72. const district = gps.address.district ? gps.address.district : '' // 区(县)名称
  73. const poiName = gps.address.poiName ? gps.address.poiName : '' // POI信息
  74. const street = gps.address.street ? gps.address.street : '' // 街道信息
  75. const streetNum = gps.address.streetNum ? gps.address.streetNum : '' // 获取街道门牌号信息
  76. _this.location = province + city + district + poiName + '(' + street + streetNum + ')'
  77. // 按照经纬度查询
  78. _this.searchHandle({ lng: gps.longitude, lat: gps.latitude })
  79. }
  80. })
  81. },
  82. // 根据经纬度获取具体位置
  83. getAddressInfo(params){
  84. tencentAddressInfo(params).then(res => {
  85. console.log(res)
  86. if(res.status == 200){
  87. this.location = res.data.province + res.data.city + res.data.district + res.data.address
  88. }
  89. })
  90. },
  91. // 按名称查询
  92. queryHandle(){
  93. this.searchHandle({
  94. name: this.queryValue
  95. })
  96. },
  97. //查询门店列表
  98. searchHandle(params){
  99. this.status = "loading"
  100. findStoreList(params).then(res => {
  101. console.log(res)
  102. if (res.status == 200) {
  103. this.listdata = res.data || []
  104. this.noDataText = this.listdata.length == 0 && this.queryValue != '' ? '没有搜索到相关结果' : '未查找到附近门店'
  105. } else {
  106. this.listdata = []
  107. this.noDataText = res.message
  108. }
  109. this.status = "loadmore"
  110. })
  111. },
  112. // 选择门店
  113. chooseStore(item){
  114. // 校验是否有历史巡店记录
  115. // type VIDEO_INSPECTION:视频巡店、SPOT_INSPECTION:现场巡店、POINT_INSPECTION:点检任务
  116. queryCurrentTaskUsing({ storeId: item.id, type: 'SPOT_INSPECTION' }).then(res => {
  117. console.log(res,'----')
  118. if(res.status == 200){
  119. if(res.data){ // 为true有历史巡店记录
  120. clzConfirm({
  121. title: '提示',
  122. content: '有进行中的巡店任务,是否继续?',
  123. confirmText: '继续巡店',
  124. cancelText: '重新开始',
  125. buttons: ['继续巡店','重新开始'],
  126. success: function (result) {
  127. if (result.confirm || result.index==0) { // 继续巡店
  128. uni.navigateTo({
  129. url: '/pages/shopTour/shopTour?storeId=' + item.id + '&taskId='+ res.data + '&restart=0&types=scene'
  130. })
  131. }else if(result.cancel || result.index==1){ // 重新开始
  132. uni.navigateTo({
  133. url:"/pages/signIn/signIn?item=" + encodeURIComponent(JSON.stringify({id:item.id,name:item.name,taskId:res.data,restart:1}))
  134. })
  135. }
  136. }
  137. })
  138. }else{
  139. uni.navigateTo({
  140. url:"/pages/signIn/signIn?item=" + encodeURIComponent(JSON.stringify({id:item.id,name:item.name}))
  141. })
  142. }
  143. }else{
  144. uni.showToast({icon: 'none', title: res.message})
  145. }
  146. })
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang="scss" scoped>
  152. .siteInspection-wrap{
  153. background-color: #f8f8f8;
  154. .search-con{
  155. padding: 30upx 30upx;
  156. }
  157. // 定位
  158. .location-con{
  159. padding: 0 30upx;
  160. .location-main{
  161. margin-top: 14upx;
  162. padding: 20upx;
  163. border-radius: 12upx;
  164. background-color: #fff;
  165. .location-icon{
  166. padding-left: 10upx;
  167. vertical-align: bottom;
  168. }
  169. }
  170. }
  171. // 附近的门店
  172. .store-con{
  173. .store-tit{
  174. display: block;
  175. padding: 30upx 30upx 20upx;
  176. }
  177. // 列表 44 62
  178. .scroll-con{
  179. height: calc(100vh - 215px);
  180. width: 100%;
  181. overflow: auto;
  182. .list-con{
  183. padding: 0 30upx;
  184. .list-item{
  185. background-color: #fff;
  186. padding: 20upx;
  187. display: flex;
  188. justify-content: space-between;
  189. align-items: center;
  190. border-bottom: 1px solid #F8F8F8;
  191. .item-main{
  192. font-size: 15px;
  193. color: rgb(48, 49, 51);
  194. display: flex;
  195. align-items: center;
  196. .company-icon{
  197. margin-right: 6upx;
  198. }
  199. }
  200. }
  201. }
  202. }
  203. }
  204. }
  205. </style>