Commit 61739d8ad1bfecf8ec0adbc6ca1c0b3df7e98625
Merge branch 'dev-ft' into 'main'
fix:修改告警分页和绑定账号 See merge request huang/thingskit-app!39
Showing
14 changed files
with
185 additions
and
1507 deletions
| 1 | <script> | 1 | <script> |
| 2 | - import base from "@/config/baseUrl"; | ||
| 3 | - import store from "@/store"; | ||
| 4 | - // #ifdef APP-PLUS | ||
| 5 | - import APPUpdate from '@/uni_modules/zhouWei-APPUpdate/js_sdk/appUpdate'; | ||
| 6 | - // #endif | ||
| 7 | - | ||
| 8 | - import { mpUpData,scene } from '@/config/common'; | ||
| 9 | - export default { | ||
| 10 | - onLaunch(e) { | ||
| 11 | - //取出缓存数据 | ||
| 12 | - store.commit('setCacheData'); | ||
| 13 | - //获取二维码信息 | ||
| 14 | - scene(e) | ||
| 15 | - // #ifdef APP-PLUS | ||
| 16 | - APPUpdate() //检测app更新 | ||
| 17 | - // #endif | ||
| 18 | - }, | ||
| 19 | - onShow(e) { | ||
| 20 | - // #ifdef MP | ||
| 21 | - mpUpData() //检测小程序更新 | ||
| 22 | - // #endif | ||
| 23 | - }, | ||
| 24 | - onHide() { | ||
| 25 | - console.log('App Hide') | ||
| 26 | - } | 2 | +import base from '@/config/baseUrl'; |
| 3 | +import store from '@/store'; | ||
| 4 | +// #ifdef APP-PLUS | ||
| 5 | +import APPUpdate from '@/uni_modules/zhouWei-APPUpdate/js_sdk/appUpdate'; | ||
| 6 | +// #endif | ||
| 7 | + | ||
| 8 | +import { mpUpData, scene } from '@/config/common'; | ||
| 9 | +export default { | ||
| 10 | + //设置全局变量,解绑时从这里取 | ||
| 11 | + globalData: { | ||
| 12 | + openId: '' | ||
| 13 | + }, | ||
| 14 | + onLaunch(e) { | ||
| 15 | + //取出缓存数据 | ||
| 16 | + store.commit('setCacheData'); | ||
| 17 | + //获取二维码信息 | ||
| 18 | + scene(e); | ||
| 19 | + // #ifdef APP-PLUS | ||
| 20 | + APPUpdate(); //检测app更新 | ||
| 21 | + // #endif | ||
| 22 | + }, | ||
| 23 | + onShow(e) { | ||
| 24 | + // #ifdef MP | ||
| 25 | + mpUpData(); //检测小程序更新 | ||
| 26 | + // #endif | ||
| 27 | + }, | ||
| 28 | + onHide() { | ||
| 29 | + console.log('App Hide'); | ||
| 27 | } | 30 | } |
| 31 | +}; | ||
| 28 | </script> | 32 | </script> |
| 29 | 33 | ||
| 30 | <style lang="scss"> | 34 | <style lang="scss"> |
| 31 | /* #ifndef APP-NVUE */ | 35 | /* #ifndef APP-NVUE */ |
| 32 | -@import "@/uni_modules/uview-ui/index.scss"; | 36 | +@import '@/uni_modules/uview-ui/index.scss'; |
| 33 | @import './style/iconfont.scss'; | 37 | @import './style/iconfont.scss'; |
| 34 | -@import "./style/common.scss"; | 38 | +@import './style/common.scss'; |
| 35 | page { | 39 | page { |
| 36 | - background-color: #f5f5f5; | 40 | + background-color: #f5f5f5; |
| 37 | } | 41 | } |
| 38 | // 隐藏滚动条 | 42 | // 隐藏滚动条 |
| 39 | ::-webkit-scrollbar { | 43 | ::-webkit-scrollbar { |
| 40 | - width: 0; | ||
| 41 | - height: 0; | ||
| 42 | - color: transparent; | 44 | + width: 0; |
| 45 | + height: 0; | ||
| 46 | + color: transparent; | ||
| 43 | } | 47 | } |
| 44 | /* #endif */ | 48 | /* #endif */ |
| 45 | </style> | 49 | </style> |
| @@ -85,6 +85,8 @@ uni.$u.http.interceptors.response.use( | @@ -85,6 +85,8 @@ uni.$u.http.interceptors.response.use( | ||
| 85 | uni.reLaunch({ | 85 | uni.reLaunch({ |
| 86 | url: "/publicLoginSubPage/public/login", | 86 | url: "/publicLoginSubPage/public/login", |
| 87 | }); | 87 | }); |
| 88 | + // 清空登录信息 | ||
| 89 | + store.commit("emptyUserInfo"); | ||
| 88 | show = false; | 90 | show = false; |
| 89 | } else { | 91 | } else { |
| 90 | errorData = message || ""; | 92 | errorData = message || ""; |
| @@ -229,10 +229,17 @@ export default { | @@ -229,10 +229,17 @@ export default { | ||
| 229 | timeArea, | 229 | timeArea, |
| 230 | ordId: '', | 230 | ordId: '', |
| 231 | detailStatus: false, | 231 | detailStatus: false, |
| 232 | - alertTotal: 0 | 232 | + alertTotal: 0, |
| 233 | + searchAlarmText: '', | ||
| 234 | + startTimeVa: '', | ||
| 235 | + endTimeVa: '', | ||
| 236 | + startTimeArea: '', | ||
| 237 | + endTimeArea: '', | ||
| 238 | + type: null | ||
| 233 | }; | 239 | }; |
| 234 | }, | 240 | }, |
| 235 | onShow() { | 241 | onShow() { |
| 242 | + this.page.num = 1; | ||
| 236 | if (this.detailStatus) { | 243 | if (this.detailStatus) { |
| 237 | this.loadData(1, null, null, null, null, null, null); | 244 | this.loadData(1, null, null, null, null, null, null); |
| 238 | } | 245 | } |
| @@ -243,6 +250,7 @@ export default { | @@ -243,6 +250,7 @@ export default { | ||
| 243 | onHide() { | 250 | onHide() { |
| 244 | this.ordId = ''; | 251 | this.ordId = ''; |
| 245 | this.detailStatus = false; | 252 | this.detailStatus = false; |
| 253 | + this.type = null; | ||
| 246 | }, | 254 | }, |
| 247 | onLoad(e) { | 255 | onLoad(e) { |
| 248 | // 隐藏原生的tabbar | 256 | // 隐藏原生的tabbar |
| @@ -251,13 +259,12 @@ export default { | @@ -251,13 +259,12 @@ export default { | ||
| 251 | this.loadData(1, null, null, null, null, null, null); | 259 | this.loadData(1, null, null, null, null, null, null); |
| 252 | } else { | 260 | } else { |
| 253 | let params = JSON.parse(e.type); | 261 | let params = JSON.parse(e.type); |
| 254 | - let type; | ||
| 255 | if (Array.isArray(params)) { | 262 | if (Array.isArray(params)) { |
| 256 | - type = params.join(','); | 263 | + this.type = params.join(','); |
| 257 | } else { | 264 | } else { |
| 258 | - type = params; | 265 | + this.type = params; |
| 259 | } | 266 | } |
| 260 | - this.loadData(1, type, null, null, null, null, null); | 267 | + this.loadData(1, this.type, null, null, null, null, null); |
| 261 | } | 268 | } |
| 262 | }, | 269 | }, |
| 263 | watch: { | 270 | watch: { |
| @@ -267,6 +274,10 @@ export default { | @@ -267,6 +274,10 @@ export default { | ||
| 267 | }, | 274 | }, |
| 268 | methods: { | 275 | methods: { |
| 269 | inputChanged(e) { | 276 | inputChanged(e) { |
| 277 | + this.resetData(); | ||
| 278 | + this.topBack(); | ||
| 279 | + this.searchAlarmText = e; | ||
| 280 | + this.page.num = 1; | ||
| 270 | this.loadData(1, null, null, null, null, null, null, e); | 281 | this.loadData(1, null, null, null, null, null, null, e); |
| 271 | }, | 282 | }, |
| 272 | getAlertStatus(e, i) { | 283 | getAlertStatus(e, i) { |
| @@ -285,44 +296,39 @@ export default { | @@ -285,44 +296,39 @@ export default { | ||
| 285 | this.current4 = i; | 296 | this.current4 = i; |
| 286 | this.selectTimeVal = e.value; | 297 | this.selectTimeVal = e.value; |
| 287 | let curTime = new Date(); | 298 | let curTime = new Date(); |
| 288 | - const formatS = curTime | ||
| 289 | - .getTime() | ||
| 290 | - .toString() | ||
| 291 | - .substring(0, 10); | 299 | + const formatS = curTime.getTime(); |
| 292 | let addMinute = new Date(curTime.setMinutes(curTime.getMinutes() + this.selectTimeVal)); | 300 | let addMinute = new Date(curTime.setMinutes(curTime.getMinutes() + this.selectTimeVal)); |
| 293 | - const formatE = addMinute | ||
| 294 | - .getTime() | ||
| 295 | - .toString() | ||
| 296 | - .substring(0, 10); | 301 | + const formatE = addMinute.getTime(); |
| 297 | this.timeData.getTimeGapS = formatS; | 302 | this.timeData.getTimeGapS = formatS; |
| 298 | this.timeData.getTimeGapE = formatE; | 303 | this.timeData.getTimeGapE = formatE; |
| 299 | }, | 304 | }, |
| 300 | queryData() { | 305 | queryData() { |
| 306 | + this.topBack(); | ||
| 307 | + this.page.num = 1; | ||
| 301 | let date1 = new Date(this.timeData.selectTime[0]); | 308 | let date1 = new Date(this.timeData.selectTime[0]); |
| 302 | let date2 = new Date(this.timeData.selectTime[1]); | 309 | let date2 = new Date(this.timeData.selectTime[1]); |
| 303 | - let startTimeVa, endTimeVa; | ||
| 304 | if (this.timeData.selectTime.length == 0) { | 310 | if (this.timeData.selectTime.length == 0) { |
| 305 | - startTimeVa = ''; | ||
| 306 | - endTimeVa = ''; | 311 | + this.startTimeVa = ''; |
| 312 | + this.endTimeVa = ''; | ||
| 307 | } else { | 313 | } else { |
| 308 | - startTimeVa = date1 | ||
| 309 | - .getTime() | ||
| 310 | - .toString() | ||
| 311 | - .substring(0, 10); | ||
| 312 | - endTimeVa = date2 | ||
| 313 | - .getTime() | ||
| 314 | - .toString() | ||
| 315 | - .substring(0, 10); | 314 | + this.startTimeVa = date1.getTime(); |
| 315 | + this.endTimeVa = date2.getTime(); | ||
| 316 | } | 316 | } |
| 317 | - let startTimeArea, endTimeArea; | ||
| 318 | if (this.timeData.getTimeGapS == '') { | 317 | if (this.timeData.getTimeGapS == '') { |
| 319 | - startTimeArea = ''; | ||
| 320 | - endTimeArea = ''; | 318 | + this.startTimeArea = ''; |
| 319 | + this.endTimeArea = ''; | ||
| 321 | } else { | 320 | } else { |
| 322 | - startTimeArea = this.timeData.getTimeGapS; | ||
| 323 | - endTimeArea = this.timeData.getTimeGapE; | 321 | + this.startTimeArea = this.timeData.getTimeGapS; |
| 322 | + this.endTimeArea = this.timeData.getTimeGapE; | ||
| 324 | } | 323 | } |
| 325 | - this.loadData(1, this.alertStatusVal, startTimeVa ? startTimeVa : startTimeArea, endTimeVa ? endTimeVa : endTimeArea, this.alertLevelVal, this.deviceTypeVal); | 324 | + this.loadData( |
| 325 | + 1, | ||
| 326 | + this.alertStatusVal, | ||
| 327 | + this.startTimeVa ? this.startTimeVa : this.startTimeArea, | ||
| 328 | + this.endTimeVa ? this.endTimeVa : this.endTimeArea, | ||
| 329 | + this.alertLevelVal, | ||
| 330 | + this.deviceTypeVal | ||
| 331 | + ); | ||
| 326 | this.show = false; | 332 | this.show = false; |
| 327 | }, | 333 | }, |
| 328 | resetData() { | 334 | resetData() { |
| @@ -338,6 +344,13 @@ export default { | @@ -338,6 +344,13 @@ export default { | ||
| 338 | this.timeDatagetTimeGapS = ''; | 344 | this.timeDatagetTimeGapS = ''; |
| 339 | this.timeDatagetTimeGapE = ''; | 345 | this.timeDatagetTimeGapE = ''; |
| 340 | this.range = []; | 346 | this.range = []; |
| 347 | + this.searchAlarmText = ''; | ||
| 348 | + this.startTimeVa = ''; | ||
| 349 | + this.endTimeVa = ''; | ||
| 350 | + this.startTimeArea = ''; | ||
| 351 | + this.endTimeArea = ''; | ||
| 352 | + this.ordId = ''; | ||
| 353 | + this.type = null; | ||
| 341 | }, | 354 | }, |
| 342 | bindImageUrl(e) { | 355 | bindImageUrl(e) { |
| 343 | switch (e) { | 356 | switch (e) { |
| @@ -361,18 +374,50 @@ export default { | @@ -361,18 +374,50 @@ export default { | ||
| 361 | break; | 374 | break; |
| 362 | } | 375 | } |
| 363 | }, | 376 | }, |
| 377 | + //筛选数据让它回到顶部 | ||
| 378 | + topBack() { | ||
| 379 | + uni.pageScrollTo({ | ||
| 380 | + scrollTop: 0, // 滚动到页面的目标位置 这个是滚动到顶部, 0 | ||
| 381 | + duration: 300 // 滚动动画的时长 | ||
| 382 | + }); | ||
| 383 | + }, | ||
| 364 | /*下拉刷新的回调 */ | 384 | /*下拉刷新的回调 */ |
| 365 | downCallback() { | 385 | downCallback() { |
| 366 | //联网加载数据 | 386 | //联网加载数据 |
| 367 | this.list.length = 0; | 387 | this.list.length = 0; |
| 368 | this.page.num = 1; | 388 | this.page.num = 1; |
| 369 | - this.loadData(1); | 389 | + this.loadData(this.page.num, null, null, null, null, null, null, null); |
| 390 | + this.resetData(); | ||
| 370 | }, | 391 | }, |
| 371 | /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */ | 392 | /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */ |
| 372 | upCallback() { | 393 | upCallback() { |
| 373 | - //联网加载数据 | ||
| 374 | - this.page.num += 1; | ||
| 375 | - this.loadData(this.page.num); | 394 | + if ( |
| 395 | + this.type != null || | ||
| 396 | + this.alertStatusVal != '' || | ||
| 397 | + this.searchAlarmText != '' || | ||
| 398 | + this.deviceTypeVal != '' || | ||
| 399 | + this.alertLevelVal != '' || | ||
| 400 | + this.startTimeVa != '' || | ||
| 401 | + this.startTimeArea != '' || | ||
| 402 | + this.ordId != '' | ||
| 403 | + ) { | ||
| 404 | + //联网加载数据 | ||
| 405 | + this.page.num += 1; | ||
| 406 | + this.loadData( | ||
| 407 | + this.page.num, | ||
| 408 | + this.alertStatusVal ? this.alertStatusVal : this.type, | ||
| 409 | + this.startTimeVa, | ||
| 410 | + this.endTimeVa, | ||
| 411 | + this.alertLevelVal, | ||
| 412 | + this.deviceTypeVal, | ||
| 413 | + this.ordId, | ||
| 414 | + this.searchAlarmText | ||
| 415 | + ); | ||
| 416 | + } else { | ||
| 417 | + //联网加载数据 | ||
| 418 | + this.page.num += 1; | ||
| 419 | + this.loadData(this.page.num); | ||
| 420 | + } | ||
| 376 | }, | 421 | }, |
| 377 | loadData(pageNo, statusV, startTimeV, endTimeV, severityV, deviceTypeV, organizationV, alarmName) { | 422 | loadData(pageNo, statusV, startTimeV, endTimeV, severityV, deviceTypeV, organizationV, alarmName) { |
| 378 | let that = this; | 423 | let that = this; |
| @@ -463,6 +508,6 @@ export default { | @@ -463,6 +508,6 @@ export default { | ||
| 463 | margin-top: -55rpx !important; | 508 | margin-top: -55rpx !important; |
| 464 | } | 509 | } |
| 465 | /deep/ .uni-calendar--fixed { | 510 | /deep/ .uni-calendar--fixed { |
| 466 | - bottom: 72rpx !important; | 511 | + bottom: 172rpx !important; |
| 467 | } | 512 | } |
| 468 | </style> | 513 | </style> |
| @@ -6,15 +6,16 @@ | @@ -6,15 +6,16 @@ | ||
| 6 | <!-- #ifdef MP || APP-PLUS --> | 6 | <!-- #ifdef MP || APP-PLUS --> |
| 7 | <!-- 登录 --> | 7 | <!-- 登录 --> |
| 8 | <view class="u-flex u-p-l-30 u-p-r-20 u-p-t-75 u-p-b-30"> | 8 | <view class="u-flex u-p-l-30 u-p-r-20 u-p-t-75 u-p-b-30"> |
| 9 | - <block v-if="userInfo.isToken"> | 9 | + <block v-if="userInfo.isToken || userInfo.isThirdLogin"> |
| 10 | <view @click="openPersonalInfo" class="u-m-r-20"> | 10 | <view @click="openPersonalInfo" class="u-m-r-20"> |
| 11 | <image class="avatar" mode="aspectFill" :src="userInfo.avatar == '' ? '/static/logo.png' : userInfo.avatar"></image> | 11 | <image class="avatar" mode="aspectFill" :src="userInfo.avatar == '' ? '/static/logo.png' : userInfo.avatar"></image> |
| 12 | </view> | 12 | </view> |
| 13 | <view class="u-flex-1"> | 13 | <view class="u-flex-1"> |
| 14 | - <view @click="openPersonalInfo" class="nickName u-flex"> | ||
| 15 | - <view class="name u-m-r-10" v-if="userInfo.realName || userInfo.nickName"> | 14 | + <view class="nickName u-flex"> |
| 15 | + <view @click="openPersonalInfo" class="name u-m-r-10" v-if="userInfo.realName || userInfo.nickName"> | ||
| 16 | <text style="#FFFFFF;font-size: 18px;">{{ userInfo.realName || userInfo.nickName }}</text> | 16 | <text style="#FFFFFF;font-size: 18px;">{{ userInfo.realName || userInfo.nickName }}</text> |
| 17 | </view> | 17 | </view> |
| 18 | + <view v-if="userInfo.isThirdLogin" @click="clickAccountFunc" class="detail"><text class="text">绑定账号</text></view> | ||
| 18 | </view> | 19 | </view> |
| 19 | <view @click="openPersonalInfo" style="color:#FFFFFF;font-size: 14px;" v-if="userInfo.phoneNumber">{{ userInfo.phoneNumber | phone }}</view> | 20 | <view @click="openPersonalInfo" style="color:#FFFFFF;font-size: 14px;" v-if="userInfo.phoneNumber">{{ userInfo.phoneNumber | phone }}</view> |
| 20 | </view> | 21 | </view> |
| @@ -23,10 +24,7 @@ | @@ -23,10 +24,7 @@ | ||
| 23 | <view class="u-m-r-20" @click="openLoginFunc"> | 24 | <view class="u-m-r-20" @click="openLoginFunc"> |
| 24 | <view class="avatar u-flex"><image class="avatar" mode="aspectFill" src="../../static/logo.png"></image></view> | 25 | <view class="avatar u-flex"><image class="avatar" mode="aspectFill" src="../../static/logo.png"></image></view> |
| 25 | </view> | 26 | </view> |
| 26 | - <view class="u-flex-1"> | ||
| 27 | - <view @click="openLoginFunc" class="u-font-lg click-login login-btn ">请点击登录</view> | ||
| 28 | - <view v-if="!userInfo.isToken" @click="clickAccountFunc" class="detail"><text class="text">绑定账号</text></view> | ||
| 29 | - </view> | 27 | + <view class="u-flex-1"><view @click="openLoginFunc" class="u-font-lg click-login login-btn ">请点击登录</view></view> |
| 30 | </block> | 28 | </block> |
| 31 | <view v-if="userInfo.isToken" @click="openPersonalInfo"><u-icon name="arrow-right" color="white" size="13"></u-icon></view> | 29 | <view v-if="userInfo.isToken" @click="openPersonalInfo"><u-icon name="arrow-right" color="white" size="13"></u-icon></view> |
| 32 | </view> | 30 | </view> |
| @@ -166,6 +164,7 @@ export default { | @@ -166,6 +164,7 @@ export default { | ||
| 166 | const params = JSON.parse(decodeURIComponent(e.obj)); | 164 | const params = JSON.parse(decodeURIComponent(e.obj)); |
| 167 | this.thirdObj = params; | 165 | this.thirdObj = params; |
| 168 | } | 166 | } |
| 167 | + console.log('UserInfo', this.userInfo); | ||
| 169 | }, | 168 | }, |
| 170 | computed: { | 169 | computed: { |
| 171 | ...mapState(['userInfo']) | 170 | ...mapState(['userInfo']) |
| @@ -247,7 +246,8 @@ export default { | @@ -247,7 +246,8 @@ export default { | ||
| 247 | }; | 246 | }; |
| 248 | let userInfo = { | 247 | let userInfo = { |
| 249 | ...resObj, | 248 | ...resObj, |
| 250 | - token: true //token用于判断是否登录 | 249 | + token: true, //token用于判断是否登录 |
| 250 | + isThirdLogin: false | ||
| 251 | }; | 251 | }; |
| 252 | if (userInfo.token) { | 252 | if (userInfo.token) { |
| 253 | this.setUserInfo(userInfo); | 253 | this.setUserInfo(userInfo); |
| @@ -308,7 +308,8 @@ export default { | @@ -308,7 +308,8 @@ export default { | ||
| 308 | }; | 308 | }; |
| 309 | let userInfo = { | 309 | let userInfo = { |
| 310 | ...resObj, | 310 | ...resObj, |
| 311 | - token: true //token用于判断是否登录 | 311 | + token: true, //token用于判断是否登录 |
| 312 | + isThirdLogin: false | ||
| 312 | }; | 313 | }; |
| 313 | if (userInfo.token) { | 314 | if (userInfo.token) { |
| 314 | this.setUserInfo(userInfo); | 315 | this.setUserInfo(userInfo); |
plugins/permission.js
deleted
100644 → 0
| 1 | -/** | ||
| 2 | - * 本模块封装了Android、iOS的应用权限判断、打开应用权限设置界面、以及位置系统服务是否开启 | ||
| 3 | - */ | ||
| 4 | - | ||
| 5 | -var isIos | ||
| 6 | -// #ifdef APP-PLUS | ||
| 7 | -isIos = (plus.os.name == "iOS") | ||
| 8 | -// #endif | ||
| 9 | - | ||
| 10 | -// 判断推送权限是否开启 | ||
| 11 | -function judgeIosPermissionPush() { | ||
| 12 | - var result = 0; | ||
| 13 | - var UIApplication = plus.ios.import("UIApplication"); | ||
| 14 | - var app = UIApplication.sharedApplication(); | ||
| 15 | - var enabledTypes = 0; | ||
| 16 | - if (app.currentUserNotificationSettings) { | ||
| 17 | - var settings = app.currentUserNotificationSettings(); | ||
| 18 | - enabledTypes = settings.plusGetAttribute("types"); | ||
| 19 | - if (enabledTypes == 0) { | ||
| 20 | - console.log("推送权限没有开启"); | ||
| 21 | - } else { | ||
| 22 | - result = 1; | ||
| 23 | - console.log("已经开启推送功能!") | ||
| 24 | - } | ||
| 25 | - plus.ios.deleteObject(settings); | ||
| 26 | - } else { | ||
| 27 | - enabledTypes = app.enabledRemoteNotificationTypes(); | ||
| 28 | - if (enabledTypes == 0) { | ||
| 29 | - console.log("推送权限没有开启!"); | ||
| 30 | - } else { | ||
| 31 | - result = 1; | ||
| 32 | - console.log("已经开启推送功能!") | ||
| 33 | - } | ||
| 34 | - console.log("enabledTypes2:" + enabledTypes); | ||
| 35 | - } | ||
| 36 | - plus.ios.deleteObject(app); | ||
| 37 | - plus.ios.deleteObject(UIApplication); | ||
| 38 | - return result; | ||
| 39 | -} | ||
| 40 | - | ||
| 41 | -// 判断定位权限是否开启 | ||
| 42 | -function judgeIosPermissionLocation() { | ||
| 43 | - var result = 0; | ||
| 44 | - var cllocationManger = plus.ios.import("CLLocationManager"); | ||
| 45 | - var status = cllocationManger.authorizationStatus(); | ||
| 46 | - result = (status != 2) ? 1 : 0; | ||
| 47 | - console.log("定位权限开启:" + result); | ||
| 48 | - // 以下代码判断了手机设备的定位是否关闭,推荐另行使用方法 checkSystemEnableLocation | ||
| 49 | - /* var enable = cllocationManger.locationServicesEnabled(); | ||
| 50 | - var status = cllocationManger.authorizationStatus(); | ||
| 51 | - console.log("enable:" + enable); | ||
| 52 | - console.log("status:" + status); | ||
| 53 | - if (enable && status != 2) { | ||
| 54 | - result = true; | ||
| 55 | - console.log("手机定位服务已开启且已授予定位权限"); | ||
| 56 | - } else { | ||
| 57 | - console.log("手机系统的定位没有打开或未给予定位权限"); | ||
| 58 | - } */ | ||
| 59 | - plus.ios.deleteObject(cllocationManger); | ||
| 60 | - return { | ||
| 61 | - result: result, | ||
| 62 | - permissionName: "定位" | ||
| 63 | - }; | ||
| 64 | -} | ||
| 65 | - | ||
| 66 | -// 判断麦克风权限是否开启 | ||
| 67 | -function judgeIosPermissionRecord() { | ||
| 68 | - var result = 0; | ||
| 69 | - var avaudiosession = plus.ios.import("AVAudioSession"); | ||
| 70 | - var avaudio = avaudiosession.sharedInstance(); | ||
| 71 | - var permissionStatus = avaudio.recordPermission(); | ||
| 72 | - console.log("permissionStatus:" + permissionStatus); | ||
| 73 | - if (permissionStatus == 1684369017 || permissionStatus == 1970168948) { | ||
| 74 | - console.log("麦克风权限没有开启"); | ||
| 75 | - } else { | ||
| 76 | - result = 1; | ||
| 77 | - console.log("麦克风权限已经开启"); | ||
| 78 | - } | ||
| 79 | - plus.ios.deleteObject(avaudiosession); | ||
| 80 | - return { | ||
| 81 | - result: result, | ||
| 82 | - permissionName: "麦克风" | ||
| 83 | - }; | ||
| 84 | -} | ||
| 85 | - | ||
| 86 | -// 判断相机权限是否开启 | ||
| 87 | -function judgeIosPermissionCamera() { | ||
| 88 | - var result = 0; | ||
| 89 | - var AVCaptureDevice = plus.ios.import("AVCaptureDevice"); | ||
| 90 | - var authStatus = AVCaptureDevice.authorizationStatusForMediaType('vide'); | ||
| 91 | - console.log("authStatus:" + authStatus); | ||
| 92 | - if (authStatus == 3) { | ||
| 93 | - result = 1; | ||
| 94 | - console.log("相机权限已经开启"); | ||
| 95 | - } else { | ||
| 96 | - console.log("相机权限没有开启"); | ||
| 97 | - } | ||
| 98 | - plus.ios.deleteObject(AVCaptureDevice); | ||
| 99 | - return { | ||
| 100 | - result: result, | ||
| 101 | - permissionName: "相机" | ||
| 102 | - }; | ||
| 103 | -} | ||
| 104 | - | ||
| 105 | -// 判断相册权限是否开启 | ||
| 106 | -function judgeIosPermissionPhotoLibrary() { | ||
| 107 | - var result = 0; | ||
| 108 | - var PHPhotoLibrary = plus.ios.import("PHPhotoLibrary"); | ||
| 109 | - var authStatus = PHPhotoLibrary.authorizationStatus(); | ||
| 110 | - console.log("authStatus:" + authStatus); | ||
| 111 | - if (authStatus == 3) { | ||
| 112 | - result = 1; | ||
| 113 | - console.log("相册权限已经开启"); | ||
| 114 | - } else { | ||
| 115 | - console.log("相册权限没有开启"); | ||
| 116 | - } | ||
| 117 | - plus.ios.deleteObject(PHPhotoLibrary); | ||
| 118 | - return { | ||
| 119 | - result: result, | ||
| 120 | - permissionName: "相册" | ||
| 121 | - }; | ||
| 122 | -} | ||
| 123 | - | ||
| 124 | -// 判断通讯录权限是否开启 | ||
| 125 | -function judgeIosPermissionContact() { | ||
| 126 | - var result = 0; | ||
| 127 | - var CNContactStore = plus.ios.import("CNContactStore"); | ||
| 128 | - var cnAuthStatus = CNContactStore.authorizationStatusForEntityType(0); | ||
| 129 | - if (cnAuthStatus == 3) { | ||
| 130 | - result = 1; | ||
| 131 | - console.log("通讯录权限已经开启"); | ||
| 132 | - } else { | ||
| 133 | - console.log("通讯录权限没有开启"); | ||
| 134 | - } | ||
| 135 | - plus.ios.deleteObject(CNContactStore); | ||
| 136 | - return { | ||
| 137 | - result: result, | ||
| 138 | - permissionName: "通讯录" | ||
| 139 | - }; | ||
| 140 | -} | ||
| 141 | - | ||
| 142 | -// 判断日历权限是否开启 | ||
| 143 | -function judgeIosPermissionCalendar() { | ||
| 144 | - var result = 0; | ||
| 145 | - var EKEventStore = plus.ios.import("EKEventStore"); | ||
| 146 | - var ekAuthStatus = EKEventStore.authorizationStatusForEntityType(0); | ||
| 147 | - if (ekAuthStatus == 3) { | ||
| 148 | - result = 1; | ||
| 149 | - console.log("日历权限已经开启"); | ||
| 150 | - } else { | ||
| 151 | - console.log("日历权限没有开启"); | ||
| 152 | - } | ||
| 153 | - plus.ios.deleteObject(EKEventStore); | ||
| 154 | - return { | ||
| 155 | - result: result, | ||
| 156 | - permissionName: "日历" | ||
| 157 | - }; | ||
| 158 | -} | ||
| 159 | - | ||
| 160 | -// 判断备忘录权限是否开启 | ||
| 161 | -function judgeIosPermissionMemo() { | ||
| 162 | - var result = 0; | ||
| 163 | - var EKEventStore = plus.ios.import("EKEventStore"); | ||
| 164 | - var ekAuthStatus = EKEventStore.authorizationStatusForEntityType(1); | ||
| 165 | - if (ekAuthStatus == 3) { | ||
| 166 | - result = 1; | ||
| 167 | - console.log("备忘录权限已经开启"); | ||
| 168 | - } else { | ||
| 169 | - console.log("备忘录权限没有开启"); | ||
| 170 | - } | ||
| 171 | - plus.ios.deleteObject(EKEventStore); | ||
| 172 | - return { | ||
| 173 | - result: result, | ||
| 174 | - permissionName: "备忘录" | ||
| 175 | - }; | ||
| 176 | -} | ||
| 177 | - | ||
| 178 | -// Android权限查询 | ||
| 179 | -function requestAndroidPermission(permissionID, permissionName) { | ||
| 180 | - return new Promise((resolve, reject) => { | ||
| 181 | - plus.android.requestPermissions( | ||
| 182 | - [permissionID], // 理论上支持多个权限同时查询,但实际上本函数封装只处理了一个权限的情况。有需要的可自行扩展封装 | ||
| 183 | - function (resultObj) { | ||
| 184 | - var result = 0; | ||
| 185 | - for (var i = 0; i < resultObj.granted.length; i++) { | ||
| 186 | - var grantedPermission = resultObj.granted[i]; | ||
| 187 | - console.log('已获取的权限:' + grantedPermission); | ||
| 188 | - result = 1 | ||
| 189 | - } | ||
| 190 | - for (var i = 0; i < resultObj.deniedPresent.length; i++) { | ||
| 191 | - var deniedPresentPermission = resultObj.deniedPresent[i]; | ||
| 192 | - console.log('拒绝本次申请的权限:' + deniedPresentPermission); | ||
| 193 | - result = 0 | ||
| 194 | - } | ||
| 195 | - for (var i = 0; i < resultObj.deniedAlways.length; i++) { | ||
| 196 | - var deniedAlwaysPermission = resultObj.deniedAlways[i]; | ||
| 197 | - console.log('永久拒绝申请的权限:' + deniedAlwaysPermission); | ||
| 198 | - result = -1 | ||
| 199 | - } | ||
| 200 | - resolve({ | ||
| 201 | - result: result, | ||
| 202 | - permissionName: permissionName | ||
| 203 | - }); | ||
| 204 | - // 若所需权限被拒绝,则打开APP设置界面,可以在APP设置界面打开相应权限 | ||
| 205 | - // if (result != 1) { | ||
| 206 | - // gotoAppPermissionSetting() | ||
| 207 | - // } | ||
| 208 | - }, | ||
| 209 | - function (error) { | ||
| 210 | - console.log('申请权限错误:' + error.code + " = " + error.message); | ||
| 211 | - resolve({ | ||
| 212 | - code: error.code, | ||
| 213 | - message: error.message | ||
| 214 | - }); | ||
| 215 | - } | ||
| 216 | - ); | ||
| 217 | - }); | ||
| 218 | -} | ||
| 219 | - | ||
| 220 | -// 使用一个方法,根据参数判断权限 | ||
| 221 | -function judgePermission(permissionID, callback) { | ||
| 222 | - function handle(res) { | ||
| 223 | - callback && callback(res.result); | ||
| 224 | - if (res.result === -1) { | ||
| 225 | - uni.showModal({ | ||
| 226 | - title: "提示", | ||
| 227 | - content: "您还未开通" + res.permissionName + "权限,是否去应用设置里开通~", | ||
| 228 | - confirmText: "去开通", | ||
| 229 | - cancelText: "再逛会", | ||
| 230 | - success: (data) => { | ||
| 231 | - if (data.confirm) { | ||
| 232 | - gotoAppPermissionSetting(); | ||
| 233 | - } | ||
| 234 | - } | ||
| 235 | - }); | ||
| 236 | - } | ||
| 237 | - } | ||
| 238 | - if (permissionID == "location") { // 位置 | ||
| 239 | - if (isIos) { | ||
| 240 | - handle(judgeIosPermissionLocation()); | ||
| 241 | - } else { | ||
| 242 | - requestAndroidPermission("android.permission.ACCESS_FINE_LOCATION", "位置").then(handle); | ||
| 243 | - } | ||
| 244 | - } else if (permissionID == "camera") { // 摄像头 | ||
| 245 | - if (isIos) { | ||
| 246 | - handle(judgeIosPermissionCamera()); | ||
| 247 | - } else { | ||
| 248 | - requestAndroidPermission("android.permission.CAMERA", "摄像头").then(handle); | ||
| 249 | - } | ||
| 250 | - } else if (permissionID == "photoLibrary") { // 相册 | ||
| 251 | - if (isIos) { | ||
| 252 | - handle(judgeIosPermissionPhotoLibrary()); | ||
| 253 | - } else { | ||
| 254 | - requestAndroidPermission("android.permission.READ_EXTERNAL_STORAGE", "相册读取").then(handle); | ||
| 255 | - } | ||
| 256 | - } else if (permissionID == "record") { // 麦克风 | ||
| 257 | - if (isIos) { | ||
| 258 | - handle(judgeIosPermissionRecord()); | ||
| 259 | - } else { | ||
| 260 | - requestAndroidPermission("android.permission.RECORD_AUDIO", "麦克风").then(handle); | ||
| 261 | - } | ||
| 262 | - } else if (permissionID == "push") { // 推送 | ||
| 263 | - if (isIos) { | ||
| 264 | - handle(judgeIosPermissionPush()); | ||
| 265 | - } else { | ||
| 266 | - handle(1); | ||
| 267 | - } | ||
| 268 | - } else if (permissionID == "contact") { // 通讯录 | ||
| 269 | - if (isIos) { | ||
| 270 | - handle(judgeIosPermissionContact()); | ||
| 271 | - } else { | ||
| 272 | - requestAndroidPermission("android.permission.READ_CONTACTS", "通讯录读取").then(handle); | ||
| 273 | - } | ||
| 274 | - } else if (permissionID == "calendar") { // 日历 | ||
| 275 | - if (isIos) { | ||
| 276 | - handle(judgeIosPermissionCalendar()); | ||
| 277 | - } else { | ||
| 278 | - requestAndroidPermission("android.permission.READ_CALENDAR", "日历读取").then(handle); | ||
| 279 | - } | ||
| 280 | - } else if (permissionID == "memo") { // 备忘录 | ||
| 281 | - if (isIos) { | ||
| 282 | - handle(judgeIosPermissionMemo()); | ||
| 283 | - } else { | ||
| 284 | - handle(1); | ||
| 285 | - } | ||
| 286 | - } else if (permissionID == "call_phone") { // 拨打电话 | ||
| 287 | - if (isIos) { | ||
| 288 | - handle(1); | ||
| 289 | - } else { | ||
| 290 | - requestAndroidPermission("android.permission.CALL_PHONE", "拨打电话").then(handle); | ||
| 291 | - } | ||
| 292 | - } | ||
| 293 | -} | ||
| 294 | - | ||
| 295 | -// 跳转到**应用**的权限页面 | ||
| 296 | -function gotoAppPermissionSetting() { | ||
| 297 | - if (isIos) { | ||
| 298 | - var UIApplication = plus.ios.import("UIApplication"); | ||
| 299 | - var application2 = UIApplication.sharedApplication(); | ||
| 300 | - var NSURL2 = plus.ios.import("NSURL"); | ||
| 301 | - // var setting2 = NSURL2.URLWithString("prefs:root=LOCATION_SERVICES"); | ||
| 302 | - var setting2 = NSURL2.URLWithString("app-settings:"); | ||
| 303 | - application2.openURL(setting2); | ||
| 304 | - | ||
| 305 | - plus.ios.deleteObject(setting2); | ||
| 306 | - plus.ios.deleteObject(NSURL2); | ||
| 307 | - plus.ios.deleteObject(application2); | ||
| 308 | - } else { | ||
| 309 | - // console.log(plus.device.vendor); | ||
| 310 | - var Intent = plus.android.importClass("android.content.Intent"); | ||
| 311 | - var Settings = plus.android.importClass("android.provider.Settings"); | ||
| 312 | - var Uri = plus.android.importClass("android.net.Uri"); | ||
| 313 | - var mainActivity = plus.android.runtimeMainActivity(); | ||
| 314 | - var intent = new Intent(); | ||
| 315 | - intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); | ||
| 316 | - var uri = Uri.fromParts("package", mainActivity.getPackageName(), null); | ||
| 317 | - intent.setData(uri); | ||
| 318 | - mainActivity.startActivity(intent); | ||
| 319 | - } | ||
| 320 | -} | ||
| 321 | - | ||
| 322 | -// 检查系统的设备服务是否开启 | ||
| 323 | -// var checkSystemEnableLocation = async function () { | ||
| 324 | -function checkSystemEnableLocation() { | ||
| 325 | - if (isIos) { | ||
| 326 | - var result = false; | ||
| 327 | - var cllocationManger = plus.ios.import("CLLocationManager"); | ||
| 328 | - var result = cllocationManger.locationServicesEnabled(); | ||
| 329 | - console.log("系统定位开启:" + result); | ||
| 330 | - plus.ios.deleteObject(cllocationManger); | ||
| 331 | - return result; | ||
| 332 | - } else { | ||
| 333 | - var context = plus.android.importClass("android.content.Context"); | ||
| 334 | - var locationManager = plus.android.importClass("android.location.LocationManager"); | ||
| 335 | - var main = plus.android.runtimeMainActivity(); | ||
| 336 | - var mainSvr = main.getSystemService(context.LOCATION_SERVICE); | ||
| 337 | - var result = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER); | ||
| 338 | - console.log("系统定位开启:" + result); | ||
| 339 | - return result | ||
| 340 | - } | ||
| 341 | -} | ||
| 342 | - | ||
| 343 | -module.exports = { | ||
| 344 | - judgePermission: judgePermission, | ||
| 345 | - requestAndroidPermission: requestAndroidPermission, | ||
| 346 | - checkSystemEnableLocation: checkSystemEnableLocation, | ||
| 347 | - gotoAppPermissionSetting: gotoAppPermissionSetting | ||
| 348 | -} |
| @@ -131,7 +131,8 @@ | @@ -131,7 +131,8 @@ | ||
| 131 | }; | 131 | }; |
| 132 | let userInfo = { | 132 | let userInfo = { |
| 133 | ...resObj, | 133 | ...resObj, |
| 134 | - token: true //token用于判断是否登录 | 134 | + token: true ,//token用于判断是否登录 |
| 135 | + isThirdLogin: false | ||
| 135 | }; | 136 | }; |
| 136 | if (userInfo.token) { | 137 | if (userInfo.token) { |
| 137 | this.setUserInfo(userInfo); | 138 | this.setUserInfo(userInfo); |
| @@ -56,9 +56,9 @@ | @@ -56,9 +56,9 @@ | ||
| 56 | <view> | 56 | <view> |
| 57 | <u-popup bgColor="transparent" :overlay="true" :show="showBind" mode="bottom"> | 57 | <u-popup bgColor="transparent" :overlay="true" :show="showBind" mode="bottom"> |
| 58 | <view class="u-flex logout-main"> | 58 | <view class="u-flex logout-main"> |
| 59 | - <view class="main"><text style="color: #999999">是否需要解绑?</text></view> | 59 | + <view class="main"><text style="color: #999999">是否需要解除绑定的账号?</text></view> |
| 60 | <view @click="confrimBind(info)" class="main"><text style="color: #f95e5a">是</text></view> | 60 | <view @click="confrimBind(info)" class="main"><text style="color: #f95e5a">是</text></view> |
| 61 | - <view class="main1"><text @click="showBind = false" style="color: #3478f7">否</text></view> | 61 | + <view @click="showBind = false" class="main1"><text style="color: #3478f7">否</text></view> |
| 62 | </view> | 62 | </view> |
| 63 | </u-popup> | 63 | </u-popup> |
| 64 | </view> | 64 | </view> |
| @@ -134,7 +134,8 @@ export default { | @@ -134,7 +134,8 @@ export default { | ||
| 134 | } | 134 | } |
| 135 | ] | 135 | ] |
| 136 | }, | 136 | }, |
| 137 | - info: {} | 137 | + info: {}, |
| 138 | + openIds: '' | ||
| 138 | }; | 139 | }; |
| 139 | }, | 140 | }, |
| 140 | onLoad(e) { | 141 | onLoad(e) { |
| @@ -150,13 +151,21 @@ export default { | @@ -150,13 +151,21 @@ export default { | ||
| 150 | this.id = params.data.userId; | 151 | this.id = params.data.userId; |
| 151 | } | 152 | } |
| 152 | }, | 153 | }, |
| 154 | + onShow() { | ||
| 155 | + let getOpenId = getApp().globalData.openId; | ||
| 156 | + console.log('获取全局openId', getOpenId); | ||
| 157 | + if (getOpenId) { | ||
| 158 | + this.openIds = getOpenId; | ||
| 159 | + } | ||
| 160 | + }, | ||
| 153 | methods: { | 161 | methods: { |
| 154 | confrimBind(e) { | 162 | confrimBind(e) { |
| 155 | if (e) { | 163 | if (e) { |
| 164 | + console.log('Bind', e.third?.thirdUserId); | ||
| 156 | //解绑 | 165 | //解绑 |
| 157 | let httpData = { | 166 | let httpData = { |
| 158 | appUserId: e.data?.userId, | 167 | appUserId: e.data?.userId, |
| 159 | - thirdUserId: e.third?.thirdUserId | 168 | + thirdUserId: e.third?.thirdUserId == null ? this.openIds : e.third?.thirdUserId |
| 160 | }; | 169 | }; |
| 161 | uni.$u.http.delete('/yt/third', httpData).then(res => { | 170 | uni.$u.http.delete('/yt/third', httpData).then(res => { |
| 162 | if (res) { | 171 | if (res) { |
| @@ -69,6 +69,8 @@ export default { | @@ -69,6 +69,8 @@ export default { | ||
| 69 | if (res.statusCode == 200) { | 69 | if (res.statusCode == 200) { |
| 70 | this.openid = res.data.openid; | 70 | this.openid = res.data.openid; |
| 71 | this.session_key = res.data.session_key; | 71 | this.session_key = res.data.session_key; |
| 72 | + //设置全局变量openId | ||
| 73 | + getApp().globalData.openId = res.data.openid; | ||
| 72 | } | 74 | } |
| 73 | }, | 75 | }, |
| 74 | complete: e => { | 76 | complete: e => { |
| @@ -88,8 +90,8 @@ export default { | @@ -88,8 +90,8 @@ export default { | ||
| 88 | ...mapMutations(['setUserInfo']), | 90 | ...mapMutations(['setUserInfo']), |
| 89 | ...mapActions(['updateBadgeTotal']), | 91 | ...mapActions(['updateBadgeTotal']), |
| 90 | //微信授权登录 | 92 | //微信授权登录 |
| 91 | - //#ifdef MP | ||
| 92 | - onAuthorization(e) { | 93 | + //#ifdef MP-WEIXIN |
| 94 | + onAuthorization() { | ||
| 93 | /** | 95 | /** |
| 94 | * 注意:通过wx.getUserProfile并不能获取用户的openid,openid是唯一识别用户的标识, | 96 | * 注意:通过wx.getUserProfile并不能获取用户的openid,openid是唯一识别用户的标识, |
| 95 | * 所以最好在用户授权登录时就获取。调用wx.login()获取 | 97 | * 所以最好在用户授权登录时就获取。调用wx.login()获取 |
| @@ -113,8 +115,12 @@ export default { | @@ -113,8 +115,12 @@ export default { | ||
| 113 | if (res.token == '' || res.token == null) { | 115 | if (res.token == '' || res.token == null) { |
| 114 | //需要绑定,跳转我的页面进行绑定,显示绑定按钮 | 116 | //需要绑定,跳转我的页面进行绑定,显示绑定按钮 |
| 115 | uni.reLaunch({ | 117 | uni.reLaunch({ |
| 116 | - url: '/pages/personal/personal' | 118 | + url: '../../pages/personal/personal' |
| 117 | }); | 119 | }); |
| 120 | + let userInfo = { | ||
| 121 | + isThirdLogin: true //token用于判断是否登录 | ||
| 122 | + }; | ||
| 123 | + this.setUserInfo(userInfo); | ||
| 118 | } else { | 124 | } else { |
| 119 | // 不需要绑定 | 125 | // 不需要绑定 |
| 120 | // 储存登录信息 | 126 | // 储存登录信息 |
| @@ -135,6 +141,9 @@ export default { | @@ -135,6 +141,9 @@ export default { | ||
| 135 | }); | 141 | }); |
| 136 | this.saveUserInfo(); | 142 | this.saveUserInfo(); |
| 137 | this.getAlarmTotalData(); | 143 | this.getAlarmTotalData(); |
| 144 | + uni.reLaunch({ | ||
| 145 | + url: '../../pages/personal/personal' | ||
| 146 | + }); | ||
| 138 | } | 147 | } |
| 139 | }) | 148 | }) |
| 140 | .catch(e => { | 149 | .catch(e => { |
| @@ -147,7 +156,7 @@ export default { | @@ -147,7 +156,7 @@ export default { | ||
| 147 | // #ifdef MP | 156 | // #ifdef MP |
| 148 | setTimeout(() => { | 157 | setTimeout(() => { |
| 149 | uni.reLaunch({ | 158 | uni.reLaunch({ |
| 150 | - url: '/pages/personal/personal?obj=' + encodeURIComponent(JSON.stringify(obj)) | 159 | + url: '../../pages/personal/personal?obj=' + encodeURIComponent(JSON.stringify(obj)) |
| 151 | }); | 160 | }); |
| 152 | }, 500); | 161 | }, 500); |
| 153 | // #endif | 162 | // #endif |
| @@ -202,7 +211,8 @@ export default { | @@ -202,7 +211,8 @@ export default { | ||
| 202 | }; | 211 | }; |
| 203 | let userInfo = { | 212 | let userInfo = { |
| 204 | ...resObj, | 213 | ...resObj, |
| 205 | - token: true //token用于判断是否登录 | 214 | + token: true, //token用于判断是否登录 |
| 215 | + isThirdLogin: false | ||
| 206 | }; | 216 | }; |
| 207 | if (userInfo.token) { | 217 | if (userInfo.token) { |
| 208 | this.setUserInfo(userInfo); | 218 | this.setUserInfo(userInfo); |
| @@ -18,9 +18,9 @@ | @@ -18,9 +18,9 @@ | ||
| 18 | <text class="text-bottom">{{ item.sysNotice.createTime }}</text> | 18 | <text class="text-bottom">{{ item.sysNotice.createTime }}</text> |
| 19 | </view> | 19 | </view> |
| 20 | </view> | 20 | </view> |
| 21 | - <view class="item-right u-flex" style="justify-content: space-between;margin-right: ;"> | 21 | + <view class="item-right u-flex" style="justify-content: space-between;"> |
| 22 | <text class="text">{{ formatType(item.sysNotice) }}</text> | 22 | <text class="text">{{ formatType(item.sysNotice) }}</text> |
| 23 | - <u-badge v-if="item.readStatus == '0'" numberType="overflow" isDot /> | 23 | + <u-badge style="margin-right: 10rpx;" v-if="item.readStatus == '0'" numberType="overflow" isDot /> |
| 24 | </view> | 24 | </view> |
| 25 | </view> | 25 | </view> |
| 26 | </view> | 26 | </view> |
| @@ -69,7 +69,8 @@ export default { | @@ -69,7 +69,8 @@ export default { | ||
| 69 | auto: false //是否在初始化后,自动执行downCallback; 默认true | 69 | auto: false //是否在初始化后,自动执行downCallback; 默认true |
| 70 | }, | 70 | }, |
| 71 | list: [], | 71 | list: [], |
| 72 | - pre: false | 72 | + pre: false, |
| 73 | + isJudgeNextPage: '' | ||
| 73 | }; | 74 | }; |
| 74 | }, | 75 | }, |
| 75 | onLoad(e) { | 76 | onLoad(e) { |
| @@ -96,9 +97,18 @@ export default { | @@ -96,9 +97,18 @@ export default { | ||
| 96 | uni.hideKeyboard(); | 97 | uni.hideKeyboard(); |
| 97 | }, | 98 | }, |
| 98 | typeSelect(e) { | 99 | typeSelect(e) { |
| 99 | - this.page.num = 0; | 100 | + this.topBack(); |
| 101 | + this.isJudgeNextPage = e.value; | ||
| 102 | + this.page.num = 1; | ||
| 100 | this.model1.userInfo.type = e.name; | 103 | this.model1.userInfo.type = e.name; |
| 101 | - this.loadData(1, e.value == '' ? null : e.value); | 104 | + this.loadData(1, this.isJudgeNextPage == '' ? null : this.isJudgeNextPage); |
| 105 | + }, | ||
| 106 | + //筛选数据让它回到顶部 | ||
| 107 | + topBack() { | ||
| 108 | + uni.pageScrollTo({ | ||
| 109 | + scrollTop: 0, // 滚动到页面的目标位置 这个是滚动到顶部, 0 | ||
| 110 | + duration: 300 // 滚动动画的时长 | ||
| 111 | + }); | ||
| 102 | }, | 112 | }, |
| 103 | /*下拉刷新的回调 */ | 113 | /*下拉刷新的回调 */ |
| 104 | downCallback() { | 114 | downCallback() { |
| @@ -109,9 +119,15 @@ export default { | @@ -109,9 +119,15 @@ export default { | ||
| 109 | }, | 119 | }, |
| 110 | /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */ | 120 | /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */ |
| 111 | upCallback() { | 121 | upCallback() { |
| 112 | - //联网加载数据 | ||
| 113 | - this.page.num += 1; | ||
| 114 | - this.loadData(this.page.num); | 122 | + if (this.isJudgeNextPage != '') { |
| 123 | + //联网加载数据 | ||
| 124 | + this.page.num += 1; | ||
| 125 | + this.loadData(this.page.num, this.isJudgeNextPage); | ||
| 126 | + } else { | ||
| 127 | + //联网加载数据 | ||
| 128 | + this.page.num += 1; | ||
| 129 | + this.loadData(this.page.num); | ||
| 130 | + } | ||
| 115 | }, | 131 | }, |
| 116 | 132 | ||
| 117 | loadData(pageNo, t) { | 133 | loadData(pageNo, t) { |
| @@ -153,4 +169,8 @@ export default { | @@ -153,4 +169,8 @@ export default { | ||
| 153 | 169 | ||
| 154 | <style lang="scss" scoped> | 170 | <style lang="scss" scoped> |
| 155 | @import './static/systemNotify.scss'; | 171 | @import './static/systemNotify.scss'; |
| 172 | +/deep/ .u-badge--error { | ||
| 173 | + position: relative; | ||
| 174 | + right: 11rpx; | ||
| 175 | +} | ||
| 156 | </style> | 176 | </style> |
uni_modules/zhouWei-APPUpdate/changelog.md
deleted
100644 → 0
uni_modules/zhouWei-APPUpdate/js_sdk/appUpdate.js
deleted
100644 → 0
| 1 | -// #ifdef APP-PLUS | ||
| 2 | -import componentConfig from "@/config/componentConfig" | ||
| 3 | -const platform = uni.getSystemInfoSync().platform; | ||
| 4 | -// 主颜色 | ||
| 5 | -const $mainColor = componentConfig.appUpdateColor ? componentConfig.appUpdateColor : "FF5B78"; | ||
| 6 | -// 弹窗图标url | ||
| 7 | -const $iconUrl = componentConfig.appUpdateIcon ? componentConfig.appUpdateIcon : "/uni_modules/zhouWei-APPUpdate/static/ic_ar.png"; | ||
| 8 | - | ||
| 9 | -// 获取当前应用的版本号 | ||
| 10 | -export const getCurrentNo = function(callback) { | ||
| 11 | - // 获取本地应用资源版本号 | ||
| 12 | - plus.runtime.getProperty(plus.runtime.appid, function(inf) { | ||
| 13 | - callback && callback({ | ||
| 14 | - versionCode: inf.versionCode, | ||
| 15 | - versionName: inf.version | ||
| 16 | - }); | ||
| 17 | - }); | ||
| 18 | -} | ||
| 19 | -// 从服务器下载应用资源包(wgt文件) | ||
| 20 | -const getDownload = function(data) { | ||
| 21 | - let dtask; | ||
| 22 | - if(data.updateType == 'forcibly' || data.updateType == 'solicit'){ | ||
| 23 | - let popupData = { | ||
| 24 | - progress: true, | ||
| 25 | - buttonNum: 2 | ||
| 26 | - }; | ||
| 27 | - if(data.updateType == 'forcibly'){ | ||
| 28 | - popupData.buttonNum = 0; | ||
| 29 | - } | ||
| 30 | - let lastProgressValue = 0; | ||
| 31 | - let popupObj = downloadPopup(popupData); | ||
| 32 | - dtask = plus.downloader.createDownload(data.downloadUrl, { | ||
| 33 | - filename: "_doc/update/" | ||
| 34 | - }, function(download, status) { | ||
| 35 | - if (status == 200) { | ||
| 36 | - popupObj.change({ | ||
| 37 | - progressValue: 100, | ||
| 38 | - progressTip:"正在安装文件...", | ||
| 39 | - progress: true, | ||
| 40 | - buttonNum: 0 | ||
| 41 | - }); | ||
| 42 | - plus.runtime.install(download.filename, {}, function() { | ||
| 43 | - popupObj.change({ | ||
| 44 | - contentText: "应用资源更新完成!", | ||
| 45 | - buttonNum: 1, | ||
| 46 | - progress: false | ||
| 47 | - }); | ||
| 48 | - }, function(e) { | ||
| 49 | - popupObj.cancel(); | ||
| 50 | - plus.nativeUI.alert("安装文件失败[" + e.code + "]:" + e.message); | ||
| 51 | - }); | ||
| 52 | - } else { | ||
| 53 | - popupObj.change({ | ||
| 54 | - contentText: "文件下载失败...", | ||
| 55 | - buttonNum: 1, | ||
| 56 | - progress: false | ||
| 57 | - }); | ||
| 58 | - } | ||
| 59 | - }); | ||
| 60 | - dtask.start(); | ||
| 61 | - dtask.addEventListener("statechanged", function(task, status) { | ||
| 62 | - switch (task.state) { | ||
| 63 | - case 1: // 开始 | ||
| 64 | - popupObj.change({ | ||
| 65 | - progressValue:0, | ||
| 66 | - progressTip:"准备下载...", | ||
| 67 | - progress: true | ||
| 68 | - }); | ||
| 69 | - break; | ||
| 70 | - case 2: // 已连接到服务器 | ||
| 71 | - popupObj.change({ | ||
| 72 | - progressValue:0, | ||
| 73 | - progressTip:"开始下载...", | ||
| 74 | - progress: true | ||
| 75 | - }); | ||
| 76 | - break; | ||
| 77 | - case 3: | ||
| 78 | - const progress = parseInt(task.downloadedSize / task.totalSize * 100); | ||
| 79 | - if(progress - lastProgressValue >= 2){ | ||
| 80 | - lastProgressValue = progress; | ||
| 81 | - popupObj.change({ | ||
| 82 | - progressValue:progress, | ||
| 83 | - progressTip: "已下载" + progress + "%", | ||
| 84 | - progress: true | ||
| 85 | - }); | ||
| 86 | - } | ||
| 87 | - break; | ||
| 88 | - } | ||
| 89 | - }); | ||
| 90 | - // 取消下载 | ||
| 91 | - popupObj.cancelDownload = function(){ | ||
| 92 | - dtask && dtask.abort(); | ||
| 93 | - uni.showToast({ | ||
| 94 | - title: "已取消下载", | ||
| 95 | - icon:"none" | ||
| 96 | - }); | ||
| 97 | - } | ||
| 98 | - // 重启APP | ||
| 99 | - popupObj.reboot = function(){ | ||
| 100 | - plus.runtime.restart(); | ||
| 101 | - } | ||
| 102 | - } else if(data.updateType == "silent"){ | ||
| 103 | - dtask = plus.downloader.createDownload(data.downloadUrl, { | ||
| 104 | - filename: "_doc/update/" | ||
| 105 | - }, function(download, status) { | ||
| 106 | - if (status == 200) { | ||
| 107 | - plus.runtime.install(download.filename, {}, function() { | ||
| 108 | - console.log("应用资源更新完成"); | ||
| 109 | - }, function(e) { | ||
| 110 | - plus.nativeUI.alert("安装文件失败[" + e.code + "]:" + e.message); | ||
| 111 | - }); | ||
| 112 | - } else { | ||
| 113 | - plus.nativeUI.alert("文件下载失败..."); | ||
| 114 | - } | ||
| 115 | - }); | ||
| 116 | - dtask.start(); | ||
| 117 | - } | ||
| 118 | -} | ||
| 119 | -// 文字换行 | ||
| 120 | -function drawtext(text, maxWidth) { | ||
| 121 | - let textArr = text.split(""); | ||
| 122 | - let len = textArr.length; | ||
| 123 | - // 上个节点 | ||
| 124 | - let previousNode = 0; | ||
| 125 | - // 记录节点宽度 | ||
| 126 | - let nodeWidth = 0; | ||
| 127 | - // 文本换行数组 | ||
| 128 | - let rowText = []; | ||
| 129 | - // 如果是字母,侧保存长度 | ||
| 130 | - let letterWidth = 0; | ||
| 131 | - // 汉字宽度 | ||
| 132 | - let chineseWidth = 14; | ||
| 133 | - // otherFont宽度 | ||
| 134 | - let otherWidth = 7; | ||
| 135 | - for (let i = 0; i < len; i++) { | ||
| 136 | - if (/[\u4e00-\u9fa5]|[\uFE30-\uFFA0]/g.test(textArr[i])) { | ||
| 137 | - if(letterWidth > 0){ | ||
| 138 | - if(nodeWidth + chineseWidth + letterWidth * otherWidth > maxWidth){ | ||
| 139 | - rowText.push({ | ||
| 140 | - type: "text", | ||
| 141 | - content: text.substring(previousNode, i) | ||
| 142 | - }); | ||
| 143 | - previousNode = i; | ||
| 144 | - nodeWidth = chineseWidth; | ||
| 145 | - letterWidth = 0; | ||
| 146 | - } else { | ||
| 147 | - nodeWidth += chineseWidth + letterWidth * otherWidth; | ||
| 148 | - letterWidth = 0; | ||
| 149 | - } | ||
| 150 | - } else { | ||
| 151 | - if(nodeWidth + chineseWidth > maxWidth){ | ||
| 152 | - rowText.push({ | ||
| 153 | - type: "text", | ||
| 154 | - content: text.substring(previousNode, i) | ||
| 155 | - }); | ||
| 156 | - previousNode = i; | ||
| 157 | - nodeWidth = chineseWidth; | ||
| 158 | - }else{ | ||
| 159 | - nodeWidth += chineseWidth; | ||
| 160 | - } | ||
| 161 | - } | ||
| 162 | - } else { | ||
| 163 | - if(/\n/g.test(textArr[i])){ | ||
| 164 | - rowText.push({ | ||
| 165 | - type: "break", | ||
| 166 | - content: text.substring(previousNode, i) | ||
| 167 | - }); | ||
| 168 | - previousNode = i + 1; | ||
| 169 | - nodeWidth = 0; | ||
| 170 | - letterWidth = 0; | ||
| 171 | - }else if(textArr[i] == "\\" && textArr[i + 1] == "n"){ | ||
| 172 | - rowText.push({ | ||
| 173 | - type: "break", | ||
| 174 | - content: text.substring(previousNode, i) | ||
| 175 | - }); | ||
| 176 | - previousNode = i + 2; | ||
| 177 | - nodeWidth = 0; | ||
| 178 | - letterWidth = 0; | ||
| 179 | - }else if(/[a-zA-Z0-9]/g.test(textArr[i])){ | ||
| 180 | - letterWidth += 1; | ||
| 181 | - if(nodeWidth + letterWidth * otherWidth > maxWidth){ | ||
| 182 | - rowText.push({ | ||
| 183 | - type: "text", | ||
| 184 | - content: text.substring(previousNode, i + 1 - letterWidth) | ||
| 185 | - }); | ||
| 186 | - previousNode = i + 1 - letterWidth; | ||
| 187 | - nodeWidth = letterWidth * otherWidth; | ||
| 188 | - letterWidth = 0; | ||
| 189 | - } | ||
| 190 | - } else{ | ||
| 191 | - if(nodeWidth + otherWidth > maxWidth){ | ||
| 192 | - rowText.push({ | ||
| 193 | - type: "text", | ||
| 194 | - content: text.substring(previousNode, i) | ||
| 195 | - }); | ||
| 196 | - previousNode = i; | ||
| 197 | - nodeWidth = otherWidth; | ||
| 198 | - }else{ | ||
| 199 | - nodeWidth += otherWidth; | ||
| 200 | - } | ||
| 201 | - } | ||
| 202 | - } | ||
| 203 | - } | ||
| 204 | - if (previousNode < len) { | ||
| 205 | - rowText.push({ | ||
| 206 | - type: "text", | ||
| 207 | - content: text.substring(previousNode, len) | ||
| 208 | - }); | ||
| 209 | - } | ||
| 210 | - return rowText; | ||
| 211 | -} | ||
| 212 | -// 是否更新弹窗 | ||
| 213 | -function updatePopup(data, callback) { | ||
| 214 | - // 弹窗遮罩层 | ||
| 215 | - let maskLayer = new plus.nativeObj.View("maskLayer", { //先创建遮罩层 | ||
| 216 | - top: '0px', | ||
| 217 | - left: '0px', | ||
| 218 | - height: '100%', | ||
| 219 | - width: '100%', | ||
| 220 | - backgroundColor: 'rgba(0,0,0,0.5)' | ||
| 221 | - }); | ||
| 222 | - | ||
| 223 | - // 以下为计算菜单的nview绘制布局,为固定算法,使用者无关关心 | ||
| 224 | - const screenWidth = plus.screen.resolutionWidth; | ||
| 225 | - const screenHeight = plus.screen.resolutionHeight; | ||
| 226 | - //弹窗容器宽度 | ||
| 227 | - const popupViewWidth = screenWidth * 0.7; | ||
| 228 | - // 弹窗容器的Padding | ||
| 229 | - const viewContentPadding = 20; | ||
| 230 | - // 弹窗容器的宽度 | ||
| 231 | - const viewContentWidth = parseInt(popupViewWidth - (viewContentPadding * 2)); | ||
| 232 | - // 描述的列表 | ||
| 233 | - const descriptionList = drawtext(data.versionInfo, viewContentWidth); | ||
| 234 | - // 弹窗容器高度 | ||
| 235 | - let popupViewHeight = 80 + 20 + 20 + 90 + 10; | ||
| 236 | - | ||
| 237 | - let popupViewContentList = [{ | ||
| 238 | - src: $iconUrl, | ||
| 239 | - id: "logo", | ||
| 240 | - tag: "img", | ||
| 241 | - position: { | ||
| 242 | - top: "0px", | ||
| 243 | - left: (popupViewWidth - 124) / 2 + "px", | ||
| 244 | - width: "124px", | ||
| 245 | - height: "80px", | ||
| 246 | - } | ||
| 247 | - }, | ||
| 248 | - { | ||
| 249 | - tag: 'font', | ||
| 250 | - id: 'title', | ||
| 251 | - text: "发现新版本" + data.versionName, | ||
| 252 | - textStyles: { | ||
| 253 | - size: '18px', | ||
| 254 | - color: "#333", | ||
| 255 | - weight: "bold", | ||
| 256 | - whiteSpace: "normal" | ||
| 257 | - }, | ||
| 258 | - position: { | ||
| 259 | - top: '90px', | ||
| 260 | - left: viewContentPadding + "px", | ||
| 261 | - width: viewContentWidth + "px", | ||
| 262 | - height: "30px", | ||
| 263 | - } | ||
| 264 | - }]; | ||
| 265 | - const textHeight = 18; | ||
| 266 | - let contentTop = 130; | ||
| 267 | - descriptionList.forEach((item,index) => { | ||
| 268 | - if(index > 0){ | ||
| 269 | - popupViewHeight += textHeight; | ||
| 270 | - contentTop += textHeight; | ||
| 271 | - } | ||
| 272 | - popupViewContentList.push({ | ||
| 273 | - tag: 'font', | ||
| 274 | - id: 'content' + index + 1, | ||
| 275 | - text: item.content, | ||
| 276 | - textStyles: { | ||
| 277 | - size: '14px', | ||
| 278 | - color: "#666", | ||
| 279 | - lineSpacing: "50%", | ||
| 280 | - align: "left" | ||
| 281 | - }, | ||
| 282 | - position: { | ||
| 283 | - top: contentTop + "px", | ||
| 284 | - left: viewContentPadding + "px", | ||
| 285 | - width: viewContentWidth + "px", | ||
| 286 | - height: textHeight + "px", | ||
| 287 | - } | ||
| 288 | - }); | ||
| 289 | - if(item.type == "break"){ | ||
| 290 | - contentTop += 10; | ||
| 291 | - popupViewHeight += 10; | ||
| 292 | - } | ||
| 293 | - }); | ||
| 294 | - | ||
| 295 | - if(data.updateType == "forcibly"){ | ||
| 296 | - popupViewContentList.push({ | ||
| 297 | - tag: 'rect', //绘制底边按钮 | ||
| 298 | - rectStyles:{ | ||
| 299 | - radius: "6px", | ||
| 300 | - color: $mainColor | ||
| 301 | - }, | ||
| 302 | - position:{ | ||
| 303 | - bottom: viewContentPadding + 'px', | ||
| 304 | - left: viewContentPadding + "px", | ||
| 305 | - width: viewContentWidth + "px", | ||
| 306 | - height: "30px" | ||
| 307 | - } | ||
| 308 | - }); | ||
| 309 | - popupViewContentList.push({ | ||
| 310 | - tag: 'font', | ||
| 311 | - id: 'confirmText', | ||
| 312 | - text: "立即升级", | ||
| 313 | - textStyles: { | ||
| 314 | - size: '14px', | ||
| 315 | - color: "#FFF", | ||
| 316 | - lineSpacing: "0%", | ||
| 317 | - }, | ||
| 318 | - position: { | ||
| 319 | - bottom: viewContentPadding + 'px', | ||
| 320 | - left: viewContentPadding + "px", | ||
| 321 | - width: viewContentWidth + "px", | ||
| 322 | - height: "30px" | ||
| 323 | - } | ||
| 324 | - }); | ||
| 325 | - } else { | ||
| 326 | - // 绘制底边按钮 | ||
| 327 | - popupViewContentList.push({ | ||
| 328 | - tag: 'rect', | ||
| 329 | - id: 'cancelBox', | ||
| 330 | - rectStyles: { | ||
| 331 | - radius: "3px", | ||
| 332 | - borderColor: "#f1f1f1", | ||
| 333 | - borderWidth: "1px", | ||
| 334 | - }, | ||
| 335 | - position: { | ||
| 336 | - bottom: viewContentPadding + 'px', | ||
| 337 | - left: viewContentPadding + "px", | ||
| 338 | - width: (viewContentWidth - viewContentPadding) / 2 + "px", | ||
| 339 | - height: "30px", | ||
| 340 | - } | ||
| 341 | - }); | ||
| 342 | - popupViewContentList.push({ | ||
| 343 | - tag: 'rect', | ||
| 344 | - id: 'confirmBox', | ||
| 345 | - rectStyles: { | ||
| 346 | - radius: "3px", | ||
| 347 | - color: $mainColor, | ||
| 348 | - }, | ||
| 349 | - position: { | ||
| 350 | - bottom: viewContentPadding + 'px', | ||
| 351 | - left: ((viewContentWidth - viewContentPadding) / 2 + viewContentPadding * 2) + "px", | ||
| 352 | - width: (viewContentWidth - viewContentPadding) / 2 + "px", | ||
| 353 | - height: "30px", | ||
| 354 | - } | ||
| 355 | - }); | ||
| 356 | - popupViewContentList.push({ | ||
| 357 | - tag: 'font', | ||
| 358 | - id: 'cancelText', | ||
| 359 | - text: "暂不升级", | ||
| 360 | - textStyles: { | ||
| 361 | - size: '14px', | ||
| 362 | - color: "#666", | ||
| 363 | - lineSpacing: "0%", | ||
| 364 | - whiteSpace: "normal" | ||
| 365 | - }, | ||
| 366 | - position: { | ||
| 367 | - bottom: viewContentPadding + 'px', | ||
| 368 | - left: viewContentPadding + "px", | ||
| 369 | - width: (viewContentWidth - viewContentPadding) / 2 + "px", | ||
| 370 | - height: "30px", | ||
| 371 | - } | ||
| 372 | - }); | ||
| 373 | - popupViewContentList.push({ | ||
| 374 | - tag: 'font', | ||
| 375 | - id: 'confirmText', | ||
| 376 | - text: "立即升级", | ||
| 377 | - textStyles: { | ||
| 378 | - size: '14px', | ||
| 379 | - color: "#FFF", | ||
| 380 | - lineSpacing: "0%", | ||
| 381 | - whiteSpace: "normal" | ||
| 382 | - }, | ||
| 383 | - position: { | ||
| 384 | - bottom: viewContentPadding + 'px', | ||
| 385 | - left: ((viewContentWidth - viewContentPadding) / 2 + viewContentPadding * 2) + "px", | ||
| 386 | - width: (viewContentWidth - viewContentPadding) / 2 + "px", | ||
| 387 | - height: "30px", | ||
| 388 | - } | ||
| 389 | - }); | ||
| 390 | - } | ||
| 391 | - // 弹窗内容 | ||
| 392 | - let popupView = new plus.nativeObj.View("popupView", { //创建底部图标菜单 | ||
| 393 | - tag: "rect", | ||
| 394 | - top: (screenHeight - popupViewHeight) / 2 + "px", | ||
| 395 | - left: '15%', | ||
| 396 | - height: popupViewHeight + "px", | ||
| 397 | - width: "70%" | ||
| 398 | - }); | ||
| 399 | - // 绘制白色背景 | ||
| 400 | - popupView.drawRect({ | ||
| 401 | - color: "#FFFFFF", | ||
| 402 | - radius: "8px" | ||
| 403 | - }, { | ||
| 404 | - top: "40px", | ||
| 405 | - height: popupViewHeight - 40 + "px", | ||
| 406 | - }); | ||
| 407 | - | ||
| 408 | - popupView.draw(popupViewContentList); | ||
| 409 | - popupView.addEventListener("click", function(e) { | ||
| 410 | - let maxTop = popupViewHeight - viewContentPadding; | ||
| 411 | - let maxLeft = popupViewWidth - viewContentPadding; | ||
| 412 | - let buttonWidth = (viewContentWidth - viewContentPadding) / 2; | ||
| 413 | - if (e.clientY > maxTop - 30 && e.clientY < maxTop) { | ||
| 414 | - if(data.updateType == "forcibly"){ | ||
| 415 | - if(e.clientX > viewContentPadding && e.clientX < maxLeft){ | ||
| 416 | - // 立即升级 | ||
| 417 | - maskLayer.hide(); | ||
| 418 | - popupView.hide(); | ||
| 419 | - callback && callback(); | ||
| 420 | - } | ||
| 421 | - } else { | ||
| 422 | - // 暂不升级 | ||
| 423 | - if (e.clientX > viewContentPadding && e.clientX < maxLeft - buttonWidth - viewContentPadding) { | ||
| 424 | - maskLayer.hide(); | ||
| 425 | - popupView.hide(); | ||
| 426 | - } else if (e.clientX > maxLeft - buttonWidth && e.clientX < maxLeft) { | ||
| 427 | - // 立即升级 | ||
| 428 | - maskLayer.hide(); | ||
| 429 | - popupView.hide(); | ||
| 430 | - callback && callback(); | ||
| 431 | - } | ||
| 432 | - } | ||
| 433 | - | ||
| 434 | - } | ||
| 435 | - }); | ||
| 436 | - if(data.updateType == "solicit"){ | ||
| 437 | - // 点击遮罩层 | ||
| 438 | - maskLayer.addEventListener("click", function() { //处理遮罩层点击 | ||
| 439 | - maskLayer.hide(); | ||
| 440 | - popupView.hide(); | ||
| 441 | - }); | ||
| 442 | - } | ||
| 443 | - // 显示弹窗 | ||
| 444 | - maskLayer.show(); | ||
| 445 | - popupView.show(); | ||
| 446 | -} | ||
| 447 | -// 文件下载的弹窗绘图 | ||
| 448 | -function downloadPopupDrawing(data){ | ||
| 449 | - // 以下为计算菜单的nview绘制布局,为固定算法,使用者无关关心 | ||
| 450 | - const screenWidth = plus.screen.resolutionWidth; | ||
| 451 | - const screenHeight = plus.screen.resolutionHeight; | ||
| 452 | - //弹窗容器宽度 | ||
| 453 | - const popupViewWidth = screenWidth * 0.7; | ||
| 454 | - // 弹窗容器的Padding | ||
| 455 | - const viewContentPadding = 20; | ||
| 456 | - // 弹窗容器的宽度 | ||
| 457 | - const viewContentWidth = popupViewWidth - (viewContentPadding * 2); | ||
| 458 | - // 弹窗容器高度 | ||
| 459 | - let popupViewHeight = viewContentPadding * 3 + 60; | ||
| 460 | - let progressTip = data.progressTip || "准备下载..."; | ||
| 461 | - let contentText = data.contentText || "正在为您更新,请耐心等待"; | ||
| 462 | - let elementList = [ | ||
| 463 | - { | ||
| 464 | - tag: 'rect', //背景色 | ||
| 465 | - color: '#FFFFFF', | ||
| 466 | - rectStyles:{ | ||
| 467 | - radius: "8px" | ||
| 468 | - } | ||
| 469 | - }, | ||
| 470 | - { | ||
| 471 | - tag: 'font', | ||
| 472 | - id: 'title', | ||
| 473 | - text: "升级APP", | ||
| 474 | - textStyles: { | ||
| 475 | - size: '16px', | ||
| 476 | - color: "#333", | ||
| 477 | - weight: "bold", | ||
| 478 | - verticalAlign: "middle", | ||
| 479 | - whiteSpace: "normal" | ||
| 480 | - }, | ||
| 481 | - position: { | ||
| 482 | - top: viewContentPadding + 'px', | ||
| 483 | - height: "30px", | ||
| 484 | - } | ||
| 485 | - }, | ||
| 486 | - { | ||
| 487 | - tag: 'font', | ||
| 488 | - id: 'content', | ||
| 489 | - text: contentText, | ||
| 490 | - textStyles: { | ||
| 491 | - size: '14px', | ||
| 492 | - color: "#333", | ||
| 493 | - verticalAlign: "middle", | ||
| 494 | - whiteSpace: "normal" | ||
| 495 | - }, | ||
| 496 | - position: { | ||
| 497 | - top: viewContentPadding * 2 + 30 + 'px', | ||
| 498 | - height: "20px", | ||
| 499 | - } | ||
| 500 | - } | ||
| 501 | - ]; | ||
| 502 | - // 是否有进度条 | ||
| 503 | - if(data.progress){ | ||
| 504 | - popupViewHeight += viewContentPadding + 40; | ||
| 505 | - elementList = elementList.concat([ | ||
| 506 | - { | ||
| 507 | - tag: 'font', | ||
| 508 | - id: 'progressValue', | ||
| 509 | - text: progressTip, | ||
| 510 | - textStyles: { | ||
| 511 | - size: '14px', | ||
| 512 | - color: $mainColor, | ||
| 513 | - whiteSpace: "normal" | ||
| 514 | - }, | ||
| 515 | - position: { | ||
| 516 | - top: viewContentPadding * 4 + 20 + 'px', | ||
| 517 | - height: "30px" | ||
| 518 | - } | ||
| 519 | - }, | ||
| 520 | - { | ||
| 521 | - tag: 'rect', //绘制进度条背景 | ||
| 522 | - id: 'progressBg', | ||
| 523 | - rectStyles:{ | ||
| 524 | - radius: "4px", | ||
| 525 | - borderColor: "#f1f1f1", | ||
| 526 | - borderWidth: "1px", | ||
| 527 | - }, | ||
| 528 | - position:{ | ||
| 529 | - top: viewContentPadding * 4 + 60 + 'px', | ||
| 530 | - left: viewContentPadding + "px", | ||
| 531 | - width: viewContentWidth + "px", | ||
| 532 | - height: "8px" | ||
| 533 | - } | ||
| 534 | - }, | ||
| 535 | - ]); | ||
| 536 | - } | ||
| 537 | - if (data.buttonNum == 2) { | ||
| 538 | - popupViewHeight += viewContentPadding + 30; | ||
| 539 | - elementList = elementList.concat([ | ||
| 540 | - { | ||
| 541 | - tag: 'rect', //绘制底边按钮 | ||
| 542 | - rectStyles:{ | ||
| 543 | - radius: "3px", | ||
| 544 | - borderColor: "#f1f1f1", | ||
| 545 | - borderWidth: "1px", | ||
| 546 | - }, | ||
| 547 | - position:{ | ||
| 548 | - bottom: viewContentPadding + 'px', | ||
| 549 | - left: viewContentPadding + "px", | ||
| 550 | - width: (viewContentWidth - viewContentPadding) / 2 + "px", | ||
| 551 | - height: "30px" | ||
| 552 | - } | ||
| 553 | - }, | ||
| 554 | - { | ||
| 555 | - tag: 'rect', //绘制底边按钮 | ||
| 556 | - rectStyles:{ | ||
| 557 | - radius: "3px", | ||
| 558 | - color: $mainColor | ||
| 559 | - }, | ||
| 560 | - position:{ | ||
| 561 | - bottom: viewContentPadding + 'px', | ||
| 562 | - left: ((viewContentWidth - viewContentPadding) / 2 + viewContentPadding * 2) + "px", | ||
| 563 | - width: (viewContentWidth - viewContentPadding) / 2 + "px", | ||
| 564 | - height: "30px" | ||
| 565 | - } | ||
| 566 | - }, | ||
| 567 | - { | ||
| 568 | - tag: 'font', | ||
| 569 | - id: 'cancelText', | ||
| 570 | - text: "取消下载", | ||
| 571 | - textStyles: { | ||
| 572 | - size: '14px', | ||
| 573 | - color: "#666", | ||
| 574 | - lineSpacing: "0%", | ||
| 575 | - whiteSpace: "normal" | ||
| 576 | - }, | ||
| 577 | - position: { | ||
| 578 | - bottom: viewContentPadding + 'px', | ||
| 579 | - left: viewContentPadding + "px", | ||
| 580 | - width: (viewContentWidth - viewContentPadding) / 2 + "px", | ||
| 581 | - height: "30px", | ||
| 582 | - } | ||
| 583 | - }, | ||
| 584 | - { | ||
| 585 | - tag: 'font', | ||
| 586 | - id: 'confirmText', | ||
| 587 | - text: "后台下载", | ||
| 588 | - textStyles: { | ||
| 589 | - size: '14px', | ||
| 590 | - color: "#FFF", | ||
| 591 | - lineSpacing: "0%", | ||
| 592 | - whiteSpace: "normal" | ||
| 593 | - }, | ||
| 594 | - position: { | ||
| 595 | - bottom: viewContentPadding + 'px', | ||
| 596 | - left: ((viewContentWidth - viewContentPadding) / 2 + viewContentPadding * 2) + "px", | ||
| 597 | - width: (viewContentWidth - viewContentPadding) / 2 + "px", | ||
| 598 | - height: "30px", | ||
| 599 | - } | ||
| 600 | - } | ||
| 601 | - ]); | ||
| 602 | - } | ||
| 603 | - if (data.buttonNum == 1) { | ||
| 604 | - popupViewHeight += viewContentPadding + 40; | ||
| 605 | - elementList = elementList.concat([ | ||
| 606 | - { | ||
| 607 | - tag: 'rect', //绘制底边按钮 | ||
| 608 | - rectStyles:{ | ||
| 609 | - radius: "6px", | ||
| 610 | - color: $mainColor | ||
| 611 | - }, | ||
| 612 | - position:{ | ||
| 613 | - bottom: viewContentPadding + 'px', | ||
| 614 | - left: viewContentPadding + "px", | ||
| 615 | - width: viewContentWidth + "px", | ||
| 616 | - height: "40px" | ||
| 617 | - } | ||
| 618 | - }, | ||
| 619 | - { | ||
| 620 | - tag: 'font', | ||
| 621 | - id: 'confirmText', | ||
| 622 | - text: "关闭", | ||
| 623 | - textStyles: { | ||
| 624 | - size: '14px', | ||
| 625 | - color: "#FFF", | ||
| 626 | - lineSpacing: "0%", | ||
| 627 | - }, | ||
| 628 | - position: { | ||
| 629 | - bottom: viewContentPadding + 'px', | ||
| 630 | - left: viewContentPadding + "px", | ||
| 631 | - width: viewContentWidth + "px", | ||
| 632 | - height: "40px" | ||
| 633 | - } | ||
| 634 | - } | ||
| 635 | - ]); | ||
| 636 | - } | ||
| 637 | - return { | ||
| 638 | - popupViewHeight:popupViewHeight, | ||
| 639 | - popupViewWidth:popupViewWidth, | ||
| 640 | - screenHeight:screenHeight, | ||
| 641 | - viewContentWidth:viewContentWidth, | ||
| 642 | - viewContentPadding:viewContentPadding, | ||
| 643 | - elementList: elementList | ||
| 644 | - }; | ||
| 645 | -} | ||
| 646 | -// 文件下载的弹窗 | ||
| 647 | -function downloadPopup(data) { | ||
| 648 | - // 弹窗遮罩层 | ||
| 649 | - let maskLayer = new plus.nativeObj.View("maskLayer", { //先创建遮罩层 | ||
| 650 | - top: '0px', | ||
| 651 | - left: '0px', | ||
| 652 | - height: '100%', | ||
| 653 | - width: '100%', | ||
| 654 | - backgroundColor: 'rgba(0,0,0,0.5)' | ||
| 655 | - }); | ||
| 656 | - let popupViewData = downloadPopupDrawing(data); | ||
| 657 | - // 弹窗内容 | ||
| 658 | - let popupView = new plus.nativeObj.View("popupView", { //创建底部图标菜单 | ||
| 659 | - tag: "rect", | ||
| 660 | - top: (popupViewData.screenHeight - popupViewData.popupViewHeight) / 2 + "px", | ||
| 661 | - left: '15%', | ||
| 662 | - height: popupViewData.popupViewHeight + "px", | ||
| 663 | - width: "70%", | ||
| 664 | - }); | ||
| 665 | - let progressValue = 0; | ||
| 666 | - let progressTip = 0; | ||
| 667 | - let contentText = 0; | ||
| 668 | - let buttonNum = 2; | ||
| 669 | - if(data.buttonNum >= 0){ | ||
| 670 | - buttonNum = data.buttonNum; | ||
| 671 | - } | ||
| 672 | - popupView.draw(popupViewData.elementList); | ||
| 673 | - let callbackData = { | ||
| 674 | - change: function(res) { | ||
| 675 | - let progressElement = []; | ||
| 676 | - if(res.progressValue){ | ||
| 677 | - progressValue = res.progressValue; | ||
| 678 | - // 绘制进度条 | ||
| 679 | - progressElement.push({ | ||
| 680 | - tag: 'rect', //绘制进度条背景 | ||
| 681 | - id: 'progressValueBg', | ||
| 682 | - rectStyles:{ | ||
| 683 | - radius: "4px", | ||
| 684 | - color: $mainColor | ||
| 685 | - }, | ||
| 686 | - position:{ | ||
| 687 | - top: popupViewData.viewContentPadding * 4 + 60 + 'px', | ||
| 688 | - left: popupViewData.viewContentPadding + "px", | ||
| 689 | - width: popupViewData.viewContentWidth * (res.progressValue / 100) + "px", | ||
| 690 | - height: "8px" | ||
| 691 | - } | ||
| 692 | - }); | ||
| 693 | - } | ||
| 694 | - if(res.progressTip){ | ||
| 695 | - progressTip = res.progressTip; | ||
| 696 | - progressElement.push({ | ||
| 697 | - tag: 'font', | ||
| 698 | - id: 'progressValue', | ||
| 699 | - text: res.progressTip, | ||
| 700 | - textStyles: { | ||
| 701 | - size: '14px', | ||
| 702 | - color: $mainColor, | ||
| 703 | - whiteSpace: "normal" | ||
| 704 | - }, | ||
| 705 | - position: { | ||
| 706 | - top: popupViewData.viewContentPadding * 4 + 20 + 'px', | ||
| 707 | - height: "30px" | ||
| 708 | - } | ||
| 709 | - }); | ||
| 710 | - } | ||
| 711 | - if(res.contentText){ | ||
| 712 | - contentText = res.contentText; | ||
| 713 | - progressElement.push({ | ||
| 714 | - tag: 'font', | ||
| 715 | - id: 'content', | ||
| 716 | - text: res.contentText, | ||
| 717 | - textStyles: { | ||
| 718 | - size: '16px', | ||
| 719 | - color: "#333", | ||
| 720 | - whiteSpace: "normal" | ||
| 721 | - }, | ||
| 722 | - position: { | ||
| 723 | - top: popupViewData.viewContentPadding * 2 + 30 + 'px', | ||
| 724 | - height: "30px", | ||
| 725 | - } | ||
| 726 | - }); | ||
| 727 | - } | ||
| 728 | - if(res.buttonNum >= 0 && buttonNum != res.buttonNum){ | ||
| 729 | - buttonNum = res.buttonNum; | ||
| 730 | - popupView.reset(); | ||
| 731 | - popupViewData = downloadPopupDrawing(Object.assign({ | ||
| 732 | - progressValue:progressValue, | ||
| 733 | - progressTip:progressTip, | ||
| 734 | - contentText:contentText, | ||
| 735 | - },res)); | ||
| 736 | - let newElement = []; | ||
| 737 | - popupViewData.elementList.map((item,index) => { | ||
| 738 | - let have = false; | ||
| 739 | - progressElement.forEach((childItem,childIndex) => { | ||
| 740 | - if(item.id == childItem.id){ | ||
| 741 | - have = true; | ||
| 742 | - } | ||
| 743 | - }); | ||
| 744 | - if(!have){ | ||
| 745 | - newElement.push(item); | ||
| 746 | - } | ||
| 747 | - }); | ||
| 748 | - progressElement = newElement.concat(progressElement); | ||
| 749 | - popupView.setStyle({ | ||
| 750 | - tag: "rect", | ||
| 751 | - top: (popupViewData.screenHeight - popupViewData.popupViewHeight) / 2 + "px", | ||
| 752 | - left: '15%', | ||
| 753 | - height: popupViewData.popupViewHeight + "px", | ||
| 754 | - width: "70%", | ||
| 755 | - }); | ||
| 756 | - popupView.draw(progressElement); | ||
| 757 | - }else{ | ||
| 758 | - popupView.draw(progressElement); | ||
| 759 | - } | ||
| 760 | - }, | ||
| 761 | - cancel: function() { | ||
| 762 | - maskLayer.hide(); | ||
| 763 | - popupView.hide(); | ||
| 764 | - } | ||
| 765 | - } | ||
| 766 | - popupView.addEventListener("click", function(e) { | ||
| 767 | - let maxTop = popupViewData.popupViewHeight - popupViewData.viewContentPadding; | ||
| 768 | - let maxLeft = popupViewData.popupViewWidth - popupViewData.viewContentPadding; | ||
| 769 | - if (e.clientY > maxTop - 40 && e.clientY < maxTop) { | ||
| 770 | - if(buttonNum == 1){ | ||
| 771 | - // 单按钮 | ||
| 772 | - if (e.clientX > popupViewData.viewContentPadding && e.clientX < maxLeft) { | ||
| 773 | - maskLayer.hide(); | ||
| 774 | - popupView.hide(); | ||
| 775 | - callbackData.reboot(); | ||
| 776 | - } | ||
| 777 | - }else if(buttonNum == 2){ | ||
| 778 | - // 双按钮 | ||
| 779 | - let buttonWidth = (popupViewData.viewContentWidth - popupViewData.viewContentPadding) / 2; | ||
| 780 | - if (e.clientX > popupViewData.viewContentPadding && e.clientX < maxLeft - buttonWidth - popupViewData.viewContentPadding) { | ||
| 781 | - maskLayer.hide(); | ||
| 782 | - popupView.hide(); | ||
| 783 | - callbackData.cancelDownload(); | ||
| 784 | - } else if (e.clientX > maxLeft - buttonWidth && e.clientX < maxLeft) { | ||
| 785 | - maskLayer.hide(); | ||
| 786 | - popupView.hide(); | ||
| 787 | - } | ||
| 788 | - } | ||
| 789 | - } | ||
| 790 | - }); | ||
| 791 | - // 显示弹窗 | ||
| 792 | - maskLayer.show(); | ||
| 793 | - popupView.show(); | ||
| 794 | - // 改变进度条 | ||
| 795 | - return callbackData; | ||
| 796 | -} | ||
| 797 | -export default function(isPrompt = false) { | ||
| 798 | - getCurrentNo(versionInfo => { | ||
| 799 | - componentConfig.getServerNo(versionInfo, isPrompt, res => { | ||
| 800 | - if (res.updateType == "forcibly" || res.updateType == "silent") { | ||
| 801 | - if (/\.wgt$/i.test(res.downloadUrl)) { | ||
| 802 | - getDownload(res); | ||
| 803 | - } else if(/\.html$/i.test(res.downloadUrl)){ | ||
| 804 | - plus.runtime.openURL(res.downloadUrl); | ||
| 805 | - } else { | ||
| 806 | - if (platform == "android") { | ||
| 807 | - getDownload(res); | ||
| 808 | - } else { | ||
| 809 | - plus.runtime.openURL(res.downloadUrl); | ||
| 810 | - } | ||
| 811 | - } | ||
| 812 | - } else if(res.updateType == "solicit"){ | ||
| 813 | - updatePopup(res, function() { | ||
| 814 | - if (/\.wgt$/i.test(res.downloadUrl)) { | ||
| 815 | - getDownload(res); | ||
| 816 | - } else if(/\.html$/i.test(res.downloadUrl)){ | ||
| 817 | - plus.runtime.openURL(res.downloadUrl); | ||
| 818 | - } else { | ||
| 819 | - if (platform == "android") { | ||
| 820 | - getDownload(res); | ||
| 821 | - } else { | ||
| 822 | - plus.runtime.openURL(res.downloadUrl); | ||
| 823 | - } | ||
| 824 | - } | ||
| 825 | - }); | ||
| 826 | - } | ||
| 827 | - }); | ||
| 828 | - }); | ||
| 829 | -} | ||
| 830 | -// #endif |
uni_modules/zhouWei-APPUpdate/package.json
deleted
100644 → 0
| 1 | -{ | ||
| 2 | - "id": "zhouWei-APPUpdate", | ||
| 3 | - "displayName": "APP版本更新、强制更新、静默更新、下载进度(wgt更新)", | ||
| 4 | - "version": "3.0.1", | ||
| 5 | - "description": "APP版本更新、强制更新、静默更新、漂亮弹窗、下载进度(wgt更新)", | ||
| 6 | - "keywords": [ | ||
| 7 | - "APP版本更新", | ||
| 8 | - "强制更新", | ||
| 9 | - "版本更新", | ||
| 10 | - "静默更新" | ||
| 11 | -], | ||
| 12 | - "repository": "https://github.com/zhouwei1994/uni-app-demo", | ||
| 13 | - "engines": { | ||
| 14 | - "HBuilderX": "^3.1.0" | ||
| 15 | - }, | ||
| 16 | - "dcloudext": { | ||
| 17 | - "category": [ | ||
| 18 | - "JS SDK", | ||
| 19 | - "通用 SDK" | ||
| 20 | - ], | ||
| 21 | - "sale": { | ||
| 22 | - "regular": { | ||
| 23 | - "price": "0.00" | ||
| 24 | - }, | ||
| 25 | - "sourcecode": { | ||
| 26 | - "price": "0.00" | ||
| 27 | - } | ||
| 28 | - }, | ||
| 29 | - "contact": { | ||
| 30 | - "qq": "465081029" | ||
| 31 | - }, | ||
| 32 | - "declaration": { | ||
| 33 | - "ads": "无", | ||
| 34 | - "data": "无", | ||
| 35 | - "permissions": "<uses-permission android:name=\\\"android.permission.INSTALL_PACKAGES\\\"/> \n<uses-permission android:name=\\\"android.permission.REQUEST_INSTALL_PACKAGES\\\"/>" | ||
| 36 | - }, | ||
| 37 | - "npmurl": "" | ||
| 38 | - }, | ||
| 39 | - "uni_modules": { | ||
| 40 | - "dependencies": [], | ||
| 41 | - "encrypt": [], | ||
| 42 | - "platforms": { | ||
| 43 | - "cloud": { | ||
| 44 | - "tcb": "y", | ||
| 45 | - "aliyun": "y" | ||
| 46 | - }, | ||
| 47 | - "client": { | ||
| 48 | - "App": { | ||
| 49 | - "app-vue": "y", | ||
| 50 | - "app-nvue": "y" | ||
| 51 | - }, | ||
| 52 | - "H5-mobile": { | ||
| 53 | - "Safari": "n", | ||
| 54 | - "Android Browser": "n", | ||
| 55 | - "微信浏览器(Android)": "n", | ||
| 56 | - "QQ浏览器(Android)": "n" | ||
| 57 | - }, | ||
| 58 | - "H5-pc": { | ||
| 59 | - "Chrome": "n", | ||
| 60 | - "IE": "n", | ||
| 61 | - "Edge": "n", | ||
| 62 | - "Firefox": "n", | ||
| 63 | - "Safari": "n" | ||
| 64 | - }, | ||
| 65 | - "小程序": { | ||
| 66 | - "微信": "n", | ||
| 67 | - "阿里": "n", | ||
| 68 | - "百度": "n", | ||
| 69 | - "字节跳动": "n", | ||
| 70 | - "QQ": "n" | ||
| 71 | - }, | ||
| 72 | - "快应用": { | ||
| 73 | - "华为": "n", | ||
| 74 | - "联盟": "n" | ||
| 75 | - } | ||
| 76 | - } | ||
| 77 | - } | ||
| 78 | - } | ||
| 79 | -} |
uni_modules/zhouWei-APPUpdate/readme.md
deleted
100644 → 0
| 1 | -### 常见问题 | ||
| 2 | -1.安卓apk下载完成后没有更新APP? | ||
| 3 | - | ||
| 4 | -答:问题是因为没有添加APP安装应用的权限,解决方法在`manifest.json`文件里面`APP模块权限配置`的`Android打包权限配置`勾选以下权限 | ||
| 5 | -``` | ||
| 6 | -<uses-permission android:name=\"android.permission.INSTALL_PACKAGES\"/> | ||
| 7 | -<uses-permission android:name=\"android.permission.REQUEST_INSTALL_PACKAGES\"/> | ||
| 8 | -``` | ||
| 9 | -若还有问题请看[安装apk无法执行的解决方案](https://ask.dcloud.net.cn/article/35703 "安装apk无法执行的解决方案") | ||
| 10 | - | ||
| 11 | -2.APP更新后版本号没变,还是之前的版本号? | ||
| 12 | - | ||
| 13 | -答:可能是更新的安装包没有升级版本号,`manifest.json`文件里面基本设置`应用版本号`和`应用版本名称`需要升高(保持一直减少问题) | ||
| 14 | - | ||
| 15 | -3.APP更新后没有覆盖之前的APP? | ||
| 16 | - | ||
| 17 | -答:可能是更新的安装包`包名`和APP的`包名`不一样 | ||
| 18 | - | ||
| 19 | -4.弹窗的图标不显示? | ||
| 20 | - | ||
| 21 | -答:检查图片是不是放项目资源文件`static`,然后重新运行项目 | ||
| 22 | - | ||
| 23 | -5.版本号是在前端对比还是在后端接口对比? | ||
| 24 | - | ||
| 25 | -答:当前案例是本地的版本号通过接口传递给后台,是后台对比的,若需要前端对比,请在接口返回数据的地方修改,不更新就不要调用`callback`方法 | ||
| 26 | - | ||
| 27 | -6.本地的版本号比接口的版本号高还弹窗升级窗口? | ||
| 28 | - | ||
| 29 | -答:当前案例是本地的版本号通过接口传递给后台,后台对比是否需要升级,不需要升级就不要返回数据(特别是需要wgt更新的,建议这种方式) | ||
| 30 | - | ||
| 31 | -### 第一步`关键`配置APP更新接口(可以参考上面的示例) | ||
| 32 | -在项目目录下`config/componentConfig.js`里面如下配置 | ||
| 33 | -``` | ||
| 34 | -// 此方法是接口请求方法 | ||
| 35 | -import $http from '@/config/requestConfig' | ||
| 36 | -export default { | ||
| 37 | - // 发起ajax请求获取服务端版本号 | ||
| 38 | - getServerNo: (version, isPrompt = false, callback) => { | ||
| 39 | - let httpData = { | ||
| 40 | - version: version.versionCode, | ||
| 41 | - // 版本名称 | ||
| 42 | - versionName: version.versionName, | ||
| 43 | - // setupPage参数说明(判断用户是不是从设置页面点击的更新,如果是设置页面点击的更新,有不要用静默更新了,不然用户点击没反应很奇怪的) | ||
| 44 | - setupPage: isPrompt | ||
| 45 | - }; | ||
| 46 | - if (platform == "android") { | ||
| 47 | - httpData.type = 1101; | ||
| 48 | - } else { | ||
| 49 | - httpData.type = 1102; | ||
| 50 | - } | ||
| 51 | - /* 接口入参说明 | ||
| 52 | - * version: 应用当前版本号(已自动获取) | ||
| 53 | - * versionName: 应用当前版本名称(已自动获取) | ||
| 54 | - * type:平台(1101是安卓,1102是IOS) | ||
| 55 | - */ | ||
| 56 | - /****************以下是示例*******************/ | ||
| 57 | - // 可以用自己项目的请求方法(接口自己找后台要,插件不提供) | ||
| 58 | - $http.get("api/common/v1/app_version", httpData,{ | ||
| 59 | - isPrompt: isPrompt | ||
| 60 | - }).then(res => { | ||
| 61 | - /* res的数据说明 | ||
| 62 | - * | 参数名称 | 一定返回 | 类型 | 描述 | ||
| 63 | - * | -------------|--------- | --------- | ------------- | | ||
| 64 | - * | versionCode | y | int | 版本号 | | ||
| 65 | - * | versionName | y | String | 版本名称 | | ||
| 66 | - * | versionInfo | y | String | 版本信息 | | ||
| 67 | - * | updateType | y | String | forcibly = 强制更新, solicit = 弹窗确认更新, silent = 静默更新 | | ||
| 68 | - * | downloadUrl | y | String | 版本下载链接(IOS安装包更新请放跳转store应用商店链接,安卓apk和wgt文件放文件下载链接) | | ||
| 69 | - */ | ||
| 70 | - if (res && res.downloadUrl) { | ||
| 71 | - // 兼容之前的版本(updateType是新版才有的参数) | ||
| 72 | - if(res.updateType){ | ||
| 73 | - callback && callback(res); | ||
| 74 | - } else { | ||
| 75 | - if(res.forceUpdate){ | ||
| 76 | - res.updateType = "forcibly"; | ||
| 77 | - } else { | ||
| 78 | - res.updateType = "solicit"; | ||
| 79 | - } | ||
| 80 | - callback && callback(res); | ||
| 81 | - } | ||
| 82 | - } else if (isPrompt) { | ||
| 83 | - uni.showToast({ | ||
| 84 | - title: "暂无新版本", | ||
| 85 | - icon: "none" | ||
| 86 | - }); | ||
| 87 | - } | ||
| 88 | - }); | ||
| 89 | - /****************以上是示例*******************/ | ||
| 90 | - }, | ||
| 91 | - // 弹窗主颜色(不填默认粉色) | ||
| 92 | - appUpdateColor: "f00", | ||
| 93 | - // 弹窗图标(不填显示默认图标,链接配置示例如: '/static/demo/ic_attention.png') | ||
| 94 | - appUpdateIcon: '' | ||
| 95 | -} | ||
| 96 | -``` | ||
| 97 | - | ||
| 98 | -### 第二步 使用方法 | ||
| 99 | -``` | ||
| 100 | -// App.vue页面 | ||
| 101 | - | ||
| 102 | -// #ifdef APP-PLUS | ||
| 103 | -import APPUpdate from '@/uni_modules/zhouWei-APPUpdate/js_sdk/appUpdate'; | ||
| 104 | -// #endif | ||
| 105 | - | ||
| 106 | -onLaunch: function(e) { | ||
| 107 | - // #ifdef APP-PLUS | ||
| 108 | - APPUpdate(); | ||
| 109 | - // #endif | ||
| 110 | -} | ||
| 111 | -``` | ||
| 112 | - | ||
| 113 | -### 第三步 添加APP安装应用的权限 | ||
| 114 | -在`manifest.json`文件里面`APP模块权限配置`的`Android打包权限配置`勾选以下权限 | ||
| 115 | -``` | ||
| 116 | -<uses-permission android:name=\"android.permission.INSTALL_PACKAGES\"/> | ||
| 117 | -<uses-permission android:name=\"android.permission.REQUEST_INSTALL_PACKAGES\"/> | ||
| 118 | -``` | ||
| 119 | - | ||
| 120 | -### 修改弹窗的主题色或弹窗图标 | ||
| 121 | -在`APPUpdate/index.js`里面上面`$mainColor`常量中定义主题颜色,`$iconUrl`常量中定义图标地址 | ||
| 122 | - | ||
| 123 | -### 检查APP是否有新版本(一般在设置页面使用) | ||
| 124 | -``` | ||
| 125 | -// #ifdef APP-PLUS | ||
| 126 | -import APPUpdate, { getCurrentNo } from '@/uni_modules/zhouWei-APPUpdate/js_sdk/appUpdate'; | ||
| 127 | -// #endif | ||
| 128 | -export default { | ||
| 129 | - data() { | ||
| 130 | - return { | ||
| 131 | - version: "" // 版本号 | ||
| 132 | - }; | ||
| 133 | - }, | ||
| 134 | - //第一次加载 | ||
| 135 | - onLoad(e) { | ||
| 136 | - // #ifdef APP-PLUS | ||
| 137 | - getCurrentNo(res => { | ||
| 138 | - // 进页面获取当前APP版本号(用于页面显示) | ||
| 139 | - this.version = res.version; | ||
| 140 | - }); | ||
| 141 | - // #endif | ||
| 142 | - }, | ||
| 143 | - //方法 | ||
| 144 | - methods: { | ||
| 145 | - // 检查APP是否有新版本 | ||
| 146 | - onAPPUpdate() { | ||
| 147 | - // true 没有新版本的时候有提示,默认:false | ||
| 148 | - APPUpdate(true); | ||
| 149 | - } | ||
| 150 | - } | ||
| 151 | -} | ||
| 152 | -``` |
uni_modules/zhouWei-APPUpdate/static/ic_ar.png
deleted
100644 → 0
30.7 KB