| | |
| | | <view class="list-no-content" v-else> |
| | | <!-- <image class="img" src="/images/icon-park-outline_attention.svg" alt=" 图片" mode="aspectFit" />--> |
| | | <uni-icons color="#ccc" type="info" size="128"></uni-icons> |
| | | <view class="space">没有找到符合条件的场景</view> |
| | | <view class="space">{{translate('no_scene_matching_criteria')}}</view> |
| | | </view> |
| | | <view class="list-tip">请选择上传到手机端的场景</view> |
| | | <view class="list-tip">{{translate('select_scene_to_upload_mobile')}}</view> |
| | | <view> |
| | | |
| | | <a-button :disabled="loading|| sceneIndex < 0" type="primary" class="button" |
| | | @click="clickSaveToLocal">上传至手机端</a-button> |
| | | <a-button v-if="!loading" :disabled=" sceneIndex < 0" type="primary" class="button" |
| | | @click="clickSaveToLocal">{{translate('upload_to_mobile')}}</a-button> |
| | | |
| | | </view> |
| | | <view v-if="loading && loadingPage== 0" class="list-progress"> |
| | | {{translate("scene_uploading") }}... |
| | | <view class="spinner"></view> |
| | | </view> |
| | | |
| | | </view> |
| | | |
| | | </swiper-item> |
| | |
| | | <view class="list-no-content" v-else> |
| | | <!-- <image class="img" src="/images/icon-park-outline_attention.svg" alt=" 图片" mode="aspectFit" />--> |
| | | <uni-icons color="#ccc" type="info" size="128"></uni-icons> |
| | | <view class="space">没有找到符合条件的场景</view> |
| | | <view class="space">{{translate('no_scene_matching_criteria')}}</view> |
| | | </view> |
| | | <view class="list-tip">请选择下载到车辆端的场景</view> |
| | | <view class="list-tip">{{translate('select_scene_to_download_vehicle')}}</view> |
| | | <view> |
| | | <a-button :disabled="loading|| sceneIndex2< 0" type="primary" class="button" |
| | | @click="clickSaveToVehicle">下载至车辆端</a-button> |
| | | <a-button v-if="!loading" :disabled="sceneIndex2< 0" type="primary" class="button" |
| | | @click="clickSaveToVehicle">{{translate('download_to_vehicle')}}</a-button> |
| | | |
| | | </view> |
| | | <view v-if="loading && loadingPage== 1" class="list-progress"> |
| | | {{translate("scene_downloading") }}...{{saveDBDataStatusStr}} |
| | | <view class="spinner"></view> |
| | | </view> |
| | | |
| | | </view> |
| | | |
| | | </swiper-item> |
| | |
| | | getAllScene, |
| | | handoffScene, |
| | | saveDBData, |
| | | getDBData |
| | | getDBData, |
| | | getSaveDBDataStatus, |
| | | cancelSaveDBData |
| | | |
| | | } from "@/api/vehicle.js" |
| | | import { |
| | | Button |
| | | } from 'antd-mobile-vue-next' |
| | | import { |
| | | async |
| | | } from "rxjs" |
| | | export default { |
| | | name: "PagesBackup", |
| | | components: { |
| | |
| | | sceneIndex: -1, |
| | | sceneIndex2: -1, |
| | | curPageIndex: 0, |
| | | loadingPage: 0, |
| | | opType: "", |
| | | pageList: [{ |
| | | name: "上传场景", |
| | | title: "ES-GO1场景列表", |
| | | name: this.translate('upload_scenes'), |
| | | title: `ES-GO1 ${this.translate('scene_list')}`, |
| | | list: [] |
| | | }, { |
| | | name: "下载场景", |
| | | title: "手机端保存的场景列表", |
| | | name: this.translate('download_scenes'), |
| | | title: this.translate('scene_list_on_cellphone'), |
| | | list: [] |
| | | }] |
| | | }], |
| | | saveDBDataStatus: 0, |
| | | } |
| | | }, |
| | | computed: {}, |
| | | computed: { |
| | | |
| | | saveDBDataStatusStr() { |
| | | if (this.saveDBDataStatus == 2) { |
| | | return this.translate("saved_success") |
| | | } else if (this.saveDBDataStatus == 3) { |
| | | return this.translate("saved_fail") |
| | | } else { |
| | | return this.translate("saving") |
| | | } |
| | | } |
| | | }, |
| | | onLoad(option) { |
| | | this.ip = option.ip || "" |
| | | this.opType = option.opType || "" |
| | | if (this.opType == "download") { |
| | | this.curPageIndex = 1 |
| | | } |
| | | |
| | | uni.setNavigationBarTitle({ |
| | | title: this.translate('scene_backup') |
| | | }) |
| | | this.loadData() |
| | | }, |
| | | onBackPress() { |
| | | |
| | | const _this = this |
| | | if (this.loading) { |
| | | showModal({ |
| | | title: this.translate("ask_exit_page"), |
| | | content: this.loadingPage == 1 ? `${this.translate('scene_downloading')}` : |
| | | `${this.translate('scene_uploading')}`, |
| | | confirmText: this.translate('yes'), |
| | | cancelText: this.translate("no"), |
| | | }).then(async (res) => { |
| | | if (res) { |
| | | |
| | | await _this.cancelSaveDBData() |
| | | _this.saveDBDataStatus = 3 |
| | | _this.setData({ |
| | | loading: false |
| | | }) |
| | | uni.navigateBack({ |
| | | delta: 1, //返回层数,2则上上页 |
| | | }) |
| | | } |
| | | |
| | | }) |
| | | return true |
| | | } |
| | | if (this.opType == "download") { |
| | | uni.reLaunch({ |
| | | url: "/pages/index/index" |
| | | }) |
| | | return true |
| | | } |
| | | }, |
| | | methods: { |
| | | setData(obj) { |
| | |
| | | |
| | | console.log(this.pageList[1].list) |
| | | } catch (ex) { |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | } |
| | | }, |
| | | async loadScene() { |
| | |
| | | const list = res?.sceneList || [] |
| | | return list |
| | | } catch (ex) { |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | return [] |
| | | } |
| | | }, |
| | |
| | | const list = session.getValue("scene_db") || [] |
| | | return list |
| | | } catch (ex) { |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | return [] |
| | | } |
| | | }, |
| | |
| | | const _this = this |
| | | let list = this.pageList[1].list |
| | | if (list.length > 0) { |
| | | showModal(`上传该场景会替换掉当前已上传的场景`, "是否要覆盖场景?").then(async (res) => { |
| | | showModal({ |
| | | title: this.translate('confirm_replace_scene'), |
| | | content: this.translate('uploading_will_replace_currently_uploaded_scene'), |
| | | confirmText: this.translate("confirm"), |
| | | cancelText: this.translate("cancel"), |
| | | }).then(async (res) => { |
| | | if (res) { |
| | | _this.saveToLocal(this.sceneIndex) |
| | | } |
| | |
| | | async saveToLocal(index) { |
| | | try { |
| | | this.setData({ |
| | | loading: true |
| | | loading: true, |
| | | loadingPage: 0, |
| | | }) |
| | | uni.showLoading({ |
| | | title:"正在上传场景" |
| | | }) |
| | | |
| | | // uni.showLoading({ |
| | | // title: `${this.translate('upload_scenes')}...` |
| | | // }) |
| | | const scene = this.pageList[0].list[index] |
| | | await handoffScene(this.ip, "", scene) |
| | | session.setValue("scene_db", []) |
| | |
| | | session.setValue("scene_db", list) |
| | | this.pageList[1].list = list |
| | | this.sceneIndex2 = -1 |
| | | showToast(`上传场景[${scene}]成功`) |
| | | showToast(this.translate('upload_success')) |
| | | } catch (ex) { |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | |
| | | } |
| | | finally { |
| | | } finally { |
| | | this.setData({ |
| | | loading: false |
| | | }) |
| | | uni.hideLoading() |
| | | // uni.hideLoading() |
| | | } |
| | | |
| | | }, |
| | |
| | | const curIndex = list.findIndex((a) => a == scene) |
| | | console.log(curIndex, scene,list) |
| | | if (curIndex > -1) { |
| | | showModal(`下载该场景会替换掉已下载的同名场景。`, "是否要覆盖场景?").then(async (res) => { |
| | | showModal({ |
| | | title: this.translate('confirm_replace_scene'), |
| | | content: this.translate('downloading_will_replace_currently_downloaded_scene'), |
| | | confirmText: this.translate("confirm"), |
| | | cancelText: this.translate("cancel"), |
| | | }).then(async (res) => { |
| | | if (res) { |
| | | _this.saveToVehicle(this.sceneIndex2) |
| | | } |
| | |
| | | } |
| | | _this.saveToVehicle(this.sceneIndex2) |
| | | }, |
| | | async saveToVehicle(index) { |
| | | async cancelSaveDBData() { |
| | | try { |
| | | this.setData({ |
| | | loading: true |
| | | }) |
| | | uni.showLoading({ |
| | | title:"正在下载场景" |
| | | }) |
| | | |
| | | const data = this.pageList[1].list[index].data |
| | | const scene = this.pageList[1].list[index].name |
| | | await saveDBData(this.ip, data) |
| | | this.pageList[0].list.push(scene) |
| | | showToast(`下载场景[${scene}]成功`) |
| | | |
| | | await cancelSaveDBData(this.ip) |
| | | } catch (ex) { |
| | | showError(ex) |
| | | showToast(ex) |
| | | } |
| | | finally { |
| | | }, |
| | | async checkSaveDBDataStatus() { |
| | | try { |
| | | |
| | | if (this.saveDBDataStatus === 2 || this.saveDBDataStatus === 3) { |
| | | this.setData({ |
| | | loading: false |
| | | }) |
| | | uni.hideLoading() |
| | | if (this.saveDBDataStatus === 2) { |
| | | const scene = this.pageList[1].list[this.sceneIndex2]?.name |
| | | this.pageList[0].list.push(scene) |
| | | showToast(this.translate('download_success')) |
| | | } |
| | | return |
| | | } |
| | | this.saveDBDataStatus = await getSaveDBDataStatus(this.ip) || 0 |
| | | |
| | | if (this.saveDBDataStatus === 2 || this.saveDBDataStatus === 3) { |
| | | this.setData({ |
| | | loading: false |
| | | }) |
| | | if (this.saveDBDataStatus === 2) { |
| | | const scene = this.pageList[1].list[this.sceneIndex2]?.name |
| | | this.pageList[0].list.push(scene) |
| | | showToast(this.translate('download_success')) |
| | | } else { |
| | | showToast(`${this.translate('update_fail')}, ${this.translate('saved_fail')} `) |
| | | } |
| | | return |
| | | } |
| | | setTimeout(this.checkSaveDBDataStatus, 1000); |
| | | } catch (ex) { |
| | | showToast(ex) |
| | | setTimeout(this.checkSaveDBDataStatus, 1000); |
| | | } |
| | | }, |
| | | |
| | | async saveToVehicle(index) { |
| | | try { |
| | | this.setData({ |
| | | loading: true, |
| | | loadingPage: 1, |
| | | }) |
| | | // uni.showLoading({ |
| | | // title: `${this.translate('download_scenes')}...` |
| | | // }) |
| | | |
| | | const data = this.pageList[1].list[index].data |
| | | const scene = this.pageList[1].list[index].name |
| | | this.saveDBDataStatus = 1 |
| | | await saveDBData(this.ip, data) |
| | | this.checkSaveDBDataStatus() |
| | | |
| | | |
| | | } catch (ex) { |
| | | this.setData({ |
| | | loading: false |
| | | }) |
| | | showError(ex, this.translate('error')) |
| | | } |
| | | |
| | | }, |
| | | translate(t) { |
| | | if (typeof this.$t == "function") return this.$t(`page.${t}`) |
| | | else return t; |
| | | }, |
| | | |
| | | |
| | |
| | | flex-direction: column; |
| | | padding: 0 10rpx; |
| | | |
| | | .list-progress { |
| | | width: 100%; |
| | | text-align: center; |
| | | margin: 20rpx; |
| | | } |
| | | |
| | | .list-tip { |
| | | width: 100%; |
| | | padding: 15rpx; |
| | | color: #888; |
| | | |
| | | } |
| | | |
| | | .list-view { |
| | |
| | | overflow: auto; |
| | | background-color: #fff; |
| | | max-height:500rpx ; |
| | | |
| | | .list-item { |
| | | |
| | | border-bottom: 1px solid #ddd; |
| | |
| | | } |
| | | |
| | | .am-button { |
| | | border-radius: 90rpx; |
| | | height: 90rpx; |
| | | border-radius: 40rpx; |
| | | height: 80rpx; |
| | | line-height: 60rpx; |
| | | } |
| | | |
| | | } |
| | | |
| | | /* CSS动画示例:旋转的圆环 */ |
| | | .spinner { |
| | | width: 100rpx; |
| | | height: 100rpx; |
| | | border: 4px solid #f3f3f3; |
| | | border-top: 4px solid #007aff; |
| | | border-radius: 50%; |
| | | animation: spin 1s linear infinite; |
| | | margin: 20rpx auto; |
| | | } |
| | | |
| | | @keyframes spin { |
| | | 0% { |
| | | transform: rotate(0deg); |
| | | } |
| | | |
| | | 100% { |
| | | transform: rotate(360deg); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |