TeachMaterial.vue 9.5 KB

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