Mytextbook.vue 8.7 KB

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