pay.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <view class="page">
  3. <!-- 金额展示 -->
  4. <view class="money-show">
  5. <view class="desc">实付金额</view>
  6. <view class="money">
  7. <text>¥</text>
  8. <text>{{orderInfo.actual_total_amount}}</text>
  9. </view>
  10. <!-- <view class="time">支付剩余时间 07:58</view> -->
  11. </view>
  12. <!-- 支付方式 -->
  13. <view class="pay-type">
  14. <u-radio-group v-model="payType">
  15. <view class="title">选择支付方式</view>
  16. <view class="item" @click="payType = 'wxPay'">
  17. <view class="left">
  18. <view class="logo"><image src="../../static/icon-wx-pay.png" mode=""></image></view>
  19. <view class="name">微信支付</view>
  20. </view>
  21. <view class="check"><u-radio shape="circle" :active-color="appThemeColor" icon-size="16" name="wxPay"></u-radio></view>
  22. </view>
  23. <!-- <view class="item" @click="payType = 'aliPay'">
  24. <view class="left">
  25. <view class="logo"><image src="../../static/icon-ali-pay.png" mode=""></image></view>
  26. <view class="name">支付宝</view>
  27. </view>
  28. <view class="check"><u-radio shape="circle" :active-color="appThemeColor" icon-size="16" name="aliPay"></u-radio></view>
  29. </view> -->
  30. </u-radio-group>
  31. </view>
  32. <!-- 支付 -->
  33. <view class="btn">
  34. <u-button type="primary" shape="circle" @click="goPayResult">
  35. <!-- <text v-show="payType == 'wxPay'">微信支付</text> -->
  36. <!-- <text v-show="payType == 'aliPay'">支付宝支付</text> -->
  37. <text>立即支付</text>
  38. <text>¥{{orderInfo.actual_total_amount}}</text>
  39. </u-button>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. var _self;
  45. export default {
  46. data() {
  47. return {
  48. payType: 'wxPay',
  49. appThemeColor: this.$appTheme.appThemeColor,
  50. orderInfo:{},
  51. };
  52. },
  53. onLoad(opt){
  54. _self = this;
  55. if(!opt.orderInfo){
  56. uni.navigateBack();
  57. }else{
  58. this.orderInfo = JSON.parse(decodeURIComponent(opt.orderInfo));
  59. console.log('>>>>>123456>',this.orderInfo)
  60. }
  61. },
  62. methods: {
  63. goPayResult() {
  64. console.log('>>>>>>>>>',this.orderInfo);
  65. /* setTimeout(() => {
  66. uni.navigateTo({
  67. url: '/pages-mall/pages/order/pay-result?payTotal='+_self.orderInfo.actual_total_amount+'&orderId='+_self.orderInfo.id
  68. })
  69. }, 500)
  70. return; */
  71. this.$u.api.payAjax(this.orderInfo.order_no).then(({code,data})=>{
  72. if(code==1){
  73. var orderInfos = data;
  74. uni.requestPayment({
  75. "provider": "wxpay",
  76. "orderInfo":orderInfos,
  77. ...data,
  78. success: function(res) {
  79. uni.showToast({
  80. title: "支付成功",
  81. icon: 'success',
  82. success: () => {
  83. setTimeout(() => {
  84. uni.redirectTo({
  85. url: '/pages-mall/pages/order/pay-result?payTotal='+_self.orderInfo.actual_total_amount+'&orderId='+_self.orderInfo.id
  86. })
  87. }, 500)
  88. }
  89. })
  90. },
  91. fail: function(err) {
  92. uni.showModal({
  93. content:'支付失败,请到我的订单中,重新支付',
  94. success() {
  95. uni.redirectTo({
  96. url:'/pages-mall/pages/order/detail'
  97. })
  98. }
  99. })
  100. console.log('fail:' + JSON.stringify(err));
  101. }
  102. });
  103. }
  104. })
  105. }
  106. }
  107. };
  108. </script>
  109. <style lang="scss" scoped>
  110. .page {
  111. background-color: $app-theme-bg-color;
  112. }
  113. .money-show {
  114. padding: 24rpx 0 48rpx 0;
  115. .desc {
  116. width: 100%;
  117. text-align: center;
  118. font-size: 24rpx;
  119. font-family: PingFang-SC-Medium, PingFang-SC;
  120. font-weight: 500;
  121. color: #2d2b36;
  122. margin-bottom: 8rpx;
  123. }
  124. .money {
  125. margin-bottom: 22rpx;
  126. display: flex;
  127. align-items: center;
  128. justify-content: center;
  129. text:nth-child(1) {
  130. font-size: 48rpx;
  131. font-family: PingFang-SC-Medium, PingFang-SC;
  132. font-weight: 500;
  133. color: #2d2b36;
  134. }
  135. text:nth-child(2) {
  136. font-size: 72rpx;
  137. font-family: DINAlternate-Bold, DINAlternate;
  138. font-weight: bold;
  139. color: #2d2b36;
  140. }
  141. }
  142. .time {
  143. text-align: center;
  144. font-size: 24rpx;
  145. font-family: PingFang-SC-Medium, PingFang-SC;
  146. font-weight: 500;
  147. color: #2d2b36;
  148. }
  149. }
  150. .pay-type {
  151. padding: 0 30rpx;
  152. margin-top: 80rpx;
  153. .title {
  154. font-size: 30rpx;
  155. font-family: PingFangSCSemibold-, PingFangSCSemibold;
  156. font-weight: normal;
  157. color: #2d2b36;
  158. padding-bottom: 4rpx;
  159. }
  160. .item {
  161. display: flex;
  162. align-items: center;
  163. justify-content: space-between;
  164. padding-bottom: 24rpx;
  165. padding-top: 26rpx;
  166. border-bottom: 1rpx solid #efefef;
  167. .left {
  168. display: flex;
  169. align-items: center;
  170. justify-content: flex-start;
  171. .logo {
  172. width: 64rpx;
  173. height: 64rpx;
  174. margin-right: 30rpx;
  175. image {
  176. width: 100%;
  177. height: 100%;
  178. }
  179. }
  180. .name {
  181. font-size: 28rpx;
  182. font-family: PingFangSC-Regular, PingFang SC;
  183. font-weight: 400;
  184. color: #171717;
  185. }
  186. }
  187. .check {
  188. }
  189. }
  190. }
  191. /deep/.u-icon {
  192. display: flex !important;
  193. }
  194. .btn {
  195. padding: 0 30rpx;
  196. position: absolute;
  197. bottom: 70rpx;
  198. left: 0;
  199. width: 100%;
  200. }
  201. </style>