displayData.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. properties: {
  4. ptype: {
  5. type: String,
  6. value: "浏览"
  7. },
  8. dataId: {
  9. type: String,
  10. value: ''
  11. },
  12. dataAuth: {
  13. type: String,
  14. value: '' //all 内部 经销商
  15. }
  16. },
  17. data: {
  18. actions: [{
  19. name: '',
  20. color: '#3874F6'
  21. }],
  22. actionShow: false,
  23. active: "经销商"
  24. },
  25. lifetimes: {
  26. ready() {
  27. let params = {
  28. "classname": "saletool.notice.data", //默认通告
  29. "method": "getSaleareaInfo", //默认经销商
  30. "content": {
  31. sat_noticeid: this.data.dataId,
  32. "sat_coursewareid": this.data.dataId
  33. }
  34. };
  35. if (this.data.ptype == '学习') params.classname = "saletool.courseware.data";
  36. if (this.data.dataAuth != 'all') {
  37. params.method = this.data.dataAuth == '内部' ? 'getInternalInfo' : 'getSaleareaInfo'
  38. this.setData({
  39. active: this.data.dataAuth
  40. })
  41. };
  42. this.setData({
  43. params
  44. })
  45. this.getData();
  46. },
  47. },
  48. options: {
  49. addGlobalClass: true
  50. },
  51. methods: {
  52. onChange(e) {
  53. let {
  54. name
  55. } = e.detail;
  56. this.setData({
  57. active: name,
  58. "params.method": name == '内部' ? 'getInternalInfo' : 'getSaleareaInfo'
  59. });
  60. this.getData();
  61. },
  62. getData() {
  63. _Http.basic(this.data.params).then(res => {
  64. console.log(this.data.active, "学习数据", res)
  65. this.setData({
  66. list: res.data,
  67. tips: res.tips
  68. });
  69. })
  70. },
  71. callOut(e) {
  72. const {
  73. item
  74. } = e.currentTarget.dataset;
  75. this.setData({
  76. 'actions[0].name': '呼叫 ' + item.phonenumber,
  77. actionShow: true
  78. })
  79. },
  80. handleCallOut(e) {
  81. let phone = e.detail.name.split(' ')[1];
  82. wx.makePhoneCall({
  83. phoneNumber: phone,
  84. success() {},
  85. fail() {}
  86. })
  87. },
  88. onClose() {
  89. this.setData({
  90. 'actions[0].name': '',
  91. actionShow: false
  92. })
  93. },
  94. }
  95. })