海南旅游项目 前端仓库
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.

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