Browse Source

2024-8-26

cmy 2 months ago
parent
commit
f07fb970e1
6 changed files with 192 additions and 37 deletions
  1. 27 18
      App.vue
  2. 9 0
      api/api.js
  3. 5 7
      manifest.json
  4. 2 2
      pages/annex/vip_paid/index.vue
  5. 0 10
      utils/request.js
  6. 149 0
      utils/upApp.js

+ 27 - 18
App.vue

@@ -32,8 +32,12 @@
 	let orange =
 		'--view-theme: #FE5C2D;--view-priceColor:#FE5C2D;--view-minorColor:rgba(254, 92, 45, 0.5);--view-minorColorT:rgba(254, 92, 45, 0.1);--view-bntColor:#FDB000;--view-assistColor:#FDB000;'
 	let gold =
-	    '--view-theme: #E0A558;--view-priceColor:#DA8C18;--view-minorColor:rgba(224, 165, 88, 0.5);--view-minorColorT:rgba(224, 165, 88, 0.1);--view-bntColor:#1A1A1A;'
-
+		'--view-theme: #E0A558;--view-priceColor:#DA8C18;--view-minorColor:rgba(224, 165, 88, 0.5);--view-minorColorT:rgba(224, 165, 88, 0.1);--view-bntColor:#1A1A1A;'
+	// #ifdef APP
+	import {
+		getUpApp
+	} from './utils/upApp.js';
+	// #endif
 
 	export default {
 		globalData: {
@@ -64,7 +68,7 @@
 				if (newCart > 0) {
 					uni.setTabBarBadge({
 						index: 3,
-						text: newCart>99?'99+':newCart+''
+						text: newCart > 99 ? '99+' : newCart + ''
 					})
 				} else {
 					uni.hideTabBarRedDot({
@@ -74,6 +78,10 @@
 			}
 		},
 		onLaunch: async function(option) {
+			// #ifdef APP
+			// 升级App
+			// getUpApp();
+			// #endif
 			//#ifdef APP
 			plus.screen.lockOrientation("portrait-primary");
 			//#endif
@@ -351,7 +359,7 @@
 					})
 					.catch(err => {
 						return that.$util.Tips({
-							title:err
+							title: err
 						})
 					});
 			},
@@ -365,7 +373,7 @@
 			 */
 			checkUpdateVersion() {
 				//判断微信版本是否 兼容小程序更新机制API的使用
-				if (wx.canIUse('getUpdateManager')) { 
+				if (wx.canIUse('getUpdateManager')) {
 					const updateManager = wx.getUpdateManager();
 					//检测版本更新
 					updateManager.onCheckForUpdate(function(res) {
@@ -422,19 +430,19 @@
 	page {
 		font-family: PingFang SC;
 	}
-	
-	.activityFrame{
-			background-size: 100% 100%;
-			background-repeat: no-repeat;
-			position: absolute;
-			top:0;
-			left:0;
-			width: 100%;
-			height: 100%;
-			z-index: 1;
+
+	.activityFrame {
+		background-size: 100% 100%;
+		background-repeat: no-repeat;
+		position: absolute;
+		top: 0;
+		left: 0;
+		width: 100%;
+		height: 100%;
+		z-index: 1;
 	}
-	
-	.placeholder{
+
+	.placeholder {
 		color: #ccc;
 	}
 
@@ -466,5 +474,6 @@
 		top: 0;
 		bottom: 0;
 	}
+
 	/* #endif */
-</style>
+</style>

+ 9 - 0
api/api.js

@@ -475,6 +475,15 @@ export function getCategoryVersion() {
 	});
 }
 
+/**
+ * 获取app版本
+ */
+export function getAppVersion() {
+	return request.get('version',{},{
+		noAuth: true
+	});
+}
+
 
 
 

+ 5 - 7
manifest.json

@@ -2,8 +2,8 @@
     "name" : "易趣C果园",
     "appid" : "__UNI__EF80BD1",
     "description" : "易趣C果园",
-    "versionName" : "2.6.0",
-    "versionCode" : 267,
+    "versionName" : "2.6.1",
+    "versionCode" : 268,
     "transformPx" : false,
     /* 5+App特有相关 */
     "app-plus" : {
@@ -24,11 +24,8 @@
         "modules" : {
             "VideoPlayer" : {},
             "Share" : {},
-            "OAuth" : {},
             "Payment" : {},
-            "Maps" : {},
             "LivePusher" : {},
-            "Geolocation" : {},
             "Barcode" : {},
             "Camera" : {}
         },
@@ -65,7 +62,7 @@
                     "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
                     "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
                 ],
-                "abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ],
+                "abiFilters" : [ "armeabi-v7a", "arm64-v8a" ],
                 "permissionExternalStorage" : {
                     "request" : "none",
                     "prompt" : "应用保存运行状态等信息,需要获取读写手机存储(系统提示为访问设备上的照片、媒体内容和文件)权限,请允许。"
@@ -73,7 +70,8 @@
                 "permissionPhoneState" : {
                     "request" : "none",
                     "prompt" : "为保证您正常、安全地使用,需要获取设备识别码(部分手机提示为获取手机号码)使用权限,请允许"
-                }
+                },
+                "minSdkVersion" : 30
             },
             /* ios打包配置 */
             "ios" : {

+ 2 - 2
pages/annex/vip_paid/index.vue

@@ -80,7 +80,7 @@
 				</view>
 			</scroll-view>
 		</view>
-		<view v-if="goodsList.length" class="goods-section">
+		<!-- <view v-if="goodsList.length" class="goods-section">
 			<view class="section-hd">SVIP商品推荐</view>
 			<view class="section-bd acea-row">
 				<view v-for="item in goodsList" :key="item.id" class="item" @click="goDetail(item.id)">
@@ -92,7 +92,7 @@
 					<view class="shop-price">商城价:¥{{item.price}}</view>
 				</view>
 			</view>
-		</view>
+		</view> -->
 		<view :class="{ mask: popupShow }" @touchmove.prevent></view>
 		<view class="popup" :class="{ on: popupShow }">
 			<view class="cont">

+ 0 - 10
utils/request.js

@@ -1,13 +1,3 @@
-// +----------------------------------------------------------------------
-// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
-// +----------------------------------------------------------------------
-// | Author: CRMEB Team <admin@crmeb.com>
-// +----------------------------------------------------------------------
-
 import {
 	HTTP_REQUEST_URL,
 	HEADER,

+ 149 - 0
utils/upApp.js

@@ -0,0 +1,149 @@
+import confige from '@/config/app.js'
+import {getAppVersion} from '@/api/api.js'
+const getIosUpAppUrl = 'https://itunes.apple.com/cn/lookup?id=6476127203'
+const iosAppStroeUrl =
+	'https://apps.apple.com/cn/app/%E7%A5%9E%E8%8B%B1%E4%BC%98%E9%80%89/id6476127203';
+
+// 获取app是否需要升级
+export function getUpApp () {
+	// 获取当前运行系统
+	let hj = uni.getSystemInfoSync().platform;
+	// 隐藏显示内容
+	uni.setStorageSync("showAppHistary",false)
+	// 获取仓库app数据对象
+	if (hj === 'ios') {
+		uni.request({
+			url: getIosUpAppUrl,
+			method: 'POST',
+			data: {},
+			success: res => {
+				console.log(res)
+				let r = res.data;
+				isUp(r, hj)
+			},
+			fail: res => {
+				// store.commit('changeState', true);
+				console.log(res, 'shib');
+			}
+		});
+		// 设置显示数据
+		return
+	}
+	// 当前系统为安卓则显示数据
+	if (hj === 'android') {
+		getAppVersion().then((res)=>{
+			let r = res.data;
+			console.log(r,'rr')
+			isUp(r, hj)
+		}).catch((res)=>{
+			console.log(res);
+		})
+	}
+}
+function isUp(r, hj) {
+	plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
+		let version = '';
+		let arr = '';
+		if (hj == "android") {
+			// 保存线上版本号
+			version =r.version;
+			// store.commit('setappversion',  r.version);
+			// 获取线上版本
+			arr = r.version.split('.');
+		}
+		if (hj == "ios") {
+			// 保存线上版本号
+			version = r.results[0].version;
+			// store.commit('setappversion', version);
+			// 获取线上版本
+			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];
+			// 判断线上版本是否小于本地版本
+			console.log(x, y, '数据');
+			if (x < y) {
+				// 设置显示数据
+				uni.setStorageSync("showAppHistary",false)
+				console.log('222')
+				return
+			}
+			// 判断线上版本是否大于本地版本
+			else if (x > y) {
+				uni.setStorageSync("showAppHistary",true)
+				console.log('223')
+				uni.showModal({
+					title: '提示',
+					content: '请更新应用',
+					showCancel: false,
+					success(e) {
+						if (hj == "android") {
+							downApp(r.apk);
+						}
+						if (hj == "ios") {
+							plus.runtime.openURL(
+								iosAppStroeUrl
+							);
+						}
+					}
+				});
+				return
+			} 
+			// 判断是否本地版本等于线上版本
+			else if (x == y && i == arr.length - 1) {
+				uni.setStorageSync("showAppHistary",true)
+				console.log('===')
+				// store.commit('changeState', true);
+				return
+			}
+		}
+	});
+}
+// 下载app
+export function downApp (version) {
+	let url = '';
+	if(version.indexOf('http')>-1){
+		url = version;
+	}else{
+		url = confige.HTTP_REQUEST_URL+version
+	}
+	console.log(url);
+	plus.nativeUI.showWaiting('下载升级包...');
+	plus.downloader
+		.createDownload(url, {}, (d, status) => {
+			if (status == 200) {
+				installApp(d.filename); // 安装app
+			} else {
+				plus.nativeUI.alert('下载升级包失败!');
+			}
+			plus.nativeUI.closeWaiting();
+		})
+		.start();
+}
+// 安装app
+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);
+		}
+	);
+}