123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- import {Component, Vue} from 'vue-property-decorator';
- import Utils from '@/extend/Utils';
- import Http from '@/extend/Http';
- import router from '@/router';
- // import { } from "@/components" // 组件
- const serviceChargeData: any = [
- {
- monthly: '月付:100元/月', seasonal: '季付:270元/季', halfYearly: '半年付:480元/半年', yearly: '年付:600元/年',
- },
- {
- monthly: '月付:150元/月', seasonal: '季付:405元/季', halfYearly: '半年付:720元/半年', yearly: '年付:900元/年',
- }
- ];
- @Component({})
- export default class Social extends Vue {
- public data: any = {
- is_fund: true,
- is_discounts: false,
- social_calc: null,
- service_calc: 0,
- fund_calc: 0,
- shouxu:0,
- subtotal_calc: 0,
- total_calc: 0,
- social_basic: {pension: 3400, fund: 3400},
- social_type: null,
- service_charge: null,
- discountList:'',
- value:'',
- is_balance:0,
- blance:'',
- };
- private service_charge_type: string = 'monthly';
- async created() {
- let params = Utils.getInstance().getParams(location.href);
- this.data.is_fund = !!params.is_fund;
- this.data.social_type = localStorage.getItem('social_type');
- if (this.data.social_type != null) {
- let res = await Http.getInstance().socialLimit({
- socialType: this.data.social_type
- });
- this.data.social_basic = res.data;
- }
- this.data.social_type = this.data.social_type - 1;
- this.data.service_charge = serviceChargeData[this.data.social_type];
- }
- updated() {
- if (this.data.social_calc == null) {
- this.calcBill();
- }
- }
- async changebalance(event: any){
- // console.log(event)
- console.log(this.data.is_balance)
- }
- async saveInfo(event: any) {
- console.log(event);
- console.log(event.target.form);
- let form = event.target.form;
- if (form.checkValidity() === false) {
- form.classList.add('was-validated');
- event.preventDefault();
- event.stopPropagation();
- return false;
- }
- let res = await Http.getInstance().saveBase(Utils.getInstance().serialize(form));
- // @ts-ignore
- this.data.social_type = res.data.social_type;
- this.data.service_charge = serviceChargeData[res.data.social_type];
- localStorage.setItem('social_type', this.data.social_type);
- localStorage.setItem('service_charge', this.data.service_charge);
- localStorage.setItem('access_token', res.data.access_token);
- localStorage.setItem('refresh_token', res.data.refresh_token);
- res = await Http.getInstance().socialLimit({
- socialType: this.data.social_type
- });
- this.data.social_basic = res.data;
- return false;
- }
- async calcBill(event?: any) {
- let form = event ? event.target.form : document.getElementById('social-detail');
- if (form.checkValidity() === false) {
- form.classList.add('was-validated');
- return false;
- }
- let res = await Http.getInstance().calcBill(Utils.getInstance().serialize(form));
- console.log(res)
- this.data.social_calc = res.data.social;
- this.data.service_calc = res.data.service;
- this.data.fund_calc = res.data.fund;
- this.data.subtotal_calc = res.data.subtotal;
- this.data.total_calc = res.data.total;
- this.data.is_discounts = res.data.discounts;
- let ress = await Http.getInstance().userinfo();
- this.data.blance = ress.data.balance
- let resss = await Http.getInstance().getDiscountListt();
- this.data.discountList = resss.data;
- console.log(this.data.discountList)
- }
- async saveOrder(event: any) {
- let form = event.target.form;
- console.log(form)
- if (form.checkValidity() === false) {
- form.classList.add('was-validated');
- event.preventDefault();
- event.stopPropagation();
- return false;
- }
- console.log(Utils.getInstance().serialize(form))
- let res = await Http.getInstance().saveOrder(Utils.getInstance().serialize(form));
- localStorage.setItem('order_paying', JSON.stringify(res.data));
- router.replace({
- name: 'opayment',
- params: {
- order_sn: res.data.order_sn
- }
- });
- }
- }
|