exchangeNew.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <!-- 互动问答 -->
  3. <view class="bg">
  4. <view class="head">
  5. <view v-if="!showType" class="search" style="margin-top: 10rpx;background: #F6F6F6;">
  6. <u-search bgColor='#F6F6F6' placeholder="请输入问题"
  7. :showAction='false'
  8. @custom="searchList" v-model="searchword"></u-search>
  9. <view @click="searchList" class="searchBtn">搜索</view>
  10. </view>
  11. <view v-if="showType" class="margintb tabwiew" >
  12. <u-tabs keyName='subIdName' @click="clicktabs" :list="list1"></u-tabs>
  13. </view>
  14. </view>
  15. <view class="wdbox" v-for="item in newsList" :key="item.id">
  16. <view class="wdflex">
  17. <view class="wen">问</view>
  18. <view class="wen_text">{{ item.content }}</view>
  19. </view>
  20. <view class="wdflex">
  21. <view class="wen" style="background: #ff8c33">答</view>
  22. <view class="wen_text" style="font-weight: 700;color: #666666;">{{ item.contentByLast || '暂无回答' }}</view>
  23. </view>
  24. <view class="wdflex" @click="openDetails(item)">
  25. <view class="wen_num">全部{{item.num}}个回答></view>
  26. </view>
  27. </view>
  28. <view class="submitbtn" @click="openAskingQuestions">
  29. 我也要提问
  30. </view>
  31. <view class="loadmore" @click="loadmore()" >
  32. {{jiazaitext}}
  33. </view>
  34. <view style="height:100rpx"></view>
  35. </view>
  36. </template>
  37. <script>
  38. import * as util from '@/pages/util/util.js'
  39. import {getContentPage} from '@/http/api/common.js'
  40. export default {
  41. components: {
  42. },
  43. data() {
  44. return {
  45. newsList:[],
  46. pageNum:1,
  47. num:0,
  48. searchword:'',
  49. jiazaitext:'加载更多',
  50. loadingType:false,
  51. showType:false,
  52. listType:'',
  53. list1:[
  54. {
  55. subIdName: '我的提问',
  56. key:'1'
  57. },
  58. {
  59. subIdName: '我的回复',
  60. key:'2'
  61. },
  62. {
  63. subIdName: '我的关注',
  64. key:'3'
  65. },
  66. {
  67. subIdName: '我的点赞',
  68. key:'4'
  69. }
  70. ],
  71. }
  72. },
  73. onReachBottom() {
  74. this.loadmore()
  75. },
  76. onLoad(e) {
  77. console.log(e.showType);
  78. if (e?.showType == 'mywenda') {
  79. this.showType = true
  80. this.listType = '1'
  81. }
  82. },
  83. onShow(){
  84. this.pageNum = 1
  85. this.newsList = []
  86. this.initData()
  87. },
  88. methods: {
  89. async clicktabs(item){
  90. console.log(item.key);
  91. this.listType = item.key
  92. //每次切换页签初始化请求页签
  93. this.pageNum = 1
  94. this.newsList = []
  95. await this.initData()
  96. },
  97. openDetails(e){
  98. uni.navigateTo({
  99. url: '/pages/home/exchangeDetails?id='+e.id
  100. })
  101. },
  102. openAskingQuestions(e){
  103. uni.navigateTo({
  104. url: '/pages/home/AskingQuestions'
  105. })
  106. },
  107. async searchList(){
  108. //每次切换页签初始化请求页签
  109. this.pageNum = 1
  110. this.newsList = []
  111. await this.initData()
  112. },
  113. async initData(){
  114. //获取互动问答列表
  115. let data = {
  116. pageNum:this.pageNum,
  117. pageSize:10,
  118. listType:this.listType
  119. }
  120. let res = await getContentPage(data,2)
  121. if (res.data.code == 200 ) {
  122. let newrows = res.data.data.rows || []
  123. this.newsList.push(...newrows)
  124. this.num = res.data.data.total
  125. if(this.newsList.length!=res.data.data.total){
  126. this.jiazaitext="加载更多"
  127. }else{
  128. this.jiazaitext="已经到底"
  129. }
  130. }
  131. },
  132. //加载更多
  133. loadmore(){
  134. console.log('下拉加载',this.jiazaitext);
  135. if (this.jiazaitext=="加载更多") {
  136. this.pageNum=this.pageNum+1
  137. this.jiazaitext="加载中..."
  138. this.initData()
  139. }
  140. },
  141. }
  142. }
  143. </script>
  144. <style>
  145. .bg{
  146. background-color: #F6F6F6;
  147. width: 100vw;
  148. min-height: 100vh;
  149. }
  150. .head{
  151. display: flex;
  152. flex-direction: column;
  153. align-items: center;
  154. justify-content: center;
  155. background: #FFFFFF;
  156. opacity: 1;
  157. height: 120rpx;
  158. }
  159. .u-search{
  160. width: 90vw;
  161. }
  162. .loadmore{
  163. height:200rpx;
  164. text-align: center;
  165. font-size: 28rpx;
  166. font-weight: 400;
  167. color: #999;
  168. padding-top: 24rpx;
  169. }
  170. .wdbox{
  171. width: 660rpx;
  172. min-height: 240rpx;
  173. background: #ffffff;
  174. margin: 26rpx;
  175. padding: 20rpx;
  176. }
  177. .wen{
  178. width: 40rpx;
  179. height: 40rpx;
  180. background: #0084ff;
  181. border-radius: 8rpx;
  182. font-size: 28rpx;
  183. text-align: center;
  184. line-height: 40rpx;
  185. color: #fff;
  186. }
  187. .wen_text{
  188. margin-left: 16rpx;
  189. width: 590rpx;
  190. font-size: 32rpx;
  191. font-family: PingFang SC, PingFang SC-Bold;
  192. font-weight: 700;
  193. text-align: left;
  194. color: #333333;
  195. display: -webkit-box;
  196. word-break: break-all;
  197. text-overflow: ellipsis;
  198. overflow: hidden;
  199. -webkit-box-orient: vertical;
  200. -webkit-line-clamp:2;
  201. }
  202. .wen_num{
  203. margin-left: 56rpx;
  204. width: 590rpx;
  205. font-size: 28rpx;
  206. font-family: PingFang SC, PingFang SC-Regular;
  207. font-weight: 400;
  208. text-align: left;
  209. color: #0084ff;
  210. }
  211. .wdflex{
  212. display: flex;
  213. justify-content: flex-start;
  214. flex-direction: row;
  215. margin-top: 24rpx;
  216. }
  217. .submitbtn{
  218. width: 700rpx;
  219. height: 80rpx;
  220. background: #46a6ff;
  221. border-radius: 40rpx;
  222. text-align: center;
  223. font-size: 28rpx;
  224. font-family: PingFang SC, PingFang SC-Medium;
  225. font-weight: 500;
  226. color: #ffffff;
  227. line-height: 80rpx;
  228. position: fixed;
  229. bottom: 10rpx;
  230. left: 26rpx;
  231. }
  232. </style>