海南旅游项目 前端仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
2.7 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <template>
  2. <view></view>
  3. </template>
  4. <script>
  5. export default {
  6. data() {
  7. return {
  8. order_id: 0,
  9. timesIndex: 0,
  10. userInfo: {},
  11. payErr: {},
  12. paySuccecc: {}
  13. }
  14. },
  15. onShow(e) {
  16. // this.order_id = uni.getStorageSync('order_id')
  17. let that = this
  18. uni.$on('order_id',function(data){
  19. that.order_id = data.msg
  20. if (that.order_id) {
  21. that.getUserProfile()
  22. } else {
  23. that.$msg('获取订单失败');
  24. }
  25. })
  26. },
  27. methods: {
  28. // 获取用户信息
  29. getUserProfile() {
  30. let that = this
  31. uni.login({
  32. complete: result => {
  33. if (result.errMsg == 'login:ok') {
  34. let code = result.code;
  35. that.$http(that.API.API_WXLOGIN, {
  36. code
  37. }).then(res => {
  38. uni.setStorageSync('userinfo', res.data);
  39. that.userInfo = JSON.stringify(res.data)
  40. uni.showModal({
  41. title: '支付提示',
  42. content: '确认支付吗?',
  43. confirmColor: '#1998FE',
  44. showCancel: false,
  45. success(res2) {
  46. if (res2.confirm) {
  47. that.payOnce();
  48. }
  49. }
  50. });
  51. })
  52. }
  53. }
  54. })
  55. },
  56. payOnce() {
  57. let that = this;
  58. that.$http(that.API.API_LF_PAY, {
  59. id: that.order_id
  60. }).then(res => {
  61. uni.requestPayment({
  62. orderInfo: res.data.order_num,
  63. timeStamp: res.data.timeStamp,
  64. nonceStr: res.data.nonceStr,
  65. package: res.data.package,
  66. signType: res.data.signType,
  67. paySign: res.data.paySign,
  68. success: (res) => {
  69. wx.navigateBackMiniProgram({
  70. extraData: {
  71. backPayState: true,
  72. payorder_id: that.order_id
  73. },
  74. success(res) {}
  75. })
  76. },
  77. fail: (err) => {
  78. wx.navigateBackMiniProgram({
  79. extraData: {
  80. backPayState: false,
  81. payorder_id: that.order_id
  82. },
  83. success(res) {}
  84. })
  85. },
  86. })
  87. }).catch(err => {
  88. uni.showModal({
  89. title: '提示',
  90. content: '支付获取订单失败',
  91. showCancel: false,
  92. success(res2) {
  93. if (res2.confirm) {
  94. wx.navigateBackMiniProgram({
  95. extraData: {
  96. backPayState: false,
  97. payorder_id: that.order_id
  98. },
  99. success(res) {}
  100. })
  101. }
  102. }
  103. });
  104. })
  105. }
  106. }
  107. }
  108. </script>
  109. <style>
  110. .btn {
  111. margin: 0;
  112. padding: 0;
  113. width: 212rpx;
  114. height: 82rpx;
  115. background-color: #1998FE;
  116. color: #FFFFFF;
  117. line-height: 80rpx;
  118. font-size: 32rpx;
  119. border-radius: 41rpx;
  120. }
  121. .bref-box {
  122. text-overflow: -o-ellipsis-lastline;
  123. overflow: hidden;
  124. text-overflow: ellipsis;
  125. display: -webkit-box;
  126. -webkit-line-clamp: 2;
  127. -webkit-box-orient: vertical;
  128. }
  129. </style>