follow_lecturer.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. {extend name="public/container" /}
  2. {block name="title"}我的关注{/block}
  3. {block name="head"}
  4. <style>
  5. body {
  6. background-color: #F5F5F5;
  7. }
  8. .my-follow .item {
  9. display: flex;
  10. align-items: center;
  11. padding: .3rem;
  12. border-top: 1px solid #F5F5F5;
  13. background-color: #FFFFFF;
  14. }
  15. .my-follow .item:first-child {
  16. border-top: none;
  17. }
  18. .my-follow .avatar {
  19. width: 1.3rem;
  20. height: 1.3rem;
  21. border-radius: 50%;
  22. overflow: hidden;
  23. }
  24. .my-follow .text {
  25. flex: 1;
  26. margin-left: .22rem;
  27. }
  28. .my-follow .name {
  29. font-weight: 500;
  30. font-size: .3rem;
  31. line-height: .42rem;
  32. color: #282828;
  33. }
  34. .my-follow .tags {
  35. display: flex;
  36. margin-top: .1rem;
  37. }
  38. .my-follow .tag {
  39. height: .32rem;
  40. padding: 0 .12rem;
  41. border-radius: .04rem;
  42. margin-left: .1rem;
  43. background-color: rgba(255, 107, 0, 0.1);
  44. font-size: .22rem;
  45. line-height: .32rem;
  46. color: #FF6B00;
  47. }
  48. .my-follow .tag:first-child {
  49. margin-left: 0;
  50. }
  51. .my-follow .attr {
  52. margin-top: .1rem;
  53. font-size: .26rem;
  54. line-height: .37rem;
  55. color: #666666;
  56. }
  57. .my-follow button {
  58. width: 1.2rem;
  59. height: .48rem;
  60. border: 1px solid #999999;
  61. border-radius: .24rem;
  62. font-size: .22rem;
  63. color: #999999;
  64. }
  65. .my-follow button .iconfont {
  66. margin-right: .05rem;
  67. vertical-align: middle;
  68. font-size: .15rem;
  69. }
  70. .my-follow .followed {
  71. border-color: #999999;
  72. color: #999999;
  73. }
  74. .my-follow .empty {
  75. display: block;
  76. width: 4.14rem;
  77. margin: 1rem auto 0;
  78. }
  79. </style>
  80. {/block}
  81. {block name="content"}
  82. <div v-cloak id="app" class="my-follow">
  83. <a v-for="item in followList" :key="item.id" class="item" :href="'{:url('merchant/teacher_detail')}?id=' + item.id">
  84. <div class="avatar">
  85. <img :src="item.lecturer_head" alt="">
  86. </div>
  87. <div class="text">
  88. <div class="name">{{ item.lecturer_name }}</div>
  89. <div class="tags">
  90. <div v-for="label in item.label" :key="label" class="tag">{{ label }}</div>
  91. </div>
  92. <div class="attr">{{ item.study }}人学习 | {{ item.curriculum }}课时</div>
  93. </div>
  94. <button @click.prevent="follow(item)">取消关注</button>
  95. </a>
  96. <img v-if="!followList.length && finished" class="empty" src="{__WAP_PATH}zsff/images/empty.png" alt="">
  97. </div>
  98. {/block}
  99. {block name="foot"}
  100. <script>
  101. require(['vue', 'helper', 'store'], function (Vue, $h, store) {
  102. new Vue({
  103. el: '#app',
  104. data: {
  105. page: 1,
  106. limit: 16,
  107. followList: [],
  108. finished: false
  109. },
  110. created: function () {
  111. var vm = this;
  112. this.getFollowList();
  113. $h.EventUtil.listenTouchDirection(document, function () {
  114. vm.getFollowList();
  115. });
  116. },
  117. methods: {
  118. // 获取关注的讲师
  119. getFollowList: function () {
  120. var vm = this;
  121. if (this.finished) {
  122. return;
  123. }
  124. $h.loadFFF();
  125. store.baseGet($h.U({
  126. c: 'merchant',
  127. a: 'get_user_follow_list',
  128. q: {
  129. page: this.page++,
  130. limit: 15
  131. }
  132. }), function (res) {
  133. $h.loadClear();
  134. var followList = res.data.data;
  135. followList.forEach(function (item) {
  136. item.label = JSON.parse(item.label);
  137. });
  138. vm.followList = vm.followList.concat(followList);
  139. vm.finished = vm.limit > followList.length;
  140. });
  141. },
  142. // 取消关注
  143. follow: function (item) {
  144. var vm = this;
  145. store.baseGet($h.U({
  146. c: 'merchant',
  147. a: 'user_follow',
  148. q: {
  149. mer_id: item.mer_id,
  150. is_follow: 0
  151. }
  152. }), function (res) {
  153. for (var i = 0; i < vm.followList.length; i++) {
  154. if (vm.followList[i].id === item.id) {
  155. vm.followList.splice(i, 1);
  156. break;
  157. }
  158. }
  159. $h.pushMsg('取消关注成功');
  160. });
  161. }
  162. }
  163. });
  164. });
  165. </script>
  166. {/block}