C端小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

99 linhas
2.3 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. .catch(err => {
  64. wx.showToast({
  65. title: err.errMsg,
  66. icon: 'none',
  67. duration: 2000,
  68. mask: false
  69. });
  70. })
  71. // 子组件向父组件传值
  72. // 传值到 coupon=>detail页面
  73. var myEvent1 = "questions2";
  74. this.triggerEvent('myevent', myEvent1);
  75. },
  76. /**
  77. * 多选
  78. */
  79. checkboxChange:function(e){
  80. console.log(e);
  81. this.setData({
  82. anwserId:e.detail.value
  83. })
  84. },
  85. queueClick: function () {
  86. let that = this;
  87. var animation = wx.createAnimation({});
  88. animation.translate((this.data.widthScreen - 0), 0).scale(0).opacity(0.5).step({ duration: 1500 })
  89. that.setData({ queueData: animation.export()})
  90. },
  91. alphaClick: function (even) {
  92. let that = this;
  93. var animation = wx.createAnimation({})
  94. animation.opacity(0).step({ duration: 1500 })
  95. that.setData({ alphaData: animation.export()});
  96. }
  97. },
  98. });