feat: upload-file
parent
e73bf55356
commit
8009263549
3
app.json
3
app.json
|
@ -58,7 +58,8 @@
|
||||||
"pages/API/canvas/canvas",
|
"pages/API/canvas/canvas",
|
||||||
"pages/API/get-wxml-node-info/get-wxml-node-info",
|
"pages/API/get-wxml-node-info/get-wxml-node-info",
|
||||||
"pages/API/intersection-observer/intersection-observer",
|
"pages/API/intersection-observer/intersection-observer",
|
||||||
"pages/API/download-file/download-file"
|
"pages/API/download-file/download-file",
|
||||||
|
"pages/API/upload-file/upload-file"
|
||||||
],
|
],
|
||||||
"window": {
|
"window": {
|
||||||
"backgroundTextStyle": "light",
|
"backgroundTextStyle": "light",
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
// pages/API/upload-file/upload-file.js
|
||||||
|
|
||||||
|
Page({
|
||||||
|
chooseImage() {
|
||||||
|
const self = this
|
||||||
|
wx.chooseImage({
|
||||||
|
success (res) {
|
||||||
|
const tempFilePaths = res.tempFilePaths
|
||||||
|
const files = res.tempFiles;
|
||||||
|
wx.uploadFile({
|
||||||
|
url: 'https://finchat-mop.finogeeks.club/api/v1/netDiskProxy/needCheckAuth/self?type=file&content={}&thumbnail=false×tamp=1581254809&uuid=12345&appid=6000133&sign=21AE06173F566598FF9A055277AA55C4', //仅为示例,非真实的接口地址
|
||||||
|
filePath: tempFilePaths[0],
|
||||||
|
name: 'file',
|
||||||
|
formData: {
|
||||||
|
'uploadFile': files[0],
|
||||||
|
},
|
||||||
|
success (res){
|
||||||
|
const data = res.data
|
||||||
|
//do something
|
||||||
|
console.log(res);
|
||||||
|
},
|
||||||
|
fail (res) {
|
||||||
|
console.log(res);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"navigationBarTitleText": "上传文件"
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
<!--pages/API/upload-file/upload-file.wxml-->
|
||||||
|
<import src="../../common/head.wxml" />
|
||||||
|
<import src="../../common/foot.wxml" />
|
||||||
|
|
||||||
|
<view class="container">
|
||||||
|
<template is="head" data="{{title: 'uploadFile'}}"/>
|
||||||
|
|
||||||
|
<view class="page-body">
|
||||||
|
<view class="page-section">
|
||||||
|
<view class="page-body-info">
|
||||||
|
|
||||||
|
<block wx:if="{{imageSrc}}">
|
||||||
|
<image src="{{imageSrc}}" class="image" mode="aspectFit"></image>
|
||||||
|
</block>
|
||||||
|
|
||||||
|
<block wx:else>
|
||||||
|
<view class="image-plus image-plus-nb" bindtap="chooseImage">
|
||||||
|
<view class="image-plus-horizontal"></view>
|
||||||
|
<view class="image-plus-vertical"></view>
|
||||||
|
</view>
|
||||||
|
<view class="image-plus-text">选择图片</view>
|
||||||
|
</block>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<template is="foot" />
|
||||||
|
</view>
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
/* pages/API/upload-file/upload-file.wxss */
|
||||||
|
.image {
|
||||||
|
width: 100%;
|
||||||
|
height: 330px;
|
||||||
|
}
|
||||||
|
.page-body-info {
|
||||||
|
display: flex;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 15px;
|
||||||
|
height: 410px;
|
||||||
|
border-top: 1px solid var(--weui-FG-3);
|
||||||
|
border-bottom: 1px solid var(--weui-FG-3);
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
Loading…
Reference in New Issue