|
@@ -1,324 +1,324 @@
|
|
|
-import { getApp, getNum } from '@/app'
|
|
|
-import { base64ToBlob, convertBlob2File } from '@/utils/file'
|
|
|
-export default {
|
|
|
- namespaced: true,
|
|
|
- state() {
|
|
|
- return {
|
|
|
- // showPath: false,
|
|
|
- // showFrame: false,
|
|
|
- toursList: [],
|
|
|
- sourceList: null,
|
|
|
- frameId: 0,
|
|
|
- partId: 0,
|
|
|
- tours: [],
|
|
|
- fileObj: {},
|
|
|
- musicList: [],
|
|
|
- delList: [],
|
|
|
- isPlay: false,
|
|
|
- showTours: false,
|
|
|
- hlIndex: -1,
|
|
|
- allTime: 0,
|
|
|
- }
|
|
|
- },
|
|
|
- getters: {
|
|
|
- tours: state => {
|
|
|
- return state.tours
|
|
|
- },
|
|
|
- allTime: state => {
|
|
|
- return state.allTime
|
|
|
- },
|
|
|
-
|
|
|
- partId: state => {
|
|
|
- return state.partId
|
|
|
- },
|
|
|
- frameId: state => {
|
|
|
- return state.frameId
|
|
|
- },
|
|
|
- isPlay: state => {
|
|
|
- return state.isPlay
|
|
|
- },
|
|
|
- showTours: state => {
|
|
|
- return state.showTours
|
|
|
- },
|
|
|
- hlIndex: state => {
|
|
|
- return state.hlIndex
|
|
|
- },
|
|
|
- },
|
|
|
- mutations: {
|
|
|
- async setData(state, payload) {
|
|
|
- if (payload) {
|
|
|
- for (let key in payload) {
|
|
|
- state[key] = payload[key]
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- setBackUp(state) {
|
|
|
- state.toursList = JSON.parse(JSON.stringify(state.tours))
|
|
|
- },
|
|
|
- update(state, tours) {
|
|
|
- this.commit('enterEdit')
|
|
|
- //如果删除片段和备份数据一样则退出编辑模式
|
|
|
- let t = setTimeout(() => {
|
|
|
- clearTimeout(t)
|
|
|
- if (state.tours.length == 0 && state.toursList.length == 0) {
|
|
|
- this.commit('leaveEdit')
|
|
|
- }
|
|
|
- }, 0)
|
|
|
- },
|
|
|
- async setFrame(state, payload) {
|
|
|
- const recordr = await getApp().TourManager.recorder
|
|
|
- recordr.setFrame(state.frameId, payload)
|
|
|
- this.commit('tour/update')
|
|
|
- },
|
|
|
- async setPart(state, payload) {
|
|
|
- let data = JSON.parse(JSON.stringify(payload))
|
|
|
-
|
|
|
- for (let key in payload) {
|
|
|
- state.tours[state.partId][key] = payload[key]
|
|
|
- }
|
|
|
- for (let key in data) {
|
|
|
- if (key === 'file') {
|
|
|
- state.fileObj[state.tours[state.partId].sid] = payload[key]
|
|
|
- delete data[key]
|
|
|
- }
|
|
|
- }
|
|
|
- const recordr = await getApp().TourManager.recorder
|
|
|
- recordr.setPart(state.partId, data)
|
|
|
- this.commit('tour/update')
|
|
|
- },
|
|
|
- getUploadMuscis(state, payload) {
|
|
|
- let musics = state.tours.filter(item => {
|
|
|
- console.log(item.file)
|
|
|
- if (item.file) {
|
|
|
- return item
|
|
|
- }
|
|
|
- })
|
|
|
- console.log(musics)
|
|
|
- return musics
|
|
|
- },
|
|
|
- // setTime(state, time) {
|
|
|
- // // state.tours[state.partId].list[state.frameId].time = time * 1000
|
|
|
- // this.commit('tour/setFrame', { time: time * 1000 })
|
|
|
- // },
|
|
|
- deleteList(state, payload) {
|
|
|
- let frameId = payload.frameId || 0
|
|
|
- let list = state.tours[state.partId].list
|
|
|
- let music = state.tours[state.partId].music
|
|
|
- // let name = state.tours[state.partId].list[frameId].enter.cover
|
|
|
- switch (payload.type) {
|
|
|
- case 'part':
|
|
|
- // if (music.indexOf('blob:') == -1 && music != '') {
|
|
|
- if (music != '') {
|
|
|
- let file = state.tours[state.partId].musicUrl ? state.tours[state.partId].musicUrl.split('/').pop().split('?').shift() : music.split('/').pop().split('?').shift()
|
|
|
- state.delList.push(file)
|
|
|
- }
|
|
|
- if (list.length > 0) {
|
|
|
- list.forEach((i, index) => {
|
|
|
- // if (i.enter.coverUrl || i.enter.cover.indexOf('data:image') == -1) {
|
|
|
- // state.delList.push(i.enter.cover.split('/').pop().split('?').shift())
|
|
|
- // }
|
|
|
- let cover = i.enter.coverUrl ? i.enter.coverUrl.split('/').pop().split('?').shift() : i.enter.cover.split('/').pop().split('?').shift()
|
|
|
- if (state.delList.length > 0) {
|
|
|
- let same = false
|
|
|
- for (let j = 0; j < state.delList.length; j++) {
|
|
|
- if (cover == state.delList[j]) {
|
|
|
- same = true
|
|
|
- }
|
|
|
- }
|
|
|
- if (!same) {
|
|
|
- state.delList.push(cover)
|
|
|
- }
|
|
|
- } else {
|
|
|
- state.delList.push(cover)
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- break
|
|
|
- case 'frame':
|
|
|
- // if (name.indexOf('data:image') == -1) {
|
|
|
- // state.delList.push(name.split('/').pop().split('?').shift())
|
|
|
- // }
|
|
|
- let enter = state.tours[state.partId].list[frameId].enter
|
|
|
-
|
|
|
- // let cover =enter.coverUrl
|
|
|
- // ? enter.coverUrl.split('/').pop().split('?').shift()
|
|
|
- // : enter.cover.split('/').pop().split('?').shift()
|
|
|
- let cover = enter.coverUrl ? enter.coverUrl : enter.cover
|
|
|
- if (cover.substring(0, 10) != 'data:image') {
|
|
|
- state.delList.push(cover)
|
|
|
- }
|
|
|
-
|
|
|
- //整理删除文件列表
|
|
|
-
|
|
|
- if (state.tours[state.partId].list.length == 1) {
|
|
|
- this.commit('tour/deleteList', { type: 'part' })
|
|
|
- }
|
|
|
-
|
|
|
- break
|
|
|
- case 'music':
|
|
|
- // if (music.indexOf('blob:') == -1 && music != '') {
|
|
|
- // state.delList.push(name.split('/').pop().split('?').shift())
|
|
|
- // }
|
|
|
- if (music != '') {
|
|
|
- let file = state.tours[state.partId].musicUrl ? state.tours[state.partId].musicUrl.split('/').pop().split('?').shift() : music.split('/').pop().split('?').shift()
|
|
|
- state.delList.push(file)
|
|
|
- }
|
|
|
- break
|
|
|
- }
|
|
|
- console.log(state.delList)
|
|
|
- },
|
|
|
- hanldActive(state, payload) {
|
|
|
- this.commit('tour/deleteList', { type: 'part' })
|
|
|
- if (state.tours[state.tours.length - 1].list == 0) {
|
|
|
- state.tours.splice(state.tours.length - 1, 1)
|
|
|
- if (state.tours.length == 0) {
|
|
|
- this.commit('setToolbox', {
|
|
|
- show: false,
|
|
|
- type: null,
|
|
|
- })
|
|
|
- }
|
|
|
- let id
|
|
|
- if (state.partId >= state.tours.length) {
|
|
|
- id = 0
|
|
|
- } else {
|
|
|
- id = state.partId
|
|
|
- }
|
|
|
- this.commit('tour/setData', { partId: id })
|
|
|
- }
|
|
|
- },
|
|
|
- async cancel(state) {
|
|
|
- this.commit('leaveEdit')
|
|
|
- state.hlIndex = -1
|
|
|
-
|
|
|
- state.tours = JSON.parse(JSON.stringify(state.toursList))
|
|
|
- getApp().TourManager.load(JSON.parse(JSON.stringify(state.toursList))) //通知回滚
|
|
|
- if (state.partId >= state.tours.length) {
|
|
|
- state.partId = 0
|
|
|
- }
|
|
|
-
|
|
|
- state.toursList = JSON.parse(JSON.stringify(state.tours))
|
|
|
- state.delList = []
|
|
|
- state.fileObj = {}
|
|
|
- },
|
|
|
- save(state, newdData) {
|
|
|
- state.toursList = JSON.parse(JSON.stringify(newdData))
|
|
|
- getApp().TourManager.load(JSON.parse(JSON.stringify(state.toursList)))
|
|
|
- // 先删除空的片段
|
|
|
- state.hlIndex = -1
|
|
|
- for (let i = 0; i < state.tours.length; i++) {
|
|
|
- if (state.tours[i].list.length == 0) {
|
|
|
- state.tours.splice(i, 1)
|
|
|
- //切换片段ID
|
|
|
- if (state.partId < state.tours.length - 1) {
|
|
|
- state.partId++
|
|
|
- } else {
|
|
|
- state.partId = 0
|
|
|
- }
|
|
|
- i--
|
|
|
- }
|
|
|
- }
|
|
|
- for (let i = 0; i < state.tours.length; i++) {
|
|
|
- state.tours[i].musicUrl = newdData[i].music
|
|
|
- for (let j = 0; j < newdData[i].list.length; j++) {
|
|
|
- state.tours[i].list[j].enter.coverUrl = newdData[i].list[j].enter.cover
|
|
|
- }
|
|
|
- }
|
|
|
- console.log(state.tours)
|
|
|
- console.log(state.hlIndex)
|
|
|
- this.commit('leaveEdit')
|
|
|
- },
|
|
|
- },
|
|
|
- actions: {
|
|
|
- delTours({ commit, state }, payload) {
|
|
|
- // tour/delete
|
|
|
- return getApp()
|
|
|
- .remote_editor.tour_delete({ num: getNum() })
|
|
|
- .then(res => {
|
|
|
- if (res.success) {
|
|
|
- state.tours = []
|
|
|
- commit('save', [])
|
|
|
- getApp().TourManager.load([])
|
|
|
- }
|
|
|
- return res
|
|
|
- })
|
|
|
- .catch(err => {
|
|
|
- console.log(err)
|
|
|
- return err
|
|
|
- })
|
|
|
- },
|
|
|
- async delFile({ commit, state }, payload) {
|
|
|
- let params = {
|
|
|
- num: getNum(),
|
|
|
- bizType: 'tour',
|
|
|
- fileNames: state.delList,
|
|
|
- }
|
|
|
- let res = await this.dispatch('delFiles', params)
|
|
|
- console.log(res)
|
|
|
- if (res.success) {
|
|
|
- state.delList = []
|
|
|
- }
|
|
|
- },
|
|
|
- async save({ commit, dispatch, state }, payload) {
|
|
|
- if (state.allTime > 60 * 30) {
|
|
|
- return Promise.reject({ type: 'toast', tips: 'warn', msg: 'tour.toolbar.timeLimit' })
|
|
|
- }
|
|
|
- let recorder = await getApp().TourManager.recorder
|
|
|
- let data = recorder.exportData()
|
|
|
- for (let i = 0; i < data.length; i++) {
|
|
|
- if (data[i].name == '') {
|
|
|
- return Promise.reject({ type: 'toast', tips: 'warn', msg: 'tour.toolbox.tourTitleTips' })
|
|
|
- }
|
|
|
- }
|
|
|
- if (state.delList.length > 0) {
|
|
|
- dispatch('delFile')
|
|
|
- }
|
|
|
-
|
|
|
- let exportFiles = recorder.exportFiles()
|
|
|
- let files = []
|
|
|
- console.log(exportFiles)
|
|
|
- exportFiles.map(item => {
|
|
|
- let obj = {}
|
|
|
- if (item.type == 'base64') {
|
|
|
- obj.file = convertBlob2File(base64ToBlob(item.file), item.name)
|
|
|
- obj.filename = item.name
|
|
|
- } else if (item.type == 'file') {
|
|
|
- state.tours.filter(i => {
|
|
|
- let fileId = item.name.split('.').shift().split('-').pop()
|
|
|
- if (fileId == i.sid) {
|
|
|
- // obj.file = i.file
|
|
|
- obj.file = state.fileObj[i.sid]
|
|
|
- obj.filename = item.name
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- files.push(obj)
|
|
|
- })
|
|
|
- console.log(files)
|
|
|
- if (files.length > 0) {
|
|
|
- let res = await this.dispatch('scene/upload_files', { bizType: 'tour', num: getNum(), type: 0, files: files })
|
|
|
- if (res.success) {
|
|
|
- state.fileObj = {}
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- console.log('data', data)
|
|
|
- console.log('tours', state.tours)
|
|
|
- let params = {
|
|
|
- num: getNum(),
|
|
|
- data: JSON.stringify(data),
|
|
|
- }
|
|
|
- return getApp()
|
|
|
- .remote_editor.tour_save(params)
|
|
|
- .then(res => {
|
|
|
- if (res.success) {
|
|
|
- commit('save', data)
|
|
|
- }
|
|
|
- return res
|
|
|
- })
|
|
|
- .catch(err => {
|
|
|
- console.log(err)
|
|
|
- return err
|
|
|
- })
|
|
|
- },
|
|
|
- },
|
|
|
-}
|
|
|
+import { getApp, getNum } from '@/app'
|
|
|
+import { base64ToBlob, convertBlob2File } from '@/utils/file'
|
|
|
+export default {
|
|
|
+ namespaced: true,
|
|
|
+ state() {
|
|
|
+ return {
|
|
|
+ // showPath: false,
|
|
|
+ // showFrame: false,
|
|
|
+ toursList: [],
|
|
|
+ sourceList: null,
|
|
|
+ frameId: 0,
|
|
|
+ partId: 0,
|
|
|
+ tours: [],
|
|
|
+ fileObj: {},
|
|
|
+ musicList: [],
|
|
|
+ delList: [],
|
|
|
+ isPlay: false,
|
|
|
+ showTours: false,
|
|
|
+ hlIndex: -1,
|
|
|
+ allTime: 0,
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getters: {
|
|
|
+ tours: state => {
|
|
|
+ return state.tours
|
|
|
+ },
|
|
|
+ allTime: state => {
|
|
|
+ return state.allTime
|
|
|
+ },
|
|
|
+
|
|
|
+ partId: state => {
|
|
|
+ return state.partId
|
|
|
+ },
|
|
|
+ frameId: state => {
|
|
|
+ return state.frameId
|
|
|
+ },
|
|
|
+ isPlay: state => {
|
|
|
+ return state.isPlay
|
|
|
+ },
|
|
|
+ showTours: state => {
|
|
|
+ return state.showTours
|
|
|
+ },
|
|
|
+ hlIndex: state => {
|
|
|
+ return state.hlIndex
|
|
|
+ },
|
|
|
+ },
|
|
|
+ mutations: {
|
|
|
+ async setData(state, payload) {
|
|
|
+ if (payload) {
|
|
|
+ for (let key in payload) {
|
|
|
+ state[key] = payload[key]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setBackUp(state) {
|
|
|
+ state.toursList = JSON.parse(JSON.stringify(state.tours))
|
|
|
+ },
|
|
|
+ update(state, tours) {
|
|
|
+ this.commit('enterEdit')
|
|
|
+ //如果删除片段和备份数据一样则退出编辑模式
|
|
|
+ // let t = setTimeout(() => {
|
|
|
+ // clearTimeout(t)
|
|
|
+ // if (state.tours.length == 0 && state.toursList.length == 0) {
|
|
|
+ // this.commit('leaveEdit')
|
|
|
+ // }
|
|
|
+ // }, 0)
|
|
|
+ },
|
|
|
+ async setFrame(state, payload) {
|
|
|
+ const recordr = await getApp().TourManager.recorder
|
|
|
+ recordr.setFrame(state.frameId, payload)
|
|
|
+ this.commit('tour/update')
|
|
|
+ },
|
|
|
+ async setPart(state, payload) {
|
|
|
+ let data = JSON.parse(JSON.stringify(payload))
|
|
|
+
|
|
|
+ for (let key in payload) {
|
|
|
+ state.tours[state.partId][key] = payload[key]
|
|
|
+ }
|
|
|
+ for (let key in data) {
|
|
|
+ if (key === 'file') {
|
|
|
+ state.fileObj[state.tours[state.partId].sid] = payload[key]
|
|
|
+ delete data[key]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const recordr = await getApp().TourManager.recorder
|
|
|
+ recordr.setPart(state.partId, data)
|
|
|
+ this.commit('tour/update')
|
|
|
+ },
|
|
|
+ getUploadMuscis(state, payload) {
|
|
|
+ let musics = state.tours.filter(item => {
|
|
|
+ console.log(item.file)
|
|
|
+ if (item.file) {
|
|
|
+ return item
|
|
|
+ }
|
|
|
+ })
|
|
|
+ console.log(musics)
|
|
|
+ return musics
|
|
|
+ },
|
|
|
+ // setTime(state, time) {
|
|
|
+ // // state.tours[state.partId].list[state.frameId].time = time * 1000
|
|
|
+ // this.commit('tour/setFrame', { time: time * 1000 })
|
|
|
+ // },
|
|
|
+ deleteList(state, payload) {
|
|
|
+ let frameId = payload.frameId || 0
|
|
|
+ let list = state.tours[state.partId].list
|
|
|
+ let music = state.tours[state.partId].music
|
|
|
+ // let name = state.tours[state.partId].list[frameId].enter.cover
|
|
|
+ switch (payload.type) {
|
|
|
+ case 'part':
|
|
|
+ // if (music.indexOf('blob:') == -1 && music != '') {
|
|
|
+ if (music != '') {
|
|
|
+ let file = state.tours[state.partId].musicUrl ? state.tours[state.partId].musicUrl.split('/').pop().split('?').shift() : music.split('/').pop().split('?').shift()
|
|
|
+ state.delList.push(file)
|
|
|
+ }
|
|
|
+ if (list.length > 0) {
|
|
|
+ list.forEach((i, index) => {
|
|
|
+ // if (i.enter.coverUrl || i.enter.cover.indexOf('data:image') == -1) {
|
|
|
+ // state.delList.push(i.enter.cover.split('/').pop().split('?').shift())
|
|
|
+ // }
|
|
|
+ let cover = i.enter.coverUrl ? i.enter.coverUrl.split('/').pop().split('?').shift() : i.enter.cover.split('/').pop().split('?').shift()
|
|
|
+ if (state.delList.length > 0) {
|
|
|
+ let same = false
|
|
|
+ for (let j = 0; j < state.delList.length; j++) {
|
|
|
+ if (cover == state.delList[j]) {
|
|
|
+ same = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!same) {
|
|
|
+ state.delList.push(cover)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ state.delList.push(cover)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ break
|
|
|
+ case 'frame':
|
|
|
+ // if (name.indexOf('data:image') == -1) {
|
|
|
+ // state.delList.push(name.split('/').pop().split('?').shift())
|
|
|
+ // }
|
|
|
+ let enter = state.tours[state.partId].list[frameId].enter
|
|
|
+
|
|
|
+ // let cover =enter.coverUrl
|
|
|
+ // ? enter.coverUrl.split('/').pop().split('?').shift()
|
|
|
+ // : enter.cover.split('/').pop().split('?').shift()
|
|
|
+ let cover = enter.coverUrl ? enter.coverUrl : enter.cover
|
|
|
+ if (cover.substring(0, 10) != 'data:image') {
|
|
|
+ state.delList.push(cover)
|
|
|
+ }
|
|
|
+
|
|
|
+ //整理删除文件列表
|
|
|
+
|
|
|
+ if (state.tours[state.partId].list.length == 1) {
|
|
|
+ this.commit('tour/deleteList', { type: 'part' })
|
|
|
+ }
|
|
|
+
|
|
|
+ break
|
|
|
+ case 'music':
|
|
|
+ // if (music.indexOf('blob:') == -1 && music != '') {
|
|
|
+ // state.delList.push(name.split('/').pop().split('?').shift())
|
|
|
+ // }
|
|
|
+ if (music != '') {
|
|
|
+ let file = state.tours[state.partId].musicUrl ? state.tours[state.partId].musicUrl.split('/').pop().split('?').shift() : music.split('/').pop().split('?').shift()
|
|
|
+ state.delList.push(file)
|
|
|
+ }
|
|
|
+ break
|
|
|
+ }
|
|
|
+ console.log(state.delList)
|
|
|
+ },
|
|
|
+ hanldActive(state, payload) {
|
|
|
+ this.commit('tour/deleteList', { type: 'part' })
|
|
|
+ if (state.tours[state.tours.length - 1].list == 0) {
|
|
|
+ state.tours.splice(state.tours.length - 1, 1)
|
|
|
+ if (state.tours.length == 0) {
|
|
|
+ this.commit('setToolbox', {
|
|
|
+ show: false,
|
|
|
+ type: null,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ let id
|
|
|
+ if (state.partId >= state.tours.length) {
|
|
|
+ id = 0
|
|
|
+ } else {
|
|
|
+ id = state.partId
|
|
|
+ }
|
|
|
+ this.commit('tour/setData', { partId: id })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async cancel(state) {
|
|
|
+ this.commit('leaveEdit')
|
|
|
+ state.hlIndex = -1
|
|
|
+
|
|
|
+ state.tours = JSON.parse(JSON.stringify(state.toursList))
|
|
|
+ getApp().TourManager.load(JSON.parse(JSON.stringify(state.toursList))) //通知回滚
|
|
|
+ if (state.partId >= state.tours.length) {
|
|
|
+ state.partId = 0
|
|
|
+ }
|
|
|
+
|
|
|
+ state.toursList = JSON.parse(JSON.stringify(state.tours))
|
|
|
+ state.delList = []
|
|
|
+ state.fileObj = {}
|
|
|
+ },
|
|
|
+ save(state, newdData) {
|
|
|
+ state.toursList = JSON.parse(JSON.stringify(newdData))
|
|
|
+ getApp().TourManager.load(JSON.parse(JSON.stringify(state.toursList)))
|
|
|
+ // 先删除空的片段
|
|
|
+ state.hlIndex = -1
|
|
|
+ for (let i = 0; i < state.tours.length; i++) {
|
|
|
+ if (state.tours[i].list.length == 0) {
|
|
|
+ state.tours.splice(i, 1)
|
|
|
+ //切换片段ID
|
|
|
+ if (state.partId < state.tours.length - 1) {
|
|
|
+ state.partId++
|
|
|
+ } else {
|
|
|
+ state.partId = 0
|
|
|
+ }
|
|
|
+ i--
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (let i = 0; i < state.tours.length; i++) {
|
|
|
+ state.tours[i].musicUrl = newdData[i].music
|
|
|
+ for (let j = 0; j < newdData[i].list.length; j++) {
|
|
|
+ state.tours[i].list[j].enter.coverUrl = newdData[i].list[j].enter.cover
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log(state.tours)
|
|
|
+ console.log(state.hlIndex)
|
|
|
+ this.commit('leaveEdit')
|
|
|
+ },
|
|
|
+ },
|
|
|
+ actions: {
|
|
|
+ delTours({ commit, state }, payload) {
|
|
|
+ // tour/delete
|
|
|
+ return getApp()
|
|
|
+ .remote_editor.tour_delete({ num: getNum() })
|
|
|
+ .then(res => {
|
|
|
+ if (res.success) {
|
|
|
+ state.tours = []
|
|
|
+ commit('save', [])
|
|
|
+ getApp().TourManager.load([])
|
|
|
+ }
|
|
|
+ return res
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.log(err)
|
|
|
+ return err
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async delFile({ commit, state }, payload) {
|
|
|
+ let params = {
|
|
|
+ num: getNum(),
|
|
|
+ bizType: 'tour',
|
|
|
+ fileNames: state.delList,
|
|
|
+ }
|
|
|
+ let res = await this.dispatch('delFiles', params)
|
|
|
+ console.log(res)
|
|
|
+ if (res.success) {
|
|
|
+ state.delList = []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async save({ commit, dispatch, state }, payload) {
|
|
|
+ if (state.allTime > 60 * 30) {
|
|
|
+ return Promise.reject({ type: 'toast', tips: 'warn', msg: 'tour.toolbar.timeLimit' })
|
|
|
+ }
|
|
|
+ let recorder = await getApp().TourManager.recorder
|
|
|
+ let data = recorder.exportData()
|
|
|
+ for (let i = 0; i < data.length; i++) {
|
|
|
+ if (data[i].name == '') {
|
|
|
+ return Promise.reject({ type: 'toast', tips: 'warn', msg: 'tour.toolbox.tourTitleTips' })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (state.delList.length > 0) {
|
|
|
+ dispatch('delFile')
|
|
|
+ }
|
|
|
+
|
|
|
+ let exportFiles = recorder.exportFiles()
|
|
|
+ let files = []
|
|
|
+ console.log(exportFiles)
|
|
|
+ exportFiles.map(item => {
|
|
|
+ let obj = {}
|
|
|
+ if (item.type == 'base64') {
|
|
|
+ obj.file = convertBlob2File(base64ToBlob(item.file), item.name)
|
|
|
+ obj.filename = item.name
|
|
|
+ } else if (item.type == 'file') {
|
|
|
+ state.tours.filter(i => {
|
|
|
+ let fileId = item.name.split('.').shift().split('-').pop()
|
|
|
+ if (fileId == i.sid) {
|
|
|
+ // obj.file = i.file
|
|
|
+ obj.file = state.fileObj[i.sid]
|
|
|
+ obj.filename = item.name
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ files.push(obj)
|
|
|
+ })
|
|
|
+ console.log(files)
|
|
|
+ if (files.length > 0) {
|
|
|
+ let res = await this.dispatch('scene/upload_files', { bizType: 'tour', num: getNum(), type: 0, files: files })
|
|
|
+ if (res.success) {
|
|
|
+ state.fileObj = {}
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('data', data)
|
|
|
+ console.log('tours', state.tours)
|
|
|
+ let params = {
|
|
|
+ num: getNum(),
|
|
|
+ data: JSON.stringify(data),
|
|
|
+ }
|
|
|
+ return getApp()
|
|
|
+ .remote_editor.tour_save(params)
|
|
|
+ .then(res => {
|
|
|
+ if (res.success) {
|
|
|
+ commit('save', data)
|
|
|
+ }
|
|
|
+ return res
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.log(err)
|
|
|
+ return err
|
|
|
+ })
|
|
|
+ },
|
|
|
+ },
|
|
|
+}
|