diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..0a2145d --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "singleQuote": true, + "trailingComma": "all", + "tabWidth": 4, + "printWidth": 120, + "useTabs": false, + "semi": false +} \ No newline at end of file diff --git a/App.vue b/App.vue index 328e4eb..99d9f00 100644 --- a/App.vue +++ b/App.vue @@ -8,7 +8,7 @@ import mqtt from 'mqtt/dist/mqtt.js' export default { methods: { connect () { - MQTT_OPTIONS.clientId = uni.getStorageSync('cidAES') + MQTT_OPTIONS.clientId = uni.getStorageSync('devCode') var that = this let client = mqtt.connect('ws://' + MQTT_IP, MQTT_OPTIONS) client.on('connect', function () { @@ -32,15 +32,15 @@ export default { }, onLaunch: function () { // this.connect() - let cidAES = uni.getStorageSync('cidAES') || 'nnvmhMk8626D8QHhJefm+W9rTAJWuBPRxcnRm4+9bWXdSLRIyTnTruoYfLxGK3Oy' - uni.setStorageSync('cidAES', cidAES); - if (!cidAES) { + let devCode = uni.getStorageSync('devCode') || 'nnvmhMk8626D8QHhJefm+W9rTAJWuBPRxcnRm4+9bWXdSLRIyTnTruoYfLxGK3Oy' + uni.setStorageSync('devCode', devCode); + if (!devCode) { document.addEventListener('plusready', () => { // 页面加载时触发 let pinf = plus.push.getClientInfo(); let cid = pinf.clientid;//客户端标识 - cidAES = encrypt.Encrypt(cid, this.$config.key); - uni.setStorageSync('cidAES', cidAES); + devCode = encrypt.Encrypt(cid, this.$config.key); + uni.setStorageSync('devCode', devCode); }, false); } diff --git a/common/api/device.js b/common/api/device.js index c39db49..92cbb2f 100644 --- a/common/api/device.js +++ b/common/api/device.js @@ -4,7 +4,7 @@ import config from '../js/config'; // 获取设备 export function getDeviceList(params) { return request({ - url: '/EquipmentDelivery/queryEquipmentByProject', + url: '/cs-device-boot/EquipmentDelivery/queryEquipmentByProject', method: 'post', data: params, }); diff --git a/common/api/gc.js b/common/api/engineering.js similarity index 78% rename from common/api/gc.js rename to common/api/engineering.js index 109b936..8391e96 100644 --- a/common/api/gc.js +++ b/common/api/engineering.js @@ -3,7 +3,7 @@ import config from '../js/config'; export function addEngineering(params) { return request({ - url: '/engineering/addEngineering', + url: '/cs-device-boot/engineering/addEngineering', method: 'post', data: params, header: { @@ -15,7 +15,7 @@ export function addEngineering(params) { export function auditEngineering(params) { return request({ - url: '/engineering/auditEngineering', + url: '/cs-device-boot/engineering/auditEngineering', method: 'post', data: params, header: { @@ -26,7 +26,7 @@ export function auditEngineering(params) { export function queryEngineering(params) { return request({ - url: '/engineering/queryEngineering', + url: '/cs-device-boot/engineering/queryEngineering', method: 'post', data: params, header: { diff --git a/common/api/feedback.js b/common/api/feedback.js index 5a7be9f..ce13d41 100644 --- a/common/api/feedback.js +++ b/common/api/feedback.js @@ -11,10 +11,10 @@ export function addFeedBack(params) { let data = JSON.parse(JSON.stringify(params)); delete data.files return uni.uploadFile({ - url: config.domain + '/feedback/addFeedBack', //仅为示例,非真实的接口地址 + url: config.domain + '/cs-device-boot/feedback/addFeedBack', //仅为示例,非真实的接口地址 files: files, header: { - Authorization: '12', + Authorization: uni.getStorageSync('access_token'), }, formData: data, }); @@ -27,7 +27,7 @@ export function addFeedBack(params) { */ export function queryFeedBackDetail(id) { return request({ - url: '/feedback/queryFeedBackDetail', + url: '/cs-device-boot/feedback/queryFeedBackDetail', method: 'post', data: { id, @@ -38,7 +38,7 @@ export function queryFeedBackDetail(id) { // 问题列表 export function queryFeedBackPage(params) { return request({ - url: '/feedback/queryFeedBackPage', + url: '/cs-device-boot/feedback/queryFeedBackPage', method: 'post', data: { pageNum: 1, @@ -58,7 +58,7 @@ export function queryFeedBackPage(params) { */ export function AddFeedbackChat(params) { return request({ - url: '/feedbackChat/AddFeedbackChat', + url: '/cs-device-boot/feedbackChat/AddFeedbackChat', method: 'post', data: params, header: { @@ -77,7 +77,7 @@ export function AddFeedbackChat(params) { */ export function updateChatStatus(params) { return request({ - url: '/feedbackChat/updateChatStatus', + url: '/cs-device-boot/feedbackChat/updateChatStatus', method: 'post', data: params, header: { diff --git a/common/api/mine.js b/common/api/mine.js index 99bc899..e87fa7a 100644 --- a/common/api/mine.js +++ b/common/api/mine.js @@ -1,12 +1,12 @@ -import request from '../js/request'; -import config from '../js/config'; +import request from '../js/request' +import config from '../js/config' export function queryPersonSet() { return request({ url: '/appinfo/queryPersonSet', method: 'post', data: {}, - }); + }) } export function queryAppInfo(id) { @@ -16,5 +16,6 @@ export function queryAppInfo(id) { data: { id, }, - }); + }) } + diff --git a/common/api/project.js b/common/api/project.js index 88af111..5ff3c86 100644 --- a/common/api/project.js +++ b/common/api/project.js @@ -3,10 +3,10 @@ import config from '../js/config' export function addAppProject(params, files) { return uni.uploadFile({ - url: config.domain + '/project/addAppProject', //仅为示例,非真实的接口地址 + url: config.domain + '/cs-device-boot/project/addAppProject', //仅为示例,非真实的接口地址 files: files, header: { - Authorization: '12', + Authorization: uni.getStorageSync('access_token'), }, formData: params, }) @@ -14,7 +14,7 @@ export function addAppProject(params, files) { export function getProjectList(params) { return request({ - url: '/project/queryProject', + url: '/cs-device-boot/project/queryProject', method: 'post', data: params, header: { @@ -36,7 +36,7 @@ export function queryTopologyDiagramPage(params) { projectId: '', searchValue: '', }, - params + params, ), header: { 'Content-Type': 'application/json', @@ -67,14 +67,15 @@ export function addAppTopologyDiagram(params, filePath) { filePath, name: 'file', header: { - Authorization: '12', + Authorization: uni.getStorageSync('access_token'), }, formData: Object.assign( { topologyDiagramName: '', projectId: '', }, - params + params, ), }) } + diff --git a/common/api/user.js b/common/api/user.js index 70bd936..ca117db 100644 --- a/common/api/user.js +++ b/common/api/user.js @@ -10,7 +10,7 @@ export function apiGetYms(params) { url: '/user-boot/appUser/authCode', data: { phone: params.phone, - devCode: uni.getStorageSync('cidAES'), + devCode: uni.getStorageSync('devCode'), type: params.type, }, method: 'POST', @@ -23,12 +23,12 @@ export function apiGetYms(params) { * @returns */ export function apiLogin(params) { - console.log(uni.getStorageSync('cidAES')) + console.log(uni.getStorageSync('devCode')) return request({ url: '/shiningCloud/user/login', data: { phone: params.phone, - devCode: uni.getStorageSync('cidAES'), + devCode: uni.getStorageSync('devCode'), key: params.key.trim(), type: params.type, }, @@ -42,9 +42,9 @@ export function apiLogin(params) { * @returns */ export function apiYsmLogin(params) { - uni.setStorageSync('token', 'Basic bmpjbmFwcDpuamNucHFz') + uni.setStorageSync('access_token', 'Basic bmpjbmFwcDpuamNucHFz') return request({ - url: '/pas-auth/oauth/token', + url: '/pqs-auth/oauth/token', data: { grant_type: 'sms_code', phone: params.phone, @@ -64,7 +64,7 @@ export function apiRegister(params) { url: '/user-boot/appUser/register', data: { phone: params.phone, - devCode: uni.getStorageSync('cidAES'), + devCode: uni.getStorageSync('devCode'), code: params.code.trim(), }, method: 'POST', @@ -81,7 +81,7 @@ export function autoLogin(phone) { url: '/user-boot/appUser/autoLogin', data: { phone: phone, - devCode: uni.getStorageSync('cidAES'), + devCode: uni.getStorageSync('devCode'), }, method: 'POST', }) @@ -93,7 +93,7 @@ export function apiSetPsd(params) { url: '/shiningCloud/user/setPsd', data: { userId: uni.getStorageSync('userInfo').userId, - devCode: uni.getStorageSync('cidAES'), + devCode: uni.getStorageSync('devCode'), password: params.password.trim(), }, method: 'POST', @@ -107,7 +107,7 @@ export function apiReSetPsd(params) { data: { phone: params.phone, code: params.code.trim(), - devCode: uni.getStorageSync('cidAES'), + devCode: uni.getStorageSync('devCode'), password: params.password.trim(), }, method: 'POST', @@ -119,7 +119,7 @@ export function apiComfirmCode(params) { return request({ url: '/shiningCloud/user/comfirmCode', data: { - devCode: uni.getStorageSync('cidAES'), + devCode: uni.getStorageSync('devCode'), phone: params.phone, code: params.code.trim(), }, @@ -132,7 +132,7 @@ export function apiRebindPhone(params) { return request({ url: '/shiningCloud/user/rebindPhone', data: { - devCode: uni.getStorageSync('cidAES'), + devCode: uni.getStorageSync('devCode'), userId: uni.getStorageSync('userInfo').userId, phoneNew: params.phone, code: params.code.trim(), @@ -140,3 +140,16 @@ export function apiRebindPhone(params) { method: 'POST', }) } + +// 角色升级 +export function roleUpdate({ userId, referralCode }) { + return request({ + url: '/user-boot/appRole/roleUpdate', + method: 'post', + data: { + devCode: uni.getStorageSync('devCode'), + referralCode, + userId, + }, + }) +} diff --git a/common/js/cacheKey.js b/common/js/cacheKey.js index 9c82364..880bcd7 100644 --- a/common/js/cacheKey.js +++ b/common/js/cacheKey.js @@ -1,4 +1,7 @@ export default { config: 'config', // 全剧配置 userInfo: 'userInfo', // 用户信息 -} \ No newline at end of file + engineering: 'engineering', // 工程信息 + access_token: 'access_token', // token + refresh_token: 'refresh_token', // 刷新token +} diff --git a/common/js/request.js b/common/js/request.js index 2d59c56..96eb368 100644 --- a/common/js/request.js +++ b/common/js/request.js @@ -25,7 +25,7 @@ export default (options = {}) => { header: { // 'Content-Type': 'application/json;charset=UTF-8', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', - Authorization: uni.getStorageSync('token'), + Authorization: uni.getStorageSync('access_token'), ...options.header, }, method: options.method || 'GET', @@ -63,17 +63,22 @@ export default (options = {}) => { * @param {Number} code 错误码 */ function errHandler(res) { - switch (res.resultCode) { + switch (res.code) { case '401': // #ifdef MP - uni.removeStorageSync('Cookie') + uni.clearStorageSync() + // #endif + uni.reLaunch({ url: '/pages/user/login' }) + break + case 'A0202': + // #ifdef MP uni.clearStorageSync() // #endif uni.reLaunch({ url: '/pages/user/login' }) break default: uni.showToast({ - title: res.message || res.msg || '服务端未知错误', + title: res.message || res.msg || '网络异常,请稍后再试', duration: 2000, icon: 'none', }) diff --git a/pages.json b/pages.json index 32fbb7f..fce8a80 100644 --- a/pages.json +++ b/pages.json @@ -298,19 +298,19 @@ } }, { - "path": "pages/gc/new", + "path": "pages/engineering/new", "style": { "navigationBarTitleText": "新增工程" } }, { - "path": "pages/gc/list", + "path": "pages/engineering/list", "style": { "navigationBarTitleText": "工程列表" } }, { - "path": "pages/gc/detail", + "path": "pages/engineering/detail", "style": { "navigationBarTitleText": "工程详情" } diff --git a/pages/device/APF/detail.vue b/pages/device/APF/detail.vue index 398735d..dfb4203 100644 --- a/pages/device/APF/detail.vue +++ b/pages/device/APF/detail.vue @@ -217,8 +217,8 @@ export default { }, init () { let userInfo = uni.getStorageSync(this.$cacheKey.userInfo) - console.log(userInfo.role); - switch (userInfo.role) { + console.log(userInfo.authorities); + switch (userInfo.authorities) { case 1: this.content.splice(0, 1) this.content.splice(0, 0, { diff --git a/pages/device/DVR/detail.vue b/pages/device/DVR/detail.vue index 9eec58a..32143bd 100644 --- a/pages/device/DVR/detail.vue +++ b/pages/device/DVR/detail.vue @@ -119,8 +119,8 @@ export default { }, init () { let userInfo = uni.getStorageSync(this.$cacheKey.userInfo) - console.log(userInfo.role); - switch (userInfo.role) { + console.log(userInfo.authorities); + switch (userInfo.authorities) { case 1: this.content.splice(0, 0, { iconPath: '/static/version.png', diff --git a/pages/gc/detail.vue b/pages/engineering/detail.vue similarity index 90% rename from pages/gc/detail.vue rename to pages/engineering/detail.vue index 2c2aa3d..2d66919 100644 --- a/pages/gc/detail.vue +++ b/pages/engineering/detail.vue @@ -4,11 +4,11 @@ {{ gc.name }} + >{{ engineering.name }} - {{ gc.provinceName + gc.cityName }} {{ gc.createTime }} - {{ gc.description }} + {{ engineering.provinceName + engineering.cityName }} {{ engineering.createTime }} + {{ engineering.description }} diff --git a/pages/gc/list.vue b/pages/engineering/list.vue similarity index 81% rename from pages/gc/list.vue rename to pages/engineering/list.vue index e06160f..5eeed11 100644 --- a/pages/gc/list.vue +++ b/pages/engineering/list.vue @@ -6,7 +6,7 @@ :fixed="true" status-bar left-icon="left" - :rightIcon="userInfo.role == '2' ? '' : 'plusempty'" + :rightIcon="userInfo.authorities == '2' ? '' : 'plusempty'" background-color="#fff" color="#111" title="工程管理" @@ -14,7 +14,13 @@ @clickRight="add" /> - + 区域 @@ -44,16 +50,22 @@ export default { }, methods: { init() { - this.store = this.DataSource('/engineering/queryEngineeringPage') + this.store = this.DataSource('/cs-device-boot/engineering/queryEngineeringPage') this.store.params.userId = uni.getStorageSync('userInfo').id this.store.reload() + this.store.firstCallBack = (res) => { + let engineering = uni.getStorageSync('engineering') + if (!engineering) { + uni.setStorageSync('engineering',this.store.data[0]) + } + } }, back() { uni.navigateBack() }, add() { uni.navigateTo({ - url: `/pages/gc/new`, + url: `/pages/engineering/new`, }) }, upgrade(code) { @@ -63,9 +75,9 @@ export default { icon: 'none', }) }, - jump(gc) { + jump(engineering) { uni.navigateTo({ - url: `/pages/gc/detail?gc=${JSON.stringify(gc)}`, + url: `/pages/engineering/detail?engineering=${JSON.stringify(engineering)}`, }) }, }, diff --git a/pages/gc/new.vue b/pages/engineering/new.vue similarity index 98% rename from pages/gc/new.vue rename to pages/engineering/new.vue index db5538b..2f6e17e 100644 --- a/pages/gc/new.vue +++ b/pages/engineering/new.vue @@ -29,7 +29,7 @@ + diff --git a/pages/index/comp/indexGongCheng.vue b/pages/index/comp/indexGongCheng.vue index 13a0297..a571188 100644 --- a/pages/index/comp/indexGongCheng.vue +++ b/pages/index/comp/indexGongCheng.vue @@ -21,179 +21,20 @@ - - {{ select.engineeringName || '工程' }} - - - {{ select.projectName || '项目' }} - - - {{ select.projectType || '类型' }} - - - - - - - - - - - - diff --git a/pages/index/comp/indexYouKe.vue b/pages/index/comp/indexYouKe.vue index cf49a9c..32ade8e 100644 --- a/pages/index/comp/indexYouKe.vue +++ b/pages/index/comp/indexYouKe.vue @@ -14,208 +14,11 @@
离线设备
- - - {{ - select.projectName || '项目' }} - - - {{ - select.projectType || '类型' }} - - - - - - - -
- \ No newline at end of file + diff --git a/pages/index/comp/indexYunWei.vue b/pages/index/comp/indexYunWei.vue index d8ba55c..c69f473 100644 --- a/pages/index/comp/indexYunWei.vue +++ b/pages/index/comp/indexYunWei.vue @@ -14,221 +14,9 @@
离线设备
- - - - {{ select.projectName || '项目' }} - - - {{ select.projectType || '类型' }} - - - - - - - -
diff --git a/pages/index/comp/indexZhuYongHu.vue b/pages/index/comp/indexZhuYongHu.vue index da3db87..a571188 100644 --- a/pages/index/comp/indexZhuYongHu.vue +++ b/pages/index/comp/indexZhuYongHu.vue @@ -21,96 +21,19 @@
- - - {{ select.projectName || '项目' }} - - - {{ select.projectType || '类型' }} - - - - - - - - -
diff --git a/pages/index/comp/indexZiYongHu.vue b/pages/index/comp/indexZiYongHu.vue deleted file mode 100644 index 407d081..0000000 --- a/pages/index/comp/indexZiYongHu.vue +++ /dev/null @@ -1,234 +0,0 @@ - - - diff --git a/pages/index/index.vue b/pages/index/index.vue index bfdddd9..54d76c8 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -3,23 +3,15 @@ - + - + - + - - - - - + + + @@ -28,13 +20,10 @@ import YunWei from './comp/indexYunWei.vue' import GongCheng from './comp/indexGongCheng.vue' import ZhuYongHu from './comp/indexZhuYongHu.vue' -import ZiYongHu from './comp/indexZiYongHu.vue' import ZhuanZhi from './comp/indexZhuanZhi.vue' import YouKe from './comp/indexYouKe.vue' +import Device from './comp/device.vue' import list from '../../common/js/list' -import { getProjectList } from '../../common/api/project' -import { queryDictData } from '../../common/api/dictionary' -import { queryEngineering } from '@/common/api/gc.js' export default { mixins: [list], @@ -42,78 +31,16 @@ export default { YunWei, GongCheng, ZhuYongHu, - ZiYongHu, ZhuanZhi, YouKe, + Device, }, data() { return { - loading: true, - userInfo: { - role: 4, - }, - projectList: [], - gcList: [], - projectType: [ - { - text: '全部类型', - value: 0, - }, - { - text: '监测', - value: 1, - }, - { - text: '用能', - value: 2, - }, - { - text: '环境', - value: 3, - }, - { - text: '安防', - value: 4, - }, - { - text: '其他', - value: 5, - }, - ], + loading: false, + userInfo: {}, } }, - computed: { - content() { - let arr = [1, 3, 4] - let content = [ - { - iconPath: '/static/mine3.png', - text: '运维管理', - }, - { - iconPath: '/static/mine3.png', - text: '专职管理', - }, - { - iconPath: '/static/mine3.png', - text: '工程', - }, - { - iconPath: '/static/mine3.png', - text: '主用户', - }, - { - iconPath: '/static/mine3.png', - text: '子用户', - }, - { - iconPath: '/static/mine3.png', - text: '游客', - }, - ] - return content - }, - }, methods: { send() { uni.createPushMessage({ @@ -127,145 +54,26 @@ export default { }, }) }, - - trigger(e) { - if (e.index === 500) { - uni.navigateTo({ - url: '/pages/device/new', - }) - } else { - this.userInfo.role = e.index + 1 - uni.setStorageSync('userInfo', { - role: e.index + 1, - id: 1, - }) - let roleName = '' - switch (e.index + 1) { - case 1: - roleName = '运维管理' - uni.removeTabBarBadge({ - index: 1, - }) - break - case 2: - roleName = '专职管理' - uni.removeTabBarBadge({ - index: 1, - }) - break - case 3: - roleName = '工程' - uni.removeTabBarBadge({ - index: 1, - }) - break - case 4: - roleName = '主用户' - uni.setTabBarBadge({ - index: 1, - text: '6', - }) - break - case 5: - roleName = '子用户' - uni.setTabBarBadge({ - index: 1, - text: '6', - }) - break - case 6: - roleName = '游客' - uni.setTabBarBadge({ - index: 1, - text: '6', - }) - break - } - this.$util.toast(roleName + '角色切换成功') - } - this.$refs.fab.close() - }, - init() { - this.store = this.DataSource('/EquipmentDelivery/queryEquipmentByProject') - this.store.reload() - this.store.firstCallBack = () => { - this.loading = false - console.log(this.store) - } - }, - getProjectList() { - getProjectList({ - pageNum: 1, - pageSize: 9999, - }).then((res) => { - console.log(res) - let arr = [ - { - text: '全部项目', - value: '-1', - }, - ...res.data.records.map((item) => { - return { - text: item.name, - value: item.id, - ...item, - } - }), - ] - arr.forEach((item) => { - if (this.projectList.findIndex((item2) => item2.value == item.value) === -1) { - this.projectList.push(item) - } - }) - }) - }, - getGcList() { - queryEngineering().then((res) => { - this.gcList = res.data - }) - }, - queryDictData() { - queryDictData('项目类型').then((res) => { - this.projectType = [ - { - text: '全部类型', - value: '', - }, - ...res.data.map((item) => { - return { - text: item.anotherName, - value: item.id, - } - }), - ] - }) + loadingChange(e) { + this.loading = e }, }, onLoad() { - this.init() + this.store = this.DataSource('/cs-device-boot/EquipmentDelivery/queryEquipmentByProject') }, onShow() { this.userInfo = uni.getStorageSync(this.$cacheKey.userInfo) - if (!this.userInfo) { - this.userInfo = { - role: 4, - id: 1, - } - uni.setStorageSync('userInfo', { - role: 4, - id: 1, - }) - } - if (this.userInfo.role == 4 || this.userInfo.role == 5 || this.userInfo.role == 6) { + if ( + this.userInfo.authorities === 'app_vip_user' || + this.userInfo.authorities == 5 || + this.userInfo.authorities === 'tourist' + ) { uni.setTabBarBadge({ index: 1, text: '6', }) } - this.getProjectList() - if (this.userInfo.role == 3) { - this.getGcList() - } + this.$refs.device && this.$refs.device.init() }, } diff --git a/pages/index/message.vue b/pages/index/message.vue index ef31523..3d9dc1d 100644 --- a/pages/index/message.vue +++ b/pages/index/message.vue @@ -6,24 +6,42 @@ 系统 - + 反馈 - + 稳态越限 - + 暂态事件 - + 终端状态 @@ -35,47 +53,47 @@