index.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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/vedio${rdw}.mp4`;
  21. } else {
  22. link = `${VIDEO_BASE_URL}4dpic/pic${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/index/index",
  38. });
  39. },
  40. saveAlbum() {
  41. let type = this.data.type;
  42. wx.showLoading({
  43. title: "保存中…",
  44. mask: true,
  45. });
  46. if (g_app.globalData.m_file) {
  47. let api =
  48. type == "0" ? "saveVideoToPhotosAlbum" : "saveImageToPhotosAlbum";
  49. wx[api]({
  50. filePath: g_app.globalData.m_file,
  51. success() {
  52. wx.showModal({
  53. title: "提示",
  54. content: "已保存到相册,快去分享吧",
  55. showCancel: false,
  56. });
  57. },
  58. fail: (e) => {
  59. if (!(e.errMsg.indexOf('cancel')>-1)) {
  60. wx.showModal({
  61. title: "提示",
  62. content: "保存失败,请稍后再试",
  63. showCancel: false,
  64. });
  65. }
  66. },
  67. complete: () => {
  68. wx.hideLoading();
  69. },
  70. });
  71. }
  72. // let link = this.data.url_link;
  73. // wx.downloadFile({
  74. // url: link,
  75. // success: function (res) {
  76. // var tempFilePath = res.tempFilePath;
  77. // },
  78. // fail: function (res) {
  79. // wx.showModal({
  80. // title:'提示',
  81. // content:'下载失败,请稍后再试',
  82. // showCancel:false
  83. // })
  84. // wx.hideLoading()
  85. // }
  86. // });
  87. },
  88. },
  89. });