challengeChoose.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view class="challenge-choose-container">
  3. <view class="search-top">
  4. <view class="input-left">
  5. <input
  6. v-model="phone"
  7. type="text"
  8. class="input-body"
  9. placeholder="请输入代理昵称或手机号"
  10. />
  11. <view v-if="phone" class="clear" @click="phone = ''"></view>
  12. </view>
  13. <view class="right-btn" @click="toSearch">查询</view>
  14. </view>
  15. <scroll-view class="user-list" scroll-y="true" @scrolltolower="toMore">
  16. <template v-if="list.length > 0">
  17. <view
  18. v-for="(item, index) in list"
  19. :key="index"
  20. class="user-item"
  21. >
  22. <view
  23. class="user-avatar"
  24. :style="{ backgroundImage: `url(${item.avatar})` }"
  25. />
  26. <view class="user-info">
  27. <view class="user-name">{{ item.nickname.slice(0,6) }}</view>
  28. <view class="user-score">学分:{{ item.integral }}</view>
  29. </view>
  30. <view class="btn" @click="choose(item)">挑战</view>
  31. </view>
  32. </template>
  33. <template v-if="!isMore">
  34. <view class="noTip">没有更多了</view>
  35. </template>
  36. </scroll-view>
  37. </view>
  38. </template>
  39. <script>
  40. import { api_getCrown } from '@/api.js'
  41. export default {
  42. data() {
  43. return {
  44. pageTitle: '选择代理',
  45. scrollViewHeight: 0,
  46. list: [],
  47. phone: '',
  48. searchParams: {
  49. page_index: 1,
  50. search_content: ''
  51. },
  52. isMore: true
  53. };
  54. },
  55. mounted() {
  56. this.getList()
  57. },
  58. methods: {
  59. toSearch() {
  60. this.searchParams.search_content = this.phone
  61. this.searchParams.page_index = 1
  62. this.list = []
  63. this.getList()
  64. },
  65. toMore() {
  66. if(!this.isMore) return false
  67. this.searchParams.page_index += 1
  68. this.getList()
  69. },
  70. getList() {
  71. uni.loading()
  72. let { page_index, search_content } = this.searchParams
  73. this.$ajax.get(`${api_getCrown}?page_index=${page_index}&search_content=${search_content}` ).then(([, { data: { data: { list }}}]) => {
  74. uni.hideLoading()
  75. if(list.length < 20) {
  76. this.isMore = false
  77. }
  78. this.list = [...this.list, ...list]
  79. })
  80. },
  81. choose({ id, nickname, avatar }) {
  82. uni.pkInfo = {
  83. accept_id: id,
  84. accept_avatar: avatar,
  85. accept_nickname: nickname,
  86. }
  87. uni.navigateBack()
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="scss">
  93. page {
  94. display: flex;
  95. flex-direction: column;
  96. .challenge-choose-container {
  97. flex: 1;
  98. overflow: hidden;
  99. display: flex;
  100. flex-direction: column;
  101. justify-content: space-between;
  102. .search-top {
  103. width: 100%;
  104. height: 140rpx;
  105. display: flex;
  106. align-items: center;
  107. justify-content: space-between;
  108. padding: 0 30rpx;
  109. background-color: #FFFFFF;
  110. .input-left {
  111. flex: 1;
  112. overflow: hidden;
  113. height: 80rpx;
  114. border-radius: 80rpx;
  115. border: 1px solid #CCCCCC;
  116. padding: 0 30rpx;
  117. box-sizing: border-box;
  118. display: flex;
  119. align-items: center;
  120. justify-content: space-between;
  121. &::before {
  122. content: "";
  123. display: block;
  124. width: 40rpx;
  125. height: 40rpx;
  126. background: url(../../static/new_challenge/search.png) center no-repeat;
  127. background-size: 100%;
  128. }
  129. .clear {
  130. width: 32rpx;
  131. height: 32rpx;
  132. background: url(../../static/new_challenge/error.png) center no-repeat;
  133. background-size: 100%;
  134. }
  135. .input-body {
  136. flex: 1;
  137. overflow: hidden;
  138. margin: 0 10rpx;
  139. font-size: 28rpx;
  140. line-height: 40rpx;
  141. }
  142. }
  143. .right-btn {
  144. width: 124rpx;
  145. height: 64rpx;
  146. border-radius: 64rpx;
  147. line-height: 64rpx;
  148. text-align: center;
  149. background: linear-gradient(90deg, #F97C55 0%, #F44545 100%);
  150. color: #FFFFFF;
  151. font-size: 28rpx;
  152. margin-left: 30rpx;
  153. }
  154. }
  155. .user-list {
  156. flex: 1;
  157. overflow: hidden;
  158. background-color: #F9F9FB;
  159. .user-item {
  160. width: calc(100% - 60rpx);
  161. margin: 0 auto 30rpx auto;
  162. &:nth-of-type(1) {
  163. margin-top: 30rpx;
  164. }
  165. padding: 30rpx;
  166. border-radius: 24rpx;
  167. background-color: #FFFFFF;
  168. display: flex;
  169. align-items: stretch;
  170. justify-content: flex-start;
  171. .user-avatar {
  172. width: 96rpx;
  173. height: 96rpx;
  174. border-radius: 50%;
  175. background-color: #EEEEEE;
  176. background-position: center;
  177. background-repeat: no-repeat;
  178. background-size: 100%;
  179. margin-right: 20rpx;
  180. }
  181. .user-info {
  182. display: flex;
  183. flex-direction: column;
  184. justify-content: space-between;
  185. .user-name {
  186. color: #333333;
  187. font-size: 32rpx;
  188. font-weight: bold;
  189. line-height: 44rpx;
  190. }
  191. .user-score {
  192. color: #EA4A41;
  193. font-size: 28rpx;
  194. line-height: 40rpx;
  195. }
  196. }
  197. .btn {
  198. width: 192rpx;
  199. height: 68rpx;
  200. line-height: 68rpx;
  201. text-align: center;
  202. border-radius: 68rpx;
  203. background: linear-gradient(141deg, #F97C55 0%, #F44545 100%);
  204. color: #FFFFFF;
  205. font-size: 28rpx;
  206. margin-left: auto;
  207. align-self: center;
  208. }
  209. }
  210. .noTip {
  211. width: 100%;
  212. padding: 20rpx;
  213. text-align: center;
  214. color: #999999;
  215. }
  216. }
  217. }
  218. }
  219. </style>