discussionArea.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <view class="discussion-page">
  3. <!-- 项目卡片 -->
  4. <view class="project-card">
  5. <image class="project-img" :src="articleInfo.main_image" />
  6. <view class="project-info">
  7. <view class="project-title two-omit">{{ articleInfo.title }}</view>
  8. </view>
  9. </view>
  10. <view class="tabs">
  11. <view class="tab-item" @click="checkTab(item.id)" v-for="(item, index) in cate" :key="index">
  12. <view class="tab" :class="{ active: tab === item.id }">
  13. <text class="left">{{ item.name }}</text>
  14. <view class="line"></view>
  15. </view>
  16. </view>
  17. </view>
  18. <view v-if="tab === 1" class="update-list">
  19. <block v-for="(item, idx) in projectUpdate" :key="idx">
  20. <view class="update-item" @click="goPages('/pages/crowdFunding/projectUpdateDetails?id=' + item.id)">
  21. <view class="update-title">第{{ item.numb }}次更新</view>
  22. <view class="update-content" >{{ item.title }}</view>
  23. <view class="update-user">
  24. <image class="avatar" :src="articleInfo.creator_avatar" />
  25. <text class="nickname">{{ articleInfo.creator_nickname }}</text>
  26. </view>
  27. <image class="update-img" :src="item.image" mode="widthFix" />
  28. <view class="update-footer">
  29. <text class="update-time">{{ item.create_time }}</text>
  30. <view class="update-like">
  31. <!-- <image :src="item.liked ? '/static/icon/icon-18.png' : '/static/icon/icon-19.png'"
  32. class="like-icon" />
  33. <text class="like-num">{{ item.likeNum }}</text> -->
  34. </view>
  35. </view>
  36. </view>
  37. </block>
  38. </view>
  39. <!-- 评论区域 -->
  40. <CommentSection v-else-if=" articleInfo&&articleInfo.is_like != 'undefined'" class="comment" ref="commentSection" :articleId="id"
  41. @totalNumberOfComments="totalNumberOfComments" :articleInfo="articleInfo" :myInfo="myInfo" :author="author"
  42. find="crowdfund" type="crowdfund">
  43. </CommentSection>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {
  50. tab: 1,
  51. id: 0,
  52. projectUpdate: [
  53. ],
  54. cate: [
  55. {
  56. name: "项目更新",
  57. id: 1,
  58. },
  59. {
  60. name: "项目讨论",
  61. id: 2,
  62. },
  63. ],
  64. myInfo: {
  65. user_id: getApp().globalData.user_id, // 用户id
  66. user_name: getApp().globalData.nickname, // 用户名
  67. user_avatar: getApp().globalData.avator, // 用户头像地址
  68. },
  69. articleInfo: {},
  70. type: 'crowdfund',
  71. find: 'crowdfund',
  72. author: {
  73. }
  74. }
  75. },
  76. onLoad(options) {
  77. if (options.tags) {
  78. this.tab = options.tags === 'update' ? 1 : options.tags === 'comment' ? 2 : 1;
  79. }
  80. if (options.id) {
  81. this.id = options.id;
  82. }
  83. this.getDetails()
  84. },
  85. methods: {
  86. checkTab(tab) {
  87. this.tab = tab;
  88. },
  89. totalNumberOfComments(tableTotal) {
  90. this.tableTotal = tableTotal;
  91. },
  92. getDetails() {
  93. uni.request({
  94. url: this.$apiHost + '/crowdfund/detail',
  95. method: 'GET',
  96. data: {
  97. id: this.id,
  98. uuid: getApp().globalData.uuid,
  99. skey: getApp().globalData.skey
  100. },
  101. success: (res) => {
  102. if (res.data && res.data.success === 'yes' && res.data.data) {
  103. this.articleInfo = res.data.data
  104. this.author = {
  105. "id": res.data.data.creator_id,
  106. "nickname": res.data.data.creator_nickname,
  107. "avator": res.data.data.creator_avatar,
  108. }
  109. }
  110. }
  111. });
  112. uni.request({
  113. url: this.$apiHost + '/crowdfund/articles',
  114. method: 'GET',
  115. data: {
  116. crowdfund_id: this.id,
  117. uuid: getApp().globalData.uuid,
  118. skey: getApp().globalData.skey
  119. },
  120. success: (res) => {
  121. if (res.data && res.data.success === 'yes' && res.data.data) {
  122. if (Array.isArray(res.data.data.list)) {
  123. this.projectUpdate = res.data.data.list.map(item => ({
  124. ...item,
  125. create_time: item.create_time.replace(/-/g, '.').slice(0, 16)
  126. }));
  127. }
  128. }
  129. }
  130. });
  131. uni.request({
  132. url: this.$apiHost + '/crowdfund/favorite/status',
  133. method: 'GET',
  134. data: {
  135. crowdfund_id: this.id,
  136. uuid: getApp().globalData.uuid,
  137. skey: getApp().globalData.skey
  138. },
  139. success: (res) => {
  140. if (res.data && res.data.success === 'yes' && res.data.data) {
  141. console.log(res.data.data, "收藏");
  142. console.log( res.data.data.is_favorited ,89798789);
  143. this.articleInfo.is_like= res.data.data.is_favorited;
  144. // 可根据接口返回字段设置isFavorite等
  145. }
  146. }
  147. });
  148. },
  149. goPages(url) {
  150. uni.navigateTo({
  151. url: url
  152. })
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. .discussion-page {
  159. min-height: 100vh;
  160. background: #f2f6f2;
  161. padding-bottom: 40rpx;
  162. .project-card {
  163. display: flex;
  164. align-items: center;
  165. background: #fff;
  166. width: 100vw;
  167. height: 184rpx;
  168. border-bottom: 1px solid #F2F6F2;
  169. padding: 28rpx;
  170. .project-img {
  171. width: 128rpx;
  172. height: 128rpx;
  173. border-radius: 6rpx;
  174. margin-right: 16rpx;
  175. }
  176. .project-title {
  177. font-size: 28rpx;
  178. font-weight: bold;
  179. color: #222;
  180. max-width: 500rpx;
  181. overflow: hidden;
  182. text-overflow: ellipsis;
  183. line-height: 2;
  184. }
  185. }
  186. .tabs {
  187. display: flex;
  188. height: 72rpx;
  189. justify-content: space-between;
  190. align-items: center;
  191. width: 100%;
  192. background: #fff;
  193. margin-bottom: 6rpx;
  194. .tab-item {
  195. width: 50%;
  196. display: flex;
  197. align-items: center;
  198. justify-content: center;
  199. .tab {
  200. position: relative;
  201. // width: 96rpx;
  202. width: 130rpx;
  203. height: 48rpx;
  204. font-size: 32rpx;
  205. font-family: "PingFang SC-Bold";
  206. color: #999;
  207. font-weight: 400;
  208. transition: all .5s;
  209. ::after {
  210. content: "";
  211. position: absolute;
  212. right: -15rpx;
  213. top: 0;
  214. width: 96rpx;
  215. height: 48rpx;
  216. background-image: url("../../static/me/wd_img_qiehuan.png");
  217. background-size: auto 100%;
  218. background-repeat: no-repeat;
  219. opacity: 0;
  220. }
  221. &.active {
  222. color: #1f1f1f;
  223. text {
  224. font-family: "PingFang SC-Bold";
  225. }
  226. ::after {
  227. opacity: 0.7;
  228. }
  229. }
  230. }
  231. }
  232. }
  233. .update-list {
  234. padding: 0 24rpx;
  235. .update-item {
  236. background: #fff;
  237. border-radius: 16rpx;
  238. margin-bottom: 24rpx;
  239. padding: 18rpx 20rpx 12rpx 20rpx;
  240. .update-title {
  241. font-size: 24rpx;
  242. color: #999;
  243. margin-bottom: 8rpx;
  244. }
  245. .update-content {
  246. font-size: 28rpx;
  247. color: #222;
  248. margin-bottom: 12rpx;
  249. }
  250. .update-user {
  251. display: flex;
  252. align-items: center;
  253. margin-bottom: 12rpx;
  254. .avatar {
  255. width: 36rpx;
  256. height: 36rpx;
  257. border-radius: 50%;
  258. margin-right: 8rpx;
  259. }
  260. .nickname {
  261. font-size: 22rpx;
  262. color: #999;
  263. }
  264. }
  265. .update-img {
  266. width: 100%;
  267. height: 160rpx;
  268. border-radius: 12rpx;
  269. object-fit: cover;
  270. margin-bottom: 10rpx;
  271. }
  272. .update-footer {
  273. display: flex;
  274. align-items: center;
  275. justify-content: space-between;
  276. .update-time {
  277. font-size: 22rpx;
  278. color: #999;
  279. }
  280. .update-like {
  281. display: flex;
  282. align-items: center;
  283. .like-icon {
  284. width: 28rpx;
  285. height: 28rpx;
  286. margin-right: 4rpx;
  287. }
  288. .like-num {
  289. font-size: 22rpx;
  290. color: #888;
  291. }
  292. }
  293. }
  294. }
  295. }
  296. .comment {
  297. background: #fff;
  298. border-top-left-radius: 32rpx;
  299. border-top-right-radius: 32rpx;
  300. }
  301. }
  302. </style>