123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <script>
- export default {
- data() {
- return {}
- },
- onLoad() {},
- onShow() {},
- onLaunch() {
- const that = this;
- // 设备信息
- let system = that.$config.system;
- if (system.uniPlatform == 'app') {
- that.appCheck()
- } else if (system.uniPlatform == 'mp-weixin') {
- that.weixinCheck()
- }
- },
- methods: {
- // app检查版本
- appCheck() {
- const that = this;
- plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
- uni.request({
- url: `${that.$config.serverUrl}/files/projectadmin/appVersion.json`,
- method: 'GET',
- success: (res) => {
- if (wgtinfo.version === res.data.version) return;
- uni.showModal({
- title: '更新',
- content: "有新版本,是否下载?",
- success: (oneres) => {
- if (oneres.confirm) {
- // 下载app
- this.toUpdateAPK(res.data.url);
- }
- }
- })
- }
- })
- })
- },
- toUpdateAPK(url) {
- if (!url) return;
- uni.showLoading({
- title: '更新中……',
- mask: true,
- })
- uni.downloadFile({
- url: url,
- success: (res) => {
- uni.hideLoading();
- if (res.statusCode == 200) {
- uni.showModal({
- content: '更新成功,确定现在重启吗?',
- confirmText: '重启',
- confirmColor: '#EE8F57',
- success: modalRes => {
- if (modalRes.confirm) {
- plus.runtime.install(
- res.tempFilePath, {
- force: true
- },
- function(res) {
- plus.runtime.restart();
- })
- }
- }
- })
- }
- }
- })
- },
- // 微信检查版本
- weixinCheck() {
- console.log('微信检查本版');
- }
- },
- }
- </script>
- <style>
- @import url('@/uni.scss');
- .textOver {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- page {
- /* 主要背景色 */
- --rgb000: #000000;
- --rgb111: #111111;
- --rgbfff: #ffffff;
- --rgbf1f: #f1f1f1;
- --rgb161: #161616;
- --rgbfa4: #FA4343;
- --rgb67c: #67c23a;
- --rgb313: #31312e;
- --rgbffd: #FFD700;
- }
- </style>
|