myqrcode.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // pages/mine/myqrcode/myqrcode.js
  2. const app = getApp()
  3. Page({
  4. data: {
  5. qrcodepath: null,
  6. loaddisplay: 'none',
  7. sqshow: false
  8. },
  9. finish: function () {
  10. this.setData({
  11. loaddisplay: 'none'
  12. })
  13. },
  14. onShow: function() {
  15. this.setData({
  16. sqshow: false
  17. })
  18. },
  19. onLoad: function (options) {
  20. this.setData({
  21. loaddisplay: true
  22. })
  23. var that = this
  24. wx.request({
  25. url: app.globalData.url + '/CreatePOP',
  26. method: 'get',
  27. data: {
  28. wv_phone: app.globalData.userphone
  29. },
  30. success: function (res) {
  31. that.setData({
  32. qrcodepath: res.data,
  33. loaddisplay: 'none'
  34. })
  35. },
  36. fail() {
  37. app.timeOut()
  38. }
  39. })
  40. let _this = this;
  41. _this.setData({
  42. navH: app.globalData.navHeight
  43. })
  44. },
  45. saveImgToPhotosAlbumTap: function () {
  46. var that = this
  47. wx.showLoading({
  48. title: '保存中......',
  49. icon: 'loading',
  50. duration: 5500
  51. })
  52. wx.downloadFile({
  53. url: this.data.qrcodepath,
  54. success: function (res) {
  55. wx.saveImageToPhotosAlbum({
  56. filePath: res.tempFilePath,
  57. success: function (res) {
  58. wx.hideLoading()
  59. wx.showToast({
  60. title: "保存成功",
  61. icon: "success",
  62. })
  63. },
  64. fail: function (res) {
  65. wx.hideLoading()
  66. wx.showToast({
  67. title: "保存失败,请点击按钮授权",
  68. icon: "none",
  69. })
  70. that.setData({
  71. sqshow: true
  72. })
  73. }
  74. })
  75. },
  76. fail: function () {
  77. wx.hideLoading()
  78. wx.showToast({
  79. title: "保存失败,请点击按钮授权",
  80. icon: "none",
  81. })
  82. that.setData({
  83. sqshow: true
  84. })
  85. }
  86. })
  87. }
  88. })