12345678910111213141516171819202122232425262728 |
- const { baseUrl } = require("../../utils/func/request");
- //单图片上传 file为上传文件暂存地址对象
- const api = '/upload/pictureLocal'
- const upload_image = (file) => {
- // console.log(file);
- return new Promise((reslove) => {
- // console.log(baseUrl + api)
- wx.uploadFile({
- url: baseUrl + api,
- filePath: file.url,
- name: 'file',
- success(res) {
- reslove({ ...file, url: JSON.parse(res.data).data })
- // console.log(res)
- },
- fail (err) {
- console.log(err);
- wx.showToast({
- title: '上传没有成功哦,再试一次吧~',
- icon: 'error'
- })
- }
- });
- })
- }
- module.exports = upload_image
|