日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【uniapp】微信小程序体验版的下载文件一直显示加载中,开发调试则没有问题

發布時間:2024/1/18 编程问答 156 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【uniapp】微信小程序体验版的下载文件一直显示加载中,开发调试则没有问题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

需求:點擊列表,下載文件并打開文件預覽

代碼:

// 點擊列表showvideo(item) {const Token = uni.getStorageSync('GetPhone_Token')if (item.fileExt === '.mp4') {if (Token) {let that = this// 瀏覽記錄,為了圓點更新that.api.BrowseFile({FileId: item.Id}).then(res => {console.log(res)})uni.navigateTo({url: '/pages/word/appUpdate?item=' + JSON.stringify(item)})} else {uni.navigateTo({url: '/pages/login/index'});}} else if (item.fileExt === '.pdf') {if (Token) {this.word = item// console.log(item)this.download()} else {uni.navigateTo({url: '/pages/login/index'});}}},// 文件下載async download() {let that = this// 文件await uni.showLoading({title: '加載中'})let filePath = ''let url = ''//這一步是為了國際化if (this.$store.state.getLocale === 'zh-Hans') {filePath = wx.env.USER_DATA_PATH + '/' + that.word.filenameurl = that.word.fileurl} else {filePath = wx.env.USER_DATA_PATH + '/' + that.word.filename_ENurl = that.word.fileurl_EN}uni.downloadFile({url: url,success(res) {// console.log(res, '123')// if (res.statusCode === 200) {// 下載到本地uni.getFileSystemManager().saveFile({tempFilePath: res.tempFilePath,//臨時路徑filePath: filePath,success(res) {uni.hideLoading()uni.showToast({title: '打開文件',icon: 'none'})// 瀏覽記錄,為了圓點更新that.api.BrowseFile({FileId: that.word.Id}).then(res => {// console.log(res)that.$emit('GetFileListById')})// 保存下載記錄that.api.DownloadFile({FileId: that.word.Id}).then(res => {// console.log(res)})// console.log(res.savedFilePath)//打開文件預覽uni.openDocument({filePath: res.savedFilePath,showMenu: true, //預覽文件的時候右上角有三點success: function(res) {},fail(error) {uni.hideLoading()uni.showToast({title: '打開失敗,請刷新后稍后重新下載',icon: 'none'})}})}})// }},fail(error) {}})},

在微信開發者工具中沒有任何問題,真機調試也沒有問題,后來我上傳體驗版后,發現用手機測試就不行,一直顯示在載中,然后我打開體驗版的調試,發現并沒有問題。

后來我把微信開發者工具中的詳情——不校驗合法域名、web-view(業務域名)、TLS版本以及HTTPS證書取消打鉤,然后在微信開發者工具中再測試一次,發現報以下錯

只要把 上面的地址添加到服務器域名的downloadFile中即可

登錄微信公眾平臺——開發管理——開發設置——服務器域名——downloadFile合法域名?

?若寫有多個域名,則域名之間用封號;隔開

總結

以上是生活随笔為你收集整理的【uniapp】微信小程序体验版的下载文件一直显示加载中,开发调试则没有问题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。