diff --git a/App.vue b/App.vue index 6d7b2f9..a6c7d0f 100644 --- a/App.vue +++ b/App.vue @@ -26,7 +26,7 @@ } else if(this.envVersion === 'trial') { return 'PRE' } else { - return 'PROD' + return 'XHJ' } } } diff --git a/manifest.json b/manifest.json index f72a8c5..54b76d7 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "appid" : "__UNI__933D519", "description" : "", "versionName" : "1.0.0", - "versionCode" : "7", + "versionCode" : "9", "transformPx" : false, /* 小程序特有相关 */ "mp-weixin" : { diff --git a/pages/bindLock/bindLock.vue b/pages/bindLock/bindLock.vue index 9aa85ee..67bb202 100644 --- a/pages/bindLock/bindLock.vue +++ b/pages/bindLock/bindLock.vue @@ -36,7 +36,7 @@ export default { ...mapActions(useBluetoothStore, ['addLockUser', 'closeBluetoothConnection', 'updateBindedDeviceName', 'closeAllBluetooth', 'initAndListenBluetooth']), ...mapActions(useLockStore, ['getLockList', 'updateLockSearch']), - ...mapActions(useBasicStore, ['backAndToast']), + ...mapActions(useBasicStore, ['backAndToast', 'getNetworkType']), uopdateName(data) { this.name = data.detail.value }, @@ -48,10 +48,15 @@ export default { }) return } + const netWork = await this.getNetworkType() + if(!netWork) { + return + } uni.showLoading({ title: '添加中', mask: true }) + this.updateBindedDeviceName(this.currentLockInfo.name) const timestamp = parseInt(new Date().getTime() / 1000) const password = (Math.floor(Math.random() * 900000) + 100000).toString() const { code: addUserCode } = await this.addLockUser({ @@ -75,12 +80,14 @@ export default { }) if(addUserCode === 0) { this.closeBluetoothConnection() - this.updateBindedDeviceName(this.currentLockInfo.name) this.closeAllBluetooth() this.initAndListenBluetooth() } else if(addUserCode === -1) { uni.hideLoading() - this.backAndToast('添加失败,请重试') + uni.showToast({ + title: '添加失败,请靠近设备并保持设备处于唤醒状态', + icon: 'none' + }) return } else { uni.hideLoading() diff --git a/pages/createKey/createKey.vue b/pages/createKey/createKey.vue index f6d9f4e..3faf3b0 100644 --- a/pages/createKey/createKey.vue +++ b/pages/createKey/createKey.vue @@ -80,7 +80,7 @@ export default { this.temporaryInvalidTime = this.setTime() }, methods: { - ...mapActions(useBasicStore, ['getDeviceInfo', 'backAndToast']), + ...mapActions(useBasicStore, ['getDeviceInfo', 'backAndToast', 'getNetworkType']), ...mapActions(useLockStore, ['getKeyList', 'updateKeySearch']), setTime () { const now = new Date() @@ -100,14 +100,6 @@ export default { return } - if ((type === 'temporary' && this.temporaryName === '') || (type === 'permanent' && this.permanentName === '')) { - uni.showToast({ - title: '名称不能为空', - icon: 'none' - }) - return - } - if(type === 'temporary' && this.temporaryValidTime >= this.temporaryInvalidTime) { uni.showToast({ title: '失效时间必须大于生效时间', @@ -116,6 +108,11 @@ export default { return } + const netWork = await this.getNetworkType() + if(!netWork) { + return + } + if (this.pending) { return } diff --git a/pages/createPassword/createPassword.vue b/pages/createPassword/createPassword.vue index e45b153..4710779 100644 --- a/pages/createPassword/createPassword.vue +++ b/pages/createPassword/createPassword.vue @@ -70,7 +70,7 @@ export default { this.temporaryTime = this.setTime() }, methods: { - ...mapActions(useBasicStore, ['getDeviceInfo', 'backAndToast']), + ...mapActions(useBasicStore, ['getDeviceInfo', 'backAndToast', 'getNetworkType']), ...mapActions(useLockStore, ['getPasswordList', 'updatePasswordSearch']), setTime() { const now = new Date() @@ -89,6 +89,11 @@ export default { return } + const netWork = await this.getNetworkType() + if(!netWork) { + return + } + if(this.pending) { return } diff --git a/pages/home/home.vue b/pages/home/home.vue index b8ec76c..3900ae7 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -43,14 +43,15 @@ 余{{lock.days}}天 未生效 已冻结 - 远程开锁 + 远程开锁 + !((lock.remoteEnable === 1 && lock.keyRight === 0) || (lock.lockSetting.remoteUnlock === 1 + && lock.keyRight === 1)) === 0 ? '12rpx 24rpx 0 24rpx' :'6rpx 24rpx 0 24rpx'}"> {{ getTimeLimit(lock.keyType) }} @@ -163,9 +164,13 @@ ...mapActions(useLockStore, ['getLockList', 'updateLockList', 'getRole', 'getTimeLimit', 'updateLockSearch', 'getPowerIcon']), ...mapActions(useBluetoothStore, ['getBluetoothStatus', 'initAndListenBluetooth', 'updateCurrentLockInfo', 'checkSetting', 'updateKeyId', 'resetDevice']), - ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']), + ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo', 'getNetworkType']), async deleteLock(lock, groupIndex, lockIndex) { const that = this + const netWork = await this.getNetworkType() + if(!netWork) { + return + } that.$refs['swipeItem' + groupIndex][lockIndex].closeHandler() if(lock.userType !== 110301 && lock.keyRight === 1) { diff --git a/pages/keyList/keyList.vue b/pages/keyList/keyList.vue index 4aa2274..eab770d 100644 --- a/pages/keyList/keyList.vue +++ b/pages/keyList/keyList.vue @@ -23,8 +23,8 @@ {{ key.keyName }} - + {{ getKeyStatus(key.keyStatus) }} diff --git a/pages/lockDetail/lockDetail.vue b/pages/lockDetail/lockDetail.vue index 901c600..2c14044 100644 --- a/pages/lockDetail/lockDetail.vue +++ b/pages/lockDetail/lockDetail.vue @@ -143,10 +143,6 @@ export default { if(this.currentLockInfo.lockSetting.appUnlockOnline) { const netWork = await this.getNetworkType() if(!netWork) { - uni.showToast({ - title: '网络访问失败,请检查网络是否正常', - icon: 'none' - }) return } } diff --git a/pages/passwordDetail/passwordDetail.vue b/pages/passwordDetail/passwordDetail.vue index ca9feb0..f2d4002 100644 --- a/pages/passwordDetail/passwordDetail.vue +++ b/pages/passwordDetail/passwordDetail.vue @@ -54,8 +54,12 @@ export default { timeFormat, ...mapActions(useBluetoothStore, ['setLockPassword', 'closeBluetoothConnection']), ...mapActions(useLockStore, ['updatePasswordSearch', 'getPasswordList']), - ...mapActions(useBasicStore, ['backAndToast']), + ...mapActions(useBasicStore, ['backAndToast', 'getNetworkType']), async deletePassword () { + const netWork = await this.getNetworkType() + if(!netWork) { + return + } const that = this uni.showModal({ title: '提示', diff --git a/pages/passwordList/passwordList.vue b/pages/passwordList/passwordList.vue index 6efa56f..a380201 100644 --- a/pages/passwordList/passwordList.vue +++ b/pages/passwordList/passwordList.vue @@ -94,7 +94,7 @@ export default { this.clearList('password') }, methods: { - ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']), + ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo', 'getNetworkType']), ...mapActions(useLockStore, ['getPasswordList', 'updateCurrentPasswordInfo', 'updatePasswordSearch', 'getPasswordStatus']), ...mapActions(useBluetoothStore, ['resetLockPassword', 'setLockPassword', 'closeBluetoothConnection']), toPasswordDetail(password) { @@ -104,6 +104,10 @@ export default { }) }, async deletePassword(data) { + const netWork = await this.getNetworkType() + if(!netWork) { + return + } const password = data const that = this let index = this.passwordList.findIndex(item => item.keyboardPwdId === password.keyboardPwdId) @@ -167,6 +171,10 @@ export default { }, async resetPassword() { const that = this + const netWork = await this.getNetworkType() + if(!netWork) { + return + } uni.showModal({ title: '提示', content: '确定要重置密码,该锁的所有密码都将被删除', diff --git a/pages/safeQuestion/safeQuestion.vue b/pages/safeQuestion/safeQuestion.vue index 7b59ca3..cc662c1 100644 --- a/pages/safeQuestion/safeQuestion.vue +++ b/pages/safeQuestion/safeQuestion.vue @@ -29,8 +29,12 @@ export default { this.getQuestionAnswer() }, methods: { - ...mapActions(useBasicStore, ['routeJump']), + ...mapActions(useBasicStore, ['routeJump', 'getNetworkType']), async getQuestionAnswer() { + const netWork = await this.getNetworkType() + if(!netWork) { + return + } const { code, data, message } = await getQuestionAnswerRequest() if(code === 0) { this.questionAnswer = data diff --git a/pages/searchDevice/searchDevice.vue b/pages/searchDevice/searchDevice.vue index 3a33715..a489930 100644 --- a/pages/searchDevice/searchDevice.vue +++ b/pages/searchDevice/searchDevice.vue @@ -43,8 +43,12 @@ export default { methods: { ...mapActions(useBluetoothStore, ['getBluetoothDevices', 'stopGetBluetoothDevices', 'updateCurrentLockInfo', 'getPublicKey', 'getCommKey', 'connectBluetoothDevice', 'updateServerTimestamp', 'getLockStatus']), - ...mapActions(useBasicStore, ['getDeviceInfo', 'routeJump']), + ...mapActions(useBasicStore, ['getDeviceInfo', 'routeJump', 'getNetworkType']), async connect(device) { + const netWork = await this.getNetworkType() + if(!netWork) { + return + } uni.showLoading({ title: '连接中', mask: true @@ -63,14 +67,14 @@ export default { deviceId: device.deviceId }) const result = await this.connectBluetoothDevice() - this.stopGetBluetoothDevices() if(result) { + this.stopGetBluetoothDevices() const { code: getPublicKeyCode } = await this.getPublicKey(this.currentLockInfo.name) console.log('获取公钥返回', getPublicKeyCode, [...this.currentLockInfo.publicKey]) if(getPublicKeyCode !== 0) { uni.hideLoading() uni.showToast({ - title: '连接失败,请重试', + title: '连接失败,请靠近设备并保持设备处于唤醒状态', icon: 'none' }) return @@ -81,7 +85,7 @@ export default { if(getCommKeyCode !== 0) { uni.hideLoading() uni.showToast({ - title: '连接失败,请重试', + title: '连接失败,请靠近设备并保持设备处于唤醒状态', icon: 'none' }) return @@ -97,7 +101,7 @@ export default { if (code !== 0) { uni.hideLoading() uni.showToast({ - title: '连接失败,请重试', + title: '连接失败,请靠近设备并保持设备处于唤醒状态', icon: 'none' }) return @@ -107,12 +111,11 @@ export default { name: 'selectAddress' }) } else { - this.getBluetoothDevices() + uni.hideLoading() uni.showToast({ - title: '连接失败,请重试', + title: '连接失败,请靠近设备并保持设备处于唤醒状态', icon: 'none' }) - uni.hideLoading() } } } diff --git a/pages/setting/setting.vue b/pages/setting/setting.vue index 18eb25a..94c784e 100644 --- a/pages/setting/setting.vue +++ b/pages/setting/setting.vue @@ -120,7 +120,7 @@ export default { timeFormat, ...mapActions(useBluetoothStore, ['resetDevice', 'updateCurrentLockInfo']), ...mapActions(useLockStore, ['getLockList', 'updateLockSearch', 'convertWeekDaysToChineseString']), - ...mapActions(useBasicStore, ['backAndToast']), + ...mapActions(useBasicStore, ['backAndToast', 'getNetworkType']), changeRadio() { this.checked = !this.checked }, @@ -156,6 +156,10 @@ export default { } }, async changeUnlockApp(value) { + const netWork = await this.getNetworkType() + if(!netWork) { + return + } uni.showLoading({ title: '更新中', mask: true @@ -182,7 +186,11 @@ export default { }) } }, - deleteLock() { + async deleteLock() { + const netWork = await this.getNetworkType() + if(!netWork) { + return + } const that = this if(this.currentLockInfo.userType !== 110301 && this.currentLockInfo.keyRight === 1) { this.showModal = true diff --git a/pages/updateEmail/updateEmail.vue b/pages/updateEmail/updateEmail.vue index 66242ce..f4c75ca 100644 --- a/pages/updateEmail/updateEmail.vue +++ b/pages/updateEmail/updateEmail.vue @@ -43,7 +43,7 @@ export default { }, methods: { ...mapActions(useUserStore, ['updateUserInfo']), - ...mapActions(useBasicStore, ['routeJump', 'backAndToast']), + ...mapActions(useBasicStore, ['routeJump', 'backAndToast', 'getNetworkType']), updateInputEmail(data) { this.email = data.detail.value }, @@ -61,6 +61,10 @@ export default { }) return } + const netWork = await this.getNetworkType() + if(!netWork) { + return + } const { code } = await getEmailCodeRequest({ account: this.email, channel: '2', @@ -84,6 +88,10 @@ export default { return } if (this.verificationCode.length === 6 && test.digits(this.verificationCode)) { + const netWork = await this.getNetworkType() + if(!netWork) { + return + } if(this.pending){ return } diff --git a/pages/updateName/updateName.vue b/pages/updateName/updateName.vue index 23f0ffd..ea86dd2 100644 --- a/pages/updateName/updateName.vue +++ b/pages/updateName/updateName.vue @@ -27,7 +27,7 @@ export default { }, methods: { ...mapActions(useUserStore, ['updateUserInfo']), - ...mapActions(useBasicStore, ['backAndToast']), + ...mapActions(useBasicStore, ['backAndToast', 'getNetworkType']), updateInput(data) { this.nickname = data.detail.value console.log(data) @@ -40,6 +40,10 @@ export default { }) return } + const netWork = await this.getNetworkType() + if(!netWork) { + return + } if(this.pending) { return } diff --git a/pages/updatePassword/updatePassword.vue b/pages/updatePassword/updatePassword.vue index 87e9317..ac61bd6 100644 --- a/pages/updatePassword/updatePassword.vue +++ b/pages/updatePassword/updatePassword.vue @@ -33,7 +33,7 @@ export default { }, methods: { ...mapActions(useUserStore, ['updateUserInfo']), - ...mapActions(useBasicStore, ['backAndToast']), + ...mapActions(useBasicStore, ['backAndToast', 'getNetworkType']), updateNewPassword (data) { this.password = data.detail.value }, @@ -44,6 +44,10 @@ export default { if (this.text !== '获取验证码') { return } + const netWork = await this.getNetworkType() + if(!netWork) { + return + } const { code, message } = await getEmailCodeRequest({ channel: '1', codeType: 9 @@ -92,6 +96,10 @@ export default { }) return } + const netWork = await this.getNetworkType() + if(!netWork) { + return + } if(this.pending) { return } diff --git a/pages/updateSafeQuestion/updateSafeQuestion.vue b/pages/updateSafeQuestion/updateSafeQuestion.vue index 40bbf71..598b6f1 100644 --- a/pages/updateSafeQuestion/updateSafeQuestion.vue +++ b/pages/updateSafeQuestion/updateSafeQuestion.vue @@ -76,7 +76,7 @@ export default { }, methods: { ...mapActions(useUserStore, ['updateUserInfo']), - ...mapActions(useBasicStore, ['backAndToast']), + ...mapActions(useBasicStore, ['backAndToast', 'getNetworkType']), async updateAnswer() { console.log('答案', this.answer) for(let i = 0; i < this.answer.length; i++) { @@ -97,6 +97,10 @@ export default { return } } + const netWork = await this.getNetworkType() + if(!netWork) { + return + } if(this.pending) { return } diff --git a/pages/verifyEmail/verifyEmail.vue b/pages/verifyEmail/verifyEmail.vue index a0740ef..1e5519e 100644 --- a/pages/verifyEmail/verifyEmail.vue +++ b/pages/verifyEmail/verifyEmail.vue @@ -29,11 +29,15 @@ export default { }, methods: { ...mapActions(useUserStore, ['updateUserInfo']), - ...mapActions(useBasicStore, ['routeJump']), + ...mapActions(useBasicStore, ['routeJump', 'getNetworkType']), async getEmailCode() { if(this.text !== '获取验证码') { return } + const netWork = await this.getNetworkType() + if(!netWork) { + return + } const { code } = await getEmailCodeRequest({ channel: '2', codeType: 7 @@ -49,6 +53,10 @@ export default { }, async toUpdateEmail() { if(this.verificationCode.length === 6 && test.digits(this.verificationCode)) { + const netWork = await this.getNetworkType() + if(!netWork) { + return + } const { code, data, message } = await unbindEmailTokenRequest({ verificationCode: this.verificationCode }) diff --git a/stores/basic.js b/stores/basic.js index 09e440a..cfb8de8 100644 --- a/stores/basic.js +++ b/stores/basic.js @@ -140,6 +140,10 @@ export const useBasicStore = defineStore('basic', { uni.getNetworkType({ success: function (res) { if(res.networkType === 'none') { + uni.showToast({ + title: '网络访问失败,请检查网络是否正常', + icon: 'none' + }) resolve(false) return } @@ -210,7 +214,7 @@ export const useBasicStore = defineStore('basic', { title: message, icon: 'none' }) - }, 200) + }, 300) } }) } diff --git a/stores/bluetooth.js b/stores/bluetooth.js index 784f5ce..c97d811 100644 --- a/stores/bluetooth.js +++ b/stores/bluetooth.js @@ -73,17 +73,15 @@ export const useBluetoothStore = defineStore('ble', { // 设备keyID keyId: '0', // 刚绑定的设备名称 - bindedDeviceName: '' + bindedDeviceNameList: [] } }, actions: { // 保存刚绑定的设备名称 updateBindedDeviceName(name) { - this.bindedDeviceName = name - setTimeout(() => { - this.bindedDeviceName = '' - console.log('清空设备名称') - }, 15000) + if(!this.bindedDeviceNameList.includes(name)) { + this.bindedDeviceNameList.push(name) + } }, // 更新keyId updateKeyId(keyId) { @@ -682,20 +680,21 @@ export const useBluetoothStore = defineStore('ble', { }) }, async fail(res) { + console.log('连接失败', res) if(res.errno === 1509007) { resolve(true) return } if(res.errno === 1509001 && number < 1) { + // 超时直接返回 + resolve(false) + return + } + + if(number < 1) { // 重新连接 resolve(await that.connectBluetoothDevice(number + 1)) } - uni.showToast({ - title: '连接失败,请靠近设备并保持设备处于唤醒状态', - icon: 'none' - }) - console.log('连接失败', res) - resolve(false) } }) }) @@ -770,7 +769,7 @@ export const useBluetoothStore = defineStore('ble', { if(deviceList[i]?.name === that.currentLockInfo.name) { const uuid = deviceList[i]?.advertisServiceUUIDs[0] console.log('设备UUID', uuid, uuid.slice(2,8), uuid.slice(30,32)) - if(uuid && uuid.slice(2,8)==='758824' && (uuid.slice(30,32)==='01' || that.bindedDeviceName === that.currentLockInfo.name)) { + if(uuid && uuid.slice(2,8)==='758824' && (uuid.slice(30,32)==='01' || that.bindedDeviceNameList.includes(that.currentLockInfo.name))) { uni.stopBluetoothDevicesDiscovery() clearTimeout(timer2) clearInterval(timer1)