question-liuyan.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <view>
  3. <view class="questionBankAnswer-bottom-flex" @tap="jiucuo">
  4. <!-- <view class="iconfont icon-sousuo1" style="font-weight: bold;"></view> -->
  5. <image src="../../static/icon/liuyan.png" mode="" style="width: 44rpx;height: 44rpx;" ></image>
  6. <view>留言</view>
  7. </view>
  8. <uni-popup ref="popup" type="bottom" radius="12rpx" background-color="#8c8989" color="#5A5B5C" width="90%">
  9. <view class="jiucuo">
  10. <view class="popup-content">
  11. <text class="text">留言</text>
  12. <view class="iconfont icon-cuo1" @tap="hide"></view>
  13. </view>
  14. <view class="" style="line-height: 200rpx;text-align: center;font-size: 32rpx;" v-if="loaded && liuyanList.length == 0">
  15. 暂无留言
  16. </view>
  17. <scroll-view scroll-y="true" style="height: 400rpx;" v-else @scrolltolower="getLiuyan">
  18. <view v-for="item in liuyanList" class="liuyan-wrap">
  19. <view class="user-info">
  20. <image :src="item.user.avatar" mode="" class="info-logo"></image>
  21. <view class="info-info">
  22. <view class="name">
  23. {{item.user.nickname}}
  24. </view>
  25. <view class="time">
  26. {{$myUtils.$common.formatDate(item.createtime * 1000,"Y-M-D h:m:s")}}
  27. </view>
  28. <view class="content">
  29. {{item.content}}
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </scroll-view>
  35. <view class="jiucuo-content">
  36. <textarea :value="content" placeholder="说说你的看法" @input="setContent" class="popup-textarea" />
  37. <button type="primary" :loading="isSubmit" @tap="submit" class="popup-button">提交</button>
  38. </view>
  39. </view>
  40. </uni-popup>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. props: {
  46. current_timu: {
  47. type: Object,
  48. default: {},
  49. },
  50. },
  51. data() {
  52. return {
  53. isSubmit: false,
  54. page: 1,
  55. limit: 20,
  56. loaded: false,
  57. loadingType: 'more',
  58. liuyanList: [],
  59. arr: [],
  60. content: '',
  61. analysis: '',
  62. }
  63. },
  64. methods: {
  65. async submit() {
  66. if (this.content == '' ) return
  67. if (this.isSubmit) return
  68. this.isSubmit = true
  69. let res = await this.$myHttp.post({
  70. url: 'api/yexam/Tag/add_msg',
  71. data: {
  72. question_id: this.current_timu.id,
  73. content: this.content,
  74. },
  75. needLogin: true
  76. })
  77. if (res.code == 1) {
  78. this.isSubmit = false
  79. uni.showToast({
  80. title: '提交成功'
  81. })
  82. this.$refs.popup.close()
  83. } else {
  84. uni.showToast({
  85. title: res.msg,
  86. icon: 'none'
  87. })
  88. this.isSubmit = false
  89. }
  90. },
  91. show() {
  92. this.$refs.popup.open('bottom')
  93. this.arr = []
  94. this.content = ''
  95. this.page = 1
  96. this.liuyanList = []
  97. this.loadingType = 'more'
  98. this.loaded = false
  99. this.getLiuyan()
  100. },
  101. hide() {
  102. this.$refs.popup.close()
  103. },
  104. setContent(e) {
  105. this.content = e.detail.value
  106. },
  107. jiucuo() {
  108. if (this.current_timu.id != '' && this.current_timu.id != undefined) {
  109. this.show()
  110. }
  111. },
  112. async getLiuyan() {
  113. let that = this
  114. if(that.loadingType == 'loading' || that.loadingType == 'noMore') {
  115. return
  116. }
  117. that.loadingType = 'loading'
  118. let res = await that.$myHttp.post({
  119. url: 'api/yexam/Question/guestbook',
  120. data: {
  121. id: that.current_timu.id,
  122. page: that.page,
  123. limit: that.limit
  124. },
  125. needLogin: true
  126. });
  127. if (res.code == 1) {
  128. that.liuyanList = that.liuyanList.concat(res.data.list)
  129. if(res.data.list.length == that.limit) {
  130. that.loadingType = 'more'
  131. that.page++
  132. }else {
  133. that.loadingType = 'noMore'
  134. }
  135. that.loaded = true
  136. }
  137. }
  138. }
  139. }
  140. </script>
  141. <style lang="scss">
  142. .popup-content {
  143. position: relative;
  144. background: #fff;
  145. z-index: 111;
  146. width: 100%;
  147. border-radius: 12px 12px 0 0;
  148. height: 42px;
  149. border-bottom: solid 1px #f1f1f1;
  150. text-align: center;
  151. line-height: 42px;
  152. color: #313131;
  153. font-size: 15px;
  154. }
  155. .jiucuo {
  156. position: relative;
  157. background: #fff;
  158. border-radius: 12rpx 12rpx 0 0;
  159. max-height: 80vh;
  160. overflow-y: auto;
  161. }
  162. .jiucuo-content {
  163. font-size: 13px;
  164. padding: 9px 9px 0;
  165. }
  166. .jiucuo-xuan {
  167. background: #fff;
  168. padding: 7px 2px;
  169. margin: 12px 0;
  170. border-radius: 4px;
  171. }
  172. .jiucuo-checkbox {
  173. width: 100%;
  174. display: flex;
  175. flex-wrap: wrap;
  176. align-items: flex-start;
  177. }
  178. .jiucuo-checkbox label {
  179. flex: 0 0 30%;
  180. display: flex;
  181. align-items: center;
  182. }
  183. .popup-textarea {
  184. width: 92%;
  185. margin: 0;
  186. font-size: 13px;
  187. background: #fff;
  188. padding: 11px;
  189. height: 72px;
  190. margin-bottom: 12px;
  191. background: #f7f7f7;
  192. }
  193. .popup-button {
  194. background: #3c7bfc !important;
  195. color: #fff;
  196. padding: 2px;
  197. margin: 0 auto 11px;
  198. border-radius: 43px;
  199. font-size: 16px;
  200. display: block !important;
  201. width: 95%;
  202. }
  203. .icon-cuo1 {
  204. position: absolute;
  205. color: #ccc;
  206. top: 0;
  207. right: 12px;
  208. }
  209. .user-info {
  210. display: flex;
  211. .info-logo {
  212. width: 60rpx;
  213. height: 60rpx;
  214. border-radius: 50%;
  215. margin-right:10rpx;
  216. background-color: #f7f7f7;
  217. }
  218. }
  219. .liuyan-wrap {
  220. padding: 20rpx;
  221. }
  222. .name {
  223. font-size: 26rpx;
  224. font-weight: bold;
  225. }
  226. .time {
  227. color: #666;
  228. font-size: 22rpx;
  229. }
  230. .content {
  231. padding-top: 10rpx;
  232. }
  233. </style>