index.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. <template>
  2. <div class="cashier-list-content" :style="{ padding, borderRadius: radius }">
  3. <div v-if="show">
  4. <slot name="header" :payment-list="paymentList"></slot>
  5. <el-radio-group :value="paymentMode" @input="handleChangePaymentMode">
  6. <div v-for="payment in paymentList" :key="payment.paymentMode" class="cashier" @click="handleClickPaymentMode(payment)">
  7. <div class="cashier-item">
  8. <div class="icon-text">
  9. <el-image
  10. lazy :src="payment.icon"
  11. style="width: 18px;height:18px;" fit="contain"
  12. />
  13. </div>
  14. <div style="margin-left: 8px;">
  15. <el-radio
  16. :disabled="payment.disabled" :label="payment.paymentMode"
  17. >
  18. <span>{{ payment.label }}</span>
  19. <span v-if="(payment.paymentMode === '7')">(佣金:{{ Number.parseFloat(Number(pricePlatformInfo.commissionPrice || 0)).toFixed(2) }})</span>
  20. <span v-if="(payment.paymentMode === '5')">(余额:{{ Number.parseFloat(Number(pricePlatformInfo.rechargePrice || 0)).toFixed(2) }})</span>
  21. <span v-if="(payment.paymentMode === '8')">(余额:{{ Number.parseFloat(Number(pricePlatformInfo.beeCoinPrice || 0)).toFixed(2) }})</span>
  22. <span v-if="(payment.paymentMode === '6')">(余额:{{ priceShopInfo.current }})</span>
  23. <span v-if="(paymentMode === '3') && (paymentMode === payment.paymentMode)">
  24. (手续费:¥{{ flowerObj.hbServiceChargeTotal }})
  25. </span>
  26. </el-radio>
  27. </div>
  28. </div>
  29. <!-- 花呗分期 -->
  30. <div v-if="(paymentMode === '3') && (paymentMode === payment.paymentMode)" class="ali-hb-content">
  31. <el-radio-group :value="flowerObj.hbByStagesPeriods" @input="handleChangePeriods">
  32. <div v-for="(flowerItem, index) in flowerObj.hbByStagesList" :key="index" class="cashier">
  33. <div class="cashier-item">
  34. <div class="icon-text">
  35. {{ flowerItem.numberOfStages }}期(¥{{ flowerItem.price }}/期)
  36. </div>
  37. <div style="display: flex;align-items: center;font-size: 24px;">
  38. 手续费:¥{{ flowerItem.serviceCharge }}/期
  39. <el-radio
  40. style="margin-left: 15px;" :disabled="flowerItem.disabled"
  41. :label="flowerItem.numberOfStages"
  42. >
  43. </el-radio>
  44. </div>
  45. </div>
  46. </div>
  47. </el-radio-group>
  48. </div>
  49. </div>
  50. </el-radio-group>
  51. </div>
  52. </div>
  53. </template>
  54. <script>
  55. // import { getOrderHuabeiConfigApi, getPricePlatformAllApi, getRechargeTotalCustomersApi } from '../../api/anotherTFInterface'
  56. export default {
  57. name: 'CashierList',
  58. props: {
  59. padding: {
  60. type: String,
  61. default: '0px 15px'
  62. },
  63. missingPriceText: {
  64. type: String,
  65. default: '缺少金额'
  66. },
  67. radius: {
  68. type: String,
  69. default: '0'
  70. },
  71. pricePay: {
  72. type: Number,
  73. default: 0
  74. },
  75. // 是否显示,用于默认某一个支付
  76. show: {
  77. type: Boolean,
  78. default: false
  79. },
  80. showWechatPay: {
  81. type: Boolean,
  82. default: false
  83. },
  84. showAliPay: {
  85. type: Boolean,
  86. default: false
  87. },
  88. showHuabeiPay: {
  89. type: Boolean,
  90. default: false
  91. },
  92. showTonglianPay: {
  93. type: Boolean,
  94. default: true
  95. },
  96. // 佣金支付
  97. showCommissionPay: {
  98. type: Boolean,
  99. default: false
  100. },
  101. // 平台余额支付
  102. showPlatformPay: {
  103. type: Boolean,
  104. default: false
  105. },
  106. // 消费金支付
  107. showTransactionPay: {
  108. type: Boolean,
  109. default: false
  110. },
  111. // 惠市宝支付
  112. showHuiShiBaoPay: {
  113. type: Boolean,
  114. default: false
  115. },
  116. // 用户的商家充值的余额支付
  117. shopIdPay: { // 某商家的‘用户的商家充值的余额支付’对应的商家Id
  118. type: [String, Number],
  119. default: ''
  120. }
  121. },
  122. data() {
  123. return {
  124. paymentMode: '', // 支付方式 1微信 2支付宝 3花呗分期
  125. paymentList: [],
  126. // 花呗相关
  127. flowerObj: {
  128. huabeiChargeType: 0, // 花呗手续费支付方式 1-商户支付 2-用户支付 后端接口返回
  129. hbByStagesPeriods: '-1', // 花呗分期期数 3 6 12
  130. hbByStagesList: [
  131. {
  132. rate: 0,
  133. price: 0,
  134. numberOfStages: '3',
  135. serviceCharge: 0,
  136. disabled: false
  137. },
  138. {
  139. rate: 0,
  140. price: 0,
  141. numberOfStages: '6',
  142. serviceCharge: 0,
  143. disabled: false
  144. },
  145. {
  146. rate: 0,
  147. price: 0,
  148. numberOfStages: '12',
  149. serviceCharge: 0,
  150. disabled: false
  151. }
  152. ], // 花呗手续费比例列表 【{3期},{6期},{12期}】
  153. hbServiceChargeTotal: 0 // 花呗支付总手续费
  154. },
  155. // 平台余额相关
  156. pricePlatformInfo: {
  157. rechargePrice: 0,
  158. commissionPrice: 0,
  159. beeCoinPrice: 0
  160. },
  161. // 用户的商家充值的余额相关
  162. priceShopInfo: {
  163. current: 0
  164. }
  165. }
  166. },
  167. watch: { // 对于watch,按书写顺序执行(如果由同步代码触发)。shopIdPay->pricePay
  168. showCommissionPay: {
  169. handler(newValue, oldValue) {
  170. if (newValue) {
  171. uni.showLoading()
  172. if (!this.paymentList.find((item) => item.paymentMode === '7')) {
  173. this.paymentList.push({
  174. label: '佣金支付',
  175. paymentMode: '7',
  176. icon: require('../../assets/images/user/pay/yongjin.png'),
  177. disabled: true
  178. })
  179. }
  180. getPricePlatformAllApi({})
  181. .then((res) => {
  182. this.pricePlatformInfo = res.data
  183. this.paymentList.find((item) => item.paymentMode === '7').disabled = !this.pricePay || (this.pricePay > this.pricePlatformInfo.commissionPrice)
  184. if (this.paymentList.find((item) => item.paymentMode === '7').disabled && (this.paymentMode === '7')) this.handleSetDisable()
  185. this.handleNoticeFather()
  186. uni.hideLoading()
  187. })
  188. .catch((e) => {
  189. if (this.paymentMode === '7') this.handleSetDisable()
  190. if (this.paymentList.find((item) => item.paymentMode === '7')) this.paymentList.splice(this.paymentList.findIndex((item) => item.paymentMode === '7'), 1)
  191. this.handleNoticeFather()
  192. uni.hideLoading()
  193. })
  194. } else {
  195. if (this.paymentMode === '7') this.handleSetDisable()
  196. if (this.paymentList.find((item) => item.paymentMode === '7')) this.paymentList.splice(this.paymentList.findIndex((item) => item.paymentMode === '7'), 1)
  197. this.handleNoticeFather()
  198. }
  199. },
  200. immediate: false,
  201. deep: true
  202. },
  203. showPlatformPay: {
  204. handler(newValue, oldValue) {
  205. if (newValue) {
  206. uni.showLoading()
  207. if (!this.paymentList.find((item) => item.paymentMode === '5')) {
  208. this.paymentList.push({
  209. label: '平台余额支付',
  210. paymentMode: '5',
  211. icon: require('../../assets/images/user/pay/platform-pay.png'),
  212. disabled: true
  213. })
  214. }
  215. getPricePlatformAllApi({})
  216. .then((res) => {
  217. this.pricePlatformInfo = res.data
  218. this.paymentList.find((item) => item.paymentMode === '5').disabled = !this.pricePay || (this.pricePay > this.pricePlatformInfo.rechargePrice)
  219. if (this.paymentList.find((item) => item.paymentMode === '5').disabled && (this.paymentMode === '5')) this.handleSetDisable()
  220. this.handleNoticeFather()
  221. uni.hideLoading()
  222. })
  223. .catch((e) => {
  224. if (this.paymentMode === '5') this.handleSetDisable()
  225. if (this.paymentList.find((item) => item.paymentMode === '5')) this.paymentList.splice(this.paymentList.findIndex((item) => item.paymentMode === '5'), 1)
  226. this.handleNoticeFather()
  227. uni.hideLoading()
  228. })
  229. } else {
  230. if (this.paymentMode === '5') this.handleSetDisable()
  231. if (this.paymentList.find((item) => item.paymentMode === '5')) this.paymentList.splice(this.paymentList.findIndex((item) => item.paymentMode === '5'), 1)
  232. this.handleNoticeFather()
  233. }
  234. },
  235. immediate: false,
  236. deep: true
  237. },
  238. showTransactionPay: {
  239. handler(newValue, oldValue) {
  240. if (newValue) {
  241. uni.showLoading()
  242. if (!this.paymentList.find((item) => item.paymentMode === '8')) {
  243. this.paymentList.push({
  244. label: '消费金支付',
  245. paymentMode: '8',
  246. icon: require('../../assets/images/user/pay/jiaoyijin.png'),
  247. disabled: true
  248. })
  249. }
  250. getPricePlatformAllApi({})
  251. .then((res) => {
  252. this.pricePlatformInfo = res.data
  253. this.paymentList.find((item) => item.paymentMode === '8').disabled = !this.pricePay || (this.pricePay > this.pricePlatformInfo.beeCoinPrice)
  254. if (this.paymentList.find((item) => item.paymentMode === '8').disabled && (this.paymentMode === '8')) this.handleSetDisable()
  255. this.handleNoticeFather()
  256. uni.hideLoading()
  257. })
  258. .catch((e) => {
  259. if (this.paymentMode === '8') this.handleSetDisable()
  260. if (this.paymentList.find((item) => item.paymentMode === '8')) this.paymentList.splice(this.paymentList.findIndex((item) => item.paymentMode === '8'), 1)
  261. this.handleNoticeFather()
  262. uni.hideLoading()
  263. })
  264. } else {
  265. if (this.paymentMode === '8') this.handleSetDisable()
  266. if (this.paymentList.find((item) => item.paymentMode === '8')) this.paymentList.splice(this.paymentList.findIndex((item) => item.paymentMode === '8'), 1)
  267. this.handleNoticeFather()
  268. }
  269. },
  270. immediate: false,
  271. deep: true
  272. },
  273. showHuiShiBaoPay: {
  274. handler(newValue, oldValue) {
  275. if (newValue) {
  276. if (!this.paymentList.find((item) => item.paymentMode === '9')) {
  277. this.paymentList.push({
  278. label: '惠市宝支付(支持微信/支付宝/银联)',
  279. paymentMode: '9',
  280. icon: require('../../assets/images/user/pay/huishibao.png'),
  281. disabled: true
  282. })
  283. }
  284. this.paymentList.find((item) => item.paymentMode === '9').disabled = !this.pricePay
  285. if (this.paymentList.find((item) => item.paymentMode === '9').disabled && (this.paymentMode === '9')) this.handleSetDisable()
  286. this.handleNoticeFather()
  287. } else {
  288. if (this.paymentMode === '9') this.handleSetDisable()
  289. if (this.paymentList.find((item) => item.paymentMode === '9')) this.paymentList.splice(this.paymentList.findIndex((item) => item.paymentMode === '9'), 1)
  290. this.handleNoticeFather()
  291. }
  292. },
  293. immediate: false,
  294. deep: true
  295. },
  296. shopIdPay: {
  297. handler(newValue, oldValue) {
  298. // console.log(2222)
  299. if (newValue && (newValue !== oldValue)) {
  300. uni.showLoading()
  301. if (!this.paymentList.find((item) => item.paymentMode === '6')) {
  302. this.paymentList.push({
  303. label: '商家余额支付',
  304. paymentMode: '6',
  305. icon: require('../../assets/images/user/pay/shop-id-pay.png'),
  306. disabled: true
  307. })
  308. }
  309. getRechargeTotalCustomersApi({ shopId: this.shopIdPay })
  310. .then((res) => {
  311. // console.log(3333)
  312. this.priceShopInfo = res.data
  313. this.paymentList.find((item) => item.paymentMode === '6').disabled = !this.pricePay || (this.pricePay > this.priceShopInfo.current)
  314. if (this.paymentList.find((item) => item.paymentMode === '6').disabled && (this.paymentMode === '6')) this.handleSetDisable()
  315. this.handleNoticeFather()
  316. uni.hideLoading()
  317. })
  318. .catch((e) => {
  319. if (this.paymentMode === '6') this.handleSetDisable()
  320. if (this.paymentList.find((item) => item.paymentMode === '6')) this.paymentList.splice(this.paymentList.findIndex((item) => item.paymentMode === '6'), 1)
  321. this.handleNoticeFather()
  322. uni.hideLoading()
  323. })
  324. } else if (!newValue) {
  325. if (this.paymentMode === '6') this.handleSetDisable()
  326. if (this.paymentList.find((item) => item.paymentMode === '6')) this.paymentList.splice(this.paymentList.findIndex((item) => item.paymentMode === '6'), 1)
  327. this.handleNoticeFather()
  328. }
  329. },
  330. immediate: false,
  331. deep: true
  332. },
  333. pricePay: {
  334. handler(newValue, oldValue) {
  335. // console.log(1111)
  336. if (newValue !== oldValue) {
  337. if (this.paymentMode === '3') {
  338. this.handleHbStagesAndPrice()
  339. }
  340. if (this.showCommissionPay) {
  341. this.paymentList.find((item) => item.paymentMode === '7').disabled = !this.pricePay || (this.pricePay > this.pricePlatformInfo.commissionPrice)
  342. if (this.paymentList.find((item) => item.paymentMode === '7').disabled && (this.paymentMode === '7')) this.handleSetDisable()
  343. } else if (!this.showCommissionPay && (this.paymentMode === '7')) {
  344. this.handleSetDisable()
  345. }
  346. if (this.showPlatformPay) {
  347. this.paymentList.find((item) => item.paymentMode === '5').disabled = !this.pricePay || (this.pricePay > this.pricePlatformInfo.rechargePrice)
  348. if (this.paymentList.find((item) => item.paymentMode === '5').disabled && (this.paymentMode === '5')) this.handleSetDisable()
  349. } else if (!this.showPlatformPay && (this.paymentMode === '5')) {
  350. this.handleSetDisable()
  351. }
  352. if (this.showTransactionPay) {
  353. this.paymentList.find((item) => item.paymentMode === '8').disabled = !this.pricePay || (this.pricePay > this.pricePlatformInfo.beeCoinPrice)
  354. if (this.paymentList.find((item) => item.paymentMode === '8').disabled && (this.paymentMode === '8')) this.handleSetDisable()
  355. } else if (!this.showTransactionPay && (this.paymentMode === '8')) {
  356. this.handleSetDisable()
  357. }
  358. if (this.showHuiShiBaoPay) {
  359. this.paymentList.find((item) => item.paymentMode === '9').disabled = !this.pricePay
  360. if (this.paymentList.find((item) => item.paymentMode === '9').disabled && (this.paymentMode === '9')) this.handleSetDisable()
  361. } else if (!this.showHuiShiBaoPay && (this.paymentMode === '9')) {
  362. this.handleSetDisable()
  363. }
  364. if (this.shopIdPay) { // pricePay(明显直接)依赖shopIdPay,所以pricePay放后面
  365. if (this.paymentList.find((item) => item.paymentMode === '6')) {
  366. this.paymentList.find((item) => item.paymentMode === '6').disabled = !this.pricePay || (this.pricePay > this.priceShopInfo.current)
  367. if (this.paymentList.find((item) => item.paymentMode === '6').disabled && (this.paymentMode === '6')) this.handleSetDisable()
  368. }
  369. } else if (!this.shopIdPay && (this.paymentMode === '6')) {
  370. this.handleSetDisable()
  371. }
  372. this.handleNoticeFather()
  373. }
  374. },
  375. immediate: false,
  376. deep: true
  377. },
  378. showTonglianPay: {
  379. handler(newValue, oldValue) {
  380. if (newValue) {
  381. if (!this.paymentList.find((item) => item.paymentMode === '4')) {
  382. this.paymentList.push({
  383. label: '通联支付(微信)',
  384. paymentMode: '4',
  385. icon: require('../../assets/images/user/pay/tonglian.png'),
  386. disabled: true
  387. })
  388. }
  389. this.handleSetDisable()
  390. this.handleNoticeFather()
  391. } else {
  392. if (this.paymentMode === '4') this.handleSetDisable()
  393. if (this.paymentList.find((item) => item.paymentMode === '4')) this.paymentList.splice(this.paymentList.findIndex((item) => item.paymentMode === '4'), 1)
  394. this.handleNoticeFather()
  395. }
  396. },
  397. immediate: false,
  398. deep: true
  399. }
  400. },
  401. created() {
  402. this.paymentList = []
  403. if (this.showWechatPay) {
  404. this.paymentList.push({
  405. label: '微信支付',
  406. paymentMode: '1',
  407. icon: require('../../assets/images/user/pay/wechat_pay.png'),
  408. disabled: true
  409. })
  410. this.handleSetDisable()
  411. this.handleNoticeFather()
  412. }
  413. if (this.showAliPay) {
  414. this.paymentList.push({
  415. label: '支付宝支付',
  416. paymentMode: '2',
  417. icon: require('../../assets/images/user/pay/alipay.png'),
  418. disabled: true
  419. })
  420. this.handleSetDisable()
  421. this.handleNoticeFather()
  422. }
  423. if (this.showHuabeiPay) {
  424. this.paymentList.push({
  425. label: '花呗分期',
  426. paymentMode: '3',
  427. icon: require('../../assets/images/user/pay/huabei.png'),
  428. disabled: true
  429. })
  430. // 获取花呗分期配置
  431. getOrderHuabeiConfigApi({})
  432. .then((res) => {
  433. this.flowerObj.huabeiChargeType = res.data.huabeiChargeType
  434. if (this.flowerObj.huabeiChargeType === 1) { // 如果后端返回的是用户支付手续费,设置费率信息
  435. res.data.huabeiFeeRateList.forEach((rate, index) => {
  436. this.flowerObj.hbByStagesList[index].rate = rate
  437. })
  438. }
  439. this.handleSetDisable()
  440. this.handleNoticeFather()
  441. })
  442. }
  443. if (this.showTonglianPay) {
  444. this.paymentList.push({
  445. label: '通联支付(微信)',
  446. paymentMode: '4',
  447. icon: require('../../assets/images/user/pay/tonglian.png'),
  448. disabled: true
  449. })
  450. this.handleSetDisable()
  451. this.handleNoticeFather()
  452. }
  453. if (this.showCommissionPay || this.showPlatformPay || this.showTransactionPay) {
  454. if (this.showCommissionPay) {
  455. this.paymentList.push({
  456. label: '佣金支付',
  457. paymentMode: '7',
  458. icon: require('../../assets/images/user/pay/yongjin.png'),
  459. disabled: true
  460. })
  461. }
  462. if (this.showPlatformPay) {
  463. this.paymentList.push({
  464. label: '平台余额支付',
  465. paymentMode: '5',
  466. icon: require('../../assets/images/user/pay/platform-pay.png'),
  467. disabled: true
  468. })
  469. }
  470. if (this.showTransactionPay) {
  471. this.paymentList.push({
  472. label: '消费金支付',
  473. paymentMode: '8',
  474. icon: require('../../assets/images/user/pay/jiaoyijin.png'),
  475. disabled: true
  476. })
  477. }
  478. getPricePlatformAllApi({})
  479. .then((res) => {
  480. this.pricePlatformInfo = res.data
  481. if (this.showCommissionPay) {
  482. this.paymentList.find((item) => item.paymentMode === '7').disabled = !this.pricePay || (this.pricePay > this.pricePlatformInfo.commissionPrice)
  483. }
  484. if (this.showPlatformPay) {
  485. this.paymentList.find((item) => item.paymentMode === '5').disabled = !this.pricePay || (this.pricePay > this.pricePlatformInfo.rechargePrice)
  486. }
  487. if (this.showTransactionPay) {
  488. this.paymentList.find((item) => item.paymentMode === '8').disabled = !this.pricePay || (this.pricePay > this.pricePlatformInfo.beeCoinPrice)
  489. }
  490. this.handleSetDisable()
  491. this.handleNoticeFather()
  492. })
  493. }
  494. if (this.showHuiShiBaoPay) {
  495. this.paymentList.push({
  496. label: '惠市宝支付(支持微信/支付宝/银联)',
  497. paymentMode: '9',
  498. icon: require('../../assets/images/user/pay/huishibao.png'),
  499. disabled: true
  500. })
  501. this.paymentList.find((item) => item.paymentMode === '9').disabled = !this.pricePay
  502. this.handleSetDisable()
  503. this.handleNoticeFather()
  504. }
  505. if (this.shopIdPay) {
  506. this.paymentList.push({
  507. label: '商家余额支付',
  508. paymentMode: '6',
  509. icon: require('../../assets/images/user/pay/shop-id-pay.png'),
  510. disabled: true
  511. })
  512. getRechargeTotalCustomersApi({ shopId: this.shopIdPay })
  513. .then((res) => {
  514. this.priceShopInfo = res.data
  515. this.paymentList.find((item) => item.paymentMode === '6').disabled = !this.pricePay || (this.pricePay > this.priceShopInfo.current)
  516. this.handleSetDisable()
  517. this.handleNoticeFather()
  518. })
  519. }
  520. },
  521. methods: {
  522. // 根据环境更改可选支付项
  523. handleSetDisable() {
  524. // #ifdef H5
  525. if (this.showTonglianPay) {
  526. this.paymentList.find((item) => item.paymentMode === '4').disabled = false
  527. this.paymentMode = '4'
  528. } else {
  529. this.paymentList.find((item) => item.paymentMode === '4').disabled = true
  530. this.paymentMode = ''
  531. }
  532. // #endif
  533. // // #ifdef APP
  534. // if (this.showTonglianPay) {
  535. // this.paymentList.find((item) => item.paymentMode === '4').disabled = false
  536. // this.paymentMode = '4'
  537. // } else {
  538. // this.paymentList.find((item) => item.paymentMode === '4').disabled = true
  539. // this.paymentMode = ''
  540. // }
  541. // // #endif
  542. // // #ifdef MP-WEIXIN
  543. // if (this.showTonglianPay) {
  544. // this.paymentList.find((item) => item.paymentMode === '4').disabled = false
  545. // this.paymentMode = '4'
  546. // } else {
  547. // // this.paymentList.find((item) => item.paymentMode === '1').disabled = false
  548. // this.paymentList.find((item) => item.paymentMode === '4').disabled = true
  549. // this.paymentMode = '' // 1
  550. // }
  551. // // #endif
  552. // // #ifdef MP-ALIPAY
  553. // if (this.showTonglianPay) {
  554. // this.paymentList.find((item) => item.paymentMode === '4').disabled = false
  555. // this.paymentMode = '4'
  556. // } else {
  557. // // this.paymentList.find((item) => item.paymentMode === '2').disabled = false
  558. // // if(this.flowerObj.huabeiChargeType) this.paymentList.find((item) => item.paymentMode === '3').disabled = false
  559. // this.paymentList.find((item) => item.paymentMode === '4').disabled = true
  560. // this.paymentMode = '' // 2
  561. // }
  562. // // #endif
  563. },
  564. // 支付方式改变事件
  565. handleChangePaymentMode(e) {
  566. console.log(e)
  567. if (this.paymentList.find((item) => item.paymentMode === e).disabled) {
  568. this.paymentMode = ''
  569. } else {
  570. this.paymentMode = e
  571. }
  572. if (this.paymentMode !== '3') {
  573. // 支付宝支付,取消分期选择
  574. this.flowerObj.hbByStagesPeriods = '-1'
  575. // 3 6 12 全部禁止
  576. this.flowerObj.hbByStagesList.forEach((item) => {
  577. item.disabled = true
  578. })
  579. } else {
  580. // 分期支付,默认选三期
  581. this.flowerObj.hbByStagesPeriods = '3'
  582. }
  583. this.handleHbStagesAndPrice()
  584. this.handleNoticeFather()
  585. },
  586. // 支付方式点击事件
  587. handleClickPaymentMode(payment) {
  588. if (payment.paymentMode === '7') {
  589. if (!this.pricePay) {
  590. uni.showToast({ title: this.missingPriceText, icon: 'none' })
  591. } else if (this.pricePay > this.pricePlatformInfo.commissionPrice) {
  592. uni.showToast({ title: '该余额小于支付金额,请使用其他支付方式', icon: 'none' }) // 佣金不足
  593. }
  594. } else if (payment.paymentMode === '5') {
  595. if (!this.pricePay) {
  596. uni.showToast({ title: this.missingPriceText, icon: 'none' })
  597. } else if (this.pricePay > this.pricePlatformInfo.rechargePrice) {
  598. uni.showToast({ title: '该余额小于支付金额,请使用其他支付方式', icon: 'none' }) // 平台余额不足
  599. }
  600. } else if (payment.paymentMode === '8') {
  601. if (!this.pricePay) {
  602. uni.showToast({ title: this.missingPriceText, icon: 'none' })
  603. } else if (this.pricePay > this.pricePlatformInfo.beeCoinPrice) {
  604. uni.showToast({ title: '该余额小于支付金额,请使用其他支付方式', icon: 'none' }) // 消费金余额不足
  605. }
  606. } else if (payment.paymentMode === '6') {
  607. if (!this.pricePay) {
  608. uni.showToast({ title: this.missingPriceText, icon: 'none' })
  609. } else if (this.pricePay > this.priceShopInfo.current) {
  610. uni.showToast({ title: '该余额小于支付金额,请使用其他支付方式', icon: 'none' }) // 商家余额不足
  611. }
  612. }
  613. },
  614. /**
  615. * 处理花呗期数选择
  616. * @param periods 期数
  617. * @param disabled
  618. */
  619. handleChangePeriods(e) {
  620. if (this.flowerObj.hbByStagesList.find((item) => item.numberOfStages === e).disabled) return
  621. this.flowerObj.hbByStagesPeriods = e
  622. this.handleHbStagesAndPrice()
  623. this.handleNoticeFather()
  624. },
  625. // 处理花呗价格和手续费显示
  626. handleHbStagesAndPrice() {
  627. if (this.paymentMode !== '3') return
  628. this.flowerObj.hbByStagesList.forEach((stages) => {
  629. // 根据价格填充每一期价格和手续费信息
  630. stages.price = ((this.pricePay * (1 + stages.rate / 100)) / Number(stages.numberOfStages)).toFixed(2) // 每一期价格
  631. stages.serviceCharge = ((this.pricePay * (stages.rate / 100)) / Number(stages.numberOfStages)).toFixed(2) // 每一期手续费
  632. // 计算总手续费
  633. if (Number(stages.numberOfStages) === Number(this.flowerObj.hbByStagesPeriods)) {
  634. this.flowerObj.hbServiceChargeTotal = (this.pricePay * (stages.rate / 100)).toFixed(2)
  635. }
  636. // 处理允许分期的区间,公式为总价格要大于分期数/100
  637. this.pricePay < Number(stages.numberOfStages) / 100 ? stages.disabled = true : stages.disabled = false
  638. })
  639. },
  640. // 通知父组件
  641. handleNoticeFather() {
  642. this.$emit('change', {
  643. paymentMode: Number(this.paymentMode),
  644. huabeiPeriod: this.paymentMode === '3' ? Number(this.flowerObj.hbByStagesPeriods) : -1
  645. })
  646. }
  647. }
  648. }
  649. </script>
  650. <style lang="scss" scoped>
  651. .cashier-list-content {
  652. width: 100%;
  653. box-sizing: border-box;
  654. background: #fff;
  655. .cashier {
  656. border-bottom: 2px solid #d0d0d0;
  657. &:last-child {
  658. border-bottom: none
  659. }
  660. .cashier-item {
  661. display: flex;
  662. align-items: center;
  663. justify-content: space-between;
  664. padding: 20px 0;
  665. box-sizing: border-box;
  666. position: relative;
  667. .icon-text {
  668. display: flex;
  669. align-items: center;
  670. justify-content: center;
  671. image {
  672. width: 50px;
  673. height: 50px;
  674. margin-right: 15px;
  675. }
  676. }
  677. }
  678. .ali-hb-content {
  679. padding: 10px 20px;
  680. box-sizing: border-box;
  681. border-top: 2px solid #d0d0d0;
  682. }
  683. }
  684. }
  685. </style>