success.vue 5.0 KB

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