|
|
@@ -248,6 +248,7 @@
|
|
|
downloadUrls: {},
|
|
|
isShangjia: 0,
|
|
|
id: 0,
|
|
|
+ androidPackageName: '', // 安卓应用包名
|
|
|
}
|
|
|
},
|
|
|
onShow() {
|
|
|
@@ -378,6 +379,10 @@
|
|
|
api('getAppDownload', {}, r => {
|
|
|
console.log(r)
|
|
|
this.downloadUrls = r.data.data;
|
|
|
+ // 保存安卓包名
|
|
|
+ if (r.data.data.androidPackageName) {
|
|
|
+ this.androidPackageName = r.data.data.androidPackageName;
|
|
|
+ }
|
|
|
this.$refs.downloadPopup.open();
|
|
|
});
|
|
|
},
|
|
|
@@ -390,22 +395,22 @@
|
|
|
// 下载iOS版本
|
|
|
downloadIOS() {
|
|
|
// 先尝试打开已安装的应用
|
|
|
- this.tryOpenInstalledApp();
|
|
|
+ this.tryOpenInstalledApp('cityexpressuser');
|
|
|
this.closeDownloadPopup();
|
|
|
},
|
|
|
|
|
|
// 下载Android版本
|
|
|
downloadAndroid() {
|
|
|
// 先尝试打开已安装的应用
|
|
|
- this.tryOpenInstalledApp();
|
|
|
+ this.tryOpenInstalledApp('deliveryking');
|
|
|
this.closeDownloadPopup();
|
|
|
},
|
|
|
|
|
|
// 尝试打开已安装的应用
|
|
|
- tryOpenInstalledApp() {
|
|
|
+ tryOpenInstalledApp(schema) {
|
|
|
const that = this;
|
|
|
|
|
|
- const appSchema = 'cityexpressuser://pages/shanpinxungou/shangjia/shangjiaView?id=' + this.id +
|
|
|
+ const appSchema = schema + '://pages/shanpinxungou/shangjia/shangjiaView?id=' + this.id +
|
|
|
'&isShangjia=' + this.isShangjia;
|
|
|
|
|
|
// 在App环境中使用plus.runtime.openURL
|
|
|
@@ -603,12 +608,17 @@
|
|
|
api('getAppDownload', {}, r => {
|
|
|
console.log(r);
|
|
|
|
|
|
+ // 保存安卓包名
|
|
|
+ if (r.data.data.androidPackageName) {
|
|
|
+ this.androidPackageName = r.data.data.androidPackageName;
|
|
|
+ }
|
|
|
+
|
|
|
// 检测是否为安卓设备
|
|
|
const isAndroid = this.isAndroidDevice();
|
|
|
|
|
|
if (isAndroid) {
|
|
|
- // 安卓设备下载APK
|
|
|
- that.downloadAndroidAPK(r.data.data.androidUrl);
|
|
|
+ // 安卓设备跳转到谷歌商店
|
|
|
+ that.openGooglePlay('com.deliveryking.user');
|
|
|
} else {
|
|
|
// iOS设备打开App Store
|
|
|
that.openAppStore(r.data.data.iosUrl);
|
|
|
@@ -616,7 +626,55 @@
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- // 下载安卓APK
|
|
|
+ // 打开谷歌商店
|
|
|
+ openGooglePlay(packageName) {
|
|
|
+ const that = this;
|
|
|
+ uni.hideLoading();
|
|
|
+
|
|
|
+ if (!packageName) {
|
|
|
+ // 如果没有包名,提示错误
|
|
|
+ uni.showToast({
|
|
|
+ title: 'Package name not found',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构建谷歌商店URL
|
|
|
+ const googlePlayUrl = `https://play.google.com/store/apps/details?id=${packageName}`;
|
|
|
+
|
|
|
+ // 在H5环境中
|
|
|
+ // #ifdef H5
|
|
|
+ // 直接跳转到谷歌商店
|
|
|
+ window.location.href = googlePlayUrl;
|
|
|
+ // #endif
|
|
|
+
|
|
|
+ // 在App环境中
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ plus.runtime.openURL(googlePlayUrl, function(res) {
|
|
|
+ console.log('Opening Google Play Store success');
|
|
|
+ }, function(err) {
|
|
|
+ console.log('Opening Google Play Store failed');
|
|
|
+ // 如果打开失败,提供手动下载选项
|
|
|
+ uni.showModal({
|
|
|
+ title: that.$t('download.download_failed'),
|
|
|
+ content: that.$t('download.download_failed_manual'),
|
|
|
+ showCancel: true,
|
|
|
+ cancelText: that.$t('comp.quxiao'),
|
|
|
+ confirmText: that.$t('comp.queren'),
|
|
|
+ success: function(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ // 使用浏览器打开谷歌商店链接
|
|
|
+ plus.runtime.openURL(googlePlayUrl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ // #endif
|
|
|
+ },
|
|
|
+
|
|
|
+ // 下载安卓APK(备用方法)
|
|
|
downloadAndroidAPK(androidUrl) {
|
|
|
const that = this;
|
|
|
|