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