my_complaint_write.vue 3.8 KB

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