|
@@ -86,6 +86,7 @@
|
|
|
<div style="margin: 10px 0"></div>
|
|
|
<div ref="mapRef" style="width: 100%; height: 194px"></div>
|
|
|
</a-form-item>
|
|
|
+
|
|
|
<a-form-item :label="t('room.form.desc')" name="desc">
|
|
|
<a-textarea
|
|
|
v-model:value="current.desc"
|
|
@@ -96,6 +97,7 @@
|
|
|
/>
|
|
|
</a-form-item>
|
|
|
<!-- <h4>{{ t('room.form.host') }}</h4> -->
|
|
|
+
|
|
|
<a-form-item
|
|
|
:label="t('room.form.nickname')"
|
|
|
name="leaderName"
|
|
@@ -118,23 +120,16 @@
|
|
|
name="title"
|
|
|
:rules="[{ required: true, message: '' }]"
|
|
|
>
|
|
|
- <a-upload
|
|
|
- v-model:file-list="avatarFile"
|
|
|
- name="file"
|
|
|
- action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
|
|
|
- :headers="{
|
|
|
- authorization: 'authorization-text'
|
|
|
- }"
|
|
|
- @change="handleAvatarChange"
|
|
|
- >
|
|
|
- <div class="add-item-icon">
|
|
|
- <a-button shape="circle" class="button" type="primary">
|
|
|
- <plus-outlined class="add-room-icon" />
|
|
|
- </a-button>
|
|
|
- </div>
|
|
|
- </a-upload>
|
|
|
+ <EditAvatar :data="current.scenesAvatar" @sync="handleAvatarSync" />
|
|
|
+ </a-form-item>
|
|
|
+ <!-- 相册 -->
|
|
|
+ <a-form-item label="相册" name="title">
|
|
|
+ <EditAlbum
|
|
|
+ :data="current.scenesAlbum || []"
|
|
|
+ @sync-list="handleAlbumSync"
|
|
|
+ />
|
|
|
</a-form-item>
|
|
|
- <!-- <h4>{{ t('room.form.selectScene') }}</h4> -->
|
|
|
+
|
|
|
<a-form-item
|
|
|
:label="t('room.form.addScene')"
|
|
|
class="select-scene"
|
|
@@ -142,6 +137,7 @@
|
|
|
style="margin-bottom: 2px"
|
|
|
>
|
|
|
</a-form-item>
|
|
|
+
|
|
|
<EditScenes
|
|
|
:class="{ disabled: isRoomEnd }"
|
|
|
:scenes="current.scenes"
|
|
@@ -308,6 +304,8 @@ import { props } from './props'
|
|
|
import { message, Modal } from 'ant-design-vue'
|
|
|
import { mainURL } from '@/env'
|
|
|
import EditScenes from './scene-list.vue'
|
|
|
+import EditAlbum from './album-list.vue'
|
|
|
+import EditAvatar from './avatar.vue'
|
|
|
import unScenePng from '@/assets/images/un-scene.png'
|
|
|
import VOtpInput from 'vue3-otp-input'
|
|
|
import type { Scene } from '@/store/modules/scene'
|
|
@@ -321,6 +319,7 @@ import { ExclamationCircleOutlined } from '@ant-design/icons-vue'
|
|
|
import { useScript } from '@/hook/useScript'
|
|
|
import { onMounted } from 'vue'
|
|
|
import type { UploadChangeParam } from 'ant-design-vue'
|
|
|
+import { watchEffect } from 'vue'
|
|
|
|
|
|
dayjs.extend(duration)
|
|
|
// const titleValidator = ref({
|
|
@@ -337,7 +336,7 @@ interface AuthUserFormState {
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'EditRoom',
|
|
|
- components: { EditScenes, VOtpInput },
|
|
|
+ components: { EditScenes, VOtpInput, EditAlbum, EditAvatar },
|
|
|
props,
|
|
|
setup(props) {
|
|
|
const visible = ref(true)
|
|
@@ -345,7 +344,6 @@ export default defineComponent({
|
|
|
const mapRef = ref<HTMLDivElement | null>(null)
|
|
|
const authformState: UnwrapRef<AuthUserFormState> = reactive({
|
|
|
userName: ''
|
|
|
- // useTimeList: []
|
|
|
})
|
|
|
const { getAntdLocale } = useLocale()
|
|
|
const roomStore = useRoomStore()
|
|
@@ -353,7 +351,7 @@ export default defineComponent({
|
|
|
const { getLocale } = useLocale()
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
- const avatarFile = ref([])
|
|
|
+ const avatarFile = ref<any[]>([])
|
|
|
|
|
|
const returnLocale = computed(() => {
|
|
|
if (unref(getLocale).includes('zh')) {
|
|
@@ -365,6 +363,7 @@ export default defineComponent({
|
|
|
const otpInput = ref('')
|
|
|
const formRef = ref<FormInstance>()
|
|
|
const current = reactive(createRoom(props.room || {}))
|
|
|
+ // current.scenesAlbum = []
|
|
|
if (current.useTimeList?.length) {
|
|
|
current.useTimeList = current.useTimeList?.map(i => dayjs(i))
|
|
|
}
|
|
@@ -499,25 +498,49 @@ export default defineComponent({
|
|
|
const onCancel = () => {
|
|
|
visible.value = false
|
|
|
}
|
|
|
+ ;(window as any)._AMapSecurityConfig = {
|
|
|
+ securityJsCode: 'cbac8ddaf1e7346784b24f10cae245a3'
|
|
|
+ }
|
|
|
const A_MAP_URL =
|
|
|
- 'https://webapi.amap.com/maps?v=2.0&key=e661b00bdf2c44cccf71ef6070ef41b8'
|
|
|
+ 'https://webapi.amap.com/maps?v=2.0&key=5a2d384532ae531bf99bd8487c4f03d2'
|
|
|
+ const UI = 'https://webapi.amap.com/ui/1.0/main.js?v=1.0.11'
|
|
|
+ // const { toPromise: toUIPromise } = useScript({ src: UI })
|
|
|
const { toPromise } = useScript({ src: A_MAP_URL })
|
|
|
|
|
|
const initMap = async () => {
|
|
|
await toPromise()
|
|
|
+ // await toUIPromise();
|
|
|
+
|
|
|
console.log('mapRef', unref(mapRef))
|
|
|
const AMap = (window as any).AMap
|
|
|
- console.log('AMap', AMap)
|
|
|
- // const center = [120.262337, 30.178285]
|
|
|
+ // console.log('AMap', AMap)
|
|
|
+ // ** 有数据时默认位置
|
|
|
+ // const center = [113.549574, 22.215372]
|
|
|
+
|
|
|
+ // var icon = new AMap.Icon({
|
|
|
+ // size: new AMap.Size(40, 50), // 图标尺寸
|
|
|
+ // image: '//webapi.amap.com/theme/v1.3/images/newpc/way_btn2.png', // Icon的图像
|
|
|
+ // imageOffset: new AMap.Pixel(0, -60), // 图像相对展示区域的偏移量,适于雪碧图等
|
|
|
+ // imageSize: new AMap.Size(40, 50) // 根据所设置的大小拉伸或压缩图片
|
|
|
+ // })
|
|
|
+ var marker = new AMap.Marker({
|
|
|
+ position: new AMap.LngLat(113.549574, 22.215372),
|
|
|
+ title: current.location,
|
|
|
+ zoom: 13
|
|
|
+ })
|
|
|
+
|
|
|
const map = new AMap.Map(unref(mapRef), {
|
|
|
zoom: 15,
|
|
|
resizeEnable: true
|
|
|
- // center: center,
|
|
|
+ // center: center
|
|
|
+ // resizeEnable: true
|
|
|
// viewMode: '3D',
|
|
|
- // resizeEnable: true,
|
|
|
+ // resizeEnable: true
|
|
|
// floorControl: true,
|
|
|
// showIndoorMap: true
|
|
|
})
|
|
|
+ map.add(marker)
|
|
|
+
|
|
|
AMap.plugin(
|
|
|
[
|
|
|
'AMap.Scale',
|
|
@@ -529,44 +552,50 @@ export default defineComponent({
|
|
|
],
|
|
|
function () {
|
|
|
const autoOptions = {
|
|
|
- city: '珠海',
|
|
|
+ // city: '珠海',
|
|
|
input: 'location'
|
|
|
}
|
|
|
const autocomplete = new AMap.Autocomplete(autoOptions)
|
|
|
const placeSearch = new AMap.PlaceSearch({
|
|
|
- city: '珠海', // 默认城市,一定要有,不然没有放大效果
|
|
|
+ // city: '珠海', // 默认城市,一定要有,不然没有放大效果
|
|
|
map: map // 地图,选中会有放大功能,绑定上面创建的地图即可
|
|
|
})
|
|
|
AMap.Event.addListener(autocomplete, 'select', function (e: any) {
|
|
|
placeSearch.search(e.poi.name)
|
|
|
- console.log('location', e.poi.location) // 获取选中的的地址的经纬度
|
|
|
- })
|
|
|
- var geolocation = new AMap.Geolocation({
|
|
|
- // 是否使用高精度定位,默认:true
|
|
|
- enableHighAccuracy: true,
|
|
|
- // 设置定位超时时间,默认:无穷大
|
|
|
- timeout: 10000,
|
|
|
- // 定位按钮的停靠位置的偏移量,默认:Pixel(10, 20)
|
|
|
- buttonOffset: new AMap.Pixel(10, 20),
|
|
|
- // 定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
|
|
|
- zoomToAccuracy: true,
|
|
|
- // 定位按钮的排放位置, RB表示右下
|
|
|
- buttonPosition: 'RB'
|
|
|
- })
|
|
|
-
|
|
|
- geolocation.getCurrentPosition()
|
|
|
- AMap.Event.addListener(geolocation, 'complete', onComplete)
|
|
|
- AMap.Event.addListener(geolocation, 'error', onError)
|
|
|
-
|
|
|
- function onComplete(data: any) {
|
|
|
- console.log('data', data)
|
|
|
- // data是具体的定位信息
|
|
|
- }
|
|
|
-
|
|
|
- function onError(data: any) {
|
|
|
- console.log('data', data)
|
|
|
- // 定位出错
|
|
|
+ // console.log('location', e.poi.location) // 获取选中的的地址的经纬度
|
|
|
+ console.log('select', e.poi) // 获取选中的的地址的经纬度
|
|
|
+ if (e.poi.name) {
|
|
|
+ current.location = e.poi.name
|
|
|
}
|
|
|
+ })
|
|
|
+ AMap.Event.addListener(autocomplete, 'click', function (e: any) {
|
|
|
+ console.log('click', e)
|
|
|
+ })
|
|
|
+ // var geolocation = new AMap.Geolocation({
|
|
|
+ // // 是否使用高精度定位,默认:true
|
|
|
+ // enableHighAccuracy: true,
|
|
|
+ // // 设置定位超时时间,默认:无穷大
|
|
|
+ // timeout: 10000,
|
|
|
+ // // 定位按钮的停靠位置的偏移量,默认:Pixel(10, 20)
|
|
|
+ // buttonOffset: new AMap.Pixel(10, 20),
|
|
|
+ // // 定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
|
|
|
+ // zoomToAccuracy: true,
|
|
|
+ // // 定位按钮的排放位置, RB表示右下
|
|
|
+ // buttonPosition: 'RB'
|
|
|
+ // })
|
|
|
+
|
|
|
+ // geolocation.getCurrentPosition()
|
|
|
+ // AMap.Event.addListener(geolocation, 'complete', onComplete)
|
|
|
+ // AMap.Event.addListener(geolocation, 'error', onError)
|
|
|
+
|
|
|
+ // function onComplete(data: any) {
|
|
|
+ // console.log('onComplete-data', data)
|
|
|
+ // }
|
|
|
+
|
|
|
+ function onError(data: any) {
|
|
|
+ console.log('onError-data', data)
|
|
|
+ // 定位出错
|
|
|
+ }
|
|
|
}
|
|
|
)
|
|
|
}
|
|
@@ -576,16 +605,32 @@ export default defineComponent({
|
|
|
})
|
|
|
|
|
|
const handleAvatarChange = (info: UploadChangeParam) => {
|
|
|
- if (info.file.status !== 'uploading') {
|
|
|
- console.log(info.file, info.fileList)
|
|
|
- }
|
|
|
+ // if (info.file.status !== 'uploading') {
|
|
|
+ // console.log(info.file, info.fileList)
|
|
|
+ // }
|
|
|
if (info.file.status === 'done') {
|
|
|
- message.success(`${info.file.name} file uploaded successfully`)
|
|
|
+ console.log('info.file', info.file)
|
|
|
+ if (info.file.response) {
|
|
|
+ const { code, data } = info.file.response
|
|
|
+ if (code === 0) {
|
|
|
+ current.scenesAvatar = data
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // message.success(`${info.file.name} file uploaded successfully`)
|
|
|
} else if (info.file.status === 'error') {
|
|
|
message.error(`${info.file.name} file upload failed.`)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ const handleAlbumSync = (list: any[]) => {
|
|
|
+ current.scenesAlbum = list
|
|
|
+ // console.log('handleAlbumSync', list)
|
|
|
+ }
|
|
|
+ const handleAvatarSync = (avatarURL: string) => {
|
|
|
+ console.log('avatarURL', avatarURL)
|
|
|
+ current.scenesAvatar = avatarURL
|
|
|
+ }
|
|
|
+
|
|
|
return {
|
|
|
handleNickRegex,
|
|
|
returnLocale,
|
|
@@ -615,7 +660,9 @@ export default defineComponent({
|
|
|
onCancel,
|
|
|
mapRef,
|
|
|
avatarFile,
|
|
|
- handleAvatarChange
|
|
|
+ handleAvatarChange,
|
|
|
+ handleAlbumSync,
|
|
|
+ handleAvatarSync
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -782,17 +829,25 @@ export default defineComponent({
|
|
|
margin: 0;
|
|
|
}
|
|
|
}
|
|
|
-.add-item-icon {
|
|
|
- width: 120px;
|
|
|
- height: 120px;
|
|
|
- display: flex;
|
|
|
- justify-content: center;
|
|
|
- align-items: center;
|
|
|
- border: 1px solid #ebedf0;
|
|
|
- .button {
|
|
|
- background: linear-gradient(144deg, #00aefb 0%, #0076f6 100%);
|
|
|
- width: 40px;
|
|
|
- height: 40px;
|
|
|
- }
|
|
|
-}
|
|
|
+
|
|
|
+// .album-list {
|
|
|
+// .album-list-item {
|
|
|
+// .list-item {
|
|
|
+// width: 100%;
|
|
|
+// height: 100%;
|
|
|
+// overflow: hidden;
|
|
|
+// display: flex;
|
|
|
+// justify-content: center;
|
|
|
+// align-items: center;
|
|
|
+// height: 120px;
|
|
|
+// overflow: hidden;
|
|
|
+// img {
|
|
|
+// max-width: 100%;
|
|
|
+// // height: 100%;
|
|
|
+// display: block;
|
|
|
+// object-fit: cover;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
</style>
|