index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <template>
  2. <view class="container" :style="viewColor">
  3. <view class="header" :style="{ 'background-image': `url(${domain}/static/images/plant-header.png)`}">
  4. <view class="user_wrapper acea-row">
  5. <image :src="userInfo.avatar || '/static/images/f.png'" class="picture"></image>
  6. <view class="user_text">
  7. <view class="name acea-row">
  8. <text>{{userInfo.nickname || ''}}</text>
  9. <image v-if="userInfo.member_icon" class="level_icon" :src="userInfo.member_icon" alt="">
  10. </view>
  11. <view class="user_id">ID: {{userInfo.uid || ''}}</view>
  12. </view>
  13. </view>
  14. <view class="plant_info acea-row">
  15. <view class="count_wrapper acea-row">
  16. <navigator :url="userInfo.is_self ? '/pages/plantGrass/plant_user_attention/index' : ''" class="item" hover-class="none">
  17. <text>{{userInfo.focus}}</text>关注
  18. </navigator>
  19. <navigator :url="userInfo.is_self ? '/pages/plantGrass/plant_user_fans/index' : ''" class="item" hover-class="none">
  20. <text>{{userInfo.fans}}</text>粉丝
  21. </navigator>
  22. <view class="item">
  23. <text>{{userInfo.start}}</text>获赞
  24. </view>
  25. </view>
  26. <view v-if="!userInfo.is_self" @click.stop="followAuthor">
  27. <button v-if="!userInfo.is_start" class="follow_btn focus">
  28. <text class="iconfont icon-jiahao2"></text>关注
  29. </button>
  30. <button v-else class="follow_btn focused">已关注</button>
  31. </view>
  32. <view v-else>
  33. <navigator hover-class="none" url="/pages/plantGrass/plant_release/index" class="follow_btn focus">
  34. <text class="iconfont icon-fabu"></text>发布
  35. </navigator>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="main">
  40. <view v-if="userInfo.is_self" class="tab_count">
  41. <text @click.stop="changeTab(0)" :class="tab==0 ? 'on' : ''">作品</text>
  42. <text @click.stop="changeTab(1)" :class="tab==1 ? 'on' : ''">赞过</text>
  43. </view>
  44. <view class="tab-cont">
  45. <view v-if="goods.length > 0" class="goods-wrap">
  46. <view class="goods">
  47. <WaterfallsFlow :wfList='goods' :isAuth="1" :uid="parseInt(uid)" :tab="tab"/>
  48. </view>
  49. </view>
  50. <view v-if="goods.length == 0 && !loading" class="empty">
  51. <image :src="`${domain}/static/images/no_thing.png`"></image>
  52. <text>暂无内容哦~</text>
  53. </view>
  54. <view class='loadingicon acea-row row-center-wrapper'>
  55. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>
  56. <view class="end" :hidden="loading || goods.length == 0"><text :class="loaded ? 'loaded' : ''">{{loadTitle}}</text>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. // +----------------------------------------------------------------------
  65. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  66. // +----------------------------------------------------------------------
  67. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  68. // +----------------------------------------------------------------------
  69. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  70. // +----------------------------------------------------------------------
  71. // | Author: CRMEB Team <admin@crmeb.com>
  72. // +----------------------------------------------------------------------
  73. import WaterfallsFlow from '@/components/plantWaterfallsFlow/WaterfallsFlow.vue'
  74. import { userInfoApi, followAuthorApi, userArticleLst, starArticleLst } from '@/api/community.js';
  75. import { mapGetters } from "vuex";
  76. import { toLogin } from '@/libs/login.js';
  77. import { HTTP_REQUEST_URL } from '@/config/app';
  78. const app = getApp();
  79. export default {
  80. components: {
  81. WaterfallsFlow
  82. },
  83. data() {
  84. return {
  85. domain: HTTP_REQUEST_URL,
  86. goods: [], // 商铺商品
  87. loadTitle: '加载更多',
  88. loading: false,
  89. loaded: false,
  90. userInfo: {},
  91. where: {
  92. page: 1,
  93. limit: 30
  94. },
  95. tab: 0,
  96. uid: ''
  97. }
  98. },
  99. created() {},
  100. computed: {
  101. ...mapGetters(['isLogin','viewColor']),
  102. },
  103. watch: {},
  104. onLoad: function(options) {
  105. let that = this;
  106. that.uid = options.id
  107. if (that.isLogin) {
  108. that.getAuthorInfo(that.uid);
  109. that.getList(that.uid);
  110. } else {
  111. toLogin()
  112. }
  113. },
  114. onShow() {},
  115. onReady() {},
  116. mounted: function() {},
  117. methods: {
  118. /*获取用户信息*/
  119. getAuthorInfo(id){
  120. let that = this;
  121. userInfoApi(id).then(res => {
  122. that.userInfo = res.data
  123. });
  124. },
  125. // 关注作者
  126. followAuthor: function() {
  127. if (this.isLogin === false) {
  128. toLogin()
  129. } else {
  130. let status = this.userInfo.is_start ? false : true
  131. followAuthorApi(this.userInfo.uid,{status: status}).then(res => {
  132. if (res.status === 200) {
  133. this.userInfo.is_start = this.userInfo.is_start ? false : true
  134. }
  135. this.$util.Tips({
  136. title: res.message
  137. });
  138. });
  139. }
  140. },
  141. changeTab(tab){
  142. this.tab = tab
  143. this.where.page = 1
  144. this.loaded = this.loading = false
  145. this.goods = []
  146. let uid = this.userInfo.is_self ? this.uid : this.userInfo.uid
  147. this.getList(uid)
  148. },
  149. // 获取用户的作品
  150. getList: function(uid) {
  151. let that = this;
  152. if (that.loaded || that.loading) return;
  153. that.loading = true;
  154. that.loadTitle = '';
  155. that.tab == 1 ? this.where.is_type = 1 : this.where.is_type = ''
  156. that.tab == 0 ?
  157. userArticleLst(uid,that.where).then(res => {
  158. let list = res.data.list;
  159. let goods = that.$util.SplitArray(list, that.goods);
  160. that.loaded = list.length < that.where.limit;
  161. that.loading = false;
  162. that.loadTitle = that.loaded ? '到底了' : '加载更多';
  163. that.$set(that, 'goods', goods);
  164. that.$set(that.where, 'page', that.where.page + 1);
  165. }).catch(err => {
  166. that.loading = false;
  167. uni.showToast({
  168. title: err,
  169. icon: 'none'
  170. })
  171. }) :
  172. starArticleLst(that.where).then(res => {
  173. that.loading = false;
  174. let list = res.data.list;
  175. let goods = that.$util.SplitArray(list, that.goods);
  176. that.loaded = list.length < that.where.limit;
  177. that.loading = false;
  178. that.loadTitle = that.loaded ? '到底了' : '加载更多';
  179. that.$set(that, 'goods', goods);
  180. that.$set(that.where, 'page', that.where.page + 1);
  181. }).catch(err => {
  182. that.loading = false;
  183. uni.showToast({
  184. title: err,
  185. icon: 'none'
  186. })
  187. })
  188. }
  189. },
  190. onReachBottom() {
  191. let uid = this.userInfo.is_self ? this.uid : this.userInfo.uid
  192. this.getList(uid);
  193. },
  194. onPullDownRefresh(){},
  195. // 滚动监听
  196. onPageScroll(e) {
  197. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  198. uni.$emit('scroll');
  199. }
  200. }
  201. </script>
  202. <style lang="scss" scoped>
  203. .container{
  204. background: #ffffff;
  205. min-height: 100vh;
  206. }
  207. .header{
  208. width: 750rpx;
  209. height: 400rpx;
  210. padding: 56rpx 30rpx 0;
  211. background-repeat: no-repeat;
  212. background-size: 100%;
  213. .user_wrapper{
  214. align-items: center;
  215. .image,uni-image,image{
  216. width: 140rpx;
  217. height: 140rpx;
  218. border-radius: 100%;
  219. border: 4rpx solid #ffffff;
  220. }
  221. .user_text{
  222. margin-left: 22rpx;
  223. color: #FFFFFF;
  224. .name{
  225. font-size: 34rpx;
  226. font-weight: bold;
  227. align-items: center;
  228. }
  229. .user_id{
  230. margin-top: 16rpx;
  231. font-size: 24rpx;
  232. }
  233. .level_icon{
  234. width: 34rpx;
  235. height: 32rpx;
  236. margin: 4rpx 0 0 6rpx;
  237. border: none;
  238. }
  239. }
  240. }
  241. .plant_info{
  242. margin-top: 60rpx;
  243. align-items: center;
  244. justify-content: space-between;
  245. .count_wrapper{
  246. color: #FFFFFF;
  247. font-size: 24rpx;
  248. .item{
  249. text-align: center;
  250. margin-right: 60rpx;
  251. &:last-child{
  252. margin-right: 0;
  253. }
  254. text{
  255. display: block;
  256. font-size: 30rpx;
  257. margin-top: 10rpx;
  258. }
  259. }
  260. }
  261. }
  262. .follow_btn{
  263. color: #ffffff;
  264. font-size: 26rpx;
  265. display: flex;
  266. align-items: center;
  267. justify-content: center;
  268. width: 146rpx;
  269. height: 62rpx;
  270. background-color: transparent;
  271. background-image: linear-gradient(270deg, var(--view-bntColor21) 0%, var(--view-bntColor22) 100%);
  272. border-radius: 33rpx;
  273. .iconfont{
  274. font-size: 16rpx;
  275. margin-right: 12rpx;
  276. }
  277. .icon-fabu{
  278. font-size: 24rpx;
  279. }
  280. &.focused{
  281. background: transparent;
  282. color: #FFFFFF;
  283. border: 1px solid #FFFFFF;
  284. }
  285. }
  286. }
  287. .main {
  288. background: #ffffff;
  289. padding: 30rpx 0;
  290. border-radius: 24rpx 24rpx 0 0;
  291. position: relative;
  292. top: -20rpx;
  293. .tab_count{
  294. margin-bottom: 40rpx;
  295. text-align: center;
  296. text{
  297. font-size: 28rpx;
  298. color: #999999;
  299. margin: 0 30rpx;
  300. position: relative;
  301. padding-bottom: 10rpx;
  302. &.on{
  303. font-size: 32rpx;
  304. color: #282828;
  305. font-weight: bold;
  306. &::after{
  307. content: "";
  308. width: 40rpx;
  309. height: 5rpx;
  310. background: var(--view-theme);
  311. position: absolute;
  312. bottom: 0;
  313. left: 10rpx;
  314. }
  315. }
  316. }
  317. }
  318. }
  319. .goods {
  320. display: flex;
  321. flex-wrap: wrap;
  322. justify-content: space-between;
  323. width: 750rpx;
  324. padding: 0 20rpx;
  325. }
  326. .empty{
  327. margin: 130rpx 0 150rpx;
  328. text-align: center;
  329. image,uni-image{
  330. display: inline-block;
  331. width: 414rpx;
  332. height: 305rpx;
  333. }
  334. text{
  335. display: block;
  336. color: #999999;
  337. font-size: 26rpx;
  338. }
  339. }
  340. .end{
  341. margin-top: 50rpx 0;
  342. text-align: center;
  343. text{
  344. color: #999999;
  345. font-size: 22rpx;
  346. position: relative;
  347. &.loaded{
  348. &::before,&::after{
  349. content: "";
  350. display: inline-block;
  351. width: 22rpx;
  352. height: 1rpx;
  353. background: #999999;
  354. position: absolute;
  355. top: 18rpx;
  356. opacity: .5;
  357. }
  358. &::before{
  359. left: -30rpx;
  360. }
  361. &::after{
  362. right: -30rpx;
  363. }
  364. }
  365. }
  366. }
  367. </style>