<template>
<view style="margin-top: 10%;">
<button type="primary" @click="upload()">测试上传</button>
</view>
</template>
<script>
const app = getApp()
export default {
data() {
return {
};
},
onLoad(options) {
},
methods: {
upload() {
let that = this;
uni.chooseImage({
count: 1, // 拍照或相册选择
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
success: function (res) {
let header = {}
if (uni.getStorageSync("tokenName")) {
header[uni.getStorageSync("tokenName")] = uni.getStorageSync("token")
}
console.log(app.globalData.IP + "user/alipay/ocr")
uni.uploadFile({
url: app.globalData.IP + "user/alipay/ocr",
filePath: res.tempFiles[0],
fileType: 'image',
formData: {
type: "face"
},
header: header,
success: (res) => {
console.log(res)
},
fail:(err) => {
console.log(err)
}
});
}
});
}
}
};
</script>
<style lang="scss"></style>
1***@qq.com
- 发布:2022-12-02 10:44
- 更新:2022-12-02 10:44
- 阅读:227
0 个回复