entry-calculate-result.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <view class="page-content relative">
  3. <large-header mode="light" :full-height="80" :title="title" :scroll-top="scrollTop"/>
  4. <view class="mx-20 py-20 bg-white mx-card overflow-hidden">
  5. <college-item :item="detail.baseInfo" reverse @tag="handleDoublePopup"/>
  6. <uv-line margin="5px 0 10px 0"/>
  7. <college-detail-summary :college="detail.baseInfo" @star="handleStarPopup"/>
  8. </view>
  9. <view class="m-20 p-20 bg-white mx-card overflow-hidden">
  10. <index-title-wrap title="测算结果" bold>
  11. <template #more>
  12. <uv-tags shape="circle" plain plain-fill :text="result.majorName"/>
  13. </template>
  14. </index-title-wrap>
  15. <view v-if="result.majorGroup" class="text-sm text-main mt-10">
  16. 专业组:
  17. <text class="text-primary-light">{{ result.majorGroup }}</text>
  18. </view>
  19. <view v-if="result.majorDirection" class="text-sm text-main mt-10">
  20. 专业方向:
  21. <text class="text-primary-light">{{ result.majorDirection }}</text>
  22. </view>
  23. <view class="mt-30 p-30 fx-row fx-bet-cen gap-30 text-main text-xs rounded-lg bg-sky-50">
  24. <view class="leading-6">
  25. 根据
  26. <text class="text-success font-bold">{{ safeYear }}</text>
  27. 年该校录取情况,
  28. 预估考取本专业需要职业技能分:
  29. </view>
  30. <view class="fx-row keep-all items-baseline">
  31. <view class="text-4xl font-bold text-primary mr-5">
  32. <template v-if="safeImprove.valid">{{ safeImprove.value }}</template>
  33. <uv-icon v-else size="24" name="question-circle" color="primary" @click="handleFailed"/>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="mt-30 text-main text-xs">
  38. <view class="mb-15">录取公式:</view>
  39. <view class="bg-slate-100 rounded-lg p-30 text-primary">
  40. <template v-for="(r,i) in enrollRules">
  41. <view>{{ r.content }}</view>
  42. <uv-line v-if="i<enrollRules.length-1" dashed margin="8px 0 8px 0"/>
  43. </template>
  44. <text v-if="!enrollRules.length">无</text>
  45. </view>
  46. </view>
  47. <view v-if="otherRules.length" class="mt-30 text-main text-xs">
  48. <view class="mb-15">院校要求:</view>
  49. <view class="bg-slate-100 rounded-lg p-30 text-primary">
  50. <template v-for="(r, i) in otherRules">
  51. <view class="rule-item">{{ r.content }}</view>
  52. <uv-line v-if="i<otherRules.length-1" dashed margin="8px 0 8px 0"/>
  53. </template>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="m-30 fx-row fx-bet-cen gap-30">
  58. <uv-button :icon="collected?'heart-fill':'heart'" icon-color="primary" size="large"
  59. shape="circle" type="primary" plain class="!flex-2" text="收藏" @click="handleToggle"/>
  60. <uv-button icon="eye" icon-color="white" size="large" shape="circle" type="primary" class="!flex-3"
  61. text="查看院校详情" @click="goCollegeDetail"/>
  62. </view>
  63. <mx-popup-template ref="popup" v-bind="popupBinding"/>
  64. </view>
  65. </template>
  66. <script>
  67. import {ref, computed} from 'vue';
  68. import _ from 'lodash';
  69. import {useTransfer} from "@/hooks/useTransfer";
  70. import {useCacheStore} from "@/hooks/useCacheStore";
  71. import {useProvidePageScroll} from "@/hooks/usePageScrollInjection";
  72. import {findTreeNode} from "@/utils/tree-helper";
  73. import {postCalculateResult} from "@/api/webApi/ie-voluntary";
  74. import {cacheActions} from "@/hooks/defineCacheActions";
  75. import {universityDetail} from "@/api/webApi/collegemajor";
  76. import LargeHeader from "@/pages/ie/components/large-header.vue";
  77. import CollegeItem from "@/pages/college-library/components/college-item.vue";
  78. import CollegeDetailSummary from "@/pages/college-library/components/college-detail-summary.vue";
  79. import {useCollegeCollectionService} from "@/pages/college-library/components/useCollegeCollectionService";
  80. import mxConfig from "@/common/mxConfig";
  81. import {object} from "@/uni_modules/uv-ui-tools/libs/function/test";
  82. import IndexTitleWrap from "@/pages/index/components/index-title-wrap.vue";
  83. import MxConst from "@/common/mxConst";
  84. import {alertAsync} from "@/utils/uni-helper";
  85. export default {
  86. components: {IndexTitleWrap, CollegeDetailSummary, CollegeItem, LargeHeader},
  87. data() {
  88. return {
  89. loading: false,
  90. title: '测职业技能分',
  91. majorTree: [],
  92. result: {}
  93. };
  94. },
  95. setup() {
  96. const {prevData, transferTo} = useTransfer()
  97. const {dispatchCache} = useCacheStore()
  98. const scrollTop = useProvidePageScroll()
  99. const detail = ref({})
  100. const collegeRef = computed(() => detail.value?.baseInfo || {})
  101. const {collected, handleToggle} = useCollegeCollectionService(collegeRef)
  102. const popup = ref(null)
  103. const popupType = ref('')
  104. const popupConfig = mxConfig.collegeDetailPopups
  105. const popupBinding = computed(() => {
  106. let cfg = popupConfig[popupType.value]
  107. if (!cfg && object(popupType.value)) cfg = popupType.value
  108. return {
  109. ...cfg,
  110. left: '',
  111. right: '我知道了',
  112. onRight: () => popup.value.close()
  113. }
  114. })
  115. const handleDoublePopup = () => {
  116. popupType.value = 'double'
  117. popup.value.open()
  118. }
  119. const handleStarPopup = () => {
  120. popupType.value = 'star'
  121. popup.value.open()
  122. }
  123. const goCollegeDetail = () => {
  124. const {code} = collegeRef.value
  125. transferTo('/pages/college-library/detail/detail', {code})
  126. }
  127. return {
  128. prevData,
  129. scrollTop,
  130. dispatchCache,
  131. detail,
  132. collected,
  133. handleToggle,
  134. popup,
  135. popupBinding,
  136. handleDoublePopup,
  137. handleStarPopup,
  138. goCollegeDetail
  139. }
  140. },
  141. computed: {
  142. major() {
  143. return findTreeNode(this.majorTree, m => m.code == this.prevData.majorCode) || {}
  144. },
  145. enrollRules() {
  146. return this.result?.improves?.filter(r => r.type == MxConst.enum.ai.ruleType.scoreTotal) || []
  147. },
  148. otherRules() {
  149. return this.result?.rules?.filter(r => r.type != MxConst.enum.ai.ruleType.scoreTotal) || []
  150. },
  151. safeImprove() {
  152. return _.first(this.enrollRules) || {}
  153. },
  154. safeYear() {
  155. return this.safeImprove.year || _.first(this.result.histories)?.year
  156. }
  157. },
  158. provide() {
  159. return {
  160. getPrevData: () => this.prevData,
  161. getDetail: () => this.detail,
  162. getMajorTree: () => this.majorTree,
  163. getMajor: () => this.major,
  164. getResult: () => this.result
  165. }
  166. },
  167. async mounted() {
  168. // wait for transfer mixin work completed.
  169. this.loading = true
  170. try {
  171. await this.loadReport();
  172. await this.loadData();
  173. } finally {
  174. this.loading = false
  175. }
  176. },
  177. methods: {
  178. async loadReport() {
  179. const res = await postCalculateResult(this.prevData)
  180. this.result = res.data
  181. },
  182. async loadData() {
  183. this.majorTree = await this.dispatchCache(cacheActions.getMajorTree)
  184. const payload = {code: this.prevData.universityCode}
  185. const res = await this.dispatchCache(universityDetail, payload)
  186. this.detail = res.data
  187. },
  188. handleFailed() {
  189. alertAsync(this.safeImprove.failedMessage || '无法计算')
  190. }
  191. }
  192. }
  193. </script>
  194. <style lang="scss" scoped>
  195. .page-content {
  196. background-image: url("~@/static/ie/entry/bg-calculate-full.png");
  197. background-repeat: no-repeat;
  198. background-size: contain;
  199. }
  200. </style>