special_cate.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <!-- +---------------------------------------------------------------------- -->
  2. <!-- | CRMEB [ CRMEB赋能开发者,助力企业发展 ] -->
  3. <!-- +---------------------------------------------------------------------- -->
  4. <!-- | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved. -->
  5. <!-- +---------------------------------------------------------------------- -->
  6. <!-- | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 -->
  7. <!-- +---------------------------------------------------------------------- -->
  8. <!-- | Author: CRMEB Team <admin@crmeb.com> -->
  9. <!-- +---------------------------------------------------------------------- -->
  10. {extend name="public/container"}
  11. {block name="title"}{/block}
  12. {block name="head_top"}
  13. <style>
  14. .free{margin-top:.1rem;font-weight:400;font-size:.22rem;line-height:.38rem;color:#FF6B00;}
  15. .nothing {
  16. width: 4.14rem;
  17. height: 3.36rem;
  18. /* -webkit-transform: translate(-50%, -50%);
  19. transform: translate(-50%, -50%); */
  20. }
  21. body {
  22. padding-bottom: 1.1rem;
  23. padding-bottom: calc(1.1rem + constant(safe-area-inset-bottom));
  24. padding-bottom: calc(1.1rem + env(safe-area-inset-bottom));
  25. }
  26. </style>
  27. <script src="/wap/first/zsff/js/scroll.js"></script>
  28. <script src="/wap/first/zsff/js/navbarscroll.js"></script>
  29. {/block}
  30. {block name="content"}
  31. <div v-cloak id="app" class="goodsClass">
  32. <div class="header" style="height: 1rem;">
  33. <div class="search acea-row row-middle">
  34. <div class="pictrue">{if $homeLogo}<img src="{$homeLogo}">{else}<img src="/wap/first/zsff/images/crmeb.png">{/if}</div>
  35. <form class="form" @submit.prevent="goSearch">
  36. <label class="label">
  37. <img class="img" src="/wap/first/zsff/images/search.png">
  38. <input class="input" v-model="search" placeholder="输入课程名称">
  39. </label>
  40. <input class="submit" type="submit" value="搜索">
  41. </form>
  42. </div>
  43. <div v-if="gradeCate.length" style="display: none;" id="wrapper" class="wrapper">
  44. <div class="scroller">
  45. <ul>
  46. <li v-for="item in gradeCate" :key="item.id" :data-id="item.id">
  47. <a href="javascript:" v-text="item.name"></a>
  48. </li>
  49. </ul>
  50. </div>
  51. </div>
  52. </div>
  53. <div v-if="bigcateco" style="margin: 10px; color: gray;">
  54. {{bigcateco}}
  55. </div>
  56. <div v-if="subjectCate.length" id="nav" class="nav">
  57. <div class="scroller">
  58. <ul>
  59. <li v-for="item in subjectCate" :key="item.id" :data-id="item.id" class="item">
  60. <a href="javascript:">
  61. <div class="pictrue"><img :src="item.pic"></div>
  62. <div class="name" v-text="item.name"></div>
  63. </a>
  64. </li>
  65. </ul>
  66. </div>
  67. </div>
  68. <div v-if="smailcatco" style="margin: 10px; color: gray;">
  69. {{smailcatco}}
  70. </div>
  71. <div class="public_list_big goodList">
  72. <a v-for="item in updateSpecialList" :key="item.id" :href="item.is_light ? '{:url('special/single_details')}?id=' + item.id : '{:url('special/details')}?id=' + item.id" class="item acea-row">
  73. <div class="pictrue">
  74. <img :src="item.image" :alt="item.title">
  75. <div class="label">{{ item.special_type }}</div>
  76. </div>
  77. <div class="text">
  78. <div class="title acea-row row-middle">
  79. <div class="name line1" v-text="item.title"></div>
  80. </div>
  81. <div class="labelList">
  82. <span class="labelItem" v-for="label in item.label">{{label}}</span>
  83. </div>
  84. <div class="acea-row row-middle row-between">
  85. <div>
  86. <div class="money" v-if="item.money > 0">¥<span>{{item.money}}</span></div>
  87. <div class="free" v-else>免费</div>
  88. <span v-if="!item.is_light && item.type!=4" class="total">共{{item.count}}节</span>
  89. </div>
  90. <div class="num">{{item.browse_count}}人已学习</div>
  91. </div>
  92. </div>
  93. </a>
  94. </div>
  95. <div v-if="loadend && !specialList.length" style="text-align:center;padding-top:20px;">
  96. <img class="nothing" src="/wap/first/zsff/images/no_data_available.png">
  97. </div>
  98. <p v-else class="loading-line" style="background-color: #fff;">
  99. <span v-show="loading" class="fa fa-spinner loadingpic" style="font-size: 0.4rem;"></span>
  100. <span v-text="loadTitle">加载更多</span>
  101. </p>
  102. <div v-if="cate_id == 64">
  103. {include file="public/store_menu"}
  104. </div>
  105. <quick-menu v-if="cate_id != 64"></quick-menu>
  106. </div>
  107. {/block}
  108. {block name="foot"}
  109. <script>
  110. var cate_id = {$cate_id};
  111. var subject_id = {$subject_id};
  112. require(['vue', 'axios', 'helper', 'special-type', 'quick'], function (Vue, axios, $h, specialType, quick) {
  113. var vm = new Vue({
  114. el: '#app',
  115. data: {
  116. gradeCate: [],
  117. subjectCate: [],
  118. specialList: [],
  119. gradeId: -1,
  120. subjectId: -1,
  121. search: '',
  122. loadTitle: '',
  123. page: 1,
  124. limit: 10,
  125. loading: false,
  126. loadend: false,
  127. count: 0,
  128. bigcateco:'',
  129. smailcatco:'',
  130. webtitle:'',
  131. cate_id: cate_id,
  132. },
  133. computed: {
  134. updateSpecialList: function () {
  135. return this.specialList.map(function (value) {
  136. value.special_type = specialType[value.type];
  137. return value;
  138. });
  139. }
  140. },
  141. created: function () {
  142. this.getCateList();
  143. },
  144. mounted: function () {
  145. this.$nextTick(function () {
  146. $h.EventUtil.listenTouchDirection(document, function () {
  147. this.getSpecialList();
  148. //this.getSubject();
  149. }.bind(this), false);
  150. });
  151. },
  152. methods: {
  153. goSearch: function () {
  154. this.loadend = false;
  155. this.page = 1;
  156. this.gradeId = 0;
  157. this.$set(this, 'specialList', []);
  158. this.getSpecialList();
  159. },
  160. // 获取导航数据
  161. getCateList: function () {
  162. this.loading = true;
  163. that = this;
  164. /* 获取主分类*/
  165. if (cate_id > 0) {
  166. axios.get("{:url('special/get_subject_info')}", {
  167. params: {
  168. id: cate_id,
  169. }
  170. }).then(function(res) {
  171. //that.webtitle = res.data.data.name;
  172. document.title = res.data.data.name;
  173. that.bigcateco = res.data.data.co;
  174. });
  175. }
  176. if (subject_id > 0) {
  177. axios.get("{:url('special/get_subject_info')}", {
  178. params: {
  179. id: subject_id,
  180. }
  181. }).then(function(res) {
  182. that.smailcatco = res.data.data.co;
  183. });
  184. }
  185. axios.get("{:url('special/get_grade_cate')}").then(function (res) {
  186. vm.loading = false;
  187. var resData = res.data;
  188. if (resData.code === 200) {
  189. vm.gradeCate = resData.data;
  190. vm.gradeCate.unshift({
  191. id: 0,
  192. name: '全部'
  193. });
  194. var defaultSelect = 0;
  195. for (var i = 0; i < vm.gradeCate.length; i++) {
  196. if (vm.gradeCate[i].id === cate_id) {
  197. defaultSelect = i;
  198. break;
  199. }
  200. }
  201. vm.$nextTick(function () {
  202. $('#wrapper').navbarscroll({
  203. defaultSelect: defaultSelect,
  204. scrollerWidth: 5,
  205. fingerClick: 1,
  206. endClickScroll: function (elem) {
  207. var id = $(elem).data('id');
  208. vm.count++;
  209. if (vm.gradeId === id) {
  210. return;
  211. }
  212. vm.gradeId = id;
  213. if (vm.gradeId) {
  214. vm.getSubject();
  215. } else {
  216. vm.subjectCate = [];
  217. vm.specialList = [];
  218. vm.subjectId = 0;
  219. vm.loading = false;
  220. vm.loadend = false;
  221. vm.page = 1;
  222. vm.getSpecialList();
  223. }
  224. }
  225. });
  226. });
  227. } else {
  228. $h.pushMsg(resData.msg);
  229. }
  230. }).catch(function () {
  231. vm.loading = false;
  232. });
  233. },
  234. // 二级导航
  235. getSubject: function () {
  236. var subjectCate = [{
  237. id: 0,
  238. name: '全部',
  239. pic: '{__WAP_PATH}zsff/images/all.png',
  240. grade_id: this.gradeId
  241. }];
  242. this.subjectCate = [];
  243. this.specialList = [];
  244. this.subjectId = -1;
  245. for (var i = 0; i < this.gradeCate.length; i++) {
  246. if (this.gradeId === this.gradeCate[i].id) {
  247. subjectCate = subjectCate.concat(this.gradeCate[i].children);
  248. break;
  249. }
  250. }
  251. this.subjectCate = subjectCate;
  252. var defaultSelect = 0;
  253. if (this.count === 1) {
  254. for (let j = 0; j < this.subjectCate.length; j++) {
  255. if (this.subjectCate[j].id === subject_id) {
  256. defaultSelect = j;
  257. break;
  258. }
  259. }
  260. }
  261. this.$nextTick(function () {
  262. $('#nav').navbarscroll({
  263. defaultSelect: defaultSelect,
  264. scrollerWidth: 5,
  265. fingerClick: 1,
  266. endClickScroll: function (elem) {
  267. var id = $(elem).data('id');
  268. if (vm.subjectId === id) {
  269. return;
  270. }
  271. vm.subjectId = id;
  272. vm.specialList = [];
  273. vm.loadend = false;
  274. vm.page = 1;
  275. vm.getSpecialList();
  276. }
  277. });
  278. });
  279. },
  280. // 课程列表
  281. getSpecialList: function () {
  282. if (this.loading || this.loadend) {
  283. return;
  284. };
  285. that = this;
  286. this.loading = true;
  287. this.loadTitle = '';
  288. axios.get("{:url('special/get_special_list')}", {
  289. params: {
  290. grade_id: this.gradeId,
  291. subject_id: this.subjectId,
  292. search: this.search,
  293. page: this.page++,
  294. limit: this.limit
  295. }
  296. }).then(function (res) {
  297. vm.loading = false;
  298. var resData = res.data;
  299. if (resData.code === 200) {
  300. var data = resData.data;
  301. vm.specialList = vm.specialList.concat(data);
  302. vm.loadend = vm.limit > data.length ? true : false;
  303. vm.loadTitle = vm.loadend ? '已全部加载完' : '上拉加载更多';
  304. } else {
  305. $h.pushMsg(resData.msg);
  306. }
  307. }).catch(function () {
  308. vm.loading = false;
  309. });
  310. }
  311. }
  312. });
  313. })
  314. </script>
  315. {/block}