schools.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <!-- 学院列表 -->
  2. <template>
  3. <view class="school">
  4. <z-paging ref="paging" v-model="schoolList" @query="queryList">
  5. <!-- 搜索 -->
  6. <view class="school-search" slot="top">
  7. <u-search class="school-search-input" placeholder="请输入关键词" v-model="keyword" shape="square"
  8. input-align="center" :show-action="false" bg-color="#ffffff" height="70" @search="keywordChange"/>
  9. </view>
  10. <view class="school-list">
  11. <view class="school-list-item" v-for="(item, index) in schoolList" :key="index" @click="recordBrowseTotal(item)">
  12. <view class="school-list-item-left">
  13. <view class="image">
  14. <image :src="item.schoolLogoUrl" mode=""></image>
  15. </view>
  16. <view class="title">
  17. <view class="name">{{ item.schoolName }}</view>
  18. <view class="grade">
  19. <!-- <view class="icon">
  20. <u-icon class="icon-img" name="star-fill" color="#EF651F" /> {{item.count}}
  21. </view> -->
  22. <view>{{ `${item.count}个专业 · ${getSchoolTypeName(item.schoolNature) || '-'} ` }}</view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="school-list-item-right">
  27. <u-icon name="arrow-right" color="#d2d3d5"/>
  28. </view>
  29. </view>
  30. </view>
  31. </z-paging>
  32. <u-toast ref="uToast" />
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. name: 'Schools',
  38. data() {
  39. return {
  40. // 搜索关键词
  41. keyword: '',
  42. // 学校列表
  43. schoolList: [],
  44. // 学校性质列表
  45. schoolTypeList: [],
  46. // 分页
  47. page: {
  48. pageNum: 1,
  49. pageSize: 10
  50. }
  51. }
  52. },
  53. onShow() {
  54. this.getSchoolTypeList()
  55. },
  56. methods: {
  57. /**
  58. * 获取列表
  59. * @param { Number } pageNum 当前页数
  60. * @param { Number } pageSize 分页大小
  61. * @param { String } schoolName 搜索关键词
  62. */
  63. getList(pageNum, pageSize, schoolName) {
  64. this.$u.api.school.getSchoolList({
  65. pageNum: pageNum,
  66. pageSize: pageSize,
  67. schoolName: schoolName
  68. }).then(res => {
  69. if (res.code === 200) {
  70. this.$refs.paging.complete(res.rows)
  71. } else {
  72. this.$refs.uToast.show({
  73. title: res.msg,
  74. type: 'error'
  75. })
  76. this.$refs.paging.complete([])
  77. }
  78. }).catch(() => {
  79. this.$refs.uToast.show({
  80. title: '系统异常!',
  81. type: 'error'
  82. })
  83. this.$refs.paging.complete([])
  84. })
  85. },
  86. /**
  87. * 获取学校性质字典
  88. */
  89. getSchoolTypeList() {
  90. this.$u.api.getDictdataUrl({
  91. key: 'school_nature'
  92. }).then(res => {
  93. if (res.code === 200) {
  94. this.schoolTypeList = res.data
  95. }
  96. })
  97. },
  98. /**
  99. * 通过字典值去获取名称
  100. * @param { String } val 字典text值
  101. */
  102. getSchoolTypeName(val) {
  103. let name
  104. this.schoolTypeList.forEach(item => {
  105. if (Number(item.text) === Number(val)) {
  106. name = item.label
  107. }
  108. })
  109. return name
  110. },
  111. /**
  112. * @param { Number } pageNo
  113. * @param { Number } pageSize
  114. */
  115. queryList(pageNo, pageSize) {
  116. this.getList(pageNo, pageSize, this.keyword)
  117. },
  118. /**
  119. * 关键词搜索回车触发
  120. */
  121. keywordChange() {
  122. this.getList(1, 10, this.keyword)
  123. },
  124. /**
  125. * 跳转到指定页面
  126. * @param { String } url 指定页面的路径
  127. * @param { Object } params 跳转携带参数
  128. */
  129. jumpPage(url, params) {
  130. this.$u.route({
  131. url: url,
  132. params: params
  133. })
  134. },
  135. /**
  136. * 学校关注度统计
  137. * @param {Object} item
  138. */
  139. recordBrowseTotal(item) {
  140. const query = {
  141. platform: '1', // 平台:1-H5 2-APP 3-小程序 4-PC端
  142. pages: location.href,//页面路径
  143. btnName: '查看学院详情',//按钮名称
  144. btnEvent: '1',//按钮事件: 1-点击 2-长按 3-滑动
  145. ipAddress: '',//IP地址
  146. typeName: '学校关注度',//类型名称 例:学校关注度 、适应性考试等
  147. typeCode: 'XXGZD',// 类型编码 例:类型名称首字母缩写(XXGZD)
  148. categoryName: item.schoolName,//类别名称 例:XX学校,SS考试
  149. }
  150. this.$u.api.postAnalysis(query).then(res => {
  151. this.jumpPage('/pages/schoolDetails/schoolDetails', { schoolId: item.id })
  152. })
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. @import './schools.scss';
  159. </style>