integral.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. const util = require("../../../utils/util.js");
  2. Component({
  3. properties: {
  4. show:{
  5. type: Boolean,
  6. observer:function(val){
  7. this.setData({ show: val });
  8. if (this.data.show) this.getScore();
  9. }
  10. },
  11. info:{
  12. type:Object,
  13. observer: function (params){
  14. params.discount = params.discount != undefined && params.discount < 0 ? params.discount.toString().replace("0.", "") : 1;
  15. this.setData({ params });
  16. if (params.idcards && params.idcards.ids.length > 0) this.getStatus();
  17. }
  18. },
  19. },
  20. data: {
  21. show: false,
  22. params:{
  23. discount: 1,
  24. aid:'',
  25. idcards:[],
  26. sid:''
  27. },
  28. explainInfo:[]
  29. },
  30. methods: {
  31. getScore(){
  32. let that = this;
  33. util.ajax({
  34. func:'v2/user/score/detail',
  35. load:false
  36. },function(res){
  37. if(res.code == 0){
  38. that.setData({ datas: res.data, role: util.userRole(res.data.score)});
  39. }
  40. })
  41. },
  42. getStatus(){
  43. let that = this, childIds = [];
  44. util.ajax({
  45. func:"v2/user/discount/detail",
  46. data: { aid: that.data.params.aid, childIds: that.data.params.idcards.ids.join(","), sid: that.data.params.sid },
  47. load: false
  48. },function(res){
  49. if(res.code == 0){
  50. that.setData({ explainInfo: res.data });
  51. }
  52. })
  53. },
  54. submit(){
  55. this.close();
  56. this.triggerEvent("close", this.data.show);
  57. },
  58. close() {
  59. this.setData({ show: false });
  60. this.triggerEvent("close", this.data.show);
  61. }
  62. }
  63. })