complaintWrite.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view>
  3. <!--pages/writeComplaint/writeComplaint.wxml-->
  4. <view>
  5. <!-- 投诉标题 -->
  6. <view class="complaintWrapper">
  7. <text class="complaintTitle">投诉标题</text>
  8. <textarea name="投诉标题" v-model="complaintTitle" cols="30" rows="10" maxlength="50" placeholder="不超过50字" class="titleInput" bindinput="getComplaintTitle"></textarea>
  9. </view>
  10. <!-- 投诉内容 -->
  11. <view class="complaintWrapper">
  12. <text class="complaintTitle">投诉内容</text>
  13. <textarea name="投诉内容" v-model="complaintDetail" cols="30" rows="10" maxlength="512" placeholder="不超过512字" class="contentInput" bindinput="getComplaintContent"></textarea>
  14. </view>
  15. </view>
  16. <!-- 取消和提交按钮 -->
  17. <view class="suggestBtn">
  18. <view class="confirmBtn" @click="toCancel">取消</view>
  19. <view class="confirmBtn" @click="toConfirm">提交</view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. data() {
  26. return {
  27. complaintTitle: "",
  28. complaintDetail: ""
  29. }
  30. },
  31. methods: {
  32. toCancel(){
  33. this.complaintTitle = "";
  34. this.complaintDetail = "";
  35. uni.navigateBack({
  36. delta: 1,
  37. })
  38. },
  39. toConfirm(){
  40. var head = '^[ ]+$';
  41. var re = new RegExp(head);
  42. if (!this.complaintTitle) {
  43. uni.showModal({
  44. title: '投诉标题未写',
  45. content: '请补充标题后再重新提交'
  46. })
  47. }
  48. else if (re.test(this.complaintTitle)) {
  49. uni.showModal({
  50. title: '标题不能全为空格',
  51. content: '投诉标题不能全部为空格,请修改投诉标题后再提交'
  52. })
  53. }
  54. else if (!this.complaintDetail) {
  55. uni.showModal({
  56. title: '投诉内容未写',
  57. content: '投诉内容不能为空,请补充投诉内容后再提交'
  58. })
  59. }
  60. else if (re.test(this.complaintDetail)) {
  61. uni.showModal({
  62. title: '投诉内容不能全部为空格',
  63. content: '投诉内容不能全部为空格,请修改投诉内容后再提交'
  64. })
  65. }
  66. else{
  67. //const { data: result } =await uni.$http.get('/education/my-suggestion/writeAdvise',this.queryObj)
  68. uni.request({
  69. url: 'http://localhost:8222/education/my-complaint/writeComplaint',
  70. data: {
  71. "complaintTitle": this.complaintTitle,
  72. "complaintDetail": this.complaintDetail,
  73. },
  74. header: {
  75. token: uni.getStorageSync('token')
  76. },
  77. method: 'POST',
  78. success: res => {
  79. // this.isLoading = false
  80. console.log(res)
  81. uni.$showMsg(res.data.message)
  82. setTimeout(() => {
  83. uni.navigateBack()
  84. }, 1000)
  85. }
  86. })
  87. }
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. /* pages/writeComplaint/writeComplaint.wxss */
  94. /* 设置页面背景 */
  95. page{
  96. background-color: #E2F0D9;
  97. height: 100%;
  98. }
  99. .complaintWrapper{
  100. display: flex;
  101. flex-direction: column;
  102. width: 100%;
  103. padding: 20rpx;
  104. }
  105. /* 标题 */
  106. .complaintTitle{
  107. text-align: center;
  108. padding-bottom: 20rpx;
  109. font-weight: bold;
  110. }
  111. /* 输入的建议标题和内容公共样式 */
  112. .titleInput,
  113. .contentInput{
  114. width: 93%;
  115. padding: 10rpx;
  116. /* border: 1rpx solid gray; */
  117. border-radius: 20rpx;
  118. background-color: #fff;
  119. }
  120. /* 建议标题输入框的高度 */
  121. .titleInput{
  122. height: 150rpx;
  123. }
  124. /* 建议内容输入框的高度 */
  125. .contentInput{
  126. height: 800rpx;
  127. }
  128. /* 下方按钮 */
  129. .suggestBtn{
  130. display: flex;
  131. margin-top: 40rpx;
  132. justify-content: space-around;
  133. }
  134. .confirmBtn{
  135. font-size: 42rpx;
  136. width: 120rpx;
  137. padding: 10rpx 20rpx;
  138. border-radius: 40rpx;
  139. text-align: center;
  140. background-color: #8FAADC;
  141. color: white;
  142. }
  143. </style>