Merge branch 'fanpeng' into 'develop'

Fanpeng

See merge request StarlockTeam/wx-starlock!42
This commit is contained in:
范鹏 2025-06-10 06:42:13 +00:00
commit 8a80d498de
28 changed files with 577 additions and 323 deletions

View File

@ -10,7 +10,8 @@ module.exports = {
getApp: 'writable',
wx: 'writable',
getCurrentPages: 'writable',
requirePlugin: 'writable'
requirePlugin: 'writable',
plus: 'writable'
},
// 指定如何解析语法
parser: 'vue-eslint-parser',

View File

@ -23,13 +23,15 @@
if (envVersionStorage) {
return envVersionStorage
}
// #ifdef MP-WEIXIN
if (this.envVersion === 'develop') {
return 'XHJ'
}
if (this.envVersion === 'trial') {
return 'XHJ'
}
return 'DEV'
// #endif
return 'XHJ'
}
},
computed: {
@ -47,7 +49,6 @@
this.onBluetoothState()
//
const checkResult = await this.checkSetting()
console.log(checkResult)
if (checkResult === true) {
this.initAndListenBluetooth(false)
}

View File

@ -10,3 +10,12 @@ export function getCountryListRequest(data) {
data
})
}
// 获取app信息
export function getAppInfoRequest(data) {
return request({
url: '/app/getAppInfo',
method: 'POST',
data
})
}

View File

@ -136,3 +136,12 @@ export function getWebUrlRequest(data) {
data
})
}
// 退出登录
export function logoutRequest(data) {
return request({
url: '/v3/user/logout',
method: 'POST',
data
})
}

View File

