upload_video.js 853 B

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