siteManage.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. </script>
  49. <script>
  50. //引入js sdk的封装
  51. import * as jwx from '../../util/jssdk.js'
  52. export default {
  53. data() {
  54. return {
  55. modalName: null,
  56. listTouchStart: 0,
  57. listTouchDirection: null,
  58. siteName: '',
  59. siteList: [],
  60. siteListRes: 0
  61. };
  62. },
  63. onLoad: function(option) {
  64. //站点列表渲染
  65. this.getSiteList()
  66. },
  67. methods: {
  68. //筛选
  69. searchSiteList() {
  70. this.getSiteList({
  71. "siteName": this.siteName
  72. })
  73. },
  74. //编辑
  75. editItem(item) {
  76. uni.navigateTo({
  77. url: '/pages/siteAdd/siteAdd?id=' + item.id + '',
  78. });
  79. },
  80. //删除
  81. deleteItem(item) {
  82. uni.showModal({
  83. title: '确认删除吗?',
  84. content: '',
  85. success: function(result) {
  86. if (result.confirm) {
  87. this.setDelSite({
  88. "id": item.id
  89. })
  90. } else if (result.cancel) {
  91. // console.log('用户点击取消');
  92. }
  93. }.bind(this)
  94. });
  95. },
  96. // 打开导航
  97. mapLocation(item) {
  98. //h5 地图导航
  99. // window.location.href = 'http://apis.map.qq.com/uri/v1/marker?marker=coord:'+parseFloat(item.latitude)+','+parseFloat(item.longitude)+''
  100. //app导航
  101. // uni.openLocation({
  102. // latitude: parseFloat(item.latitude),
  103. // longitude: parseFloat(item.longitude),
  104. // success: function() {
  105. // // console.log('success');
  106. // }
  107. // });
  108. // 微信公众号导航
  109. jwx.configWeiXin(jweixin => {
  110. let shareInfo = {
  111. latitude: parseFloat(item.latitude), // 纬度,浮点数,范围为90 ~ -90
  112. longitude: parseFloat(item.longitude), // 经度,浮点数,范围为180 ~ -180。
  113. name: item.siteName, // 位置名
  114. address: item.address, // 地址详情说明
  115. scale: 15, // 地图缩放级别,整型值,范围从1~28。默认为最大
  116. };
  117. jweixin.openLocation(shareInfo);
  118. });
  119. },
  120. async setDelSite(ming = {}) {
  121. const res = await this.$myRequest({
  122. url: 'SiteManagement/setDelSite',
  123. data: ming
  124. })
  125. if (!res.data.flag) {
  126. uni.showToast({
  127. title: "删除失败",
  128. icon: "none"
  129. });
  130. } else {
  131. uni.showToast({
  132. title: "删除成功",
  133. });
  134. setTimeout(() => {
  135. this.getSiteList()
  136. }, 1000);
  137. }
  138. },
  139. async getSiteList(ming = {}) {
  140. const res = await this.$myRequest({
  141. url: 'SiteManagement/getSiteList',
  142. showLoading: true,
  143. data: ming
  144. })
  145. this.siteListRes = 1;
  146. this.siteList = res.data.data
  147. console.log(res.data.data);
  148. },
  149. // 新增跳转
  150. goAddPage() {
  151. uni.navigateTo({
  152. url: '/pages/siteAdd/siteAdd',
  153. success: res => {},
  154. fail: () => {},
  155. complete: () => {}
  156. });
  157. },
  158. //跳转到设备管理页面
  159. goDeviceManage(item) {
  160. uni.navigateTo({
  161. url: '/pages/deviceManage/deviceManage?siteId=' + item.id + '',
  162. success: res => {},
  163. fail: () => {},
  164. complete: () => {}
  165. });
  166. },
  167. // ListTouch触摸开始
  168. ListTouchStart(e) {
  169. this.listTouchStart = e.touches[0].pageX
  170. },
  171. // ListTouch计算方向
  172. ListTouchMove(e) {
  173. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart < -80 ? 'left' : 'right'
  174. },
  175. // ListTouch计算滚动
  176. ListTouchEnd(e) {
  177. if (this.listTouchDirection == 'left') {
  178. this.modalName = e.currentTarget.dataset.target
  179. } else {
  180. this.modalName = null
  181. }
  182. this.listTouchDirection = null
  183. }
  184. }
  185. }
  186. </script>
  187. <style>
  188. </style>