鸿宇研学生前端代码
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.

182 lines
4.0 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 this.queryParams.userId ? 'queryExperienceList' : ''
  64. },
  65. },
  66. onLoad() {
  67. if(uni.getStorageSync('token')){
  68. this.$store.commit('getUserInfo')
  69. }
  70. },
  71. onShow() {
  72. // todo: set queryParams.userId by memberInfo
  73. if (!this.memberInfo && this.userInfo.id) {
  74. this.$store.commit('setMemberInfo', this.userInfo)
  75. }
  76. this.queryParams.userId = this.memberInfo.id
  77. this.getData()
  78. },
  79. methods: {
  80. getDataThen(records) {
  81. this.list = records.map(item => {
  82. const { id, name, image, createTime } = item
  83. return {
  84. id,
  85. // todo: check key
  86. name,
  87. image: image?.split?.(',') || [],
  88. createTime
  89. }
  90. })
  91. },
  92. search() {
  93. console.log('search', this.keyword)
  94. uni.navigateTo({
  95. url: '/pages_order/growing/activity/search?search=' + this.keyword
  96. })
  97. // this.keyword = ''
  98. },
  99. onAdd() {
  100. this.$refs.recordFormPopup.open()
  101. },
  102. jumpToChooseMember() {
  103. uni.navigateTo({
  104. url: `/pages_order/member/switch`
  105. })
  106. },
  107. },
  108. }
  109. </script>
  110. <style scoped lang="scss">
  111. .search {
  112. $w: 474rpx;
  113. $h: 64rpx;
  114. $radius: 32rpx;
  115. $borderWidth: 4rpx;
  116. width: $w;
  117. height: $h;
  118. position: relative;
  119. padding: 94rpx 32rpx 6rpx 32rpx;
  120. border-radius: $radius;
  121. &-icon {
  122. margin: 0 13rpx 0 26rpx;
  123. width: 30rpx;
  124. height: auto;
  125. }
  126. /deep/ .uv-search__content {
  127. padding: 12rpx 0;
  128. border: 4rpx solid transparent;
  129. }
  130. /deep/ .uv-search__content {
  131. background: #FFFFFF !important;
  132. border-color: #CFEFFF !important;
  133. }
  134. &.is-focus {
  135. /deep/ .uv-search__action {
  136. padding: 19rpx 24rpx;
  137. font-size: 26rpx;
  138. font-weight: 500;
  139. line-height: 1;
  140. color: #FFFFFF;
  141. background: #00A9FF;
  142. border-radius: 32rpx;
  143. }
  144. }
  145. }
  146. .archives {
  147. padding: 32rpx 40rpx 16rpx 40rpx;
  148. }
  149. .btn-choose {
  150. margin-top: 84rpx;
  151. padding: 14rpx 125rpx;
  152. font-size: 36rpx;
  153. font-weight: 500;
  154. line-height: 1.4;
  155. color: #FFFFFF;
  156. background: linear-gradient(to right, #21FEEC, #019AF9);
  157. border: 2rpx solid #00A9FF;
  158. border-radius: 41rpx;
  159. }
  160. </style>