pay.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="page-content">
  3. <uv-navbar title="收银台" :placeholder="true" titleStyle="font-weight: bold" :fixed="true" @leftClick="handleBack" />
  4. <view class="content">
  5. <view class="money-info flex flex-col align-center justify-center">
  6. <view class="">
  7. <text class="unit">¥</text>
  8. <text class="money">{{ price }}</text>
  9. </view>
  10. <view class="tip">待支付金额</view>
  11. </view>
  12. <view class="goods-info">
  13. <view class="goods-info-item flex justify-between">
  14. <text class="tip">商品名称</text>
  15. <text>会员卡</text>
  16. </view>
  17. <view class="goods-info-item flex justify-between">
  18. <text class="tip">商品金额</text>
  19. <text>¥{{ price }}</text>
  20. </view>
  21. </view>
  22. <view v-if="!isIOS" class="tip">选择支付方式</view>
  23. </view>
  24. <view v-if="!isIOS" class="channel-list">
  25. <uv-radio-group v-model="payType" placement="column" iconPlacement="right" shape="square" size="24" iconSize="18">
  26. <uv-radio v-if="isAndroid" :name="1">
  27. <view class="flex align-center" slot="label">
  28. <image class="channel-icon" mode="widthFix" src="@/static/wechat-pay.png" />
  29. <text>微信支付</text>
  30. </view>
  31. </uv-radio>
  32. <uv-radio v-if="isIOS" :name="2">
  33. <view class="flex align-center" slot="label">
  34. <image class="channel-icon" mode="widthFix" src="@/static/apple-pay.png" />
  35. <text>苹果支付</text>
  36. </view>
  37. </uv-radio>
  38. </uv-radio-group>
  39. </view>
  40. <view class="btn-wrap">
  41. <uv-button type="primary" size="large" @click="handlePay">确认支付 ¥{{ price }}</uv-button>
  42. </view>
  43. </view>
  44. </template>
  45. <script setup>
  46. import { ref } from 'vue';
  47. import config from '@/config';
  48. import { usePayment } from '@/hooks/usePayment.js';
  49. import { useEnvStore } from '@/hooks/useEnvStore';
  50. const {isAndroid, isIOS, isWap2App, isH5} = useEnvStore();
  51. const { price, payment, iosPayment, onOrderSucceed, onOrderFailed, onOrderTimeout } = usePayment();
  52. const payType = ref(1);
  53. const dividerStyle = {
  54. "margin": "10px 0"
  55. };
  56. function handlePay() {
  57. if (isAndroid.value) {
  58. payment();
  59. } else {
  60. iosPayment();
  61. }
  62. }
  63. function handleBack() {
  64. uni.navigateBack();
  65. }
  66. </script>
  67. <style lang="scss">
  68. .page-content {
  69. background-color: #f6f5f5;
  70. }
  71. .flex {
  72. display: flex;
  73. }
  74. .flex-row {
  75. flex-direction: row;
  76. }
  77. .flex-col {
  78. flex-direction: column;
  79. }
  80. .align-center {
  81. align-items: center;
  82. }
  83. .align-end {
  84. align-items: flex-end;
  85. }
  86. .justify-between {
  87. justify-content: space-between;
  88. }
  89. .content {
  90. padding: 0 28px;
  91. }
  92. .money-info {
  93. padding: 30px 0;
  94. }
  95. .unit {
  96. font-size: 20px;
  97. }
  98. .money {
  99. font-size: 48px;
  100. font-weight: bold;
  101. letter-spacing: 2px;
  102. }
  103. .tip {
  104. color: #7c7c7c;
  105. font-size: 15px;
  106. }
  107. .goods-info {
  108. margin-bottom: 26px;
  109. }
  110. .goods-info-item {
  111. &+& {
  112. margin-top: 10px;
  113. }
  114. }
  115. .channel-list {
  116. margin: 10px 18px 0 18px;
  117. border-radius: 12px;
  118. background-color: #ffffff;
  119. padding: 12px;
  120. }
  121. .u-radio+.u-radio {
  122. margin-top: 10px;
  123. }
  124. .u-radio:last-child {
  125. border-bottom: none !important;
  126. }
  127. .channel-icon {
  128. width: 40px;
  129. height: 40px;
  130. margin-right: 8px;
  131. }
  132. .btn-wrap {
  133. margin-top: 36px;
  134. padding: 0 24px;
  135. }
  136. </style>