customservice.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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: 'xcx_group'
  70. })
  71. },
  72. tokf(){
  73. console.log('oninfo');
  74. var that = this
  75. var url = 'v1/user/info'
  76. var params = {}
  77. var success = function (res) {
  78. let info = res.data;
  79. if(info.wx_user.id){
  80. let uurl = encodeURIComponent(`https://tfohowapi.hiwavo.com/h5yingyuchat.html?&visitor_id=fohow-${info.wx_user.id}&visitor_name=${info.wx_user.nickname}&avator=${info.wx_user.head}&from=xcx`);
  81. console.log("uurl",uurl);
  82. wx.navigateTo({
  83. url: '/pages/web/web?id='+uurl
  84. })
  85. }else{
  86. wx.showToast({
  87. title: '请先登录'
  88. })
  89. }
  90. }
  91. _request.$get(url, params, success);
  92. },
  93. })