user.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <view>
  3. <!-- 顶部导航 -->
  4. <fa-navbar :title="userInfo.nickname || '用户'" :border-bottom="false"></fa-navbar>
  5. <!-- 会员中心 -->
  6. <view class="u-p-t-30 u-p-b-50 home" :style="[{ backgroundColor: theme.bgColor || '#374486' }]">
  7. <view class="userinfo">
  8. <u-avatar size="120" :show-sex="true" :sex-icon="userInfo.gender == 1 ? 'man' : 'woman'" :src="url || userInfo.avatar"></u-avatar>
  9. <view class="u-m-t-10 u-p-l-80 u-p-r-80 u-line-1">{{ userInfo.nickname || '' }}</view>
  10. <view class="u-m-t-10 u-p-l-80 u-p-r-80 u-line-2">{{ userInfo.bio || '这家伙很懒,什么也没写!' }}</view>
  11. </view>
  12. <view class="corrugated">
  13. <view class="wave-top wave-item" :style="[{ backgroundImage: 'url(' + wavetop + ')' }]"></view>
  14. <view class="wave-middle wave-item" :style="[{ backgroundImage: 'url(' + wavemiddle + ')' }]"></view>
  15. <view class="wave-bottom wave-item" :style="[{ backgroundImage: 'url(' + wavebottom + ')' }]"></view>
  16. </view>
  17. </view>
  18. <!-- 他的文章和评论 -->
  19. <!-- #ifdef MP-BAIDU -->
  20. <fa-u-tabs :list="tableList" :active-color="theme.bgColor" :bar-width="tabwidth" :is-scroll="false" :current="current" @change="change"></fa-u-tabs>
  21. <!-- #endif -->
  22. <!-- #ifndef MP-BAIDU -->
  23. <u-tabs :list="tableList" :active-color="theme.bgColor" :bar-width="tabwidth" :is-scroll="false" :current="current" @change="change"></u-tabs>
  24. <!-- #endif -->
  25. <u-gap height="1" bg-color="#f4f6f8"></u-gap>
  26. <u-gap height="30" bg-color="#fff"></u-gap>
  27. <view class="" v-if="current">
  28. <view class="comment" v-for="(res, index) in list" :key="res.id" @click="goDetail(res.archives)">
  29. <view class="left"><image :src="res.archives && res.archives.image" mode="aspectFill"></image></view>
  30. <view class="right">
  31. <view class="content u-line-2">{{ res.archives && res.archives.title }}</view>
  32. <view class="reply-box">
  33. <view class="item">
  34. <view class="u-tips-color"><rich-text :nodes="res.content"></rich-text></view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="" v-else>
  41. <view class="list u-bg-white">
  42. <view class="item u-flex u-p-30 u-border-bottom" v-for="(item, index) in list" :key="index" @click="goDetail(item)">
  43. <view class=""><u-image width="300rpx" border-radius="10" height="225rpx" :src="item.image"></u-image></view>
  44. <view class="u-m-l-20 content">
  45. <view class="u-text-weight">
  46. <text class="u-line-2">{{ item.title }}</text>
  47. </view>
  48. <view class="u-p-t-15 u-flex">
  49. <view class="u-m-r-10" v-for="(it, idx) in item.taglist" :key="idx">
  50. <u-tag :text="it.name" shape="circle" :bg-color="lightColor" :border-color="faBorderColor" :color="theme.bgColor" />
  51. </view>
  52. </view>
  53. <view class="u-p-t-15 u-tips-color u-line-2">{{ item.description }}</view>
  54. <view class="u-p-t-15 u-tips-color">{{ item.createtime | timeFrom('yyyy-mm-dd') }}</view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <!-- 回到顶部 -->
  60. <u-back-top :scroll-top="scrollTop" :icon-style="{ color: theme.bgColor }" :custom-style="{ backgroundColor: lightColor }"></u-back-top>
  61. <!-- 加载更多 -->
  62. <view class="u-p-30" v-if="list.length"><u-loadmore bg-color="#ffffff" :status="status" /></view>
  63. <!-- 底部导航 -->
  64. <fa-tabbar></fa-tabbar>
  65. </view>
  66. </template>
  67. <script>
  68. import { avatar } from '@/common/fa.mixin.js';
  69. export default {
  70. mixins: [avatar],
  71. computed: {
  72. wavetop() {
  73. return this.$u.http.config.baseUrl + '/assets/addons/cms/img/wave-top.png';
  74. },
  75. wavemiddle() {
  76. return this.$u.http.config.baseUrl + '/assets/addons/cms/img/wave-mid.png';
  77. },
  78. wavebottom() {
  79. return this.$u.http.config.baseUrl + '/assets/addons/cms/img/wave-bot.png';
  80. },
  81. isBind() {
  82. return false;
  83. }
  84. },
  85. onLoad(e) {
  86. let query = this.$Route.query || e || {};
  87. this.user_id = query.user_id || query.uid || '';
  88. this.getUserIndex();
  89. },
  90. data() {
  91. return {
  92. url: '',
  93. tabwidth: 150,
  94. userInfo: {},
  95. user_id: 0,
  96. tableList: [
  97. {
  98. name: `他的文章(0)`,
  99. type: 'archives'
  100. },
  101. {
  102. name: `他的评论(0)`,
  103. type: 'comments'
  104. }
  105. ],
  106. current: 0,
  107. list: [],
  108. is_update: false,
  109. has_more: false,
  110. status: 'nomore',
  111. scrollTop: 0,
  112. page: 1
  113. };
  114. },
  115. methods: {
  116. goDetail(item) {
  117. if(item.model_id==2){
  118. this.$Router.push({
  119. path: '/pages/product/detail',
  120. query: { id: item.id }
  121. });
  122. }else{
  123. this.$Router.push({
  124. path: '/pages/article/detail',
  125. query: { id: item.id }
  126. });
  127. }
  128. },
  129. getUserIndex() {
  130. this.$api
  131. .getUserInfo({
  132. user_id: this.user_id,
  133. type: this.tableList[this.current].type,
  134. page: this.page
  135. })
  136. .then(res => {
  137. if(!res.code){
  138. this.$u.toast(res.msg);
  139. setTimeout(()=>{
  140. uni.navigateBack({
  141. delta:1
  142. })
  143. },1000)
  144. return;
  145. }
  146. this.status = 'nomore';
  147. if (this.is_update) {
  148. this.is_update = false;
  149. this.list = [];
  150. }
  151. this.tableList = [
  152. {
  153. name: `他的文章(${res.data.archives})`,
  154. type: 'archives'
  155. },
  156. {
  157. name: `他的评论(${res.data.comments})`,
  158. type: 'comments'
  159. }
  160. ];
  161. this.userInfo = res.data.user;
  162. this.list = [...this.list, ...res.data.list.data];
  163. this.has_more = res.data.list.last_page > res.data.list.current_page;
  164. });
  165. },
  166. change(index) {
  167. this.tabwidth = this.$util.strlen(this.tableList[index].name) * 30;
  168. this.current = index;
  169. this.page = 1;
  170. this.is_update = true;
  171. this.getUserIndex();
  172. }
  173. },
  174. onPageScroll(e) {
  175. this.scrollTop = e.scrollTop;
  176. },
  177. onReachBottom() {
  178. if (this.has_more) {
  179. this.status = 'loading';
  180. this.page++;
  181. this.getUserIndex();
  182. }
  183. }
  184. };
  185. </script>
  186. <style>
  187. page {
  188. background-color: #ffffff;
  189. }
  190. </style>
  191. <style lang="scss" scoped>
  192. .home {
  193. position: relative;
  194. .userinfo {
  195. display: flex;
  196. flex-direction: column;
  197. align-items: center;
  198. padding: 30rpx 0;
  199. z-index: 100;
  200. height: 310rpx;
  201. color: #ffffff;
  202. }
  203. .corrugated {
  204. bottom: -2rpx;
  205. left: 0;
  206. position: absolute;
  207. width: 100%;
  208. height: 50%;
  209. overflow: hidden;
  210. z-index: 0;
  211. .wave-item {
  212. position: absolute;
  213. width: 200%;
  214. left: 0;
  215. height: 200rpx;
  216. background-repeat: repeat no-repeat;
  217. background-position: 0 bottom;
  218. transform-origin: center bottom;
  219. }
  220. .wave-top {
  221. opacity: 0.5;
  222. animation: wave-animation 3s;
  223. animation-delay: 1s;
  224. background-size: 50% 60rpx;
  225. z-index: 15;
  226. }
  227. .wave-middle {
  228. opacity: 0.75;
  229. animation: wavemove 10s linear infinite;
  230. background-size: 50% 80rpx;
  231. z-index: 10;
  232. }
  233. .wave-bottom {
  234. animation: wavemove 15s linear infinite;
  235. background-size: 50% 45rpx;
  236. z-index: 5;
  237. }
  238. }
  239. }
  240. .comment {
  241. display: flex;
  242. padding: 30rpx;
  243. border-bottom: 1px solid #eee;
  244. .left {
  245. image {
  246. width: 180rpx;
  247. height: 130rpx;
  248. background-color: #f2f2f2;
  249. border-radius: 10rpx;
  250. }
  251. }
  252. .right {
  253. flex: 1;
  254. padding-left: 20rpx;
  255. font-size: 28rpx;
  256. .content {
  257. margin-bottom: 10rpx;
  258. }
  259. .reply-box {
  260. background-color: rgb(242, 242, 242);
  261. border-radius: 12rpx;
  262. .item {
  263. padding: 20rpx;
  264. word-break: break-word;
  265. }
  266. }
  267. }
  268. }
  269. @keyframes wavemove {
  270. 0% {
  271. transform: translateX(0) translateZ(0) scaleY(1);
  272. }
  273. 50% {
  274. transform: translateX(-25%) translateZ(0) scaleY(0.55);
  275. }
  276. 100% {
  277. transform: translateX(-50%) translateZ(0) scaleY(1);
  278. }
  279. }
  280. </style>