order-address-modify.page.js
2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import Vue from 'vue';
require('scss/common.scss');
require('scss/home/order-address-modify.page.scss');
const $ = require('yoho-jquery');
const tip = require('js/plugin/tip');
const stringHandle = require('js/common/helpers/stringHandle');
require('js/common');
let $areaForm = $('#areaForm');
let $btnSure = $('#btnSure');
let $province = $('input[name=province]');
let $provinceCode = $('input[name=provinceCode]');
let $area = $('#area');
let $usernameInput = $areaForm.find('input[name=username]');
import vueAddressAct from 'vues/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;
});
$usernameInput.bind('input propertychange', function() {
if (stringHandle.chinese2($usernameInput.val()) > 20) {
tip.show('收货人姓名最多支持20个字');
$usernameInput.val($usernameInput.val() && stringHandle.sub_chinese2($usernameInput.val(), 20));
}
});
/**
* 提交表单
*/
$btnSure.on('click', function() {
let username = $usernameInput.val().replace(/(^\s+)|(\s+$)/g, '');
if (username && !/^[\u4E00-\u9FA5A-Za-z0-9*]+$/gi.test(username)) {
tip.show('收货人姓名不支持特殊符号');
return false;
}
$.post('/home/orders/changeAddress', $areaForm.serialize(), function(result) {
if (result && result.code === 200) {
if (result.data && result.data.is_modified === 'Y') {
tip.show(result.data.tips);
}
location.href = document.referrer;
} else {
tip.show((result && result.message) || '系统错误,请重试!');
}
});
});
/**
* 动态更改页面高度
*/
$(function() {
$('.address-modify').css('height', $(window).height());
});