special_cate.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. {extend name="public/container"}
  2. {block name="title"}分类{/block}
  3. {block name="head_top"}
  4. <style>
  5. .free{margin-top:.1rem;font-weight:400;font-size:.22rem;line-height:.38rem;color:#feb720;}
  6. .nothing {
  7. position: absolute;
  8. top: 50%;
  9. left: 50%;
  10. width: 4rem;
  11. height: 4rem;
  12. -webkit-transform: translate(-50%, -50%);
  13. transform: translate(-50%, -50%);
  14. }
  15. </style>
  16. <script src="/wap/first/zsff/js/scroll.js"></script>
  17. <script src="/wap/first/zsff/js/navbarscroll.js"></script>
  18. {/block}
  19. {block name="content"}
  20. <div class="goodsClass" id="app" v-cloak>
  21. <div class="header">
  22. <div class="search acea-row row-middle">
  23. <div class="pictrue">{if $homeLogo}<img src="{$homeLogo}">{else}<img src="/wap/first/zsff/images/crmeb.png">{/if}</div>
  24. <div class="input acea-row row-middle">
  25. <img src="/wap/first/zsff/images/search.png">
  26. <form method="post" @submit.prevent="goSearch">
  27. <input type="text" placeholder="输入课程名称" v-model="search">
  28. </form>
  29. </div>
  30. </div>
  31. <div class="wrapper" id="wrapper">
  32. <div class="scroller">
  33. <ul>
  34. <li v-for="item in grabeCate" :data-id="item.id">
  35. <a href="javascript:void(0)" v-text="item.name"></a>
  36. </li>
  37. </ul>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="nav" id="nav">
  42. <div class="scroller">
  43. <ul>
  44. <li class="item" :class="subjectId == item.id ? 'on': ''" v-for="item in subjectCate" @click="subjectId = item.id" :data-id="item.id">
  45. <a href="javascript:void(0)">
  46. <div class="pictrue"><img :src="item.pic" :class="{ borde: subjectId === item.id }"></div>
  47. <div class="name" v-text="item.name"></div>
  48. </a>
  49. </li>
  50. </ul>
  51. </div>
  52. </div>
  53. <div class="public_list goodList">
  54. <a class="item acea-row" v-for="item in updateSpecialList" :href="getDetails(item.id)">
  55. <div class="pictrue">
  56. <img :src="item.image">
  57. <div class="label">{{ item.type }}</div>
  58. </div>
  59. <div class="text">
  60. <div class="title acea-row row-middle">
  61. <div class="name line1" v-text="item.title"></div>
  62. </div>
  63. <div class="labelList">
  64. <span class="labelItem" v-for="label in item.label">{{label}}</span>
  65. </div>
  66. <div class="acea-row row-middle row-between">
  67. <div>
  68. <div class="money" v-if="item.money > 0">¥<span>{{item.money}}</span></div>
  69. <div class="free" v-else>免费</div>
  70. <span v-if="item.special_type!=4" class="total">共{{item.count}}节</span>
  71. </div>
  72. <div class="num">{{item.browse_count}}人已学习</div>
  73. </div>
  74. </div>
  75. </a>
  76. </div>
  77. <p class="loading-line" style="background-color: #ffffff" v-show="updateSpecialList.length">
  78. <span v-show="loading" class="fa fa-spinner loadingpic" style="font-size: 0.4rem"></span>
  79. <span v-text="loadTitle">加载更多</span>
  80. </p>
  81. <div v-if="!updateSpecialList.length && !loading" >
  82. <img class="nothing" src="/wap/first/zsff/images/no_data_available.png">
  83. </div>
  84. <div style="height: 1.0rem"></div>
  85. {include file="public/store_menu"}
  86. </div>
  87. {/block}
  88. {block name='foot'}
  89. <script>
  90. var cate_id = {$cate_id};
  91. var subject_id = {$subject_id};
  92. require(['vue', 'helper', 'store', 'special-type'], function (Vue, $h, app, specialType) {
  93. new Vue({
  94. el: '#app',
  95. data: {
  96. grabeCate: [],
  97. subjectCate: [],
  98. specialList: [],
  99. gradeId: 0,
  100. subjectId: 0,
  101. search: '',
  102. loadTitle: '',
  103. loading: false,
  104. limit: 10,
  105. page: 1,
  106. loadend: false,
  107. },
  108. computed: {
  109. updateSpecialList: function () {
  110. return this.specialList.map(function (value) {
  111. value.special_type=value.type;
  112. value.type = specialType[value.type];
  113. return value;
  114. });
  115. }
  116. },
  117. watch: {
  118. gradeId: function (n) {
  119. this.subjectCate = [];
  120. this.specialList = [];
  121. this.getSubject();
  122. },
  123. subjectId: function (n) {
  124. if (n == 0) return;
  125. this.loadend = false;
  126. this.page = 1;
  127. this.$set(this, 'specialList', []);
  128. this.getSpecialList();
  129. }
  130. },
  131. mounted: function () {
  132. this.getCateList();
  133. },
  134. methods: {
  135. goSearch: function () {
  136. this.loadend = false;
  137. this.page = 1;
  138. this.$set(this, 'specialList', []);
  139. this.getSpecialList();
  140. },
  141. getDetails: function (id) {
  142. return $h.U({
  143. c: 'special',
  144. a: 'details',
  145. q: { id: id }
  146. });
  147. },
  148. getCateList: function () {
  149. var that = this;
  150. app.baseGet($h.U({ c: 'special', a: 'get_grade_cate' }), function (res) {
  151. that.$set(that, 'grabeCate', res.data.data);
  152. if(res.data.data.length>0){
  153. var defaultSelect = 0;
  154. if (cate_id) {
  155. for (var i = 0; i < that.grabeCate.length; i++) {
  156. if (cate_id == that.grabeCate[i].id) {
  157. defaultSelect = i;
  158. that.gradeId = cate_id;
  159. break;
  160. }
  161. }
  162. if(!that.gradeId){
  163. that.gradeId =that.grabeCate[0].id;
  164. subject_id=0;
  165. }
  166. }
  167. that.$nextTick(function () {
  168. $('#wrapper').navbarscroll({
  169. defaultSelect: defaultSelect,
  170. scrollerWidth: 5,
  171. fingerClick: 1,
  172. endClickScroll: function (obj) {
  173. that.gradeId = obj.data('id');
  174. }
  175. });
  176. })
  177. }else{
  178. return $h.showMsg('请添加课程分类!');
  179. }
  180. });
  181. },
  182. getSubject: function () {
  183. var that = this;
  184. app.baseGet($h.U({
  185. c: 'special',
  186. a: 'get_subject_cate',
  187. q: { grade_id: this.gradeId }
  188. }), function (res) {
  189. that.$set(that, 'subjectCate', res.data.data);
  190. if (res.data.data.length) {
  191. var defaultSubjectSelect = 0;
  192. if(subject_id){
  193. for (var i = 0; i < that.subjectCate.length; i++) {
  194. if (subject_id == that.subjectCate[i].id) {
  195. defaultSubjectSelect = i;
  196. that.subjectId = subject_id;
  197. break;
  198. }
  199. }
  200. if(!that.subjectId){
  201. that.subjectId =that.subjectCate[0].id;
  202. }
  203. }
  204. that.$nextTick(function () {
  205. $('#nav').navbarscroll({
  206. defaultSelect: defaultSubjectSelect,
  207. scrollerWidth: 5,
  208. fingerClick: 1,
  209. endClickScroll: function (obj) {
  210. that.subjectId = obj.data('id');
  211. }
  212. });
  213. })
  214. } else {
  215. that.subjectId = 0;
  216. that.$set(that, 'specialList', []);
  217. }
  218. });
  219. },
  220. getSpecialList: function () {
  221. var that = this;
  222. if (that.loadend) return;
  223. if (that.loading) return;
  224. that.loading = true;
  225. that.loadTitle = '';
  226. app.baseGet($h.U({
  227. c: 'special',
  228. a: 'get_special_list',
  229. q: { subject_id: that.subjectId, search: that.search, page: that.page, limit: that.limit }
  230. }), function (res) {
  231. var list = res.data.data;
  232. var specialList = $h.SplitArray(list, that.specialList);
  233. that.loading = false;
  234. that.page++;
  235. that.loadend = list.length < that.limit;
  236. that.loadTitle = that.loadend ? '我是有底线的' : '上拉加载更多';
  237. that.$set(that, 'specialList', specialList);
  238. that.EventUtil();
  239. }, function (res) {
  240. that.loading = false;
  241. this.loadTitle = '加载更多';
  242. });
  243. },
  244. EventUtil: function () {
  245. this.$nextTick(function () {
  246. $h.EventUtil.listenTouchDirection(document, function () {
  247. this.loading == false && this.getSpecialList();
  248. }.bind(this), false);
  249. })
  250. }
  251. }
  252. });
  253. })
  254. </script>
  255. {/block}