风险测评小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

302 lines
7.0 KiB

  1. <template>
  2. <view class="page__view">
  3. <navbar title="支付" leftClick @leftClick="$utils.navigateBack" />
  4. <view class="flex flex-column info">
  5. <view>实付金额</view>
  6. <view class="flex price">
  7. <view>¥</view>
  8. <view class="highlight">{{ payAmount }}</view>
  9. </view>
  10. <view class="flex flex-column contact">
  11. <view>联系客服获取抵扣码</view>
  12. <image class="qr" :src="configList.customer_service_qrcode" :show-menu-by-longpress="true" mode="widthFix"></image>
  13. </view>
  14. </view>
  15. <view class="form">
  16. <uv-form
  17. ref="form"
  18. :model="form"
  19. :rules="rules"
  20. errorType="toast"
  21. >
  22. <view class="form-item">
  23. <uv-form-item prop="payment" :customStyle="formItemStyle">
  24. <view class="form-item-label">选择支付方式</view>
  25. <view class="form-item-content">
  26. <uv-radio-group
  27. v-model="form.payment"
  28. placement="column"
  29. shape="circle"
  30. size="30rpx"
  31. iconSize="30rpx"
  32. activeColor="#014FA2"
  33. >
  34. <view class="payment">
  35. <view class="flex payment-content">
  36. <view class="flex payment-content-info">
  37. <image class="icon" src="@/pages_order/static/report/icon-wx.png" mode="widthFix"></image>
  38. <view>微信支付</view>
  39. </view>
  40. <view>
  41. <uv-radio :name="0"></uv-radio>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="payment">
  46. <view class="flex payment-content">
  47. <view class="flex payment-content-info">
  48. <image class="icon" src="@/pages_order/static/report/icon-coupon.png" mode="widthFix"></image>
  49. <view>兑换码抵扣支付</view>
  50. </view>
  51. <view>
  52. <uv-radio :name="1"></uv-radio>
  53. </view>
  54. </view>
  55. </view>
  56. </uv-radio-group>
  57. </view>
  58. </uv-form-item>
  59. </view>
  60. <view class="form-item is-child" v-if="form.payment == 1">
  61. <uv-form-item prop="code" :customStyle="formItemStyle">
  62. <view class="flex row">
  63. <view class="form-item-label">兑换码</view>
  64. <view class="form-item-content">
  65. <input
  66. v-model="form.code"
  67. placeholder="请输入兑换码"
  68. placeholderStyle="color: #999999; font-size: 30rpx; font-weight: 400;"
  69. />
  70. </view>
  71. </view>
  72. </uv-form-item>
  73. </view>
  74. </uv-form>
  75. </view>
  76. <view class="bottom">
  77. <button class="btn" @click="onPay">立即支付</button>
  78. </view>
  79. <codeErrorPopup ref="codeErrorPopup"></codeErrorPopup>
  80. </view>
  81. </template>
  82. <script>
  83. import codeErrorPopup from './codeErrorPopup.vue'
  84. export default {
  85. components: {
  86. codeErrorPopup,
  87. },
  88. data() {
  89. return {
  90. batchNo: null,
  91. form: {
  92. payment: 0,
  93. code: null,
  94. },
  95. rules: {
  96. 'payment': {
  97. type: 'number',
  98. required: false,
  99. message: '请选择支付方式',
  100. },
  101. 'code': {
  102. type: 'string',
  103. required: true,
  104. message: '请输入兑换码',
  105. },
  106. },
  107. formItemStyle: { padding: 0 },
  108. }
  109. },
  110. computed: {
  111. payAmount() {
  112. return Number(this.configList.pay_amount)
  113. }
  114. },
  115. onLoad(arg) {
  116. const { batchNo } = arg
  117. this.batchNo = batchNo
  118. },
  119. methods: {
  120. async onPay() {
  121. try {
  122. await this.$refs.form.validate()
  123. const {
  124. payment,
  125. code,
  126. } = this.form
  127. let payAmount = this.payAmount
  128. let discountAmount = 0
  129. if (payment == 1) { // 兑换码
  130. const infoRes = await this.$fetch('queryCodeById', { code }, false, null, true)
  131. const { result: infoResult } = infoRes
  132. if (!infoResult || infoResult?.isUse !== '0') {
  133. this.$refs.codeErrorPopup.open()
  134. return
  135. }
  136. discountAmount = infoResult.discountAmount
  137. payAmount -= discountAmount
  138. }
  139. const params = {
  140. batchNo: this.batchNo,
  141. payAmount,
  142. discountAmount,
  143. code,
  144. }
  145. const result = await this.$fetch('createOrder', params)
  146. await uni.requestPaymentWxPay({ result })
  147. uni.showToast({
  148. title: '支付成功',
  149. icon: 'none'
  150. })
  151. setTimeout(() => {
  152. uni.redirectTo({
  153. url: `/pages_order/report/userInfo?batchNo=${this.batchNo}`
  154. })
  155. }, 700)
  156. } catch (err) {
  157. }
  158. },
  159. },
  160. }
  161. </script>
  162. <style scoped lang="scss">
  163. .info {
  164. width: 100%;
  165. padding: 96rpx 62rpx 51rpx 62rpx;
  166. box-sizing: border-box;
  167. font-size: 28rpx;
  168. line-height: 50rpx;
  169. color: #000000;
  170. .price {
  171. margin-top: 23rpx;
  172. align-items: baseline;
  173. column-gap: 13rpx;
  174. font-size: 51rpx;
  175. line-height: 72rpx;
  176. color: #000000;
  177. .highlight {
  178. font-size: 78rpx;
  179. line-height: 110rpx;
  180. }
  181. }
  182. .contact {
  183. margin-top: 52rpx;
  184. row-gap: 40rpx;
  185. width: 100%;
  186. padding: 30rpx 0 26rpx 0;
  187. box-sizing: border-box;
  188. border: 1rpx dashed #014FA2;
  189. .qr {
  190. width: 157rpx;
  191. height: auto;
  192. }
  193. }
  194. }
  195. .form {
  196. &-item {
  197. &-label {
  198. padding: 0 38rpx;
  199. font-size: 28rpx;
  200. line-height: 50rpx;
  201. color: #000000;
  202. }
  203. &-content {
  204. }
  205. }
  206. }
  207. .payment {
  208. &:first-child {
  209. margin-top: 24rpx;
  210. }
  211. & + & {
  212. border-top: 20rpx solid #F7F7F7;
  213. }
  214. &-content {
  215. justify-content: space-between;
  216. padding: 32rpx 60rpx 32rpx 50rpx;
  217. &-info {
  218. column-gap: 15rpx;
  219. font-size: 30rpx;
  220. color: #000000;
  221. .icon {
  222. width: 58rpx;
  223. height: auto;
  224. }
  225. }
  226. }
  227. }
  228. .form-item.is-child {
  229. padding: 22rpx 60rpx 0 123rpx;
  230. .form-item-label,
  231. .form-item-content {
  232. padding: 0;
  233. }
  234. .form-item-label {
  235. padding-right: 16rpx;
  236. font-size: 30rpx;
  237. }
  238. .form-item-content {
  239. flex: 1;
  240. padding: 11rpx;
  241. background: #F7F7F7;
  242. }
  243. }
  244. .bottom {
  245. position: fixed;
  246. left: 0;
  247. bottom: 0;
  248. width: 100%;
  249. padding: 35rpx 56rpx;
  250. padding-bottom: calc(env(safe-area-inset-bottom) + 35rpx);
  251. background: #FFFFFF;
  252. box-sizing: border-box;
  253. .btn {
  254. width: 100%;
  255. padding: 29rpx 0;
  256. font-size: 30rpx;
  257. line-height: 1.5;
  258. color: #FFFFFF;
  259. background: #014FA2;
  260. border-radius: 50rpx;
  261. }
  262. }
  263. </style>