my_suggestion_write.vue 3.8 KB

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