风险测评小程序前端代码仓库
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.

298 lines
6.9 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. const params = {
  128. batchNo: this.batchNo,
  129. payAmount: this.payAmount,
  130. }
  131. if (payment == 1) { // 兑换码
  132. const infoRes = await this.$fetch('queryCodeById', { code }, false, null, true)
  133. const { result: infoResult } = infoRes
  134. if (!infoResult || infoResult?.isUse !== '0') {
  135. this.$refs.codeErrorPopup.open()
  136. return
  137. }
  138. params.discountAmount = infoResult.discountAmount
  139. params.payAmount -= params.discountAmount
  140. params.code = code
  141. }
  142. const result = await this.$fetch('createOrder', params)
  143. await uni.requestPaymentWxPay({ result })
  144. uni.showToast({
  145. title: '支付成功',
  146. icon: 'none'
  147. })
  148. setTimeout(() => {
  149. uni.redirectTo({
  150. url: `/pages_order/report/userInfo?batchNo=${this.batchNo}`
  151. })
  152. }, 700)
  153. } catch (err) {
  154. }
  155. },
  156. },
  157. }
  158. </script>
  159. <style scoped lang="scss">
  160. .info {
  161. width: 100%;
  162. padding: 96rpx 62rpx 51rpx 62rpx;
  163. box-sizing: border-box;
  164. font-size: 28rpx;
  165. line-height: 50rpx;
  166. color: #000000;
  167. .price {
  168. margin-top: 23rpx;
  169. align-items: baseline;
  170. column-gap: 13rpx;
  171. font-size: 51rpx;
  172. line-height: 72rpx;
  173. color: #000000;
  174. .highlight {
  175. font-size: 78rpx;
  176. line-height: 110rpx;
  177. }
  178. }
  179. .contact {
  180. margin-top: 52rpx;
  181. row-gap: 40rpx;
  182. width: 100%;
  183. padding: 30rpx 0 26rpx 0;
  184. box-sizing: border-box;
  185. border: 1rpx dashed #014FA2;
  186. .qr {
  187. width: 157rpx;
  188. height: auto;
  189. }
  190. }
  191. }
  192. .form {
  193. &-item {
  194. &-label {
  195. padding: 0 38rpx;
  196. font-size: 28rpx;
  197. line-height: 50rpx;
  198. color: #000000;
  199. }
  200. &-content {
  201. }
  202. }
  203. }
  204. .payment {
  205. &:first-child {
  206. margin-top: 24rpx;
  207. }
  208. & + & {
  209. border-top: 20rpx solid #F7F7F7;
  210. }
  211. &-content {
  212. justify-content: space-between;
  213. padding: 32rpx 60rpx 32rpx 50rpx;
  214. &-info {
  215. column-gap: 15rpx;
  216. font-size: 30rpx;
  217. color: #000000;
  218. .icon {
  219. width: 58rpx;
  220. height: auto;
  221. }
  222. }
  223. }
  224. }
  225. .form-item.is-child {
  226. padding: 22rpx 60rpx 0 123rpx;
  227. .form-item-label,
  228. .form-item-content {
  229. padding: 0;
  230. }
  231. .form-item-label {
  232. padding-right: 16rpx;
  233. font-size: 30rpx;
  234. }
  235. .form-item-content {
  236. flex: 1;
  237. padding: 11rpx;
  238. background: #F7F7F7;
  239. }
  240. }
  241. .bottom {
  242. position: fixed;
  243. left: 0;
  244. bottom: 0;
  245. width: 100%;
  246. padding: 35rpx 56rpx;
  247. padding-bottom: calc(env(safe-area-inset-bottom) + 35rpx);
  248. background: #FFFFFF;
  249. box-sizing: border-box;
  250. .btn {
  251. width: 100%;
  252. padding: 29rpx 0;
  253. font-size: 30rpx;
  254. line-height: 1.5;
  255. color: #FFFFFF;
  256. background: #014FA2;
  257. border-radius: 50rpx;
  258. }
  259. }
  260. </style>