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