success.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. let data = JSON.parse(option.data);
  57. this.orderInfo = data.data
  58. console.log(this.orderInfo)
  59. },
  60. filters:{
  61. NumFormat(value) {//处理金额
  62. return Number(value).toFixed(2);
  63. },
  64. },
  65. methods:{
  66. setHeaderBtnPosi(){
  67. // 获得胶囊按钮位置信息
  68. let headerBtnPosi = uni.getMenuButtonBoundingClientRect();
  69. return headerBtnPosi
  70. },
  71. setSysteminfo(){
  72. let systeminfo;
  73. uni.getSystemInfo({ // 获取设备信息
  74. success: (res) => {
  75. systeminfo = res
  76. },
  77. })
  78. return systeminfo
  79. },
  80. async MiniWxPayFor(data){
  81. const wechatCode = await authorize.getCode('weixin')
  82. this.PayService.WeChatMiniWxPay(
  83. {
  84. payAmount:data.payableAmount*100,
  85. payWay:"WEIXIN",
  86. code:wechatCode,
  87. orderId:data.orderId
  88. }
  89. )
  90. .then(response =>{
  91. let PayInfo = JSON.parse(response.data.data.payInfo);
  92. this.WxRequestPayment(PayInfo)
  93. })
  94. .catch(error =>{
  95. this.$util.msg(error.msg,2000)
  96. })
  97. },
  98. WxRequestPayment(data){
  99. let self = this
  100. wx.requestPayment({
  101. 'timeStamp': data.timeStamp,
  102. 'nonceStr': data.nonceStr,
  103. 'package': data.package,
  104. 'signType': data.signType,
  105. 'paySign': data.paySign,
  106. 'success':function(res){
  107. wx.reLaunch({url: '/pages/tabBar/index/index'});
  108. },
  109. 'fail':function(res){
  110. console.log(res)
  111. self.$api.redirectTo(`/pages/user/order/success?data=${JSON.stringify({data:self.orderInfo})}`)
  112. },
  113. 'complete':function(res){
  114. }
  115. })
  116. },
  117. },
  118. onShow() {
  119. }
  120. }
  121. </script>
  122. <style lang="scss">
  123. page{
  124. background-color: #f7f7f7;
  125. height: auto !important;
  126. }
  127. .container-cash{
  128. width: 100%;
  129. .container-wrapper{
  130. width:100%;
  131. margin: 0 auto;
  132. margin-top: 120rpx;
  133. display: flex;
  134. flex-direction: column;
  135. align-items: center;
  136. background-color: #FFFFFF;
  137. .cash-icon{
  138. width: 210rpx;
  139. height: 210rpx;
  140. margin-top: 112rpx;
  141. image{
  142. width: 210rpx;
  143. height: 210rpx;
  144. }
  145. }
  146. .cash-text{
  147. font-size: $font-size-28;
  148. color:#666666;
  149. line-height: 104rpx;
  150. font-weight: bold;
  151. }
  152. }
  153. .container-money{
  154. width: 100%;
  155. height: 90rpx;
  156. float: left;
  157. line-height: 90rpx;
  158. font-size: $font-size-28;
  159. box-sizing: border-box;
  160. padding: 0 24rpx;
  161. margin-top: 20rpx;
  162. background-color: #FFFFFF;
  163. .label{
  164. float: left;
  165. color: #333333;
  166. }
  167. .money{
  168. float: right;
  169. color: #666666;
  170. }
  171. }
  172. .container-button{
  173. width: 100%;
  174. height: auto;
  175. float: left;
  176. display: flex;
  177. flex-direction: column;
  178. align-items: center;
  179. margin-top: 160rpx;
  180. .btn{
  181. width: 600rpx;
  182. height: 90rpx;
  183. border-radius: 45rpx;
  184. line-height: 90rpx;
  185. text-align: center;
  186. font-size: $font-size-26;
  187. color: #FFFFFF;
  188. box-sizing: border-box;
  189. border: 1px solid $color-system;
  190. margin-bottom: 24rpx;
  191. &.btn-open{
  192. color: $color-system;
  193. }
  194. &.btn-pay{
  195. border-color: $color-system;
  196. background:$btn-confirm;
  197. }
  198. }
  199. }
  200. }
  201. </style>