success.vue 4.8 KB

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