challengeChoose.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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-flex">
  28. <view class="user-name">{{ item.nickname.slice(0,6) }}</view>
  29. <view v-if="item.chall_status" class="blue">(已挑战)</view>
  30. </view>
  31. <view class="user-score">学分:{{ item.integral }}</view>
  32. </view>
  33. <!-- challenge_status 1次数已够不能挑战 0不够次数可以挑战
  34. chall_status 1已经挑战 0未挑战 -->
  35. <view :class="!item.challenge_status && !item.chall_status ?'btn':'gray'" @click="choose(item)">挑战</view>
  36. </view>
  37. </template>
  38. <template v-if="!isMore">
  39. <view class="noTip">没有更多了</view>
  40. </template>
  41. </scroll-view>
  42. </view>
  43. </template>
  44. <script>
  45. import { api_getCrown } from '@/api.js'
  46. export default {
  47. data() {
  48. return {
  49. pageTitle: '选择客户',
  50. scrollViewHeight: 0,
  51. list: [],
  52. phone: '',
  53. searchParams: {
  54. page_index: 1,
  55. search_content: ''
  56. },
  57. isMore: true
  58. };
  59. },
  60. mounted() {
  61. this.getList()
  62. },
  63. methods: {
  64. toSearch() {
  65. this.searchParams.search_content = this.phone
  66. this.searchParams.page_index = 1
  67. this.list = []
  68. this.getList()
  69. },
  70. toMore() {
  71. if(!this.isMore) return false
  72. this.searchParams.page_index += 1
  73. this.getList()
  74. },
  75. getList() {
  76. uni.loading()
  77. let { page_index, search_content } = this.searchParams
  78. this.$ajax.get(`${api_getCrown}?page_index=${page_index}&search_content=${search_content}` ).then(([, { data: { data: { list }}}]) => {
  79. uni.hideLoading()
  80. if(list.length < 20) {
  81. this.isMore = false
  82. }
  83. this.list = [...this.list, ...list]
  84. })
  85. },
  86. choose({ id, nickname, avatar, challenge_status, chall_status }) {
  87. if (challenge_status == 1 || chall_status == 1) {
  88. return false;
  89. }
  90. uni.pkInfo = {
  91. accept_id: id,
  92. accept_avatar: avatar,
  93. accept_nickname: nickname
  94. }
  95. uni.navigateBack()
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss">
  101. page {
  102. display: flex;
  103. flex-direction: column;
  104. .challenge-choose-container {
  105. flex: 1;
  106. overflow: hidden;
  107. display: flex;
  108. flex-direction: column;
  109. justify-content: space-between;
  110. .search-top {
  111. width: 100%;
  112. height: 140rpx;
  113. display: flex;
  114. align-items: center;
  115. justify-content: space-between;
  116. padding: 0 30rpx;
  117. background-color: #FFFFFF;
  118. .input-left {
  119. flex: 1;
  120. overflow: hidden;
  121. height: 80rpx;
  122. border-radius: 80rpx;
  123. border: 1px solid #CCCCCC;
  124. padding: 0 30rpx;
  125. box-sizing: border-box;
  126. display: flex;
  127. align-items: center;
  128. justify-content: space-between;
  129. &::before {
  130. content: "";
  131. display: block;
  132. width: 40rpx;
  133. height: 40rpx;
  134. background: url(../../static/new_challenge/search.png) center no-repeat;
  135. background-size: 100%;
  136. }
  137. .clear {
  138. width: 32rpx;
  139. height: 32rpx;
  140. background: url(../../static/new_challenge/error.png) center no-repeat;
  141. background-size: 100%;
  142. }
  143. .input-body {
  144. flex: 1;
  145. overflow: hidden;
  146. margin: 0 10rpx;
  147. font-size: 28rpx;
  148. line-height: 40rpx;
  149. }
  150. }
  151. .right-btn {
  152. width: 124rpx;
  153. height: 64rpx;
  154. border-radius: 64rpx;
  155. line-height: 64rpx;
  156. text-align: center;
  157. background: linear-gradient(90deg, #F97C55 0%, #F44545 100%);
  158. color: #FFFFFF;
  159. font-size: 28rpx;
  160. margin-left: 30rpx;
  161. }
  162. }
  163. .user-list {
  164. flex: 1;
  165. overflow: hidden;
  166. background-color: #F9F9FB;
  167. .user-item {
  168. width: calc(100% - 60rpx);
  169. margin: 0 auto 30rpx auto;
  170. &:nth-of-type(1) {
  171. margin-top: 30rpx;
  172. }
  173. padding: 30rpx;
  174. border-radius: 24rpx;
  175. background-color: #FFFFFF;
  176. display: flex;
  177. align-items: stretch;
  178. justify-content: flex-start;
  179. .user-avatar {
  180. width: 96rpx;
  181. height: 96rpx;
  182. border-radius: 50%;
  183. background-color: #EEEEEE;
  184. background-position: center;
  185. background-repeat: no-repeat;
  186. background-size: 100%;
  187. margin-right: 20rpx;
  188. }
  189. .user-info {
  190. display: flex;
  191. flex-direction: column;
  192. justify-content: space-between;
  193. .user-flex {
  194. display: flex;
  195. align-items: center;
  196. .blue {
  197. font-size: 28rpx;
  198. font-weight: bold;
  199. color: #538EF9;
  200. margin-left: 20rpx;
  201. }
  202. .user-name {
  203. color: #333333;
  204. font-size: 32rpx;
  205. font-weight: bold;
  206. line-height: 44rpx;
  207. }
  208. }
  209. .user-score {
  210. color: #EA4A41;
  211. font-size: 28rpx;
  212. line-height: 40rpx;
  213. }
  214. }
  215. .btn {
  216. width: 192rpx;
  217. height: 68rpx;
  218. line-height: 68rpx;
  219. text-align: center;
  220. border-radius: 68rpx;
  221. background: linear-gradient(141deg, #F97C55 0%, #F44545 100%);
  222. color: #FFFFFF;
  223. font-size: 28rpx;
  224. margin-left: auto;
  225. align-self: center;
  226. }
  227. .gray {
  228. width: 192rpx;
  229. height: 68rpx;
  230. line-height: 68rpx;
  231. text-align: center;
  232. border-radius: 68rpx;
  233. background: #F8F8F8;
  234. color: #333333;
  235. font-size: 28rpx;
  236. margin-left: auto;
  237. align-self: center;
  238. }
  239. }
  240. .noTip {
  241. width: 100%;
  242. padding: 20rpx;
  243. text-align: center;
  244. color: #999999;
  245. }
  246. }
  247. }
  248. }
  249. </style>