orderlist.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <view class="orderlist-container">
  3. <view class="list-content">
  4. <view class="title">订单记录</view>
  5. <view class="list">
  6. <view class="list-item" v-for="(order, index) in orderList" :key="index">
  7. <view class="title">
  8. {{ order.description }}
  9. </view>
  10. <view class="item">
  11. 订单金额:<span>¥{{ order.amount / 100 }}</span>
  12. </view>
  13. <view class="item">
  14. 订单状态:<span>{{ PAY_STATUS[order.status] }}</span>
  15. </view>
  16. <view class="item">
  17. 商户订单号:<span @click="handleCopy(order.outTradeNo)">{{ order.outTradeNo ? order.outTradeNo : '-'}}</span>
  18. </view>
  19. <view class="item">
  20. 微信订单号:<span @click="handleCopy(order.wxOrderId)">{{ order.wxOrderId ? order.wxOrderId : '-'}}</span>
  21. </view>
  22. <view class="item">
  23. 订单创建时间:<span>{{ dateFormat(order.createTime, 'yyyy-MM-dd hh:mm:ss') }}</span>
  24. </view>
  25. </view>
  26. <view class="list-item" v-if="!over" @click="loadMore">
  27. 加载更多
  28. </view>
  29. </view>
  30. <view class="empty" v-if="orderList.length == 0 || isIOS">
  31. 暂无订单
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import { getOrders } from '@/api/index.js';
  38. import { PAY_STATUS, PAY_TYPE, PAY_TYPE_NAME } from '@/common/enum.js'
  39. import { mapState, mapMutations } from 'vuex'
  40. import { dateFormat } from '@/common/util.js'
  41. import { curVersion } from '@/common/config.js'
  42. var app = getApp();
  43. export default {
  44. data() {
  45. return {
  46. PAY_STATUS,
  47. over: true,
  48. orderList: [
  49. // {
  50. // "id": 1, // 订单ID
  51. // "createTime": 1678199732898, // 下单时间
  52. // "type": "MONTHLY", // 订单类别
  53. // "status": "CANCELED", // 订单状态,CANCELED:已取消,INIT:等待支付,PAID:支付成功
  54. // "outTradeNo": "090c96d00a3947c4aec72587b2fd8453", // 商户订单号
  55. // "description": "AI降临派-包月", // 商品描述
  56. // "amount": 1, // 金额,单位(分)
  57. // "wxOrderId": "wxasdadf1213fesd21334", // 微信订单号,只有支付成功才会有
  58. // "successTime": 1678199732898 ,// 支付成功时间,只有支付成功才会有
  59. // }
  60. ],
  61. page: 1,
  62. pageSize: 30,
  63. loaded: false,
  64. isIOS: app.globalData.isIOS
  65. };
  66. },
  67. onLoad() {
  68. if (!this.chatToken || curVersion !== this.version) {
  69. this.$store.dispatch('login').then(rst => {
  70. this.getOrderList()
  71. })
  72. } else {
  73. this.getOrderList()
  74. }
  75. },
  76. computed: {
  77. ...mapState(['chatToken', 'version','userId', 'isVIP', 'expireTime'])
  78. },
  79. methods: {
  80. dateFormat,
  81. loadMore() {
  82. this.getOrderList();
  83. },
  84. async getOrderList() {
  85. if (this.isIOS) {
  86. this.loaded = true
  87. return
  88. }
  89. const res = await getOrders(this.page, this.pageSize)
  90. this.loaded = true
  91. if (res.code === 0 && res.data && res.data.list) {
  92. this.orderList = this.orderList.concat(res.data.list)
  93. this.over = res.data.list.length < this.pageSize
  94. this.page++
  95. }
  96. },
  97. handleCopy(str) {
  98. const that = this
  99. wx.setClipboardData({
  100. data: str, //这个是要复制的数据
  101. success (res) {
  102. wx.showToast({
  103. title: '复制成功',
  104. icon: 'success',
  105. duration: 1500
  106. })
  107. }
  108. })
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang="less" scoped>
  114. .orderlist-container {
  115. padding: 20rpx 30rpx 40rpx;
  116. background-color: @mainBg;
  117. height: 100%;
  118. color: #EDEDED;
  119. overflow: auto;
  120. .list-content {
  121. .title {
  122. font-size: 32rpx;
  123. padding-bottom: 20rpx;
  124. }
  125. .list {
  126. .list-item {
  127. padding: 30rpx;
  128. border-radius: 8rpx;
  129. background-color: @lightBg;
  130. margin-bottom: 20rpx;
  131. .item {
  132. line-height: 1.6;
  133. span {
  134. color: @mainColor;
  135. &:active {
  136. color: lighten(@mainColor, 5%);
  137. }
  138. }
  139. }
  140. }
  141. }
  142. .empty {
  143. background-color: @lightBg;
  144. display: flex;
  145. align-items: center;
  146. justify-content: center;
  147. height: 200rpx;
  148. border-radius: 8rpx;
  149. color: @fontColor;
  150. }
  151. }
  152. }
  153. </style>