首页修改
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<view class="device">
|
||||
<view class="nav" :style="{ top: navHeight + 'px' }">
|
||||
<view class="nav" :style="{ top: navTabHeight + 'px' }">
|
||||
<!-- <view class="nav-menu" :class="{ 'nav-menu-active': select.engineeringName }" @click="openDrawer"
|
||||
>{{ select.engineeringName || '工程' }}
|
||||
</view> -->
|
||||
@@ -37,20 +37,21 @@
|
||||
<view style="flex: 1"></view>
|
||||
<template v-if="deviceListFilter.length">
|
||||
<template v-if="transfer || share">
|
||||
<view class="nav-menu nav-menu-btn" @click="submit">确定 </view>
|
||||
<view class="nav-menu nav-menu-btn" @click="cancel">取消</view>
|
||||
<view class="nav-menu nav-menu-btn" @click="submit">确定</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view
|
||||
class="nav-menu nav-menu-btn"
|
||||
@click="transfer = true"
|
||||
@click="selectDevice('transfer')"
|
||||
v-if="userInfo.authorities === 'app_vip_user' || userInfo.authorities === 'engineering_user'"
|
||||
>移交
|
||||
>移交
|
||||
</view>
|
||||
<view
|
||||
class="nav-menu nav-menu-btn"
|
||||
@click="share = true"
|
||||
@click="selectDevice('share')"
|
||||
v-if="userInfo.authorities === 'app_vip_user'"
|
||||
>分享
|
||||
>分享
|
||||
</view>
|
||||
</template>
|
||||
</template>
|
||||
@@ -92,8 +93,9 @@
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import { getProjectList } from '@/common/api/project'
|
||||
import { queryDictData } from '@/common/api/dictionary'
|
||||
import {getProjectList} from '@/common/api/project'
|
||||
import {queryDictData} from '@/common/api/dictionary'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
store: {
|
||||
@@ -113,18 +115,18 @@ export default {
|
||||
projectType: '',
|
||||
projectTypeIndex: 0,
|
||||
},
|
||||
minHeight: '',
|
||||
minHeight: 0,
|
||||
navTabHeight: 0,
|
||||
engineeringList: [],
|
||||
projectList: [],
|
||||
projectType: [],
|
||||
navHeight: 0,
|
||||
userInfo: {},
|
||||
selectProject: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
deviceListFilter() {
|
||||
return this.store.data.filter((item) => {
|
||||
let arr = this.store.data.filter((item) => {
|
||||
if (this.select.projectName && this.select.projectType) {
|
||||
return item.project === this.select.projectName && item.type === this.select.projectType
|
||||
} else if (this.select.projectName) {
|
||||
@@ -135,12 +137,30 @@ export default {
|
||||
return true
|
||||
}
|
||||
})
|
||||
if (this.transfer || this.share) {
|
||||
return arr.filter((item) => {
|
||||
return item.isPrimaryUser === '1'
|
||||
})
|
||||
} else {
|
||||
return arr
|
||||
}
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.userInfo = uni.getStorageSync(this.$cacheKey.userInfo)
|
||||
},
|
||||
mounted() {
|
||||
|
||||
|
||||
},
|
||||
methods: {
|
||||
selectDevice(type) {
|
||||
if (this.deviceListFilter.findIndex(item => item.isPrimaryUser === '1') === -1) {
|
||||
this.$util.toast('没有可操作的设备')
|
||||
} else {
|
||||
this[type] = true
|
||||
}
|
||||
},
|
||||
deviceIcon(e) {
|
||||
let str = ''
|
||||
switch (e) {
|
||||
@@ -165,35 +185,50 @@ export default {
|
||||
this.checkList.push(e.equipmentId)
|
||||
}
|
||||
},
|
||||
submit() {
|
||||
console.log(this.checkList)
|
||||
if (this.transfer) {
|
||||
this.transfer = false
|
||||
uni.navigateTo({ url: '/pages/device/transfer?id=' + this.checkList.join(',') })
|
||||
} else if (this.share) {
|
||||
this.share = false
|
||||
this.$emit('share', this.shareList)
|
||||
}
|
||||
cancel() {
|
||||
this.transfer = false
|
||||
this.share = false
|
||||
this.checkList = []
|
||||
},
|
||||
submit() {
|
||||
console.log(this.checkList)
|
||||
if (this.checkList.length === 0) {
|
||||
this.$util.toast('请选择设备')
|
||||
return
|
||||
}
|
||||
if (this.transfer) {
|
||||
uni.navigateTo({url: '/pages/device/transfer?id=' + this.checkList.join(',')})
|
||||
} else if (this.share) {
|
||||
uni.navigateTo({url: '/pages/device/share?id=' + this.checkList.join(',')})
|
||||
}
|
||||
this.cancel()
|
||||
},
|
||||
async init() {
|
||||
console.warn('init')
|
||||
this.getProjectList()
|
||||
this.getDeviceList()
|
||||
},
|
||||
getDeviceList() {
|
||||
this.store.params.pageSize = 999
|
||||
this.store.firstCallBack = () => {
|
||||
// 获取nav高度
|
||||
this.store.params.pageSize = 50
|
||||
this.store.firstCallBack = (res) => {
|
||||
uni.createSelectorQuery()
|
||||
.select('.nav')
|
||||
.boundingClientRect((rect2) => {
|
||||
if (!rect2) return
|
||||
// #ifdef H5
|
||||
this.minHeight = 'calc(100vh - env(safe-area-inset-bottom) - ' + (50 + rect2.height) + 'px)'
|
||||
// #endif
|
||||
// #ifdef APP-PLUS
|
||||
this.minHeight = 'calc(100vh - ' + rect2.height + 'px)'
|
||||
// #endif
|
||||
.select('.uni-navbar')
|
||||
.boundingClientRect((rect1) => {
|
||||
if (!rect1) return
|
||||
this.navTabHeight = rect1.height
|
||||
uni.createSelectorQuery()
|
||||
.select('.nav')
|
||||
.boundingClientRect((rect2) => {
|
||||
if (!rect2) return
|
||||
// #ifdef H5
|
||||
this.minHeight = 'calc(100vh - ' + (this.navTabHeight + rect2.height + 50) + 'px)'
|
||||
// #endif
|
||||
// #ifdef APP-PLUS
|
||||
this.minHeight = 'calc(100vh - ' + (this.navTabHeight + rect2.height) + 'px)'
|
||||
console.log(this.minHeight)
|
||||
// #endif
|
||||
})
|
||||
.exec()
|
||||
})
|
||||
.exec()
|
||||
}
|
||||
@@ -239,7 +274,7 @@ export default {
|
||||
})
|
||||
},
|
||||
submitFeedBack() {
|
||||
uni.navigateTo({ url: '/pages/home/feedback' })
|
||||
uni.navigateTo({url: '/pages/home/feedback'})
|
||||
},
|
||||
projectTypeChange(e) {
|
||||
this.select.projectTypeIndex = e.detail.value
|
||||
@@ -266,7 +301,7 @@ export default {
|
||||
confirmText: '直连装置',
|
||||
cancelText: '网关接入',
|
||||
cancelColor: '#007aff',
|
||||
success: ({ confirm, cancel }) => {
|
||||
success: ({confirm, cancel}) => {
|
||||
if (confirm) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/device/new',
|
||||
@@ -300,6 +335,7 @@ export default {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 20rpx 0;
|
||||
|
||||
&-left {
|
||||
flex: 1;
|
||||
margin-right: 10px;
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<Cn-grid title="">
|
||||
<Cn-grid-item src="/static/device2.png" text="设备注册" @click="registerDevice"></Cn-grid-item>
|
||||
<!-- <Cn-grid-item src="/static/gateway2.png" text="网关注册" @click="registerGateway"></Cn-grid-item> -->
|
||||
<Cn-grid-item src="/static/feedback2.png" text="问题反馈" @click="submitFeedBack"></Cn-grid-item>
|
||||
<!-- <Cn-grid-item src="/static/feedback2.png" text="问题反馈" @click="submitFeedBack"></Cn-grid-item>-->
|
||||
</Cn-grid>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
<template>
|
||||
<Cn-page :loading="loading" noPadding>
|
||||
<view slot="body" class="canneng-index">
|
||||
<!-- <uni-nav-bar
|
||||
<uni-nav-bar
|
||||
rightWidth="300rpx"
|
||||
leftWidth="300rpx"
|
||||
dark
|
||||
:fixed="true"
|
||||
status-bar
|
||||
background-color="#376cf3"
|
||||
color="#fff"
|
||||
@clickRight="openDrawer"
|
||||
background-color="#fff"
|
||||
color="#111"
|
||||
@clickRight="selectEngineering"
|
||||
>
|
||||
<template slot="left">
|
||||
<text style="font-size: 32rpx; font-weight: 500">灿能物联</text>
|
||||
</template>
|
||||
<template slot="right">
|
||||
<text class="hide-txt mr5" style="font-size: 28rpx">{{ select.engineeringName }}</text>
|
||||
<uni-icons type="bottom" size="16" color="#fff"></uni-icons>
|
||||
<uni-icons type="bottom" size="16" color="#111"></uni-icons>
|
||||
</template>
|
||||
</uni-nav-bar> -->
|
||||
</uni-nav-bar>
|
||||
<view class="index">
|
||||
<!-- 运维 -->
|
||||
<YunWei :devCount="devCount" v-if="userInfo.authorities === 'operation_manager'"/>
|
||||
@@ -34,15 +34,6 @@
|
||||
<Device ref="device" :store="store"/>
|
||||
</template>
|
||||
</view>
|
||||
<uni-drawer ref="showRight" mode="right" :mask-click="false">
|
||||
<view>
|
||||
<uni-indexed-list
|
||||
:options="engineeringListFilter"
|
||||
:showSelect="false"
|
||||
@click="closeDrawer"
|
||||
></uni-indexed-list>
|
||||
</view>
|
||||
</uni-drawer>
|
||||
</view>
|
||||
</Cn-page>
|
||||
</template>
|
||||
@@ -56,7 +47,6 @@ import Device from './comp/device.vue'
|
||||
import list from '../../common/js/list'
|
||||
import {getDevCount} from '../../common/api/device.js'
|
||||
import {queryEngineering} from '@/common/api/engineering.js'
|
||||
import {pinyin} from 'pinyin-pro'
|
||||
|
||||
export default {
|
||||
mixins: [list],
|
||||
@@ -78,56 +68,24 @@ export default {
|
||||
engineeringId: '',
|
||||
},
|
||||
engineeringList: [],
|
||||
drawer: false,
|
||||
navTabHeight: 0
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
engineeringListFilter() {
|
||||
let result = []
|
||||
this.engineeringList.forEach((item) => {
|
||||
let arr = pinyin(item.name[0], {toneType: 'none', type: 'array'})
|
||||
let letter = arr[0][0].toUpperCase()
|
||||
console.log(letter)
|
||||
let index = result.findIndex((item) => item.letter === letter)
|
||||
if (index === -1) {
|
||||
result.push({
|
||||
letter,
|
||||
data: [item.name],
|
||||
})
|
||||
} else {
|
||||
result[index].data.push(item.name)
|
||||
}
|
||||
})
|
||||
return result
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
onNavigationBarButtonTap(e) {
|
||||
console.log(e)
|
||||
// e的返回格式为json对象:{"text":"测试","index":0}
|
||||
this.drawer = !this.drawer
|
||||
if (this.drawer) {
|
||||
this.openDrawer()
|
||||
} else {
|
||||
this.closeDrawer()
|
||||
}
|
||||
selectEngineering() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/home/selectEngineering',
|
||||
})
|
||||
},
|
||||
async init() {
|
||||
let engineering = uni.getStorageSync('engineering')
|
||||
let res = await queryEngineering()
|
||||
this.engineeringList = res.data
|
||||
uni.setStorageSync('engineeringList', this.engineeringList)
|
||||
if (this.engineeringList.length === 0) {
|
||||
console.log('没有工程')
|
||||
uni.removeStorageSync(this.$cacheKey.engineering)
|
||||
this.projectList = []
|
||||
// 修改buttons
|
||||
// #ifdef APP-PLUS
|
||||
var webView = this.$mp.page.$getAppWebview()
|
||||
// 修改buttons
|
||||
webView.setTitleNViewButtonStyle(0, {
|
||||
text: '请先创建工程',
|
||||
})
|
||||
// #endif
|
||||
} else {
|
||||
if (!engineering) {
|
||||
uni.setStorageSync('engineering', res.data[0])
|
||||
@@ -144,15 +102,11 @@ export default {
|
||||
}
|
||||
}
|
||||
this.store.params.engineerId = this.select.engineeringId
|
||||
// #ifdef APP-PLUS
|
||||
var webView = this.$mp.page.$getAppWebview()
|
||||
// 修改buttons
|
||||
webView.setTitleNViewButtonStyle(0, {
|
||||
text: this.select.engineeringName,
|
||||
})
|
||||
// #endif
|
||||
this.getDevCount()
|
||||
this.$refs.device && this.$refs.device.init()
|
||||
console.log(this.$refs.device, 'this.$refs.device')
|
||||
this.$nextTick(() => {
|
||||
this.$refs.device && this.$refs.device.init()
|
||||
})
|
||||
}
|
||||
},
|
||||
getDevCount() {
|
||||
@@ -169,90 +123,18 @@ export default {
|
||||
console.log(this.devCount);
|
||||
})
|
||||
},
|
||||
closeDrawer(e) {
|
||||
if (!e) {
|
||||
// #ifdef APP-PLUS
|
||||
var webView = this.$mp.page.$getAppWebview()
|
||||
// 修改buttons
|
||||
webView.setTitleNViewButtonStyle(0, {
|
||||
text: this.select.engineeringName
|
||||
? this.select.engineeringName.length > 7
|
||||
? this.select.engineeringName.substring(0, 7) + '...'
|
||||
: this.select.engineeringName
|
||||
: '请选择工程',
|
||||
select: true,
|
||||
})
|
||||
// #endif
|
||||
this.$refs.showRight.close()
|
||||
return
|
||||
}
|
||||
console.log(e)
|
||||
this.engineeringList.forEach((item) => {
|
||||
if (item.name === e.item.name) {
|
||||
uni.setStorageSync('engineering', item)
|
||||
this.select.engineeringName = item.name
|
||||
this.select.engineeringId = item.id
|
||||
this.store.params.engineerId = item.id
|
||||
// #ifdef APP-PLUS
|
||||
var webView = this.$mp.page.$getAppWebview()
|
||||
// 修改buttons
|
||||
webView.setTitleNViewButtonStyle(0, {
|
||||
text:
|
||||
this.select.engineeringName.length > 7
|
||||
? this.select.engineeringName.substring(0, 7) + '...'
|
||||
: this.select.engineeringName,
|
||||
select: true,
|
||||
})
|
||||
// #endif
|
||||
}
|
||||
})
|
||||
this.$refs.device.select.projectName = ''
|
||||
this.$refs.device.select.projectNameIndex = 0
|
||||
this.getDevCount()
|
||||
this.$refs.device.init()
|
||||
this.$refs.showRight.close()
|
||||
},
|
||||
send() {
|
||||
uni.createPushMessage({
|
||||
title: '灿能',
|
||||
content: '灿能推送',
|
||||
success: function (res) {
|
||||
console.log('推送成功')
|
||||
},
|
||||
fail: function (res) {
|
||||
console.log('推送失败')
|
||||
},
|
||||
})
|
||||
},
|
||||
loadingChange(e) {
|
||||
this.loading = e
|
||||
},
|
||||
openDrawer(item) {
|
||||
if (this.engineeringList.length === 0) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/engineering/new',
|
||||
})
|
||||
return
|
||||
} else if (this.engineeringList.length === 1) {
|
||||
uni.showToast({
|
||||
title: '暂无其他工程',
|
||||
icon: 'none',
|
||||
})
|
||||
return
|
||||
}
|
||||
// #ifdef APP-PLUS
|
||||
var webView = this.$mp.page.$getAppWebview()
|
||||
// 修改buttons
|
||||
webView.setTitleNViewButtonStyle(0, {
|
||||
text: '取消',
|
||||
select: false,
|
||||
})
|
||||
// #endif
|
||||
this.$refs.showRight.open()
|
||||
},
|
||||
},
|
||||
onLoad() {
|
||||
this.store = this.DataSource('/cs-device-boot/EquipmentDelivery/queryEquipmentByProject')
|
||||
// #ifdef APP-PLUS
|
||||
setTimeout(() => {
|
||||
// 获取nav高度
|
||||
uni.createSelectorQuery().select('.uni-navbar').boundingClientRect((rect) => {
|
||||
this.navTabHeight = rect.height
|
||||
console.log('calc(100vh - ' + this.navTabHeight + ')')
|
||||
}).exec()
|
||||
}, 1000)
|
||||
// #endif
|
||||
},
|
||||
onShow() {
|
||||
this.userInfo = uni.getStorageSync(this.$cacheKey.userInfo)
|
||||
@@ -271,6 +153,10 @@ export default {
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.popup-content {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.index {
|
||||
padding: 20rpx 0 0;
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
<view :loading="loading">
|
||||
<view class="mine">
|
||||
<view class="mine-header" @click="jump('basic')">
|
||||
<image mode="aspectFill" class="mine-header-head" :src="userInfo.avatar" v-if="userInfo.avatar" />
|
||||
<image mode="aspectFill" class="mine-header-head" src="/static/head.png" v-else />
|
||||
<image mode="aspectFill" class="mine-header-head" :src="userInfo.avatar" v-if="userInfo.avatar"/>
|
||||
<image mode="aspectFill" class="mine-header-head" src="/static/head.png" v-else/>
|
||||
<view class="mine-header-name hide-txt">
|
||||
<view>{{ userInfo.nickname }}</view>
|
||||
<view></view>
|
||||
<view class="tag">{{ roleName }} </view>
|
||||
<view class="tag">{{ roleName }}</view>
|
||||
</view>
|
||||
<image
|
||||
src="/static/erweima.png"
|
||||
@@ -17,7 +17,7 @@
|
||||
<uni-icons type="forward" color="#aaa" size="16"></uni-icons>
|
||||
</view>
|
||||
<view class="mine-nav" v-if="userInfo.authorities === 'tourist'" @click="jump('upgrade')">
|
||||
<image mode="aspectFill" class="mine-nav-icon" src="/static/server.png" />
|
||||
<image mode="aspectFill" class="mine-nav-icon" src="/static/server.png"/>
|
||||
<view class="mine-nav-label">角色升级</view>
|
||||
<uni-icons type="forward" color="#aaa" size="20"></uni-icons>
|
||||
</view>
|
||||
@@ -37,12 +37,12 @@
|
||||
@click="jump('scan')"
|
||||
v-if="userInfo.authorities === 'app_vip_user' || userInfo.authorities === 'engineering_user'"
|
||||
>
|
||||
<image mode="aspectFill" class="mine-nav-icon" src="/static/scan.png" />
|
||||
<image mode="aspectFill" class="mine-nav-icon" src="/static/scan.png"/>
|
||||
<view class="mine-nav-label">扫一扫</view>
|
||||
<uni-icons type="forward" color="#aaa" size="20"></uni-icons>
|
||||
</view>
|
||||
<view class="mine-nav" @click="jump('engineering')">
|
||||
<image mode="aspectFill" class="mine-nav-icon" src="/static/project.png" />
|
||||
<image mode="aspectFill" class="mine-nav-icon" src="/static/project.png"/>
|
||||
<view class="mine-nav-label">工程列表</view>
|
||||
<uni-icons type="forward" color="#aaa" size="20"></uni-icons>
|
||||
</view>
|
||||
@@ -51,12 +51,12 @@
|
||||
@click="jump('engineering/setting')"
|
||||
v-if="userInfo.authorities === 'engineering_user'"
|
||||
>
|
||||
<image mode="aspectFill" class="mine-nav-icon" src="/static/like.png" />
|
||||
<image mode="aspectFill" class="mine-nav-icon" src="/static/like.png"/>
|
||||
<view class="mine-nav-label">关注工程配置</view>
|
||||
<uni-icons type="forward" color="#aaa" size="20"></uni-icons>
|
||||
</view>
|
||||
<view class="mine-nav" @click="jump('project')">
|
||||
<image mode="aspectFill" class="mine-nav-icon" src="/static/project.png" />
|
||||
<image mode="aspectFill" class="mine-nav-icon" src="/static/project.png"/>
|
||||
<view class="mine-nav-label">项目列表</view>
|
||||
<uni-icons type="forward" color="#aaa" size="20"></uni-icons>
|
||||
</view>
|
||||
@@ -70,12 +70,12 @@
|
||||
<uni-icons type="forward" color="#aaa" size="20"></uni-icons>
|
||||
</view> -->
|
||||
<view class="mine-nav" @click="jump('setupMessage')">
|
||||
<image mode="aspectFill" class="mine-nav-icon" src="/static/message4.png" />
|
||||
<image mode="aspectFill" class="mine-nav-icon" src="/static/message4.png"/>
|
||||
<view class="mine-nav-label">消息配置</view>
|
||||
<uni-icons type="forward" color="#aaa" size="20"></uni-icons>
|
||||
</view>
|
||||
<view class="mine-nav" @click="jump('setup')" style="border-bottom: none">
|
||||
<image mode="aspectFill" class="mine-nav-icon" src="/static/setup.png" />
|
||||
<image mode="aspectFill" class="mine-nav-icon" src="/static/setup.png"/>
|
||||
<view class="mine-nav-label">设置</view>
|
||||
<uni-icons type="forward" color="#aaa" size="20"></uni-icons>
|
||||
</view>
|
||||
@@ -93,8 +93,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { roleUpdate, autoLogin } from '@/common/api/user'
|
||||
import { transferDevice } from '@/common/api/device'
|
||||
import {roleUpdate, autoLogin} from '@/common/api/user'
|
||||
import {transferDevice,shareDevice} from '@/common/api/device'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -130,7 +130,8 @@ export default {
|
||||
this.init()
|
||||
},
|
||||
methods: {
|
||||
init() {},
|
||||
init() {
|
||||
},
|
||||
upgrade(code) {
|
||||
console.log(code)
|
||||
roleUpdate({
|
||||
@@ -162,7 +163,11 @@ export default {
|
||||
case 'transferDevice':
|
||||
this.transferDevice(content.id.split(','))
|
||||
break
|
||||
case 'shareDevice':
|
||||
this.shareDevice(content.id.split(','))
|
||||
break
|
||||
default:
|
||||
this.$util.toast('无效二维码')
|
||||
break
|
||||
}
|
||||
},
|
||||
@@ -210,7 +215,12 @@ export default {
|
||||
},
|
||||
transferDevice(id) {
|
||||
transferDevice(id).then((res) => {
|
||||
uni.navigateTo({ url: '/pages/mine/result?type=transferDevice&id=' + id })
|
||||
uni.navigateTo({url: '/pages/mine/result?type=transferDevice&id=' + id})
|
||||
})
|
||||
},
|
||||
shareDevice(id) {
|
||||
shareDevice(id).then((res) => {
|
||||
uni.navigateTo({url: '/pages/mine/result?type=shareDevice&id=' + id})
|
||||
})
|
||||
},
|
||||
},
|
||||
@@ -252,6 +262,7 @@ export default {
|
||||
margin-top: 10rpx;
|
||||
font-size: 24rpx;
|
||||
color: #aaa;
|
||||
|
||||
.engineering-button {
|
||||
margin-left: 10rpx;
|
||||
font-size: 24rpx;
|
||||
|
||||
Reference in New Issue
Block a user