othercustom.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. var _request = require('../../../utils/request.js')
  2. Page({
  3. data: {
  4. qr: '',
  5. popup: false
  6. },
  7. onLoad: function (options) {
  8. this.getqcode()
  9. },
  10. getqcode: function () {
  11. var that = this
  12. var url = 'v1/customer_service/qrcode'
  13. var params = {}
  14. var success = function (res) {
  15. that.setData({
  16. qr: res.data
  17. })
  18. }
  19. _request.$get(url, params, success)
  20. },
  21. downLoad () {
  22. wx.showLoading({
  23. title: '加载中',
  24. })
  25. var that = this
  26. wx.downloadFile({
  27. url: that.data.qr,
  28. success: function(res) {
  29. if (res.statusCode === 200) {
  30. that.saveImage(res.tempFilePath)
  31. }
  32. }
  33. })
  34. },
  35. saveImage (val) {
  36. var that = this
  37. wx.saveImageToPhotosAlbum({
  38. filePath: val,
  39. success(res) {
  40. wx.showToast({
  41. title: '已保存相册',
  42. icon: 'success',
  43. duration: 2000
  44. })
  45. },
  46. fail (res) {
  47. wx.getSetting({
  48. success (res) {
  49. if (!res.authSetting['scope.writePhotosAlbum']) {
  50. that.setData({
  51. popup: true
  52. })
  53. }
  54. }
  55. })
  56. },
  57. complete () {
  58. wx.hideLoading()
  59. }
  60. })
  61. },
  62. setting () {
  63. this.setData({
  64. popup: false
  65. })
  66. },
  67. onShareAppMessage: function (val) {
  68. return _request.share({
  69. sc: 'helpfarm_othercustom'
  70. })
  71. }
  72. })