contact.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. const util = require('../../../utils/util.js');
  2. Component({
  3. properties: {
  4. show:{
  5. type: Boolean,
  6. observer: function (newVal) {
  7. this.setData({ show: newVal });
  8. if (this.data.show) {
  9. this.getPopupContent()
  10. }
  11. }
  12. },
  13. type:{
  14. type: Boolean,
  15. observer: function (newVal) {
  16. this.setData({ type: newVal });
  17. }
  18. }
  19. },
  20. data: {
  21. type:false,
  22. show:false,
  23. height:'60%',
  24. customerService:{}
  25. },
  26. methods: {
  27. // 获取弹窗内容
  28. getPopupContent(){
  29. var that = this;
  30. let data={};
  31. if (this.data.type) {
  32. data.city='总部'
  33. }
  34. util.ajax({
  35. func: "article/wx_info",
  36. load: false,
  37. data
  38. }, function (res) {
  39. if (res.code == 0) {
  40. that.setData({
  41. customerService:res.data
  42. })
  43. } else {
  44. util.showTips(res.reason);
  45. }
  46. })
  47. },
  48. // 关闭弹窗
  49. closeTip(e){
  50. this.colse(e.detail)
  51. },
  52. // 确定
  53. closePopup(){
  54. let that =this
  55. if (!util.isEmpty(this.data.customerService.wxlogo)) {
  56. wx.downloadFile({
  57. url:that.data.customerService.wxlogo,
  58. success(res) {
  59. wx.saveImageToPhotosAlbum({
  60. filePath:res.tempFilePath,
  61. success:(res)=>{
  62. setTimeout(() => {
  63. util.showTips('已保存至相册!')
  64. }, 100);
  65. setTimeout(() => {
  66. that.colse(false)
  67. }, 600);
  68. }
  69. })
  70. },
  71. fail(res){
  72. util.showTips('保存失败!')
  73. }
  74. })
  75. }
  76. },
  77. colse(data){
  78. this.triggerEvent("close",{
  79. status:data,
  80. type:'contact'
  81. } );
  82. }
  83. }
  84. })