Ver Fonte

fix:登录页面版本号

xuyunhui há 2 meses atrás
pai
commit
5aefd54b7c
2 ficheiros alterados com 27 adições e 6 exclusões
  1. 6 6
      common/js/app.js
  2. 21 0
      config/version.js

+ 6 - 6
common/js/app.js

@@ -12,15 +12,15 @@ export default {
 		try {
 			const systemInfo = uni.getSystemInfoSync()
 
-			console.log(systemInfo,'systemInfosystemInfosystemInfo')
+			console.log(systemInfo,'systemInfosystemInfo')
 			// #ifdef APP-PLUS
 			// App 端优先使用 plus API
 			return plus.runtime.version
 			// #endif
 
-			// 小程序和 H5 端使用 uni.getSystemInfoSync 的 appVersion 字段
-			if (systemInfo.appVersion) {
-				return systemInfo.appVersion
+			// 小程序和 H5 端使用 uni.getSystemInfoSync
+			if (systemInfo.version) {
+				return systemInfo.version
 			}
 
 			// 如果获取不到,返回配置文件的版本号
@@ -46,8 +46,8 @@ export default {
 						// #endif
 
 						// #ifndef APP-PLUS
-						if (res.appVersion) {
-							resolve(res.appVersion)
+						if (res.version) {
+							resolve(res.version)
 						} else {
 							resolve(versionConfig.getVersionName())
 						}

+ 21 - 0
config/version.js

@@ -0,0 +1,21 @@
+/**
+ * 应用版本配置
+ * 注意:修改版本号时需要同步更新 manifest.json 中的 versionName 和 versionCode
+ */
+export default {
+	// 应用版本名称(显示给用户看的)
+	versionName: '1.0.21',
+
+	// 应用版本号(用于版本比较的数字)
+	versionCode: 1021,
+
+	// 获取版本名称
+	getVersionName() {
+		return this.versionName
+	},
+
+	// 获取版本号
+	getVersionCode() {
+		return this.versionCode
+	}
+}