@ -4,12 +4,6 @@ export const myRequest = async (option = {}) => {
const envConfig = getApp().globalData.getEnvConfig()
const baseConfig = env[envConfig]
console.log('=== 请求入参 ===')
console.log('URL:', baseConfig.baseUrl + option.url)
console.log('Data:', JSON.stringify(option.data || {}, null, 2))
console.log('Method:', option.method || 'GET')
console.log('================')
return new Promise((resolve, reject) => {
uni.request({
url: baseConfig.baseUrl + option.url,
@ -21,10 +15,14 @@ export const myRequest = async (option = {}) => {
...option.header
},
success: result => {
console.log('=== 请求出参 ===')
console.log('StatusCode:', result.statusCode)
console.log('Response:', JSON.stringify(result.data, null, 2))
console.log('================')
console.log({
url: baseConfig.baseUrl + option.url,
request: option.data,
response: result.data,
statusCode: result.statusCode,
method: option.method,
header: option.header
})
if (result.statusCode === 200) {
resolve(result)

View File

@ -323,31 +323,14 @@
xWidth: Math.round(moveLeftDistance)
}
console.log('=== 滑动验证请求参数 ===')
console.log('params:', JSON.stringify(_this.params, null, 2))
console.log('moveLeftDistance:', moveLeftDistance)
console.log('captchaVerification:', captchaVerification)
console.log('token:', _this.backToken)
console.log('data:', JSON.stringify(data, null, 2))
console.log('=====================')
myRequest({
url: `/user/sendValidationCode`,
data,
method: 'POST'
})
.then(result => {
console.log('=== 滑动验证响应数据 ===')
console.log('result:', JSON.stringify(result, null, 2))
console.log('=====================')
if (result && result.data) {
let res = result.data
console.log('=== 验证结果详情 ===')
console.log('errorCode:', res.errorCode)
console.log('errorMsg:', res.errorMsg)
console.log('res.data:', JSON.stringify(res.data, null, 2))
console.log('==================')
if (res.errorCode === 0) {
this.moveBlockBackgroundColor = '#5cb85c'
@ -377,9 +360,8 @@
}
})
.catch(error => {
console.log('=== 滑动验证请求错误 ===')
console.log('error:', error)
console.log('=====================')
this.handleValidationError('网络错误,请重试')
})
}
@ -455,11 +437,6 @@
captchaType: this.captchaType || 'blockPuzzle'
}
console.log('=== getPictrue 请求参数 ===')
console.log('params:', JSON.stringify(this.params, null, 2))
console.log('data:', JSON.stringify(data, null, 2))
console.log('========================')
myRequest({
url: '/user/getSliderVerifyImg',
data,
@ -469,9 +446,6 @@
this.loading = false
if (result && result.data) {
let res = result.data
console.log('=== getPictrue 响应数据 ===')
console.log('res:', JSON.stringify(res, null, 2))
console.log('========================')
if (res.errorCode === 0 && res.data) {
this.backImgBase = res.data.bigImg

View File

@ -1,42 +1,109 @@
{
"name" : "wx-starlock",
"appid" : "__UNI__933D519",
"description" : "",
"versionName" : "1.3.0",
"versionCode" : "37",
"mp-weixin" : {
"appid" : "wx9829a39e65550757",
"setting" : {
"urlCheck" : true,
"minified" : true
},
"permission" : {
"scope.bluetooth" : {
"desc" : "蓝牙将用于控制和管理您的智能门锁"
}
},
"requiredPrivateInfos" : [ "getLocation" ],
"usingComponents" : true,
"lazyCodeLoading" : "requiredComponents",
"optimization" : {
"subPackages" : true
},
"plugins" : {
"xp2p" : {
"version" : "latest",
"provider" : "wx1319af22356934bf",
"export" : "exportForXp2pPlugin.js"
},
"wmpf-voip" : {
"version" : "latest",
"provider" : "wxf830863afde621eb",
"genericsImplementation" : {
"call-page-plugin" : {
"custombox" : "pages/main/customBox"
}
}
}
}
"name": "星星锁Lite",
"appid": "__UNI__933D519",
"description": "",
"versionName": "1.3.0",
"versionCode": "37",
"mp-weixin": {
"appid": "wx9829a39e65550757",
"setting": {
"urlCheck": true,
"minified": true
},
"vueVersion" : "3"
"permission": {
"scope.bluetooth": {
"desc": "蓝牙将用于控制和管理您的智能门锁"
}
},
"requiredPrivateInfos": ["getLocation"],
"usingComponents": true,
"lazyCodeLoading": "requiredComponents",
"optimization": {
"subPackages": true
},
"plugins": {
"xp2p": {
"version": "latest",
"provider": "wx1319af22356934bf",
"export": "exportForXp2pPlugin.js"
},
"wmpf-voip": {
"version": "latest",
"provider": "wxf830863afde621eb",
"genericsImplementation": {
"call-page-plugin": {
"custombox": "pages/main/customBox"
}
}
}
}
},
"vueVersion": "3",
"app-plus": {
"distribute": {
"icons": {
"android": {
"hdpi": "unpackage/res/icons/72x72.png",
"xhdpi": "unpackage/res/icons/96x96.png",
"xxhdpi": "unpackage/res/icons/144x144.png",
"xxxhdpi": "unpackage/res/icons/192x192.png"
},
"ios": {
"appstore": "unpackage/res/icons/1024x1024.png",
"ipad": {
"app": "unpackage/res/icons/76x76.png",
"app@2x": "unpackage/res/icons/152x152.png",
"notification": "unpackage/res/icons/20x20.png",
"notification@2x": "unpackage/res/icons/40x40.png",
"proapp@2x": "unpackage/res/icons/167x167.png",
"settings": "unpackage/res/icons/29x29.png",
"settings@2x": "unpackage/res/icons/58x58.png",
"spotlight": "unpackage/res/icons/40x40.png",
"spotlight@2x": "unpackage/res/icons/80x80.png"
},
"iphone": {
"app@2x": "unpackage/res/icons/120x120.png",
"app@3x": "unpackage/res/icons/180x180.png",
"notification@2x": "unpackage/res/icons/40x40.png",
"notification@3x": "unpackage/res/icons/60x60.png",
"settings@2x": "unpackage/res/icons/58x58.png",
"settings@3x": "unpackage/res/icons/87x87.png",
"spotlight@2x": "unpackage/res/icons/80x80.png",
"spotlight@3x": "unpackage/res/icons/120x120.png"
}
}
},
"android": {
"permissions": [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\" />",
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" />",
"<uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\" />",
"<uses-permission android:name=\"android.permission.BLUETOOTH\" />",
"<uses-permission android:name=\"android.permission.BLUETOOTH_SCAN\" />",
"<uses-permission android:name=\"android.permission.BLUETOOTH_CONNECT\" />"
]
}
},
"modules": {
"Bluetooth": {}
},
"splashscreen": {
"waiting": false
}
}
}

View File

@ -116,19 +116,22 @@
{
"path": "login",
"style": {
"navigationBarTitleText": "登录"
"navigationBarTitleText": "登录",
"disableScroll": true
}
},
{
"path": "register",
"style": {
"navigationBarTitleText": "注册"
"navigationBarTitleText": "注册",
"disableScroll": true
}
},
{
"path": "forgotPassword",
"style": {
"navigationBarTitleText": "忘记密码"
"navigationBarTitleText": "忘记密码",
"disableScroll": true
}
},
{

View File

@ -130,8 +130,8 @@
nowTime: this.serverTimestamp,
localTime: timestamp
})
uni.hideLoading()
if (code !== 0) {
uni.hideLoading()
uni.showToast({
title: '连接失败,请靠近设备并保持设备处于唤醒状态',
icon: 'none'

View File

@ -275,7 +275,9 @@
}
const { code, data, message } = await createKeyRequest(params)
if (code === 0) {
// #ifdef MP-WEIXIN
uni.reportEvent('create_key', {})
// #endif
this.updateKeySearch({
...this.keySearch,
pageNo: 1

View File

@ -455,7 +455,9 @@
})
uni.hideLoading()
if (requestCode === 0) {
// #ifdef MP-WEIXIN
uni.reportEvent('create_password', {})
// #endif
$lock.updatePasswordSearch({
...$lock.passwordSearch,
pageNo: 1
@ -562,7 +564,10 @@
}
const { code, data, message } = await createPsaawordRequest(params)
if (code === 0) {
// #ifdef MP-WEIXIN
uni.reportEvent('create_password', {})
// #endif
$lock.updatePasswordSearch({
...$lock.passwordSearch,
pageNo: 1
@ -638,23 +643,23 @@
}
.text {
padding: 0 32rpx;
margin-top: 40rpx;
margin-bottom: 50rpx;
color: #262626;
font-size: 26rpx;
padding: 0 32rpx;
color: #262626;
}
.button {
border-radius: 64rpx;
width: 686rpx;
margin-left: 32rpx;
height: 100rpx;
line-height: 100rpx;
text-align: center;
background-color: #63b8af;
color: #fff;
margin-left: 32rpx;
font-size: 32rpx;
font-weight: bold;
line-height: 100rpx;
color: #fff;
text-align: center;
background-color: #63b8af;
border-radius: 64rpx;
}
</style>

View File

@ -129,10 +129,12 @@
$bluetooth.closeBluetoothConnection()
})
// #ifdef MP-WEIXIN
uni.reportEvent('open_door', {
result: code,
duration: new Date().getTime() - timestamp
})
// #endif
if (code === 0) {
uni.showToast({

View File

@ -363,15 +363,19 @@
onlineToken: onlineToken.value
})
if (type === 'open') {
// #ifdef MP-WEIXIN
uni.reportEvent('open_door', {
result: code,
duration: new Date().getTime() - timestamp
})
// #endif
} else if (type === 'close') {
// #ifdef MP-WEIXIN
uni.reportEvent('close_door', {
result: code,
duration: new Date().getTime() - timestamp
})
// #endif
}
if (code === 0) {
$bluetooth

View File

@ -11,6 +11,7 @@
></image>
</view>
<view class="view-line"></view>
<!-- #ifdef MP-WEIXIN -->
<label for="contact">
<view class="view-button">
<view>客服</view>
@ -21,6 +22,19 @@
></image>
</view>
</label>
<!-- #endif -->
<!-- #ifdef APP-PLUS -->
<view @click="toContact">
<view class="view-button">
<view>客服</view>
<image
class="icon-arrow"
src="https://oss-lock.xhjcn.ltd/mp/icon_arrow.png"
mode="aspectFill"
></image>
</view>
</view>
<!-- #endif -->
<view class="view-line"></view>
<view class="view-button" @click="toWebview()">
<view>公司介绍</view>
@ -56,9 +70,14 @@
>切换环境</view
>
</view>
<!-- #ifdef MP-WEIXIN -->
<label for="changePhone">
<view class="switch-account">切换账号</view>
</label>
<!-- #endif -->
<!-- #ifdef APP-PLUS -->
<view class="switch-account !bg-red-500" @click="logout">退出</view>
<!-- #endif -->
</view>
<view v-else>
<view class="tips">因智能门锁与账号绑定登录为手机号登录</view>
@ -68,9 +87,13 @@
<view class="env" v-if="env">
<view class="env-text">{{ env.name }} {{ env.version }}+{{ env.buildNumber }}</view>
<view>{{ env.baseUrl.split('/').slice(0, 3).join('/') }}</view>
<view v-if="envVersion !== 'release' && env" class="env-button" @click="show = true"
>切换环境</view
<view
v-if="(envVersion !== 'release' || nodeEnv === 'development') && env"
class="env-button"
@click="show = true"
>
切换环境
</view>
</view>
</view>
</view>
@ -105,10 +128,11 @@
import { useBasicStore } from '@/stores/basic'
import { useUserStore } from '@/stores/user'
import { useLockStore } from '@/stores/lock'
import { phoneLoginRequest } from '@/api/user'
import { phoneLoginRequest, logoutRequest } from '@/api/user'
import env from '@/config/env'
import { setStorage, getStorage, removeStorage } from '@/utils/storage'
import { useNotificationStore } from '@/stores/notification'
import { getAppInfoRequest } from '@/api/system'
export default {
data() {
@ -117,7 +141,8 @@
env: null,
envVersion: '',
envList: [],
show: false
show: false,
nodeEnv: ''
}
},
computed: {
@ -129,6 +154,8 @@
this.buttonInfo = await this.getButtonInfo()
this.env = await env[await getApp().globalData.getEnvConfig()]
this.envVersion = getApp().globalData.envVersion
this.nodeEnv = process.env.NODE_ENV
// eslint-disable-next-line guard-for-in,no-restricted-syntax
for (let key in env) {
this.envList.push({
@ -136,7 +163,6 @@
key
})
}
console.log(this.envList)
},
methods: {
...mapActions(useBasicStore, ['getButtonInfo', 'routeJump']),
@ -159,6 +185,13 @@
url: '/pages/main/home'
})
},
toContact() {
getAppInfoRequest().then(res => {
if (res.code === 0) {
plus.runtime.openURL(res.data.wechat_service_url)
}
})
},
async changePhone(res) {
if (res.detail.errMsg === 'getPhoneNumber:fail user deny') {
return
@ -260,6 +293,25 @@
type
}
})
},
logout() {
uni.showModal({
title: '提示',
content: '确定退出登录吗?',
success: async res => {
if (res.confirm) {
await logoutRequest()
removeStorage('token')
removeStorage('openid')
removeStorage('userInfo')
removeStorage('lockList')
this.routeJump({
name: 'login',
type: 'reLaunch'
})
}
}
})
}
}
}

View File

@ -322,18 +322,18 @@
}
.u-swipe-action {
overflow: inherit !important;
width: 700rpx;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
width: 700rpx;
padding-bottom: 140rpx !important;
overflow: inherit !important;
}
.u-swipe-action-item {
overflow: inherit !important;
border-radius: 32rpx !important;
background: transparent !important;
border-radius: 32rpx !important;
}
.u-swipe-action-item__right {
@ -342,8 +342,8 @@
}
.u-swipe-action-item__content {
border-radius: 32rpx !important;
margin-left: 25rpx;
border-radius: 32rpx !important;
}
.u-swipe-action-item__right__button {
@ -357,14 +357,14 @@
}
.notification {
border-radius: 32rpx;
margin-top: 32rpx;
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
width: 636rpx;
padding: 32rpx;
justify-content: space-between;
align-items: center;
position: relative;
margin-top: 32rpx;
border-radius: 32rpx;
box-shadow: 2rpx 2rpx 10rpx rgba(0, 0, 0, 0.3);
.icon {
@ -373,44 +373,44 @@
}
.point {
position: absolute;
top: 41rpx;
left: 72rpx;
width: 16rpx;
height: 16rpx;
background-color: #ff0000;
border-radius: 50%;
position: absolute;
top: 41rpx;
left: 72rpx;
}
.content {
width: 550rpx;
font-size: 28rpx;
color: #6c6c6c;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-size: 28rpx;
font-weight: bold;
color: #6c6c6c;
white-space: nowrap;
}
.time {
font-size: 24rpx;
color: #6c6c6c;
margin-top: 5rpx;
font-size: 24rpx;
font-weight: bold;
color: #6c6c6c;
}
}
.delete {
position: fixed;
right: 30rpx;
bottom: 80rpx;
display: flex;
align-items: center;
justify-content: center;
width: 100rpx;
height: 100rpx;
border-radius: 50%;
background-color: #5db5aa;
position: fixed;
bottom: 80rpx;
right: 30rpx;
display: flex;
justify-content: center;
align-items: center;
border-radius: 50%;
.delete-image {
width: 45rpx;
@ -426,29 +426,29 @@
}
.empty-list-text {
text-align: center;
font-size: 32rpx;
color: #999999;
text-align: center;
}
.tips {
margin-top: 40vh;
padding: 32rpx 0;
text-align: center;
margin-top: 40vh;
font-size: 28rpx;
color: #999999;
text-align: center;
}
.button-login {
border-radius: 46rpx;
width: 650rpx;
height: 120rpx;
line-height: 120rpx;
text-align: center;
margin-left: 50rpx;
background: #63b8af;
color: #ffffff;
font-size: 48rpx;
font-weight: bold;
line-height: 120rpx;
color: #ffffff;
text-align: center;
background: #63b8af;
border-radius: 46rpx;
}
</style>

View File

@ -78,15 +78,20 @@
const data = list.value.find(item => item.sn === authResult.data.wxDeviceSn)
if (authResult?.code === 0 && authResult?.data?.wxOpenid === getStorage('openid') && data) {
isAuthorized.value = true
requestFinish.value = true
if (data.status === 1) {
reject.value = false
} else if (data.status === 0) {
if (authResult?.code === 0 && data) {
if (authResult?.data?.wxOpenid === getStorage('openid')) {
if (data.status === 1) {
reject.value = false
} else if (data.status === 0) {
reject.value = false
weChatTicketsFlag.value = false
}
} else {
reject.value = true
weChatTicketsFlag.value = true
}
isAuthorized.value = true
requestFinish.value = true
uni.hideLoading()
} else {
requestFinish.value = true
@ -125,6 +130,8 @@
})
uni.hideLoading()
isAuthorized.value = true
reject.value = false
weChatTicketsFlag.value = false
} else {
uni.hideLoading()
uni.showToast({
@ -165,10 +172,10 @@
return result
}
const weChatTickets = async (snTicket, sn) => {
let ticket = snTicket
let snResult = sn
if (!snTicket) {
const weChatTickets = async () => {
let ticket = null
let snResult = null
if (!ticket) {
const result = await getInfo()
ticket = result.data.WXIoTDeviceInfo.SNTicket
snResult = result.data.WXIoTDeviceInfo.SN
@ -220,6 +227,8 @@
wxDeviceSn: result.data.WXIoTDeviceInfo.SN
}
})
reject.value = false
weChatTicketsFlag.value = false
uni.showToast({
title: '授权成功',
icon: 'none'

View File

@ -286,10 +286,12 @@
$bluetooth.closeBluetoothConnection()
})
// #ifdef MP-WEIXIN
uni.reportEvent('open_door', {
result: code,
duration: new Date().getTime() - timestamp
})
// #endif
if (code === 0) {
uni.showToast({

View File

@ -131,6 +131,8 @@
const seconds = ref(120)
const uCodeRef = ref(null)
const pending = ref(false)
const codeChange = text => {
tips.value = text
}
@ -142,7 +144,8 @@
const params = {
account: username.value,
codeType: 2,
countryCode: country.value.code
countryCode: country.value.code,
channel: EMAIL_REG.test(username.value) ? 2 : 1
}
$basic.routeJump({
name: 'safeVerify',
@ -202,14 +205,28 @@
if (!canResetPassword.value) {
return
}
if (pending.value) {
return
}
pending.value = true
uni.showLoading({
title: '重置中'
})
const res = await resetPasswordRequest({
account: username.value,
newPassword: password.value,
countryCode: country.value.code,
verificationCode: code.value
})
if (res) {
pending.value = false
uni.hideLoading()
if (res.code === 0) {
$basic.backAndToast('密码重置成功')
} else {
uni.showToast({
title: res.message,
icon: 'none'
})
}
}

View File

@ -99,6 +99,8 @@
const select = ref(false)
const pending = ref(false)
const isValidUsername = computed(() => {
if (!username.value) return false
return PHONE_REG.test(username.value) || EMAIL_REG.test(username.value)
@ -155,11 +157,16 @@
})
return
}
if (pending.value) {
return
}
pending.value = true
const res = await $user.passwordLogin({
username: username.value,
password: password.value,
countryCode: country.value.code
})
pending.value = false
if (res) {
$basic.routeJump({
name: 'home',

View File

@ -170,6 +170,8 @@
const uCodeRef = ref(null)
const select = ref(false)
const pending = ref(false)
onMounted(async () => {
const res = await $basic.getDeviceInfo()
if (res.language !== 'zh-CN') {
@ -263,6 +265,11 @@
})
return
}
if (pending.value) {
return
}
pending.value = true
const res = await $user.register({
account: username.value,
password: password.value,
@ -270,6 +277,7 @@
countryCode: country.value.code,
verificationCode: code.value
})
pending.value = false
if (res) {
$basic.routeJump({
name: 'home',

View File

@ -168,28 +168,27 @@
}
.input-email {
border-radius: 16rpx;
background: #ffffff;
margin-left: 35rpx;
margin-top: 48rpx;
height: 108rpx;
width: 616rpx;
padding-left: 32rpx;
height: 108rpx;
padding-right: 32rpx;
padding-left: 32rpx;
margin-top: 48rpx;
margin-left: 35rpx;
background: #ffffff;
border-radius: 16rpx;
}
.button-verify {
margin-top: 48rpx;
height: 108rpx;
width: 265rpx;
line-height: 108rpx;
border-radius: 16rpx;
text-align: center;
font-size: 32rpx;
height: 108rpx;
margin-top: 48rpx;
margin-left: 35rpx;
background: #63b8af;
font-size: 32rpx;
line-height: 108rpx;
color: #ffffff;
text-align: center;
background: #63b8af;
border-radius: 16rpx;
}
.view-top {
@ -198,14 +197,14 @@
}
.input-verify {
border-radius: 16rpx;
background: #ffffff;
margin-left: 35rpx;
margin-top: 48rpx;
height: 108rpx;
width: 316rpx;
padding-left: 32rpx;
height: 108rpx;
padding-right: 32rpx;
padding-left: 32rpx;
margin-top: 48rpx;
margin-left: 35rpx;
background: #ffffff;
border-radius: 16rpx;
}
.input-placeholder {
@ -216,15 +215,15 @@
}
.button {
margin-top: 32rpx;
margin-left: 35rpx;
width: 680rpx;
height: 96rpx;
margin-top: 32rpx;
margin-left: 35rpx;
font-size: 32rpx;
line-height: 96rpx;
color: #ffffff;
text-align: center;
background: #63b8af;
border-radius: 16rpx;
line-height: 96rpx;
text-align: center;
font-size: 32rpx;
color: #ffffff;
}
</style>

View File

@ -84,14 +84,14 @@
<style scoped lang="scss">
.input {
border-radius: 16rpx;
background: #ffffff;
margin-left: 35rpx;
margin-top: 48rpx;
height: 108rpx;
width: 616rpx;
padding-left: 32rpx;
height: 108rpx;
padding-right: 32rpx;
padding-left: 32rpx;
margin-top: 48rpx;
margin-left: 35rpx;
background: #ffffff;
border-radius: 16rpx;
}
.input-placeholder {
@ -102,15 +102,15 @@
}
.button {
margin-top: 32rpx;
margin-left: 35rpx;
width: 680rpx;
height: 96rpx;
margin-top: 32rpx;
margin-left: 35rpx;
font-size: 32rpx;
line-height: 96rpx;
color: #ffffff;
text-align: center;
background: #63b8af;
border-radius: 16rpx;
line-height: 96rpx;
text-align: center;
font-size: 32rpx;
color: #ffffff;
}
</style>

View File

@ -145,14 +145,14 @@
<style scoped lang="scss">
.input {
border-radius: 16rpx;
background: #ffffff;
margin-left: 35rpx;
margin-top: 48rpx;
height: 108rpx;
width: 616rpx;
padding-left: 32rpx;
height: 108rpx;
padding-right: 32rpx;
padding-left: 32rpx;
margin-top: 48rpx;
margin-left: 35rpx;
background: #ffffff;
border-radius: 16rpx;
}
.input-placeholder {
@ -163,23 +163,23 @@
}
.button {
margin-top: 32rpx;
margin-left: 35rpx;
width: 680rpx;
height: 96rpx;
margin-top: 32rpx;
margin-left: 35rpx;
font-size: 32rpx;
line-height: 96rpx;
color: #ffffff;
text-align: center;
background: #63b8af;
border-radius: 16rpx;
line-height: 96rpx;
text-align: center;
font-size: 32rpx;
color: #ffffff;
}
.text-tips {
text-align: center;
margin-top: 32rpx;
font-size: 28rpx;
color: #9b9b9b;
text-align: center;
}
.view-top {
@ -188,27 +188,26 @@
}
.input-verify {
border-radius: 16rpx;
background: #ffffff;
margin-left: 35rpx;
margin-top: 48rpx;
height: 108rpx;
width: 316rpx;
padding-left: 32rpx;
height: 108rpx;
padding-right: 32rpx;
padding-left: 32rpx;
margin-top: 48rpx;
margin-left: 35rpx;
background: #ffffff;
border-radius: 16rpx;
}
.button-verify {
margin-top: 48rpx;
height: 108rpx;
width: 265rpx;
line-height: 108rpx;
border-radius: 16rpx;
text-align: center;
font-size: 32rpx;
height: 108rpx;
margin-top: 48rpx;
margin-left: 35rpx;
background: #63b8af;
font-size: 32rpx;
line-height: 108rpx;
color: #ffffff;
text-align: center;
background: #63b8af;
border-radius: 16rpx;
}
</style>

View File

@ -1,6 +1,7 @@
<template>
<view>
<view class="view">
<!-- #ifdef MP-WEIXIN -->
<label for="avatar">
<view class="view-button">
<view>头像</view>
@ -14,6 +15,22 @@
</view>
</view>
</label>
<!-- #endif -->
<!-- #ifdef APP-PLUS -->
<view @click="chooseImage">
<view class="view-button">
<view>头像</view>
<view class="view-button" style="padding: 0">
<image class="avatar" :src="userInfo.headUrl" mode="aspectFill"></image>
<image
class="icon-arrow"
src="https://oss-lock.xhjcn.ltd/mp/icon_arrow.png"
mode="aspectFill"
></image>
</view>
</view>
</view>
<!-- #endif -->
<view class="view-line"></view>
<view class="view-button" @click="toUpdateName">
<view>昵称</view>
@ -146,13 +163,33 @@
}
this.pending = false
},
chooseImage() {
const that = this
uni.chooseImage({
count: 1,
sourceType: ['camera', 'album'],
crop: {
quality: 60,
width: 108,
height: 108
},
success: res => {
const data = res.tempFiles[0]
const list = data.path.split('/')
const filename = list[list.length - 1]
that.uploadRequest({
...data,
filename
})
}
})
},
chooseAvatar(e) {
const that = this
if (that.pending) {
return
}
that.pending = true
const path = e.detail.avatarUrl
const list = path.split('/')
const filename = list[list.length - 1]
@ -160,58 +197,65 @@
filePath: path,
async success(res) {
const size = res.size
const { code, data } = await getUploadParamsRequest({
that.uploadRequest({
size,
module: 'avatar',
userId: that.userInfo.userId,
filename
filename,
path
})
if (code === 0) {
uni.uploadFile({
url: data.uploadUrl,
filePath: path,
name: 'file',
formData: data.formData,
async success() {
const { code: updateCode } = await updateUserInfoRequest({
headUrl: data.fileUrl
})
if (updateCode === 0) {
that.updateUserInfo({
...that.userInfo,
headUrl: data.fileUrl
})
uni.showToast({
title: '头像更新成功',
icon: 'none'
})
} else {
uni.showToast({
title: '头像更新失败',
icon: 'none'
})
}
that.pending = false
},
fail(res) {
console.log('上传失败', res)
console.log(data.uploadUrl, path, data.formData)
uni.showToast({
title: '头像更新失败',
icon: 'none'
})
that.pending = false
}
}
})
},
async uploadRequest(params) {
const that = this
const { code, data } = await getUploadParamsRequest({
size: params.size,
module: 'avatar',
userId: that.userInfo.userId,
filename: params.filename
})
if (code === 0) {
uni.uploadFile({
url: data.uploadUrl,
filePath: params.path,
name: 'file',
formData: data.formData,
async success() {
const { code: updateCode } = await updateUserInfoRequest({
headUrl: data.fileUrl
})
} else {
if (updateCode === 0) {
that.updateUserInfo({
...that.userInfo,
headUrl: data.fileUrl
})
uni.showToast({
title: '头像更新成功',
icon: 'none'
})
} else {
uni.showToast({
title: '头像更新失败',
icon: 'none'
})
}
that.pending = false
},
fail(res) {
console.log('上传失败', res)
uni.showToast({
title: '头像更新失败',
icon: 'none'
})
that.pending = false
}
}
})
})
} else {
uni.showToast({
title: '头像更新失败',
icon: 'none'
})
that.pending = false
}
},
toUpdateName() {
this.routeJump({

View File

@ -122,17 +122,16 @@
}
.button-verify {
margin-top: 48rpx;
height: 108rpx;
width: 265rpx;
line-height: 108rpx;
border-radius: 16rpx;
text-align: center;
font-size: 32rpx;
height: 108rpx;
margin-top: 48rpx;
margin-left: 35rpx;
background: #63b8af;
font-size: 32rpx;
line-height: 108rpx;
color: #ffffff;
text-align: center;
background: #63b8af;
border-radius: 16rpx;
}
.view-top {
@ -141,14 +140,14 @@
}
.input {
border-radius: 16rpx;
background: #ffffff;
margin-left: 35rpx;
margin-top: 48rpx;
height: 108rpx;
width: 316rpx;
padding-left: 32rpx;
height: 108rpx;
padding-right: 32rpx;
padding-left: 32rpx;
margin-top: 48rpx;
margin-left: 35rpx;
background: #ffffff;
border-radius: 16rpx;
}
.input-placeholder {
@ -159,15 +158,15 @@
}
.button {
margin-top: 32rpx;
margin-left: 35rpx;
width: 680rpx;
height: 96rpx;
margin-top: 32rpx;
margin-left: 35rpx;
font-size: 32rpx;
line-height: 96rpx;
color: #ffffff;
text-align: center;
background: #63b8af;
border-radius: 16rpx;
line-height: 96rpx;
text-align: center;
font-size: 32rpx;
color: #ffffff;
}
</style>

View File

@ -440,7 +440,7 @@ export const useBasicStore = defineStore('basic', {
// 设备信息
deviceInfo: null,
// 胶囊按钮的位置信息
buttonInfo: null,
buttonInfo: {},
// 分享配置
shareConfig: {}
}

View File

@ -190,7 +190,9 @@ export const useBluetoothStore = defineStore('ble', {
},
// 关闭全部蓝牙监听并关闭蓝牙模拟
closeAllBluetooth() {
// #ifdef MP
uni.offBluetoothAdapterStateChange()
// #endif
uni.closeBluetoothAdapter({
success(res) {
console.log('关闭蓝牙模块', res)
@ -858,7 +860,7 @@ export const useBluetoothStore = defineStore('ble', {
}
}
}
console.log('设备列表', that.deviceList)
// console.log('设备列表', that.deviceList)
},
async fail(res) {
console.log('获取设备列表失败', res)
@ -943,6 +945,9 @@ export const useBluetoothStore = defineStore('ble', {
}
})
// #endif
// #ifdef APP-PLUS
resolve(true)
// #endif
resolve(false)
})
},
@ -962,63 +967,74 @@ export const useBluetoothStore = defineStore('ble', {
success(res) {
console.log('连接成功', res)
// 获取设备服务
uni.getBLEDeviceServices({
deviceId: that.currentLockInfo.deviceId,
success(res) {
let serviceId
for (let i = 0; i < res.services.length; i++) {
if (res.services[i].uuid.indexOf('FFF0') !== -1) {
serviceId = res.services[i].uuid
}
}
// 获取设备对应服务的特征值
uni.getBLEDeviceCharacteristics({
deviceId: that.currentLockInfo.deviceId,
serviceId,
success(res) {
let notifyCharacteristicId
let writeCharacteristicId
for (let i = 0; i < res.characteristics.length; i++) {
const characteristic = res.characteristics[i]
if (characteristic.properties.notify) {
notifyCharacteristicId = characteristic.uuid
}
if (characteristic.properties.write) {
writeCharacteristicId = characteristic.uuid
}
const executeBluetoothOperation = () => {
uni.getBLEDeviceServices({
deviceId: that.currentLockInfo.deviceId,
success(res) {
let serviceId
for (let i = 0; i < res.services.length; i++) {
if (res.services[i].uuid.indexOf('FFF0') !== -1) {
serviceId = res.services[i].uuid
}
that.updateCurrentLockInfo({
...that.currentLockInfo,
serviceId,
notifyCharacteristicId,
writeCharacteristicId
})
that.notifyBluetoothCharacteristicValueChange()
resolve(true)
},
fail(res) {
if (res.errCode === 10006) {
uni.showToast({
title: '连接失败,请靠近设备并保持设备处于唤醒状态',
icon: 'none'
}
// 获取设备对应服务的特征值
uni.getBLEDeviceCharacteristics({
deviceId: that.currentLockInfo.deviceId,
serviceId,
success(res) {
let notifyCharacteristicId
let writeCharacteristicId
for (let i = 0; i < res.characteristics.length; i++) {
const characteristic = res.characteristics[i]
if (characteristic.properties.notify) {
notifyCharacteristicId = characteristic.uuid
}
if (characteristic.properties.write) {
writeCharacteristicId = characteristic.uuid
}
}
that.updateCurrentLockInfo({
...that.currentLockInfo,
serviceId,
notifyCharacteristicId,
writeCharacteristicId
})
that.notifyBluetoothCharacteristicValueChange()
resolve(true)
},
fail(res) {
if (res.errCode === 10006) {
uni.showToast({
title: '连接失败,请靠近设备并保持设备处于唤醒状态',
icon: 'none'
})
}
console.log('获取设备特征值失败', res)
resolve(false)
}
console.log('获取设备特征值失败', res)
resolve(false)
}
})
},
fail(res) {
if (res.errCode === 10006) {
uni.showToast({
title: '连接失败,请靠近设备并保持设备处于唤醒状态',
icon: 'none'
})
},
fail(res) {
if (res.errCode === 10006) {
uni.showToast({
title: '连接失败,请靠近设备并保持设备处于唤醒状态',
icon: 'none'
})
}
console.log('获取设备服务失败', res)
resolve(false)
}
console.log('获取设备服务失败', res)
resolve(false)
}
})
})
}
// #ifdef APP-PLUS
setTimeout(executeBluetoothOperation, 800)
// #endif
// #ifdef MP
executeBluetoothOperation()
// #endif
},
async fail(res) {
console.log('连接失败', res)
@ -1412,6 +1428,24 @@ export const useBluetoothStore = defineStore('ble', {
i === count - 1 ? binaryData.length : (i + 1) * 20
)
// #ifdef APP-PLUS
setTimeout(
() => {
uni.writeBLECharacteristicValue({
deviceId: that.currentLockInfo.deviceId,
serviceId: that.currentLockInfo.serviceId,
characteristicId: that.currentLockInfo.writeCharacteristicId,
value: writeData.buffer,
fail(res) {
console.log('写入失败', res)
}
})
},
(i + 1) * 200
)
// #endif
// #ifdef MP
uni.writeBLECharacteristicValue({
deviceId: that.currentLockInfo.deviceId,
serviceId: that.currentLockInfo.serviceId,
@ -1421,6 +1455,7 @@ export const useBluetoothStore = defineStore('ble', {
console.log('写入失败', res)
}
})
// #endif
}
}
},

View File

@ -43,6 +43,9 @@ export const useUserStore = defineStore('user', {
return code
},
async register(params) {
uni.showLoading({
title: '注册中'
})
const { account, password, receiverType, countryCode, verificationCode } = params
const $basic = useBasicStore()
const deviceInfo = await $basic.getDeviceInfo()
@ -62,6 +65,7 @@ export const useUserStore = defineStore('user', {
platId: 2,
deviceInfo: info
})
uni.hideLoading()
if (code === 0) {
setStorage('token', data.accessToken)
return true
@ -73,6 +77,9 @@ export const useUserStore = defineStore('user', {
return false
},
async passwordLogin(params) {
uni.showLoading({
title: '登录中'
})
const { username, password, countryCode } = params
const $basic = useBasicStore()
const deviceInfo = await $basic.getDeviceInfo()
@ -91,6 +98,7 @@ export const useUserStore = defineStore('user', {
platId: 2,
deviceInfo: info
})
uni.hideLoading()
if (code === 0) {
setStorage('token', data.accessToken)
return true