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

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <template></template>
  2. <script>
  3. export default {
  4. data() {
  5. return {
  6. order_id: 0,
  7. timesIndex: 0,
  8. userInfo: {},
  9. payErr: {},
  10. paySuccecc: {}
  11. }
  12. },
  13. onShow(e) {
  14. // this.order_id = uni.getStorageSync('order_id')
  15. let that = this
  16. uni.$on('order_id',function(data){
  17. that.order_id = data.msg
  18. if (that.order_id) {
  19. that.getUserProfile()
  20. } else {
  21. that.$msg('获取订单失败');
  22. }
  23. })
  24. },
  25. methods: {
  26. // 获取用户信息
  27. getUserProfile() {
  28. let that = this
  29. uni.login({
  30. complete: result => {
  31. if (result.errMsg == 'login:ok') {
  32. let code = result.code;
  33. that.$http(that.API.API_WXLOGIN, {
  34. code
  35. }).then(res => {
  36. uni.setStorageSync('userinfo', res.data);
  37. that.userInfo = JSON.stringify(res.data)
  38. if(res.data) {
  39. uni.showModal({
  40. title: '支付提示',
  41. content: '确认支付吗?',
  42. confirmColor: '#1998FE',
  43. showCancel: false,
  44. success(res2) {
  45. if (res2.confirm) {
  46. that.payOnce();
  47. }
  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>