index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <view class="rechargePopup-box">
  3. <view class="rechargePopup-title">
  4. <view>代金券充值</view>
  5. <view @click="cancel">取消</view>
  6. </view>
  7. <view class="rechargePopup-list">
  8. <view
  9. class="rechargePopup-item"
  10. v-for="(item, index) in transferPriceList"
  11. :key="index"
  12. :class="idx === index ? 'act' : ''"
  13. @click="changeIdx(index)"
  14. >
  15. <view>{{ item.number }}</view>
  16. <view>售价:{{ item.payGrade }}元</view>
  17. </view>
  18. </view>
  19. <view class="custom" :class="idx === 5 ? 'act' : ''" @click="changeIdx(5)">
  20. <view class="custom-left">自定义代金券</view>
  21. <view class="custom-input">
  22. <input type="number" v-model="customNum" />
  23. </view>
  24. <view class="custom-right">售价:{{ realityNum }}元</view>
  25. </view>
  26. <view class="immediately-btn" @click="getOrder">立即充值</view>
  27. </view>
  28. </template>
  29. <script>
  30. import { voucherOrderApi } from "@/config/index.js";
  31. export default {
  32. computed: {
  33. realityNum() {
  34. return this.customNum / 2;
  35. },
  36. },
  37. data() {
  38. return {
  39. // 激活态
  40. idx: "",
  41. // 转赠金额列表
  42. // 50, 100, 200, 1000, 2000, ""
  43. transferPriceList: [
  44. {
  45. number: "50",
  46. payGrade: "25",
  47. },
  48. {
  49. number: "100",
  50. payGrade: "50",
  51. },
  52. {
  53. number: "200",
  54. payGrade: "100",
  55. },
  56. {
  57. number: "1000",
  58. payGrade: "500",
  59. },
  60. {
  61. number: "2000",
  62. payGrade: "1000",
  63. },
  64. {
  65. number: "",
  66. payGrade: "",
  67. },
  68. ],
  69. customNum: "",
  70. };
  71. },
  72. methods: {
  73. // 提交订单
  74. async getOrder() {
  75. this.$showToast("功能正在开发....")
  76. return
  77. console.log(this.idx);
  78. if (this.idx === "") {
  79. this.$showToast("请选择充值金额");
  80. return;
  81. }
  82. let obj = {
  83. voucherId: 186,
  84. ...(this.idx === 5?{number: this.customNum,payGrade: this.realityNum,}: this.transferPriceList[this.idx]),
  85. };
  86. let res = await voucherOrderApi(obj);
  87. console.log(res);
  88. },
  89. // 修改激活态
  90. changeIdx(val) {
  91. this.idx = val;
  92. },
  93. // 取消按钮
  94. cancel() {
  95. this.$emit("cancel");
  96. },
  97. },
  98. };
  99. </script>
  100. <style lang="scss" scoped>
  101. @import "./index.scss";
  102. </style>