addMeg.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <!-- -->
  2. <template>
  3. <div class="addMeg_box" :style="'height:' + fullHeight + 'px'">
  4. <!-- 头部 -->
  5. <div class="addMeg_box_head">
  6. <!-- 返回图标 -->
  7. <div class="head_div" @click="goBack()">
  8. <img src="../../assets/image/return.png" alt class="head_div_img" />
  9. </div>
  10. <!-- 标题 -->
  11. <div class="head_title">
  12. <span class="head_title_text">新增留言</span>
  13. </div>
  14. </div>
  15. <!-- 内容 -->
  16. <div class="addMeg_box_main">
  17. <!-- 反馈信息 -->
  18. <div class="addMeg_box_main_meg">
  19. <!-- 标题 -->
  20. <div class="addMeg_box_main_meg_title">反馈信息:</div>
  21. <!-- 输入框 -->
  22. <el-input maxlength="100" type="textarea" placeholder="请输入需要反馈的问题或建议" v-model="textarea1"></el-input>
  23. <div class="addMeg_IptNum">{{ this.textarea1.length }} / 100</div>
  24. </div>
  25. <!-- 回访 -->
  26. <div class="addMeg_box_main_visit">
  27. <!-- 标题 -->
  28. <div class="addMeg_box_main_visit_title">如果方便,请留下您的手机号</div>
  29. <!-- 输入框 -->
  30. <el-input type="number" placeholder="请输入手机号" v-model="input2" maxlength="6" clearable></el-input>
  31. </div>
  32. <!-- 提交按钮 -->
  33. <el-button @click="addAxios()" type="success">提交</el-button>
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. export default {
  39. components: {},
  40. data() {
  41. //这里存放数据
  42. return {
  43. fullHeight: document.documentElement.clientHeight,
  44. textarea1: "",
  45. input2: "",
  46. isClick: true //点赞开关
  47. };
  48. },
  49. //监听属性 类似于data概念
  50. computed: {},
  51. //监控data中的数据变化
  52. watch: {
  53. fullHeight(val) {
  54. //监控浏览器高度变化
  55. if (!this.timer) {
  56. this.fullHeight = val;
  57. this.timer = true;
  58. let that = this;
  59. setTimeout(function() {
  60. //防止过度调用监测事件,导致卡顿
  61. that.timer = false;
  62. }, 400);
  63. }
  64. },
  65. textarea1(val) {
  66. this.textarea1 = this.textarea1.replace(/[^A-Za-z0-9\u4e00-\u9fa5]/g, "");
  67. }
  68. },
  69. //方法集合
  70. methods: {
  71. //动态获取浏览器高度
  72. get_boderHeight() {
  73. const that = this;
  74. window.onresize = () => {
  75. return (() => {
  76. window.fullHeight = document.documentElement.clientHeight;
  77. that.fullHeight = window.fullHeight;
  78. })();
  79. };
  80. },
  81. //点击返回到主页
  82. goBack() {
  83. let _this = this;
  84. // _this.$router.push("/message");
  85. _this.$router.replace("/message");
  86. },
  87. //点击上传反馈
  88. addAxios() {
  89. let _this = this;
  90. let postData = _this.$qs.parse({
  91. content: _this.textarea1,
  92. photo: _this.input2
  93. });
  94. var isClick = _this.isClick;
  95. if (isClick === true) {
  96. _this.isClick = false;
  97. _this
  98. .$axios({
  99. method: "post",
  100. url: "bigservers/user_leaving",
  101. data: postData,
  102. headers: {
  103. "Content-Type": "multipart/form-data"
  104. }
  105. })
  106. .then(res => {
  107. if (res.data === 0) {
  108. this.$message({
  109. message: "提交成功,您的意见我们会尽快回复",
  110. type: "success",
  111. duration: 1000
  112. });
  113. _this.textarea1 = "";
  114. _this.input2 = "";
  115. _this.$router.replace("/message");
  116. const timeA = setInterval(() => {
  117. location.reload();
  118. }, 1500);
  119. } else if (res.data === 1) {
  120. this.$message({
  121. message: "手机号码格式不正确",
  122. type: "error",
  123. duration: 1000
  124. });
  125. }
  126. })
  127. .catch(error => {
  128. this.$message({
  129. message: "提交失败",
  130. type: "error",
  131. duration: 1000
  132. });
  133. });
  134. setTimeout(function() {
  135. _this.isClick = true;
  136. }, 1500);
  137. }
  138. }
  139. },
  140. //生命周期 - 创建完成(可以访问当前this实例)
  141. created() {},
  142. //生命周期 - 挂载完成(可以访问DOM元素)
  143. mounted() {
  144. this.get_boderHeight();
  145. }
  146. };
  147. </script>
  148. <style lang='scss'>
  149. @import "../../assets/scss/bus.scss";
  150. @import "../../assets/scss/addMeg.scss";
  151. </style>