siteManage.vue 6.1 KB

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