C端小程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

103 строки
2.4 KiB

  1. const Http = require("../../utils/HttpBasics");
  2. var config = require("../../config/config.js");
  3. Component({
  4. properties: {
  5. questionnaire: {
  6. type: Object,
  7. value: {}
  8. },
  9. questionId: {
  10. type: String,
  11. value: {}
  12. }
  13. },
  14. data: {
  15. widthScreen: null,
  16. moveData: null,
  17. rotateData: null,
  18. alphaData: null,
  19. scaleData: null,
  20. skewData: null,
  21. matrixData: null,
  22. flag: false,
  23. },
  24. methods:{
  25. close:function(){
  26. this.alphaClick();
  27. this.queueClick();
  28. // 子组件向父组件传值
  29. // 传值到 coupon=>detail页面
  30. var myEvent = "questions1";
  31. this.triggerEvent('myevent', myEvent);
  32. },
  33. /**
  34. * 点击提交问题单选
  35. */
  36. formSubmit:function(e){
  37. let that = this;
  38. /**
  39. * 多选
  40. */
  41. if (e.currentTarget.dataset.flags =='multi'){
  42. if (that.data.anwserId.length==0){
  43. var answserIs = ""
  44. }else{
  45. var answserIs = that.data.anwserId.join(",");
  46. }
  47. }
  48. else{
  49. var answserIs = e.target.dataset.answerid;
  50. }
  51. Http.post({
  52. url: config.api.answerQuestion,
  53. data: {
  54. answer: answserIs,
  55. questionId: e.currentTarget.dataset.questionid
  56. }
  57. })
  58. .then(res => {
  59. this.alphaClick();
  60. this.queueClick();
  61. })
  62. .catch(err => {
  63. wx.showToast({
  64. title: err.errMsg,
  65. icon: 'none',
  66. duration: 2000,
  67. mask: false
  68. });
  69. })
  70. // 子组件向父组件传值
  71. // 传值到 coupon=>detail页面
  72. var myEvent1 = "questions2";
  73. this.triggerEvent('myevent', myEvent1);
  74. },
  75. /**
  76. * 多选
  77. */
  78. checkboxChange:function(e){
  79. this.setData({
  80. anwserId:e.detail.value
  81. })
  82. },
  83. queueClick: function () {
  84. let that = this;
  85. var animation = wx.createAnimation({});
  86. setTimeout(function () {
  87. that.setData({ flag: true })
  88. }, 600)
  89. animation.translate((this.data.widthScreen - 0), 0).scale(0).opacity(0.5).step({ duration: 1000 })
  90. that.setData({ queueData: animation.export()})
  91. },
  92. alphaClick: function (even) {
  93. let that = this;
  94. var animation = wx.createAnimation({});
  95. setTimeout(function () {
  96. that.setData({ flag: true })
  97. }, 600)
  98. animation.opacity(0).step({ duration: 1000 })
  99. that.setData({ alphaData: animation.export()});
  100. }
  101. },
  102. });