Commit d63e8b1b9ee7b3bf83bd958a2d917a94f2ac93f5
Merge branch 'ft-dev' into 'main'
feat:新增组态功能 See merge request huang/thingskit-app!67
Showing
9 changed files
with
152 additions
and
41 deletions
| ... | ... | @@ -2,15 +2,17 @@ import { |
| 2 | 2 | getTabbarHeight |
| 3 | 3 | } from '@/plugins/utils'; |
| 4 | 4 | let baseUrl = ""; |
| 5 | +let baseDrawioUrl = "" | |
| 5 | 6 | if (process.env.NODE_ENV === 'development') { |
| 6 | 7 | // 开发环境 |
| 7 | 8 | // baseUrl = 'http://192.168.10.115:8080/api' |
| 8 | 9 | baseUrl = 'https://dev.thingskit.com/api' |
| 9 | - | |
| 10 | + baseDrawioUrl = 'https://dev.thingskit.com/thingskit-drawio' | |
| 10 | 11 | } else if (process.env.NODE_ENV === 'production') { |
| 11 | 12 | // 生产环境 |
| 12 | 13 | // baseUrl = 'http://47.99.141.212:8080/api' |
| 13 | 14 | baseUrl = 'https://dev.thingskit.com/api' |
| 15 | + baseDrawioUrl = 'https://dev.thingskit.com/thingskit-drawio' | |
| 14 | 16 | } |
| 15 | 17 | |
| 16 | 18 | let systemInfo = { |
| ... | ... | @@ -41,6 +43,7 @@ console.log(systemInfo, 'systemInfo') |
| 41 | 43 | const courtConfig = { |
| 42 | 44 | publicAppId: '', //公众号appId |
| 43 | 45 | baseUrl: baseUrl, //域名 |
| 46 | + baseDrawioUrl: baseDrawioUrl, | |
| 44 | 47 | systemInfo: systemInfo, //系统信息 |
| 45 | 48 | mapData: { |
| 46 | 49 | key: '', //地图key | ... | ... |
| ... | ... | @@ -14,7 +14,10 @@ uni.$u.http.setConfig((config) => { |
| 14 | 14 | window.sessionStorage.getItem("userInfo").isToken; |
| 15 | 15 | // #endif |
| 16 | 16 | /* config 为默认全局配置*/ |
| 17 | - config.baseURL = base.baseUrl; /* 根域名 */ | |
| 17 | + // const getConfiguration = uni.getStorageSync('getConfiguration').isConfiguration | |
| 18 | + // console.log('getConfiguration', getConfiguration); | |
| 19 | + // config.baseURL = getConfiguration == true ? base.baseDrawioUrl : base.baseUrl /* 根域名 */ | |
| 20 | + config.baseURL = base.baseUrl /* 根域名 */ | |
| 18 | 21 | config.header = { |
| 19 | 22 | "Content-Type": "application/json", |
| 20 | 23 | 'X-Authorization': "Bearer " + token, |
| ... | ... | @@ -39,17 +42,23 @@ uni.$u.http.interceptors.request.use( |
| 39 | 42 | // 初始化请求拦截器时,会执行此方法,此时data为undefined,赋予默认{} |
| 40 | 43 | config.data = config.data || {}; |
| 41 | 44 | // 根据custom参数中配置的是否需要token,添加对应的请求头 |
| 45 | + const getConfiguration = uni.getStorageSync('getConfiguration').isConfiguration | |
| 42 | 46 | if (config?.custom?.auth) { |
| 43 | 47 | config.header['X-Authorization'] = |
| 44 | 48 | "Bearer " + store.state.userInfo.isToken || |
| 45 | 49 | uni.getStorageSync("userInfo").isToken || |
| 46 | 50 | undefined; |
| 51 | + config.baseURL = getConfiguration == true ? base.baseDrawioUrl : base.baseUrl | |
| 47 | 52 | } |
| 48 | 53 | if (config?.custom?.load) { |
| 49 | 54 | //打开加载动画 |
| 50 | 55 | store.commit("setLoadingShow", true); |
| 51 | 56 | } |
| 52 | - | |
| 57 | + if (getConfiguration) { | |
| 58 | + uni.setStorageSync('config', config) | |
| 59 | + } else { | |
| 60 | + uni.removeStorageSync('config') | |
| 61 | + } | |
| 53 | 62 | return config; |
| 54 | 63 | }, |
| 55 | 64 | (config) => { | ... | ... |
| ... | ... | @@ -2,60 +2,112 @@ |
| 2 | 2 | <view class="status-page"> |
| 3 | 3 | <f-navbar navbarType="2" @leftClick="leftClick"> |
| 4 | 4 | <view class="u-flex search-top" slot="left"> |
| 5 | - <view class="search-main"><u--input prefixIcon="search" placeholder="请输入组态名称" border="surround" shape="circle"></u--input></view> | |
| 5 | + <view class="search-main"><u--input @change="inputChanged" prefixIcon="search" placeholder="请输入组态名称" border="surround" shape="circle"></u--input></view> | |
| 6 | 6 | </view> |
| 7 | 7 | </f-navbar> |
| 8 | 8 | <!-- 公共组件-每个页面必须引入 --> |
| 9 | 9 | <public-module></public-module> |
| 10 | - <view class="status-container"> | |
| 11 | - <view @click="openStatusDetail(item.id)" v-for="(item, index) in list" :key="index" class="status-item u-flex"> | |
| 12 | - <view class="item-image"><image class="image" :src="item.icon"></image></view> | |
| 13 | - <view class="item-text"> | |
| 14 | - <text class="text">{{ item.name }}</text> | |
| 10 | + <mescroll-body ref="mescrollRef" :up="upOption" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback"> | |
| 11 | + <view class="status-container"> | |
| 12 | + <view @click="openConfigDetail(item.id)" v-for="(item, index) in list" :key="index" class="status-item u-flex"> | |
| 13 | + <view style="cursor: pointer;" class="item-image"><image class="image" :src="item.icon || defaultConfigImage"></image></view> | |
| 14 | + <view class="item-text"> | |
| 15 | + <text class="text">{{ item.name }}</text> | |
| 16 | + </view> | |
| 15 | 17 | </view> |
| 16 | 18 | </view> |
| 17 | - </view> | |
| 18 | - <f-tabbar></f-tabbar> | |
| 19 | + </mescroll-body> | |
| 19 | 20 | </view> |
| 20 | 21 | </template> |
| 21 | 22 | |
| 22 | 23 | <script> |
| 23 | -import fTabbar from '@/components/module/f-tabbar/f-tabbar'; | |
| 24 | 24 | import fNavbar from '@/components/module/f-navbar/f-navbar'; |
| 25 | +import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js'; | |
| 25 | 26 | |
| 26 | 27 | export default { |
| 27 | 28 | components: { |
| 28 | - fTabbar, | |
| 29 | 29 | fNavbar |
| 30 | 30 | }, |
| 31 | + mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件) | |
| 31 | 32 | data() { |
| 32 | 33 | return { |
| 33 | - list: [ | |
| 34 | - { | |
| 35 | - id: 1, | |
| 36 | - name: '智慧办公室1', | |
| 37 | - icon: '../../../static/test.png' | |
| 38 | - }, | |
| 39 | - { | |
| 40 | - id: 2, | |
| 41 | - name: '智慧办公室2', | |
| 42 | - icon: '../../../static/test.png' | |
| 43 | - } | |
| 44 | - ] | |
| 34 | + page: { | |
| 35 | + num: 0, | |
| 36 | + size: 10 | |
| 37 | + }, | |
| 38 | + downOption: { | |
| 39 | + auto: true //是否在初始化后,自动执行downCallback; 默认true | |
| 40 | + }, | |
| 41 | + upOption: { | |
| 42 | + auto: false // 不自动加载 | |
| 43 | + }, | |
| 44 | + defaultConfigImage: '../../../static/test.png', | |
| 45 | + list: [] | |
| 45 | 46 | }; |
| 46 | 47 | }, |
| 47 | 48 | onLoad() { |
| 48 | 49 | // 隐藏原生的tabbar |
| 49 | 50 | uni.hideTabBar(); |
| 51 | + uni.setStorageSync('getConfiguration', { | |
| 52 | + isConfiguration: false | |
| 53 | + }); | |
| 54 | + }, | |
| 55 | + onUnload() { | |
| 56 | + uni.setStorageSync('getConfiguration', { | |
| 57 | + isConfiguration: false | |
| 58 | + }); | |
| 59 | + uni.removeStorageSync('getConfiguration'); | |
| 50 | 60 | }, |
| 51 | 61 | methods: { |
| 62 | + inputChanged(e) { | |
| 63 | + this.page.num = 1; | |
| 64 | + this.loadData(1, e); | |
| 65 | + }, | |
| 52 | 66 | leftClick() { |
| 53 | 67 | return false; |
| 54 | 68 | }, |
| 55 | - openStatusDetail(e) { | |
| 69 | + onBackPress() { | |
| 70 | + console.log('返回'); | |
| 71 | + return true; // 阻止返回 不阻止就不写或者用uni.navigateBack({ delta: 1 })返回 | |
| 72 | + }, | |
| 73 | + openConfigDetail(e) { | |
| 56 | 74 | uni.navigateTo({ |
| 57 | - url: 'configurationDetail' | |
| 75 | + url: 'configurationDetail?configId=' + e | |
| 58 | 76 | }); |
| 77 | + }, | |
| 78 | + /*下拉刷新的回调 */ | |
| 79 | + downCallback() { | |
| 80 | + //联网加载数据 | |
| 81 | + this.page.num = 1; | |
| 82 | + this.loadData(1); | |
| 83 | + }, | |
| 84 | + /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */ | |
| 85 | + upCallback() { | |
| 86 | + //联网加载数据 | |
| 87 | + this.page.num += 1; | |
| 88 | + this.loadData(this.page.num); | |
| 89 | + }, | |
| 90 | + loadData(pageNo, T) { | |
| 91 | + let httpData = { | |
| 92 | + page: pageNo, | |
| 93 | + pageSize: 10, | |
| 94 | + name: T | |
| 95 | + }; | |
| 96 | + uni.$u.http | |
| 97 | + .get('/yt/configuration/center', { params: httpData, custom: { load: false } }) | |
| 98 | + .then(res => { | |
| 99 | + uni.stopPullDownRefresh(); | |
| 100 | + this.mescroll.endByPage(res.items.length, res.total); | |
| 101 | + if (pageNo == 1) { | |
| 102 | + this.list = res.items; | |
| 103 | + } else { | |
| 104 | + this.list = this.list.concat(res.items); | |
| 105 | + } | |
| 106 | + }) | |
| 107 | + .catch(e => { | |
| 108 | + //联网失败, 结束加载 | |
| 109 | + this.mescroll.endErr(); | |
| 110 | + }); | |
| 59 | 111 | } |
| 60 | 112 | } |
| 61 | 113 | }; | ... | ... |
| ... | ... | @@ -2,24 +2,66 @@ |
| 2 | 2 | <view class="content"> |
| 3 | 3 | <!-- 公共组件-每个页面必须引入 --> |
| 4 | 4 | <public-module></public-module> |
| 5 | - <f-tabbar :isFillHeight="false"></f-tabbar> | |
| 5 | + <web-view :src="showConfiguration" bindload="bindload" binderror="binderror"></web-view> | |
| 6 | 6 | </view> |
| 7 | 7 | </template> |
| 8 | 8 | |
| 9 | 9 | <script> |
| 10 | -import fTabbar from '@/components/module/f-tabbar/f-tabbar'; | |
| 11 | 10 | export default { |
| 12 | - components: { | |
| 13 | - fTabbar | |
| 14 | - }, | |
| 15 | 11 | data() { |
| 16 | - return {}; | |
| 12 | + return { | |
| 13 | + showConfiguration: '', | |
| 14 | + defauleConfigImage: 'https://dev.thingskit.com', | |
| 15 | + params: '' | |
| 16 | + }; | |
| 17 | 17 | }, |
| 18 | 18 | onLoad(e) { |
| 19 | + uni.setStorageSync('getConfiguration', { | |
| 20 | + isConfiguration: true | |
| 21 | + }); | |
| 22 | + if (e.configId !== null) { | |
| 23 | + this.params = e.configId; | |
| 24 | + this.requestUrl(this.params); | |
| 25 | + } | |
| 19 | 26 | // 隐藏原生的tabbar |
| 20 | 27 | uni.hideTabBar(); |
| 28 | + }, | |
| 29 | + onShow() { | |
| 30 | + uni.setStorageSync('getConfiguration', { | |
| 31 | + isConfiguration: true | |
| 32 | + }); | |
| 33 | + }, | |
| 34 | + onUnload() { | |
| 35 | + uni.setStorageSync('getConfiguration', { | |
| 36 | + isConfiguration: false | |
| 37 | + }); | |
| 38 | + uni.removeStorageSync('config'); | |
| 39 | + }, | |
| 40 | + methods: { | |
| 41 | + // 网页加载成功时候触发此事件 | |
| 42 | + bindload(res) { | |
| 43 | + console.log(res, res.detail); | |
| 44 | + }, | |
| 45 | + // 网页加载失败的时候触发此事件 | |
| 46 | + binderror(err) { | |
| 47 | + console.log(err, err.detail); | |
| 48 | + }, | |
| 49 | + async requestUrl(e) { | |
| 50 | + const httpData = { | |
| 51 | + configurationId: e, | |
| 52 | + lightbox: 1 | |
| 53 | + }; | |
| 54 | + const getUrl = await uni.$u.http.get('/', { params: httpData, custom: { load: false } }); | |
| 55 | + const pathUrl = uni.getStorageSync('config'); | |
| 56 | + this.showConfiguration = pathUrl.baseURL + '/' + '?' + 'configurationId=' + e + '&' + 'lightbox=' + 1; | |
| 57 | + } | |
| 21 | 58 | } |
| 22 | 59 | }; |
| 23 | 60 | </script> |
| 24 | 61 | |
| 25 | -<style lang="scss" scoped></style> | |
| 62 | +<style lang="scss" scoped> | |
| 63 | +.content { | |
| 64 | + background: #f8f9fa; | |
| 65 | + min-height: 100vh; | |
| 66 | +} | |
| 67 | +</style> | ... | ... |
| ... | ... | @@ -121,6 +121,10 @@ export default { |
| 121 | 121 | // 隐藏原生的tabbar |
| 122 | 122 | uni.hideTabBar(); |
| 123 | 123 | this.getDeviceTotalData(); |
| 124 | + uni.setStorageSync('getConfiguration', { | |
| 125 | + isConfiguration: false | |
| 126 | + }); | |
| 127 | + uni.removeStorageSync('getConfiguration'); | |
| 124 | 128 | }, |
| 125 | 129 | methods: { |
| 126 | 130 | ...mapActions(['updateBadgeTotal']), |
| ... | ... | @@ -145,13 +149,11 @@ export default { |
| 145 | 149 | uni.navigateTo({ |
| 146 | 150 | url: 'camera/camera' |
| 147 | 151 | }); |
| 148 | - // this.showToastWip() | |
| 149 | 152 | }, |
| 150 | 153 | openOrgStatus() { |
| 151 | - // uni.navigateTo({ | |
| 152 | - // url: 'configuration/configuration' | |
| 153 | - // }); | |
| 154 | - this.showToastWip(); | |
| 154 | + uni.navigateTo({ | |
| 155 | + url: 'configuration/configuration' | |
| 156 | + }); | |
| 155 | 157 | }, |
| 156 | 158 | //告警状态查询 |
| 157 | 159 | navigatorAlarmStatus(e) { | ... | ... |
| ... | ... | @@ -174,7 +174,7 @@ export default { |
| 174 | 174 | icon: 'none' |
| 175 | 175 | }).then(res => { |
| 176 | 176 | uni.reLaunch({ |
| 177 | - url: '/pages/personal/personal' | |
| 177 | + url: '/publicLoginSubPage/public/login' | |
| 178 | 178 | }); |
| 179 | 179 | }); |
| 180 | 180 | }) |
| ... | ... | @@ -183,7 +183,6 @@ export default { |
| 183 | 183 | title: err.data.msg, |
| 184 | 184 | icon: 'none' |
| 185 | 185 | }); |
| 186 | - console.log(err.data.msg); | |
| 187 | 186 | }); |
| 188 | 187 | }, |
| 189 | 188 | showPasswordModeF() { | ... | ... |