OrderList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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. </el-table-column>
  17. <el-table-column
  18. prop="sn"
  19. label="交易单号"
  20. width="200">
  21. </el-table-column>
  22. <el-table-column
  23. prop="pay_time"
  24. label="交易时间"
  25. width="180"
  26. sortable="custom">
  27. <template slot-scope="scope">
  28. {{scope.row.pay_time?scope.row.pay_time.substring(0,16):'-'}}
  29. </template>
  30. </el-table-column>
  31. <el-table-column
  32. prop="goods_name"
  33. label="购买商品"
  34. min-width="220">
  35. </el-table-column>
  36. <el-table-column
  37. label="类型"
  38. width="72">
  39. <template slot-scope="scope" v-if="scope.row.goods_type>=0">
  40. <span class="items-type" :style="{background:typeList[scope.row.goods_type]?typeList[scope.row.goods_type].bg:'', color:typeList[scope.row.goods_type]?typeList[scope.row.goods_type].color:''}">{{typeList[scope.row.goods_type]?typeList[scope.row.goods_type].text:'-'}}</span>
  41. </template>
  42. </el-table-column>
  43. <el-table-column
  44. prop="goods_study_phase_name"
  45. label="学段"
  46. width="64">
  47. </el-table-column>
  48. <el-table-column
  49. prop="study"
  50. label="价格"
  51. width="154">
  52. <template slot-scope="scope">
  53. <span class="currectPrice">¥{{scope.row.goods_price_discount?scope.row.goods_price_discount:scope.row.goods_price | cutMoneyFiter}}</span>
  54. <span class="oldPrice" v-if="scope.row.goods_price_discount&&scope.row.goods_price_discount!==scope.row.goods_price">(¥{{scope.row.goods_price | cutMoneyFiter}})</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column
  58. label="兑换码"
  59. width="160">
  60. <template slot-scope="scope">
  61. <template v-if="scope.row.is_use_discount_code=='false'">
  62. 未使用
  63. </template>
  64. <template v-else>
  65. <span class="code" :id="'copy-'+scope.row.discount_code">{{scope.row.discount_code}}</span>
  66. <svg-icon icon-class="copy" class="copy" @click="CopyToClipboard('copy-'+scope.row.discount_code)"></svg-icon>
  67. </template>
  68. </template>
  69. </el-table-column>
  70. <el-table-column
  71. label="支付金额"
  72. width="96">
  73. <template slot-scope="scope">
  74. <span v-if="scope.row.pay_amount">¥{{scope.row.pay_amount | cutMoneyFiter}}</span>
  75. <span v-else>-</span>
  76. </template>
  77. </el-table-column>
  78. <el-table-column
  79. prop="pay_type_name"
  80. label="支付渠道"
  81. width="104">
  82. </el-table-column>
  83. <el-table-column
  84. prop="status"
  85. label="交易状态"
  86. width="112">
  87. <template slot-scope="scope">
  88. <div class="status-box">
  89. <span :style="{background:statusList[scope.row.is_pay==='true'&&scope.row.is_use_discount_code==='true'?'success2':scope.row.is_pay==='true'&&scope.row.is_use_discount_code==='false'?'success':'refundFail'].bg}"></span>
  90. <b :style="{color:statusList[scope.row.is_pay==='true'&&scope.row.is_use_discount_code==='true'?'success2':scope.row.is_pay==='true'&&scope.row.is_use_discount_code==='false'?'success':'refundFail'].textColor}">{{statusList[scope.row.is_pay==='true'&&scope.row.is_use_discount_code==='true'?'success2':scope.row.is_pay==='true'&&scope.row.is_use_discount_code==='false'?'success':'refundFail'].text}}</b>
  91. </div>
  92. </template>
  93. </el-table-column>
  94. <!-- <el-table-column
  95. prop="status"
  96. label="操作"
  97. width="150"
  98. fixed='right'>
  99. <template slot-scope="scope">
  100. <template v-if="scope.row.operate==='1'">
  101. <a class="apply">申请退款</a>
  102. </template>
  103. <template v-if="scope.row.operate==='3'">
  104. <a class="order-detail"><svg-icon icon-class="question-line"></svg-icon>详情</a>
  105. </template>
  106. <template v-if="scope.row.operate==='4'">
  107. <a class="order-detail"><svg-icon icon-class="question-line"></svg-icon>详情</a>
  108. <a class="apply">申请退款</a>
  109. </template>
  110. </template>
  111. </el-table-column> -->
  112. </el-table>
  113. <el-pagination
  114. background
  115. @size-change="handleSizeChange"
  116. @current-change="handleCurrentChange"
  117. :current-page="pageNumber"
  118. :page-sizes="[10, 20, 30, 40, 50]"
  119. :page-size="pageSize"
  120. layout="total, prev, pager, next, sizes, jumper"
  121. :total="total_count">
  122. </el-pagination>
  123. </div>
  124. </template>
  125. <script>
  126. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  127. //例如:import 《组件名称》from ‘《组件路径》';
  128. import { cutMoneyFiter } from '@/utils/defined';
  129. import { getLogin } from "@/api/ajax";
  130. export default {
  131. //import引入的组件需要注入到对象中才能使用
  132. components: { },
  133. props: [],
  134. filters:{
  135. cutMoneyFiter
  136. },
  137. data() {
  138. //这里存放数据
  139. return {
  140. pageSize: 10,
  141. pageNumber: 1,
  142. statusList:{
  143. 'success':{
  144. text:'支付成功',
  145. bg:'#00B42A',
  146. textColor:'#1D2129'
  147. },
  148. 'success2':{
  149. text:'兑换成功',
  150. bg:'#165DFF',
  151. textColor:'#1D2129'
  152. },
  153. 'refunded':{
  154. text:'已退款',
  155. bg:'#EF21DA',
  156. textColor:'#EF21DA'
  157. },
  158. 'refundFail':{
  159. text:'支付失败',
  160. bg:'#F53F3F',
  161. textColor:'#F53F3F'
  162. },
  163. 'refunding':{
  164. text:'申请退款中',
  165. bg:'#F53F3F',
  166. textColor:'#F53F3F'
  167. }
  168. },
  169. typeList:{
  170. 2:{
  171. text:'报纸',
  172. color:'#165DFF',
  173. bg:'#E8F7FF'
  174. },
  175. // '2':{
  176. // text:'画刊',
  177. // color:'#F53F3F',
  178. // bg:'#FFECE8'
  179. // },
  180. '3':{
  181. text:'精读',
  182. color:'#0FC6C2',
  183. bg:'#E8FFFB'
  184. },
  185. 0:{
  186. text:'课程',
  187. color:'#722ED1',
  188. bg:'#F5E8FF'
  189. },
  190. 1:{
  191. text:'课程',
  192. color:'#722ED1',
  193. bg:'#F5E8FF'
  194. },
  195. // '5':{
  196. // text:'报纸专辑',
  197. // color:'#165DFF',
  198. // bg:'#E8F7FF'
  199. // },
  200. // '6':{
  201. // text:'画刊专辑',
  202. // color:'#F53F3F',
  203. // bg:'#FFECE8'
  204. // }
  205. },
  206. orderList:[],
  207. total_count: 0,
  208. dataSort: {},
  209. tableLoading: false,
  210. tableHeight: "", // 表格高度
  211. }
  212. },
  213. //计算属性 类似于data概念
  214. computed: {},
  215. //监控data中数据变化
  216. watch: {
  217. },
  218. //方法集合
  219. methods: {
  220. //计算table高度(动态设置table高度)
  221. getTableHeight() {
  222. let tableH = 260; //距离页面下方的高度
  223. let tableHeightDetil = window.innerHeight - tableH;
  224. if (tableHeightDetil <= 300) {
  225. this.tableHeight = 300;
  226. } else {
  227. this.tableHeight = window.innerHeight - tableH;
  228. }
  229. },
  230. handleSort(value){
  231. let dataSort = {
  232. prop: value.prop,
  233. order: value.order
  234. }
  235. this.dataSort = dataSort
  236. this.getList()
  237. },
  238. handleSizeChange(val) {
  239. this.pageSize = val
  240. this.pageNumber = 1
  241. this.getList()
  242. },
  243. handleCurrentChange(val) {
  244. this.pageNumber = val
  245. this.getList()
  246. },
  247. CopyToClipboard(element) {
  248. var doc = document,
  249. text = doc.getElementById(element),
  250. range,
  251. selection;
  252. if (doc.body.createTextRange) {
  253. range = doc.body.createTextRange();
  254. range.moveToElementText(text);
  255. range.select();
  256. } else if (window.getSelection) {
  257. selection = window.getSelection();
  258. range = doc.createRange();
  259. range.selectNodeContents(text);
  260. selection.removeAllRanges();
  261. selection.addRange(range);
  262. }
  263. document.execCommand("copy");
  264. this.$message({
  265. message: "复制成功",
  266. type: "success",
  267. });
  268. window.getSelection().removeAllRanges();
  269. },
  270. getList(){
  271. this.tableLoading = true
  272. let MethodName = "/ShopServer/Client/OrderManager/PageQueryMyOrderList";
  273. let order_column_list = []
  274. if(this.dataSort != {}){
  275. if(this.dataSort.order=='descending'){
  276. order_column_list = [this.dataSort.prop + ':desc']
  277. }else if(this.dataSort.order=='ascending'){
  278. // 升序不传值
  279. order_column_list = [this.dataSort.prop]
  280. }
  281. }
  282. let data = {
  283. page_capacity:this.pageSize,
  284. cur_page:this.pageNumber,
  285. order_column_list: order_column_list,
  286. pay_status:1
  287. }
  288. getLogin(MethodName, data)
  289. .then((res) => {
  290. this.tableLoading = false
  291. if(res.status===1){
  292. this.orderList = res.order_list
  293. this.total_count = res.total_count
  294. }
  295. })
  296. .catch(() => {
  297. this.tableLoading = false
  298. });
  299. }
  300. },
  301. //生命周期 - 创建完成(可以访问当前this实例)
  302. created() {
  303. this.getTableHeight()
  304. this.getList()
  305. },
  306. //生命周期 - 挂载完成(可以访问DOM元素)
  307. mounted() {
  308. },
  309. //生命周期-创建之前
  310. beforeCreated() { },
  311. //生命周期-挂载之前
  312. beforeMount() { },
  313. //生命周期-更新之前
  314. beforUpdate() { },
  315. //生命周期-更新之后
  316. updated() { },
  317. //生命周期-销毁之前
  318. beforeDestory() { },
  319. //生命周期-销毁完成
  320. destoryed() { },
  321. //如果页面有keep-alive缓存功能,这个函数会触发
  322. activated() { }
  323. }
  324. </script>
  325. <style lang="scss" scoped>
  326. /* @import url(); 引入css类 */
  327. .my-share{
  328. background: #FFFFFF;
  329. border-radius: 4px;
  330. padding: 24px;
  331. h2{
  332. font-weight: 500;
  333. font-size: 20px;
  334. line-height: 28px;
  335. color: #1D2129;
  336. margin: 0;
  337. }
  338. .el-table{
  339. margin: 24px 0;
  340. max-width: 100%;
  341. }
  342. .el-pagination{
  343. text-align: right;
  344. }
  345. .status-box{
  346. display: flex;
  347. align-items: center;
  348. span{
  349. width: 6px;
  350. height: 6px;
  351. border-radius: 3px;
  352. margin-right: 8px;
  353. margin-top: 2px;
  354. }
  355. b{
  356. font-weight: 400;
  357. font-size: 14px;
  358. line-height: 22px;
  359. color: #1D2129;
  360. }
  361. }
  362. .order-detail{
  363. color: #165DFF;
  364. margin-right: 8px;
  365. }
  366. .apply{
  367. font-size: 14px;
  368. line-height: 22px;
  369. color: #86909C;
  370. }
  371. .items-type{
  372. padding: 1px 8px;
  373. font-weight: 500;
  374. font-size: 14px;
  375. line-height: 22px;
  376. border-radius: 2px;
  377. }
  378. .oldPrice{
  379. color: #86909C;
  380. margin-left: 8px;
  381. }
  382. .code{
  383. color: #175DFF;
  384. }
  385. .copy{
  386. color: #C9CDD4;
  387. margin-left: 8px;
  388. cursor: pointer;
  389. }
  390. }
  391. </style>