order-address-modify.page.js 1.2 KB
const $ = require('yoho-jquery');
const Vue = require('vue');
const tip = require('../plugin/tip');

require('home/order-address-modify.page.css');
require('common.css');
require('../common');

let $areaForm = $('#areaForm');
let $btnSure = $('#btnSure');
let $province = $('input[name=province]');
let $provinceCode = $('input[name=provinceCode]');
let $area = $('#area');


let vueAddressAct = require('home/address/address-act.vue');

let addressVact = new Vue({
    el: '#vAddressAct',
    components: {
        vueAddressAct: vueAddressAct
    }
});

/**
 * 弹出地址选择框
 */
$area.on('click', function() {
    if ($provinceCode.val() && $province.val()) {
        addressVact.$children[0].supportChangeProvince = false;
        addressVact.$children[0].switchAddress($provinceCode.val(), $province.val());
    }

    addressVact.$children[0].show = true;
});

/**
 * 提交表单
 */
$btnSure.on('click', function() {
    $.post('/home/orders/changeAddress', $areaForm.serialize(), function(result) {
        if (result && result.code === 200) {
            tip.show(result.msg);
            location.href = document.referrer;
        } else {
            tip.show('系统错误,请重试!');
        }
    });
});