siteManage.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <view class="site-wrapper">
  3. <!-- 筛选框start -->
  4. <view style="height:200rpx"></view>
  5. <view class="ding">
  6. <view class="cu-bar search bg-gray filter-section" style="padding-top:10rpx">
  7. <view class="search-form round bg-white">
  8. <select name="" id="" filterable clearable v-model="router_id" style="padding-left:40rpx;background-size: 4.6%;">
  9. <option value="0">请选择线路名称</option>
  10. <option :value=item.route_name v-for="item in routeListData">{{ item.route_name}}</option>
  11. </select>
  12. </view>
  13. </view>
  14. <view class="cu-bar search bg-gray filter-section" >
  15. <view class="search-form round bg-white">
  16. <text class="cuIcon-search"></text>
  17. <input class="" type="text" placeholder="请输入站点名称" confirm-type="search" v-model="siteName"></input>
  18. </view>
  19. <view class="action">
  20. <button class="cu-btn bg-blue round" @click="searchSiteList">查询</button>
  21. </view>
  22. </view>
  23. </view>
  24. <!-- 筛选框end -->
  25. <!-- 站点列表start -->
  26. <view class="site-items" style="margin-top:0;height: calc(100vh - 500rpx);">
  27. <view class="cu-list menu-avatar">
  28. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''" v-for="(item,index) in siteList" :key="index"
  29. @touchstart="ListTouchStart" @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
  30. <view class="cu-avatar round lg" style="background-image: url(../../static/site-icon.png);"></view>
  31. <view class="content" @tap="goDeviceManage(item)">
  32. <view class="text-grey site-tit">{{item.siteName}}</view>
  33. </view>
  34. <view class="nav-right num">
  35. <view class="text-grey text-xs">
  36. <image @click="mapLocation(item)" src="../../static/nav-icon.png" style="width:25rpx;height:25rpx;margin-right:26rpx"></image>
  37. </view>
  38. </view>
  39. <view class="move">
  40. <view class="bg-grey" @click.stop="editItem(item)">编辑</view>
  41. <view class="bg-red" @click.stop="deleteItem(item)">删除</view>
  42. </view>
  43. </view>
  44. </view>
  45. <view v-if="!siteList.length&&siteListRes==1" class="text-center margin-top"> 暂无数据</view>
  46. </view>
  47. <!-- 站点列表end -->
  48. <!-- 新增按钮start -->
  49. <view class="plus">
  50. <image src="../../static/plus.png" style="width:125rpx;height:125rpx" @tap="goAddPage()"></image>
  51. </view>
  52. <!-- 新增按钮end -->
  53. </view>
  54. </template>
  55. <!-- <script src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script> -->
  56. <script>
  57. </script>
  58. <script>
  59. //引入js sdk的封装
  60. import * as jwx from '../../util/jssdk.js'
  61. export default {
  62. data() {
  63. return {
  64. modalName: null,
  65. listTouchStart: 0,
  66. listTouchDirection: null,
  67. siteName: '',
  68. siteList: [],
  69. siteListRes: 0,
  70. router_id:0,
  71. routeListData:[]
  72. };
  73. },
  74. onLoad: function(option) {
  75. //站点列表渲染
  76. this.getSiteList()
  77. this.getRoutrBox()
  78. },
  79. methods: {
  80. //线路名称下拉数据请求
  81. async getRoutrBox(params = {}) {
  82. const res = await this.$myRequest({
  83. url: 'Archives/getRoutrBox',
  84. showLoading: true,
  85. data: params
  86. })
  87. this.routeListData = res.data.data;
  88. console.log(this.routeListData)
  89. },
  90. //筛选
  91. searchSiteList() {
  92. this.getSiteList({
  93. "siteName": this.siteName,
  94. "route_name":this.router_id
  95. })
  96. },
  97. //编辑
  98. editItem(item) {
  99. uni.navigateTo({
  100. url: '/pages/siteAdd/siteAdd?id=' + item.id + '',
  101. });
  102. },
  103. //删除
  104. deleteItem(item) {
  105. uni.showModal({
  106. title: '确认删除吗?',
  107. content: '',
  108. success: function(result) {
  109. if (result.confirm) {
  110. this.setDelSite({
  111. "id": item.id
  112. })
  113. } else if (result.cancel) {
  114. // console.log('用户点击取消');
  115. }
  116. }.bind(this)
  117. });
  118. },
  119. // 打开导航
  120. mapLocation(item) {
  121. //h5 地图导航
  122. // window.location.href = 'http://apis.map.qq.com/uri/v1/marker?marker=coord:'+parseFloat(item.latitude)+','+parseFloat(item.longitude)+''
  123. //app导航
  124. // uni.openLocation({
  125. // latitude: parseFloat(item.latitude),
  126. // longitude: parseFloat(item.longitude),
  127. // success: function() {
  128. // // console.log('success');
  129. // }
  130. // });
  131. // 微信公众号导航
  132. jwx.configWeiXin(jweixin => {
  133. let shareInfo = {
  134. latitude: parseFloat(item.latitude), // 纬度,浮点数,范围为90 ~ -90
  135. longitude: parseFloat(item.longitude), // 经度,浮点数,范围为180 ~ -180。
  136. name: item.siteName, // 位置名
  137. address: item.address, // 地址详情说明
  138. scale: 15, // 地图缩放级别,整型值,范围从1~28。默认为最大
  139. };
  140. jweixin.openLocation(shareInfo);
  141. });
  142. },
  143. async setDelSite(ming = {}) {
  144. const res = await this.$myRequest({
  145. url: 'SiteManagement/setDelSite',
  146. data: ming
  147. })
  148. if (!res.data.flag) {
  149. uni.showToast({
  150. title: "删除失败",
  151. icon: "none"
  152. });
  153. } else {
  154. uni.showToast({
  155. title: "删除成功",
  156. });
  157. setTimeout(() => {
  158. this.getSiteList()
  159. }, 1000);
  160. }
  161. },
  162. async getSiteList(ming = {}) {
  163. const res = await this.$myRequest({
  164. url: 'SiteManagement/getSiteList',
  165. showLoading: true,
  166. data: ming
  167. })
  168. this.siteListRes = 1;
  169. this.siteList = res.data.data
  170. console.log(res.data.data);
  171. },
  172. // 新增跳转
  173. goAddPage() {
  174. uni.navigateTo({
  175. url: '/pages/siteAdd/siteAdd',
  176. success: res => {},
  177. fail: () => {},
  178. complete: () => {}
  179. });
  180. },
  181. //跳转到设备管理页面
  182. goDeviceManage(item) {
  183. uni.navigateTo({
  184. url: '/pages/deviceManage/deviceManage?siteId=' + item.id + '',
  185. success: res => {},
  186. fail: () => {},
  187. complete: () => {}
  188. });
  189. },
  190. // ListTouch触摸开始
  191. ListTouchStart(e) {
  192. this.listTouchStart = e.touches[0].pageX
  193. },
  194. // ListTouch计算方向
  195. ListTouchMove(e) {
  196. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart < -80 ? 'left' : 'right'
  197. },
  198. // ListTouch计算滚动
  199. ListTouchEnd(e) {
  200. if (this.listTouchDirection == 'left') {
  201. this.modalName = e.currentTarget.dataset.target
  202. } else {
  203. this.modalName = null
  204. }
  205. this.listTouchDirection = null
  206. }
  207. }
  208. }
  209. </script>
  210. <style>
  211. </style>