my_complaint_write.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. this.disableButton = false
  88. }
  89. }
  90. }
  91. </script>
  92. <!-- 设置页面背景 -->
  93. <style lang="scss">
  94. page{
  95. height: 100%;
  96. //background-color: #FFF;
  97. // background-color: #D4F5E9;
  98. }
  99. </style>
  100. <style lang="scss" scoped>
  101. /* 设置页面背景 */
  102. // page{
  103. // background-color: #E2F0D9;
  104. // height: 100%;
  105. // }
  106. .complaintWrapper{
  107. display: flex;
  108. flex-direction: column;
  109. width: 100%;
  110. padding: 20rpx;
  111. font-size: 30rpx;
  112. }
  113. /* 标题 */
  114. .complaintTitle{
  115. text-align: center;
  116. padding-bottom: 20rpx;
  117. font-weight: bold;
  118. font-size: 30rpx;
  119. color: #606060;
  120. }
  121. /* 输入的建议标题和内容公共样式 */
  122. .titleInput,
  123. .contentInput{
  124. width: 93%;
  125. padding: 10rpx;
  126. /* border: 1rpx solid gray; */
  127. border-radius: 20rpx;
  128. background-color: #fff;
  129. }
  130. /* 建议标题输入框的高度 */
  131. .titleInput{
  132. height: 150rpx;
  133. }
  134. /* 建议内容输入框的高度 */
  135. .contentInput{
  136. height: 600rpx;
  137. }
  138. /* 下方按钮 */
  139. .suggestBtn{
  140. display: flex;
  141. margin-top: 40rpx;
  142. justify-content: space-around;
  143. }
  144. .confirmBtn,
  145. .cancelBtn{
  146. font-size: 30rpx;
  147. height: 85rpx;
  148. width: 200rpx;
  149. line-height: 85rpx;
  150. border-radius: 50rpx;
  151. text-align: center;
  152. color: white;
  153. margin-top: 5rpx;
  154. }
  155. .confirmBtn{
  156. background-color: #35b882;
  157. }
  158. .cancelBtn{
  159. background-color: #3ed598;
  160. }
  161. </style>