exchangeDetails.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <!-- 互动问答详情 -->
  3. <view class="bg">
  4. <view style="height: 10rpx;"></view>
  5. <!-- 顶部 问题发起人 -->
  6. <view class="wdbox">
  7. <view class="wdflex" style="align-items: center;">
  8. <view class="photo">
  9. <u--image shape="circle" width="80rpx" height="80rpx" :src="QaDetail.authorLogo" ></u--image>
  10. </view>
  11. <view class="wen_name">{{ QaDetail.authorName }}</view>
  12. <view class="follow" @click="setQacollect()">{{ QaDetail.isCollection == '1' ? '取消关注' : '关注问题' }}</view>
  13. </view>
  14. <view class="wdflex">
  15. <!-- <view class="wen" style="background: #ff8c33">答</view> -->
  16. <view class="wen_text">{{ QaDetail.content }}</view>
  17. </view>
  18. <view class="wdflex" style="justify-content: space-between;">
  19. <view class="wen_text2">{{ QaDetail.createTime }}</view>
  20. <view class="wen_text2">{{ QaDetail.num + '回复'}}</view>
  21. </view>
  22. </view>
  23. <!-- 问题回复列表 -->
  24. <view class="wdbox" v-for="item in newsList" :key="item.id">
  25. <view class="wdflex" style="align-items: center;">
  26. <view class="photo">
  27. <u--image shape="circle" width="80rpx" height="80rpx" :src="item.authorLogo" ></u--image>
  28. </view>
  29. <view class="wen_name">{{ item.authorName }}</view>
  30. </view>
  31. <view class="wdflex">
  32. <view class="wen" style="background: #ff8c33">答</view>
  33. <view class="wen_text" style="font-weight: 700;color: #666666;">{{ item.content }}</view>
  34. </view>
  35. <view class="wdflex" style="justify-content: space-between;align-items: center;">
  36. <view class="wen_text2">{{ item.createTime }}</view>
  37. <view class="flex wen_text2" style="width: 200rpx;">
  38. <view class="flex" style="align-items: center;" @click="openComment(item)">
  39. <u--image shape="circle" width="48rpx" height="48rpx" src="/static/myinfo/icomx_message2.png" ></u--image>
  40. <text style="margin-left: 8rpx;">{{ item.num }}</text>
  41. </view>
  42. <view class="flex" @click="setQalike(item)" style="align-items: center;">
  43. <u--image v-if="item.isLike == '1'" shape="circle" width="48rpx" height="48rpx" src="/static/myinfo/icomx_dianzan1.png" ></u--image>
  44. <u--image v-else shape="circle" width="48rpx" height="48rpx" src="/static/myinfo/icomx_dianzan.png" ></u--image>
  45. <text style="margin-left: 8rpx;">{{ item.likesCount }}</text>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <commentNew @initDatalist="'initDatalist'" :CommentData="CommentData" :showComment="showComment" @closeComment="closeComment"></commentNew>
  51. <view class="loadmore" @click="loadmore()" >
  52. {{jiazaitext}}
  53. </view>
  54. <view class="btnflex">
  55. <view class="commentInput">
  56. <u-input placeholder="评论" v-model="inputValue2" type="text" />
  57. </view>
  58. <view class="btn" @click="submit2">
  59. 提交
  60. </view>
  61. </view>
  62. <view style="height:100rpx"></view>
  63. </view>
  64. </template>
  65. <script>
  66. import {topicQaDetail,Qareplybyid,QareplyPage,Qalike,Qacollect} from '@/http/api/common.js'
  67. import commentNew from './base/commentNew.vue'
  68. import * as util from '@/pages/util/util.js'
  69. export default {
  70. components: {
  71. commentNew
  72. },
  73. data() {
  74. return {
  75. newsList:[],
  76. pageNum:1,
  77. num:0,
  78. topicId:'',
  79. inputValue2:'',
  80. jiazaitext:'加载更多',
  81. loadingType:false,
  82. showComment:false,
  83. QaDetail:{
  84. authorLogo:'',
  85. name:'张三',
  86. title:'我们睡着了,身体都在忙些什么呢?',
  87. follow:'关注问题',
  88. time:'2024-5-20 16:54 提问',
  89. num:'4',
  90. isCollection:'1',
  91. },
  92. CommentData:null
  93. }
  94. },
  95. onReachBottom() {
  96. this.loadmore()
  97. },
  98. onLoad(e) {
  99. this.topicId = e.id
  100. this.initData()
  101. },
  102. methods: {
  103. async setQacollect(){
  104. let res = await Qacollect(this.QaDetail.id)
  105. this.QaDetail.isCollection = this.QaDetail.isCollection == '1'? '2' : '1'
  106. },
  107. async setQalike(item){
  108. let res = await Qalike(item.id)
  109. if (item.isLike == '1') {
  110. item.isLike = '2'
  111. item.likesCount = item.likesCount - 1
  112. }else{
  113. item.isLike = '1'
  114. item.likesCount = item.likesCount + 1
  115. }
  116. },
  117. async submit2(){
  118. //对主题回复
  119. let res = await Qareplybyid({
  120. floorId:'',
  121. content:this.inputValue2,
  122. replyId:'',
  123. replyType:1, //回复类型 1:回复主题 2:回复楼层 3:回复楼层内的评论
  124. },this.topicId)
  125. if (res.data.code == 200) {
  126. util.toastFunc('回复成功')
  127. this.inputValue2 = ''
  128. //初始化请求页签
  129. this.pageNum = 1
  130. this.CommentData = []
  131. //获取评论列表
  132. this.getTopicReply()
  133. this.close()
  134. }
  135. },
  136. async openComment(item){
  137. //把选中的子项回复赋值
  138. console.log(item);
  139. let res = await QareplyPage({
  140. pageNum:1,
  141. pageSize:100,
  142. floorId:item.id,
  143. topicId:item.topicId,
  144. })
  145. this.CommentData = {
  146. ...item,
  147. floorList:res.data.data.rows || []
  148. },
  149. this.showComment = true
  150. },
  151. closeComment(){
  152. this.showComment = false
  153. },
  154. openAskingQuestions(e){
  155. uni.navigateTo({
  156. url: '/pages/home/AskingQuestions'
  157. })
  158. },
  159. async initDatalist(){
  160. //每次切换页签初始化请求页签
  161. this.pageNum = 1
  162. this.newsList = []
  163. await this.initData()
  164. },
  165. async initData(){
  166. let data = {
  167. pageNum:this.pageNum,
  168. pageSize:10
  169. }
  170. let res = await topicQaDetail(data,this.topicId)
  171. if (res.data.code == 200 ) {
  172. this.QaDetail = res.data.data
  173. let newrows = this.QaDetail.repliesPage.rows || []
  174. this.newsList.push(...newrows)
  175. this.num = this.QaDetail.repliesPage.total
  176. if(this.newsList.length!=this.QaDetail.repliesPage.total){
  177. this.jiazaitext="加载更多"
  178. }else{
  179. this.jiazaitext="已经到底"
  180. }
  181. }
  182. },
  183. //加载更多
  184. loadmore(){
  185. console.log('下拉加载',this.jiazaitext);
  186. if (this.jiazaitext=="加载更多") {
  187. this.pageNum=this.pageNum+1
  188. this.jiazaitext="加载中..."
  189. this.initData()
  190. }
  191. },
  192. }
  193. }
  194. </script>
  195. <style lang="less" scoped>
  196. .bg{
  197. background-color: #F6F6F6;
  198. width: 100vw;
  199. min-height: 100vh;
  200. }
  201. .loadmore{
  202. height:200rpx;
  203. text-align: center;
  204. font-size: 28rpx;
  205. font-weight: 400;
  206. color: #999;
  207. padding-top: 24rpx;
  208. }
  209. .wdbox{
  210. width: 660rpx;
  211. min-height: 240rpx;
  212. background: #ffffff;
  213. margin: 26rpx;
  214. padding: 20rpx;
  215. border-radius: 16rpx;
  216. }
  217. .wen{
  218. width: 40rpx;
  219. height: 40rpx;
  220. background: #0084ff;
  221. border-radius: 8rpx;
  222. font-size: 28rpx;
  223. text-align: center;
  224. line-height: 40rpx;
  225. color: #fff;
  226. }
  227. .wen_text{
  228. margin-left: 16rpx;
  229. width: 590rpx;
  230. font-size: 32rpx;
  231. font-family: PingFang SC, PingFang SC-Bold;
  232. font-weight: 700;
  233. text-align: left;
  234. color: #333333;
  235. display: -webkit-box;
  236. word-break: break-all;
  237. text-overflow: ellipsis;
  238. overflow: hidden;
  239. -webkit-box-orient: vertical;
  240. -webkit-line-clamp:2;
  241. }
  242. .wen_name{
  243. margin-left: 16rpx;
  244. width: 400rpx;
  245. font-size: 32rpx;
  246. font-family: PingFang SC, PingFang SC-Bold;
  247. font-weight: 700;
  248. text-align: left;
  249. color: #666666;
  250. word-break: break-all;
  251. text-overflow: ellipsis;
  252. overflow: hidden;
  253. }
  254. .wen_num{
  255. margin-left: 56rpx;
  256. width: 590rpx;
  257. font-size: 28rpx;
  258. font-family: PingFang SC, PingFang SC-Regular;
  259. font-weight: 400;
  260. text-align: left;
  261. color: #0084ff;
  262. }
  263. .wen_text2{
  264. font-size: 28rpx;
  265. font-family: PingFang SC, PingFang SC-Regular;
  266. font-weight: 400;
  267. text-align: left;
  268. color: #999999;
  269. }
  270. .wdflex{
  271. display: flex;
  272. justify-content: flex-start;
  273. flex-direction: row;
  274. margin-top: 24rpx;
  275. }
  276. .submitbtn{
  277. width: 700rpx;
  278. height: 80rpx;
  279. background: #46a6ff;
  280. border-radius: 40rpx;
  281. text-align: center;
  282. font-size: 28rpx;
  283. font-family: PingFang SC, PingFang SC-Medium;
  284. font-weight: 500;
  285. color: #ffffff;
  286. line-height: 80rpx;
  287. position: fixed;
  288. bottom: 10rpx;
  289. left: 26rpx;
  290. }
  291. .follow{
  292. width: 160rpx;
  293. height: 64rpx;
  294. background: #deeefc;
  295. border-radius: 4px;
  296. font-size: 28rpx;
  297. font-family: PingFang SC, PingFang SC-Medium;
  298. font-weight: 500;
  299. text-align: center;
  300. color: #0084ff;
  301. line-height: 64rpx;
  302. }
  303. .btnflex{
  304. display: flex;
  305. flex-direction: row;
  306. align-items: center;
  307. position: fixed;
  308. bottom: 0;
  309. left: 0;
  310. width: 750rpx;
  311. height: 100rpx;
  312. background: #ffffff;
  313. }
  314. .commentInput{
  315. width: 520rpx;
  316. background: #EEEEEE;
  317. border-radius: 40rpx 40rpx 40rpx 40rpx;
  318. margin-left: 30rpx;
  319. }
  320. .btn{
  321. width: 150rpx;
  322. height: 70rpx;
  323. margin-left: 20rpx;
  324. border-radius: 40rpx;
  325. background: #46a6ff;
  326. text-align: center;
  327. line-height: 70rpx;
  328. font-size: 28rpx;
  329. color: #fff;
  330. }
  331. /deep/.u-input{
  332. border: 0px;
  333. }
  334. </style>