schools.vue 4.3 KB

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