success.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <view class="container cashier">
  3. <header-pay
  4. :systeminfo="systeminfo"
  5. :navbar-data="nvabarData"
  6. :headerBtnPosi="headerBtnPosi"
  7. :isBackType="true"
  8. :path="'/pages/user/cart/cart'"
  9. >
  10. </header-pay>
  11. <view class="container-cash clearfix" :style="{ marginTop: CustomBar + 'px' }">
  12. <view class="container-wrapper">
  13. <view class="cash-icon"> <image :src="StaticUrl + 'icon-pay-fail.png'" mode=""></image> </view>
  14. <view class="cash-text">
  15. <text>{{ successText }}</text>
  16. </view>
  17. </view>
  18. <view class="container-money">
  19. <view class="label">支付金额</view>
  20. <view class="money">¥{{ orderInfo.payableAmount | NumFormat }}</view>
  21. </view>
  22. <view class="container-button">
  23. <view class="btn btn-pay" @click="MiniWxPayFor(orderInfo)">重新支付</view>
  24. <view
  25. class="btn btn-open"
  26. @click="
  27. this.$api.redirectTo('/pages/user/order/order-details?type=confim&orderId=' + orderInfo.orderId)
  28. "
  29. >查看订单</view
  30. >
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import HeaderPay from '@/components/cm-module/headerNavbar/header-pay'
  37. import authorize from '@/common/authorize.js'
  38. export default {
  39. components: {
  40. HeaderPay
  41. },
  42. data() {
  43. return {
  44. StaticUrl: this.$Static,
  45. orderId: '',
  46. nvabarData: {
  47. //顶部自定义导航
  48. haveBack: false,
  49. showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示,
  50. showSearch: 0,
  51. title: '支付结果', // 导航栏 中间的标题
  52. textLeft: this.$store.getters.isIphone
  53. },
  54. headerBtnPosi: this.setHeaderBtnPosi(), //获取设备顶部胶囊高度
  55. systeminfo: this.setSysteminfo(), //获取设备信息
  56. isIphoneX: this.$store.getters.isIphoneX,
  57. CustomBar: this.CustomBar, // 顶部导航栏高度
  58. successText: '订单支付失败',
  59. orderInfo: {}
  60. }
  61. },
  62. onLoad(option) {
  63. console.log(option)
  64. let data = JSON.parse(option.data)
  65. this.orderInfo = data.data
  66. console.log(this.orderInfo)
  67. },
  68. filters: {
  69. NumFormat(value) {
  70. //处理金额
  71. console.log(value)
  72. return Number(value).toFixed(2)
  73. }
  74. },
  75. methods: {
  76. setHeaderBtnPosi() {
  77. // 获得胶囊按钮位置信息
  78. let headerBtnPosi = uni.getMenuButtonBoundingClientRect()
  79. return headerBtnPosi
  80. },
  81. setSysteminfo() {
  82. let systeminfo
  83. uni.getSystemInfo({
  84. // 获取设备信息
  85. success: res => {
  86. systeminfo = res
  87. }
  88. })
  89. return systeminfo
  90. },
  91. MiniWxPayFor(data) {
  92. this.PayService.PayOrderOnLineSwitch().then(response => {
  93. if (response.data === 1) {
  94. this.WeChatMiniWxPay(data)
  95. } else {
  96. this.$api.navigateTo(`/pages/user/order/order-payment?money=${data.payableAmount}`)
  97. }
  98. })
  99. },
  100. async WeChatMiniWxPay(data) {
  101. const wechatCode = await authorize.getCode('weixin')
  102. this.PayService.WeChatMiniWxPay({
  103. payAmount: data.payableAmount * 100,
  104. payWay: 'WEIXIN',
  105. code: wechatCode,
  106. orderId: data.orderId
  107. })
  108. .then(response => {
  109. let PayInfo = JSON.parse(response.data.data.payInfo)
  110. this.WxRequestPayment(PayInfo)
  111. })
  112. .catch(error => {
  113. this.$util.msg(error.msg, 2000)
  114. })
  115. },
  116. WxRequestPayment(data) {
  117. let self = this
  118. wx.requestPayment({
  119. timeStamp: data.timeStamp,
  120. nonceStr: data.nonceStr,
  121. package: data.package,
  122. signType: data.signType,
  123. paySign: data.paySign,
  124. success: function(res) {
  125. wx.reLaunch({ url: '/pages/tabBar/index/index' })
  126. },
  127. fail: function(res) {
  128. console.log(res)
  129. self.$api.redirectTo(`/pages/user/order/success?data=${JSON.stringify({ data: self.orderInfo })}`)
  130. },
  131. complete: function(res) {}
  132. })
  133. }
  134. },
  135. onShow() {}
  136. }
  137. </script>
  138. <style lang="scss">
  139. page {
  140. background-color: #f7f7f7;
  141. height: auto !important;
  142. }
  143. .container-cash {
  144. width: 100%;
  145. .container-wrapper {
  146. width: 100%;
  147. margin: 0 auto;
  148. margin-top: 120rpx;
  149. display: flex;
  150. flex-direction: column;
  151. align-items: center;
  152. background-color: #ffffff;
  153. .cash-icon {
  154. width: 210rpx;
  155. height: 210rpx;
  156. margin-top: 112rpx;
  157. image {
  158. width: 210rpx;
  159. height: 210rpx;
  160. }
  161. }
  162. .cash-text {
  163. font-size: $font-size-28;
  164. color: #666666;
  165. line-height: 104rpx;
  166. font-weight: bold;
  167. }
  168. }
  169. .container-money {
  170. width: 100%;
  171. height: 90rpx;
  172. float: left;
  173. line-height: 90rpx;
  174. font-size: $font-size-28;
  175. box-sizing: border-box;
  176. padding: 0 24rpx;
  177. margin-top: 20rpx;
  178. background-color: #ffffff;
  179. .label {
  180. float: left;
  181. color: #333333;
  182. }
  183. .money {
  184. float: right;
  185. color: #666666;
  186. }
  187. }
  188. .container-button {
  189. width: 100%;
  190. height: auto;
  191. float: left;
  192. display: flex;
  193. flex-direction: column;
  194. align-items: center;
  195. margin-top: 160rpx;
  196. .btn {
  197. width: 600rpx;
  198. height: 90rpx;
  199. border-radius: 45rpx;
  200. line-height: 90rpx;
  201. text-align: center;
  202. font-size: $font-size-26;
  203. color: #ffffff;
  204. box-sizing: border-box;
  205. border: 1px solid $color-system;
  206. margin-bottom: 24rpx;
  207. &.btn-open {
  208. color: $color-system;
  209. }
  210. &.btn-pay {
  211. border-color: $color-system;
  212. background: $btn-confirm;
  213. }
  214. }
  215. }
  216. }
  217. </style>