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

199 lines
4.7 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" v-if="userInfo.id">
  22. <userCard :medalList="medalList" :medalCount="medalCount" :experienceCount="total" @switchMember="jumpToChooseMember" @addRecord="onAdd"></userCard>
  23. </view>
  24. <view class="list" v-if="userInfo.id">
  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. bindUserId: '',
  57. },
  58. mixinsListApi: '',
  59. medalList: [],
  60. medalCount: 0,
  61. }
  62. },
  63. computed: {
  64. ...mapState(['userInfo', 'memberInfo']),
  65. bindUserId() {
  66. return this.memberInfo?.id || this.userInfo.id
  67. },
  68. },
  69. onLoad() {
  70. if(uni.getStorageSync('token')){
  71. this.$store.commit('getUserInfo')
  72. }
  73. },
  74. onShow() {
  75. console.log('bindUserId', this.bindUserId)
  76. this.queryParams.bindUserId = this.bindUserId
  77. this.mixinsListApi = this.queryParams.bindUserId ? 'queryExperienceList' : ''
  78. if(uni.getStorageSync('token')){
  79. this.fetchMedalList()
  80. this.getData()
  81. }
  82. },
  83. onHide() {
  84. this.mixinsListApi = ''
  85. },
  86. methods: {
  87. getDataThen(records) {
  88. this.list = records.map(item => {
  89. const { id, activityTitle, activityId_dictText, imageList, createTime } = item
  90. return {
  91. id,
  92. name: activityTitle || activityId_dictText || '',
  93. images: imageList?.split?.(',') || [],
  94. createTime
  95. }
  96. })
  97. },
  98. search() {
  99. console.log('search', this.keyword)
  100. uni.navigateTo({
  101. url: '/pages_order/growing/activity/search?search=' + this.keyword
  102. })
  103. // this.keyword = ''
  104. },
  105. async fetchMedalList() {
  106. try {
  107. const result = await this.$fetch('queryMedalList', { pageNo: 1, pageSize: 1000, isLight: '1', bindUserId: this.bindUserId })
  108. const { records, total } = result
  109. this.medalList = records
  110. this.medalCount = total
  111. } catch (err) {
  112. }
  113. },
  114. // onAdd() {
  115. // this.$refs.recordFormPopup.open()
  116. // },
  117. jumpToChooseMember() {
  118. uni.navigateTo({
  119. url: `/pages_order/member/switch`
  120. })
  121. },
  122. },
  123. }
  124. </script>
  125. <style scoped lang="scss">
  126. .search {
  127. $w: 474rpx;
  128. $h: 64rpx;
  129. $radius: 32rpx;
  130. $borderWidth: 4rpx;
  131. width: $w;
  132. height: $h;
  133. position: relative;
  134. padding: 94rpx 32rpx 6rpx 32rpx;
  135. border-radius: $radius;
  136. &-icon {
  137. margin: 0 13rpx 0 26rpx;
  138. width: 30rpx;
  139. height: auto;
  140. }
  141. /deep/ .uv-search__content {
  142. padding: 12rpx 0;
  143. border: 4rpx solid transparent;
  144. }
  145. /deep/ .uv-search__content {
  146. background: #FFFFFF !important;
  147. border-color: #CFEFFF !important;
  148. }
  149. &.is-focus {
  150. /deep/ .uv-search__action {
  151. padding: 19rpx 24rpx;
  152. font-size: 26rpx;
  153. font-weight: 500;
  154. line-height: 1;
  155. color: #FFFFFF;
  156. background: #00A9FF;
  157. border-radius: 32rpx;
  158. }
  159. }
  160. }
  161. .archives {
  162. padding: 32rpx 40rpx 16rpx 40rpx;
  163. }
  164. .btn-choose {
  165. margin-top: 84rpx;
  166. padding: 14rpx 125rpx;
  167. font-size: 36rpx;
  168. font-weight: 500;
  169. line-height: 1.4;
  170. color: #FFFFFF;
  171. background: linear-gradient(to right, #21FEEC, #019AF9);
  172. border: 2rpx solid #00A9FF;
  173. border-radius: 41rpx;
  174. }
  175. </style>