score-pop.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import Api from "../../../../model/api";
  2. import {getDataSet, getEventParam, throttle, toast} from "../../../../utils/utils";
  3. Component({
  4. properties: {
  5. show: {
  6. type: Boolean,
  7. value: false
  8. },
  9. scoreInfos: Array,
  10. item: Object,
  11. },
  12. data: {
  13. radio: null,
  14. },
  15. methods: {
  16. onClickHide(e) {
  17. this.setData({
  18. show: false
  19. })
  20. },
  21. onChange(e) {
  22. this.setData({
  23. radio: getEventParam(e),
  24. });
  25. },
  26. onClick(e) {
  27. const name = getDataSet(e, "name");
  28. this.setData({
  29. radio: name,
  30. });
  31. },
  32. pay: throttle(async function (e) {
  33. if (this.data.radio == null) {
  34. toast("请选择使用其中一个项目积分进行兑换")
  35. return;
  36. }
  37. const res = await Api.useScore({
  38. educationStuId: this.data.scoreInfos[this.data.radio].stuId,
  39. integralCourseId: this.data.item.id
  40. }, true)
  41. toast(res.msg)
  42. this.setData({
  43. show: false
  44. })
  45. this.triggerEvent("pay")
  46. })
  47. }
  48. });