鸿宇研学生前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

183 lines
4.1 KiB

  1. <template>
  2. <view class="page__view highlight">
  3. <!-- 搜索栏 -->
  4. <view :class="['flex', 'search', isFocusSearch ? 'is-focus' : '']" >
  5. <uv-search
  6. v-model="keyword"
  7. placeholder="请输入"
  8. color="#181818"
  9. bgColor="transparent"
  10. :showAction="isFocusSearch"
  11. @custom="search"
  12. @search="search"
  13. @focus="isFocusSearch = true"
  14. @blur="isFocusSearch = false"
  15. >
  16. <template #prefix>
  17. <image class="search-icon" src="@/static/image/icon-search-dark.png" mode="widthFix"></image>
  18. </template>
  19. </uv-search>
  20. </view>
  21. <view class="archives">
  22. <userCard @switchMember="jumpToChooseMember" @addRecord="onAdd"></userCard>
  23. </view>
  24. <view class="list" v-if="memberInfo">
  25. <recordsView :list="list"></recordsView>
  26. </view>
  27. <view class="flex" v-else>
  28. <button class="btn btn-choose" @click="jumpToChooseMember">请先选择人员</button>
  29. </view>
  30. <record-form-popup ref="recordFormPopup" @submitted="getData"></record-form-popup>
  31. <tabber select="growing" />
  32. </view>
  33. </template>
  34. <script>
  35. import { mapState } from 'vuex'
  36. import mixinsList from '@/mixins/list.js'
  37. import tabber from '@/components/base/tabbar.vue'
  38. import userCard from '@/components/growing/userCard.vue'
  39. import recordsView from '@/components/growing/recordsView.vue'
  40. import recordFormPopup from '@/pages_order/comment/recordFormPopup.vue'
  41. export default {
  42. mixins: [mixinsList],
  43. components: {
  44. userCard,
  45. recordsView,
  46. recordFormPopup,
  47. tabber,
  48. },
  49. data() {
  50. return {
  51. keyword: '',
  52. isFocusSearch: false,
  53. queryParams: {
  54. pageNo: 1,
  55. pageSize: 10,
  56. userId: '',
  57. },
  58. }
  59. },
  60. computed: {
  61. ...mapState(['memberInfo']),
  62. mixinsListApi() {
  63. return 'queryExperienceList'
  64. // todo
  65. return this.queryParams.userId ? 'queryExperienceList' : ''
  66. },
  67. },
  68. onLoad() {
  69. if(uni.getStorageSync('token')){
  70. this.$store.commit('getUserInfo')
  71. }
  72. },
  73. onShow() {
  74. // todo: set queryParams.userId by memberInfo
  75. if (!this.memberInfo && this.userInfo.id) {
  76. this.$store.commit('setMemberInfo', this.userInfo)
  77. }
  78. // this.queryParams.userId = this.memberInfo.id
  79. // this.getData()
  80. },
  81. methods: {
  82. getDataThen(records) {
  83. this.list = records.map(item => {
  84. const { id, name, image, createTime } = item
  85. return {
  86. id,
  87. // todo: check key
  88. name,
  89. image: image?.split?.(',') || [],
  90. createTime
  91. }
  92. })
  93. },
  94. search() {
  95. console.log('search', this.keyword)
  96. uni.navigateTo({
  97. url: '/pages_order/growing/activity/search?search=' + this.keyword
  98. })
  99. // this.keyword = ''
  100. },
  101. onAdd() {
  102. this.$refs.recordFormPopup.open()
  103. },
  104. jumpToChooseMember() {
  105. uni.navigateTo({
  106. url: `/pages_order/member/switch`
  107. })
  108. },
  109. },
  110. }
  111. </script>
  112. <style scoped lang="scss">
  113. .search {
  114. $w: 474rpx;
  115. $h: 64rpx;
  116. $radius: 32rpx;
  117. $borderWidth: 4rpx;
  118. width: $w;
  119. height: $h;
  120. position: relative;
  121. padding: 94rpx 32rpx 6rpx 32rpx;
  122. border-radius: $radius;
  123. &-icon {
  124. margin: 0 13rpx 0 26rpx;
  125. width: 30rpx;
  126. height: auto;
  127. }
  128. /deep/ .uv-search__content {
  129. padding: 12rpx 0;
  130. border: 4rpx solid transparent;
  131. }
  132. /deep/ .uv-search__content {
  133. background: #FFFFFF !important;
  134. border-color: #CFEFFF !important;
  135. }
  136. &.is-focus {
  137. /deep/ .uv-search__action {
  138. padding: 19rpx 24rpx;
  139. font-size: 26rpx;
  140. font-weight: 500;
  141. line-height: 1;
  142. color: #FFFFFF;
  143. background: #00A9FF;
  144. border-radius: 32rpx;
  145. }
  146. }
  147. }
  148. .archives {
  149. padding: 32rpx 40rpx 16rpx 40rpx;
  150. }
  151. .btn-choose {
  152. margin-top: 84rpx;
  153. padding: 14rpx 125rpx;
  154. font-size: 36rpx;
  155. font-weight: 500;
  156. line-height: 1.4;
  157. color: #FFFFFF;
  158. background: linear-gradient(to right, #21FEEC, #019AF9);
  159. border: 2rpx solid #00A9FF;
  160. border-radius: 41rpx;
  161. }
  162. </style>