详细问题描述
(DCloud产品不会有明显的bug,所以你遇到的问题大都是在特定环境下才能重现的问题,请仔细描述你的环境和重现方式,否则DCloud很难排查解决你的问题)
[内容]
重现步骤
[步骤]
点击按钮触发弹出层打开
[结果]
微信开发者工具正常打开,真机卡死
[期望]
微信开发者工具正常打开,真机正常打开
[如果语言难以表述清晰,拍一个视频或截图,有图有真相]
IDE运行环境说明
[HBuilder 或 HBuilderX。如果你用其他工具开发uni-app,也需要在此说明]
HBuilderX
[IDE版本号]
2.4.5.20191209
[windows版本号]
win10
[mac版本号]
uni-app运行环境说明
[运行端是h5或app或某个小程序?]
微信小程序
[运行端版本号]
stable v1.02.1911180
[项目是cli创建的还是HBuilderX创建的?如果是cli创建的,请更新到最新版cli再试]
HBuilderX
[编译模式是老模板模式还是新的自定义组件模式?]
自定义组件模式
App运行环境说明
[Android版本号]
9
[iOS版本号]
[手机型号]
galaxy s10 sm-g9730
[模拟器型号]
iphone 6
附件
[IDE问题请提供HBuilderX运行日志。菜单帮助-查看运行日志,点右键打开文件所在目录,将log文件压缩成zip包上传]
[App问题请提供可重现问题的代码片段,你补充的细一点,问题就解决的快一点]
[App安装包或H5地址]
[可重现代码片段]
<template>
<view>
<uni-list
v-for="item in allFiles"
:key="item.id">
<uni-list-item :title="item.fileKey.split('/')[1]" :show-arrow="false" @click="togglePopup(item)"></uni-list-item>
</uni-list>
<file-list
:allFiles="allFiles"
:signedFiles="signedFiles">
</file-list>
<uni-fab
:pattern="pattern"
:content="content"
:horizontal="horizontal"
:vertical="vertical"
:direction="direction"
@trigger="trigger">
</uni-fab>
<uni-popup ref="showtip" type="center" :mask-click="true">
<view class="uni-tip">
<!-- <text class="uni-tip-title">警告</text> -->
<text class="uni-tip-content">请选择功能</text>
<view class="uni-tip-group-button">
<text class="uni-tip-button" @click="openFile()">查看文档</text>
<text class="uni-tip-button" @click="cancel('tip')">查看签字</text>
<text class="uni-tip-button" @click="sign()">签字</text>
</view>
</view>
</uni-popup>
</view>
</template>
<script>
import cos from '@/utils/cos.js';
import uniFab from '@/components/uni-fab/uni-fab.vue';
import uniList from '@/components/uni-list/uni-list.vue';
import uniPopup from '../../components/uni-popup/uni-popup';
import fileList from '@/components/file-list/file-list.vue';
import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
export default {
components: {
uniFab,
uniList,
fileList,
uniPopup,
uniListItem
},
data() {
return {
horizontal: 'right',
vertical: 'bottom',
direction: 'horizontal',
allFiles: [],
signedFiles: [],
item: {},// 当前选中的文件对象
content: [
{
iconPath: '/static/upload.png',
selectedIconPath: '',
text: '上传',
active: false
}
]
};
},
methods: {
sign: function () {
console.log("sign")
uni.redirectTo({
url: '../sign/sign'
});
},
trigger: function (e) {
if(e.index == 0){
this.uploadFile()
}
},
togglePopup: function(item) {
this.item = item
this.$nextTick(() => {
this.$refs['showtip'].open()
})
},
openFile: function () {
cos.getObjectUrl({
Bucket: 'oss-store-1300707427',
Region: 'ap-shanghai',
Key: this.item.fileKey,
Sign: true
}, function (err, data) {
// if (!err) return console.log(err);
wx.downloadFile({
url: data.Url, // 需要加 url 的域名作为下载白名单
success (res) {
console.log(res.statusCode, res.tempFilePath);
wx.openDocument({
filePath: res.tempFilePath,
success: function (res) {
console.log('打开文档成功')
}
})
},
fail: function (err) {
console.log(err);
},
});
});
this.$nextTick(() => {
this.$refs['showtip'].close()
})
},
uploadFile: function () {
let _this = this
wx.chooseMessageFile({
count: 10,
success (res) {
for(let i = 0; i < res.tempFiles.length; ++i){
// tempFilePath可以作为img标签的src属性显示图片
let filePath = res.tempFiles[i].path;
// let filename = filePath.substr(filePath.lastIndexOf('/') + 1);
let filename = res.tempFiles[i].name
cos.postObject({
Bucket: 'oss-store-1300707427',
Region: 'ap-shanghai',
Key: 'file/' + filename,
FilePath: filePath,
onProgress: function (info) {
console.log(JSON.stringify(info));
}
}, function (err, data) {
console.log(err || data);
});
wx.request({
url: 'http://127.0.0.1:443/createFile',
// url: 'http://106.54.198.21:443/user/updateUser',
data: {
fileKey: 'file/' + filename
},
method: 'POST',
header: {
'content-type': 'application/json'
},
success(res) {
if(res.data.rejCode == '999999'){
console.log("失败了")
}
if(res.data.rejCode == '000000'){
console.log("success")
}
}
})
}
}
})
}
},
onLoad: function (option) {
let userInfo = JSON.parse(option.userInfo)
this.allFiles = userInfo.allFiles
this.signedFiles = userInfo.signedFiles
}
}
</script>
<style>
/* 提示窗口 */
.uni-tip {
/* #ifndef APP-NVUE */
display: flex;
flex-direction: column;
/* #endif */
padding: 15px;
width: 300px;
background-color: #fff;
border-radius: 10px;
}
.uni-tip-title {
margin-bottom: 10px;
text-align: center;
font-weight: bold;
font-size: 16px;
color: #333;
}
.uni-tip-content {
/* padding: 15px;
*/
font-size: 14px;
color: #666;
}
.uni-tip-group-button {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
margin-top: 20px;
}
.uni-tip-button {
flex: 1;
text-align: center;
font-size: 14px;
color: #3b4144;
}
</style>
联系方式
[QQ]