top-creators.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <view class="contain">
  3. <view class="header">
  4. <image src="/static/image/common/grade-left.png" mode="" @click="$back()"></image>
  5. <div class="tabbar">
  6. <div class="tab" :class="{'active': tab == 1}" @click="changeTab(1)">
  7. {{ $t("game.lab") }}
  8. <div class="line"></div>
  9. </div>
  10. <div class="tab" :class="{'active': tab == 2}" @click="changeTab(2)">
  11. {{ $t('member.tab1') }}
  12. <div class="line"></div>
  13. </div>
  14. </div>
  15. </view>
  16. <div class="list">
  17. <div class="item" v-for="(item, index) in list" :key="item.id">
  18. <div class="img-box" @click="toUrlLive(item)">
  19. <u--image
  20. class="avatar"
  21. :src="item.avatar"
  22. shape="circle"
  23. width="96rpx"
  24. height="96rpx"
  25. ></u--image>
  26. <img v-if="item.islive == 1" class="img" src="/static/image/match/live-actives.png" alt="">
  27. <img v-else class="img" src="/static/image/match/live.png" alt="">
  28. </div>
  29. <div class="content">
  30. <div class="left">
  31. <div>{{ item.user_nickname }}</div>
  32. <div class="num">{{ $t('member.lab2') }}: {{ numberToK(item.attention) }}</div>
  33. </div>
  34. <view class="paid size28" v-if="item.is_attention == 1" @click="attention(item, index)">
  35. <!-- Followed -->
  36. {{ $t('member.lab') }}
  37. </view>
  38. <view class="guanzhu-box" v-if="item.is_attention == 0" @click="attention(item, index)">
  39. <image src="/static/image/match/guanzhu.png" mode="widthFix" class="guanzhu-icon mg-rt12"></image>
  40. <text class="size28 cfff">{{ $t('member.lab1') }}</text>
  41. </view>
  42. </div>
  43. </div>
  44. </div>
  45. <u-loadmore
  46. :status="status"
  47. fontSize="28"
  48. :line="true"
  49. :loading-text="statusType.loadingText"
  50. :loadmore-text="statusType.loadmoreText"
  51. :nomore-text="statusType.nomoreText"
  52. />
  53. </view>
  54. </template>
  55. <script>
  56. import { numberToK, parseTime } from '@/utils/util'
  57. export default {
  58. data() {
  59. return {
  60. type:0,
  61. list: [],
  62. statusType:{
  63. loadingText: this.$t('common.lab'),
  64. loadmoreText: this.$t('common.lab1'),
  65. nomoreText: this.$t('common.lab2')
  66. },
  67. status:'loadmore',
  68. tab: 1,
  69. pageNumber: 1
  70. }
  71. },
  72. onLoad(option) {
  73. this.type = option.type;
  74. this.getList()
  75. },
  76. // 触底触发
  77. onReachBottom() {
  78. if(this.status == 'loadmore'){
  79. this.pageNumber++;
  80. this.getList();
  81. }
  82. },
  83. // 下拉刷新
  84. onPullDownRefresh(){
  85. // 正常情况下接口返回应该很会很快。故意延迟调用,让用户有在刷新的体验感
  86. this.pageNumber = 1;
  87. this.status = 'loadmore';
  88. this.getList();
  89. setTimeout(res=>{
  90. uni.stopPullDownRefresh()
  91. },1500)
  92. },
  93. methods: {
  94. getList() {
  95. this.status= 'loading';
  96. this.getHistory()
  97. },
  98. getHistory() {
  99. let params = {
  100. page: this.pageNumber
  101. }
  102. if (this.tab == 2) {
  103. params.type = '2'
  104. }
  105. uni.$u.http.get('/api/game/users', {
  106. params
  107. }).then(res => {
  108. if (this.pageNumber == 1) {
  109. this.list = res.data || []
  110. } else {
  111. this.list = this.list.concat(res.data || [])
  112. }
  113. this.status = this.list.length == res.total ? 'nomore' : 'loadmore'
  114. })
  115. },
  116. changeTab(item){
  117. if (this.tab == item) {
  118. return
  119. }
  120. if (this.$store.state.isLogin != 1) {
  121. this.$toUrl('/pages/login/login')
  122. return
  123. }
  124. this.tab = item
  125. this.pageNumber = 1
  126. this.getList()
  127. },
  128. /* 关注 */
  129. attention(item, index) {
  130. if (this.$store.state.isLogin != 1) {
  131. this.$toUrl('/pages/login/login')
  132. return
  133. }
  134. uni.showLoading({
  135. title: this.$t('common.lab'),
  136. });
  137. uni.$u.http
  138. .post("/api/Member/attention", {
  139. id: item.id,
  140. })
  141. .then((res) => {
  142. if (this.tab == 1) {
  143. this.$set(this.list[index], 'attention', item.is_attention == 0 ? (item.attention + 1) : (item.attention - 1) )
  144. this.$set(this.list[index], 'is_attention', item.is_attention == 0 ? 1 : 0 )
  145. } else {
  146. this.pageNumber = 1
  147. this.getList()
  148. }
  149. }).finally(() => {
  150. uni.hideLoading();
  151. });
  152. },
  153. toUrlLive(item) {
  154. uni.navigateTo({
  155. url: `/pages/Match/member/usermanger?id=${item.id}`,
  156. });
  157. },
  158. numberToK(v) {
  159. return numberToK(v)
  160. },
  161. parseTime(t) {
  162. return parseTime(t, '{y}-{m}-{d} {h}:{i}')
  163. }
  164. },
  165. }
  166. </script>
  167. <style lang="scss" scoped>
  168. page {
  169. background-color: #F3F3F7;
  170. }
  171. .header {
  172. color: #fff;
  173. font-size: 34rpx;
  174. padding: 0 24rpx;
  175. position: sticky;
  176. top: 0;
  177. z-index: 10;
  178. background-color: #1D2550;
  179. display: flex;
  180. align-items: center;
  181. justify-content: center;
  182. image {
  183. position: absolute;
  184. left: 24rpx;
  185. top: 50%;
  186. transform: translateY(-50%);
  187. width: 60rpx;
  188. height: 60rpx;
  189. }
  190. .tabbar {
  191. width: 260px;
  192. display: flex;
  193. align-items: center;
  194. justify-content: center;
  195. .tab {
  196. flex: 1;
  197. line-height: 44px;
  198. text-align: center;
  199. position: relative;
  200. &.active {
  201. color: #DC3C23;
  202. .line {
  203. display: block;
  204. }
  205. }
  206. }
  207. .line {
  208. position: absolute;
  209. bottom: 3px;
  210. left: 50%;
  211. transform: translateX(-50%);
  212. width: 126rpx;
  213. background-color: #DC3C23;
  214. display: none;
  215. height: 2px;
  216. }
  217. }
  218. }
  219. .list {
  220. padding: 24rpx 28rpx;
  221. background-color: #F3F3F7;
  222. }
  223. .item {
  224. margin-bottom: 24rpx;
  225. padding: 28rpx 28rpx;
  226. background-color: #fff;
  227. border-radius: 12rpx;
  228. display: flex;
  229. font-size: 14px;
  230. .num {
  231. color: rgb(117, 117, 117);
  232. margin-top: 8px;
  233. }
  234. }
  235. .img-box {
  236. margin-right: 20rpx;
  237. position: relative;
  238. .img {
  239. position: absolute;
  240. bottom: 0;
  241. left: 50%;
  242. transform: translateX(-50%);
  243. width: 77%;
  244. }
  245. }
  246. .content {
  247. flex: 1;
  248. min-width: 10%;
  249. max-width: 100%;
  250. display: flex;
  251. justify-content: space-between;
  252. align-items: center;
  253. .left {
  254. flex: 1;
  255. min-width: 10%;
  256. max-width: 100%;
  257. }
  258. .paid{
  259. padding: 8rpx 20rpx;
  260. border-radius: 12rpx;
  261. background-color: #ccc;
  262. color: #fff;
  263. }
  264. .guanzhu-box{
  265. display: flex;
  266. justify-content: center;
  267. align-items: center;
  268. background: url(@/static/image/match/right-bg.png)center center/ 100% 100% no-repeat;
  269. width: 180rpx;
  270. height: 59.54rpx;
  271. .guanzhu-icon{
  272. width: 28.82rpx;
  273. height: 25.39rpx;
  274. }
  275. }
  276. }
  277. </style>