upload_video.js 857 B

12345678910111213141516171819202122232425262728293031
  1. const _my = require("../../__antmove/api/index.js")(my);
  2. const wx = _my;
  3. const { baseUrl } = require("../request/request"); //单视频上传 file为上传文件暂存地址对象
  4. const api = "/upload/video";
  5. const upload_video = file => {
  6. return new Promise(reslove => {
  7. wx.uploadFile({
  8. url: baseUrl + api,
  9. filePath: file.url,
  10. name: "file",
  11. success(res) {
  12. reslove({
  13. ...file,
  14. url: baseUrl + "/" + JSON.parse(res.data).data,
  15. relative_url: JSON.parse(res.data).data
  16. });
  17. },
  18. fail(err) {
  19. wx.showToast({
  20. title: "视频上传没有成功哦,再试一次吧~"
  21. });
  22. }
  23. });
  24. });
  25. };
  26. module.exports = upload_video;