integralOrderPaySuccess.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view class="content">
  3. <view class="inner">
  4. <view class="top">
  5. <text class="title">兑换成功</text>
  6. <image class="icon" src="https://hdtobs.obs.cn-north-4.myhuaweicloud.com/miniapp/success.png" ></image>
  7. <view class="btn-box">
  8. <view class="btn cancel" @click="showOrderDetails(order.orderId)"> 查看订单</view>
  9. </view>
  10. </view>
  11. <!-- 订单详情查看 -->
  12. <view class="order-info">
  13. <view class="title">订单信息</view>
  14. <view class="item">
  15. <text class="label">订单编号</text>
  16. <view class="sn-box">
  17. <text class="text">{{order.orderCode}}</text>
  18. <view class="copy-btn" @click="copyTest(order.orderCode)">复制</view>
  19. </view>
  20. </view>
  21. <view class="item">
  22. <text class="label">支付金额</text>
  23. <text class="text">{{order.integral}}</text>
  24. </view>
  25. <view class="item">
  26. <text class="label">兑换时间</text>
  27. <text class="text">{{formattedCreateTime}}</text>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import {getIntegralOrderById} from '@/api/integral.js'
  35. export default {
  36. data() {
  37. return {
  38. order:null,
  39. }
  40. },
  41. onLoad(option) {
  42. uni.setNavigationBarTitle({
  43.   title:'支付结果'
  44. })
  45. uni.$emit('refreshStoreOrder');
  46. this.orderId=option.orderId;
  47. this.getIntegralOrderById();
  48. },
  49. computed:{
  50. formattedCreateTime() {
  51. if (!this.order || !this.order.createTime) return '';
  52. // 如果是时间戳格式
  53. if (typeof this.order.createTime === 'number') {
  54. const date = new Date(this.order.createTime);
  55. return this.formatDate(date);
  56. }
  57. // 如果是字符串格式,尝试解析
  58. const date = new Date(this.order.createTime);
  59. if (!isNaN(date.getTime())) {
  60. return this.formatDate(date);
  61. }
  62. // 如果无法解析,返回原值
  63. return this.order.createTime;
  64. },
  65. },
  66. methods: {
  67. // 日期格式化方法
  68. formatDate(date) {
  69. const year = date.getFullYear();
  70. const month = String(date.getMonth() + 1).padStart(2, '0');
  71. const day = String(date.getDate()).padStart(2, '0');
  72. const hours = String(date.getHours()).padStart(2, '0');
  73. const minutes = String(date.getMinutes()).padStart(2, '0');
  74. const seconds = String(date.getSeconds()).padStart(2, '0');
  75. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  76. },
  77. getIntegralOrderById(){
  78. var data = {orderId:this.orderId};
  79. var that=this;
  80. uni.showLoading();
  81. getIntegralOrderById(data).then(
  82. res => {
  83. uni.hideLoading();
  84. if(res.code==200){
  85. that.order=res.data;
  86. }else{
  87. uni.showToast({
  88. icon:'none',
  89. title: res.msg,
  90. });
  91. }
  92. },
  93. rej => {}
  94. );
  95. },
  96. copyTest(text) {
  97. // 复制方法
  98. uni.setClipboardData({
  99. data:text,
  100. success:()=>{
  101. uni.showToast({
  102. title:'内容已成功复制到剪切板',
  103. icon:'none'
  104. })
  105. }
  106. });
  107. },
  108. showOrderDetails(orderId){
  109. console.log(orderId)
  110. uni.redirectTo({
  111. url: "./integralOrderDetails?orderId="+orderId
  112. })
  113. }
  114. }
  115. }
  116. </script>
  117. <style lang="scss">
  118. page{
  119. height: 100%;
  120. }
  121. .content{
  122. height: 100%;
  123. display: flex;
  124. flex-direction: column;
  125. justify-content: space-between;
  126. .inner{
  127. padding: 20upx;
  128. .top{
  129. box-sizing: border-box;
  130. background: #FFFFFF;
  131. border-radius: 16upx;
  132. display: flex;
  133. flex-direction: column;
  134. align-items: center;
  135. padding: 50upx 0upx;
  136. .title{
  137. font-size: 40upx;
  138. font-family: PingFang SC;
  139. font-weight: 500;
  140. color: #222222;
  141. line-height: 1;
  142. text-align: center;
  143. }
  144. .icon{
  145. margin: 60upx 0upx;
  146. width: 100upx;
  147. height: 100upx;
  148. }
  149. }
  150. .order-info{
  151. margin-top: 20upx;
  152. background: #FFFFFF;
  153. border-radius: 16upx;
  154. padding: 40upx 30upx;
  155. .title{
  156. font-size: 30upx;
  157. font-family: PingFang SC;
  158. font-weight: bold;
  159. color: #222222;
  160. line-height: 1;
  161. }
  162. .item{
  163. margin-top: 40upx;
  164. display: flex;
  165. align-items: center;
  166. justify-content: space-between;
  167. .label{
  168. font-size: 26upx;
  169. font-family: PingFang SC;
  170. font-weight: 500;
  171. color: #666666;
  172. line-height: 1;
  173. }
  174. .text{
  175. font-size: 26upx;
  176. font-family: PingFang SC;
  177. font-weight: 500;
  178. color: #222222;
  179. line-height: 32upx;
  180. }
  181. .cont-text{
  182. font-size: 26upx;
  183. font-family: PingFang SC;
  184. font-weight: 500;
  185. color: #666666;
  186. .bold{
  187. color: #111111;
  188. }
  189. }
  190. .sn-box{
  191. display: flex;
  192. align-items: center;
  193. .copy-btn{
  194. width: 58upx;
  195. height: 32upx;
  196. line-height: 32upx;
  197. text-align: center;
  198. font-size: 22upx;
  199. font-family: PingFang SC;
  200. font-weight: 500;
  201. color: #222222;
  202. background: #F5F5F5;
  203. border-radius: 4upx;
  204. margin-left: 24upx;
  205. }
  206. }
  207. }
  208. .line{
  209. width: 100%;
  210. height: 1px;
  211. background: #F0F0F0;
  212. margin-top: 30upx;
  213. }
  214. }
  215. }
  216. .btn-box{
  217. margin-top: 20upx;
  218. box-sizing: border-box;
  219. display: flex;
  220. align-items: center;
  221. .btn{
  222. width: 155upx;
  223. height: 64upx;
  224. line-height: 64upx;
  225. font-size: 26upx;
  226. font-family: PingFang SC;
  227. font-weight: 500;
  228. text-align: center;
  229. border-radius: 32upx;
  230. &.cancel{
  231. border: 1px solid #DDDDDD;
  232. color: #666666;
  233. }
  234. }
  235. }
  236. }
  237. </style>