siteManage.vue 4.9 KB

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