123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- import store from '../store/index.js'
- const getUpAppUrl = 'https://itunes.apple.com/cn/lookup?id=1524593346'
- const iosAppStroeUrl =
- 'https://apps.apple.com/cn/app/%E6%BB%A1%E5%9B%AD%E6%98%A5%E7%BA%BF%E4%B8%8A%E5%95%86%E5%9F%8E/id1524593346';
- export function getUpApp () {
-
- let hj = uni.getSystemInfoSync().platform;
-
- let app = store.state.isShowIllegality;
-
- if (hj === 'android') {
-
- app = true;
- store.commit('changeState', {
- name: 'app',
- value: app
- });
- }
- uni.request({
- url: getUpAppUrl,
- method: 'POST',
- data: {},
- success: res => {
- let r = res.data;
- plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
-
- let version = r.results[0].version;
-
- const arr = r.results[0].version.split('.');
-
- const arr1 = wgtinfo.version.split('.');
- for (let i = 0; i < arr.length; i++) {
-
- const x = +arr[i];
-
- const y = +arr1[i];
-
- if (x <= y) {
-
- if (hj === 'ios') {
-
- app = true;
- store.commit('changeState', {
- name: 'app',
- value: app
- });
- }
-
- if (x < y) {
- uni.showModal({
- title: '提示',
- content: '请更新应用',
- showCancel: false,
- success(e) {
- if (hj === 'ios') {
- plus.runtime.openURL(
- iosAppStroeUrl
- );
- }
- if (hj === 'android') {
-
- _self.downApp(version);
- }
- }
- });
- }
- return;
- }
- }
- });
- },
- });
- }
- export function downApp (version) {
- plus.nativeUI.showWaiting('下载升级包...');
- plus.downloader
- .createDownload('http://lxscimg.liuniu946.com/lxscV' + version + '.apk', {}, (d, status) => {
- if (status == 200) {
- installApp(d.filename);
- } else {
- plus.nativeUI.alert('下载升级包失败!');
- }
- plus.nativeUI.closeWaiting();
- })
- .start();
- }
- export function installApp (path) {
- plus.nativeUI.showWaiting('安装升级包...');
- plus.runtime.install(
- path, {},
- function() {
- plus.nativeUI.closeWaiting();
- uni.showToast({
- icon: 'none',
- title: '升级完成,准备重新载入'
- });
- setTimeout(_ => {
- uni.hideToast();
- plus.runtime.restart();
- }, 1000);
- },
- function(e) {
- plus.nativeUI.closeWaiting();
- plus.nativeUI.alert('安装升级包失败[' + e.code + ']:' + e.message);
- }
- );
- }
|