Commit 6bc7d9dd by zhangxw

上传延保协议添加自定义loading

1 parent 3dd49c86
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
left: 0; left: 0;
bottom: 0; bottom: 0;
right: 0; right: 0;
background-color: rgba(0, 0, 0, .6); background-color: rgba(0, 0, 0, .7);
} }
.text-center { .text-center {
......
...@@ -47,15 +47,19 @@ Component({ ...@@ -47,15 +47,19 @@ Component({
let [tempFiles] = res.tempFilePaths let [tempFiles] = res.tempFilePaths
let imgType = tempFiles.split('.')[1] let imgType = tempFiles.split('.')[1]
let type = imgType == 'unknown' ? 'jpg' : imgType let type = imgType == 'unknown' ? 'jpg' : imgType
_this.setData({
loadingFlag: true
})
wx.getFileSystemManager().readFile({ wx.getFileSystemManager().readFile({
filePath: tempFiles, //选择图片返回的相对路径 filePath: tempFiles, //选择图片返回的相对路径
encoding: 'base64', //编码格式 encoding: 'base64', //编码格式
success(_res) { success(_res) {
wx.$util.showLoading('上传中...')
api.uploadImg({ api.uploadImg({
file: `${type}@${_res.data}` file: `${type}@${_res.data}`
}).then(img => { }).then(img => {
wx.$util.hideLoading() _this.setData({
loadingFlag: false
})
let { code, data, message } = img let { code, data, message } = img
if (code == 0) { if (code == 0) {
fileList.push({url: data}) fileList.push({url: data})
...@@ -97,16 +101,20 @@ Component({ ...@@ -97,16 +101,20 @@ Component({
let fileType = fileName.split('.').pop() // 获取文件扩展名 let fileType = fileName.split('.').pop() // 获取文件扩展名
// 读取文件 // 读取文件
if (fileType != 'pdf') return wx.$util.showToast('只可上传pdf类型文件') if (fileType != 'pdf') return wx.$util.showToast('只可上传pdf类型文件')
_this.setData({
loadingFlag: true
})
wx.getFileSystemManager().readFile({ wx.getFileSystemManager().readFile({
filePath: tempFile.path, // 使用正确的路径 filePath: tempFile.path, // 使用正确的路径
encoding: 'base64', encoding: 'base64',
success(_res) { success(_res) {
wx.$util.showLoading('上传中...');
// 调用上传接口 // 调用上传接口
api.uploadPdfAPI({ api.uploadPdfAPI({
file: `${fileType}@${_res.data}` // 处理文件类型 file: `${fileType}@${_res.data}` // 处理文件类型
}).then(img => { }).then(img => {
wx.$util.hideLoading(); _this.setData({
loadingFlag: false
})
let { code, data, message } = img; let { code, data, message } = img;
if (code == 0) { if (code == 0) {
......
{ {
"component": true, "component": true,
"usingComponents": { "usingComponents": {
"popup": "../Popup/Popup" "popup": "../Popup/Popup",
"van-loading": "@vant/weapp/loading/index"
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -102,3 +102,9 @@ ...@@ -102,3 +102,9 @@
border-bottom: var(--fontSize1) solid #EBEDF0; border-bottom: var(--fontSize1) solid #EBEDF0;
} }
} }
.loading-box{
background-color: rgba(0, 0, 0, 0.7);
.van-loading__text{
color: #FFFFFF !important;
}
}
\ No newline at end of file \ No newline at end of file
<!--packageEquity/pages/carQuotation/components/zyPayPopup/zyPayPopup.wxml--> <!--packageEquity/pages/carQuotation/components/zyPayPopup/zyPayPopup.wxml-->
<glsx-privacy appletName="生意助手员工版" bind:agreeClick="agreeClick" bind:disagreeClick="disagreeClick"></glsx-privacy> <glsx-privacy appletName="生意助手员工版" bind:agreeClick="agreeClick" bind:disagreeClick="disagreeClick"></glsx-privacy>
<block wx:if="{{!showChangeFileType}}"> <block wx:if="{{!showChangeFileType && !loadingFlag}}">
<popup <popup
title="{{'上传延保协议'}}" title="{{'上传延保协议'}}"
show="{{show}}" show="{{show}}"
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
</view> </view>
</popup> </popup>
</block> </block>
<block wx:else> <block wx:if="{{showChangeFileType && !loadingFlag}}">
<van-popup <van-popup
class="file-type-popup" class="file-type-popup"
show="{{show}}" show="{{show}}"
...@@ -54,4 +54,9 @@ ...@@ -54,4 +54,9 @@
</view> </view>
</van-popup> </van-popup>
</block> </block>
<block wx:if="{{loadingFlag}}">
<van-popup show="{{show}}" close-on-click-overlay="{{false}}" >
<van-loading custom-class="loading-box" color="#FFFFFF" type="spinner" size="45px" vertical>上传中</van-loading>
</van-popup>
</block>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!