reply.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-01-12 11:57:48
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-05-22 15:31:58
  6. * @Description: file content
  7. * @FilePath: \oms\pages\distributor\index.vue
  8. -->
  9. <template>
  10. <view class="home">
  11. <view class="nav">
  12. <view :style="{ paddingTop }">
  13. <view class="title" :style="[{ height }, { lineHeight: height }]">
  14. <text>评论回复</text>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="main">
  19. <view class="flex top-tips">
  20. <u-text type="error" text="*请先回复完以下评论"></u-text>
  21. <u-text type="primary" :text="'待回复信息' + replyIndex + '/' + commentList.length"></u-text>
  22. </view>
  23. <transition-group name="fade" tag="view">
  24. <view class="comment-wrap" v-show="replyIndex - 1 == i" v-for="(v, i) in commentList" :key="i">
  25. <view class="header flex">
  26. <u-image
  27. :src="require('../../static/images/user_avatar.png')"
  28. width="40px"
  29. height="40px"
  30. shape="circle"></u-image>
  31. <view class="name">{{ v.createdName }}</view>
  32. </view>
  33. <view class="content-wrap">
  34. <view class="content">
  35. <u-text :text="v.content"></u-text>
  36. </view>
  37. <view class="flex">
  38. <text>{{ parseTime(v.createdTime, '{y}-{m}-{d} {h}:{i}') }}</text>
  39. </view>
  40. <view class="replyText">
  41. <u-textarea v-model="replyContent" height="100" placeholder="回复内容:"></u-textarea>
  42. <view style="float: right; margin: 20px 0 0">
  43. <u-button :loading="loading" customStyle="width:60px" type="primary" @click="handleReply(v)">
  44. 回复
  45. </u-button>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </transition-group>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import followApi from '@/api/follow/index'
  56. import to from 'await-to-js'
  57. export default {
  58. name: 'omsIndex',
  59. components: {},
  60. data() {
  61. return {
  62. height: '',
  63. paddingTop: '',
  64. commentList: [],
  65. replyIndex: 1,
  66. replyContent: '',
  67. loading: false,
  68. }
  69. },
  70. created() {
  71. const navData = uni.getMenuButtonBoundingClientRect()
  72. this.height = navData.height + 'px'
  73. this.paddingTop = navData.top + 'px'
  74. },
  75. onShow() {
  76. this.getCommentList()
  77. },
  78. methods: {
  79. async getCommentList() {
  80. const [err, res] = await to(followApi.getNeedReplyComments())
  81. if (err) return
  82. if (res && res.code == 200) {
  83. this.commentList = res.data.list
  84. }
  85. },
  86. async handleReply(row) {
  87. if (!this.replyContent) {
  88. return this.$u.toast('请输入回复内容')
  89. }
  90. const params = {
  91. followId: '' + row.followId,
  92. content: this.replyContent,
  93. pid: row.id,
  94. }
  95. this.loading = true
  96. const [err, res] = await to(followApi.onReply(params))
  97. this.loading = false
  98. if (err) return
  99. if (res && res.code == 200) {
  100. this.replyContent = ''
  101. if (this.replyIndex < this.commentList.length) {
  102. this.replyIndex++
  103. return this.$u.toast('回复成功,请继续回复下一条')
  104. }
  105. this.$u.toast('已全部回复,即将返回首页')
  106. setTimeout(() => {
  107. uni.switchTab({ url: '/pages/home/index' })
  108. }, 2000)
  109. }
  110. },
  111. },
  112. }
  113. </script>
  114. <style>
  115. page {
  116. background: #f2f3f5;
  117. }
  118. </style>
  119. <style lang="scss" scoped>
  120. .home {
  121. padding-top: 188rpx;
  122. .nav {
  123. position: absolute;
  124. left: 0;
  125. top: 0;
  126. width: 100%;
  127. height: 284rpx;
  128. background: #3e7ef8;
  129. .title {
  130. position: relative;
  131. text-align: center;
  132. font-size: 32rpx;
  133. font-weight: bold;
  134. color: #ffffff;
  135. .back {
  136. position: absolute;
  137. top: 0;
  138. bottom: 0;
  139. margin: auto;
  140. left: 70rpx;
  141. display: flex;
  142. }
  143. }
  144. }
  145. .main {
  146. position: absolute;
  147. width: 100%;
  148. height: calc(100vh - 188rpx);
  149. background: #f5f5f5;
  150. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  151. border-radius: 31rpx 31rpx 0 0;
  152. padding: 0 32rpx;
  153. padding-bottom: 64rpx;
  154. .top-tips {
  155. padding: 10px 10px 20px;
  156. }
  157. .comment-wrap {
  158. border: 1px solid #d7e8f4;
  159. background: #f7fbfe;
  160. border-radius: 8px;
  161. padding: 10px;
  162. overflow: hidden;
  163. .header {
  164. align-items: center;
  165. .name {
  166. margin-left: 20rpx;
  167. font-weight: bold;
  168. color: #333;
  169. margin-left: 10px;
  170. }
  171. }
  172. .content-wrap {
  173. padding-left: 50px;
  174. .content {
  175. padding: 10px 0;
  176. }
  177. }
  178. .replyText {
  179. margin: 20px 0;
  180. }
  181. }
  182. }
  183. }
  184. .fade-enter-active,
  185. .fade-leave-active {
  186. transition: opacity 0.5s;
  187. }
  188. .fade-enter-from,
  189. .fade-leave-to {
  190. opacity: 0;
  191. }
  192. .is-hidden {
  193. display: none;
  194. }
  195. </style>