Traincourse.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <!-- 我的课程 -->
  3. <div class="Teachcourse personal-center">
  4. <EditTitle :title="title" />
  5. <el-menu
  6. :default-active="activeIndex"
  7. class="el-menu-demo"
  8. mode="horizontal"
  9. @select="handleSelect"
  10. >
  11. <el-menu-item
  12. v-for="(item, acIndex) in activeList"
  13. :index="item.code"
  14. :key="'nav' + acIndex"
  15. >{{ item.name }}</el-menu-item
  16. >
  17. </el-menu>
  18. <template v-if="!isEmpty">
  19. <div class="bookList">
  20. <div v-for="(item, i) in list" :key="i" @click="jump(item)">
  21. <div class="img-box" :class="item.checked ? 'active' : ''">
  22. <div class="fengmian">
  23. <img :src="item.goods_picture_url" alt="" />
  24. </div>
  25. <div class="checkout-box" v-if="isShowCheckBox">
  26. <img src="@/assets/Personalcenter/selected-icon.png" />
  27. </div>
  28. </div>
  29. <p class="goods_name">{{ item.goods_name }}</p>
  30. </div>
  31. </div>
  32. <div class="paging" :class="list.length < 16 ? 'paging1' : ''">
  33. <el-pagination
  34. background
  35. layout="prev, pager, next"
  36. :current-page="pageNum"
  37. :total="total"
  38. :page-size="pageSize"
  39. @current-change="changecurrentPage"
  40. />
  41. </div>
  42. </template>
  43. <template v-else>
  44. <Empty :navType="navType" />
  45. </template>
  46. </div>
  47. </template>
  48. <script>
  49. import EditTitle from "../common/EditTitle.vue";
  50. import { getLearnWebContent } from "@/api/ajax";
  51. import { jumpPath } from "@/utils/jumpPath";
  52. import Empty from "../common/Empty.vue";
  53. export default {
  54. components: { EditTitle, Empty },
  55. props: {},
  56. data() {
  57. //这里存放数据
  58. return {
  59. navType: "3",
  60. isEmpty: false,
  61. activeIndex: "[301, 302, 303]",
  62. activeList: [
  63. {
  64. code: "[301, 302, 303]",
  65. name: this.$t("Key110"), //"全部",
  66. },
  67. {
  68. code: "[302]",
  69. name: this.$t("Key74"), //"视频",
  70. },
  71. {
  72. code: "[301]",
  73. name: this.$t("Key75"), // "直播",
  74. },
  75. {
  76. code: "[303]",
  77. name: this.$t("Key42"), //"线下活动",
  78. },
  79. ],
  80. goods_name: "",
  81. total: 0,
  82. pageSize: 20,
  83. pageNum: 1,
  84. list: [],
  85. loading: false,
  86. isShowCheckBox: false,
  87. title: this.$t("Key63"),
  88. };
  89. },
  90. //计算属性 类似于data概念
  91. computed: {},
  92. //监控data中数据变化
  93. watch: {},
  94. //方法集合
  95. methods: {
  96. jump(item) {
  97. jumpPath(item);
  98. },
  99. // 选择已购买还是待付款
  100. handleSelect(val) {
  101. let _this = this;
  102. _this.activeIndex = val;
  103. _this.navValue = "";
  104. _this.pageNum = 1;
  105. _this.goods_name = "";
  106. this.getOrderList();
  107. },
  108. changeNav() {
  109. console.log(this.navValue);
  110. },
  111. changecurrentPage(val) {
  112. this.pageNum = val;
  113. this.getOrderList();
  114. },
  115. //分页查询我的订单列表
  116. getOrderList() {
  117. let _this = this;
  118. _this.loading = true;
  119. let MethodName = "page_query-PageQueryMyGoodsList";
  120. let data = {
  121. goods_id_list: [], // 商品 ID 列表,空表示查询所有商品
  122. goods_type_list: JSON.parse(_this.activeIndex), // 商品类型列表,具体参看数据字典 6.9,订单商品类型。空表示查询所有类型
  123. goods_name: _this.goods_name, // 商品名称,模糊查询,空表示查询所有
  124. pay_status: 1, //支付状态 -1全部0未支付1已支付
  125. cancel_status: 0, //取消状态 -1 全部 0 未取消 1 已取消(只有未支付的订单才会有取消状态)
  126. page_capacity: _this.pageSize, // 每页容量,最大不能超过 200
  127. cur_page: _this.pageNum, // 当前查询第几页,页码序号从 1 开始
  128. };
  129. getLearnWebContent(MethodName, data).then((res) => {
  130. _this.loading = false;
  131. this.total = res.total_count;
  132. if (res.goods_list && res.goods_list.length > 0) {
  133. let list = res.goods_list;
  134. list = list.map((item) => {
  135. // let obj = this.handleGoodsType(item.goods_type);
  136. // console.log(obj);
  137. // item.coverUrl = obj.imgUrl;
  138. // item.goods_type_root_name = obj.rootName;
  139. item.checked = false;
  140. return item;
  141. });
  142. this.list = list;
  143. console.log(this.list);
  144. this.isEmpty = false;
  145. } else {
  146. this.isEmpty = true;
  147. }
  148. });
  149. },
  150. handleGoodsType(type) {
  151. let imgUrl = "",
  152. rootName = "";
  153. if (type == 401) {
  154. rootName = "Word";
  155. imgUrl = wordImg;
  156. }
  157. if (type == 402) {
  158. rootName = "Excel";
  159. imgUrl = excelImg;
  160. }
  161. if (type == 403) {
  162. rootName = "PPT";
  163. imgUrl = pptImg;
  164. }
  165. if (type == 404) {
  166. rootName = "PDF";
  167. imgUrl = pdfImg;
  168. }
  169. return { imgUrl: imgUrl, rootName: rootName };
  170. },
  171. handlePrice(price) {
  172. let str = "";
  173. price = toString("price");
  174. if (price.indexOf(".") > -1) {
  175. let arr = price.split(".");
  176. str = `<span class="num1">${arr[0]}</span>.<span class="num2">${arr[1]}</span>`;
  177. } else {
  178. str = `<span class="num1">${price}</span>.<span class="num2">00</span>`;
  179. }
  180. return str;
  181. },
  182. close(item) {
  183. item.isPop = false;
  184. },
  185. //删除
  186. deleteMyOrder(id) {
  187. let _this = this;
  188. // "此操作将永久删除该订单, 是否继续?"
  189. _this
  190. .$confirm(_this.$t("Key103"), _this.$t("Key361"), {
  191. confirmButtonText: _this.$t("Key94"),
  192. cancelButtonText: _this.$t("Key83"),
  193. type: "warning",
  194. })
  195. .then(() => {
  196. _this.setDeleteMyOrder(id);
  197. })
  198. .catch(() => {
  199. this.$message({
  200. type: "info",
  201. message: this.$t("Key673"), //Key673 已取消删除
  202. });
  203. });
  204. },
  205. setDeleteMyOrder(id) {
  206. let _this = this;
  207. let MethodName = "order-order_manager-DeleteMyOrder";
  208. let data = {
  209. id: id,
  210. };
  211. getLearnWebContent(MethodName, data).then((res) => {
  212. _this.$message.success(this.$t("Key532"));
  213. _this.handleSelect(this.activeIndex);
  214. });
  215. },
  216. // 处理价格
  217. changePrice(type, item) {
  218. if (item.indexOf(".") != -1) {
  219. if (type == 1) {
  220. return item.split(".")[0];
  221. } else if (type == 2) {
  222. return "." + item.split(".")[1];
  223. }
  224. } else {
  225. if (type == 1) {
  226. return item;
  227. }
  228. }
  229. },
  230. },
  231. //生命周期 - 创建完成(可以访问当前this实例)
  232. created() {},
  233. //生命周期 - 挂载完成(可以访问DOM元素)
  234. mounted() {
  235. this.getOrderList();
  236. },
  237. //生命周期-创建之前
  238. beforeCreated() {},
  239. //生命周期-挂载之前
  240. beforeMount() {},
  241. //生命周期-更新之前
  242. beforUpdate() {},
  243. //生命周期-更新之后
  244. updated() {},
  245. //生命周期-销毁之前
  246. beforeDestory() {},
  247. //生命周期-销毁完成
  248. destoryed() {},
  249. //如果页面有keep-alive缓存功能,这个函数会触发
  250. activated() {},
  251. };
  252. </script>
  253. <style lang="scss" scoped>
  254. /* @import url(); 引入css类 */
  255. .Teachcourse {
  256. .bookList {
  257. display: flex;
  258. flex-wrap: wrap;
  259. padding: 16px 32px;
  260. min-height: 400px;
  261. > div {
  262. width: 160px;
  263. margin: 0px 8px 24px 8px;
  264. cursor: pointer;
  265. .img-box {
  266. position: relative;
  267. width: 100%;
  268. .fengmian {
  269. box-sizing: border-box;
  270. width: 100%;
  271. height: 160px;
  272. display: flex;
  273. justify-content: center;
  274. align-items: center;
  275. border: 1px solid rgba(0, 0, 0, 0.15);
  276. > img {
  277. max-width: 100%;
  278. max-height: 100%;
  279. }
  280. }
  281. .checkout-box {
  282. position: absolute;
  283. border-radius: 10px 0 0 0;
  284. right: 0;
  285. bottom: 0;
  286. width: 24px;
  287. height: 24px;
  288. background: rgba(0, 0, 0, 0.5);
  289. display: flex;
  290. justify-content: center;
  291. align-items: center;
  292. }
  293. &.active {
  294. > img {
  295. border: 2px solid #ff9900;
  296. }
  297. .checkout-box {
  298. background: #ff9900;
  299. > img {
  300. width: 10px;
  301. height: 10px;
  302. }
  303. }
  304. }
  305. }
  306. > p.goods_name {
  307. height: 50px;
  308. padding: 8px 0 0 0;
  309. box-sizing: border-box;
  310. margin: 0;
  311. font-size: 14px;
  312. line-height: 150%;
  313. color: #2c2c2c;
  314. word-break: break-all;
  315. display: -webkit-box;
  316. -webkit-box-orient: vertical;
  317. -webkit-line-clamp: 2;
  318. text-overflow: ellipsis;
  319. overflow: hidden;
  320. text-align: center;
  321. }
  322. }
  323. }
  324. .paging {
  325. margin-left: 25px;
  326. margin-top: 44px;
  327. &.paging1 {
  328. margin-top: 0px;
  329. }
  330. }
  331. }
  332. </style>
  333. <style lang="scss">
  334. .Teachcourse {
  335. .el-menu.el-menu--horizontal {
  336. border: 0;
  337. padding: 0 32px;
  338. }
  339. .el-menu--horizontal > .el-menu-item {
  340. height: 44px;
  341. font-size: 16px;
  342. line-height: 44px;
  343. text-align: center;
  344. padding: 0;
  345. margin-right: 24px;
  346. }
  347. .el-menu--horizontal > .el-menu-item.is-active {
  348. border-bottom: 1px solid #ff9900;
  349. color: #ff9900;
  350. }
  351. .el-pagination.is-background .el-pager li:not(.disabled).active {
  352. background: #ff9900;
  353. color: #fff;
  354. }
  355. }
  356. </style>