index.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. const util = require("../../../utils/util.js");
  2. Page({
  3. data: {
  4. wheelId:'',
  5. content:'',
  6. imagelist:[],
  7. theam:'redContent',
  8. showQrcode:false,
  9. video:[]
  10. },
  11. onLoad: function (options) {
  12. if (!util.isEmpty(options.wheelId)) {
  13. this.setData({
  14. wheelId:options.wheelId
  15. })
  16. this.getHtml()
  17. }
  18. if (!util.isEmpty(options.theam)) {
  19. this.setData({theam:options.theam})
  20. }
  21. },
  22. onReady: function () {
  23. },
  24. onShow: function () {
  25. },
  26. // 点击图片放大
  27. lookImg(e) {
  28. let picurl = e.currentTarget.dataset.pic
  29. let urls = [];
  30. // urls.push(data)
  31. urls = this.data.content.sharePisList
  32. wx.previewImage({
  33. current: picurl, // 当前显示图片的http链接
  34. urls: urls // 需要预览的图片http链接列表
  35. });
  36. },
  37. // 复制内容
  38. copyContent(e){
  39. let that=this,article=e.currentTarget.dataset.article;
  40. wx.setClipboardData({
  41. data: article,
  42. success: function (res) {
  43. console.log(res)
  44. }
  45. })
  46. },
  47. // 复制图片
  48. savePic(e){
  49. let self = this,picList=e.currentTarget.dataset.pic;
  50. picList.forEach((el,index) => {
  51. wx.downloadFile({
  52. url:el,
  53. success(res) {
  54. wx.saveImageToPhotosAlbum({
  55. filePath:res.tempFilePath,
  56. success:(res)=>{
  57. setTimeout(() => {
  58. util.showTips('已保存至相册!')
  59. }, 100);
  60. }
  61. })
  62. },
  63. fail(res){
  64. util.showTips('保存失败!')
  65. }
  66. })
  67. });
  68. },
  69. getHtml(){
  70. let that=this;
  71. util.ajax({
  72. func: "v2/market/wheel/info",
  73. data: {wheelId:that.data.wheelId}
  74. }, function (res) {
  75. if (res.code==0) {
  76. let data = res.data;
  77. data.rules = data.rules.replace(/section/g, "div");
  78. data.rules = data.rules.replace(/<img/g, "<img style='max-width:100%'");
  79. data.description = data.description.replace(/section/g, "div");
  80. data.description = data.description.replace(/<img/g, "<img style='max-width:100%'");
  81. let str = data.description.match(/<source src="(\S*)"/g);
  82. if (str) {
  83. let video = [];
  84. for (let i in str) {
  85. if (i < 3) {//只显示三个视频
  86. let src = str[i].match(/<source src="(\S*)"/)[1];
  87. video.push(src.toString())
  88. }
  89. }
  90. that.setData({ video });
  91. }
  92. that.setData({content:data})
  93. } else {
  94. util.showTips(res.reason);
  95. }
  96. })
  97. },
  98. // 跳转至发圈证明页
  99. jumpPage(){
  100. wx.navigateTo({
  101. url: `/pages/turntable/hairpin/index?flag=1`,
  102. })
  103. },
  104. // 联系客服
  105. connect(){
  106. this.setData({showQrcode:true})
  107. },
  108. // 关闭弹窗
  109. closeTip(e){
  110. this.setData({showQrcode:e.detail.status})
  111. },
  112. onShareAppMessage: function () {
  113. }
  114. })