<template> <transition name="slide"> <div class="index-container"> <!--标题--> <mt-header class="header" title="个人中心"> </mt-header> <div class="listbody"> <mt-cell :title="name" is-link to="/information"></mt-cell> <mt-cell title="帮助中心" is-link to="/helpMe"></mt-cell> <mt-cell title="联系客服" is-link to="/contactUs"></mt-cell> <mt-cell title="版本更新" is-link @click.native="checkVersions"></mt-cell> <mt-cell title="关于我们" is-link to="/aboutUs"></mt-cell> </div> <tabbottom activeTabItem="MINE"/> </div> </transition> </template> <script> import {checkVersion, downloadApk} from '@/api/app' import { MessageBox } from 'mint-ui'; export default { name: "Mine", data() { return { name:this.$store.getters.name } }, methods: { //检查更新 checkVersions(){ console.log('checkVersion') checkVersion().then(response => { console.log('response:') const version = response.data.version //如果有新版本的话 if(version!=this.$store.getters.version){ const base_url = process.env.BASE_API + '/static/' MessageBox({ title: '提示', message: '新版本来了,马上更新!', showCancelButton: true, confirmButtonText:'立即下载', cancelButtonText:'稍后再说' }).then(action=>{ if(action!='cancel') { const url = response.data.downloadUrl var url2 = base_url + url window.open(url2); // // console.log('action:') // console.log(action) // //下载apk // downloadApk(url).then(res => { // loading.close() // 关闭加载动画 // console.log('download===', res) // const blob = new Blob([res.data]) // const downloadElement = document.createElement('a') // const href = window.URL.createObjectURL(blob) // 创建下载的链接 // downloadElement.href = href // downloadElement.download = `smartWell.apk` // 下载后文件名 // document.body.appendChild(downloadElement) // downloadElement.click() // 点击下载 // document.body.removeChild(downloadElement) // 下载完成移除元素 // window.URL.revokeObjectURL(href) // 释放blob对象 // }).catch((res) => { // Toast(res.message); // }) } }) }else{ MessageBox('提示', '当前已是最新版,无需更新'); } }) } } } </script> <style lang="stylus" rel="stylesheet/stylus" scoped> .mint-cell-title { margin-left: 5px !important } </style>