siteManage.vue 5.6 KB

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