index.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // index.js
  2. // 获取应用实例
  3. import { VueLikePage } from "../../utils/page";
  4. import { CDN_URL, API_BASE_URL, VIDEO_BASE_URL } from "../../config/index";
  5. var g_app = getApp();
  6. VueLikePage([], {
  7. data: {
  8. cdn_url: CDN_URL,
  9. baseUrl: API_BASE_URL + "/",
  10. url_link: "",
  11. id: "",
  12. type: "",
  13. loadCompele: false,
  14. },
  15. methods: {
  16. onLoad: function (options) {
  17. let { rdw, id, type } = options;
  18. let link = "";
  19. if (type == "0") {
  20. link = `${VIDEO_BASE_URL}4dvedio/${rdw}.mp4`;
  21. } else {
  22. link = `${VIDEO_BASE_URL}4dpic/${rdw}.jpg`;
  23. }
  24. this.setData({
  25. url_link: link,
  26. id,
  27. type,
  28. });
  29. },
  30. loadcompele() {
  31. this.setData({
  32. loadCompele: true,
  33. });
  34. },
  35. cancel() {
  36. // wx.reLaunch({
  37. // url: "/pages/work/index",
  38. // });
  39. wx.navigateBack();
  40. },
  41. saveAlbum() {
  42. let type = this.data.type;
  43. wx.showLoading({
  44. title: "保存中…",
  45. mask: true,
  46. });
  47. if (g_app.globalData.m_file) {
  48. let api =
  49. type == "0" ? "saveVideoToPhotosAlbum" : "saveImageToPhotosAlbum";
  50. wx[api]({
  51. filePath: g_app.globalData.m_file,
  52. success() {
  53. wx.showModal({
  54. title: "提示",
  55. content: "已保存到相册,快去分享吧",
  56. showCancel: false,
  57. });
  58. },
  59. fail: (e) => {
  60. if (!(e.errMsg.indexOf('cancel')>-1)) {
  61. wx.showModal({
  62. title: "提示",
  63. content: "保存失败,请稍后再试",
  64. showCancel: false,
  65. });
  66. }
  67. },
  68. complete: () => {
  69. wx.hideLoading();
  70. },
  71. });
  72. }
  73. // let link = this.data.url_link;
  74. // wx.downloadFile({
  75. // url: link,
  76. // success: function (res) {
  77. // var tempFilePath = res.tempFilePath;
  78. // },
  79. // fail: function (res) {
  80. // wx.showModal({
  81. // title:'提示',
  82. // content:'下载失败,请稍后再试',
  83. // showCancel:false
  84. // })
  85. // wx.hideLoading()
  86. // }
  87. // });
  88. },
  89. },
  90. });