新增的手写模块
This commit is contained in:
parent
535081b7d2
commit
091594bec7
|
|
@ -1,76 +1,66 @@
|
|||
<template>
|
||||
<view class="content">
|
||||
<button @tap="authVerification">请选择位置</button>
|
||||
<template v-if="currentLocation.address">
|
||||
<div>name:{{ currentLocation.name }}</div>
|
||||
<div>address:{{ currentLocation.address }}</div>
|
||||
<div>latitude:{{ currentLocation.latitude }}</div>
|
||||
<div>longitude:{{ currentLocation.longitude }}</div>
|
||||
</template>
|
||||
<view style="width: 750rpx; height: 750rpx">
|
||||
<l-signature
|
||||
ref="signatureRef"
|
||||
:openSmooth="openSmooth"
|
||||
:penColor="penColor"
|
||||
:penSize="penSize"
|
||||
disableScroll
|
||||
></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>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getCurrentInstance, onMounted, ref } from 'vue'
|
||||
|
||||
export default {
|
||||
mounted() {
|
||||
console.log('uvUI 可用性:', !!this.$uv)
|
||||
console.log('debounce 方法:', !!this.$uv?.debounce)
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
currentLocation: {},
|
||||
title: 'Hello',
|
||||
penColor: 'red',
|
||||
penSize: 5,
|
||||
url: '',
|
||||
openSmooth: true,
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
uni.getStorage({
|
||||
key: 'currentLocation',
|
||||
success: res => {
|
||||
this.currentLocation = res.data
|
||||
},
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
authVerification() {
|
||||
uni.getSetting({
|
||||
success: res => {
|
||||
if (res.authSetting['scope.userLocation']) {
|
||||
/* 用户授权成功时走这里 */
|
||||
this.handerChooseLocation()
|
||||
} else if (res.authSetting['scope.userLocation'] === undefined) {
|
||||
/* 用户未授权时走这里 */
|
||||
console.log('没有授权')
|
||||
this.handleOpenSetting()
|
||||
} else {
|
||||
/* 用户拒绝了授权后走这里 */
|
||||
console.log('拒绝了授权 false')
|
||||
this.handleOpenSetting()
|
||||
onClick(type) {
|
||||
if (type == 'openSmooth') {
|
||||
this.openSmooth = !this.openSmooth
|
||||
return
|
||||
}
|
||||
},
|
||||
if (type == 'save') {
|
||||
this.$refs.signatureRef.canvasToTempFilePath({
|
||||
success: res => {
|
||||
// 是否为空画板 无签名
|
||||
console.log(res.isEmpty)
|
||||
// 生成图片的临时路径
|
||||
// H5 生成的是base64
|
||||
this.url = res.tempFilePath
|
||||
console.log(res.tempFilePath)
|
||||
// uni.saveImageToPhotosAlbum({
|
||||
// filePath: res.tempFilePath,
|
||||
// success: () => {
|
||||
// uni.showToast({ title: '已保存到相册' })
|
||||
// },
|
||||
// })
|
||||
uni.previewImage({
|
||||
urls: [res.tempFilePath],
|
||||
current: 0,
|
||||
})
|
||||
},
|
||||
handerChooseLocation(latitude, longitude) {
|
||||
uni.chooseLocation({
|
||||
latitude: latitude || '',
|
||||
longitude: longitude || '',
|
||||
success: res => {
|
||||
console.log('wx.chooseLocation res=', res)
|
||||
uni.setStorageSync('currentLocation', res)
|
||||
},
|
||||
fail: function (err) {
|
||||
console.log('取消按钮', err)
|
||||
},
|
||||
})
|
||||
},
|
||||
handleOpenSetting() {
|
||||
wx.openSetting({
|
||||
success: res => {
|
||||
console.log('定位 openSetting', res)
|
||||
if (res.authSetting['scope.userLocation']) {
|
||||
this.handerChooseLocation()
|
||||
return
|
||||
}
|
||||
},
|
||||
})
|
||||
if (this.$refs.signatureRef) this.$refs.signatureRef[type]()
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="scss"></style>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ const ENV_CONFIG = {
|
|||
// 正式版
|
||||
// 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.21:4601',
|
||||
appId: 1,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user