Teachcourse.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <!-- 我的课程 -->
  3. <div class="Teachcourse personal-center">
  4. <EditTitle :title="title" />
  5. <template v-if="!isEmpty">
  6. <div v-loading="loading" class="bookList">
  7. <div v-for="(item, i) in list" :key="i" @click="jump(item)">
  8. <div class="img-box" :class="item.checked ? 'active' : ''">
  9. <div class="fengmian">
  10. <img
  11. :src="
  12. userType == 'TEACHER'
  13. ? item.picture_url
  14. : item.goods_picture_url
  15. "
  16. alt=""
  17. />
  18. </div>
  19. <div class="checkout-box" v-if="isShowCheckBox">
  20. <img src="@/assets/Personalcenter/selected-icon.png" />
  21. </div>
  22. </div>
  23. <p class="goods_name">
  24. {{ userType == "TEACHER" ? item.name : item.goods_name }}
  25. </p>
  26. </div>
  27. </div>
  28. <div class="paging" :class="list.length < 16 ? 'paging1' : ''">
  29. <el-pagination
  30. background
  31. layout="prev, pager, next"
  32. :current-page="pageNum"
  33. :total="total"
  34. :page-size="pageSize"
  35. @current-change="changecurrentPage"
  36. />
  37. </div>
  38. </template>
  39. <template v-else>
  40. <Empty :navType="navType" />
  41. </template>
  42. </div>
  43. </template>
  44. <script>
  45. import EditTitle from "../common/EditTitle.vue";
  46. import Empty from "../common/Empty.vue";
  47. import { getLearnWebContent } from "@/api/ajax";
  48. import { jumpPath } from "@/utils/jumpPath";
  49. export default {
  50. name: "Teachcourse",
  51. //import引入的组件需要注入到对象中才能使用
  52. components: {
  53. EditTitle,
  54. Empty,
  55. },
  56. props: ["userType"],
  57. data() {
  58. //这里存放数据
  59. return {
  60. navType: "2",
  61. list: [],
  62. pageSize: 15,
  63. pageNum: 1,
  64. total: 0,
  65. activeIndex: "[201]",
  66. loading: false,
  67. isEmpty: false,
  68. isShowCheckBox: false,
  69. title: this.$t("Key62"),
  70. };
  71. },
  72. //计算属性 类似于data概念
  73. computed: {},
  74. //监控data中数据变化
  75. watch: {},
  76. //方法集合
  77. methods: {
  78. jump(item) {
  79. if (this.userType == "TEACHER") {
  80. let url = `/GCLS-Learn/#/GoodsDetail?goods_id=${item.id}&goods_type=201&invok_module=GCLS-Personal`;
  81. window.open(url);
  82. } else {
  83. jumpPath(item);
  84. }
  85. },
  86. // 修改当前页
  87. changecurrentPage(val) {
  88. this.pageNum = val;
  89. this.getOrderList();
  90. },
  91. //分页查询我的订单列表
  92. getOrderList() {
  93. let _this = this;
  94. _this.loading = true;
  95. let MethodName = "";
  96. let data = null;
  97. if (_this.userType == "TEACHER") {
  98. MethodName = "page_query-PageQueryMyCourseList";
  99. data = {
  100. finish_status: -1, // 完成状态列表, - 1 表示查询所有
  101. release_status: -1, // 发布状态 -1【全部】,1 【已发布】,0【未发布】
  102. name: "", // 课程名称,模糊查询
  103. page_capacity: _this.pageSize, // 每页容量,最大不能超过 200
  104. cur_page: _this.pageNum, // 当前查询第几页,页码序号从 1 开始
  105. };
  106. } else {
  107. MethodName = "page_query-PageQueryMyGoodsList";
  108. data = {
  109. goods_id_list: [], // 商品 ID 列表,空表示查询所有商品
  110. goods_type_list: JSON.parse(_this.activeIndex), // 商品类型列表,具体参看数据字典 6.9,订单商品类型。空表示查询所有类型
  111. goods_name: _this.goods_name, // 商品名称,模糊查询,空表示查询所有
  112. pay_status: 1, //支付状态 -1全部0未支付1已支付
  113. cancel_status: 0, //取消状态 -1 全部 0 未取消 1 已取消(只有未支付的订单才会有取消状态)
  114. page_capacity: _this.pageSize, // 每页容量,最大不能超过 200
  115. cur_page: _this.pageNum, // 当前查询第几页,页码序号从 1 开始
  116. };
  117. }
  118. getLearnWebContent(MethodName, data).then((res) => {
  119. _this.loading = false;
  120. this.total = res.total_count;
  121. let list = [];
  122. if (_this.userType == "TEACHER") {
  123. if (res.course_list && res.course_list.length > 0) {
  124. list = res.course_list;
  125. this.isEmpty = false;
  126. } else {
  127. this.isEmpty = true;
  128. }
  129. } else {
  130. if (res.goods_list && res.goods_list.length > 0) {
  131. list = res.goods_list;
  132. this.isEmpty = false;
  133. } else {
  134. this.isEmpty = true;
  135. }
  136. }
  137. list = list.map((item) => {
  138. item.checked = false;
  139. return item;
  140. });
  141. this.list = list;
  142. });
  143. },
  144. handleGoodsType(type) {
  145. let imgUrl = "",
  146. rootName = "";
  147. if (type == 401) {
  148. rootName = "Word";
  149. imgUrl = wordImg;
  150. }
  151. if (type == 402) {
  152. rootName = "Excel";
  153. imgUrl = excelImg;
  154. }
  155. if (type == 403) {
  156. rootName = "PPT";
  157. imgUrl = pptImg;
  158. }
  159. if (type == 404) {
  160. rootName = "PDF";
  161. imgUrl = pdfImg;
  162. }
  163. return { imgUrl: imgUrl, rootName: rootName };
  164. },
  165. handlePrice(price) {
  166. let str = "";
  167. price = toString("price");
  168. if (price.indexOf(".") > -1) {
  169. let arr = price.split(".");
  170. str = `<span class="num1">${arr[0]}</span>.<span class="num2">${arr[1]}</span>`;
  171. } else {
  172. str = `<span class="num1">${price}</span>.<span class="num2">00</span>`;
  173. }
  174. return str;
  175. },
  176. },
  177. //生命周期 - 创建完成(可以访问当前this实例)
  178. created() {},
  179. //生命周期 - 挂载完成(可以访问DOM元素)
  180. mounted() {
  181. this.getOrderList();
  182. },
  183. //生命周期-创建之前
  184. beforeCreated() {},
  185. //生命周期-挂载之前
  186. beforeMount() {},
  187. //生命周期-更新之前
  188. beforUpdate() {},
  189. //生命周期-更新之后
  190. updated() {},
  191. //生命周期-销毁之前
  192. beforeDestory() {},
  193. //生命周期-销毁完成
  194. destoryed() {},
  195. //如果页面有keep-alive缓存功能,这个函数会触发
  196. activated() {},
  197. };
  198. </script>
  199. <style lang="scss" scoped>
  200. /* @import url(); 引入css类 */
  201. .Teachcourse {
  202. .bookList {
  203. display: flex;
  204. flex-wrap: wrap;
  205. padding: 16px 32px;
  206. min-height: 400px;
  207. > div {
  208. width: 160px;
  209. margin: 0px 8px 24px 8px;
  210. cursor: pointer;
  211. .img-box {
  212. position: relative;
  213. width: 100%;
  214. .fengmian {
  215. box-sizing: border-box;
  216. width: 100%;
  217. height: 160px;
  218. display: flex;
  219. justify-content: center;
  220. align-items: center;
  221. border: 1px solid rgba(0, 0, 0, 0.15);
  222. > img {
  223. max-width: 100%;
  224. max-height: 100%;
  225. }
  226. }
  227. .checkout-box {
  228. position: absolute;
  229. border-radius: 10px 0 0 0;
  230. right: 0;
  231. bottom: 0;
  232. width: 24px;
  233. height: 24px;
  234. background: rgba(0, 0, 0, 0.5);
  235. display: flex;
  236. justify-content: center;
  237. align-items: center;
  238. }
  239. &.active {
  240. > img {
  241. border: 2px solid #ff9900;
  242. }
  243. .checkout-box {
  244. background: #ff9900;
  245. > img {
  246. width: 10px;
  247. height: 10px;
  248. }
  249. }
  250. }
  251. }
  252. > p.goods_name {
  253. height: 50px;
  254. padding: 8px 0 0 0;
  255. box-sizing: border-box;
  256. margin: 0;
  257. font-size: 14px;
  258. line-height: 150%;
  259. color: #2c2c2c;
  260. word-break: break-all;
  261. display: -webkit-box;
  262. -webkit-box-orient: vertical;
  263. -webkit-line-clamp: 2;
  264. text-overflow: ellipsis;
  265. overflow: hidden;
  266. }
  267. }
  268. }
  269. .paging {
  270. margin-left: 25px;
  271. margin-top: 88px;
  272. &.paging1 {
  273. margin-top: 0px;
  274. }
  275. }
  276. }
  277. </style>
  278. <style lang="scss">
  279. .Teachcourse {
  280. .el-pagination.is-background .el-pager li:not(.disabled).active {
  281. background: #ff9900;
  282. color: #fff;
  283. }
  284. }
  285. </style>