Showing
23 changed files
with
1901 additions
and
1748 deletions
... | ... | @@ -5,7 +5,8 @@ |
5 | 5 | <view class="alarm-detail-column"> |
6 | 6 | <view class="u-flex detail-column"> |
7 | 7 | <view class="u-flex column"> |
8 | - <text class="text-org-bold">{{ list.deviceName == null ? '暂无数据' : list.deviceName }}</text> | |
8 | + <text | |
9 | + class="text-clip device-name text-org-bold">{{ list.deviceName == null ? '暂无数据' : list.deviceName }}</text> | |
9 | 10 | <image class="image" src="/static/alarm-device.png"></image> |
10 | 11 | </view> |
11 | 12 | <view class="column"> |
... | ... | @@ -98,6 +99,8 @@ |
98 | 99 | import { |
99 | 100 | mapActions |
100 | 101 | } from 'vuex' |
102 | + import api from '@/api/index.js' | |
103 | + | |
101 | 104 | export default { |
102 | 105 | data() { |
103 | 106 | return { |
... | ... | @@ -117,62 +120,48 @@ |
117 | 120 | }, |
118 | 121 | methods: { |
119 | 122 | //处理 |
120 | - handleSubmit() { | |
123 | + async handleSubmit() { | |
121 | 124 | if (this.formModel.result == '') return uni.$u.toast('请输入处理结果'); |
122 | - else | |
123 | - uni.$u.http | |
124 | - .post(`/alarm/${this.list.id}/ack`) | |
125 | - .then(res => { | |
126 | - if (res == '') { | |
127 | - uni.showToast({ | |
128 | - title: '处理成功~', | |
129 | - icon: 'none' | |
130 | - }); | |
131 | - let pages = getCurrentPages(); //获取所有页面栈实例列表 | |
132 | - let nowPage = pages[pages.length - 1]; //当前页页面实例 | |
133 | - let prevPage = pages[pages.length - 2]; //上一页页面实例 | |
134 | - prevPage.$vm.detailStatus = true; | |
135 | - setTimeout(() => { | |
136 | - uni.navigateBack({ | |
137 | - delta: 1 | |
138 | - }); | |
139 | - }, 500); | |
140 | - } | |
141 | - }) | |
142 | - .catch(e => { | |
143 | - uni.$u.toast(e.data?.message); | |
125 | + const res = await api.alarmApi.postAlarmAckApi(this.list.id) | |
126 | + if (res == '') { | |
127 | + uni.showToast({ | |
128 | + title: '处理成功~', | |
129 | + icon: 'none' | |
144 | 130 | }); |
131 | + let pages = getCurrentPages(); //获取所有页面栈实例列表 | |
132 | + let nowPage = pages[pages.length - 1]; //当前页页面实例 | |
133 | + let prevPage = pages[pages.length - 2]; //上一页页面实例 | |
134 | + prevPage.$vm.detailStatus = true; | |
135 | + setTimeout(() => { | |
136 | + uni.navigateBack({ | |
137 | + delta: 1 | |
138 | + }); | |
139 | + }, 500); | |
140 | + } | |
145 | 141 | }, |
146 | 142 | // 清除 |
147 | - handleRemove() { | |
148 | - uni.$u.http | |
149 | - .post(`/alarm/${this.list.id}/clear`) | |
150 | - .then(res => { | |
151 | - if (res == '') { | |
152 | - uni.showToast({ | |
153 | - title: '清除成功~', | |
154 | - icon: 'none' | |
155 | - }); | |
156 | - | |
157 | - let pages = getCurrentPages(); //获取所有页面栈实例列表 | |
158 | - let nowPage = pages[pages.length - 1]; //当前页页面实例 | |
159 | - let prevPage = pages[pages.length - 2]; //上一页页面实例 | |
160 | - prevPage.$vm.detailStatus = true; | |
161 | - setTimeout(async () => { | |
162 | - uni.navigateBack({ | |
163 | - delta: 1 | |
164 | - }); | |
165 | - const res = await uni.$u.http.get('/yt/homepage/app?login=true'); | |
166 | - if (res) { | |
167 | - //异步实时更新告警徽标数 | |
168 | - await this.updateBadgeTotal(res.totalAlarm?.activedAlarm); | |
169 | - } | |
170 | - }, 500); | |
171 | - } | |
172 | - }) | |
173 | - .catch(e => { | |
174 | - uni.$u.toast(e.data?.message); | |
143 | + async handleRemove() { | |
144 | + const res = await api.alarmApi.postAlarmClearApi(this.list.id) | |
145 | + if (res == '') { | |
146 | + uni.showToast({ | |
147 | + title: '清除成功~', | |
148 | + icon: 'none' | |
175 | 149 | }); |
150 | + let pages = getCurrentPages(); //获取所有页面栈实例列表 | |
151 | + let nowPage = pages[pages.length - 1]; //当前页页面实例 | |
152 | + let prevPage = pages[pages.length - 2]; //上一页页面实例 | |
153 | + prevPage.$vm.detailStatus = true; | |
154 | + setTimeout(async () => { | |
155 | + uni.navigateBack({ | |
156 | + delta: 1 | |
157 | + }); | |
158 | + const res = await uni.$u.http.get('/yt/homepage/app?login=true'); | |
159 | + if (res) { | |
160 | + //异步实时更新告警徽标数 | |
161 | + await this.updateBadgeTotal(res.totalAlarm?.activedAlarm); | |
162 | + } | |
163 | + }, 500); | |
164 | + } | |
176 | 165 | }, |
177 | 166 | ...mapActions(['updateBadgeTotal']), |
178 | 167 | formatDetailText(e) { | ... | ... |
api/alarmApi/index.js
0 → 100644
1 | +//获取告警分页API | |
2 | +const getAlarmApi = (params = {}) => { | |
3 | + return uni.$u.http.get("/yt/alarm", params) | |
4 | +}; | |
5 | + | |
6 | +//告警处理API | |
7 | +const postAlarmAckApi = (id) => { | |
8 | + return uni.$u.http | |
9 | + .post(`/alarm/${id}/ack`) | |
10 | +}; | |
11 | + | |
12 | +//告警清除API | |
13 | +const postAlarmClearApi = (id) => { | |
14 | + return uni.$u.http | |
15 | + .post(`/alarm/${id}/clear`) | |
16 | +}; | |
17 | + | |
18 | +export default { | |
19 | + getAlarmApi, | |
20 | + postAlarmAckApi, | |
21 | + postAlarmClearApi | |
22 | +} | ... | ... |
api/deviceApi/index.js
0 → 100644
api/feebbackApi/index.js
0 → 100644
api/homeApi/index.js
0 → 100644
1 | +//获取首页统计数据API | |
2 | +const getHomeStatisticsApi = () => { | |
3 | + return uni.$u.http.get("/yt/homepage/app?login=false") | |
4 | +}; | |
5 | + | |
6 | +//获取视频分页API | |
7 | +const getCameraApi = (params = {}) => { | |
8 | + return uni.$u.http | |
9 | + .get('/yt/video', params) | |
10 | +}; | |
11 | + | |
12 | +//获取视频详情API | |
13 | +const byCameraIdGetDetailApi = (id) => { | |
14 | + return uni.$u.http.get(`/yt/video/url/${id}`) | |
15 | +}; | |
16 | + | |
17 | +//获取组态分页API | |
18 | +const getConfigurationApi = (params = {}) => { | |
19 | + return uni.$u.http | |
20 | + .get('/yt/configuration/center', params) | |
21 | +} | |
22 | + | |
23 | +export default { | |
24 | + getHomeStatisticsApi, | |
25 | + getCameraApi, | |
26 | + byCameraIdGetDetailApi, | |
27 | + getConfigurationApi | |
28 | +} | ... | ... |
api/index.js
0 → 100644
1 | +/** | |
2 | + * 统一管理API | |
3 | + * 按模块划分API | |
4 | + */ | |
5 | + | |
6 | +//登录 | |
7 | +import loginApi from './loginApi/index.js' | |
8 | + | |
9 | +//意见反馈 | |
10 | +import feedbackApi from './feebbackApi/index.js' | |
11 | + | |
12 | +//通知 | |
13 | +import notifyApi from './notifyApi/index.js' | |
14 | + | |
15 | +//首页 | |
16 | +import homeApi from './homeApi/index.js' | |
17 | + | |
18 | +//告警 | |
19 | +import alarmApi from './alarmApi/index.js' | |
20 | + | |
21 | +//设备 | |
22 | +import deviceApi from './deviceApi/index.js' | |
23 | + | |
24 | +export default { | |
25 | + loginApi, | |
26 | + feedbackApi, | |
27 | + notifyApi, | |
28 | + homeApi, | |
29 | + alarmApi, | |
30 | + deviceApi | |
31 | +} | ... | ... |
api/loginApi/index.js
0 → 100644
1 | +//获取平台定制API | |
2 | +const getPlateCustomApi = () => { | |
3 | + return uni.$u.http.get("/yt/app_design/get") | |
4 | +}; | |
5 | + | |
6 | +//第三方账号绑定API | |
7 | +const getThirdLoginApi = (code) => { | |
8 | + return uni.$u.http.get(`/yt/third/login/${code}`) | |
9 | +}; | |
10 | + | |
11 | +//获取个人信息API | |
12 | +const setUserInfoApi = () => { | |
13 | + return uni.$u.http.get("/yt/user/me/info") | |
14 | +}; | |
15 | + | |
16 | +//获取平台信息API | |
17 | +const setPlateInfoApi = () => { | |
18 | + return uni.$u.http.get("/yt/platform/get") | |
19 | +}; | |
20 | + | |
21 | +//获取告警徽标数API | |
22 | +const getAlarmTotalApi = () => { | |
23 | + return uni.$u.http.get("/yt/homepage/app?login=true") | |
24 | +}; | |
25 | + | |
26 | +//登录API | |
27 | +const postLoginApi = (loginForm = {}) => { | |
28 | + return uni.$u.http | |
29 | + .post("/auth/login", loginForm) | |
30 | +}; | |
31 | + | |
32 | +//获取验证码API | |
33 | +const postCodeApi = (phone) => { | |
34 | + return uni.$u.http | |
35 | + .post(`/yt/noauth/reset_code/${phone}`) | |
36 | +} | |
37 | + | |
38 | +//重置密码API | |
39 | +const postResetCodeApi = (phone, data = {}) => { | |
40 | + return uni.$u.http | |
41 | + .post(`/yt/noauth/reset/${phone}`, data) | |
42 | +} | |
43 | + | |
44 | +//更新个人资料API | |
45 | +const postPersonalInfoApi = (data = {}) => { | |
46 | + return uni.$u.http | |
47 | + .put('/yt/user/center', data) | |
48 | +} | |
49 | + | |
50 | +//第三方登录需要解绑API | |
51 | +const deleteBindApi = (data = {}) => { | |
52 | + return uni.$u.http.delete('/yt/third', data) | |
53 | +} | |
54 | + | |
55 | +export default { | |
56 | + getPlateCustomApi, | |
57 | + getThirdLoginApi, | |
58 | + setUserInfoApi, | |
59 | + setPlateInfoApi, | |
60 | + getAlarmTotalApi, | |
61 | + postLoginApi, | |
62 | + postCodeApi, | |
63 | + postResetCodeApi, | |
64 | + postPersonalInfoApi, | |
65 | + deleteBindApi | |
66 | +} | ... | ... |
api/notifyApi/index.js
0 → 100644
1 | +//获取通知分页API | |
2 | +const getNotifyApi = (params = {}) => { | |
3 | + return uni.$u.http.get("/yt/notice_user/page", params) | |
4 | +}; | |
5 | + | |
6 | +//获取通知详情API | |
7 | +const byNotifyIdGetDetailApi = (id) => { | |
8 | + return uni.$u.http | |
9 | + .get(`/yt/notice_user/${id}`) | |
10 | +} | |
11 | + | |
12 | +export default { | |
13 | + getNotifyApi, | |
14 | + byNotifyIdGetDetailApi | |
15 | +} | ... | ... |
... | ... | @@ -6,15 +6,17 @@ |
6 | 6 | <view class="form-page"> |
7 | 7 | <u--form labelPosition="left" :model="feedbackData" :rules="rules" ref="myfeedBackFormRef"> |
8 | 8 | <u-form-item required label="主题" prop="feedbackInfo.title" borderBottom ref="item1"> |
9 | - <u--input placeholder="请输入主题" v-model="feedbackData.feedbackInfo.title" border="none"></u--input> | |
9 | + <u--input placeholder="请输入主题" v-model="feedbackData.feedbackInfo.title" border="none"> | |
10 | + </u--input> | |
10 | 11 | </u-form-item> |
11 | 12 | <u-form-item required label="姓名" prop="feedbackInfo.name" borderBottom ref="item1"> |
12 | 13 | <u--input placeholder="请输入姓名" v-model="feedbackData.feedbackInfo.name" border="none"></u--input> |
13 | 14 | </u-form-item> |
14 | 15 | <view class="info"> |
15 | 16 | <view class="info-contain"> |
16 | - <u-form-item required label="反馈" prop="feedbackInfo.message" borderBottom ref="item1"> | |
17 | - <u--textarea placeholder="请输入反馈信息" v-model="feedbackData.feedbackInfo.message" count></u--textarea> | |
17 | + <u-form-item required label="反馈" prop="feedbackInfo.message" borderBottom ref="item1"> | |
18 | + <u--textarea placeholder="请输入反馈信息" v-model="feedbackData.feedbackInfo.message" count> | |
19 | + </u--textarea> | |
18 | 20 | </u-form-item> |
19 | 21 | </view> |
20 | 22 | </view> |
... | ... | @@ -22,244 +24,251 @@ |
22 | 24 | <view class="info" style="margin-top: 15rpx;background: rgba(1, 1, 1, 0);"> |
23 | 25 | <view class="info-contain"> |
24 | 26 | <u-form-item label="图片" prop="feedbackInfo.images" borderBottom ref="item1"> |
25 | - <u-upload :sizeType="compressed" :fileList="fileList1" | |
26 | - @afterRead="afterRead" @delete="deletePic" name="1" multiple :maxCount="6"></u-upload> | |
27 | + <u-upload :sizeType="compressed" :fileList="fileList1" @afterRead="afterRead" | |
28 | + @delete="deletePic" name="1" multiple :maxCount="6"></u-upload> | |
27 | 29 | </u-form-item> |
28 | 30 | </view> |
29 | 31 | </view> |
30 | 32 | </u--form> |
31 | 33 | <view style="width:427rpx;margin:0 auto;"> |
32 | - <u-button class="buttonSty button-sty" shape="circle" type="primary" text="提交" customStyle="margin-top: 129rpx" @click="submit"></u-button> | |
33 | - </view> | |
34 | + <u-button class="buttonSty button-sty" shape="circle" type="primary" text="提交" | |
35 | + customStyle="margin-top: 129rpx" @click="submit"></u-button> | |
34 | 36 | </view> |
35 | - <!-- #ifdef MP --> | |
36 | - <view style="height: 18rpx;"></view> | |
37 | - <!-- #endif --> | |
38 | - <!-- #ifndef MP --> | |
39 | - <view style="height: 52rpx;"></view> | |
40 | - <!-- #endif --> | |
41 | 37 | </view> |
42 | - <view style="height: 20rpx;"></view> | |
38 | + <!-- #ifdef MP --> | |
39 | + <view style="height: 18rpx;"></view> | |
40 | + <!-- #endif --> | |
41 | + <!-- #ifndef MP --> | |
42 | + <view style="height: 52rpx;"></view> | |
43 | + <!-- #endif --> | |
43 | 44 | </view> |
45 | + <view style="height: 20rpx;"></view> | |
46 | + </view> | |
44 | 47 | </view> |
45 | 48 | </template> |
46 | 49 | |
47 | 50 | <script> |
48 | -import baseUrl from '@/config/baseUrl.js'; | |
49 | -import { mapState } from 'vuex'; | |
51 | + import baseUrl from '@/config/baseUrl.js'; | |
52 | + import { | |
53 | + mapState | |
54 | + } from 'vuex'; | |
55 | + import api from '@/api/index.js' | |
50 | 56 | |
51 | -export default { | |
52 | - data() { | |
53 | - return { | |
54 | - feedbackData: { | |
55 | - feedbackInfo: { | |
56 | - title: '', | |
57 | - name: '', | |
58 | - images: [], | |
59 | - message: '' | |
60 | - } | |
61 | - }, | |
62 | - fileList1: [], | |
63 | - rules: { | |
64 | - 'feedbackInfo.title': { | |
65 | - type: 'string', | |
66 | - required: true, | |
67 | - message: '请输入主题', | |
68 | - trigger: ['blur', 'change'] | |
69 | - }, | |
70 | - 'feedbackInfo.name': { | |
71 | - type: 'string', | |
72 | - required: true, | |
73 | - message: '请输入姓名', | |
74 | - trigger: ['blur', 'change'] | |
75 | - }, | |
76 | - 'feedbackInfo.message': { | |
77 | - type: 'string', | |
78 | - required: true, | |
79 | - message: '请输入意见反馈', | |
80 | - trigger: ['blur', 'change'] | |
81 | - }, | |
82 | - | |
57 | + export default { | |
58 | + data() { | |
59 | + return { | |
60 | + feedbackData: { | |
61 | + feedbackInfo: { | |
62 | + title: '', | |
63 | + name: '', | |
64 | + images: [], | |
65 | + message: '' | |
66 | + } | |
67 | + }, | |
68 | + fileList1: [], | |
69 | + rules: { | |
70 | + 'feedbackInfo.title': { | |
71 | + type: 'string', | |
72 | + required: true, | |
73 | + message: '请输入主题', | |
74 | + trigger: ['blur', 'change'] | |
75 | + }, | |
76 | + 'feedbackInfo.name': { | |
77 | + type: 'string', | |
78 | + required: true, | |
79 | + message: '请输入姓名', | |
80 | + trigger: ['blur', 'change'] | |
81 | + }, | |
82 | + 'feedbackInfo.message': { | |
83 | + type: 'string', | |
84 | + required: true, | |
85 | + message: '请输入意见反馈', | |
86 | + trigger: ['blur', 'change'] | |
87 | + }, | |
88 | + | |
89 | + }, | |
90 | + }; | |
83 | 91 | }, |
84 | - }; | |
85 | - }, | |
86 | - onReady() { | |
87 | - // 如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则 | |
88 | - this.$refs.myfeedBackFormRef.setRules(this.rules); | |
89 | - }, | |
90 | - onLoad() { | |
91 | - // 隐藏原生的tabbar | |
92 | - uni.hideTabBar(); | |
93 | - }, | |
94 | - computed: { | |
95 | - ...mapState(['userInfo']) | |
96 | - }, | |
97 | - methods: { | |
98 | - // 删除图片 | |
99 | - deletePic(event) { | |
100 | - this[`fileList${event.name}`].splice(event.index, 1); | |
92 | + onReady() { | |
93 | + // 如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则 | |
94 | + this.$refs.myfeedBackFormRef.setRules(this.rules); | |
101 | 95 | }, |
102 | - // 新增图片 | |
103 | - async afterRead(event) { | |
104 | - let lists = [].concat(event.file); | |
105 | - let fileListLen = this[`fileList${event.name}`].length; | |
106 | - lists.map(item => { | |
107 | - if(item.size>5242880){ | |
108 | - this[`fileList${event.name}`].push({ | |
109 | - ...item, | |
110 | - status: 'error', | |
111 | - message: '上传失败' | |
112 | - }); | |
113 | - }else{ | |
114 | - this[`fileList${event.name}`].push({ | |
115 | - ...item, | |
116 | - status: 'uploading', | |
117 | - message: '上传中' | |
118 | - }); | |
119 | - } | |
120 | - }); | |
121 | - for (let i = 0; i < lists.length; i++) { | |
122 | - const judgeImageSize=lists[0].size | |
123 | - if(judgeImageSize>5242880){ | |
124 | - return uni.$u.toast('图片限定5M') | |
125 | - }else{ | |
126 | - const result = await this.uploadFilePromise(lists[i].url); | |
127 | - let item = this[`fileList${event.name}`][fileListLen]; | |
128 | - this[`fileList${event.name}`].splice( | |
129 | - fileListLen, | |
130 | - 1, | |
131 | - Object.assign(item, { | |
132 | - status: 'success', | |
133 | - message: '', | |
134 | - url: result | |
135 | - }) | |
136 | - ); | |
137 | - fileListLen++; | |
138 | - } | |
139 | - } | |
96 | + onLoad() { | |
97 | + // 隐藏原生的tabbar | |
98 | + uni.hideTabBar(); | |
140 | 99 | }, |
141 | - uploadFilePromise(url) { | |
142 | - let token; | |
143 | - token = this.userInfo.isToken || uni.getStorageSync('userInfo').isToken || undefined; | |
144 | - // #ifdef H5 | |
145 | - token = window.sessionStorage.getItem('userInfo').isToken; | |
146 | - // #endif | |
147 | - if (!token) return uni.$u.toast('请登录后上传图片'); | |
148 | - return new Promise((resolve, reject) => { | |
149 | - let a = uni.uploadFile({ | |
150 | - url: `${baseUrl.baseUrl}/yt/oss/upload`, | |
151 | - filePath: url, | |
152 | - name: 'file', | |
153 | - header: { | |
154 | - 'content-type': 'multipart/form-data', | |
155 | - Authorization: 'Bearer ' + token | |
156 | - }, | |
157 | - formData: {}, | |
158 | - success: res => { | |
159 | - setTimeout(() => { | |
160 | - if(res.statusCode===200){ | |
161 | - if(res.data){ | |
162 | - let objImage = JSON.parse(res.data); | |
163 | - if (this.feedbackData.feedbackInfo.images.length < 6) { | |
164 | - this.feedbackData.feedbackInfo.images.push(objImage.fileStaticUri); | |
165 | - } | |
166 | - resolve(res.data?.fileStaticUri); | |
167 | - } | |
168 | - }else{ | |
169 | - return uni.$u.toast('图片上传失败') | |
170 | - } | |
171 | - }, 1000); | |
100 | + computed: { | |
101 | + ...mapState(['userInfo']) | |
102 | + }, | |
103 | + methods: { | |
104 | + // 删除图片 | |
105 | + deletePic(event) { | |
106 | + this[`fileList${event.name}`].splice(event.index, 1); | |
107 | + }, | |
108 | + // 新增图片 | |
109 | + async afterRead(event) { | |
110 | + let lists = [].concat(event.file); | |
111 | + let fileListLen = this[`fileList${event.name}`].length; | |
112 | + lists.map(item => { | |
113 | + if (item.size > 5242880) { | |
114 | + this[`fileList${event.name}`].push({ | |
115 | + ...item, | |
116 | + status: 'error', | |
117 | + message: '上传失败' | |
118 | + }); | |
119 | + } else { | |
120 | + this[`fileList${event.name}`].push({ | |
121 | + ...item, | |
122 | + status: 'uploading', | |
123 | + message: '上传中' | |
124 | + }); | |
172 | 125 | } |
173 | 126 | }); |
174 | - }); | |
175 | - }, | |
176 | - submit() { | |
177 | - this.$refs.myfeedBackFormRef | |
178 | - .validate() | |
179 | - .then(res => { | |
180 | - if(res){ | |
181 | - let httpData = { | |
182 | - title: this.feedbackData.feedbackInfo.title, | |
183 | - name: this.feedbackData.feedbackInfo.name, | |
184 | - images: this.feedbackData.feedbackInfo.images.length == 0 ? '' : JSON.stringify(this.feedbackData.feedbackInfo.images), | |
185 | - message: this.feedbackData.feedbackInfo.message | |
186 | - }; | |
187 | - uni.$u.http | |
188 | - .post('/yt/opinion', httpData) | |
189 | - .then(res => { | |
190 | - if (res) { | |
191 | - uni.showToast({ | |
192 | - title: '意见反馈提交成功~', | |
193 | - icon: 'none' | |
194 | - }); | |
195 | - setTimeout(() => { | |
196 | - uni.navigateBack(); | |
197 | - }, 500); | |
198 | - } | |
127 | + for (let i = 0; i < lists.length; i++) { | |
128 | + const judgeImageSize = lists[0].size | |
129 | + if (judgeImageSize > 5242880) { | |
130 | + return uni.$u.toast('图片限定5M') | |
131 | + } else { | |
132 | + const result = await this.uploadFilePromise(lists[i].url); | |
133 | + let item = this[`fileList${event.name}`][fileListLen]; | |
134 | + this[`fileList${event.name}`].splice( | |
135 | + fileListLen, | |
136 | + 1, | |
137 | + Object.assign(item, { | |
138 | + status: 'success', | |
139 | + message: '', | |
140 | + url: result | |
199 | 141 | }) |
200 | - .catch(e => { | |
201 | - uni.$u.toast(e.data?.message); | |
202 | - }); | |
142 | + ); | |
143 | + fileListLen++; | |
203 | 144 | } |
204 | - }) | |
205 | - .catch(errors => { | |
206 | - uni.$u.toast('请填写或者请填写正确格式的数据'); | |
145 | + } | |
146 | + }, | |
147 | + uploadFilePromise(url) { | |
148 | + let token; | |
149 | + token = this.userInfo.isToken || uni.getStorageSync('userInfo').isToken || undefined; | |
150 | + // #ifdef H5 | |
151 | + token = window.sessionStorage.getItem('userInfo').isToken; | |
152 | + // #endif | |
153 | + if (!token) return uni.$u.toast('请登录后上传图片'); | |
154 | + return new Promise((resolve, reject) => { | |
155 | + let a = uni.uploadFile({ | |
156 | + url: `${baseUrl.baseUrl}/yt/oss/upload`, | |
157 | + filePath: url, | |
158 | + name: 'file', | |
159 | + header: { | |
160 | + 'content-type': 'multipart/form-data', | |
161 | + Authorization: 'Bearer ' + token | |
162 | + }, | |
163 | + formData: {}, | |
164 | + success: res => { | |
165 | + setTimeout(() => { | |
166 | + if (res.statusCode === 200) { | |
167 | + if (res.data) { | |
168 | + let objImage = JSON.parse(res.data); | |
169 | + if (this.feedbackData.feedbackInfo.images.length < 6) { | |
170 | + this.feedbackData.feedbackInfo.images.push(objImage | |
171 | + .fileStaticUri); | |
172 | + } | |
173 | + resolve(res.data?.fileStaticUri); | |
174 | + } | |
175 | + } else { | |
176 | + return uni.$u.toast('图片上传失败') | |
177 | + } | |
178 | + }, 1000); | |
179 | + } | |
180 | + }); | |
207 | 181 | }); |
182 | + }, | |
183 | + submit() { | |
184 | + this.$refs.myfeedBackFormRef | |
185 | + .validate() | |
186 | + .then(async res => { | |
187 | + if (res) { | |
188 | + let httpData = { | |
189 | + title: this.feedbackData.feedbackInfo.title, | |
190 | + name: this.feedbackData.feedbackInfo.name, | |
191 | + images: this.feedbackData.feedbackInfo.images.length == 0 ? '' : JSON | |
192 | + .stringify( | |
193 | + this.feedbackData.feedbackInfo.images), | |
194 | + message: this.feedbackData.feedbackInfo.message | |
195 | + }; | |
196 | + const res = await api.feedbackApi.postFeedBackApi(httpData) | |
197 | + uni.showToast({ | |
198 | + title: '意见反馈提交成功~', | |
199 | + icon: 'none' | |
200 | + }); | |
201 | + setTimeout(() => { | |
202 | + uni.navigateBack(); | |
203 | + }, 500); | |
204 | + } | |
205 | + }) | |
206 | + .catch(errors => { | |
207 | + uni.$u.toast('请填写或者请填写正确格式的数据'); | |
208 | + }); | |
209 | + } | |
208 | 210 | } |
209 | - } | |
210 | -}; | |
211 | + }; | |
211 | 212 | </script> |
212 | 213 | |
213 | 214 | <style lang="scss" scoped> |
214 | -.feedback-page { | |
215 | - min-height: 100vh; | |
216 | - background-color: #f8f9fa; | |
217 | - padding-top: 9rpx; | |
218 | - padding-left: 27rpx; | |
219 | - overflow-y: scroll; | |
220 | - overflow: hidden; | |
221 | -} | |
222 | -.form-page { | |
223 | - width: 700rpx; | |
224 | - background-color: #ffffff; | |
225 | - border-radius: 10px; | |
226 | - margin-top: 20rpx; | |
227 | - padding-left: 15rpx; | |
228 | - padding: 0 20rpx; | |
229 | - height: 500rpx; | |
230 | - .info { | |
215 | + .feedback-page { | |
216 | + min-height: 100vh; | |
217 | + background-color: #f8f9fa; | |
218 | + padding-top: 9rpx; | |
219 | + padding-left: 27rpx; | |
220 | + overflow-y: scroll; | |
221 | + overflow: hidden; | |
222 | + } | |
223 | + | |
224 | + .form-page { | |
231 | 225 | width: 700rpx; |
232 | 226 | background-color: #ffffff; |
233 | 227 | border-radius: 10px; |
234 | - margin-top: 100rpx; | |
235 | - height: 256rpx; | |
236 | - margin-left: -20rpx; | |
237 | - .info-contain { | |
238 | - margin: 0rpx 27rpx; | |
239 | - /deep/ .u-line { | |
240 | - display: none !important; | |
241 | - } | |
242 | - /deep/ .u-form-item__body__left__content__label { | |
243 | - display: none !important; | |
244 | - } | |
245 | - /deep/.u-form-item__body__right { | |
246 | - margin-left: -106rpx; | |
247 | - } | |
248 | - /deep/.u-textarea--radius { | |
249 | - border: none !important; | |
228 | + margin-top: 20rpx; | |
229 | + padding-left: 15rpx; | |
230 | + padding: 0 20rpx; | |
231 | + height: 500rpx; | |
232 | + | |
233 | + .info { | |
234 | + width: 700rpx; | |
235 | + background-color: #ffffff; | |
236 | + border-radius: 10px; | |
237 | + margin-top: 100rpx; | |
238 | + height: 256rpx; | |
239 | + margin-left: -20rpx; | |
240 | + | |
241 | + .info-contain { | |
242 | + margin: 0rpx 27rpx; | |
243 | + | |
244 | + /deep/ .u-line { | |
245 | + display: none !important; | |
246 | + } | |
247 | + | |
248 | + /deep/ .u-form-item__body__left__content__label { | |
249 | + display: none !important; | |
250 | + } | |
251 | + | |
252 | + /deep/.u-form-item__body__right { | |
253 | + margin-left: -106rpx; | |
254 | + } | |
255 | + | |
256 | + /deep/.u-textarea--radius { | |
257 | + border: none !important; | |
258 | + } | |
250 | 259 | } |
251 | 260 | } |
261 | + | |
262 | + /deep/.u-button--primary { | |
263 | + background-color: #377DFF !important; | |
264 | + border-color: #377DFF !important; | |
265 | + } | |
252 | 266 | } |
253 | - /deep/.u-button--primary{ | |
254 | - background-color: #377DFF!important; | |
255 | - border-color: #377DFF!important; | |
256 | - } | |
257 | -} | |
258 | -//#ifndef MP | |
259 | -.buttonSty { | |
260 | - margin-top: 30rpx !important; | |
261 | -} | |
262 | -//#endif | |
263 | 267 | |
268 | + //#ifndef MP | |
269 | + .buttonSty { | |
270 | + margin-top: 30rpx !important; | |
271 | + } | |
264 | 272 | |
273 | + //#endif | |
265 | 274 | </style> | ... | ... |
... | ... | @@ -7,7 +7,10 @@ |
7 | 7 | <view class="device-top"> |
8 | 8 | <view class="search"> |
9 | 9 | <view> |
10 | - <view class="search-left"><u--input prefixIcon="search" placeholder="请输入告警名字" shape="circle" @change="inputChanged"></u--input></view> | |
10 | + <view class="search-left"> | |
11 | + <u--input prefixIcon="search" placeholder="请输入告警名字" shape="circle" @change="inputChanged"> | |
12 | + </u--input> | |
13 | + </view> | |
11 | 14 | </view> |
12 | 15 | <view @click="openSearchDialog" class="search-right"> |
13 | 16 | <text>筛选</text> |
... | ... | @@ -30,7 +33,8 @@ |
30 | 33 | </u-sticky> |
31 | 34 | <!-- 吸顶组件 --> |
32 | 35 | <!-- 自带分页组件 --> |
33 | - <mescroll-body ref="mescrollRef" :up="upOption" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback"> | |
36 | + <mescroll-body ref="mescrollRef" :up="upOption" @init="mescrollInit" :down="downOption" @down="downCallback" | |
37 | + @up="upCallback"> | |
34 | 38 | <view class="device-list"> |
35 | 39 | <view @click="openAlertDetail(item)" class="list-item" v-for="(item, index) in list" :key="index"> |
36 | 40 | <view class="u-flex item"> |
... | ... | @@ -38,7 +42,8 @@ |
38 | 42 | <text class="text-bold">{{ item.deviceName == null ? '暂无数据' : item.deviceName }}</text> |
39 | 43 | </view> |
40 | 44 | <view class="item-text text-clip"> |
41 | - <text class="text-muted">{{ item.details == null ? '暂无数据' : formatDetailText(item.details.data) }}</text> | |
45 | + <text | |
46 | + class="text-muted">{{ item.details == null ? '暂无数据' : formatDetailText(item.details.data) }}</text> | |
42 | 47 | </view> |
43 | 48 | <view class="item-text"> |
44 | 49 | <text class="text-muted"> |
... | ... | @@ -61,9 +66,7 @@ |
61 | 66 | <view class="u-flex item-right"> |
62 | 67 | <image class="right-image" :src="bindImageUrl(item.severity)"></image> |
63 | 68 | <view class="right-text"> |
64 | - <text | |
65 | - class="text-no-color" | |
66 | - :style="[ | |
69 | + <text class="text-no-color" :style="[ | |
67 | 70 | item.severity == 'CRITICAL' |
68 | 71 | ? { color: '#DE4437' } |
69 | 72 | : item.severity == 'MAJOR' |
... | ... | @@ -73,8 +76,7 @@ |
73 | 76 | : item.severity == 'WARNING' |
74 | 77 | ? { color: '#DE4437' } |
75 | 78 | : { color: '#00C9A7' } |
76 | - ]" | |
77 | - > | |
79 | + ]"> | |
78 | 80 | {{ |
79 | 81 | item.severity == 'CRITICAL' |
80 | 82 | ? '危险' |
... | ... | @@ -104,76 +106,67 @@ |
104 | 106 | <view> |
105 | 107 | <view class="popup-alarm-text"><text class="text">告警状态</text></view> |
106 | 108 | <view class="u-flex popup-alarm-child"> |
107 | - <view | |
108 | - class="alarm-text" | |
109 | - @click="getAlertStatus(item, index)" | |
109 | + <view class="alarm-text" @click="getAlertStatus(item, index)" | |
110 | 110 | :style="[index == current1 ? { background: 'rgba(55, 125, 255, 0.05)', border: '1rpx solid rgba(55, 125, 255, 0.3)' } : { background: '#F6F6F6' }]" |
111 | - v-for="(item, index) in alertStatus" | |
112 | - :key="index" | |
113 | - > | |
114 | - <text :class="[index == current1 ? 'select-text' : 'un-select-text']" class="text">{{ item.name }}</text> | |
111 | + v-for="(item, index) in alertStatus" :key="index"> | |
112 | + <text :class="[index == current1 ? 'select-text' : 'un-select-text']" | |
113 | + class="text">{{ item.name }}</text> | |
115 | 114 | </view> |
116 | 115 | </view> |
117 | 116 | <view style="margin-top: 169rpx;"> |
118 | 117 | <view class="popup-alarm-text"><text class="text">设备类型</text></view> |
119 | 118 | <view class="u-flex popup-alarm-child"> |
120 | - <view | |
121 | - class="alarm-text" | |
122 | - @click="getTypeStatus(item, index)" | |
123 | - :style="[ | |
119 | + <view class="alarm-text" @click="getTypeStatus(item, index)" :style="[ | |
124 | 120 | index == current2 ? { background: 'rgba(55, 125, 255, 0.05)', border: '1rpx solid rgba(55, 125, 255, 0.3)' } : { background: '#F6F6F6' } |
125 | - ]" | |
126 | - v-for="(item, index) in deviceType" | |
127 | - :key="index" | |
128 | - > | |
129 | - <text :class="[index == current2 ? 'select-text' : 'un-select-text']" class="text">{{ item.name }}</text> | |
121 | + ]" v-for="(item, index) in deviceType" :key="index"> | |
122 | + <text :class="[index == current2 ? 'select-text' : 'un-select-text']" | |
123 | + class="text">{{ item.name }}</text> | |
130 | 124 | </view> |
131 | 125 | </view> |
132 | 126 | |
133 | 127 | <view style="margin-top: 169rpx;"> |
134 | 128 | <view class="popup-alarm-text"><text class="text">告警等级</text></view> |
135 | 129 | <view class="u-flex popup-alarm-child"> |
136 | - <view | |
137 | - class="alarm-text" | |
138 | - @click="getLevelStatus(item, index)" | |
139 | - :style="[ | |
130 | + <view class="alarm-text" @click="getLevelStatus(item, index)" :style="[ | |
140 | 131 | index == current3 ? { background: 'rgba(55, 125, 255, 0.05)', border: '1rpx solid rgba(55, 125, 255, 0.3)' } : { background: '#F6F6F6' } |
141 | - ]" | |
142 | - v-for="(item, index) in alertLevel" | |
143 | - :key="index" | |
144 | - > | |
145 | - <text :class="[index == current3 ? 'select-text' : 'un-select-text']" class="text">{{ item.name }}</text> | |
132 | + ]" v-for="(item, index) in alertLevel" :key="index"> | |
133 | + <text :class="[index == current3 ? 'select-text' : 'un-select-text']" | |
134 | + class="text">{{ item.name }}</text> | |
146 | 135 | </view> |
147 | 136 | </view> |
148 | 137 | <view style="margin-top: 169rpx;"> |
149 | 138 | <view class="popup-alarm-text"><text class="text">选择时间</text></view> |
150 | 139 | <view class="u-flex popup-alarm-child"> |
151 | - <view | |
152 | - class="alarm-text" | |
153 | - @click="getTimeStatus(item, index)" | |
154 | - :style="[ | |
140 | + <view class="alarm-text" @click="getTimeStatus(item, index)" :style="[ | |
155 | 141 | index == current4 |
156 | 142 | ? { background: 'rgba(55, 125, 255, 0.05)', border: '1rpx solid rgba(55, 125, 255, 0.3)' } |
157 | 143 | : { background: '#F6F6F6' } |
158 | - ]" | |
159 | - v-for="(item, index) in timeArea" | |
160 | - :key="index" | |
161 | - > | |
162 | - <text :class="[index == current4 ? 'select-text' : 'un-select-text']" class="text">{{ item.name }}</text> | |
144 | + ]" v-for="(item, index) in timeArea" :key="index"> | |
145 | + <text :class="[index == current4 ? 'select-text' : 'un-select-text']" | |
146 | + class="text">{{ item.name }}</text> | |
163 | 147 | </view> |
164 | 148 | </view> |
165 | 149 | <view style="margin-top: 169rpx;margin-left: 22rpx;"> |
166 | 150 | <view class="u-flex popup-alarm-child"> |
167 | 151 | <view class="home-text-muted">选择日期</view> |
168 | - <view style="width: 623rpx;margin-left: 5rpx;margin-right: 70rpx;margin-top: 35rpx;"> | |
169 | - <uni-datetime-picker v-model="range" type="datetimerange" rangeSeparator="至" /> | |
152 | + <view | |
153 | + style="width: 623rpx;margin-left: 5rpx;margin-right: 70rpx;margin-top: 35rpx;"> | |
154 | + <uni-datetime-picker v-model="range" type="datetimerange" | |
155 | + rangeSeparator="至" /> | |
170 | 156 | </view> |
171 | 157 | </view> |
172 | 158 | </view> |
173 | 159 | <view style="height: 130rpx;"></view> |
174 | - <view class="u-flex" style="position: fixed;bottom: 10rpx;z-index: 9999;flex-direction: row; margin-top: 128rpx; margin-left: 10rpx"> | |
175 | - <view style="width: 300rpx"><u-button @click="resetData" type="info" shape="circle" text="重置"></u-button></view> | |
176 | - <view style="width: 300rpx; margin-left: 46rpx"><u-button @click="queryData" type="primary" shape="circle" text="确认"></u-button></view> | |
160 | + <view class="u-flex" | |
161 | + style="position: fixed;bottom: 10rpx;z-index: 9999;flex-direction: row; margin-top: 128rpx; margin-left: 10rpx"> | |
162 | + <view style="width: 300rpx"> | |
163 | + <u-button @click="resetData" type="info" shape="circle" text="重置"> | |
164 | + </u-button> | |
165 | + </view> | |
166 | + <view style="width: 300rpx; margin-left: 46rpx"> | |
167 | + <u-button @click="queryData" type="primary" shape="circle" text="确认"> | |
168 | + </u-button> | |
169 | + </view> | |
177 | 170 | </view> |
178 | 171 | <view style="height: 90rpx;"></view> |
179 | 172 | </view> |
... | ... | @@ -188,264 +181,274 @@ |
188 | 181 | </template> |
189 | 182 | |
190 | 183 | <script> |
191 | -import fTabbar from '@/components/module/f-tabbar/f-tabbar'; | |
192 | -import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js'; | |
193 | -import { alertStatus, deviceType, alertLevel, timeArea } from './static/data.js'; | |
184 | + import fTabbar from '@/components/module/f-tabbar/f-tabbar'; | |
185 | + import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js'; | |
186 | + import { | |
187 | + alertStatus, | |
188 | + deviceType, | |
189 | + alertLevel, | |
190 | + timeArea | |
191 | + } from './static/data.js'; | |
192 | + import api from '@/api/index.js' | |
194 | 193 | |
195 | -export default { | |
196 | - mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件) | |
197 | - components: { | |
198 | - fTabbar | |
199 | - }, | |
200 | - data() { | |
201 | - return { | |
202 | - range: [], | |
203 | - alertStatusVal: '', | |
204 | - deviceTypeVal: '', | |
205 | - alertLevelVal: '', | |
206 | - selectTimeVal: '', | |
207 | - current1: 0, | |
208 | - current2: 0, | |
209 | - current3: 0, | |
210 | - current4: 0, | |
211 | - page: { | |
212 | - num: 0, | |
213 | - size: 10 | |
214 | - }, | |
215 | - downOption: { | |
216 | - auto: false //是否在初始化后,自动执行downCallback; 默认true | |
217 | - }, | |
218 | - upOption: { | |
219 | - auto: false // 不自动加载 | |
220 | - }, | |
221 | - timeData: { | |
222 | - selectTime: [], | |
223 | - getTimeGapS: '', | |
224 | - getTimeGapE: '' | |
225 | - }, | |
226 | - show: false, | |
227 | - list: [], | |
228 | - alertStatus, | |
229 | - deviceType, | |
230 | - alertLevel, | |
231 | - timeArea, | |
232 | - ordId: '', | |
233 | - detailStatus: false, | |
234 | - alertTotal: 0, | |
235 | - searchAlarmText: '', | |
236 | - startTimeVa: '', | |
237 | - endTimeVa: '', | |
238 | - startTimeArea: '', | |
239 | - endTimeArea: '', | |
240 | - type: null | |
241 | - }; | |
242 | - }, | |
243 | - onShow() { | |
244 | - this.page.num = 1; | |
245 | - if (this.detailStatus) { | |
246 | - this.loadData(1, null, null, null, null, null, null); | |
247 | - } | |
248 | - if (this.ordId) { | |
249 | - this.loadData(1, null, null, null, null, null, this.ordId); | |
250 | - } | |
251 | - }, | |
252 | - onHide() { | |
253 | - this.ordId = ''; | |
254 | - this.detailStatus = false; | |
255 | - this.type = null; | |
256 | - }, | |
257 | - onLoad(e) { | |
258 | - // 隐藏原生的tabbar | |
259 | - uni.hideTabBar(); | |
260 | - if (e.type == undefined) { | |
261 | - this.loadData(1, null, null, null, null, null, null); | |
262 | - } else { | |
263 | - let params = JSON.parse(e.type); | |
264 | - if (Array.isArray(params)) { | |
265 | - this.type = params.join(','); | |
266 | - } else { | |
267 | - this.type = params; | |
268 | - } | |
269 | - this.loadData(1, this.type, null, null, null, null, null); | |
270 | - } | |
271 | - }, | |
272 | - watch: { | |
273 | - range(newval) { | |
274 | - this.timeData.selectTime = this.range; | |
275 | - } | |
276 | - }, | |
277 | - methods: { | |
278 | - moveHandle() { | |
279 | - return false; | |
280 | - }, | |
281 | - inputChanged(e) { | |
282 | - this.resetData(); | |
283 | - this.topBack(); | |
284 | - this.searchAlarmText = e; | |
285 | - this.page.num = 1; | |
286 | - this.loadData(1, null, null, null, null, null, null, e); | |
287 | - }, | |
288 | - getAlertStatus(e, i) { | |
289 | - this.current1 = i; | |
290 | - this.alertStatusVal = e.value; | |
291 | - }, | |
292 | - getTypeStatus(e, i) { | |
293 | - this.current2 = i; | |
294 | - this.deviceTypeVal = e.value; | |
194 | + export default { | |
195 | + mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件) | |
196 | + components: { | |
197 | + fTabbar | |
295 | 198 | }, |
296 | - getLevelStatus(e, i) { | |
297 | - this.current3 = i; | |
298 | - this.alertLevelVal = e.value; | |
299 | - }, | |
300 | - getTimeStatus(e, i) { | |
301 | - this.current4 = i; | |
302 | - this.selectTimeVal = e.value; | |
303 | - let curTime = new Date(); | |
304 | - const formatS = curTime.getTime(); | |
305 | - let addMinute = new Date(curTime.setMinutes(curTime.getMinutes() - this.selectTimeVal)); | |
306 | - const formatE = addMinute.getTime(); | |
307 | - this.timeData.getTimeGapS = formatS; | |
308 | - this.timeData.getTimeGapE = formatE; | |
199 | + data() { | |
200 | + return { | |
201 | + range: [], | |
202 | + alertStatusVal: '', | |
203 | + deviceTypeVal: '', | |
204 | + alertLevelVal: '', | |
205 | + selectTimeVal: '', | |
206 | + current1: 0, | |
207 | + current2: 0, | |
208 | + current3: 0, | |
209 | + current4: 0, | |
210 | + page: { | |
211 | + num: 0, | |
212 | + size: 10 | |
213 | + }, | |
214 | + downOption: { | |
215 | + auto: false //是否在初始化后,自动执行downCallback; 默认true | |
216 | + }, | |
217 | + upOption: { | |
218 | + auto: false // 不自动加载 | |
219 | + }, | |
220 | + timeData: { | |
221 | + selectTime: [], | |
222 | + getTimeGapS: '', | |
223 | + getTimeGapE: '' | |
224 | + }, | |
225 | + show: false, | |
226 | + list: [], | |
227 | + alertStatus, | |
228 | + deviceType, | |
229 | + alertLevel, | |
230 | + timeArea, | |
231 | + ordId: '', | |
232 | + detailStatus: false, | |
233 | + alertTotal: 0, | |
234 | + searchAlarmText: '', | |
235 | + startTimeVa: '', | |
236 | + endTimeVa: '', | |
237 | + startTimeArea: '', | |
238 | + endTimeArea: '', | |
239 | + type: null | |
240 | + }; | |
309 | 241 | }, |
310 | - queryData() { | |
311 | - this.topBack(); | |
242 | + onShow() { | |
312 | 243 | this.page.num = 1; |
313 | - let date1 = new Date(this.timeData.selectTime[0]); | |
314 | - let date2 = new Date(this.timeData.selectTime[1]); | |
315 | - if (this.timeData.selectTime.length == 0) { | |
316 | - this.startTimeVa = ''; | |
317 | - this.endTimeVa = ''; | |
318 | - } else { | |
319 | - this.startTimeVa = date1.getTime(); | |
320 | - this.endTimeVa = date2.getTime(); | |
244 | + if (this.detailStatus) { | |
245 | + this.loadData(1, null, null, null, null, null, null); | |
321 | 246 | } |
322 | - if (this.timeData.getTimeGapS == '') { | |
323 | - this.startTimeArea = ''; | |
324 | - this.endTimeArea = ''; | |
325 | - } else { | |
326 | - this.startTimeArea = this.timeData.getTimeGapE; | |
327 | - this.endTimeArea = this.timeData.getTimeGapS; | |
247 | + if (this.ordId) { | |
248 | + this.loadData(1, null, null, null, null, null, this.ordId); | |
328 | 249 | } |
329 | - this.loadData( | |
330 | - 1, | |
331 | - this.alertStatusVal, | |
332 | - this.startTimeVa ? this.startTimeVa : this.startTimeArea, | |
333 | - this.endTimeVa ? this.endTimeVa : this.endTimeArea, | |
334 | - this.alertLevelVal, | |
335 | - this.deviceTypeVal | |
336 | - ); | |
337 | - this.show = false; | |
338 | 250 | }, |
339 | - resetData() { | |
340 | - this.current1 = 0; | |
341 | - this.alertStatusVal = ''; | |
342 | - this.current2 = 0; | |
343 | - this.deviceTypeVal = ''; | |
344 | - this.current3 = 0; | |
345 | - this.alertLevelVal = ''; | |
346 | - this.current4 = 0; | |
347 | - this.selectTimeVal = ''; | |
348 | - this.timeData.selectTime = []; | |
349 | - this.timeDatagetTimeGapS = ''; | |
350 | - this.timeDatagetTimeGapE = ''; | |
351 | - this.range = []; | |
352 | - this.searchAlarmText = ''; | |
353 | - this.startTimeVa = ''; | |
354 | - this.endTimeVa = ''; | |
355 | - this.startTimeArea = ''; | |
356 | - this.endTimeArea = ''; | |
251 | + onHide() { | |
357 | 252 | this.ordId = ''; |
253 | + this.detailStatus = false; | |
358 | 254 | this.type = null; |
359 | 255 | }, |
360 | - bindImageUrl(e) { | |
361 | - switch (e) { | |
362 | - case 'CRITICAL': | |
363 | - return '../../static/danger.png'; | |
364 | - break; | |
365 | - case 'MAJOR': | |
366 | - return '../../static/major.png'; | |
367 | - break; | |
368 | - case 'MINOR': | |
369 | - return '../../static/secondary.png'; | |
370 | - break; | |
371 | - case 'WARNING': | |
372 | - return '../../static/danger.png'; | |
373 | - break; | |
374 | - case 'INDETERMINATE': | |
375 | - return '../../static/noshue.png'; | |
376 | - break; | |
377 | - default: | |
378 | - return ''; | |
379 | - break; | |
256 | + onLoad(e) { | |
257 | + // 隐藏原生的tabbar | |
258 | + uni.hideTabBar(); | |
259 | + if (e.type == undefined) { | |
260 | + this.loadData(1, null, null, null, null, null, null); | |
261 | + } else { | |
262 | + let params = JSON.parse(e.type); | |
263 | + if (Array.isArray(params)) { | |
264 | + this.type = params.join(','); | |
265 | + } else { | |
266 | + this.type = params; | |
267 | + } | |
268 | + this.loadData(1, this.type, null, null, null, null, null); | |
380 | 269 | } |
381 | 270 | }, |
382 | - //筛选数据让它回到顶部 | |
383 | - topBack() { | |
384 | - uni.pageScrollTo({ | |
385 | - scrollTop: 0, // 滚动到页面的目标位置 这个是滚动到顶部, 0 | |
386 | - duration: 10 // 滚动动画的时长 | |
387 | - }); | |
388 | - }, | |
389 | - /*下拉刷新的回调 */ | |
390 | - downCallback() { | |
391 | - //联网加载数据 | |
392 | - this.list.length = 0; | |
393 | - this.page.num = 1; | |
394 | - this.loadData(this.page.num, null, null, null, null, null, null, null); | |
395 | - this.resetData(); | |
271 | + watch: { | |
272 | + range(newval) { | |
273 | + this.timeData.selectTime = this.range; | |
274 | + } | |
396 | 275 | }, |
397 | - /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */ | |
398 | - upCallback() { | |
399 | - if ( | |
400 | - this.type != null || | |
401 | - this.alertStatusVal != '' || | |
402 | - this.searchAlarmText != '' || | |
403 | - this.deviceTypeVal != '' || | |
404 | - this.alertLevelVal != '' || | |
405 | - this.startTimeVa != '' || | |
406 | - this.startTimeArea != '' || | |
407 | - this.ordId != '' | |
408 | - ) { | |
409 | - //联网加载数据 | |
410 | - this.page.num += 1; | |
276 | + methods: { | |
277 | + moveHandle() { | |
278 | + return false; | |
279 | + }, | |
280 | + inputChanged(e) { | |
281 | + this.resetData(); | |
282 | + this.topBack(); | |
283 | + this.searchAlarmText = e; | |
284 | + this.page.num = 1; | |
285 | + this.loadData(1, null, null, null, null, null, null, e); | |
286 | + }, | |
287 | + getAlertStatus(e, i) { | |
288 | + this.current1 = i; | |
289 | + this.alertStatusVal = e.value; | |
290 | + }, | |
291 | + getTypeStatus(e, i) { | |
292 | + this.current2 = i; | |
293 | + this.deviceTypeVal = e.value; | |
294 | + }, | |
295 | + getLevelStatus(e, i) { | |
296 | + this.current3 = i; | |
297 | + this.alertLevelVal = e.value; | |
298 | + }, | |
299 | + getTimeStatus(e, i) { | |
300 | + this.current4 = i; | |
301 | + this.selectTimeVal = e.value; | |
302 | + let curTime = new Date(); | |
303 | + const formatS = curTime.getTime(); | |
304 | + let addMinute = new Date(curTime.setMinutes(curTime.getMinutes() - this.selectTimeVal)); | |
305 | + const formatE = addMinute.getTime(); | |
306 | + this.timeData.getTimeGapS = formatS; | |
307 | + this.timeData.getTimeGapE = formatE; | |
308 | + }, | |
309 | + queryData() { | |
310 | + this.topBack(); | |
311 | + this.page.num = 1; | |
312 | + let date1 = new Date(this.timeData.selectTime[0]); | |
313 | + let date2 = new Date(this.timeData.selectTime[1]); | |
314 | + if (this.timeData.selectTime.length == 0) { | |
315 | + this.startTimeVa = ''; | |
316 | + this.endTimeVa = ''; | |
317 | + } else { | |
318 | + this.startTimeVa = date1.getTime(); | |
319 | + this.endTimeVa = date2.getTime(); | |
320 | + } | |
321 | + if (this.timeData.getTimeGapS == '') { | |
322 | + this.startTimeArea = ''; | |
323 | + this.endTimeArea = ''; | |
324 | + } else { | |
325 | + this.startTimeArea = this.timeData.getTimeGapE; | |
326 | + this.endTimeArea = this.timeData.getTimeGapS; | |
327 | + } | |
411 | 328 | this.loadData( |
412 | - this.page.num, | |
413 | - this.alertStatusVal ? this.alertStatusVal : this.type, | |
414 | - this.startTimeVa, | |
415 | - this.endTimeVa, | |
329 | + 1, | |
330 | + this.alertStatusVal, | |
331 | + this.startTimeVa ? this.startTimeVa : this.startTimeArea, | |
332 | + this.endTimeVa ? this.endTimeVa : this.endTimeArea, | |
416 | 333 | this.alertLevelVal, |
417 | - this.deviceTypeVal, | |
418 | - this.ordId, | |
419 | - this.searchAlarmText | |
334 | + this.deviceTypeVal | |
420 | 335 | ); |
421 | - } else { | |
336 | + this.show = false; | |
337 | + }, | |
338 | + resetData() { | |
339 | + this.current1 = 0; | |
340 | + this.alertStatusVal = ''; | |
341 | + this.current2 = 0; | |
342 | + this.deviceTypeVal = ''; | |
343 | + this.current3 = 0; | |
344 | + this.alertLevelVal = ''; | |
345 | + this.current4 = 0; | |
346 | + this.selectTimeVal = ''; | |
347 | + this.timeData.selectTime = []; | |
348 | + this.timeDatagetTimeGapS = ''; | |
349 | + this.timeDatagetTimeGapE = ''; | |
350 | + this.range = []; | |
351 | + this.searchAlarmText = ''; | |
352 | + this.startTimeVa = ''; | |
353 | + this.endTimeVa = ''; | |
354 | + this.startTimeArea = ''; | |
355 | + this.endTimeArea = ''; | |
356 | + this.ordId = ''; | |
357 | + this.type = null; | |
358 | + }, | |
359 | + bindImageUrl(e) { | |
360 | + switch (e) { | |
361 | + case 'CRITICAL': | |
362 | + return '../../static/danger.png'; | |
363 | + break; | |
364 | + case 'MAJOR': | |
365 | + return '../../static/major.png'; | |
366 | + break; | |
367 | + case 'MINOR': | |
368 | + return '../../static/secondary.png'; | |
369 | + break; | |
370 | + case 'WARNING': | |
371 | + return '../../static/danger.png'; | |
372 | + break; | |
373 | + case 'INDETERMINATE': | |
374 | + return '../../static/noshue.png'; | |
375 | + break; | |
376 | + default: | |
377 | + return ''; | |
378 | + break; | |
379 | + } | |
380 | + }, | |
381 | + //筛选数据让它回到顶部 | |
382 | + topBack() { | |
383 | + uni.pageScrollTo({ | |
384 | + scrollTop: 0, // 滚动到页面的目标位置 这个是滚动到顶部, 0 | |
385 | + duration: 10 // 滚动动画的时长 | |
386 | + }); | |
387 | + }, | |
388 | + /*下拉刷新的回调 */ | |
389 | + downCallback() { | |
422 | 390 | //联网加载数据 |
423 | - this.page.num += 1; | |
424 | - this.loadData(this.page.num); | |
425 | - } | |
426 | - }, | |
427 | - loadData(pageNo, statusV, startTimeV, endTimeV, severityV, deviceTypeV, organizationV, alarmName) { | |
428 | - let that = this; | |
429 | - let httpData = { | |
430 | - page: pageNo, | |
431 | - pageSize: 10, | |
432 | - status: statusV, | |
433 | - startTime: startTimeV, | |
434 | - endTime: endTimeV, | |
435 | - severity: severityV, | |
436 | - deviceType: deviceTypeV, | |
437 | - organizationId: organizationV, | |
438 | - alarmType: alarmName | |
439 | - }; | |
440 | - if (statusV == '') { | |
441 | - delete httpData.status; | |
442 | - } | |
443 | - if (severityV == '') { | |
444 | - delete httpData.severity; | |
445 | - } | |
446 | - uni.$u.http | |
447 | - .get('/yt/alarm', { params: httpData, custom: { load: false } }) | |
448 | - .then(res => { | |
391 | + this.list.length = 0; | |
392 | + this.page.num = 1; | |
393 | + this.loadData(this.page.num, null, null, null, null, null, null, null); | |
394 | + this.resetData(); | |
395 | + }, | |
396 | + /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */ | |
397 | + upCallback() { | |
398 | + if ( | |
399 | + this.type != null || | |
400 | + this.alertStatusVal != '' || | |
401 | + this.searchAlarmText != '' || | |
402 | + this.deviceTypeVal != '' || | |
403 | + this.alertLevelVal != '' || | |
404 | + this.startTimeVa != '' || | |
405 | + this.startTimeArea != '' || | |
406 | + this.ordId != '' | |
407 | + ) { | |
408 | + //联网加载数据 | |
409 | + this.page.num += 1; | |
410 | + this.loadData( | |
411 | + this.page.num, | |
412 | + this.alertStatusVal ? this.alertStatusVal : this.type, | |
413 | + this.startTimeVa, | |
414 | + this.endTimeVa, | |
415 | + this.alertLevelVal, | |
416 | + this.deviceTypeVal, | |
417 | + this.ordId, | |
418 | + this.searchAlarmText | |
419 | + ); | |
420 | + } else { | |
421 | + //联网加载数据 | |
422 | + this.page.num += 1; | |
423 | + this.loadData(this.page.num); | |
424 | + } | |
425 | + }, | |
426 | + async loadData(pageNo, statusV, startTimeV, endTimeV, severityV, deviceTypeV, organizationV, alarmName) { | |
427 | + let that = this; | |
428 | + let httpData = { | |
429 | + page: pageNo, | |
430 | + pageSize: 10, | |
431 | + status: statusV, | |
432 | + startTime: startTimeV, | |
433 | + endTime: endTimeV, | |
434 | + severity: severityV, | |
435 | + deviceType: deviceTypeV, | |
436 | + organizationId: organizationV, | |
437 | + alarmType: alarmName | |
438 | + }; | |
439 | + if (statusV == '') { | |
440 | + delete httpData.status; | |
441 | + } | |
442 | + if (severityV == '') { | |
443 | + delete httpData.severity; | |
444 | + } | |
445 | + const res = await api.alarmApi.getAlarmApi({ | |
446 | + params: httpData, | |
447 | + custom: { | |
448 | + load: false | |
449 | + } | |
450 | + }) | |
451 | + if (res) { | |
449 | 452 | uni.stopPullDownRefresh(); |
450 | 453 | that.mescroll.endByPage(res.items.length, res.total); //必传参数(当前页的数据个数, 总页数) |
451 | 454 | that.alertTotal = res.total; |
... | ... | @@ -454,96 +457,103 @@ export default { |
454 | 457 | } else { |
455 | 458 | that.list = that.list.concat(res.items); |
456 | 459 | } |
457 | - }) | |
458 | - .catch(e => { | |
459 | - //联网失败, 结束加载 | |
460 | - that.mescroll.endErr(); | |
460 | + } | |
461 | + }, | |
462 | + openOrg() { | |
463 | + uni.navigateTo({ | |
464 | + url: './org/org' | |
461 | 465 | }); |
462 | - }, | |
463 | - openOrg() { | |
464 | - uni.navigateTo({ | |
465 | - url: './org/org' | |
466 | - }); | |
467 | - }, | |
468 | - close() { | |
469 | - this.show = false; | |
470 | - }, | |
471 | - openSearchDialog() { | |
472 | - this.show = true; | |
473 | - this.resetData(); | |
474 | - }, | |
475 | - //跳转告警详情 | |
476 | - openAlertDetail(e) { | |
477 | - let obj = { | |
478 | - id: e.id, | |
479 | - deviceName: e.deviceName, | |
480 | - severity: e.severity, | |
481 | - organizationName: e.organizationName, | |
482 | - details: e.details, | |
483 | - createdTime: e.createdTime, | |
484 | - status: e.status | |
485 | - }; | |
486 | - uni.navigateTo({ | |
487 | - url: '/alarmSubPage/alarmDetailPage/alarmDetail?data=' + JSON.stringify(obj) | |
488 | - }); | |
489 | - }, | |
490 | - formatDetailText(e) { | |
491 | - //去除字符串双引号 | |
492 | - const jsonStr = JSON.stringify(e); | |
493 | - const str = jsonStr.substring(1, jsonStr.length - 1); | |
494 | - const newStr = str.replace(/\"/g, ''); | |
495 | - return newStr; | |
466 | + }, | |
467 | + close() { | |
468 | + this.show = false; | |
469 | + }, | |
470 | + openSearchDialog() { | |
471 | + this.show = true; | |
472 | + this.resetData(); | |
473 | + }, | |
474 | + //跳转告警详情 | |
475 | + openAlertDetail(e) { | |
476 | + let obj = { | |
477 | + id: e.id, | |
478 | + deviceName: e.deviceName, | |
479 | + severity: e.severity, | |
480 | + organizationName: e.organizationName, | |
481 | + details: e.details, | |
482 | + createdTime: e.createdTime, | |
483 | + status: e.status | |
484 | + }; | |
485 | + uni.navigateTo({ | |
486 | + url: '/alarmSubPage/alarmDetailPage/alarmDetail?data=' + JSON.stringify(obj) | |
487 | + }); | |
488 | + }, | |
489 | + formatDetailText(e) { | |
490 | + //去除字符串双引号 | |
491 | + const jsonStr = JSON.stringify(e); | |
492 | + const str = jsonStr.substring(1, jsonStr.length - 1); | |
493 | + const newStr = str.replace(/\"/g, ''); | |
494 | + return newStr; | |
495 | + } | |
496 | 496 | } |
497 | - } | |
498 | -}; | |
497 | + }; | |
499 | 498 | </script> |
500 | 499 | |
501 | 500 | <style lang="scss" scoped> |
502 | -@import './static/alarm.scss'; | |
503 | -/deep/ .u-button--primary { | |
504 | - background-color: #377dff !important; | |
505 | - border-color: #377dff !important; | |
506 | -} | |
507 | -/deep/ .u-button--info { | |
508 | - background-color: #e3e3e5 !important; | |
509 | - border-color: #e3e3e5 !important; | |
510 | -} | |
511 | -/deep/ .u-cell__right-icon-wrap { | |
512 | - margin-top: -55rpx !important; | |
513 | -} | |
514 | -/deep/ .uni-calendar--fixed { | |
515 | - bottom: 172rpx !important; | |
516 | -} | |
517 | -.pop-no-scroll { | |
518 | - overflow: hidden; | |
519 | - position: fixed; | |
520 | - height: 100%; | |
521 | - width: 100%; | |
522 | -} | |
523 | -.device-top { | |
524 | - padding: 10rpx 30rpx; | |
525 | - background-color: #fff; | |
526 | - .search { | |
527 | - display: flex; | |
528 | - justify-content: space-between; | |
529 | - padding-bottom: 10rpx; | |
530 | - .search-left { | |
531 | - width: 580rpx; | |
532 | - background-color: #f8f9fa; | |
533 | - border-radius: 200rpx; | |
534 | - } | |
535 | - .search-right { | |
501 | + @import './static/alarm.scss'; | |
502 | + | |
503 | + /deep/ .u-button--primary { | |
504 | + background-color: #377dff !important; | |
505 | + border-color: #377dff !important; | |
506 | + } | |
507 | + | |
508 | + /deep/ .u-button--info { | |
509 | + background-color: #e3e3e5 !important; | |
510 | + border-color: #e3e3e5 !important; | |
511 | + } | |
512 | + | |
513 | + /deep/ .u-cell__right-icon-wrap { | |
514 | + margin-top: -55rpx !important; | |
515 | + } | |
516 | + | |
517 | + /deep/ .uni-calendar--fixed { | |
518 | + bottom: 172rpx !important; | |
519 | + } | |
520 | + | |
521 | + .pop-no-scroll { | |
522 | + overflow: hidden; | |
523 | + position: fixed; | |
524 | + height: 100%; | |
525 | + width: 100%; | |
526 | + } | |
527 | + | |
528 | + .device-top { | |
529 | + padding: 10rpx 30rpx; | |
530 | + background-color: #fff; | |
531 | + | |
532 | + .search { | |
536 | 533 | display: flex; |
537 | - align-items: center; | |
538 | - text { | |
539 | - color: #333; | |
540 | - font-size: 14px; | |
534 | + justify-content: space-between; | |
535 | + padding-bottom: 10rpx; | |
536 | + | |
537 | + .search-left { | |
538 | + width: 580rpx; | |
539 | + background-color: #f8f9fa; | |
540 | + border-radius: 200rpx; | |
541 | 541 | } |
542 | - image { | |
543 | - width: 40rpx; | |
544 | - height: 40rpx; | |
542 | + | |
543 | + .search-right { | |
544 | + display: flex; | |
545 | + align-items: center; | |
546 | + | |
547 | + text { | |
548 | + color: #333; | |
549 | + font-size: 14px; | |
550 | + } | |
551 | + | |
552 | + image { | |
553 | + width: 40rpx; | |
554 | + height: 40rpx; | |
555 | + } | |
545 | 556 | } |
546 | 557 | } |
547 | 558 | } |
548 | -} | |
549 | 559 | </style> | ... | ... |
... | ... | @@ -4,7 +4,10 @@ |
4 | 4 | <view class="device-top"> |
5 | 5 | <view class="search"> |
6 | 6 | <view> |
7 | - <view class="search-left"><u--input prefixIcon="search" placeholder="输入设备SN或名称搜索" shape="circle" @change="inputChanged"></u--input></view> | |
7 | + <view class="search-left"> | |
8 | + <u--input prefixIcon="search" placeholder="输入设备SN或名称搜索" shape="circle" | |
9 | + @change="inputChanged"></u--input> | |
10 | + </view> | |
8 | 11 | </view> |
9 | 12 | <view @click="openSearchDialog" class="search-right"> |
10 | 13 | <text>筛选</text> |
... | ... | @@ -25,22 +28,22 @@ |
25 | 28 | </view> |
26 | 29 | </view> |
27 | 30 | </u-sticky> |
28 | - <mescroll-body ref="mescrollRef" @init="mescrollInit" :up="upOption" :down="downOption" @down="downCallback" @up="upCallback"> | |
31 | + <mescroll-body ref="mescrollRef" @init="mescrollInit" :up="upOption" :down="downOption" @down="downCallback" | |
32 | + @up="upCallback"> | |
29 | 33 | <view class="device-list"> |
30 | - <view @click="openDeviceDetail(item.id, item.alarmStatus, item.lastOnlineTime, item.tbDeviceId)" class="list-item" v-for="item in list" :key="item.id"> | |
31 | - <view | |
32 | - class="u-flex item" | |
33 | - style=" | |
34 | + <view @click="openDeviceDetail(item.id, item.alarmStatus, item.lastOnlineTime, item.tbDeviceId)" | |
35 | + class="list-item" v-for="item in list" :key="item.id"> | |
36 | + <view class="u-flex item" style=" | |
34 | 37 | justify-content: flex-start; |
35 | 38 | flex-direction: column; |
36 | 39 | align-items: center; |
37 | - " | |
38 | - > | |
40 | + "> | |
39 | 41 | <view style="width: 450rpx; text-align: left"> |
40 | 42 | <view class="text-clip" style="width:450rpx"> |
41 | - <text class="" style="color: #333; font-size: 15px;font-weight: bold;">{{ item.alias ? item.alias : item.name }}</text> | |
43 | + <text class="" | |
44 | + style="color: #333; font-size: 15px;font-weight: bold;">{{ item.alias ? item.alias : item.name }}</text> | |
42 | 45 | </view> |
43 | - | |
46 | + | |
44 | 47 | </view> |
45 | 48 | <view style="width: 450rpx; text-align: left; margin-top: 10rpx"> |
46 | 49 | <view style="color: #666; font-size: 14px;display: flex;"> |
... | ... | @@ -57,32 +60,26 @@ |
57 | 60 | </view> |
58 | 61 | <view class="item"> |
59 | 62 | <view class="u-flex" style="margin-top: -6rpx"> |
60 | - <image | |
61 | - style=" | |
63 | + <image style=" | |
62 | 64 | width: 30rpx; |
63 | 65 | height: 30rpx; |
64 | 66 | margin-top: 5rpx; |
65 | 67 | margin-right: 5rpx; |
66 | - " | |
67 | - :src=" | |
68 | + " :src=" | |
68 | 69 | item.deviceState === 'ONLINE' |
69 | 70 | ? '../../static/online.png' |
70 | 71 | : item.deviceState === 'INACTIVE' |
71 | 72 | ? '../../static/unonline.png' |
72 | 73 | : '../../static/baojing.png' |
73 | - " | |
74 | - /> | |
74 | + " /> | |
75 | 75 | |
76 | 76 | <view> |
77 | - <text | |
78 | - style=" | |
77 | + <text style=" | |
79 | 78 | color: #377dff; |
80 | 79 | font-size: 13px; |
81 | 80 | margin-left: 5rpx; |
82 | 81 | margin-top: 20rpx; |
83 | - " | |
84 | - :style="{ color: item.deviceState === 'ONLINE' ? '#377DFF' : item.deviceState === 'INACTIVE' ? '#666666' : '#DE4437' }" | |
85 | - > | |
82 | + " :style="{ color: item.deviceState === 'ONLINE' ? '#377DFF' : item.deviceState === 'INACTIVE' ? '#666666' : '#DE4437' }"> | |
86 | 83 | {{ item.deviceState === 'ONLINE' ? '在线' : item.deviceState === 'INACTIVE' ? '待激活' : '离线' }} |
87 | 84 | </text> |
88 | 85 | </view> |
... | ... | @@ -92,15 +89,24 @@ |
92 | 89 | </view> |
93 | 90 | </mescroll-body> |
94 | 91 | <!-- 设备筛选 --> |
95 | - <u-popup @close="close" closeable bgColor="#fff" :show="show" mode="bottom" :round="20" @touchmove.stop.prevent="disabledScroll"> | |
92 | + <u-popup @close="close" closeable bgColor="#fff" :show="show" mode="bottom" :round="20" | |
93 | + @touchmove.stop.prevent="disabledScroll"> | |
96 | 94 | <view class="filter" @touchmove.stop.prevent="disabledScroll"> |
97 | 95 | <view class="filter-title"><text>筛选条件</text></view> |
98 | - <FilterItem :filterList="deviceStatus" title="设备状态" @clickTag="currentIndex => handleClickTag(currentIndex, deviceStatus)"></FilterItem> | |
99 | - <FilterItem :filterList="alarmStatus" title="告警状态" @clickTag="currentIndex => handleClickTag(currentIndex, alarmStatus)"></FilterItem> | |
100 | - <FilterItem :filterList="typeStatus" title="设备类型" @clickTag="currentIndex => handleClickTag(currentIndex, typeStatus)"></FilterItem> | |
96 | + <FilterItem :filterList="deviceStatus" title="设备状态" | |
97 | + @clickTag="currentIndex => handleClickTag(currentIndex, deviceStatus)"></FilterItem> | |
98 | + <FilterItem :filterList="alarmStatus" title="告警状态" | |
99 | + @clickTag="currentIndex => handleClickTag(currentIndex, alarmStatus)"></FilterItem> | |
100 | + <FilterItem :filterList="typeStatus" title="设备类型" | |
101 | + @clickTag="currentIndex => handleClickTag(currentIndex, typeStatus)"></FilterItem> | |
101 | 102 | <view class="button-group"> |
102 | - <view><u-button :customStyle="{ color: '#333' }" color="#e3e3e5" shape="circle" text="重置" @click="resetFilter"></u-button></view> | |
103 | - <view><u-button color="#3388ff" shape="circle" text="确认" @click="confirmFilter"></u-button></view> | |
103 | + <view> | |
104 | + <u-button :customStyle="{ color: '#333' }" color="#e3e3e5" shape="circle" text="重置" | |
105 | + @click="resetFilter"></u-button> | |
106 | + </view> | |
107 | + <view> | |
108 | + <u-button color="#3388ff" shape="circle" text="确认" @click="confirmFilter"></u-button> | |
109 | + </view> | |
104 | 110 | </view> |
105 | 111 | </view> |
106 | 112 | </u-popup> |
... | ... | @@ -109,306 +115,319 @@ |
109 | 115 | </template> |
110 | 116 | |
111 | 117 | <script> |
112 | -import fTabbar from '@/components/module/f-tabbar/f-tabbar'; | |
113 | -import FilterItem from './FilterItem.vue'; | |
114 | -import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js'; | |
115 | -import { debounce } from '@/plugins/throttle.js'; | |
116 | -export default { | |
117 | - mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件) | |
118 | - components: { | |
119 | - fTabbar, | |
120 | - FilterItem | |
121 | - }, | |
122 | - data() { | |
123 | - return { | |
124 | - downOption: { | |
125 | - auto: false //是否在初始化后,自动执行downCallback; 默认true | |
126 | - }, | |
127 | - upOption: { | |
128 | - isBounce: false, | |
129 | - auto: false // 不自动加载 | |
130 | - }, | |
131 | - show: false, | |
132 | - deviceStatus: [ | |
133 | - { | |
134 | - checked: true, | |
135 | - name: '全部', | |
136 | - type: '' | |
137 | - }, | |
138 | - { | |
139 | - checked: false, | |
140 | - name: '在线', | |
141 | - type: 'ONLINE' | |
142 | - }, | |
143 | - { | |
144 | - checked: false, | |
145 | - name: '离线', | |
146 | - type: 'OFFLINE' | |
147 | - }, | |
148 | - { | |
149 | - checked: false, | |
150 | - name: '待激活', | |
151 | - type: 'INACTIVE' | |
152 | - } | |
153 | - ], | |
154 | - alarmStatus: [ | |
155 | - { | |
156 | - checked: true, | |
157 | - name: '全部', | |
158 | - type: '' | |
159 | - }, | |
160 | - { | |
161 | - checked: false, | |
162 | - name: '告警', | |
163 | - type: '1' | |
118 | + import fTabbar from '@/components/module/f-tabbar/f-tabbar'; | |
119 | + import FilterItem from './FilterItem.vue'; | |
120 | + import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js'; | |
121 | + import { | |
122 | + debounce | |
123 | + } from '@/plugins/throttle.js'; | |
124 | + import api from '@/api/index.js' | |
125 | + | |
126 | + export default { | |
127 | + mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件) | |
128 | + components: { | |
129 | + fTabbar, | |
130 | + FilterItem | |
131 | + }, | |
132 | + data() { | |
133 | + return { | |
134 | + downOption: { | |
135 | + auto: false //是否在初始化后,自动执行downCallback; 默认true | |
164 | 136 | }, |
165 | - { | |
166 | - checked: false, | |
167 | - name: '正常', | |
168 | - type: '0' | |
169 | - } | |
170 | - ], | |
171 | - typeStatus: [ | |
172 | - { | |
173 | - checked: true, | |
174 | - name: '全部', | |
175 | - type: '' | |
137 | + upOption: { | |
138 | + isBounce: false, | |
139 | + auto: false // 不自动加载 | |
176 | 140 | }, |
141 | + show: false, | |
142 | + deviceStatus: [{ | |
143 | + checked: true, | |
144 | + name: '全部', | |
145 | + type: '' | |
146 | + }, | |
147 | + { | |
148 | + checked: false, | |
149 | + name: '在线', | |
150 | + type: 'ONLINE' | |
151 | + }, | |
152 | + { | |
153 | + checked: false, | |
154 | + name: '离线', | |
155 | + type: 'OFFLINE' | |
156 | + }, | |
157 | + { | |
158 | + checked: false, | |
159 | + name: '待激活', | |
160 | + type: 'INACTIVE' | |
161 | + } | |
162 | + ], | |
163 | + alarmStatus: [{ | |
164 | + checked: true, | |
165 | + name: '全部', | |
166 | + type: '' | |
167 | + }, | |
168 | + { | |
169 | + checked: false, | |
170 | + name: '告警', | |
171 | + type: '1' | |
172 | + }, | |
173 | + { | |
174 | + checked: false, | |
175 | + name: '正常', | |
176 | + type: '0' | |
177 | + } | |
178 | + ], | |
179 | + typeStatus: [{ | |
180 | + checked: true, | |
181 | + name: '全部', | |
182 | + type: '' | |
183 | + }, | |
177 | 184 | |
178 | - { | |
179 | - checked: false, | |
180 | - name: '直连设备', | |
181 | - type: 'DIRECT_CONNECTION' | |
182 | - }, | |
183 | - { | |
184 | - checked: false, | |
185 | - name: '网关设备', | |
186 | - type: 'GATEWAY' | |
185 | + { | |
186 | + checked: false, | |
187 | + name: '直连设备', | |
188 | + type: 'DIRECT_CONNECTION' | |
189 | + }, | |
190 | + { | |
191 | + checked: false, | |
192 | + name: '网关设备', | |
193 | + type: 'GATEWAY' | |
194 | + }, | |
195 | + { | |
196 | + checked: false, | |
197 | + name: '网关子设备', | |
198 | + type: 'SENSOR' | |
199 | + } | |
200 | + ], | |
201 | + total: 0, | |
202 | + list: [], | |
203 | + page: { | |
204 | + num: 0, | |
205 | + size: 10 | |
187 | 206 | }, |
188 | - { | |
189 | - checked: false, | |
190 | - name: '网关子设备', | |
191 | - type: 'SENSOR' | |
192 | - } | |
193 | - ], | |
194 | - total: 0, | |
195 | - list: [], | |
196 | - page: { | |
197 | - num: 0, | |
198 | - size: 10 | |
199 | - }, | |
200 | - deviceState: '', | |
201 | - deviceName: '' | |
202 | - }; | |
203 | - }, | |
204 | - async onLoad(options) { | |
205 | - // 隐藏原生的tabbar | |
206 | - uni.hideTabBar(); | |
207 | - this.page.num = 1; | |
208 | - const { deviceState } = options; | |
209 | - this.deviceState = deviceState; | |
210 | - if (deviceState) { | |
211 | - this.deviceStatus.forEach(item => { | |
212 | - item.type === deviceState ? (item.checked = true) : (item.checked = false); | |
213 | - }); | |
214 | - await this.loadData(1, { | |
215 | - deviceState | |
216 | - }); | |
217 | - } else { | |
218 | - await this.loadData(1); | |
219 | - } | |
220 | - if (!this.list.length) { | |
221 | - this.mescroll.showEmpty(); | |
222 | - } | |
223 | - }, | |
224 | - onShow() { | |
225 | - if (this.orgId) { | |
226 | - this.loadData(1, { | |
227 | - organizationId: this.orgId | |
228 | - }); | |
229 | - } | |
230 | - }, | |
231 | - methods: { | |
232 | - disabledScroll() { | |
233 | - return; | |
207 | + deviceState: '', | |
208 | + deviceName: '' | |
209 | + }; | |
234 | 210 | }, |
235 | - /*下拉刷新的回调 */ | |
236 | - downCallback() { | |
237 | - this.deviceName = ''; | |
238 | - this.orgId = ''; | |
239 | - //联网加载数据 | |
240 | - this.list = []; | |
211 | + async onLoad(options) { | |
212 | + // 隐藏原生的tabbar | |
213 | + uni.hideTabBar(); | |
241 | 214 | this.page.num = 1; |
242 | - //联网加载数据 | |
243 | - this.resetFilter(); | |
244 | - this.loadData(this.page.num); | |
215 | + const { | |
216 | + deviceState | |
217 | + } = options; | |
218 | + this.deviceState = deviceState; | |
219 | + if (deviceState) { | |
220 | + this.deviceStatus.forEach(item => { | |
221 | + item.type === deviceState ? (item.checked = true) : (item.checked = false); | |
222 | + }); | |
223 | + await this.loadData(1, { | |
224 | + deviceState | |
225 | + }); | |
226 | + } else { | |
227 | + await this.loadData(1); | |
228 | + } | |
229 | + if (!this.list.length) { | |
230 | + this.mescroll.showEmpty(); | |
231 | + } | |
245 | 232 | }, |
246 | - | |
247 | - /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */ | |
248 | - upCallback() { | |
249 | - //联网加载数据 | |
250 | - this.page.num += 1; | |
251 | - const deviceState = this.deviceStatus.find(item => item.checked); | |
252 | - const alarmStatus = this.alarmStatus.find(item => item.checked); | |
253 | - const deviceType = this.typeStatus.find(item => item.checked); | |
254 | - this.loadData(this.page.num, { | |
255 | - deviceState: deviceState.type ? deviceState.type : undefined, | |
256 | - deviceType: deviceType.type ? deviceType.type : undefined, | |
257 | - alarmStatus: alarmStatus.type === '0' || alarmStatus.type === '1' ? alarmStatus.type : undefined, | |
258 | - name: this.deviceName == null ? null : this.deviceName, | |
259 | - organizationId: this.orgId == null ? null : this.orgId | |
260 | - }); | |
233 | + onShow() { | |
234 | + if (this.orgId) { | |
235 | + this.loadData(1, { | |
236 | + organizationId: this.orgId | |
237 | + }); | |
238 | + } | |
261 | 239 | }, |
240 | + methods: { | |
241 | + disabledScroll() { | |
242 | + return; | |
243 | + }, | |
244 | + /*下拉刷新的回调 */ | |
245 | + downCallback() { | |
246 | + this.deviceName = ''; | |
247 | + this.orgId = ''; | |
248 | + //联网加载数据 | |
249 | + this.list = []; | |
250 | + this.page.num = 1; | |
251 | + //联网加载数据 | |
252 | + this.resetFilter(); | |
253 | + this.loadData(this.page.num); | |
254 | + }, | |
262 | 255 | |
263 | - //获取设备 | |
264 | - async loadData(pageNo, params = {}) { | |
265 | - try { | |
266 | - let httpData = { | |
267 | - page: pageNo, | |
268 | - pageSize: 10, | |
269 | - ...params | |
270 | - }; | |
271 | - const { total, items } = await uni.$u.http.get('/yt/device', { | |
272 | - params: httpData, | |
273 | - custom: { | |
274 | - load: false | |
275 | - } | |
256 | + /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */ | |
257 | + upCallback() { | |
258 | + //联网加载数据 | |
259 | + this.page.num += 1; | |
260 | + const deviceState = this.deviceStatus.find(item => item.checked); | |
261 | + const alarmStatus = this.alarmStatus.find(item => item.checked); | |
262 | + const deviceType = this.typeStatus.find(item => item.checked); | |
263 | + this.loadData(this.page.num, { | |
264 | + deviceState: deviceState.type ? deviceState.type : undefined, | |
265 | + deviceType: deviceType.type ? deviceType.type : undefined, | |
266 | + alarmStatus: alarmStatus.type === '0' || alarmStatus.type === '1' ? alarmStatus.type : | |
267 | + undefined, | |
268 | + name: this.deviceName == null ? null : this.deviceName, | |
269 | + organizationId: this.orgId == null ? null : this.orgId | |
276 | 270 | }); |
277 | - this.total = total; | |
278 | - uni.stopPullDownRefresh(); | |
279 | - this.mescroll.endByPage(items.length, total); //必传参数(当前页的数据个数, 总页数) | |
280 | - if (pageNo == 1) { | |
281 | - this.list = items; | |
282 | - } else { | |
283 | - this.list = this.list.concat(items); | |
271 | + }, | |
272 | + | |
273 | + //获取设备 | |
274 | + async loadData(pageNo, params = {}) { | |
275 | + try { | |
276 | + let httpData = { | |
277 | + page: pageNo, | |
278 | + pageSize: 10, | |
279 | + ...params | |
280 | + }; | |
281 | + const { | |
282 | + total, | |
283 | + items | |
284 | + } = await api.deviceApi.getDeviceApi({ | |
285 | + params: httpData, | |
286 | + custom: { | |
287 | + load: false | |
288 | + } | |
289 | + }) | |
290 | + this.total = total; | |
291 | + uni.stopPullDownRefresh(); | |
292 | + this.mescroll.endByPage(items.length, total); //必传参数(当前页的数据个数, 总页数) | |
293 | + if (pageNo == 1) { | |
294 | + this.list = items; | |
295 | + } else { | |
296 | + this.list = this.list.concat(items); | |
297 | + } | |
298 | + } catch { | |
299 | + this.mescroll.endErr(); | |
284 | 300 | } |
285 | - } catch { | |
286 | - this.mescroll.endErr(); | |
301 | + }, | |
302 | + openOrg() { | |
303 | + uni.navigateTo({ | |
304 | + url: './org/org' | |
305 | + }); | |
306 | + }, | |
307 | + close() { | |
308 | + this.show = false; | |
309 | + }, | |
310 | + openSearchDialog() { | |
311 | + this.show = true; | |
312 | + }, | |
313 | + openDeviceDetail(id, alarmStatus, lastOnlineTime, tbDeviceId) { | |
314 | + uni.navigateTo({ | |
315 | + url: `/deviceSubPage/deviceDetailPage/deviceDetail?id=${id}&alarmStatus=${alarmStatus}&lastOnlineTime=${lastOnlineTime}&tbDeviceId=${tbDeviceId}` | |
316 | + }); | |
317 | + }, | |
318 | + handleClickTag(currentIndex, list) { | |
319 | + list.map((item, index) => { | |
320 | + item.checked = index === currentIndex; | |
321 | + }); | |
322 | + }, | |
323 | + resetFilter() { | |
324 | + const { | |
325 | + deviceStatus, | |
326 | + alarmStatus, | |
327 | + typeStatus | |
328 | + } = this; | |
329 | + [deviceStatus, alarmStatus, typeStatus].forEach(item => item.map((item, index) => (item.checked = index === | |
330 | + 0))); | |
331 | + }, | |
332 | + confirmFilter() { | |
333 | + const deviceState = this.deviceStatus.find(item => item.checked); | |
334 | + const alarmStatus = this.alarmStatus.find(item => item.checked); | |
335 | + const deviceType = this.typeStatus.find(item => item.checked); | |
336 | + this.loadData(1, { | |
337 | + deviceState: deviceState.type ? deviceState.type : undefined, | |
338 | + deviceType: deviceType.type ? deviceType.type : undefined, | |
339 | + alarmStatus: alarmStatus.type === '0' || alarmStatus.type === '1' ? alarmStatus.type : | |
340 | + undefined | |
341 | + }); | |
342 | + this.show = false; | |
343 | + }, | |
344 | + inputChanged(e) { | |
345 | + this.page.num = 1; | |
346 | + this.deviceName = e; | |
347 | + this.loadData(1, { | |
348 | + name: this.deviceName | |
349 | + }); | |
287 | 350 | } |
288 | - }, | |
289 | - openOrg() { | |
290 | - uni.navigateTo({ | |
291 | - url: './org/org' | |
292 | - }); | |
293 | - }, | |
294 | - close() { | |
295 | - this.show = false; | |
296 | - }, | |
297 | - openSearchDialog() { | |
298 | - this.show = true; | |
299 | - }, | |
300 | - openDeviceDetail(id, alarmStatus, lastOnlineTime, tbDeviceId) { | |
301 | - uni.navigateTo({ | |
302 | - url: `/deviceSubPage/deviceDetailPage/deviceDetail?id=${id}&alarmStatus=${alarmStatus}&lastOnlineTime=${lastOnlineTime}&tbDeviceId=${tbDeviceId}` | |
303 | - }); | |
304 | - }, | |
305 | - handleClickTag(currentIndex, list) { | |
306 | - list.map((item, index) => { | |
307 | - item.checked = index === currentIndex; | |
308 | - }); | |
309 | - }, | |
310 | - resetFilter() { | |
311 | - const { deviceStatus, alarmStatus, typeStatus } = this; | |
312 | - [deviceStatus, alarmStatus, typeStatus].forEach(item => item.map((item, index) => (item.checked = index === 0))); | |
313 | - }, | |
314 | - confirmFilter() { | |
315 | - const deviceState = this.deviceStatus.find(item => item.checked); | |
316 | - const alarmStatus = this.alarmStatus.find(item => item.checked); | |
317 | - const deviceType = this.typeStatus.find(item => item.checked); | |
318 | - this.loadData(1, { | |
319 | - deviceState: deviceState.type ? deviceState.type : undefined, | |
320 | - deviceType: deviceType.type ? deviceType.type : undefined, | |
321 | - alarmStatus: alarmStatus.type === '0' || alarmStatus.type === '1' ? alarmStatus.type : undefined | |
322 | - }); | |
323 | - this.show = false; | |
324 | - }, | |
325 | - inputChanged(e) { | |
326 | - this.page.num = 1; | |
327 | - this.deviceName = e; | |
328 | - this.loadData(1, { | |
329 | - name: this.deviceName | |
330 | - }); | |
331 | 351 | } |
332 | - } | |
333 | -}; | |
352 | + }; | |
334 | 353 | </script> |
335 | 354 | |
336 | 355 | <style lang="scss" scoped> |
337 | -.device-page { | |
338 | - min-height: 100vh; | |
339 | - background-color: #f8f9fa; | |
340 | -} | |
341 | - | |
342 | -.device-top { | |
343 | - padding: 10rpx 30rpx; | |
344 | - background-color: #fff; | |
345 | - | |
346 | - .search { | |
347 | - display: flex; | |
348 | - justify-content: space-between; | |
349 | - padding-bottom: 10rpx; | |
356 | + .device-page { | |
357 | + min-height: 100vh; | |
358 | + background-color: #f8f9fa; | |
359 | + } | |
350 | 360 | |
351 | - .search-left { | |
352 | - width: 580rpx; | |
353 | - background-color: #f8f9fa; | |
354 | - border-radius: 200rpx; | |
355 | - } | |
361 | + .device-top { | |
362 | + padding: 10rpx 30rpx; | |
363 | + background-color: #fff; | |
356 | 364 | |
357 | - .search-right { | |
365 | + .search { | |
358 | 366 | display: flex; |
359 | - align-items: center; | |
367 | + justify-content: space-between; | |
368 | + padding-bottom: 10rpx; | |
360 | 369 | |
361 | - text { | |
362 | - color: #333; | |
363 | - font-size: 14px; | |
370 | + .search-left { | |
371 | + width: 580rpx; | |
372 | + background-color: #f8f9fa; | |
373 | + border-radius: 200rpx; | |
364 | 374 | } |
365 | 375 | |
366 | - image { | |
367 | - width: 40rpx; | |
368 | - height: 40rpx; | |
376 | + .search-right { | |
377 | + display: flex; | |
378 | + align-items: center; | |
379 | + | |
380 | + text { | |
381 | + color: #333; | |
382 | + font-size: 14px; | |
383 | + } | |
384 | + | |
385 | + image { | |
386 | + width: 40rpx; | |
387 | + height: 40rpx; | |
388 | + } | |
369 | 389 | } |
370 | 390 | } |
371 | 391 | } |
372 | -} | |
373 | 392 | |
374 | -.device-list { | |
375 | - display: flex; | |
376 | - flex-direction: column; | |
377 | - padding-left: 20rpx; | |
378 | - | |
379 | - .list-item { | |
380 | - width: 713rpx; | |
381 | - height: 200rpx; | |
382 | - background-color: #fff; | |
383 | - margin-top: 24rpx; | |
393 | + .device-list { | |
384 | 394 | display: flex; |
385 | - border-radius: 10px; | |
386 | - justify-content: space-between; | |
395 | + flex-direction: column; | |
396 | + padding-left: 20rpx; | |
387 | 397 | |
388 | - .item { | |
389 | - margin: 30rpx; | |
398 | + .list-item { | |
399 | + width: 713rpx; | |
400 | + height: 200rpx; | |
401 | + background-color: #fff; | |
402 | + margin-top: 24rpx; | |
403 | + display: flex; | |
404 | + border-radius: 10px; | |
405 | + justify-content: space-between; | |
406 | + | |
407 | + .item { | |
408 | + margin: 30rpx; | |
409 | + } | |
390 | 410 | } |
391 | 411 | } |
392 | -} | |
393 | 412 | |
394 | -.filter { | |
395 | - padding: 0 30rpx; | |
413 | + .filter { | |
414 | + padding: 0 30rpx; | |
396 | 415 | |
397 | - .filter-title { | |
398 | - text-align: center; | |
399 | - margin-top: 14px; | |
400 | - font-size: 16px; | |
401 | - font-weight: 700; | |
402 | - } | |
416 | + .filter-title { | |
417 | + text-align: center; | |
418 | + margin-top: 14px; | |
419 | + font-size: 16px; | |
420 | + font-weight: 700; | |
421 | + } | |
403 | 422 | |
404 | - .button-group { | |
405 | - display: flex; | |
406 | - margin-top: 40rpx; | |
407 | - justify-content: space-between; | |
423 | + .button-group { | |
424 | + display: flex; | |
425 | + margin-top: 40rpx; | |
426 | + justify-content: space-between; | |
408 | 427 | |
409 | - view { | |
410 | - width: 330rpx; | |
428 | + view { | |
429 | + width: 330rpx; | |
430 | + } | |
411 | 431 | } |
412 | 432 | } |
413 | -} | |
414 | 433 | </style> | ... | ... |
... | ... | @@ -10,7 +10,7 @@ |
10 | 10 | <text class="device-text">摄像头数:{{ cameraTotal }}</text> |
11 | 11 | </view> |
12 | 12 | </view> |
13 | - <view @click="openOrg" class="org-item" > | |
13 | + <view @click="openOrg" class="org-item"> | |
14 | 14 | <image class="image" src="../../../static/arrow-right.png"></image> |
15 | 15 | </view> |
16 | 16 | </view> |
... | ... | @@ -25,12 +25,12 @@ |
25 | 25 | :id="'video' + item.id" class="video" :src="item.videoUrl || commonVideoUrl" controls |
26 | 26 | :title="item.name" x5-video-player-type="h5" x5-video-orientation="portraint" show-mute-btn |
27 | 27 | :poster="item.avatar" @play="playVideo"></video> |
28 | - <view class="bottom-text"> | |
28 | + <view style="width:300rpx" class="bottom-text text-clip"> | |
29 | 29 | <text class="text">{{ item.name }}</text> |
30 | 30 | </view> |
31 | 31 | </view> |
32 | 32 | </view> |
33 | - </view> | |
33 | + </view> | |
34 | 34 | <mescroll-empty v-if="!list.length" /> |
35 | 35 | </mescroll-body> |
36 | 36 | <!-- 自带分页组件 --> |
... | ... | @@ -40,6 +40,7 @@ |
40 | 40 | |
41 | 41 | <script> |
42 | 42 | import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js'; |
43 | + import api from '@/api/index.js' | |
43 | 44 | |
44 | 45 | export default { |
45 | 46 | mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件) |
... | ... | @@ -88,38 +89,33 @@ |
88 | 89 | this.page.num += 1; |
89 | 90 | this.loadData(this.page.num); |
90 | 91 | }, |
91 | - loadData(pageNo, organizationV) { | |
92 | + async loadData(pageNo, organizationV) { | |
92 | 93 | let httpData = { |
93 | 94 | page: pageNo, |
94 | 95 | pageSize: 10, |
95 | 96 | organizationId: organizationV |
96 | 97 | }; |
97 | - uni.$u.http | |
98 | - .get('/yt/video', { | |
99 | - params: httpData, | |
100 | - custom: { | |
101 | - load: false | |
102 | - } | |
103 | - }) | |
104 | - .then(res => { | |
105 | - uni.stopPullDownRefresh(); | |
106 | - this.mescroll.endByPage(res.items.length, res.total); | |
107 | - this.cameraTotal = res.total; | |
108 | - if (pageNo == 1) { | |
109 | - this.list = res.items; | |
110 | - } else { | |
111 | - this.list = this.list.concat(res.items); | |
112 | - } | |
113 | - }) | |
114 | - .catch(e => { | |
115 | - //联网失败, 结束加载 | |
116 | - this.mescroll.endErr(); | |
117 | - }); | |
98 | + const res = await api.homeApi.getCameraApi({ | |
99 | + params: httpData, | |
100 | + custom: { | |
101 | + load: false | |
102 | + } | |
103 | + }) | |
104 | + if (res) { | |
105 | + uni.stopPullDownRefresh(); | |
106 | + this.mescroll.endByPage(res.items.length, res.total); | |
107 | + this.cameraTotal = res.total; | |
108 | + if (pageNo == 1) { | |
109 | + this.list = res.items; | |
110 | + } else { | |
111 | + this.list = this.list.concat(res.items); | |
112 | + } | |
113 | + } | |
118 | 114 | }, |
119 | 115 | hideImageUrl(item, index) { |
120 | 116 | this.current = index; |
121 | 117 | }, |
122 | - playVideo(e) { | |
118 | + async playVideo(e) { | |
123 | 119 | const { |
124 | 120 | currentTarget: { |
125 | 121 | dataset: { |
... | ... | @@ -130,28 +126,27 @@ |
130 | 126 | } = e |
131 | 127 | const isExistVideoUrl = this.list.find(item => item.id == id).videoUrl |
132 | 128 | if (accessmode === 1 && !isExistVideoUrl) { |
133 | - uni.$u.http.get(`/yt/video/url/${id}`) | |
134 | - .then(res => { | |
135 | - const { | |
136 | - data: { | |
137 | - url | |
138 | - } = {} | |
139 | - } = res | |
140 | - const index = this.list.findIndex(item => item.id === id) | |
141 | - if (~index && url) { | |
142 | - this.list.splice(index, 1, { | |
143 | - ...this.list[index], | |
144 | - videoUrl: url | |
145 | - }) | |
146 | - this.$nextTick(() => { | |
147 | - let currentId = 'video' + id; | |
148 | - const videoContext = uni.createVideoContext(currentId, this); | |
149 | - videoContext.play() | |
150 | - }) | |
151 | - } | |
152 | - }) | |
129 | + const res = api.homeApi.byCameraIdGetDetailApi(id) | |
130 | + if (res) { | |
131 | + const { | |
132 | + data: { | |
133 | + url | |
134 | + } = {} | |
135 | + } = res | |
136 | + const index = this.list.findIndex(item => item.id === id) | |
137 | + if (~index && url) { | |
138 | + this.list.splice(index, 1, { | |
139 | + ...this.list[index], | |
140 | + videoUrl: url | |
141 | + }) | |
142 | + this.$nextTick(() => { | |
143 | + let currentId = 'video' + id; | |
144 | + const videoContext = uni.createVideoContext(currentId, this); | |
145 | + videoContext.play() | |
146 | + }) | |
147 | + } | |
148 | + } | |
153 | 149 | } |
154 | - | |
155 | 150 | /** |
156 | 151 | * 点击全屏播放当前视频,暂停其余视频 |
157 | 152 | * 兼容APP和MP端 | ... | ... |
... | ... | @@ -3,14 +3,18 @@ |
3 | 3 | <view style="margin-left:15rpx;background-color: #f8f9fa;position:fixed;top:0rpx;z-index: 99999;"> |
4 | 4 | <view style="height:35rpx;background-color: #f8f9fa;"></view> |
5 | 5 | <view class="u-flex search-top"> |
6 | - <view class="search-main"><u--input @change="inputChanged" prefixIcon="search" placeholder="请输入组态名称" border="surround" shape="circle"></u--input></view> | |
6 | + <view class="search-main"> | |
7 | + <u--input @change="inputChanged" prefixIcon="search" placeholder="请输入组态名称" border="surround" | |
8 | + shape="circle"></u--input> | |
9 | + </view> | |
7 | 10 | </view> |
8 | 11 | </view> |
9 | 12 | <view style="height:35rpx"></view> |
10 | 13 | <!-- 公共组件-每个页面必须引入 --> |
11 | 14 | <public-module></public-module> |
12 | 15 | <!-- 自带分页组件 --> |
13 | - <mescroll-body ref="mescrollRef" :up="upOption" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback"> | |
16 | + <mescroll-body ref="mescrollRef" :up="upOption" @init="mescrollInit" :down="downOption" @down="downCallback" | |
17 | + @up="upCallback"> | |
14 | 18 | <view class="configuation-container"> |
15 | 19 | <view class="configuation-item"> |
16 | 20 | <view @click="openConfigDetail(item.id)" v-for="(item, index) in list" :key="index" class="item"> |
... | ... | @@ -27,71 +31,76 @@ |
27 | 31 | </template> |
28 | 32 | |
29 | 33 | <script> |
30 | -import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js'; | |
34 | + import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js'; | |
35 | + import api from '@/api/index.js' | |
31 | 36 | |
32 | -export default { | |
33 | - mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件) | |
34 | - data() { | |
35 | - return { | |
36 | - defaultConfigImage: '../../../static/test.png', | |
37 | - page: { | |
38 | - num: 0, | |
39 | - size: 10 | |
40 | - }, | |
41 | - downOption: { | |
42 | - auto: true //是否在初始化后,自动执行downCallback; 默认true | |
43 | - }, | |
44 | - upOption: { | |
45 | - auto: false // 不自动加载 | |
46 | - }, | |
47 | - list: [] | |
48 | - }; | |
49 | - }, | |
50 | - onLoad() { | |
51 | - // 隐藏原生的tabbar | |
52 | - uni.hideTabBar(); | |
53 | - uni.setStorageSync('getConfiguration', { | |
54 | - isConfiguration: false | |
55 | - }); | |
56 | - }, | |
57 | - onUnload() { | |
58 | - uni.setStorageSync('getConfiguration', { | |
59 | - isConfiguration: false | |
60 | - }); | |
61 | - uni.removeStorageSync('getConfiguration'); | |
62 | - }, | |
63 | - methods: { | |
64 | - inputChanged(e) { | |
65 | - this.page.num = 1; | |
66 | - this.loadData(1, e); | |
37 | + export default { | |
38 | + mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件) | |
39 | + data() { | |
40 | + return { | |
41 | + defaultConfigImage: '../../../static/test.png', | |
42 | + page: { | |
43 | + num: 0, | |
44 | + size: 10 | |
45 | + }, | |
46 | + downOption: { | |
47 | + auto: true //是否在初始化后,自动执行downCallback; 默认true | |
48 | + }, | |
49 | + upOption: { | |
50 | + auto: false // 不自动加载 | |
51 | + }, | |
52 | + list: [] | |
53 | + }; | |
67 | 54 | }, |
68 | - openConfigDetail(e) { | |
69 | - uni.navigateTo({ | |
70 | - url: 'configurationDetail?configId=' + e | |
55 | + onLoad() { | |
56 | + // 隐藏原生的tabbar | |
57 | + uni.hideTabBar(); | |
58 | + uni.setStorageSync('getConfiguration', { | |
59 | + isConfiguration: false | |
71 | 60 | }); |
72 | 61 | }, |
73 | - /*下拉刷新的回调 */ | |
74 | - downCallback() { | |
75 | - //联网加载数据 | |
76 | - this.page.num = 1; | |
77 | - this.loadData(1); | |
78 | - }, | |
79 | - /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */ | |
80 | - upCallback() { | |
81 | - //联网加载数据 | |
82 | - this.page.num += 1; | |
83 | - this.loadData(this.page.num); | |
62 | + onUnload() { | |
63 | + uni.setStorageSync('getConfiguration', { | |
64 | + isConfiguration: false | |
65 | + }); | |
66 | + uni.removeStorageSync('getConfiguration'); | |
84 | 67 | }, |
85 | - loadData(pageNo, organizationV) { | |
86 | - let httpData = { | |
87 | - page: pageNo, | |
88 | - pageSize: 10, | |
89 | - name: organizationV, | |
90 | - platform: 'phone' | |
91 | - }; | |
92 | - uni.$u.http | |
93 | - .get('/yt/configuration/center', { params: httpData, custom: { load: false } }) | |
94 | - .then(res => { | |
68 | + methods: { | |
69 | + inputChanged(e) { | |
70 | + this.page.num = 1; | |
71 | + this.loadData(1, e); | |
72 | + }, | |
73 | + openConfigDetail(e) { | |
74 | + uni.navigateTo({ | |
75 | + url: 'configurationDetail?configId=' + e | |
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 | + async loadData(pageNo, organizationV) { | |
91 | + let httpData = { | |
92 | + page: pageNo, | |
93 | + pageSize: 10, | |
94 | + name: organizationV, | |
95 | + platform: 'phone' | |
96 | + }; | |
97 | + const res = await api.homeApi.getConfigurationApi({ | |
98 | + params: httpData, | |
99 | + custom: { | |
100 | + load: false | |
101 | + } | |
102 | + }) | |
103 | + if (res) { | |
95 | 104 | uni.stopPullDownRefresh(); |
96 | 105 | this.mescroll.endByPage(res.items.length, res.total); |
97 | 106 | this.cameraTotal = res.total; |
... | ... | @@ -100,16 +109,12 @@ export default { |
100 | 109 | } else { |
101 | 110 | this.list = this.list.concat(res.items); |
102 | 111 | } |
103 | - }) | |
104 | - .catch(e => { | |
105 | - //联网失败, 结束加载 | |
106 | - this.mescroll.endErr(); | |
107 | - }); | |
112 | + } | |
113 | + } | |
108 | 114 | } |
109 | - } | |
110 | -}; | |
115 | + }; | |
111 | 116 | </script> |
112 | 117 | |
113 | 118 | <style lang="scss" scoped> |
114 | -@import '../static/configuration.scss'; | |
119 | + @import '../static/configuration.scss'; | |
115 | 120 | </style> | ... | ... |
1 | -<template> | |
2 | - <view class="content"> | |
3 | - <!-- 公共组件-每个页面必须引入 --> | |
4 | - <public-module></public-module> | |
5 | - <web-view :src="showConfiguration" bindload="bindload" binderror="binderror"></web-view> | |
6 | - </view> | |
7 | -</template> | |
8 | - | |
9 | -<script> | |
10 | -export default { | |
11 | - data() { | |
12 | - return { | |
13 | - showConfiguration: '', | |
14 | - defauleConfigImage: 'https://dev.thingskit.com', | |
15 | - params: '' | |
16 | - }; | |
17 | - }, | |
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 | - } | |
26 | - // 隐藏原生的tabbar | |
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 | - const userInfo = uni.getStorageSync('userInfo') | |
57 | - this.showConfiguration = `${pathUrl.baseURL}/?configurationId=${e}&userId=${userInfo.userId}&lightbox=1` | |
58 | - // this.showConfiguration = pathUrl.baseURL + '/' + '?' + 'configurationId=' + e + '&' + 'lightbox=' + 1; | |
59 | - } | |
60 | - } | |
61 | -}; | |
62 | -</script> | |
63 | - | |
64 | -<style lang="scss" scoped> | |
65 | -.content { | |
66 | - background: #f8f9fa; | |
67 | - min-height: 100vh; | |
68 | -} | |
1 | +<template> | |
2 | + <view class="content"> | |
3 | + <!-- 公共组件-每个页面必须引入 --> | |
4 | + <public-module></public-module> | |
5 | + <web-view :src="showConfiguration" bindload="bindload" binderror="binderror"></web-view> | |
6 | + </view> | |
7 | +</template> | |
8 | + | |
9 | +<script> | |
10 | + export default { | |
11 | + data() { | |
12 | + return { | |
13 | + showConfiguration: '', | |
14 | + defauleConfigImage: 'https://dev.thingskit.com', | |
15 | + params: '' | |
16 | + }; | |
17 | + }, | |
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 | + } | |
26 | + // 隐藏原生的tabbar | |
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('/', { | |
55 | + params: httpData, | |
56 | + custom: { | |
57 | + load: false | |
58 | + } | |
59 | + }); | |
60 | + const pathUrl = uni.getStorageSync('config'); | |
61 | + const userInfo = uni.getStorageSync('userInfo') | |
62 | + this.showConfiguration = | |
63 | + `${pathUrl.baseURL}/?configurationId=${e}&userId=${userInfo.userId}&lightbox=1` | |
64 | + } | |
65 | + } | |
66 | + }; | |
67 | +</script> | |
68 | + | |
69 | +<style lang="scss" scoped> | |
70 | + .content { | |
71 | + background: #f8f9fa; | |
72 | + min-height: 100vh; | |
73 | + } | |
69 | 74 | </style> | ... | ... |
... | ... | @@ -105,6 +105,7 @@ |
105 | 105 | import { |
106 | 106 | mapActions |
107 | 107 | } from 'vuex'; |
108 | + import api from '@/api/index.js' | |
108 | 109 | |
109 | 110 | export default { |
110 | 111 | components: { |
... | ... | @@ -135,19 +136,18 @@ |
135 | 136 | }, |
136 | 137 | methods: { |
137 | 138 | ...mapActions(['updateBadgeTotal']), |
138 | - getDeviceTotalData() { | |
139 | - uni.$u.http.get('/yt/homepage/app?login=false').then(res => { | |
140 | - if (res) { | |
141 | - this.deviceData.onLine = res.totalDevice?.onLine; | |
142 | - this.deviceData.unLine = res.totalDevice?.offLine; | |
143 | - this.deviceData.noActive = res.totalDevice?.inActive; | |
144 | - this.alertData.noHandle = res.totalAlarm?.activedAlarm; | |
145 | - this.alertData.doneHandle = res.totalAlarm?.clearedAck; | |
146 | - this.alertData.errorReport = res.totalAlarm?.clearedUnack; | |
147 | - //异步实时更新告警徽标数 | |
148 | - this.updateBadgeTotal(res.totalAlarm?.activedAlarm); | |
149 | - } | |
150 | - }); | |
139 | + async getDeviceTotalData() { | |
140 | + const res = await api.homeApi.getHomeStatisticsApi() | |
141 | + if (res) { | |
142 | + this.deviceData.onLine = res.totalDevice?.onLine; | |
143 | + this.deviceData.unLine = res.totalDevice?.offLine; | |
144 | + this.deviceData.noActive = res.totalDevice?.inActive; | |
145 | + this.alertData.noHandle = res.totalAlarm?.activedAlarm; | |
146 | + this.alertData.doneHandle = res.totalAlarm?.clearedAck; | |
147 | + this.alertData.errorReport = res.totalAlarm?.clearedUnack; | |
148 | + //异步实时更新告警徽标数 | |
149 | + this.updateBadgeTotal(res.totalAlarm?.activedAlarm); | |
150 | + } | |
151 | 151 | }, |
152 | 152 | showToastWip() { |
153 | 153 | uni.$u.toast('拼命开发中 ...'); | ... | ... |
... | ... | @@ -8,65 +8,69 @@ |
8 | 8 | </template> |
9 | 9 | |
10 | 10 | <script> |
11 | -import { mapState } from 'vuex'; | |
12 | -export default { | |
13 | - data() { | |
14 | - return { | |
15 | - staticLogo: '../../static/logo.png', | |
16 | - mpOwnConfig: {} | |
17 | - }; | |
18 | - }, | |
19 | - onLoad() { | |
20 | - this.getPlateForm(); | |
21 | - if (!this.userInfo.isToken) { | |
22 | - setTimeout(() => { | |
23 | - uni.reLaunch({ | |
24 | - url: '/publicLoginSubPage/public/login' | |
11 | + import { | |
12 | + mapState | |
13 | + } from 'vuex'; | |
14 | + export default { | |
15 | + data() { | |
16 | + return { | |
17 | + staticLogo: '../../static/logo.png', | |
18 | + mpOwnConfig: {} | |
19 | + }; | |
20 | + }, | |
21 | + onLoad() { | |
22 | + this.getPlateForm(); | |
23 | + if (!this.userInfo.isToken) { | |
24 | + setTimeout(() => { | |
25 | + uni.reLaunch({ | |
26 | + url: '/publicLoginSubPage/public/login' | |
27 | + }); | |
28 | + }, 2500); | |
29 | + } else { | |
30 | + setTimeout(() => { | |
31 | + uni.reLaunch({ | |
32 | + url: '/pages/index/index' | |
33 | + }); | |
34 | + }, 2500); | |
35 | + } | |
36 | + }, | |
37 | + computed: { | |
38 | + ...mapState(['userInfo']) | |
39 | + }, | |
40 | + methods: { | |
41 | + getPlateForm() { | |
42 | + uni.$u.http.get('/yt/app_design/get').then(res => { | |
43 | + if (res) { | |
44 | + this.mpOwnConfig = { | |
45 | + bg: res.background, | |
46 | + logo: res.logo, | |
47 | + name: res.name | |
48 | + }; | |
49 | + } | |
25 | 50 | }); |
26 | - }, 2500); | |
27 | - } else { | |
28 | - setTimeout(() => { | |
29 | - uni.reLaunch({ | |
30 | - url: '/pages/index/index' | |
31 | - }); | |
32 | - }, 2500); | |
33 | - } | |
34 | - }, | |
35 | - computed: { | |
36 | - ...mapState(['userInfo']) | |
37 | - }, | |
38 | - methods: { | |
39 | - getPlateForm() { | |
40 | - uni.$u.http.get('/yt/app_design/get').then(res => { | |
41 | - if (res) { | |
42 | - this.mpOwnConfig = { | |
43 | - bg: res.background, | |
44 | - logo: res.logo, | |
45 | - name: res.name | |
46 | - }; | |
47 | - } | |
48 | - }); | |
51 | + } | |
49 | 52 | } |
50 | - } | |
51 | -}; | |
53 | + }; | |
52 | 54 | </script> |
53 | 55 | |
54 | -<style lang="less"> | |
55 | -.container { | |
56 | - width: 100%; | |
57 | - height: 100%; | |
58 | - margin-top: 300rpx; | |
59 | - .container-box { | |
60 | - display: flex; | |
61 | - align-items: center; | |
62 | - justify-content: space-between; | |
63 | - flex-direction: column; | |
64 | - image { | |
65 | - width: 100rpx; | |
66 | - height: 100rpx; | |
67 | - } | |
68 | - text { | |
56 | +<style lang="scss"> | |
57 | + .container { | |
58 | + width: 100%; | |
59 | + height: 100%; | |
60 | + margin-top: 300rpx; | |
61 | + | |
62 | + .container-box { | |
63 | + display: flex; | |
64 | + align-items: center; | |
65 | + justify-content: space-between; | |
66 | + flex-direction: column; | |
67 | + | |
68 | + image { | |
69 | + width: 100rpx; | |
70 | + height: 100rpx; | |
71 | + } | |
72 | + | |
73 | + text {} | |
69 | 74 | } |
70 | 75 | } |
71 | -} | |
72 | 76 | </style> | ... | ... |
... | ... | @@ -51,6 +51,8 @@ |
51 | 51 | </template> |
52 | 52 | |
53 | 53 | <script> |
54 | + import api from '@/api/index.js' | |
55 | + | |
54 | 56 | var clear; |
55 | 57 | export default { |
56 | 58 | data() { |
... | ... | @@ -109,8 +111,7 @@ |
109 | 111 | } |
110 | 112 | let httpData = {}; |
111 | 113 | // 获取验证码接口 |
112 | - uni.$u.http | |
113 | - .post(`/yt/noauth/reset_code/${this.phone}`) | |
114 | + api.loginApi.postCodeApi(this.phone) | |
114 | 115 | .then(res => { |
115 | 116 | this.getCodeState(); //开始倒计时 |
116 | 117 | }) |
... | ... | @@ -177,24 +178,17 @@ |
177 | 178 | phoneNumber: this.phone, |
178 | 179 | userId: this.vCode |
179 | 180 | }; |
180 | - uni.$u.http | |
181 | - .post(`/yt/noauth/reset/${this.phone}`, httpData) | |
182 | - .then(res => { | |
183 | - uni.showToast({ | |
184 | - title: '重置密码成功~', | |
185 | - icon: 'none' | |
186 | - }).then(res => { | |
187 | - uni.reLaunch({ | |
188 | - url: '/publicLoginSubPage/public/login' | |
189 | - }); | |
190 | - }); | |
191 | - }) | |
192 | - .catch(err => { | |
193 | - uni.showToast({ | |
194 | - title: err.data.msg, | |
195 | - icon: 'none' | |
181 | + const res = api.loginApi.postResetCodeApi(this.phone, httpData) | |
182 | + if (res) { | |
183 | + uni.showToast({ | |
184 | + title: '重置密码成功~', | |
185 | + icon: 'none' | |
186 | + }).then(res => { | |
187 | + uni.reLaunch({ | |
188 | + url: '/publicLoginSubPage/public/login' | |
196 | 189 | }); |
197 | 190 | }); |
191 | + } | |
198 | 192 | }, |
199 | 193 | showPasswordMode() { |
200 | 194 | this.showPasswordF = !this.showPasswordF; | ... | ... |
... | ... | @@ -3,8 +3,12 @@ |
3 | 3 | <!-- 公共组件-每个页面必须引入 --> |
4 | 4 | <public-module></public-module> |
5 | 5 | <view @click="upAvatar" class="u-flex set-main"> |
6 | - <view class="main-image"><image class="image" :src="avatar || '../../static/logo.png'"></image></view> | |
7 | - <view class="main-right-image"><image class="image" src="../../static/arrow-right.png"></image></view> | |
6 | + <view class="main-image"> | |
7 | + <image class="image" :src="avatar || '../../static/logo.png'"></image> | |
8 | + </view> | |
9 | + <view class="main-right-image"> | |
10 | + <image class="image" src="../../static/arrow-right.png"></image> | |
11 | + </view> | |
8 | 12 | </view> |
9 | 13 | <view class="u-m-t-20 basic-text"><text class="text">基本资料</text></view> |
10 | 14 | <view class="basic-main"> |
... | ... | @@ -21,43 +25,28 @@ |
21 | 25 | <u-form-item labelWidth="80px" label="邮箱地址" prop="email" borderBottom ref="item1"> |
22 | 26 | <u--input placeholder="请输入邮箱地址" v-model="myInfoModel.email" border="none"></u--input> |
23 | 27 | </u-form-item> |
24 | - <u-form-item | |
25 | - @click=" | |
28 | + <u-form-item @click=" | |
26 | 29 | showDate = true; |
27 | 30 | hideKeyboard(); |
28 | - " | |
29 | - labelWidth="80px" | |
30 | - label="有效期" | |
31 | - prop="accountExpireTime" | |
32 | - ref="item1" | |
33 | - > | |
31 | + " labelWidth="80px" label="有效期" prop="accountExpireTime" ref="item1"> | |
34 | 32 | <u--input v-model="myInfoModel.accountExpireTime" placeholder="请选择有效期" border="none"></u--input> |
35 | - <u-datetime-picker | |
36 | - :formatter="formatter" | |
37 | - :show="showDate" | |
38 | - :value="datetime" | |
39 | - mode="dateTime" | |
40 | - closeOnClickOverlay | |
41 | - @confirm="dateConfirm" | |
42 | - @cancel="dateClose" | |
43 | - @close="dateClose" | |
44 | - ></u-datetime-picker> | |
33 | + <u-datetime-picker :formatter="formatter" :show="showDate" :value="datetime" mode="dateTime" | |
34 | + closeOnClickOverlay @confirm="dateConfirm" @cancel="dateClose" @close="dateClose"> | |
35 | + </u-datetime-picker> | |
45 | 36 | </u-form-item> |
46 | 37 | </u--form> |
47 | 38 | </view> |
48 | 39 | <view class="basic-bottom u-flex"> |
49 | 40 | <view class="item" v-if="info.data.isThirdLoginAndNoDind && isJudgeBindBtn"> |
50 | - <button class="submit" size="default" @click="clearAccountFunc" :style="{ background: InfoColor }"><text class="un-bind-text">解绑</text></button> | |
41 | + <button class="submit" size="default" @click="clearAccountFunc" :style="{ background: InfoColor }"><text | |
42 | + class="un-bind-text">解绑</text></button> | |
51 | 43 | </view> |
52 | - <view | |
53 | - class="item" | |
54 | - style="margin-right: 60rpx;" | |
55 | - :style="[ | |
44 | + <view class="item" style="margin-right: 60rpx;" :style="[ | |
56 | 45 | { position: info.data.isThirdLoginAndNoDind && isJudgeBindBtn ? '' : 'relative' }, |
57 | 46 | { right: info.data.isThirdLoginAndNoDind && isJudgeBindBtn ? '' : '-190rpx' } |
58 | - ]" | |
59 | - > | |
60 | - <button class="submit" size="default" @click="onSubmitFunc" :style="{ background: PrimaryColor }"><text class="un-bind-text">确认</text></button> | |
47 | + ]"> | |
48 | + <button class="submit" size="default" @click="onSubmitFunc" :style="{ background: PrimaryColor }"><text | |
49 | + class="un-bind-text">确认</text></button> | |
61 | 50 | </view> |
62 | 51 | </view> |
63 | 52 | <!-- #ifdef MP --> |
... | ... | @@ -78,258 +67,256 @@ |
78 | 67 | </template> |
79 | 68 | |
80 | 69 | <script> |
81 | -import { mapMutations } from 'vuex'; | |
82 | -import baseUrl from '@/config/baseUrl.js'; | |
83 | -import { mapState } from 'vuex'; | |
70 | + import { | |
71 | + mapMutations | |
72 | + } from 'vuex'; | |
73 | + import baseUrl from '@/config/baseUrl.js'; | |
74 | + import { | |
75 | + mapState | |
76 | + } from 'vuex'; | |
77 | + import api from '@/api/index.js' | |
84 | 78 | |
85 | -export default { | |
86 | - data() { | |
87 | - return { | |
88 | - showBind: false, | |
89 | - PrimaryColor: '#377DFF', //主题色 | |
90 | - InfoColor: '#00C9A7', //主题色 | |
91 | - myInfoModel: { | |
92 | - realName: '', | |
93 | - phoneNumber: '', | |
94 | - username: '', | |
95 | - email: '', | |
96 | - accountExpireTime: '' | |
97 | - }, | |
79 | + export default { | |
80 | + data() { | |
81 | + return { | |
82 | + showBind: false, | |
83 | + PrimaryColor: '#377DFF', //主题色 | |
84 | + InfoColor: '#00C9A7', //主题色 | |
85 | + myInfoModel: { | |
86 | + realName: '', | |
87 | + phoneNumber: '', | |
88 | + username: '', | |
89 | + email: '', | |
90 | + accountExpireTime: '' | |
91 | + }, | |
98 | 92 | |
99 | - rules: { | |
100 | - phoneNumber: [ | |
101 | - { | |
102 | - required: true, | |
103 | - message: '请输入正确的手机号码', | |
104 | - trigger: 'change' | |
105 | - }, | |
106 | - { | |
107 | - pattern: /^1[3-9][0-9]{9}$/, | |
108 | - message: '请输入正确的手机号码' | |
109 | - } | |
110 | - ], | |
111 | - email: [ | |
112 | - { | |
113 | - required: true, | |
114 | - message: '请输入正确的邮箱号', | |
115 | - trigger: 'change' | |
116 | - }, | |
117 | - { | |
118 | - pattern: /^[0-9a-zA-Z]+@(([0-9a-zA-Z]+)[.])+[a-z]{3}$/, | |
119 | - message: '请输入正确的邮箱号' | |
120 | - } | |
121 | - ] | |
122 | - }, | |
123 | - showDate: false, | |
124 | - dateTime: Number(new Date()), | |
125 | - avatar: '', | |
126 | - id: '', | |
127 | - info: {}, | |
128 | - openIds: '', | |
129 | - isUpdatePersonOrLoginInfo: false, | |
130 | - isJudgeBindBtn: true | |
131 | - }; | |
132 | - }, | |
133 | - onReady() { | |
134 | - this.$refs.myForm.setRules(this.rules); | |
135 | - }, | |
136 | - onLoad(e) { | |
137 | - console.log(e); | |
138 | - if (e.data !== null) { | |
139 | - let params = JSON.parse(e.data); | |
140 | - this.info = params; | |
141 | - this.myInfoModel.realName = params.data.realName; | |
142 | - this.myInfoModel.phoneNumber = params.data.phoneNumber; | |
143 | - this.myInfoModel.username = params.data.username; | |
144 | - this.myInfoModel.email = params.data.email; | |
145 | - this.myInfoModel.accountExpireTime = params.data.accountExpireTime; | |
146 | - this.avatar = params.data.avatar == undefined ? '../../static/logo.png' : params.data.avatar; | |
147 | - this.id = params.data.userId; | |
148 | - } | |
149 | - }, | |
150 | - onShow() { | |
151 | - let getOpenId = getApp().globalData.openId; | |
152 | - if (getOpenId) { | |
153 | - this.openIds = getOpenId; | |
154 | - console.log('OPenid', this.openIds); | |
155 | - } | |
156 | - }, | |
157 | - computed: { | |
158 | - ...mapState(['userInfo']) | |
159 | - }, | |
160 | - methods: { | |
161 | - ...mapMutations(['setUserInfo', 'emptyUserInfo']), | |
162 | - confrimBind(e) { | |
163 | - if (e) { | |
164 | - //解绑 | |
165 | - let httpData = { | |
166 | - appUserId: e.data?.userId, | |
167 | - thirdUserId: e.data?.thirdUserId == null ? this.openIds : e.data?.thirdUserId | |
168 | - }; | |
169 | - uni.$u.http.delete('/yt/third', httpData).then(res => { | |
170 | - if (res) { | |
171 | - uni.showToast({ | |
172 | - title: '解绑成功' | |
173 | - }); | |
174 | - this.showBind = false; | |
175 | - this.isJudgeBindBtn = false; | |
176 | - uni.reLaunch({ | |
177 | - url: '/publicLoginSubPage/public/login' | |
178 | - }); | |
179 | - this.emptyUserInfo(); | |
180 | - } else { | |
181 | - uni.showToast({ | |
182 | - title: '解绑失败' | |
183 | - }); | |
184 | - this.showBind = false; | |
185 | - } | |
186 | - }); | |
93 | + rules: { | |
94 | + phoneNumber: [{ | |
95 | + required: true, | |
96 | + message: '请输入正确的手机号码', | |
97 | + trigger: 'change' | |
98 | + }, | |
99 | + { | |
100 | + pattern: /^1[3-9][0-9]{9}$/, | |
101 | + message: '请输入正确的手机号码' | |
102 | + } | |
103 | + ], | |
104 | + email: [{ | |
105 | + required: true, | |
106 | + message: '请输入正确的邮箱号', | |
107 | + trigger: 'change' | |
108 | + }, | |
109 | + { | |
110 | + pattern: /^[0-9a-zA-Z]+@(([0-9a-zA-Z]+)[.])+[a-z]{3}$/, | |
111 | + message: '请输入正确的邮箱号' | |
112 | + } | |
113 | + ] | |
114 | + }, | |
115 | + showDate: false, | |
116 | + dateTime: Number(new Date()), | |
117 | + avatar: '', | |
118 | + id: '', | |
119 | + info: {}, | |
120 | + openIds: '', | |
121 | + isUpdatePersonOrLoginInfo: false, | |
122 | + isJudgeBindBtn: true | |
123 | + }; | |
124 | + }, | |
125 | + onReady() { | |
126 | + this.$refs.myForm.setRules(this.rules); | |
127 | + }, | |
128 | + onLoad(e) { | |
129 | + console.log(e); | |
130 | + if (e.data !== null) { | |
131 | + let params = JSON.parse(e.data); | |
132 | + this.info = params; | |
133 | + this.myInfoModel.realName = params.data.realName; | |
134 | + this.myInfoModel.phoneNumber = params.data.phoneNumber; | |
135 | + this.myInfoModel.username = params.data.username; | |
136 | + this.myInfoModel.email = params.data.email; | |
137 | + this.myInfoModel.accountExpireTime = params.data.accountExpireTime; | |
138 | + this.avatar = params.data.avatar == undefined ? '../../static/logo.png' : params.data.avatar; | |
139 | + this.id = params.data.userId; | |
187 | 140 | } |
188 | 141 | }, |
189 | - clearAccountFunc() { | |
190 | - this.showBind = true; | |
142 | + onShow() { | |
143 | + let getOpenId = getApp().globalData.openId; | |
144 | + if (getOpenId) { | |
145 | + this.openIds = getOpenId; | |
146 | + console.log('OPenid', this.openIds); | |
147 | + } | |
191 | 148 | }, |
192 | - // 修改头像 | |
193 | - async upAvatar() { | |
194 | - let token; | |
195 | - token = this.userInfo.isToken || uni.getStorageSync('userInfo').isToken || undefined; | |
196 | - // #ifdef H5 | |
197 | - token = window.sessionStorage.getItem('userInfo').isToken; | |
198 | - // #endif | |
199 | - if (!token) return uni.$u.toast('请登录后上传图片'); | |
200 | - uni.chooseImage({ | |
201 | - count: 1, | |
202 | - sourceType: ['camera', 'album'], | |
203 | - success: res => { | |
204 | - const tempFilePaths = res.tempFilePaths; | |
205 | - //限制上传的图片大小不超过5M | |
206 | - let resSize = res.tempFiles[0].size; | |
207 | - if (resSize > 5242880) { | |
208 | - uni.showToast({ | |
209 | - title: '上传的图片大小不能超过5M', | |
210 | - icon: 'none', | |
211 | - duration: 2000, | |
212 | - mask: true | |
213 | - }); | |
214 | - return; | |
215 | - } | |
216 | - //获取图片扩展名 | |
217 | - const fileTxt = res.tempFilePaths[0].split('.').pop(); | |
218 | - const judgeType = fileTxt == 'jpg' || fileTxt == 'jpeg' || fileTxt == 'png'; | |
219 | - if (!judgeType) { | |
220 | - uni.showToast({ | |
221 | - title: '请上传指定图片类型(jpg、jpeg、png)', | |
222 | - icon: 'none', | |
223 | - duration: 2000, | |
224 | - mask: true | |
225 | - }); | |
226 | - return; | |
227 | - } | |
228 | - uni.uploadFile({ | |
229 | - url: `${baseUrl.baseUrl}/yt/oss/upload`, | |
230 | - filePath: tempFilePaths[0], | |
231 | - name: 'file', | |
232 | - header: { | |
233 | - 'content-type': 'multipart/form-data', | |
234 | - Authorization: 'Bearer ' + token | |
235 | - }, | |
236 | - formData: {}, | |
237 | - success: res => { | |
238 | - let objImage = JSON.parse(res.data); | |
239 | - this.avatar = objImage.fileStaticUri; | |
240 | - uni.$u.toast('头像上传成功'); | |
149 | + computed: { | |
150 | + ...mapState(['userInfo']) | |
151 | + }, | |
152 | + methods: { | |
153 | + ...mapMutations(['setUserInfo', 'emptyUserInfo']), | |
154 | + confrimBind(e) { | |
155 | + if (e) { | |
156 | + //解绑 | |
157 | + let httpData = { | |
158 | + appUserId: e.data?.userId, | |
159 | + thirdUserId: e.data?.thirdUserId == null ? this.openIds : e.data?.thirdUserId | |
160 | + }; | |
161 | + api.loginApi.deleteBindApi(httpData).then(res => { | |
162 | + if (res) { | |
163 | + uni.showToast({ | |
164 | + title: '解绑成功' | |
165 | + }); | |
166 | + this.showBind = false; | |
167 | + this.isJudgeBindBtn = false; | |
168 | + uni.reLaunch({ | |
169 | + url: '/publicLoginSubPage/public/login' | |
170 | + }); | |
171 | + this.emptyUserInfo(); | |
172 | + } else { | |
173 | + uni.showToast({ | |
174 | + title: '解绑失败' | |
175 | + }); | |
176 | + this.showBind = false; | |
241 | 177 | } |
242 | 178 | }); |
243 | 179 | } |
244 | - }); | |
245 | - }, | |
246 | - onSubmitFunc() { | |
247 | - let httpData = { | |
248 | - avatar: this.avatar, | |
249 | - email: this.myInfoModel.email, | |
250 | - id: this.id, | |
251 | - phoneNumber: this.myInfoModel.phoneNumber, | |
252 | - realName: this.myInfoModel.realName | |
253 | - }; | |
254 | - this.$refs.myForm | |
255 | - .validate() | |
256 | - .then(res => { | |
257 | - uni.$u.http | |
258 | - .put('/yt/user/center', httpData) | |
259 | - .then(res => { | |
260 | - if (res) { | |
261 | - this.setUserInfo(res); | |
262 | - uni.showToast({ | |
263 | - title: '更新个人资料成功~', | |
264 | - icon: 'none' | |
265 | - }); | |
266 | - setTimeout(() => { | |
267 | - uni.navigateBack({ | |
268 | - delta: 1 | |
269 | - }); | |
270 | - }, 500); | |
180 | + }, | |
181 | + clearAccountFunc() { | |
182 | + this.showBind = true; | |
183 | + }, | |
184 | + // 修改头像 | |
185 | + async upAvatar() { | |
186 | + let token; | |
187 | + token = this.userInfo.isToken || uni.getStorageSync('userInfo').isToken || undefined; | |
188 | + // #ifdef H5 | |
189 | + token = window.sessionStorage.getItem('userInfo').isToken; | |
190 | + // #endif | |
191 | + if (!token) return uni.$u.toast('请登录后上传图片'); | |
192 | + uni.chooseImage({ | |
193 | + count: 1, | |
194 | + sourceType: ['camera', 'album'], | |
195 | + success: res => { | |
196 | + const tempFilePaths = res.tempFilePaths; | |
197 | + //限制上传的图片大小不超过5M | |
198 | + let resSize = res.tempFiles[0].size; | |
199 | + if (resSize > 5242880) { | |
200 | + uni.showToast({ | |
201 | + title: '上传的图片大小不能超过5M', | |
202 | + icon: 'none', | |
203 | + duration: 2000, | |
204 | + mask: true | |
205 | + }); | |
206 | + return; | |
207 | + } | |
208 | + //获取图片扩展名 | |
209 | + const fileTxt = res.tempFilePaths[0].split('.').pop(); | |
210 | + const judgeType = fileTxt == 'jpg' || fileTxt == 'jpeg' || fileTxt == 'png'; | |
211 | + if (!judgeType) { | |
212 | + uni.showToast({ | |
213 | + title: '请上传指定图片类型(jpg、jpeg、png)', | |
214 | + icon: 'none', | |
215 | + duration: 2000, | |
216 | + mask: true | |
217 | + }); | |
218 | + return; | |
219 | + } | |
220 | + uni.uploadFile({ | |
221 | + url: `${baseUrl.baseUrl}/yt/oss/upload`, | |
222 | + filePath: tempFilePaths[0], | |
223 | + name: 'file', | |
224 | + header: { | |
225 | + 'content-type': 'multipart/form-data', | |
226 | + Authorization: 'Bearer ' + token | |
227 | + }, | |
228 | + formData: {}, | |
229 | + success: res => { | |
230 | + let objImage = JSON.parse(res.data); | |
231 | + this.avatar = objImage.fileStaticUri; | |
232 | + uni.$u.toast('头像上传成功'); | |
271 | 233 | } |
272 | - }) | |
273 | - .catch(e => { | |
274 | - uni.$u.toast(e.data.message); | |
275 | 234 | }); |
276 | - }) | |
277 | - .catch(errors => { | |
278 | - uni.$u.toast('校验失败'); | |
235 | + } | |
279 | 236 | }); |
280 | - }, | |
281 | - dateClose() { | |
282 | - this.showDate = false; | |
283 | - }, | |
284 | - dateConfirm(e) { | |
285 | - this.showDate = false; | |
286 | - this.myInfoModel.userInfo.accountExpireTime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss'); | |
287 | - }, | |
288 | - //格式化日期 | |
289 | - formatter(type, value) { | |
290 | - if (type === 'year') { | |
291 | - return `${value}年`; | |
292 | - } | |
293 | - if (type === 'month') { | |
294 | - return `${value}月`; | |
295 | - } | |
296 | - if (type === 'day') { | |
297 | - return `${value}日`; | |
298 | - } | |
299 | - if (type === 'hour') { | |
300 | - return `${value}时`; | |
301 | - } | |
302 | - if (type === 'minute') { | |
303 | - return `${value}分`; | |
237 | + }, | |
238 | + onSubmitFunc() { | |
239 | + let httpData = { | |
240 | + avatar: this.avatar, | |
241 | + email: this.myInfoModel.email, | |
242 | + id: this.id, | |
243 | + phoneNumber: this.myInfoModel.phoneNumber, | |
244 | + realName: this.myInfoModel.realName | |
245 | + }; | |
246 | + this.$refs.myForm | |
247 | + .validate() | |
248 | + .then(async res => { | |
249 | + const resp = await api.loginApi.postPersonalInfoApi(httpData) | |
250 | + if (res) { | |
251 | + this.setUserInfo(resp); | |
252 | + uni.showToast({ | |
253 | + title: '更新个人资料成功~', | |
254 | + icon: 'none' | |
255 | + }); | |
256 | + setTimeout(() => { | |
257 | + uni.navigateBack({ | |
258 | + delta: 1 | |
259 | + }); | |
260 | + }, 500); | |
261 | + } | |
262 | + }) | |
263 | + .catch(errors => { | |
264 | + uni.$u.toast('校验失败'); | |
265 | + }); | |
266 | + }, | |
267 | + dateClose() { | |
268 | + this.showDate = false; | |
269 | + }, | |
270 | + dateConfirm(e) { | |
271 | + this.showDate = false; | |
272 | + this.myInfoModel.userInfo.accountExpireTime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss'); | |
273 | + }, | |
274 | + //格式化日期 | |
275 | + formatter(type, value) { | |
276 | + if (type === 'year') { | |
277 | + return `${value}年`; | |
278 | + } | |
279 | + if (type === 'month') { | |
280 | + return `${value}月`; | |
281 | + } | |
282 | + if (type === 'day') { | |
283 | + return `${value}日`; | |
284 | + } | |
285 | + if (type === 'hour') { | |
286 | + return `${value}时`; | |
287 | + } | |
288 | + if (type === 'minute') { | |
289 | + return `${value}分`; | |
290 | + } | |
291 | + return value; | |
292 | + }, | |
293 | + //隐藏输入框 | |
294 | + hideKeyboard() { | |
295 | + uni.hideKeyboard(); | |
304 | 296 | } |
305 | - return value; | |
306 | - }, | |
307 | - //隐藏输入框 | |
308 | - hideKeyboard() { | |
309 | - uni.hideKeyboard(); | |
310 | 297 | } |
311 | - } | |
312 | -}; | |
298 | + }; | |
313 | 299 | </script> |
314 | 300 | |
315 | 301 | <style lang="scss" scoped> |
316 | -.userName { | |
317 | - background-color: green; | |
318 | -} | |
319 | -@import './static/set.scss'; | |
302 | + .userName { | |
303 | + background-color: green; | |
304 | + } | |
320 | 305 | |
321 | -/deep/ .u-line { | |
322 | - width: 662rpx !important; | |
323 | -} | |
306 | + @import './static/set.scss'; | |
324 | 307 | |
325 | -/deep/ .u-form-item { | |
326 | - height: 100rpx !important; | |
327 | -} | |
308 | + /deep/ .u-line { | |
309 | + width: 662rpx !important; | |
310 | + } | |
311 | + | |
312 | + /deep/ .u-form-item { | |
313 | + height: 100rpx !important; | |
314 | + } | |
328 | 315 | |
329 | -/deep/ .u-form-item:nth-child(3) { | |
330 | - .u-form-item__body { | |
331 | - background: #f5f7fa !important; | |
332 | - width: 663rpx !important; | |
316 | + /deep/ .u-form-item:nth-child(3) { | |
317 | + .u-form-item__body { | |
318 | + background: #f5f7fa !important; | |
319 | + width: 663rpx !important; | |
320 | + } | |
333 | 321 | } |
334 | -} | |
335 | 322 | </style> | ... | ... |
1 | 1 | <template> |
2 | - <view class="login-page" style="background-size: 100% 100%; min-height: 100vh" :style="{ | |
2 | + <view class="login-page" :style="{ | |
3 | 3 | backgroundImage: |
4 | 4 | 'url(' + |
5 | 5 | (mpOwnConfig.bg !== undefined ? mpOwnConfig.bg : `${defaultLogo}`) + |
... | ... | @@ -10,8 +10,7 @@ |
10 | 10 | <view class="u-flex login-main"> |
11 | 11 | <view class="content"> |
12 | 12 | <view class="hello login-text-muted">您好,</view> |
13 | - <!-- <view class="hello-welcome login-text-muted">欢迎来到ThingsKit!</view> --> | |
14 | - <view style="width: 587rpx" class="text-clip hello-welcome login-text-muted">欢迎来到{{ | |
13 | + <view style="width: 587rpx;" class="text-clip hello-welcome login-text-muted">欢迎来到{{ | |
15 | 14 | mpOwnConfig.name !== undefined ? mpOwnConfig.name : "ThingsKit" |
16 | 15 | }}!</view> |
17 | 16 | </view> |
... | ... | @@ -22,7 +21,6 @@ |
22 | 21 | <view class="form-row u-flex"> |
23 | 22 | <u-input v-model="loginForm.username" type="text" placeholder="请输入登录账号" border="bottom" /> |
24 | 23 | </view> |
25 | - | |
26 | 24 | <view class="form-row u-flex"> |
27 | 25 | <u-input v-model="loginForm.password" :password="showPassword" placeholder="请输入登录密码" |
28 | 26 | border="bottom"> |
... | ... | @@ -35,29 +33,25 @@ |
35 | 33 | </template> |
36 | 34 | </u-input> |
37 | 35 | </view> |
38 | - | |
39 | 36 | <button class="submit" size="default" @click="onSubmitFunc"> |
40 | 37 | <text class="text">登录</text> |
41 | 38 | </button> |
42 | - | |
43 | 39 | <view class="u-flex row-item"> |
44 | 40 | <view class="row-phone login-text-gray" @click="openCodeFunc">手机验证码登录</view> |
45 | - | |
46 | 41 | <view class="row-reset login-text-gray" @click="findPassrordFunc">忘记密码</view> |
47 | 42 | </view> |
48 | - | |
49 | 43 | <view class="u-flex link-login"> |
50 | 44 | <view class="link-text login-text-gray">第三方账号登录</view> |
51 | - | |
52 | 45 | <view style="height: 20rpx"></view> |
53 | - | |
54 | - <button class="link-image" @tap="onWenxinAuthorization"> | |
46 | + <!-- #ifdef MP-WEIXIN --> | |
47 | + <button class="link-image" @tap="handleWenxinAuthorization"> | |
55 | 48 | <image class="image" src="../../static/weixin.png" mode="aspectFill"></image> |
56 | 49 | </button> |
50 | + <!-- #endif --> | |
57 | 51 | <!-- #ifdef APP-PLUS --> |
58 | - <!-- <button class="link-image" @click="onWenxinAppAuthorization"> | |
52 | + <button class="link-image" @click="handleAppPlusAuthorization"> | |
59 | 53 | <image class="image" src="../../static/weixin.png" mode="aspectFill"></image> |
60 | - </button> --> | |
54 | + </button> | |
61 | 55 | <!-- #endif --> |
62 | 56 | </view> |
63 | 57 | </view> |
... | ... | @@ -71,18 +65,13 @@ |
71 | 65 | mapActions, |
72 | 66 | mapState |
73 | 67 | } from "vuex"; |
74 | - import { | |
75 | - loginApp | |
76 | - } from "@/config/login"; | |
77 | - import baseUrl from "@/config/baseUrl.js"; | |
78 | - import WXBizDataCrypt from "@/config/WXBizDataCrypt.js"; | |
68 | + import api from '@/api' | |
79 | 69 | |
80 | 70 | export default { |
81 | 71 | data() { |
82 | 72 | return { |
83 | 73 | loginForm: { |
84 | 74 | username: "", |
85 | - | |
86 | 75 | password: "", |
87 | 76 | }, |
88 | 77 | showPassword: true, |
... | ... | @@ -117,25 +106,24 @@ |
117 | 106 | }, |
118 | 107 | methods: { |
119 | 108 | //获取平台定制信息 |
120 | - getPlateForm() { | |
121 | - uni.$u.http.get("/yt/app_design/get").then((res) => { | |
122 | - if (res) { | |
123 | - this.mpOwnConfig = { | |
124 | - bg: res.background, | |
125 | - logo: res.logo, | |
126 | - name: res.name, | |
127 | - }; | |
128 | - } | |
129 | - }); | |
109 | + async getPlateForm() { | |
110 | + const res = await api.loginApi.getPlateCustomApi() | |
111 | + if (res) { | |
112 | + this.mpOwnConfig = { | |
113 | + bg: res.background, | |
114 | + logo: res.logo, | |
115 | + name: res.name, | |
116 | + }; | |
117 | + } | |
130 | 118 | }, |
131 | 119 | ...mapMutations(["setUserInfo", "setPlateInfo"]), |
132 | 120 | ...mapActions(["updateBadgeTotal"]), |
133 | 121 | //微信授权登录 |
134 | 122 | //#ifdef MP-WEIXIN |
135 | - onWenxinAuthorization() { | |
123 | + handleWenxinAuthorization() { | |
136 | 124 | wx.getUserProfile({ |
137 | 125 | desc: "微信第三方授权", |
138 | - success: (reswenxin) => { | |
126 | + success: async (reswenxin) => { | |
139 | 127 | if ( |
140 | 128 | reswenxin.errMsg === "getUserProfile:ok" && |
141 | 129 | reswenxin.encryptedData |
... | ... | @@ -145,99 +133,81 @@ |
145 | 133 | avatarUrl: reswenxin.userInfo.avatarUrl, |
146 | 134 | thirdUserId: this.openid, |
147 | 135 | }; |
148 | - //判断是否需要绑定 | |
149 | - uni.$u.http | |
150 | - .get(`/yt/third/login/${this.code}`) | |
151 | - .then((res) => { | |
152 | - if (res.token == "" || (res.token == null && res.thirdUserId)) { | |
153 | - //需要绑定 | |
154 | - let userInfo = { | |
155 | - isThirdLogin: true, //用于判断是否是第三方登录并且需要绑定账号 | |
156 | - avatar: obj.avatarUrl, | |
157 | - thirdUserId: res.thirdUserId, | |
158 | - }; | |
159 | - this.setUserInfo(userInfo); | |
160 | - //设置全局变量openId | |
161 | - getApp().globalData.openId = res.thirdUserId; | |
136 | + const res = await api.loginApi.getThirdLoginApi(this.code) | |
137 | + if (res.token == "" || (res.token == null && res.thirdUserId)) { | |
138 | + //需要绑定 | |
139 | + let userInfo = { | |
140 | + isThirdLogin: true, //用于判断是否是第三方登录并且需要绑定账号 | |
141 | + avatar: obj.avatarUrl, | |
142 | + thirdUserId: res.thirdUserId, | |
143 | + }; | |
144 | + this.setUserInfo(userInfo); | |
145 | + //设置全局变量openId | |
146 | + getApp().globalData.openId = res.thirdUserId; | |
147 | + uni.reLaunch({ | |
148 | + url: "../../pages/personal/personal", | |
149 | + }); | |
150 | + } else { | |
151 | + // 不需要绑定,直接第三方登录使用 | |
152 | + let resObj = { | |
153 | + refreshToken: res.refreshToken, | |
154 | + isToken: res.token, | |
155 | + }; | |
156 | + let userInfo = { | |
157 | + ...resObj, | |
158 | + token: true, //token用于判断是否登录 | |
159 | + isThirdLoginAndNoDind: true, //用于判断是否是第三方登录并且不需要绑定账号 | |
160 | + thirdUserId: res.thirdUserId, | |
161 | + }; | |
162 | + //设置全局变量openId | |
163 | + getApp().globalData.openId = res.thirdUserId; | |
164 | + if (userInfo.token) { | |
165 | + this.setUserInfo(userInfo); | |
166 | + } | |
167 | + uni | |
168 | + .showToast({ | |
169 | + title: "第三方账号登录成功", | |
170 | + icon: "none", | |
171 | + }) | |
172 | + .then(async (res) => { | |
173 | + this.saveUserInfo(); | |
174 | + await this.getAlarmTotalData(); | |
162 | 175 | uni.reLaunch({ |
163 | - url: "../../pages/personal/personal", | |
176 | + url: "/pages/personal/personal", | |
164 | 177 | }); |
165 | - } else { | |
166 | - // 不需要绑定,直接第三方登录使用 | |
167 | - let resObj = { | |
168 | - refreshToken: res.refreshToken, | |
169 | - isToken: res.token, | |
170 | - }; | |
171 | - let userInfo = { | |
172 | - ...resObj, | |
173 | - token: true, //token用于判断是否登录 | |
174 | - isThirdLoginAndNoDind: true, //用于判断是否是第三方登录并且不需要绑定账号 | |
175 | - thirdUserId: res.thirdUserId, | |
176 | - }; | |
177 | - //设置全局变量openId | |
178 | - getApp().globalData.openId = res.thirdUserId; | |
179 | - if (userInfo.token) { | |
180 | - this.setUserInfo(userInfo); | |
181 | - } | |
182 | - uni | |
183 | - .showToast({ | |
184 | - title: "第三方账号登录成功", | |
185 | - icon: "none", | |
186 | - }) | |
187 | - .then(async (res) => { | |
188 | - this.saveUserInfo(); | |
189 | - await this.getAlarmTotalData(); | |
190 | - uni.reLaunch({ | |
191 | - url: "/pages/personal/personal", | |
192 | - }); | |
193 | - }); | |
194 | - } | |
195 | - }) | |
196 | - .catch((e) => { | |
197 | - if (e?.data?.data === null) { | |
198 | - uni.$u.toast(e.data?.msg); | |
199 | - } | |
200 | - }); | |
178 | + }); | |
179 | + } | |
201 | 180 | } |
202 | 181 | }, |
203 | - | |
204 | 182 | fail: (res) => { |
205 | 183 | //拒绝授权 |
206 | - | |
207 | 184 | return; |
208 | 185 | }, |
209 | 186 | }); |
210 | 187 | }, |
211 | 188 | //#endif |
212 | - | |
213 | 189 | //#ifdef APP-PLUS |
214 | - // onWenxinAppAuthorization() { | |
215 | - | |
216 | - // }, | |
190 | + handleAppPlusAuthorization() { | |
191 | + console.log('TODO'); | |
192 | + }, | |
217 | 193 | //#endif |
218 | - | |
219 | - saveUserInfo() { | |
220 | - //储存个人信息 | |
221 | - uni.$u.http.get("/yt/user/me/info").then((res) => { | |
222 | - if (res) { | |
223 | - this.setUserInfo(res); | |
224 | - } | |
225 | - }); | |
226 | - //储存平台信息 | |
227 | - uni.$u.http.get("/yt/platform/get").then((res) => { | |
228 | - if (res) { | |
229 | - this.setPlateInfo(res); | |
230 | - } | |
231 | - }); | |
194 | + async saveUserInfo() { | |
195 | + const userInfoRes = await api.loginApi.setUserInfoApi() | |
196 | + const plateInfoRes = await api.loginApi.setPlateInfoApi() | |
197 | + if (userInfoRes) { | |
198 | + this.setUserInfo(userInfoRes); | |
199 | + } | |
200 | + if (plateInfoRes) { | |
201 | + this.setPlateInfo(plateInfoRes); | |
202 | + } | |
232 | 203 | }, |
233 | 204 | async getAlarmTotalData() { |
234 | - const res = await uni.$u.http.get("/yt/homepage/app?login=true"); | |
205 | + const res = await api.loginApi.getAlarmTotalApi() | |
235 | 206 | if (res) { |
236 | - //异步实时更新告警徽标数 | |
237 | 207 | this.updateBadgeTotal(res.totalAlarm?.activedAlarm); |
238 | 208 | } |
239 | 209 | }, |
240 | - onSubmitFunc() { | |
210 | + async onSubmitFunc() { | |
241 | 211 | if (this.loginForm.username == "") { |
242 | 212 | return uni.$u.toast("请输入登录账号~"); |
243 | 213 | } |
... | ... | @@ -247,12 +217,10 @@ |
247 | 217 | if (this.loginForm.password == "") { |
248 | 218 | uni.showToast({ |
249 | 219 | title: "请输入登录密码~", |
250 | - | |
251 | 220 | icon: "none", |
252 | 221 | }); |
253 | 222 | return; |
254 | 223 | } else if (!passReg.test(this.loginForm.password)) { |
255 | - //uni.showToast,字数过长,会造成手机上显示不完全,官方bug,采用uni.showModal | |
256 | 224 | uni.showModal({ |
257 | 225 | title: "提示", |
258 | 226 | content: "密码格式不正确(至少一个大写英文字母、至少一个小写英文字母、至少一位数字、至少一个特殊字符、最少八个字符)~", |
... | ... | @@ -260,51 +228,35 @@ |
260 | 228 | }); |
261 | 229 | return; |
262 | 230 | } |
263 | - uni.$u.http | |
264 | - .post("/auth/login", this.loginForm) | |
265 | - | |
266 | - .then((res) => { | |
267 | - if (res) { | |
268 | - // 储存登录信息 | |
269 | - | |
270 | - let resObj = { | |
271 | - refreshToken: res.refreshToken, | |
272 | - | |
273 | - isToken: res.token, | |
274 | - }; | |
275 | - | |
276 | - let userInfo = { | |
277 | - ...resObj, | |
278 | - | |
279 | - token: true, //token用于判断是否登录 | |
280 | - | |
281 | - isThirdLogin: false, | |
282 | - isThirdLoginAndNoDind: false, | |
283 | - }; | |
284 | - | |
285 | - if (userInfo.token) { | |
286 | - this.setUserInfo(userInfo); | |
287 | - } | |
288 | - | |
289 | - uni | |
290 | - .showToast({ | |
291 | - title: "登录成功~", | |
292 | - | |
293 | - icon: "none", | |
294 | - }) | |
295 | - .then(async (res) => { | |
296 | - this.saveUserInfo(); | |
297 | - uni.reLaunch({ | |
298 | - url: "/pages/personal/personal", | |
299 | - }); | |
300 | - await this.getAlarmTotalData(); | |
301 | - }); | |
302 | - } | |
303 | - }) | |
304 | - | |
305 | - .catch((e) => { | |
306 | - uni.$u.toast(e.data?.message); | |
307 | - }); | |
231 | + const res = await api.loginApi.postLoginApi(this.loginForm) | |
232 | + if (res) { | |
233 | + // 储存登录信息 | |
234 | + let resObj = { | |
235 | + refreshToken: res.refreshToken, | |
236 | + isToken: res.token, | |
237 | + }; | |
238 | + let userInfo = { | |
239 | + ...resObj, | |
240 | + token: true, //token用于判断是否登录 | |
241 | + isThirdLogin: false, | |
242 | + isThirdLoginAndNoDind: false, | |
243 | + }; | |
244 | + if (userInfo.token) { | |
245 | + this.setUserInfo(userInfo); | |
246 | + } | |
247 | + uni | |
248 | + .showToast({ | |
249 | + title: "登录成功~", | |
250 | + icon: "none", | |
251 | + }) | |
252 | + .then(async (res) => { | |
253 | + await this.saveUserInfo(); | |
254 | + await this.getAlarmTotalData(); | |
255 | + uni.reLaunch({ | |
256 | + url: "/pages/personal/personal", | |
257 | + }); | |
258 | + }); | |
259 | + } | |
308 | 260 | }, |
309 | 261 | openCodeFunc() { |
310 | 262 | uni.navigateTo({ | ... | ... |
... | ... | @@ -4,17 +4,24 @@ |
4 | 4 | <public-module></public-module> |
5 | 5 | <view style="width: 750rpx;height:53rpx;background-color: #f8f9fa;position:fixed;top:0;z-index: 99999;"> |
6 | 6 | <view @click="openTypeClick" style="background-color: #f8f9fa;width: 700rpx;position: relative;top: 35rpx;"> |
7 | - <u--input suffixIcon="arrow-down" shape="circle" disabled v-model="model1.userInfo.type" placeholder="请选择类型" border="surround"></u--input> | |
8 | - <u-action-sheet :show="showType" :actions="actions" title="请选择类型" @close="showType = false" @select="typeSelect"></u-action-sheet> | |
7 | + <u--input suffixIcon="arrow-down" shape="circle" disabled v-model="model1.userInfo.type" | |
8 | + placeholder="请选择类型" border="surround"></u--input> | |
9 | + <u-action-sheet :show="showType" :actions="actions" title="请选择类型" @close="showType = false" | |
10 | + @select="typeSelect"></u-action-sheet> | |
9 | 11 | </view> |
10 | 12 | </view> |
11 | 13 | <view style="height: 110rpx;"></view> |
12 | 14 | <view class="notify-main"> |
13 | - <mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback"> | |
15 | + <mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback" | |
16 | + @up="upCallback"> | |
14 | 17 | <view class="u-flex main"> |
15 | - <view @click="clickNotifyDetail(item, index)" class="u-flex main-item" v-for="(item, index) in list" :key="index"> | |
18 | + <view @click="clickNotifyDetail(item, index)" class="u-flex main-item" v-for="(item, index) in list" | |
19 | + :key="index"> | |
16 | 20 | <view class="u-flex item"> |
17 | - <view class="item-avatar"><u-avatar class="avatar" shape="circle" size="40" :src="item.sysNotice.avatar"></u-avatar></view> | |
21 | + <view class="item-avatar"> | |
22 | + <u-avatar class="avatar" shape="circle" size="40" :src="item.sysNotice.avatar"> | |
23 | + </u-avatar> | |
24 | + </view> | |
18 | 25 | <view class="u-flex item-content"> |
19 | 26 | <text class="text-top text-clip">{{ item.sysNotice.title }}</text> |
20 | 27 | <text class="text-bottom text-clip">{{ item.sysNotice.createTime }}</text> |
... | ... | @@ -22,7 +29,8 @@ |
22 | 29 | </view> |
23 | 30 | <view class="item-right u-flex" style="justify-content: space-between;"> |
24 | 31 | <text class="text">{{ formatType(item.sysNotice) }}</text> |
25 | - <u-badge style="margin-right: 10rpx;" v-if="item.readStatus == '0'" numberType="overflow" isDot /> | |
32 | + <u-badge style="margin-right: 10rpx;" v-if="item.readStatus == '0'" numberType="overflow" | |
33 | + isDot /> | |
26 | 34 | </view> |
27 | 35 | </view> |
28 | 36 | </view> |
... | ... | @@ -32,151 +40,146 @@ |
32 | 40 | </template> |
33 | 41 | |
34 | 42 | <script> |
35 | -import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js'; | |
36 | - | |
37 | -export default { | |
38 | - mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件) | |
43 | + import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js'; | |
44 | + import api from '@/api/index.js' | |
39 | 45 | |
40 | - data() { | |
41 | - return { | |
42 | - model1: { | |
43 | - userInfo: { | |
44 | - type: '' | |
45 | - } | |
46 | - }, | |
47 | - showType: false, | |
48 | - actions: [ | |
49 | - { | |
50 | - name: '全部', | |
51 | - value: '' | |
46 | + export default { | |
47 | + mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件) | |
48 | + data() { | |
49 | + return { | |
50 | + model1: { | |
51 | + userInfo: { | |
52 | + type: '' | |
53 | + } | |
52 | 54 | }, |
53 | - { | |
54 | - name: '会议', | |
55 | - value: 'MEETING' | |
55 | + showType: false, | |
56 | + actions: [{ | |
57 | + name: '全部', | |
58 | + value: '' | |
59 | + }, | |
60 | + { | |
61 | + name: '会议', | |
62 | + value: 'MEETING' | |
63 | + }, | |
64 | + { | |
65 | + name: '公告', | |
66 | + value: 'NOTICE' | |
67 | + }, | |
68 | + { | |
69 | + name: '其他', | |
70 | + value: 'OTHER' | |
71 | + } | |
72 | + ], | |
73 | + page: { | |
74 | + num: 0, | |
75 | + size: 10 | |
56 | 76 | }, |
57 | - { | |
58 | - name: '公告', | |
59 | - value: 'NOTICE' | |
77 | + downOption: { | |
78 | + auto: false //是否在初始化后,自动执行downCallback; 默认true | |
60 | 79 | }, |
61 | - { | |
62 | - name: '其他', | |
63 | - value: 'OTHER' | |
64 | - } | |
65 | - ], | |
66 | - page: { | |
67 | - num: 0, | |
68 | - size: 10 | |
69 | - }, | |
70 | - downOption: { | |
71 | - auto: false //是否在初始化后,自动执行downCallback; 默认true | |
72 | - }, | |
73 | - list: [], | |
74 | - pre: false, | |
75 | - isJudgeNextPage: '', | |
76 | - distance: 0, | |
77 | - scrollDistance: 0 | |
78 | - }; | |
79 | - }, | |
80 | - onLoad(e) { | |
81 | - // 隐藏原生的tabbar | |
82 | - uni.hideTabBar(); | |
83 | - this.pre = false; | |
84 | - uni.removeStorageSync('storagePre'); | |
85 | - }, | |
86 | - onShow() { | |
87 | - this.pre = uni.getStorageSync('storagePre'); | |
88 | - if (this.pre) { | |
89 | - } | |
90 | - }, | |
91 | - onHide() { | |
92 | - uni.removeStorageSync('storagePre'); | |
93 | - }, | |
94 | - methods: { | |
95 | - formatType(e) { | |
96 | - return e?.type == 'OTHER' ? '其他' : e?.type == 'MEETING' ? '会议' : '公告'; | |
97 | - }, | |
98 | - openTypeClick() { | |
99 | - this.showType = true; | |
100 | - uni.hideKeyboard(); | |
80 | + list: [], | |
81 | + pre: false, | |
82 | + isJudgeNextPage: '', | |
83 | + distance: 0, | |
84 | + scrollDistance: 0 | |
85 | + }; | |
101 | 86 | }, |
102 | - typeSelect(e) { | |
103 | - this.isJudgeNextPage = e.value; | |
104 | - this.page.num = 1; | |
105 | - this.model1.userInfo.type = e.name; | |
106 | - this.loadData(1, this.isJudgeNextPage == '' ? null : this.isJudgeNextPage); | |
107 | - uni.pageScrollTo({ | |
108 | - scrollTop: this.scrollDistance + 20, | |
109 | - duration: 50 | |
110 | - }); | |
111 | - uni.pageScrollTo({ | |
112 | - scrollTop: this.scrollDistance - 20, | |
113 | - duration: 50 | |
114 | - }); | |
87 | + onLoad(e) { | |
88 | + // 隐藏原生的tabbar | |
89 | + uni.hideTabBar(); | |
90 | + this.pre = false; | |
91 | + uni.removeStorageSync('storagePre'); | |
115 | 92 | }, |
116 | - onPageScroll(e) { | |
117 | - this.scrollDistance = e.scrollTop; | |
93 | + onShow() { | |
94 | + this.pre = uni.getStorageSync('storagePre'); | |
95 | + if (this.pre) {} | |
118 | 96 | }, |
119 | - /*下拉刷新的回调 */ | |
120 | - downCallback() { | |
121 | - //联网加载数据 | |
122 | - this.list.length = 0; | |
123 | - this.page.num = 1; | |
124 | - this.loadData(1); | |
125 | - this.isJudgeNextPage = ''; | |
126 | - this.model1.userInfo.type = ''; | |
97 | + onHide() { | |
98 | + uni.removeStorageSync('storagePre'); | |
127 | 99 | }, |
128 | - /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */ | |
129 | - upCallback() { | |
130 | - if (this.isJudgeNextPage != '') { | |
131 | - //联网加载数据 | |
132 | - this.page.num += 1; | |
133 | - this.loadData(this.page.num, this.isJudgeNextPage); | |
134 | - } else { | |
100 | + methods: { | |
101 | + formatType(e) { | |
102 | + return e?.type == 'OTHER' ? '其他' : e?.type == 'MEETING' ? '会议' : '公告'; | |
103 | + }, | |
104 | + openTypeClick() { | |
105 | + this.showType = true; | |
106 | + uni.hideKeyboard(); | |
107 | + }, | |
108 | + typeSelect(e) { | |
109 | + this.isJudgeNextPage = e.value; | |
110 | + this.page.num = 1; | |
111 | + this.model1.userInfo.type = e.name; | |
112 | + this.loadData(1, this.isJudgeNextPage == '' ? null : this.isJudgeNextPage); | |
113 | + uni.pageScrollTo({ | |
114 | + scrollTop: this.scrollDistance + 20, | |
115 | + duration: 50 | |
116 | + }); | |
117 | + uni.pageScrollTo({ | |
118 | + scrollTop: this.scrollDistance - 20, | |
119 | + duration: 50 | |
120 | + }); | |
121 | + }, | |
122 | + onPageScroll(e) { | |
123 | + this.scrollDistance = e.scrollTop; | |
124 | + }, | |
125 | + /*下拉刷新的回调 */ | |
126 | + downCallback() { | |
135 | 127 | //联网加载数据 |
136 | - this.page.num += 1; | |
137 | - this.loadData(this.page.num); | |
138 | - } | |
139 | - }, | |
128 | + this.list.length = 0; | |
129 | + this.page.num = 1; | |
130 | + this.loadData(1); | |
131 | + this.isJudgeNextPage = ''; | |
132 | + this.model1.userInfo.type = ''; | |
133 | + }, | |
134 | + /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */ | |
135 | + upCallback() { | |
136 | + if (this.isJudgeNextPage != '') { | |
137 | + //联网加载数据 | |
138 | + this.page.num += 1; | |
139 | + this.loadData(this.page.num, this.isJudgeNextPage); | |
140 | + } else { | |
141 | + //联网加载数据 | |
142 | + this.page.num += 1; | |
143 | + this.loadData(this.page.num); | |
144 | + } | |
145 | + }, | |
140 | 146 | |
141 | - loadData(pageNo, t) { | |
142 | - let httpData = { | |
143 | - page: pageNo, | |
144 | - pageSize: 10, | |
145 | - type: t | |
146 | - }; | |
147 | - uni.$u.http | |
148 | - .get('/yt/notice_user/page', { params: httpData, custom: { load: false } }) | |
149 | - .then(res => { | |
150 | - uni.stopPullDownRefresh(); | |
151 | - this.mescroll.endByPage(res.items.length, res.total); | |
152 | - if (pageNo == 1) { | |
153 | - this.list = res.items; | |
154 | - } else { | |
155 | - this.list = this.list.concat(res.items); | |
147 | + async loadData(pageNo, t) { | |
148 | + let httpData = { | |
149 | + page: pageNo, | |
150 | + pageSize: 10, | |
151 | + type: t | |
152 | + }; | |
153 | + const res = await api.notifyApi.getNotifyApi({ | |
154 | + params: httpData, | |
155 | + custom: { | |
156 | + load: false | |
156 | 157 | } |
157 | 158 | }) |
158 | - .catch(e => { | |
159 | - this.mescroll.endErr(); | |
159 | + uni.stopPullDownRefresh(); | |
160 | + this.mescroll.endByPage(res.items.length, res.total); | |
161 | + if (pageNo == 1) { | |
162 | + this.list = res.items; | |
163 | + } else { | |
164 | + this.list = this.list.concat(res.items); | |
165 | + } | |
166 | + }, | |
167 | + async clickNotifyDetail(e, i) { | |
168 | + this.list[i].readStatus = 1; | |
169 | + await api.notifyApi.byNotifyIdGetDetailApi(e.sysNotice.id) | |
170 | + uni.navigateTo({ | |
171 | + url: './notifyDetail?data=' + encodeURIComponent(JSON.stringify(e.sysNotice)) | |
160 | 172 | }); |
161 | - }, | |
162 | - clickNotifyDetail(e, i) { | |
163 | - this.list[i].readStatus = 1; | |
164 | - uni.$u.http | |
165 | - .get(`/yt/notice_user/${e.sysNotice.id}`) | |
166 | - .then(res => {}) | |
167 | - .catch(e => {}); | |
168 | - uni.navigateTo({ | |
169 | - url: './notifyDetail?data=' + encodeURIComponent(JSON.stringify(e.sysNotice)) | |
170 | - }); | |
173 | + } | |
171 | 174 | } |
172 | - } | |
173 | -}; | |
175 | + }; | |
174 | 176 | </script> |
175 | 177 | |
176 | 178 | <style lang="scss" scoped> |
177 | -@import './static/systemNotify.scss'; | |
178 | -/deep/ .u-badge--error { | |
179 | - position: relative; | |
180 | - right: 11rpx; | |
181 | -} | |
179 | + @import './static/systemNotify.scss'; | |
180 | + | |
181 | + /deep/ .u-badge--error { | |
182 | + position: relative; | |
183 | + right: 11rpx; | |
184 | + } | |
182 | 185 | </style> | ... | ... |