success.vue 5.3 KB

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