paymentOnline.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <div class="online">
  3. <nav-bar title="收银台" @click-left="$router.back()" />
  4. <div class="content">
  5. <div class="payIcon">
  6. <div class="payList">
  7. <div class="text" @click="handlerDiscern">支付记录</div>
  8. </div>
  9. <div class="shouldPay">
  10. <div class="payment">
  11. <div class="label">本次支付金额</div>
  12. <div class="money"><span>¥</span>{{ totalAmount | handlerPayFixed }}</div>
  13. </div>
  14. <div class="payment">
  15. <div class="label">应付剩余</div>
  16. <div class="money"><span>¥</span>{{ totalAmount | handlerPayFixed }}</div>
  17. </div>
  18. </div>
  19. </div>
  20. <div class="payCard">
  21. <div class="amount">
  22. <div class="label">待付金额</div>
  23. <div class="money">¥{{ obligation | handlerPayFixed }}</div>
  24. </div>
  25. <div class="amount">
  26. <div class="label">应付总额</div>
  27. <div class="money">¥{{ totalAmount | handlerPayFixed }}</div>
  28. </div>
  29. <div class="amount">
  30. <div class="label">已支付金额</div>
  31. <div class="money">¥{{ shopOrder.receiptAmount | handlerPayFixed }}</div>
  32. </div>
  33. </div>
  34. <div class="bank-pay">
  35. <van-cell title="添加银行卡快捷支付" is-link to="addBanks?type=2" v-if="false"/>
  36. <van-radio-group v-model="radio">
  37. <van-cell-group>
  38. <div v-if="bankList.length !== 0">
  39. <van-cell :title="item.bankName" clickable @click="handlerPay(item)" :icon="'https://static.caimei365.com/app/img/pay/icon_' +
  40. item.bankCode +
  41. '_@2x.png'" v-for="item in bankList" :key="item.id">
  42. <template #right-icon>
  43. <van-radio :name="item.id" />
  44. </template>
  45. </van-cell>
  46. <van-cell title="添加别的银行卡快捷支付" is-link :to="`addBanks?type=2&userId=${shopOrder.userId}`" />
  47. </div>
  48. <van-cell :title="item.title" clickable @click="handlerPay(item)" :icon="item.icon" v-for="item in payList" :key="item.id">
  49. <template #right-icon>
  50. <van-radio :name="item.id" />
  51. </template>
  52. </van-cell>
  53. </van-cell-group>
  54. </van-radio-group>
  55. </div>
  56. <div class="tips">
  57. 使用任何一种线上支付方式支付全部金额后,供应商会在24
  58. 小时后发货(周末、节假日顺延)。
  59. </div>
  60. </div>
  61. <div class="bank-btn">
  62. <van-button color="#FF5B00" @click="bankQuickPay">{{ payName || '微信支付' }}</van-button>
  63. </div>
  64. <bank-link-vue :show="showLink" @handlerShowDialog="handlerShowDialog" :bankLink="handlerPayLink"/>
  65. <discern-popup :discernReceipt="discernReceipt" ref="discern" />
  66. </div>
  67. </template>
  68. <script>
  69. import BankLinkVue from './components/bankLinkVue'
  70. import discernPopup from './components/discern-popup'
  71. import { payCheckout, getBankList, bankQuickPay, payLink } from '@/api/institutionApi/pay.js'
  72. export default {
  73. components: { BankLinkVue, discernPopup },
  74. data () {
  75. return {
  76. bankList: [],
  77. totalAmount: 0,
  78. obligation: 0,
  79. radio: 1,
  80. shopOrder: {},
  81. userId: '',
  82. payName: '',
  83. bankForm: {
  84. unpaidAmount: '',
  85. shopOrderId: '',
  86. payType: 2
  87. },
  88. payForm: {},
  89. payList: [
  90. {
  91. id: 1,
  92. title: '微信支付',
  93. icon: 'https://static.caimei365.com/app/mini-distribution/wechat-pay.png'
  94. },
  95. {
  96. id: 2,
  97. title: '个人网银支付',
  98. icon: 'https://static.caimei365.com/app/mini-distribution/net-pay.png'
  99. }
  100. ],
  101. discernReceipt: [],
  102. handlerPayLink: '',
  103. showLink: false
  104. }
  105. },
  106. filters: {
  107. handlerPayFixed (val) {
  108. return (val * 1).toFixed(2)
  109. }
  110. },
  111. computed: {
  112. shopOrderId () {
  113. return this.$route.query.shopOrderId
  114. },
  115. quickForm () {
  116. if (this.radio * 1 > 2) {
  117. return Object.assign(this.payForm, {
  118. userId: this.shopOrder.userId,
  119. quickPayFlag: 1,
  120. payAmount: this.shopOrder.totalAmount,
  121. shopOrderId: this.shopOrder.shopOrderId
  122. })
  123. }
  124. return {}
  125. }
  126. },
  127. watch: {
  128. radio (val) {
  129. if (val * 1 > 2) {
  130. this.payForm = this.bankList.filter(e => e.id === val)[0]
  131. }
  132. }
  133. },
  134. mounted () {
  135. this.payCheckout()
  136. },
  137. methods: {
  138. async payCheckout () {
  139. const data = await payCheckout({ shopOrderId: this.shopOrderId })
  140. const data2 = await getBankList({ userId: data.shopOrder.userId })
  141. this.totalAmount = data.shopOrder.totalAmount.toFixed(2) || 0
  142. this.obligation = data.shopOrder.obligation.toFixed(2) || 0
  143. this.userId = data.shopOrder.userId
  144. this.shopOrder = data.shopOrder
  145. this.bankList = data2
  146. this.radio = data2.length > 0 ? this.bankList[0].id : 1
  147. this.payForm = data2.length > 0 ? this.payForm[0] : {}
  148. this.discernReceipt = data.discernReceipt
  149. },
  150. async bankQuickPay () {
  151. if (this.radio === 2) {
  152. try {
  153. const data = await payLink({ unpaidAmount: this.totalAmount, shopOrderId: this.shopOrderId, payType: 2 })
  154. this.handlerPayLink = data
  155. this.showLink = true
  156. } catch (error) {
  157. console.log(error)
  158. }
  159. } else if (this.radio === 1) {
  160. this.$router.push(`/wechatpay?shopOrderId=${this.shopOrderId}&payAmount=${this.totalAmount}`)
  161. } else {
  162. try {
  163. await bankQuickPay(this.quickForm)
  164. } catch (error) {
  165. console.log(error)
  166. }
  167. }
  168. },
  169. handlerPay ($event) {
  170. this.payName = $event.title || $event.bankName
  171. this.radio = $event.id
  172. },
  173. handlerShowDialog ($event) {
  174. this.showLink = false
  175. },
  176. handlerDiscern () {
  177. this.$refs.discern.show = true
  178. }
  179. }
  180. }
  181. </script>
  182. <style lang="scss" scoped>
  183. .online {
  184. min-height: 100vh;
  185. .content {
  186. position: relative;
  187. .payIcon {
  188. height: 50vw;
  189. background: url('https://static.caimei365.com/app/mini-distribution/pay-bg.png');
  190. background-size: 100% 100%;
  191. padding: 5.3vw 4.3vw;
  192. box-sizing: border-box;
  193. .payList {
  194. display: flex;
  195. flex-direction: row-reverse;
  196. align-items: center;
  197. .text {
  198. font-size: 3.2vw;
  199. color: #fff;
  200. margin-right: 1vw;
  201. position: relative;
  202. &::after {
  203. position: absolute;
  204. right: -2vw;
  205. top: 0;
  206. content: '\276D';
  207. }
  208. }
  209. }
  210. .shouldPay {
  211. display: grid;
  212. grid-template-rows: 1;
  213. grid-template-columns: repeat(2, 1fr);
  214. margin-top: 5.3vw;
  215. .payment {
  216. .label {
  217. font-size: 3.7vw;
  218. color: #fff;
  219. font-size: 3.7vw;
  220. margin-bottom: 2vw;
  221. }
  222. .money {
  223. display: flex;
  224. color: #fff;
  225. font-size: 5.3vw;
  226. font-weight: 600;
  227. align-items: center;
  228. vertical-align: -webkit-baseline-middle;
  229. span {
  230. font-size: 3.2vw;
  231. font-weight: 400;
  232. margin-right: 0.2vw;
  233. }
  234. }
  235. }
  236. .payment:nth-child(2) {
  237. padding-left: 10.7vw;
  238. box-sizing: border-box;
  239. position: relative;
  240. &::before {
  241. content: '';
  242. position: absolute;
  243. height: 8.5vw;
  244. left: 0;
  245. top: 0;
  246. transform: translateY(50%);
  247. width: 1px;
  248. background: #fff;
  249. }
  250. }
  251. }
  252. }
  253. .payCard {
  254. position: fixed;
  255. top: 47vw;
  256. background: #fff;
  257. box-shadow: 0px 8px 13px 1px rgba(236,116,47,0.16);
  258. border-radius: 1.1vw;
  259. display: grid;
  260. left: 50%;
  261. transform: translateX(-50%);
  262. grid-template-columns: repeat(3, 1fr);
  263. z-index: 66;
  264. .amount {
  265. padding: 6.25vw 7.25vw;
  266. display: flex;
  267. flex-direction: column;
  268. align-items: center;
  269. .label {
  270. white-space: nowrap;
  271. color: #999;
  272. font-size: 3.2vw;
  273. margin-bottom: 2.1vw;
  274. }
  275. .money {
  276. color: #333333;
  277. font-weight: 600;
  278. font-size: 3.7vw;
  279. }
  280. &:nth-child(2) {
  281. position: relative;
  282. &::before {
  283. content: '';
  284. position: absolute;
  285. height: 8.3vw;
  286. left: 0;
  287. top: 50%;
  288. transform: translateY(-50%);
  289. width: 1px;
  290. background: #E1E1E1;
  291. }
  292. &::after {
  293. content: '';
  294. position: absolute;
  295. height: 8.3vw;
  296. right: 0;
  297. top: 50%;
  298. transform: translateY(-50%);
  299. width: 1px;
  300. background: #E1E1E1;
  301. }
  302. }
  303. }
  304. }
  305. .bank-pay {
  306. padding-top: 16vw;
  307. background: #fff;
  308. .van-cell {
  309. .van-cell__title {
  310. font-weight: 600;
  311. font-size: 4.3vw;
  312. }
  313. }
  314. .van-radio-group {
  315. .van-cell {
  316. .van-cell__title {
  317. font-weight: 400;
  318. font-size: 3.7vw;
  319. color: #333333;
  320. }
  321. .van-cell__left-icon {
  322. width: 6.4vw;
  323. height: 6.4vw;
  324. margin-right: 3.2vw;
  325. .van-icon__image {
  326. width: 100%;
  327. height: 100%;
  328. }
  329. }
  330. }
  331. ::v-deep .van-radio__icon--checked .van-icon {
  332. border-color: #FF5B00 !important;
  333. background: #fff;
  334. position: relative;
  335. &::before {
  336. content: '';
  337. width: 2vw;
  338. height: 2vw;
  339. border-radius: 50%;
  340. background: #FF5B00;
  341. position: absolute;
  342. left: 50%;
  343. top: 50%;
  344. transform: translate(-50%, -50%);
  345. }
  346. }
  347. }
  348. }
  349. .tips {
  350. margin-top: 5.3vw;
  351. width: 93.6vw;
  352. margin: 5.3vw auto 0 auto;
  353. border-radius: 1.1vw;
  354. border: 1px solid #ccc;
  355. overflow: hidden;
  356. line-height: 5.3vw;
  357. font-size: 3.2vw;
  358. color: #999;
  359. padding: 3.6vw 2.7vw 3.6vw 7.1vw;
  360. box-sizing: border-box;
  361. position: relative;
  362. &::before {
  363. content: '';
  364. position: absolute;
  365. top: 4.4vw;
  366. left: 2.7vw;
  367. width: 3.2vw;
  368. height: 3.2vw;
  369. background: url('https://static.caimei365.com/app/mini-distribution/tips.png');
  370. background-size: 100% 100%;
  371. }
  372. }
  373. }
  374. .bank-btn {
  375. background: #fff;
  376. position: fixed;
  377. left: 0;
  378. height: 13.1vw;
  379. width: 100%;
  380. bottom: 0;
  381. @include display-flex-center;
  382. .van-button {
  383. width: 80vw;
  384. border-radius: 1.1vw;
  385. font-size: 4vw;
  386. }
  387. }
  388. }
  389. </style>