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

175 lines
3.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
  1. <template>
  2. <view></view>
  3. </template>
  4. <script>
  5. export default {
  6. data() {
  7. return {
  8. order_id: 0,
  9. timesIndex: 0
  10. }
  11. },
  12. onShow(e) {
  13. // this.order_id = uni.getStorageSync('order_id')
  14. let that = this
  15. uni.$on('order_id',function(data){
  16. that.order_id = data.msg
  17. if (that.order_id) {
  18. that.getUserProfile()
  19. } else {
  20. that.$msg('获取订单失败');
  21. }
  22. })
  23. },
  24. methods: {
  25. // 获取用户信息
  26. getUserProfile() {
  27. let that = this
  28. return new Promise((resolve, rejecj) => {
  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. resolve(res.data);
  38. if(res.data) {
  39. that.payOnce();
  40. }
  41. // uni.showModal({
  42. // title: '用户信息',
  43. // content: JSON.stringify(res.data),
  44. // confirmColor: '#1998FE',
  45. // showCancel: false,
  46. // success(res2) {
  47. // if (res2.confirm) {
  48. // that.payOnce();
  49. // }
  50. // }
  51. // });
  52. })
  53. }
  54. }
  55. })
  56. })
  57. },
  58. payOnce() {
  59. let that = this
  60. uni.showModal({
  61. title: '订单id提示',
  62. content: JSON.stringify(that.order_id),
  63. showCancel: false,
  64. });
  65. that.$http(that.API.API_LF_PAY, {
  66. id: that.order_id
  67. }).then(res => {
  68. uni.showModal({
  69. title: '进入支付接口',
  70. content: '',
  71. showCancel: false,
  72. });
  73. uni.showModal({
  74. title: '接口返回信息',
  75. content: JSON.stringify(res),
  76. showCancel: false,
  77. });
  78. uni.requestPayment({
  79. orderInfo: res.data.order_num,
  80. timeStamp: res.data.timeStamp,
  81. nonceStr: res.data.nonceStr,
  82. package: res.data.package,
  83. signType: res.data.signType,
  84. paySign: res.data.paySign,
  85. success: (res) => {
  86. uni.showModal({
  87. title: '支付成功提示',
  88. content: JSON.stringify(res),
  89. showCancel: false,
  90. });
  91. wx.navigateBackMiniProgram({
  92. extraData: {
  93. backPayState: true
  94. },
  95. success(res) {}
  96. })
  97. },
  98. fail: (err) => {
  99. uni.showModal({
  100. title: '支付失败提示',
  101. content: JSON.stringify(err),
  102. showCancel: false,
  103. });
  104. wx.navigateBackMiniProgram({
  105. extraData: {
  106. backPayState: false
  107. },
  108. success(res) {}
  109. })
  110. },
  111. })
  112. }).catch(err => {
  113. uni.showModal({
  114. title: '接口报错',
  115. content: JSON.stringify(err),
  116. showCancel: false,
  117. success(res2) {
  118. if (res2.confirm) {
  119. wx.navigateBackMiniProgram({
  120. extraData: {
  121. backPayState: false
  122. },
  123. success(res) {}
  124. })
  125. }
  126. }
  127. });
  128. // uni.showModal({
  129. // title: '提示',
  130. // content: '支付获取订单失败',
  131. // confirmColor: '#1998FE',
  132. // showCancel: false,
  133. // success(res2) {
  134. // if (res2.confirm) {
  135. // wx.navigateBackMiniProgram({
  136. // extraData: {
  137. // backPayState: false
  138. // },
  139. // success(res) {}
  140. // })
  141. // }
  142. // }
  143. // });
  144. })
  145. }
  146. }
  147. }
  148. </script>
  149. <style>
  150. .btn {
  151. margin: 0;
  152. padding: 0;
  153. width: 212rpx;
  154. height: 82rpx;
  155. background-color: #1998FE;
  156. color: #FFFFFF;
  157. line-height: 80rpx;
  158. font-size: 32rpx;
  159. border-radius: 41rpx;
  160. }
  161. .bref-box {
  162. text-overflow: -o-ellipsis-lastline;
  163. overflow: hidden;
  164. text-overflow: ellipsis;
  165. display: -webkit-box;
  166. -webkit-line-clamp: 2;
  167. -webkit-box-orient: vertical;
  168. }
  169. </style>