success.vue 4.9 KB

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