MoneyRate.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <div>
  3. <x-input type="number" placeholder="请输入正确的数字" title="自定义利率" v-model="customRate">
  4. <span slot="right">%
  5. <x-button plain mini @click.native="submit" class="custom-primary-red">确定</x-button>
  6. </span>
  7. </x-input>
  8. <group title="或者选择常用利率">
  9. <radio :options="rateList" v-model="selectedRate" @on-change="change"></radio>
  10. </group>
  11. </div>
  12. </template>
  13. <script>
  14. import {Group, XInput, XButton, Radio } from "vux";
  15. export default {
  16. components: {
  17. Group,
  18. XInput,
  19. XButton,
  20. Radio
  21. },
  22. props: {
  23. baseRate:0
  24. },
  25. data() {
  26. return {
  27. customRate: null,
  28. selectedRate: 1,
  29. rateList: [
  30. { key: 1, value: "基准利率" },
  31. { key: 0.7, value: "7折" },
  32. { key: 0.85, value: "85折" },
  33. { key: 0.88, value: "88折" },
  34. { key: 0.9, value: "9折" },
  35. { key: 0.95, value: "95折" },
  36. { key: 1.05, value: "1.05倍" },
  37. { key: 1.1, value: "1.1倍" },
  38. { key: 1.2, value: "1.2倍" },
  39. { key: 1.3, value: "1.3倍" }
  40. ]
  41. };
  42. },
  43. methods: {
  44. change(val, label) {
  45. let actRate = this.baseRate*val
  46. this.$emit("submit", (actRate*100).toFixed(2)+"%",actRate);
  47. },
  48. submit() {
  49. if (this.customRate) {
  50. if (this.customRate < 100) {
  51. this.customRate = Number(this.customRate).toFixed(2);
  52. this.$emit("submit", this.customRate+"%",this.customRate/100);
  53. }
  54. } else {
  55. this.change(this.selectedRate)
  56. }
  57. }
  58. },
  59. watch: {
  60. baseRate () {
  61. this.change(this.selectedRate)
  62. }
  63. }
  64. };
  65. </script>
  66. <style lang="less">
  67. .custom-primary-red {
  68. border-color: #0259e7 !important;
  69. color: #0259e7 !important;
  70. // // ce3c39
  71. // &:active {
  72. // border-color: rgba(206, 60, 57, 0.6) !important;
  73. // color: rgba(206, 60, 57, 0.6) !important;
  74. // background-color: transparent;
  75. // }
  76. }
  77. </style>