commentPost.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view class="container">
  3. <view class="post-comment">
  4. <view class="input-box">
  5. <textarea class="content" focus="true" v-model="content" maxlength="140" placeholder="留言经过筛选后,对所有人可见" />
  6. <text class="count">{{140 - content.length}}</text>
  7. </view>
  8. <view class="btns">
  9. <view class="close" @tap="onClose">取消</view>
  10. <view class="post" @tap="onPost">发表</view>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. const util = require("@/utils/util.js");
  17. const api = require('@/utils/api.js');
  18. export default {
  19. data() {
  20. return {
  21. typeId: 0,
  22. valueId: 0,
  23. content: ''
  24. }
  25. },
  26. methods: {
  27. onPost() {
  28. let that = this;
  29. if (!that.content) {
  30. util.toast('请填写评论')
  31. return false;
  32. }
  33. util.request(api.CommentPost, {
  34. typeId: that.typeId,
  35. valueId: that.valueId,
  36. content: that.content
  37. }, 'POST', 'application/json').then(function (res) {
  38. if (res.errno === 0) {
  39. uni.showToast({
  40. title: '评论成功',
  41. complete: function(){
  42. uni.navigateBack({
  43. delta: 1
  44. });
  45. }
  46. })
  47. }
  48. });
  49. }
  50. },
  51. onClose:function() {
  52. uni.navigateBack({
  53. delta: 1
  54. });
  55. },
  56. onLoad: function(options) {
  57. var that = this;
  58. that.typeId= parseInt(options.typeId)
  59. that.valueId= parseInt(options.valueId)
  60. }
  61. }
  62. </script>
  63. <style lang="scss">
  64. page, .container {
  65. height: 100%;
  66. background: #f4f4f4;
  67. }
  68. .post-comment {
  69. width: 750rpx;
  70. height: auto;
  71. overflow: hidden;
  72. padding: 30rpx;
  73. }
  74. .post-comment .input-box {
  75. height: 337.5rpx;
  76. width: 690rpx;
  77. position: relative;
  78. background: #fff;
  79. }
  80. .post-comment .input-box .content {
  81. position: absolute;
  82. top: 0;
  83. left: 0;
  84. display: block;
  85. background: #fff;
  86. font-size: 29rpx;
  87. color: #333;
  88. height: 300rpx;
  89. width: 650rpx;
  90. padding: 20rpx;
  91. }
  92. .post-comment .input-box .count {
  93. position: absolute;
  94. bottom: 20rpx;
  95. right: 20rpx;
  96. display: block;
  97. height: 30rpx;
  98. width: 50rpx;
  99. font-size: 29rpx;
  100. color: #999;
  101. }
  102. .post-comment .btns {
  103. height: 108rpx;
  104. }
  105. .post-comment .close {
  106. float: left;
  107. height: 108rpx;
  108. line-height: 108rpx;
  109. text-align: left;
  110. color: #666;
  111. padding: 0 30rpx;
  112. }
  113. .post-comment .post {
  114. float: right;
  115. height: 108rpx;
  116. line-height: 108rpx;
  117. text-align: right;
  118. padding: 0 30rpx;
  119. }
  120. </style>