OrderList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. <template>
  2. <div class="my-share personal-info">
  3. <h2>订单管理</h2>
  4. <el-table
  5. :data="orderList"
  6. @sort-change="handleSort"
  7. :default-sort="dataSort"
  8. v-loading="tableLoading"
  9. :max-height="tableHeight"
  10. >
  11. <el-table-column
  12. type="index"
  13. label="#"
  14. width="48"
  15. :index="(pageNumber - 1) * pageSize + 1"
  16. >
  17. </el-table-column>
  18. <el-table-column prop="sn" label="交易单号" width="200">
  19. </el-table-column>
  20. <el-table-column
  21. prop="pay_time"
  22. label="交易时间"
  23. width="180"
  24. sortable="custom"
  25. >
  26. <template slot-scope="scope">
  27. {{ scope.row.pay_time ? scope.row.pay_time.substring(0, 16) : "-" }}
  28. </template>
  29. </el-table-column>
  30. <el-table-column prop="name" label="购买商品" min-width="220">
  31. </el-table-column>
  32. <el-table-column label="类型" width="72">
  33. <template slot-scope="scope" v-if="scope.row.goods_type >= 0">
  34. <span
  35. class="items-type"
  36. :style="{
  37. background: typeList[scope.row.goods_type]
  38. ? typeList[scope.row.goods_type].bg
  39. : '',
  40. color: typeList[scope.row.goods_type]
  41. ? typeList[scope.row.goods_type].color
  42. : '',
  43. }"
  44. >{{
  45. typeList[scope.row.goods_type]
  46. ? typeList[scope.row.goods_type].text
  47. : "-"
  48. }}</span
  49. >
  50. </template>
  51. </el-table-column>
  52. <el-table-column prop="goods_study_phase_name" label="学段" width="64">
  53. </el-table-column>
  54. <el-table-column prop="study" label="价格" width="154">
  55. <template slot-scope="scope">
  56. <span class="currectPrice"
  57. >¥{{
  58. scope.row.hasOwnProperty("goods_price_discount")
  59. ? scope.row.goods_price_discount
  60. : scope.row.goods_price | cutMoneyFiter
  61. }}</span
  62. >
  63. <span
  64. class="oldPrice"
  65. v-if="
  66. scope.row.hasOwnProperty('goods_price_discount') &&
  67. scope.row.goods_price_discount !== scope.row.goods_price
  68. "
  69. >(¥{{ scope.row.goods_price | cutMoneyFiter }})</span
  70. >
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="兑换码" width="194">
  74. <template slot-scope="scope">
  75. <template v-if="scope.row.is_use_discount_code == 'false'">
  76. </template>
  77. <template v-else>
  78. <template v-if="scope.row.discount_code">
  79. <span class="code" :id="'copy-' + scope.row.discount_code">{{
  80. scope.row.discount_code
  81. }}</span>
  82. <svg-icon
  83. icon-class="copy"
  84. class="copy"
  85. @click="CopyToClipboard('copy-' + scope.row.discount_code)"
  86. ></svg-icon>
  87. </template>
  88. <template v-else>-</template>
  89. </template>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="支付金额" width="96">
  93. <template slot-scope="scope">
  94. <span>¥{{ scope.row.order_amount | cutMoneyFiter }}</span>
  95. </template>
  96. </el-table-column>
  97. <el-table-column prop="pay_type_name" label="支付渠道" width="104">
  98. </el-table-column>
  99. <el-table-column prop="status" label="交易状态" width="112">
  100. <template slot-scope="scope">
  101. <div class="status-box">
  102. <span
  103. :style="{ background: statusList[scope.row.order_status].bg }"
  104. ></span>
  105. <b
  106. :style="{ color: statusList[scope.row.order_status].textColor }"
  107. >{{ scope.row.order_status_name }}</b
  108. >
  109. </div>
  110. </template>
  111. </el-table-column>
  112. <el-table-column prop="status" label="退款申请状态" width="112">
  113. <template
  114. slot-scope="scope"
  115. v-if="scope.row.is_has_refund_apply === 'true'"
  116. >
  117. <div class="status-box">
  118. <span
  119. :style="{
  120. background: refundStatusList[scope.row.refund_apply_status].bg,
  121. }"
  122. ></span>
  123. <b
  124. :style="{
  125. color:
  126. refundStatusList[scope.row.refund_apply_status].textColor,
  127. }"
  128. >{{ refundStatusList[scope.row.refund_apply_status].text }}</b
  129. >
  130. </div>
  131. </template>
  132. </el-table-column>
  133. <el-table-column
  134. prop="refund_apply_submit_time"
  135. label="退款申请时间"
  136. width="165"
  137. >
  138. </el-table-column>
  139. <el-table-column prop="refund_amount" label="退款金额" width="100">
  140. <template slot-scope="scope" v-if="scope.row.refund_apply_status === 2">
  141. <span>¥{{ scope.row.refund_amount | cutMoneyFiter }}</span>
  142. </template>
  143. </el-table-column>
  144. <el-table-column prop="status" label="操作" width="140" fixed="right">
  145. <template slot-scope="scope">
  146. <template
  147. v-if="
  148. scope.row.is_use_discount_code == 'false' &&
  149. scope.row.order_status === 1
  150. "
  151. >
  152. <a class="apply" @click="handleApply(scope.row, scope.$index)"
  153. >申请退款</a
  154. >
  155. </template>
  156. <template
  157. v-if="
  158. scope.row.order_status === 1 ||
  159. scope.row.order_status === 2 ||
  160. (scope.row.order_status === 3 &&
  161. scope.row.order_amount !== scope.row.refund_amount)
  162. "
  163. >
  164. <a class="apply" @click="handleToShlef">去查看</a>
  165. </template>
  166. <!-- <template v-if="scope.row.operate==='3'">
  167. <a class="order-detail"><svg-icon icon-class="question-line"></svg-icon>详情</a>
  168. </template>
  169. <template v-if="scope.row.operate==='4'">
  170. <a class="order-detail"><svg-icon icon-class="question-line"></svg-icon>详情</a>
  171. <a class="apply">申请退款</a>
  172. </template> -->
  173. </template>
  174. </el-table-column>
  175. </el-table>
  176. <el-pagination
  177. background
  178. @size-change="handleSizeChange"
  179. @current-change="handleCurrentChange"
  180. :current-page="pageNumber"
  181. :page-sizes="[10, 20, 30, 40, 50]"
  182. :page-size="pageSize"
  183. layout="total, prev, pager, next, sizes, jumper"
  184. :total="total_count"
  185. >
  186. </el-pagination>
  187. <div
  188. class="kefu-box"
  189. v-if="kefuShow"
  190. @mouseover="kefuCode = true"
  191. @mouseleave="kefuCode = false"
  192. >
  193. <div v-if="kefuCode" style="background: #ffffff">
  194. <img src="../../../assets/21st-kefu-code.jpg" />
  195. <span>扫一扫,添加客服微信</span>
  196. </div>
  197. <div v-else>
  198. <img class="kefu-img" src="../../../assets/kefu.png" />
  199. <span style="color: #ff3333; font-weight: bold; font-size: 16px"
  200. >客服咨询入口</span
  201. >
  202. </div>
  203. </div>
  204. </div>
  205. </template>
  206. <script>
  207. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  208. //例如:import 《组件名称》from ‘《组件路径》';
  209. import { cutMoneyFiter } from "@/utils/defined";
  210. import { getLogin } from "@/api/ajax";
  211. export default {
  212. //import引入的组件需要注入到对象中才能使用
  213. components: {},
  214. props: [],
  215. filters: {
  216. cutMoneyFiter,
  217. },
  218. data() {
  219. //这里存放数据
  220. return {
  221. pageSize: 10,
  222. pageNumber: 1,
  223. statusList: {
  224. 1: {
  225. text: "支付成功",
  226. bg: "#00B42A",
  227. textColor: "#1D2129",
  228. },
  229. 2: {
  230. text: "兑换成功",
  231. bg: "#165DFF",
  232. textColor: "#1D2129",
  233. },
  234. 4: {
  235. text: "已退款",
  236. textColor: "#0FC6C2",
  237. bg: "#0FC6C2",
  238. },
  239. 5: {
  240. text: "支付失败",
  241. bg: "#EF21DA",
  242. textColor: "#EF21DA",
  243. },
  244. 3: {
  245. text: "已撤回",
  246. bg: "#FF7D00",
  247. textColor: "#1D2129",
  248. },
  249. 0: {
  250. text: "未支付",
  251. bg: "#F53F3F",
  252. textColor: "#F53F3F",
  253. },
  254. },
  255. refundStatusList: {
  256. 2: {
  257. text: "审核通过",
  258. bg: "#00B42A",
  259. textColor: "#1D2129",
  260. },
  261. 0: {
  262. text: "待审核",
  263. bg: "#165DFF",
  264. textColor: "#1D2129",
  265. },
  266. 1: {
  267. text: "驳回",
  268. bg: "#FF7D00",
  269. textColor: "#1D2129",
  270. },
  271. },
  272. typeList: {
  273. 2: {
  274. text: "报纸",
  275. color: "#165DFF",
  276. bg: "#E8F7FF",
  277. },
  278. 4: {
  279. text: "画刊",
  280. color: "#F53F3F",
  281. bg: "#FFECE8",
  282. },
  283. 3: {
  284. text: "精读",
  285. color: "#0FC6C2",
  286. bg: "#E8FFFB",
  287. },
  288. 0: {
  289. text: "课程",
  290. color: "#722ED1",
  291. bg: "#F5E8FF",
  292. },
  293. 1: {
  294. text: "课程",
  295. color: "#722ED1",
  296. bg: "#F5E8FF",
  297. },
  298. // '5':{
  299. // text:'报纸专辑',
  300. // color:'#165DFF',
  301. // bg:'#E8F7FF'
  302. // },
  303. // '6':{
  304. // text:'画刊专辑',
  305. // color:'#F53F3F',
  306. // bg:'#FFECE8'
  307. // }
  308. },
  309. orderList: [],
  310. total_count: 0,
  311. dataSort: {
  312. prop: "pay_time",
  313. order: "descending",
  314. },
  315. tableLoading: false,
  316. tableHeight: "", // 表格高度
  317. kefuShow: true, // 是否显示客服
  318. kefuCode: false, // 显示客服二维码
  319. };
  320. },
  321. //计算属性 类似于data概念
  322. computed: {},
  323. //监控data中数据变化
  324. watch: {},
  325. //方法集合
  326. methods: {
  327. //计算table高度(动态设置table高度)
  328. getTableHeight() {
  329. let tableH = 260; //距离页面下方的高度
  330. let tableHeightDetil = window.innerHeight - tableH;
  331. if (tableHeightDetil <= 300) {
  332. this.tableHeight = 300;
  333. } else {
  334. this.tableHeight = window.innerHeight - tableH;
  335. }
  336. },
  337. handleSort(value) {
  338. let dataSort = {
  339. prop: value.prop,
  340. order: value.order,
  341. };
  342. this.dataSort = dataSort;
  343. this.getList();
  344. },
  345. handleSizeChange(val) {
  346. this.pageSize = val;
  347. this.pageNumber = 1;
  348. this.getList();
  349. },
  350. handleCurrentChange(val) {
  351. this.pageNumber = val;
  352. this.getList();
  353. },
  354. CopyToClipboard(element) {
  355. var doc = document,
  356. text = doc.getElementById(element),
  357. range,
  358. selection;
  359. if (doc.body.createTextRange) {
  360. range = doc.body.createTextRange();
  361. range.moveToElementText(text);
  362. range.select();
  363. } else if (window.getSelection) {
  364. selection = window.getSelection();
  365. range = doc.createRange();
  366. range.selectNodeContents(text);
  367. selection.removeAllRanges();
  368. selection.addRange(range);
  369. }
  370. document.execCommand("copy");
  371. this.$message({
  372. message: "复制成功",
  373. type: "success",
  374. });
  375. window.getSelection().removeAllRanges();
  376. },
  377. getList() {
  378. this.tableLoading = true;
  379. let MethodName = "/ShopServer/Client/OrderManager/PageQueryMyOrderList";
  380. let order_column_list = [];
  381. if (this.dataSort != {}) {
  382. if (this.dataSort.order == "descending") {
  383. order_column_list = [this.dataSort.prop + ":desc"];
  384. } else if (this.dataSort.order == "ascending") {
  385. // 升序不传值
  386. order_column_list = [this.dataSort.prop];
  387. }
  388. } else {
  389. order_column_list = ["pay_time:desc"];
  390. }
  391. let data = {
  392. page_capacity: this.pageSize,
  393. cur_page: this.pageNumber,
  394. order_column_list: order_column_list,
  395. pay_status: 1,
  396. };
  397. getLogin(MethodName, data)
  398. .then((res) => {
  399. this.tableLoading = false;
  400. if (res.status === 1) {
  401. this.orderList = res.order_list;
  402. this.total_count = res.total_count;
  403. }
  404. })
  405. .catch(() => {
  406. this.tableLoading = false;
  407. });
  408. },
  409. // 申请退款
  410. handleApply(obj, index) {
  411. let data = {
  412. order_id: obj.id,
  413. };
  414. getLogin(
  415. "/ShopServer/Client/OrderManager/CheckOrderIsCanSubmitRefundApply",
  416. data
  417. ).then((res) => {
  418. if (res.status === 1) {
  419. if (res.is_can_submit_refund_apply === "true") {
  420. this.$confirm("确定申请退款吗?", "提示", {
  421. confirmButtonText: "确定",
  422. cancelButtonText: "取消",
  423. type: "warning",
  424. })
  425. .then(() => {
  426. let Mname =
  427. "/ShopServer/Client/OrderManager/SubmitOrderRefundApply";
  428. getLogin(Mname, data).then((res) => {
  429. if (res.status === 1) {
  430. this.$message({
  431. type: "success",
  432. message: "申请成功!",
  433. });
  434. this.getList();
  435. }
  436. });
  437. })
  438. .catch(() => {});
  439. } else {
  440. this.$confirm(res.cannot_submit_reason, "不可退款原因", {
  441. confirmButtonText: "确定",
  442. showCancelButton: false,
  443. type: "warning",
  444. });
  445. }
  446. }
  447. });
  448. },
  449. handleToShlef() {
  450. this.$router.push({ path: "/bookShelf" });
  451. },
  452. },
  453. //生命周期 - 创建完成(可以访问当前this实例)
  454. created() {
  455. this.getTableHeight();
  456. this.getList();
  457. },
  458. //生命周期 - 挂载完成(可以访问DOM元素)
  459. mounted() {},
  460. //生命周期-创建之前
  461. beforeCreated() {},
  462. //生命周期-挂载之前
  463. beforeMount() {},
  464. //生命周期-更新之前
  465. beforUpdate() {},
  466. //生命周期-更新之后
  467. updated() {},
  468. //生命周期-销毁之前
  469. beforeDestory() {},
  470. //生命周期-销毁完成
  471. destoryed() {},
  472. //如果页面有keep-alive缓存功能,这个函数会触发
  473. activated() {},
  474. };
  475. </script>
  476. <style lang="scss" scoped>
  477. /* @import url(); 引入css类 */
  478. .my-share {
  479. background: #ffffff;
  480. border-radius: 4px;
  481. padding: 24px;
  482. h2 {
  483. font-weight: 500;
  484. font-size: 20px;
  485. line-height: 28px;
  486. color: #1d2129;
  487. margin: 0;
  488. }
  489. .el-table {
  490. margin: 24px 0;
  491. max-width: 100%;
  492. }
  493. .el-pagination {
  494. text-align: right;
  495. }
  496. .status-box {
  497. display: flex;
  498. align-items: center;
  499. span {
  500. width: 6px;
  501. height: 6px;
  502. border-radius: 3px;
  503. margin-right: 8px;
  504. margin-top: 2px;
  505. }
  506. b {
  507. font-weight: 400;
  508. font-size: 14px;
  509. line-height: 22px;
  510. color: #1d2129;
  511. }
  512. }
  513. .order-detail {
  514. color: #165dff;
  515. margin-right: 8px;
  516. }
  517. .apply {
  518. font-size: 14px;
  519. line-height: 22px;
  520. color: #165dff;
  521. margin-right: 10px;
  522. font-weight: 500;
  523. }
  524. .items-type {
  525. padding: 1px 8px;
  526. font-weight: 500;
  527. font-size: 14px;
  528. line-height: 22px;
  529. border-radius: 2px;
  530. }
  531. .oldPrice {
  532. color: #86909c;
  533. margin-left: 8px;
  534. }
  535. .code {
  536. color: #175dff;
  537. }
  538. .copy {
  539. color: #c9cdd4;
  540. margin-left: 8px;
  541. cursor: pointer;
  542. }
  543. .kefu-box {
  544. position: fixed;
  545. right: 0;
  546. bottom: 300px;
  547. z-index: 3;
  548. text-align: center;
  549. cursor: pointer;
  550. img {
  551. width: 150px;
  552. }
  553. .kefu-img {
  554. width: 70px;
  555. }
  556. span {
  557. display: block;
  558. text-align: center;
  559. font-size: 12px;
  560. line-height: 1.4;
  561. }
  562. }
  563. }
  564. </style>