postmessage.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view>
  3. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="发帖"></uni-nav-bar>
  4. <view class="post">
  5. <view class="post_title">
  6. <input type="text" placeholder="请输入标题" v-model="title" />
  7. </view>
  8. <view class="post_contert">
  9. <textarea v-model="mainbody" placeholder="请输入正文" />
  10. </view>
  11. <button class="post_btn" @click="post">发布</button>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. title:'',
  20. mainbody:''
  21. }
  22. },
  23. methods: {
  24. async getPostmessage(data) { //发帖
  25. const res = await this.$myRequest({
  26. url: '/api/api_gateway?method=pest.pests.pests_new_idea',
  27. data:{
  28. title:data.title,
  29. content:data.content
  30. }
  31. })
  32. console.log(res)
  33. },
  34. post(){
  35. if(this.title!=''&&this.mainbody!=''){
  36. let obj ={}
  37. obj.title=this.title
  38. obj.content=this.mainbody
  39. this.getPostmessage(obj)
  40. }
  41. },
  42. clickLeft(){
  43. uni.navigateTo({
  44. url: './exchangeShare'
  45. })
  46. },
  47. }
  48. }
  49. </script>
  50. <style lang="scss">
  51. .post {
  52. background-color: #F5F5F5;
  53. width: 100%;
  54. height: 93vh;
  55. padding-top: 16rpx;
  56. .post_title {
  57. padding: 40rpx 20rpx;
  58. background-color: white;
  59. width: 100%;
  60. input {
  61. width: 90%;
  62. margin: 0 auto;
  63. }
  64. }
  65. .post_contert {
  66. margin-top: 16rpx;
  67. padding: 40rpx 20rpx;
  68. background-color: white;
  69. width: 100%;
  70. height: 660rpx;
  71. textarea{
  72. width: 90%;
  73. margin: 0 auto;
  74. }
  75. }
  76. .post_btn{
  77. width: 90%;
  78. margin: 40rpx auto;
  79. background-color: #57C878;
  80. color: white;
  81. font-size: 32rpx;
  82. }
  83. }
  84. </style>