const _my = require("../../__antmove/api/index.js")(my);
const wx = _my;
const { baseUrl } = require("../../utils/func/request");

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