C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 rivejä
2.2 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. /**
  38. * 多选
  39. */
  40. if (e.currentTarget.dataset.flags =='multi'){
  41. if (that.data.anwserId.length==0){
  42. var answserIs = ""
  43. }else{
  44. var answserIs = that.data.anwserId.join(",");
  45. }
  46. }
  47. else{
  48. var answserIs = e.target.dataset.answerid;
  49. }
  50. Http.post({
  51. url: config.api.answerQuestion,
  52. data: {
  53. answer: answserIs,
  54. questionId: e.currentTarget.dataset.questionid
  55. }
  56. })
  57. .then(res => {
  58. this.alphaClick();
  59. this.queueClick();
  60. })
  61. .catch(err => {
  62. wx.showToast({
  63. title: err.errMsg,
  64. icon: 'none',
  65. duration: 2000,
  66. mask: false
  67. });
  68. })
  69. // 子组件向父组件传值
  70. // 传值到 coupon=>detail页面
  71. var myEvent1 = "questions2";
  72. this.triggerEvent('myevent', myEvent1);
  73. },
  74. /**
  75. * 多选
  76. */
  77. checkboxChange:function(e){
  78. this.setData({
  79. anwserId:e.detail.value
  80. })
  81. },
  82. queueClick: function () {
  83. let that = this;
  84. var animation = wx.createAnimation({});
  85. animation.translate((this.data.widthScreen - 0), 0).scale(0).opacity(0.5).step({ duration: 1500 })
  86. that.setData({ queueData: animation.export()})
  87. },
  88. alphaClick: function (even) {
  89. let that = this;
  90. var animation = wx.createAnimation({})
  91. animation.opacity(0).step({ duration: 1500 })
  92. that.setData({ alphaData: animation.export()});
  93. }
  94. },
  95. });