Merge branch 'fanpeng' into 'master'
1. 修改重连逻辑 See merge request StarlockTeam/wx-starlock!7
This commit is contained in:
commit
fd23acc4c9
2
App.vue
2
App.vue
@ -26,7 +26,7 @@
|
||||
} else if(this.envVersion === 'trial') {
|
||||
return 'PRE'
|
||||
} else {
|
||||
return 'PROD'
|
||||
return 'XHJ'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
"appid" : "__UNI__933D519",
|
||||
"description" : "",
|
||||
"versionName" : "1.0.0",
|
||||
"versionCode" : "7",
|
||||
"versionCode" : "9",
|
||||
"transformPx" : false,
|
||||
/* 小程序特有相关 */
|
||||
"mp-weixin" : {
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -43,14 +43,15 @@
|
||||
<view v-if="lock.days" class="lock-status" style="background-color: #63b8af">余{{lock.days}}天</view>
|
||||
<view v-if="lock.keyStatus === 110403" class="lock-status" style="background-color: #63b8af">未生效</view>
|
||||
<view v-if="lock.keyStatus === 110405" class="lock-status">已冻结</view>
|
||||
<view v-if="lock.lockSetting.remoteUnlock === 1" class="lock-status" style="background-color:
|
||||
#63b8af">远程开锁
|
||||
<view v-if="(lock.remoteEnable === 1 && lock.keyRight === 0) ||
|
||||
(lock.lockSetting.remoteUnlock === 1 && lock.keyRight === 1)" class="lock-status"
|
||||
style="background-color: #63b8af">远程开锁
|
||||
</view>
|
||||
</view>
|
||||
<view class="lock-time"
|
||||
:style="{padding: lock.keyStatus === 110401 && !lock.days &&
|
||||
lock.lockSetting.remoteUnlock === 0 ? '12rpx 24rpx 0 24rpx'
|
||||
:'6rpx 24rpx 0 24rpx'}">
|
||||
!((lock.remoteEnable === 1 && lock.keyRight === 0) || (lock.lockSetting.remoteUnlock === 1
|
||||
&& lock.keyRight === 1)) === 0 ? '12rpx 24rpx 0 24rpx' :'6rpx 24rpx 0 24rpx'}">
|
||||
<view v-if="lock.keyType === 1 || lock.keyType === 3" style="font-size: 32rpx">{{
|
||||
getTimeLimit(lock.keyType) }}</view>
|
||||
<view v-else>
|
||||
@ -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) {
|
||||
|
||||
@ -23,8 +23,8 @@
|
||||
<view class="key-right">
|
||||
<view style="display: flex;">
|
||||
<view class="key-right-top">{{ key.keyName }}</view>
|
||||
<image class="key-admin" mode="aspectFill" v-if="key.keyRight === 1 && key.lockSetting.remoteUnlock
|
||||
=== 1" src="/static/images/icon_remote_unlock.png"></image>
|
||||
<image class="key-admin" mode="aspectFill" v-if="key.remoteEnable === 1"
|
||||
src="/static/images/icon_remote_unlock.png"></image>
|
||||
<image class="key-admin" mode="aspectFill" v-if="key.keyRight === 1" src="/static/images/icon_admin.png"></image>
|
||||
<view class="key-status" :style="{ color: (key.keyStatus === 110401) ? '#63b8af' : '#df282d' }">
|
||||
{{ getKeyStatus(key.keyStatus) }}
|
||||
|
||||
@ -143,10 +143,6 @@ export default {
|
||||
if(this.currentLockInfo.lockSetting.appUnlockOnline) {
|
||||
const netWork = await this.getNetworkType()
|
||||
if(!netWork) {
|
||||
uni.showToast({
|
||||
title: '网络访问失败,请检查网络是否正常',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@ -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: '提示',
|
||||
|
||||
@ -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: '确定要重置密码,该锁的所有密码都将被删除',
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
})
|
||||
|
||||
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user