index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <view class="container">
  3. <u-sticky bgColor="#F8F8F8">
  4. <view class="top"> </view>
  5. <u-tabs :list="list1" lineWidth="30" lineColor="#f56c6c" @change='tabChange' :activeStyle="{
  6. color: '#303133',
  7. fontWeight: 'bold',
  8. transform: 'scale(1.05)',
  9. fontSize:'40rpx',
  10. fontStyle: 'italic'
  11. }" :inactiveStyle="{
  12. color: '#606266',
  13. transform: 'scale(1)'
  14. }" itemStyle=" padding-left: 15px; padding-right: 15px; height: 34px;">
  15. </u-tabs>
  16. <view class="top-bottom"> </view>
  17. </u-sticky>
  18. <view class="center-box">
  19. <view class="item-box" v-for="(item,index) of initList" :key='index'>
  20. <view class="item-top">
  21. <view class="top-left">
  22. <image class="img" :src="item.userDTO.avatar"></image>
  23. </view>
  24. <view class="top-right">
  25. <view class="right-title">{{ item.userDTO.nickname }}</view>
  26. <view class="right-address">2天前 {{ item.location }}</view>
  27. </view>
  28. </view>
  29. <u-line margin='10rpx 0'></u-line>
  30. <view class="item-center">
  31. <view class="center-text">
  32. {{ item.textContent }}
  33. </view>
  34. <view class="center-img-box">
  35. <image v-for="itm of item.resourceVos" class="center-img" :src="itm.resourceKey"></image>
  36. </view>
  37. </view>
  38. <view class="item-bottom">
  39. <view class="bottom-item">
  40. <u-icon :name="item.clickStatus == 0 ? 'thumb-up' : 'thumb-up-fill'" :size='iconSize'
  41. @click='handlerPraise(item)'></u-icon><span>{{ item.goodNum }}</span>
  42. </view>
  43. <view class="bottom-item" @click='communityShow = true'>
  44. <u-icon name="more-circle" :size='iconSize'></u-icon><span>{{ item.commentNum }}</span>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <empty v-if="initList.length == 0" />
  50. <view class="flex-box">
  51. <view class="flex" @click="handlerToPublish">
  52. <view class="flex-icon">
  53. <u-icon name="edit-pen" color='#fff' size='26'></u-icon>
  54. </view>
  55. <view class=""> 发布 </view>
  56. </view>
  57. </view>
  58. <u-popup :show="communityShow" @close="communityShow = false" mode='bottom' overlayOpacity='0.1' round="20">
  59. <view class="pop-box">
  60. <communityPop />
  61. </view>
  62. </u-popup>
  63. <tabbar currentTab="clientCommunity" />
  64. </view>
  65. </template>
  66. <script>
  67. import {
  68. clientContentList,
  69. addEvaulateRecords
  70. } from '@/api/client/community.js';
  71. import {
  72. intervalTime
  73. } from "@/utils/tools.js"
  74. import communityPop from "@/components/communityPop/index.vue"
  75. import empty from "@/components/empty/index.vue"
  76. export default {
  77. components: {
  78. communityPop,
  79. empty
  80. },
  81. data() {
  82. return {
  83. communityShow: false,
  84. list1: [{
  85. name: '最新',
  86. type: 'LATEST',
  87. },
  88. {
  89. name: '关注',
  90. type: 'ATTENTION',
  91. },
  92. {
  93. name: '最热',
  94. type: 'HOTTEST',
  95. }
  96. ],
  97. iconSize: 24,
  98. duration: 700,
  99. params: {
  100. pageNum: 1,
  101. pageSize: 10,
  102. type: 'LATEST',
  103. keyWord: '',
  104. },
  105. initList: [], // 初始化列表
  106. }
  107. },
  108. onShow() {
  109. this.handlerInitList()
  110. // let a = intervalTime(1709797137000)
  111. },
  112. methods: {
  113. handlerInitList() {
  114. clientContentList(this.params).then(res => {
  115. this.initList = res.data.records
  116. })
  117. },
  118. // 选择时间
  119. // confirmTime(e) {
  120. // let time = new Date(e)
  121. // let year = time.getFullYear()
  122. // let month = time.getMonth() + 1
  123. // let date = time.getDate()
  124. // if (month < 10) {
  125. // month = '0' + month
  126. // }
  127. // if (date < 10) {
  128. // date = '0' + date
  129. // }
  130. // this.queryParams.birthday = year + '-' + month + '-' + date
  131. // },
  132. // 切换顶部tabbar
  133. tabChange(e) {
  134. this.params.type = e.type
  135. this.handlerInitList()
  136. },
  137. // 发布按钮
  138. handlerToPublish() {
  139. uni.navigateTo({
  140. url: "/pages/client/clientPackage/communityPublish"
  141. })
  142. },
  143. // 点赞按钮
  144. handlerPraise(item) {
  145. let params = {
  146. dynamicStatusType: item.clickStatus == 0 ? 'GOOD' : 'BAD', // 操作类型:1-点赞;2-踩 允许值: GOOD, BAD
  147. recordType: 'DYNAMIC', // 内容类型:1-动态;2-评论/回复 允许值: DYNAMIC, COMMENT, USER
  148. actionType: item.clickStatus == 0 ? 'ADD' : 'CANCEL', // 点击类型:1-点赞/踩;2-取消赞/取消踩 允许值: ADD, CANCEL
  149. contentId: item.id,
  150. targetUserId: item.userId
  151. }
  152. addEvaulateRecords(params).then(res => {
  153. if (res.code == 200) {
  154. uni.showToast({
  155. title:'点赞成功',
  156. icon:'none'
  157. })
  158. this.handlerInitList()
  159. }else{
  160. uni.showToast({
  161. title:res.msg,
  162. icon:'none'
  163. })
  164. return
  165. }
  166. })
  167. }
  168. }
  169. }
  170. </script>
  171. <style lang="scss" scoped>
  172. .container {
  173. background-color: #F8F8F8;
  174. min-height: calc(100vh);
  175. // padding: 0 0 40rpx;
  176. // box-sizing: border-box;
  177. .top {
  178. height: 100rpx;
  179. }
  180. .top-bottom {
  181. height: 20rpx;
  182. }
  183. .center-box {
  184. margin: 30rpx auto 0;
  185. width: 95%;
  186. font-size: 28rpx;
  187. .item-box {
  188. padding: 20rpx;
  189. border-radius: 20rpx;
  190. box-sizing: border-box;
  191. margin-bottom: 20rpx;
  192. box-shadow: 0 5rpx 15rpx 0 rgba(0, 0, 0, 0.2);
  193. background-color: #fff;
  194. .item-top {
  195. display: flex;
  196. align-items: center;
  197. .top-left {
  198. .img {
  199. width: 90rpx;
  200. height: 90rpx;
  201. border-radius: 50%;
  202. }
  203. }
  204. .top-right {
  205. margin-left: 20rpx;
  206. .right-title {
  207. font-weight: bold;
  208. font-size: 34rpx;
  209. }
  210. .right-address {
  211. color: #959595;
  212. font-style: italic;
  213. font-weight: bold;
  214. font-size: 24rpx;
  215. }
  216. }
  217. }
  218. .item-center {
  219. .center-text {
  220. font-size: 32rpx;
  221. }
  222. .center-img-box {
  223. margin-top: 20rpx;
  224. display: grid;
  225. grid-template-columns: 32% 32% 32%;
  226. gap: 4% 1%;
  227. .center-img {
  228. width: 200rpx;
  229. height: 200rpx;
  230. }
  231. }
  232. }
  233. .item-bottom {
  234. display: flex;
  235. margin-top: 40rpx;
  236. .bottom-item {
  237. display: flex;
  238. align-items: center;
  239. width: 20%;
  240. }
  241. }
  242. }
  243. }
  244. .flex-box {
  245. width: 120rpx;
  246. height: 120rpx;
  247. border-radius: 50%;
  248. background-color: #000;
  249. position: fixed;
  250. bottom: 15%;
  251. right: 5%;
  252. box-shadow: 0 5rpx 15rpx 0 rgba(0, 0, 0, 0.5);
  253. padding: 10rpx;
  254. box-sizing: border-box;
  255. text-align: center;
  256. .flex {
  257. color: #fff;
  258. font-size: 26rpx;
  259. font-weight: bold;
  260. .flex-icon {
  261. display: flex;
  262. justify-content: center;
  263. }
  264. }
  265. }
  266. }
  267. // ::v-deep .u-safe-area-inset-bottom{
  268. // padding-bottom: 0;
  269. // }
  270. </style>