success.vue 5.1 KB

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