feedback.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <view>
  3. <form>
  4. <view class="cu-form-group margin-top">
  5. <view class="title">姓名</view>
  6. <input placeholder="请输入姓名" data-field="name" @input="bindInput"></input>
  7. </view>
  8. <view class="cu-form-group">
  9. <view class="title">联系方式</view>
  10. <input placeholder="请输入联系方式" data-field="mobile" @input="bindInput"></input>
  11. </view>
  12. <view class="cu-form-group">
  13. <textarea maxlength="-1" @input="bindInput" data-field="content" placeholder="请输入您的意见和建议"></textarea>
  14. </view>
  15. <view class="cu-bar bg-white justify-end margin-top">
  16. <view class="action">
  17. <button class="cu-btn bg-green margin-left" @tap="subModal">确定</button>
  18. </view>
  19. </view>
  20. </form>
  21. </view>
  22. </template>
  23. <script>
  24. var _this;
  25. export default {
  26. data() {
  27. return {
  28. userinfo: {},
  29. info: {
  30. name: '',
  31. mobile: '',
  32. content: '',
  33. userid: 0,
  34. },
  35. }
  36. },
  37. onLoad: function(option) {
  38. _this = this;
  39. _this.userinfo = _this.checkLogin("/pages/my/myinfo");
  40. _this.info.userid = _this.userinfo.id;
  41. },
  42. methods: {
  43. textareaAInput(e) {
  44. _this.info.content = e.detail.value;
  45. },
  46. bindInput: function(e) {
  47. _this.info[e.currentTarget.dataset.field] = e.detail.value;
  48. },
  49. subModal() {
  50. if (_this.info.name == '') {
  51. uni.showModal({
  52. title: '信息提示',
  53. content: '姓名不能为空',
  54. showCancel: false
  55. });
  56. return false;
  57. }
  58. if (_this.info.mobile == '') {
  59. uni.showModal({
  60. title: '信息提示',
  61. content: '联系方式不能为空',
  62. showCancel: false
  63. });
  64. return false;
  65. }
  66. if (_this.info.content == '') {
  67. uni.showModal({
  68. title: '信息提示',
  69. content: '反馈内容不能为空',
  70. showCancel: false
  71. });
  72. return false;
  73. }
  74. _this.$req.ajax({
  75. path: "my/feedback",
  76. data: _this.info,
  77. }).then((data) => {
  78. uni.navigateBack();
  79. }).catch((err) => {
  80. uni.showModal({
  81. title: '信息提示',
  82. content: err,
  83. showCancel: false
  84. });
  85. });
  86. },
  87. }
  88. }
  89. </script>
  90. <style>
  91. .cu-form-group .title {
  92. min-width: calc(4em + 30rpx);
  93. }
  94. </style>