shish 4 лет назад
Родитель
Сommit
b36352c081
1 измененных файлов с 70 добавлено и 19 удалено
  1. 70 19
      ghsApp/src/admin/item/list.vue

+ 70 - 19
ghsApp/src/admin/item/list.vue

@@ -92,6 +92,19 @@ export default {
 	methods: {
 		downPriceTable(){
 			// #ifdef MP-WEIXIN
+			let isWindows = false
+			uni.getSystemInfo({
+				success: function (res) {
+					if(res.platform == 'windows'){
+						isWindows = true
+					}
+				}
+			});
+			if(isWindows == false){
+				this.$msg('请在电脑上打开小程序下载')
+				return false
+			}
+
 			let level = 0
 			let levelList = ['散客价', '普店价', '银店价','金店价']
 			uni.showActionSheet({
@@ -110,25 +123,39 @@ export default {
 								filePath: `${wx.env.USER_DATA_PATH}/${shortFile}`,
 								success: (res) => {
 									if (res.statusCode === 200) {
-										wx.saveFileToDisk({
-											filePath: res.filePath,
-											success: function(res) {
-												console.log(res)
-											},
-											fail:function(res) {
-												console.log(res)
-											}
-										})
+
+										if(isWindows == true){
+											wx.saveFileToDisk({
+												filePath: res.filePath,
+												success: function(res) {
+													console.log(res)
+												},
+												fail:function(res) {
+													console.log(res)
+												}
+											})
+										}else{
+											var filePath = res.filePath
+											//试了手机上只能打开无法转发分享
+											wx.openDocument({
+												filePath: filePath,
+												success: function (res) {
+													wx.hideLoading();
+												}
+											})
+										}
+
 									}
 								},
 								fail:()=>{
 									uni.showToast({title:'请用电脑打开小程序下载',mask:true,icon:'none'})
 								}
 							});
-						}					
+						}
 					})
 				}
 			})
+
 			// #endif
 			// #ifdef APP-PLUS
 			this.$msg('请在电脑上打开小程序进行下载')
@@ -136,6 +163,19 @@ export default {
 		},
 		downBarcodeTable(){
 			// #ifdef MP-WEIXIN
+			let isWindows = false
+			uni.getSystemInfo({
+				success: function (res) {
+					if(res.platform == 'windows'){
+						isWindows = true
+					}
+				}
+			});
+			if(isWindows == false){
+				this.$msg('请在电脑上打开小程序下载')
+				return false
+			}
+
 			uni.showLoading({title:'下载中',mask:true})
 			generateBarcodeTable().then(res => {
 				if(res.code == 1){
@@ -148,15 +188,26 @@ export default {
 						filePath: `${wx.env.USER_DATA_PATH}/${shortFile}`,
 						success: (res) => {
 							if (res.statusCode === 200) {
-								wx.saveFileToDisk({
-									filePath: res.filePath,
-									success: function(res) {
-										console.log(res)
-									},
-									fail:function(res) {
-										console.log(res)
-									}
-								})
+								if(isWindows == true){
+									wx.saveFileToDisk({
+										filePath: res.filePath,
+										success: function(res) {
+											console.log(res)
+										},
+										fail:function(res) {
+											console.log(res)
+										}
+									})
+								}else{
+									var filePath = res.filePath
+									//试了手机上只能打开无法转发分享
+									wx.openDocument({
+										filePath: filePath,
+										success: function (res) {
+											wx.hideLoading();
+										}
+									})
+								}
 							}
 						},
 						fail:()=>{