123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- <template>
- <view class="site-wrapper">
- <!-- 筛选框start -->
- <view style="height:200rpx"></view>
- <view class="ding">
- <view class="cu-bar search bg-gray filter-section" style="padding-top:10rpx">
- <view class="search-form round bg-white" style="position:relative;overflow:auto">
- <input name="siteName" v-model="formMess.siteName" @click="toggleShow" @focus="focusfns"
- @input="handleInput()" placeholder="请输入或选择所属线路"></input>
- </view>
- </view>
- <view class="cu-bar search bg-gray filter-section">
- <view class="search-form round bg-white">
- <text class="cuIcon-search"></text>
- <input class="" type="text" placeholder="请输入站点名称" confirm-type="search" v-model="siteName"></input>
- </view>
- <view class="action">
- <button class="cu-btn bg-blue round" @click="searchSiteList">查询</button>
- </view>
- </view>
- </view>
- <view class="siteItems" v-if="isShow" style="max-height:60vh;overflow:auto;position:absolute;z-index:999; margin: 0 32rpx;
- width: calc(100% - 64rpx);top:100rpx">
- <view class=" site-item" v-if="!siteItemData.length">暂无结果</view>
- <view class="site-item" v-for="(item,index) in siteItemData" @click="changeModel(item,index)" :key="index" style="padding:16rpx 22rpx">
- {{item.route_name}}
- </view>
- </view>
- <!-- 筛选框end -->
- <!-- 站点列表start -->
- <view class="site-items" style="margin-top:0;height: calc(100vh - 380rpx);">
- <view class="cu-list menu-avatar">
- <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
- v-for="(item,index) in siteList" :key="index" @touchstart="ListTouchStart"
- @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
- <view class="cu-avatar round lg" style="background-image: url(../../static/site-icon.png);"></view>
- <view class="content" @tap="goDeviceManage(item)">
- <view class="text-grey site-tit">{{item.siteName}}</view>
- </view>
- <view class="nav-right num">
- <view class="text-grey text-xs">
- <image @click="mapLocation(item)" src="../../static/nav-icon.png"
- style="width:25rpx;height:25rpx;margin-right:26rpx"></image>
- </view>
- </view>
- <view class="move">
- <view class="bg-grey" @click.stop="editItem(item)">编辑</view>
- <view class="bg-red" @click.stop="deleteItem(item)">删除</view>
- </view>
- </view>
- </view>
- <view v-if="!siteList.length&&siteListRes==1" class="text-center margin-top"> 暂无数据</view>
- </view>
- <!-- 站点列表end -->
- <!-- 新增按钮start -->
- <view class="plus">
- <image src="../../static/plus.png" style="width:100rpx;height:100rpx" @tap="goAddPage()"></image>
- </view>
- <!-- 新增按钮end -->
- </view>
- </template>
- <!-- <script src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script> -->
- <script>
- </script>
- <script>
- //引入js sdk的封装
- import * as jwx from '../../util/jssdk.js'
- export default {
- data() {
- return {
- modalName: null,
- listTouchStart: 0,
- listTouchDirection: null,
- siteName: '',
- siteList: [],
- siteListRes: 0,
- router_id: 0,
- routeListData: [],
- route_name: '',
- isShow: false,
- formMess: {
- "siteName": "",
- },
- siteItemDataOrigin: [],
- siteItemData: [],
- };
- },
- onLoad: function(option) {
- //站点列表渲染
- this.getSiteList()
- this.getRoutrBox()
- },
- methods: {
- //线路名称下拉数据请求
- async getRoutrBox(params = {}) {
- const res = await this.$myRequest({
- url: 'Archives/getRoutrBox',
- showLoading: true,
- data: params
- })
- // this.routeListData = res.data.data;
- // console.log(this.routeListData)
- this.siteItemData = res.data.data;
- this.siteItemDataOrigin = res.data.data;
- this.siteItemData = this.siteItemDataOrigin;
- },
- //选中下拉选项,隐藏框,赋值
- changeModel: function(item, index) {
- this.isShow = false;
- this.formMess.siteName = item.route_name;
- },
- // 输入框点击 显示隐藏下拉框
- toggleShow: function() {
- this.isShow = !this.isShow;
- },
- //点击下拉筛选
- handleInput() {
- //将元素根据搜索内容过滤出来 这里改变了siteItemData
- this.siteItemData = this.siteItemDataOrigin;
- this.siteItemData = this.siteItemData.filter(item => item.route_name.indexOf(this.formMess.siteName) > -1);
- },
- focusfns: function(e) {
- //将元素根据搜索内容过滤出来 这里改变了siteItemData
- this.siteItemData = this.siteItemDataOrigin;
- this.siteItemData = this.siteItemData.filter(item => item.route_name.indexOf(this.formMess.siteName) >
- -1);
- },
- //筛选
- searchSiteList() {
- this.getSiteList({
- "siteName": this.siteName,
- "route_name": this.formMess.siteName
- })
- },
- //编辑
- editItem(item) {
- uni.navigateTo({
- url: '/pages/siteAdd/siteAdd?id=' + item.id + '',
- });
- },
- //删除
- deleteItem(item) {
- uni.showModal({
- title: '确认删除吗?',
- content: '',
- success: function(result) {
- if (result.confirm) {
- this.setDelSite({
- "id": item.id
- })
- } else if (result.cancel) {
- // console.log('用户点击取消');
- }
- }.bind(this)
- });
- },
- // 打开导航
- mapLocation(item) {
- //h5 地图导航
- // window.location.href = 'http://apis.map.qq.com/uri/v1/marker?marker=coord:'+parseFloat(item.latitude)+','+parseFloat(item.longitude)+''
- //app导航
- // uni.openLocation({
- // latitude: parseFloat(item.latitude),
- // longitude: parseFloat(item.longitude),
- // success: function() {
- // // console.log('success');
- // }
- // });
- // 微信公众号导航
- jwx.configWeiXin(jweixin => {
- let shareInfo = {
- latitude: parseFloat(item.latitude), // 纬度,浮点数,范围为90 ~ -90
- longitude: parseFloat(item.longitude), // 经度,浮点数,范围为180 ~ -180。
- name: item.siteName, // 位置名
- address: item.address, // 地址详情说明
- scale: 15, // 地图缩放级别,整型值,范围从1~28。默认为最大
- };
- jweixin.openLocation(shareInfo);
- });
- },
- async setDelSite(ming = {}) {
- const res = await this.$myRequest({
- url: 'SiteManagement/setDelSite',
- data: ming
- })
- if (!res.data.flag) {
- uni.showToast({
- title: "删除失败",
- icon: "none"
- });
- } else {
- uni.showToast({
- title: "删除成功",
- });
- setTimeout(() => {
- this.getSiteList()
- }, 1000);
- }
- },
- async getSiteList(ming = {}) {
- const res = await this.$myRequest({
- url: 'SiteManagement/getSiteList',
- showLoading: true,
- data: ming
- })
- this.siteListRes = 1;
- this.siteList = res.data.data
- console.log(res.data.data);
- },
- // 新增跳转
- goAddPage() {
- uni.navigateTo({
- url: '/pages/siteAdd/siteAdd',
- success: res => {},
- fail: () => {},
- complete: () => {}
- });
- },
- //跳转到设备管理页面
- goDeviceManage(item) {
- uni.navigateTo({
- url: '/pages/deviceManage/deviceManage?siteId=' + item.id + '',
- success: res => {},
- fail: () => {},
- complete: () => {}
- });
- },
- // ListTouch触摸开始
- ListTouchStart(e) {
- this.listTouchStart = e.touches[0].pageX
- },
- // ListTouch计算方向
- ListTouchMove(e) {
- this.listTouchDirection = e.touches[0].pageX - this.listTouchStart < -80 ? 'left' : 'right'
- },
- // ListTouch计算滚动
- ListTouchEnd(e) {
- if (this.listTouchDirection == 'left') {
- this.modalName = e.currentTarget.dataset.target
- } else {
- this.modalName = null
- }
- this.listTouchDirection = null
- }
- }
- }
- </script>
- <style>
- </style>
|