C端小程序
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.1 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. },
  23. methods:{
  24. close:function(){
  25. this.alphaClick();
  26. this.queueClick();
  27. // 子组件向父组件传值
  28. // 传值到 coupon=>detail页面
  29. var myEvent = "questions1";
  30. this.triggerEvent('myevent', myEvent);
  31. },
  32. /**
  33. * 点击提交问题单选
  34. */
  35. formSubmit:function(e){
  36. let that = this;
  37. console.log(e);
  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. console.log(res);
  60. this.alphaClick();
  61. this.queueClick();
  62. })
  63. // 子组件向父组件传值
  64. // 传值到 coupon=>detail页面
  65. var myEvent1 = "questions2";
  66. this.triggerEvent('myevent', myEvent1);
  67. },
  68. /**
  69. * 多选
  70. */
  71. checkboxChange:function(e){
  72. console.log(e);
  73. this.setData({
  74. anwserId:e.detail.value
  75. })
  76. },
  77. queueClick: function () {
  78. let that = this;
  79. var animation = wx.createAnimation({});
  80. animation.translate((this.data.widthScreen - 0), 0).scale(0).opacity(0.5).step({ duration: 1500 })
  81. that.setData({ queueData: animation.export()})
  82. },
  83. alphaClick: function (even) {
  84. let that = this;
  85. var animation = wx.createAnimation({})
  86. animation.opacity(0).step({ duration: 1500 })
  87. that.setData({ alphaData: animation.export()});
  88. }
  89. },
  90. });