social.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import {Component, Vue} from 'vue-property-decorator';
  2. import Utils from '@/extend/Utils';
  3. import Http from '@/extend/Http';
  4. import router from '@/router';
  5. // import { } from "@/components" // 组件
  6. const serviceChargeData: any = [
  7. {
  8. monthly: '月付:100元/月', seasonal: '季付:270元/季', halfYearly: '半年付:480元/半年', yearly: '年付:600元/年',
  9. },
  10. {
  11. monthly: '月付:150元/月', seasonal: '季付:405元/季', halfYearly: '半年付:720元/半年', yearly: '年付:900元/年',
  12. }
  13. ];
  14. @Component({})
  15. export default class Social extends Vue {
  16. public data: any = {
  17. is_fund: true,
  18. is_discounts: false,
  19. social_calc: null,
  20. service_calc: 0,
  21. fund_calc: 0,
  22. shouxu:0,
  23. subtotal_calc: 0,
  24. total_calc: 0,
  25. social_basic: {pension: 3400, fund: 3400},
  26. social_type: null,
  27. service_charge: null,
  28. discountList:'',
  29. value:'',
  30. is_balance:0,
  31. blance:'',
  32. };
  33. private service_charge_type: string = 'monthly';
  34. async created() {
  35. let params = Utils.getInstance().getParams(location.href);
  36. this.data.is_fund = !!params.is_fund;
  37. this.data.social_type = localStorage.getItem('social_type');
  38. if (this.data.social_type != null) {
  39. let res = await Http.getInstance().socialLimit({
  40. socialType: this.data.social_type
  41. });
  42. this.data.social_basic = res.data;
  43. }
  44. this.data.social_type = this.data.social_type - 1;
  45. this.data.service_charge = serviceChargeData[this.data.social_type];
  46. }
  47. updated() {
  48. if (this.data.social_calc == null) {
  49. this.calcBill();
  50. }
  51. }
  52. async changebalance(event: any){
  53. // console.log(event)
  54. console.log(this.data.is_balance)
  55. }
  56. async saveInfo(event: any) {
  57. console.log(event);
  58. console.log(event.target.form);
  59. let form = event.target.form;
  60. if (form.checkValidity() === false) {
  61. form.classList.add('was-validated');
  62. event.preventDefault();
  63. event.stopPropagation();
  64. return false;
  65. }
  66. let res = await Http.getInstance().saveBase(Utils.getInstance().serialize(form));
  67. // @ts-ignore
  68. this.data.social_type = res.data.social_type;
  69. this.data.service_charge = serviceChargeData[res.data.social_type];
  70. localStorage.setItem('social_type', this.data.social_type);
  71. localStorage.setItem('service_charge', this.data.service_charge);
  72. localStorage.setItem('access_token', res.data.access_token);
  73. localStorage.setItem('refresh_token', res.data.refresh_token);
  74. res = await Http.getInstance().socialLimit({
  75. socialType: this.data.social_type
  76. });
  77. this.data.social_basic = res.data;
  78. return false;
  79. }
  80. async calcBill(event?: any) {
  81. let form = event ? event.target.form : document.getElementById('social-detail');
  82. if (form.checkValidity() === false) {
  83. form.classList.add('was-validated');
  84. return false;
  85. }
  86. let res = await Http.getInstance().calcBill(Utils.getInstance().serialize(form));
  87. console.log(res)
  88. this.data.social_calc = res.data.social;
  89. this.data.service_calc = res.data.service;
  90. this.data.fund_calc = res.data.fund;
  91. this.data.subtotal_calc = res.data.subtotal;
  92. this.data.total_calc = res.data.total;
  93. this.data.is_discounts = res.data.discounts;
  94. let ress = await Http.getInstance().userinfo();
  95. this.data.blance = ress.data.balance
  96. let resss = await Http.getInstance().getDiscountListt();
  97. this.data.discountList = resss.data;
  98. console.log(this.data.discountList)
  99. }
  100. async saveOrder(event: any) {
  101. let form = event.target.form;
  102. console.log(form)
  103. if (form.checkValidity() === false) {
  104. form.classList.add('was-validated');
  105. event.preventDefault();
  106. event.stopPropagation();
  107. return false;
  108. }
  109. console.log(Utils.getInstance().serialize(form))
  110. let res = await Http.getInstance().saveOrder(Utils.getInstance().serialize(form));
  111. localStorage.setItem('order_paying', JSON.stringify(res.data));
  112. router.replace({
  113. name: 'opayment',
  114. params: {
  115. order_sn: res.data.order_sn
  116. }
  117. });
  118. }
  119. }