index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <view>
  3. <view class="head" catchtouchmove="true" @touchmove.stop.prevent="() => { }">
  4. <My_search :value="content.where.condition" @onSearch="onSearch">
  5. <view class="filtrate" v-if="filtrateList.length" hover-class="navigator-hover" @click="openFiltrate">
  6. 筛选
  7. <text class="iconfont icon-shaixuan" />
  8. </view>
  9. </My_search>
  10. <view class="crumbs">
  11. <view class="crumb" v-for="item in crumbs" :key="item.classname">{{ item.classname }}</view>
  12. </view>
  13. </view>
  14. <view style="height: 1px;" />
  15. <filtrate ref="Filtrate" :filtrateList="filtrateList" @onFiltration="onFiltration" />
  16. <view style="height: 9px;" />
  17. <My_listbox ref="List" @getlist="getList" boxBackground="#fff">
  18. <view class="list-box">
  19. <navigator class="item" v-for="item in list" :key="item.sat_coursewareid"
  20. :url="'/packageA/course/list?id=' + item.sat_coursewareid">
  21. <image class="image" :src="item.cover" mode="aspectFill" lazy-load="true" />
  22. <view class="text">
  23. <view class="title u-line-1">{{ item.title || '--' }}</view>
  24. <view class="teacher u-line-1">讲师:{{ item.teacher || '--' }}</view>
  25. <view class="count u-line-1">共{{ item.onsale_courseware_count || 0 }}个课件 | {{ item.study_count || 0
  26. }}人已学习
  27. </view>
  28. </view>
  29. </navigator>
  30. </view>
  31. </My_listbox>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data() {
  37. return {
  38. crumbs: [],
  39. list: [],
  40. "content": {
  41. "where": {
  42. "condition": "",
  43. "sat_courseware_classids": [[]]
  44. }
  45. },
  46. filtrateList: []
  47. }
  48. },
  49. computed: {
  50. },
  51. onLoad(options) {
  52. this.crumbs = [{
  53. classname: "商学院"
  54. }, {
  55. classname: options.classname,
  56. parentid: options.id
  57. }, {
  58. classname: "全部",
  59. parentid: ''
  60. }]
  61. this.getType()
  62. this.getList(true)
  63. },
  64. methods: {
  65. getType() {
  66. this.$Http.basic({
  67. "id": "20221102143302",
  68. content: {
  69. pageSize: 9999,
  70. parentid: this.crumbs[1].parentid,
  71. "where": {
  72. "isenable": 1
  73. }
  74. }
  75. }).then(res => {
  76. console.log("获取二级列表", res)
  77. if (this.cutoff(res.msg)) return;
  78. this.filtrateList = [{
  79. title: "分类",
  80. key: 'sat_courseware_classids',//提交时返回的Key
  81. showKey: "classname",//显示的key
  82. selected: "sat_courseware_classid",//选择时选择的字段
  83. value: "",//提交时选中的value
  84. defaultVal: "",//返回的默认值
  85. isAll: true,
  86. rang: [{ classname: "全部", sat_courseware_classid: "" }].concat(res.data),//选择的范围
  87. }]
  88. })
  89. },
  90. getList(init = false) {
  91. if (this.paging(this.content, init)) return;
  92. let ids = this.crumbs.map(v => v.parentid).filter(v => v);
  93. this.content.where.sat_courseware_classids = ids.length ? [[ids[ids.length - 1]]] : []
  94. this.$Http.basic({
  95. "id": 20240318101802,
  96. content: this.content
  97. }).then(res => {
  98. this.$refs.List.RefreshToComplete()
  99. console.log("获取课程列表", res)
  100. if (this.cutoff(res.msg)) return;
  101. this.list = res.pageNumber == 1 ? res.data : this.list.concat(res.data);
  102. this.content = this.$refs.List.paging(this.content, res)
  103. })
  104. },
  105. openFiltrate() {
  106. this.$refs.Filtrate.changeShow();
  107. },
  108. onSearch(condition) {
  109. this.content.where.condition = condition;
  110. this.getList(true)
  111. },
  112. onFiltration(e) {
  113. this.$set(this.crumbs, 2, {
  114. classname: e.sat_courseware_classids.classname,
  115. parentid: e.sat_courseware_classids.sat_courseware_classid,
  116. })
  117. this.getList(true)
  118. }
  119. }
  120. }
  121. </script>
  122. <style lang="scss">
  123. .head {
  124. padding: 10px;
  125. width: 100%;
  126. background: #fff;
  127. box-sizing: border-box;
  128. .filtrate {
  129. line-height: 30px;
  130. padding: 0 10px;
  131. font-family: PingFang SC, PingFang SC;
  132. font-size: 14px;
  133. color: #333333;
  134. border-radius: 3px;
  135. margin-left: 10px;
  136. .iconfont {
  137. margin-left: 3px;
  138. color: #BBBBBB;
  139. }
  140. }
  141. }
  142. .crumbs {
  143. display: flex;
  144. line-height: 17px;
  145. font-family: PingFang SC, PingFang SC;
  146. font-size: 12px;
  147. flex-wrap: wrap;
  148. width: 100%;
  149. margin-top: 10px;
  150. .crumb {
  151. flex-shrink: 0;
  152. }
  153. .crumb::after {
  154. content: ">";
  155. padding: 0 2px;
  156. }
  157. .crumb:last-child {
  158. font-weight: bold;
  159. }
  160. .crumb:last-child::after {
  161. content: "";
  162. }
  163. }
  164. .list-box {
  165. padding: 10px;
  166. width: 100vw;
  167. box-sizing: border-box;
  168. .item {
  169. display: flex;
  170. width: 100%;
  171. border-radius: 5px;
  172. overflow: hidden;
  173. margin-top: 10px;
  174. .image {
  175. width: 120px;
  176. height: 74px;
  177. margin-right: 10px;
  178. border-radius: 5px;
  179. flex-shrink: 0;
  180. }
  181. .text {
  182. flex: 1;
  183. font-family: Source Han Sans SC, Source Han Sans SC;
  184. .title {
  185. font-weight: bold;
  186. font-size: 16px;
  187. color: #000000;
  188. line-height: 24px;
  189. }
  190. .teacher {
  191. font-size: 14px;
  192. color: #999999;
  193. line-height: 20px;
  194. margin-top: 4px;
  195. }
  196. .count {
  197. font-size: 12px;
  198. color: #666666;
  199. line-height: 17px;
  200. margin-top: 8px;
  201. }
  202. }
  203. }
  204. }
  205. </style>