新增的手写模块

This commit is contained in:
WindowBird 2025-09-10 11:05:53 +08:00
parent 535081b7d2
commit 091594bec7
2 changed files with 52 additions and 62 deletions

View File

@ -1,76 +1,66 @@
<template> <template>
<view class="content"> <view style="width: 750rpx; height: 750rpx">
<button @tap="authVerification">请选择位置</button> <l-signature
<template v-if="currentLocation.address"> ref="signatureRef"
<div>name{{ currentLocation.name }}</div> :openSmooth="openSmooth"
<div>address{{ currentLocation.address }}</div> :penColor="penColor"
<div>latitude{{ currentLocation.latitude }}</div> :penSize="penSize"
<div>longitude{{ currentLocation.longitude }}</div> disableScroll
</template> ></l-signature>
</view>
<view>
<button @click="onClick('clear')">清空</button>
<button @click="onClick('undo')">撤消</button>
<button @click="onClick('save')">保存</button>
<button @click="onClick('openSmooth')">压感{{ openSmooth ? '' : '' }}</button>
</view> </view>
</template> </template>
<script> <script>
import { getCurrentInstance, onMounted, ref } from 'vue'
export default { export default {
mounted() {
console.log('uvUI 可用性:', !!this.$uv)
console.log('debounce 方法:', !!this.$uv?.debounce)
},
data() { data() {
return { return {
currentLocation: {}, title: 'Hello',
penColor: 'red',
penSize: 5,
url: '',
openSmooth: true,
} }
}, },
onShow() {
uni.getStorage({
key: 'currentLocation',
success: res => {
this.currentLocation = res.data
},
})
},
methods: { methods: {
authVerification() { onClick(type) {
uni.getSetting({ if (type == 'openSmooth') {
success: res => { this.openSmooth = !this.openSmooth
if (res.authSetting['scope.userLocation']) { return
/* 用户授权成功时走这里 */ }
this.handerChooseLocation() if (type == 'save') {
} else if (res.authSetting['scope.userLocation'] === undefined) { this.$refs.signatureRef.canvasToTempFilePath({
/* 用户未授权时走这里 */ success: res => {
console.log('没有授权') //
this.handleOpenSetting() console.log(res.isEmpty)
} else { //
/* 用户拒绝了授权后走这里 */ // H5 base64
console.log('拒绝了授权 false') this.url = res.tempFilePath
this.handleOpenSetting() console.log(res.tempFilePath)
} // uni.saveImageToPhotosAlbum({
}, // filePath: res.tempFilePath,
}) // success: () => {
}, // uni.showToast({ title: '' })
handerChooseLocation(latitude, longitude) { // },
uni.chooseLocation({ // })
latitude: latitude || '', uni.previewImage({
longitude: longitude || '', urls: [res.tempFilePath],
success: res => { current: 0,
console.log('wx.chooseLocation res=', res) })
uni.setStorageSync('currentLocation', res) },
}, })
fail: function (err) { return
console.log('取消按钮', err) }
}, if (this.$refs.signatureRef) this.$refs.signatureRef[type]()
})
},
handleOpenSetting() {
wx.openSetting({
success: res => {
console.log('定位 openSetting', res)
if (res.authSetting['scope.userLocation']) {
this.handerChooseLocation()
}
},
})
}, },
}, },
} }
</script> </script>
<style lang="scss"></style>

View File

@ -20,7 +20,7 @@ const ENV_CONFIG = {
// 正式版 // 正式版
// baseUrl: 'https://chu.chuangtewl.com/prod-api', // baseUrl: 'https://chu.chuangtewl.com/prod-api',
// baseUrl: 'http://192.168.2.88:4601', // baseUrl: 'http://192.168.2.88:4601',
baseUrl: 'http://192.168.2.88:4601', baseUrl: 'http://192.168.2.21:4601',
appId: 1, appId: 1,
}, },
} }