user.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <view class="">
  3. <view class="bg-grey">
  4. <view class="flex align-center">
  5. <view class="flex justify-center align-center avatar margin">
  6. <image :src="avatar" mode="aspectFit"></image>
  7. </view>
  8. <view class="flex-sub flex justify-between">
  9. <text>{{user_info.nickname}}</text>
  10. </view>
  11. </view>
  12. <view class="padding">
  13. <text>{{user_info.doodling}}</text>
  14. </view>
  15. <view class="flex padding-bottom">
  16. <view class="margin-left" @click="toFlow">
  17. <text class="text-lg margin-right-sm">{{follow}}</text>
  18. <text>关注</text>
  19. </view>
  20. <view class="margin-left" @click="toFans">
  21. <text class="text-lg margin-right-sm">{{fans}}</text>
  22. <text>粉丝</text>
  23. </view>
  24. <view class="margin-left">
  25. <text class="text-lg margin-right-sm"> {{fabulous}}</text>
  26. <text>获赞</text>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="flex justify-center align-center">
  31. <view class="margin" v-for="(item,index) in tabs" :key='index' @click="changeTab(index)">
  32. <text :class="active == index?'text-lg text-bold':''">{{item}}</text>
  33. </view>
  34. </view>
  35. <view v-if="active == 0" class="video-list">
  36. <view class="video-item flex-direction bg-gray flex shadow shadow-blur" v-for="(item,index) in list"
  37. :key="index" @click="toDetail(item.id)">
  38. <view class="cover">
  39. <image :src="static_url + item.gif" mode="aspectFill"></image>
  40. </view>
  41. <view class="padding-left">
  42. <text class="text-cut">{{item.title}}</text>
  43. </view>
  44. <view class="padding-left padding-right flex justify-between">
  45. <text>{{timestampFormat(item.createtime)}}</text>
  46. <view class="">
  47. <text class="text-orange"></text>
  48. <text class="margin-left-sm">{{item.fabulous}}</text>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <view v-if="active == 1" class="video-list">
  54. <view class="video-item flex-direction bg-gray flex shadow shadow-blur" v-for="(item,index) in list"
  55. :key="index" @click="toDetail(item.share_id)">
  56. <view class="cover">
  57. <image :src="static_url + item.gif" mode="aspectFill"></image>
  58. </view>
  59. <view class="padding-left">
  60. <text class="text-cut">{{item.title}}</text>
  61. </view>
  62. <view class="padding-left padding-right flex justify-between">
  63. <text>{{timestampFormat(item.createtime)}}</text>
  64. <view class="">
  65. <text class="cuIcon-likefill text-orange"></text>
  66. <text class="margin-left-sm">{{item.fabulous}}</text>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. <view v-if="active == 2" class="margin-left margin-right">
  72. <view class="bg-gray flex align-center shadow shadow-blur" v-for="(item,index) in list" :key="index">
  73. <view class="comment-cover margin-sm">
  74. <image :src="static_url + item.gif" mode="aspectFill"></image>
  75. </view>
  76. <view class="flex-sub">
  77. <text class="text-cut">{{item.content}}</text>
  78. <view class="padding-right flex justify-between">
  79. <text>{{timestampFormat(item.createtime)}}</text>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </template>
  86. <script>
  87. import _data from "@/common/_data";
  88. import _get from "@/common/_get.js";
  89. import _action from '@/common/_action.js'
  90. export default {
  91. data() {
  92. return {
  93. user_info: {},
  94. fabulous: 0,
  95. follow: 0,
  96. fans: 0,
  97. static_photo: '',
  98. static_url: '',
  99. avatar:'',
  100. tabs: [
  101. '作品',
  102. '喜欢',
  103. '评论'
  104. ],
  105. active: 0,
  106. list: [], //列表
  107. user_id: '',
  108. page: 1,
  109. my_data: {}, //我
  110. }
  111. },
  112. onPullDownRefresh() {
  113. uni.startPullDownRefresh();
  114. this.getInfo(this.user_id);
  115. },
  116. onLoad(option) {
  117. this.user_id = option.id;
  118. this.static_photo = _data.staticPhoto();
  119. this.static_url = _data.staticUrl();
  120. this.getUserInfo();
  121. this.getInfo(option.id);
  122. this.changeTab(this.active);
  123. },
  124. onReachBottom() {
  125. if (this.active == 0) {
  126. this.get_video_list();
  127. }
  128. if (this.active == 1) {
  129. this.get_fabulous_log();
  130. }
  131. if (this.active == 2) {
  132. this.get_comment_log();
  133. }
  134. },
  135. methods: {
  136. getUserInfo() {
  137. let _this = this;
  138. _get.getUserInfo({}, function(data) {
  139. _this.my_data = data;
  140. });
  141. },
  142. toFans() {
  143. // console.log("this.my_data.id", this.my_data);
  144. // console.log("this.user_id", this.user_id);
  145. if (this.my_data.id == this.user_id) {
  146. uni.navigateTo({
  147. url: './fans',
  148. })
  149. }
  150. },
  151. toFlow() {
  152. if (this.my_data.id == this.user_id) {
  153. uni.navigateTo({
  154. url: './flow',
  155. })
  156. }
  157. },
  158. toDetail(id) {
  159. console.log("id", id);
  160. uni.navigateTo({
  161. url: './detail?id=' + id,
  162. })
  163. },
  164. timestampFormat(time) {
  165. return _action.timestampFormat(time);
  166. },
  167. changeTab(index) {
  168. this.active = index;
  169. this.page = 1;
  170. this.list = [];
  171. if (this.active == 0) {
  172. this.get_video_list();
  173. }
  174. if (this.active == 1) {
  175. this.get_fabulous_log();
  176. }
  177. if (this.active == 2) {
  178. this.get_comment_log();
  179. }
  180. },
  181. get_video_list() {
  182. this.$httpSend({
  183. path: "/im/video.Share/user_video",
  184. data: {
  185. user_id: this.user_id,
  186. page: this.page,
  187. },
  188. success: (res) => {
  189. if (res.data.length) {
  190. this.page++;
  191. }
  192. console.log("res", res);
  193. this.list = [...this.list, ...res.data];
  194. }
  195. })
  196. },
  197. get_comment_log() {
  198. this.$httpSend({
  199. path: "/im/video.Share/common_log",
  200. data: {
  201. user_id: this.user_id,
  202. page: this.page,
  203. },
  204. success: (res) => {
  205. if (res.data.length) {
  206. this.page++;
  207. }
  208. console.log("res", res);
  209. this.list = [...this.list, ...res.data];
  210. }
  211. })
  212. },
  213. get_fabulous_log() {
  214. this.$httpSend({
  215. path: "/im/video.Share/fabulous_log",
  216. data: {
  217. user_id: this.user_id,
  218. page: this.page,
  219. },
  220. success: (res) => {
  221. if (res.data.length) {
  222. this.page++;
  223. }
  224. console.log("res", res);
  225. this.list = [...this.list, ...res.data];
  226. }
  227. })
  228. },
  229. getInfo(id) {
  230. const _this = this;
  231. _this.$httpSend({
  232. path: "/im/video.Share/user_info",
  233. data: {
  234. user_id: this.user_id,
  235. },
  236. success: (res) => {
  237. console.log("res", res);
  238. _this.user_info = res.user_info;
  239. _this.fabulous = res.fabulous;
  240. _this.follow = res.follow;
  241. _this.fans = res.fans;
  242. _this.avatar = _this.static_photo + _this.user_info.face
  243. uni.stopPullDownRefresh();
  244. }
  245. })
  246. },
  247. },
  248. }
  249. </script>
  250. <style scoped lang="scss">
  251. @import '@/static/css/colorui/main.css';
  252. @import '@/static/css/colorui/icon.css';
  253. .comment-cover {
  254. width: 160rpx;
  255. height: 160rpx;
  256. image {
  257. width: 100%;
  258. height: 100%;
  259. background: #fff;
  260. }
  261. }
  262. .video-list {
  263. box-sizing: border-box;
  264. display: flex;
  265. justify-content: space-between;
  266. flex-wrap: wrap;
  267. padding: 0 20rpx;
  268. .video-item {
  269. flex-shrink: 0;
  270. width: 48%;
  271. border-radius: 20rpx;
  272. margin-bottom: 20rpx;
  273. .cover {
  274. border-radius: 10rpx;
  275. display: flex;
  276. justify-content: center;
  277. align-items: center;
  278. }
  279. }
  280. }
  281. page {
  282. background: #fff;
  283. }
  284. .avatar {
  285. background: #eee;
  286. width: 160rpx;
  287. height: 160rpx;
  288. overflow: hidden;
  289. border-radius: 50%;
  290. }
  291. </style>