';
if (data.oaReturn.loanData.curr === 'TWD' && parseInt(data.oaReturn.loanData.loanMoney.replace(/,/g, '')) > 7000000) {
body += '【臺幣保單】單張借款金額以700萬為限,超過限額者系統將自動進行借款金額分配至其它保單。';
} else if (data.oaReturn.loanData.curr === 'USD' && parseInt(data.oaReturn.loanData.loanMoney.replace(/,/g, '')) > 200000) {
body += '【美元保單】單張借款金額以20萬為限,超過限額者系統將自動進行借款金額分配至其它保單。';
}
body += '
';
var modalBody = vajQuery(body);
var modalFooter = vajQuery('');
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
chatbotModal('noticeModal', 'show');
vajQuery('#appreciateSubmit').click(function () {
chatbotModal('noticeModal', 'hide');
});
});
}
vajQuery('#loanDistriSubmit').bind('click', function (e) {
try {
$('.loaderMain').show();
chatbotModal('loanDistriModal', 'hide');
vaCreateLoanConfirmModal(data);
} catch (e) {
$('.loaderMain').hide();
}
});
}
}
function vaCreateLoanDistriErrorModal(data) {
if (vajQuery('#loanDistriError').length !== 0) {
chatbotModal('loanDistriError', 'hide');
vajQuery('#loanDistriError').remove();
vaCreateLoanDistriErrorModal(data);
} else {
var modalWindow = vajQuery('
';
vajQuery('#ibmchat').append(loanConfirmModal);
chatbotModal('loanConfirmModal', 'show');
$('.loaderMain').hide();
vajQuery('#loanConfirmSubmit').bind('click', function (e) {
var hasInputIsEmpty = 'N';
if (vajQuery('#loanSuccess').is(':hidden')) {
if(emailList.length > 0){
hasInputIsEmpty = 'Y';
vaCreateVerifyModal('email');
} else{
hasInputIsEmpty = 'Y';
vaCreateVerifyModal('phone');
}
}
try {
$('.loaderMain').show();
if (hasInputIsEmpty === 'N') {
data.oaReturn.loanData.loanMoney = data.oaReturn.loanData.loanMoney.replace(/,/g, '');
var elementText = vajQuery(e.target).data('text');
va_sendWebSocket('openForm', 'formback', elementText, 'changePolicyLoan', data);
} else{
$('.loaderMain').hide();
}
} catch (e) {
$('.loaderMain').hide();
}
});
vajQuery('#checkloanCaptchaCode').click(function (e) {
try {
$('.loaderMain').show();
var hasInputIsEmpty = 'N';
if (vajQuery('#loanCaptchaCode').val() === '') {
vajQuery('#loanCaptchaCode').addClass('inputIsEmpty');
vajQuery('#loanCaptchaCode').attr('placeholder', '請輸入驗證碼');
hasInputIsEmpty = 'Y';
} else if (vajQuery('#loanCaptchaCode').hasClass('inputIsEmpty')) {
vajQuery('#loanCaptchaCode').removeClass('inputIsEmpty');
}
if (hasInputIsEmpty === 'N') {
var data = null;
var elementText = vajQuery(e.target).data('text');
if(emailList.length > 0){
data = {
OTPCode: vajQuery('#loanCaptchaCode').val(),
email: vajQuery('#emailInput').val(),
type: 'email'
};
} else {
data = {
OTPCode: vajQuery('#loanCaptchaCode').val(),
phone: vajQuery('#phoneInput').val(),
type: 'phone'
};
}
va_sendWebSocket('openForm', 'formback', elementText, 'checkOTP', data);
} else {
$('.loaderMain').hide();
}
} catch (e) {
console.log(e);
$('.loaderMain').hide();
}
});
vajQuery('#sendloanCaptchaByCSIS').click(function (e) {
if (vajQuery('#emailInput').val() === '請選擇電子郵件') {
vaCreateOTPErrorMessageModal(vajQuery('#emailInput').val());
} else if(vajQuery('#phoneInput').val() === '請選擇手機號碼'){
vaCreateOTPErrorMessageModal(vajQuery('#phoneInput').val());
}
else {
var elementText = vajQuery(e.target).data('text');
var endtime = addMinutes(new Date(), 5);
let year = endtime.getFullYear();
let month = ('0' + (endtime.getMonth() + 1)).slice(-2);
let day = ('0' + endtime.getDate()).slice(-2);
let hour = endtime.getHours();
let minute = endtime.getMinutes();
var endTime;
if (minute < 10) {
endTime = year + '/' + month + '/' + day + ' ' + hour + ':0' + minute;
} else{
endTime = year + '/' + month + '/' + day + ' ' + hour + ':' + minute;
}
let value = null;
if(emailList.length > 0){
value = {
email: vajQuery('#emailInput').val(),
sendTheOTPType: 'E',
returnCode: 'loanOTP',
endTime: endTime
};
} else {
value = {
phone: vajQuery('#phoneInput').val(),
sendTheOTPType: 'P',
returnCode: 'loanOTP',
endTime: endTime,
policyNo: data.oaReturn.returnMessage[0].policyCode
};
}
va_sendWebSocket('openForm', 'formback', elementText, 'sendCaptchaByCSIS', value);
vajQuery('#loanCaptchaCode').val('');
}
});
vajQuery('#edit').bind('click', function (e) {
chatbotModal('loanConfirmModal', 'hide');
vaCreateLoanModal(data.oaReturn.loanData, data.oaReturn.loanData.maxLoanAmount, data.oaReturn.loanData.curr, data.oaReturn.loanData.loanMoneyName);
});
}
}
function vaCreateChangeInfoModal(data) {
let policyDataList = JSON.parse(data);
if (vajQuery('#changeConfirmModal').length !== 0) {
chatbotModal('changeConfirmModal', 'hide');
vajQuery('#changeConfirmModal').remove();
vaCreateChangeInfoModal(data);
} else {
let changeConfirmModal = '';
changeConfirmModal += '
';
vajQuery('#ibmchat').append(changeConfirmModal);
chatbotModal('changeConfirmModal', 'show');
$('.loaderMain').hide();
$(function () {
var modalWindow = vajQuery('
'
);
var modalFooter = vajQuery('');
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
chatbotModal('noticeModal', 'show');
vajQuery('#appreciateSubmit').click(function () {
chatbotModal('noticeModal', 'hide');
});
});
vajQuery('#changeConfirmSubmit').bind('click', function (e) {
try {
$('.loaderMain').show();
chatbotModal('changeConfirmModal', 'hide');
vaCreateBasicChangeFormModal(data);
} catch (e) {
$('.loaderMain').hide();
}
});
vajQuery('#cancel,#close').bind('click', function (e) {
va_sendWebSocket('cancel', 'postback', '', 'F12_保單基本資料變更_取消');
chatbotModal('changeConfirmModal', 'hide');
});
}
}
function vaCreateBasicChangeFormModal(value) {
vajQuery('#emailInput').remove();
let policyDataList = [];
let changeData = '';
if (value.oaReturn === undefined) {
policyDataList = value;
} else {
policyDataList = JSON.stringify(value.oaReturn.policyDataList);
changeData = value.oaReturn.changeData;
}
if (vajQuery('#basicChangeFormModal').length !== 0) {
chatbotModal('basicChangeFormModal', 'hide');
vajQuery('#basicChangeFormModal').remove();
vaCreateBasicChangeFormModal(value);
} else {
var basicChangeFormModal = '';
basicChangeFormModal += '
';
vajQuery('#ibmchat').append(basicChangeFormModal);
chatbotModal('basicChangeFormModal', 'show');
$('.loaderMain').hide();
if (changeData !== '') {
let checkedItems = changeData.checkedItem;
for (var i in checkedItems) {
let item = checkedItems[i];
if (item === 'A') {
vajQuery('#addressCheckbox').prop('checked', true);
if (changeData.checkedAddrOpt === 'B') {
vajQuery('#postAddress').prop('checked', true);
}
$("div[name='addressArea']").toggle();
vajQuery('#postCodeInput').val(changeData.postCode);
vajQuery('#addressInput').val(changeData.address);
}
if (item === 'MO') {
vajQuery('#mobileOneCheckbox').prop('checked', true);
$("div[name='mobileOneArea']").toggle();
vajQuery('#mobileOneInput').val(changeData.mobileOne);
}
if (item === 'MT') {
vajQuery('#mobileTwoCheckbox').prop('checked', true);
$("div[name='mobileTwoArea']").toggle();
vajQuery('#mobileTwoInput').val(changeData.mobileTwo);
}
if (item === 'O') {
vajQuery('#officeTelCheckbox').prop('checked', true);
$("div[name='officeTelArea']").toggle();
vajQuery('#officeTelRegInput').val(changeData.officeTelReg);
vajQuery('#officeTelInput').val(changeData.officeTel);
vajQuery('#officeTelExtInput').val(changeData.officeTelExt);
}
if (item === 'H') {
vajQuery('#homeTelCheckbox').prop('checked', true);
$("div[name='homeTelArea']").toggle();
vajQuery('#homeTelRegInput').val(changeData.homeTelReg);
vajQuery('#homeTelInput').val(changeData.homeTel);
vajQuery('#homeTelExtInput').val(changeData.homeTelExt);
}
if (item === 'E') {
vajQuery('#emailCheckbox').prop('checked', true);
$("div[name='emailArea']").toggle();
vajQuery('#emailInput').val(changeData.mail);
}
}
}
$(function () {
$("div[name='addressArea']").toggle();
$("div[name='mobileOneArea']").toggle();
$("div[name='mobileTwoArea']").toggle();
$("div[name='officeTelArea']").toggle();
$("div[name='homeTelArea']").toggle();
$("div[name='emailArea']").toggle();
stopPsrnTimer(myPsrnOTPTimer);
stopMobileOnePsrnOTPTimer(myMobileOnePsrnOTPTimer);
});
vajQuery('#closeBasicChangeForm').click(function () {
va_sendWebSocket('cancel', 'postback', '', 'F12_保單基本資料變更_取消');
chatbotModal('basicChangeFormModal', 'hide');
});
vajQuery('#addressCheckbox').click(function () {
$("div[name='addressArea']").toggle();
});
vajQuery('#mobileOneCheckbox').click(function () {
$("div[name='mobileOneArea']").toggle();
});
vajQuery('#mobileTwoCheckbox').click(function () {
$("div[name='mobileTwoArea']").toggle();
});
vajQuery('#officeTelCheckbox').click(function () {
$("div[name='officeTelArea']").toggle();
});
vajQuery('#homeTelCheckbox').click(function () {
$("div[name='homeTelArea']").toggle();
});
vajQuery('#emailCheckbox').click(function () {
$("div[name='emailArea']").toggle();
});
vajQuery('#backToChangeConfirmSubmit').click(function (e) {
chatbotModal('basicChangeFormModal', 'hide');
if (value.oaReturn === undefined) {
vaCreateChangeInfoModal(value);
} else {
vaCreateChangeInfoModal(JSON.stringify(value.oaReturn.policyDataList));
}
});
vajQuery('#sendBasicChangeCaptchaByCSIS').click(function (e) {
if (vajQuery('#emailCheckbox').is(':checked') && vajQuery('#emailInput').val() === '') {
vajQuery('#emailInput').addClass('inputIsEmpty');
vajQuery('#emailInput').attr('placeholder', '請輸入Email');
} else if (vajQuery('#emailInput').hasClass('inputIsEmpty')) {
vajQuery('#emailInput').removeClass('inputIsEmpty');
} else if (vajQuery('#emailCheckbox').is(':checked') && vajQuery('#emailInput').val() !== '') {
vajQuery('#otpTimer').prop('hidden', false);
vajQuery('#psrnOTPTimer').prop('hidden', false);
var elementText = vajQuery(e.target).data('text');
const data = {
email: vajQuery('#emailInput').val(),
sendTheOTPType: 'E',
returnCode: 'changeOTP'
};
va_sendWebSocket('openForm', 'formback', elementText, 'sendCaptchaByCSIS', data);
vajQuery('#changeCaptchaCode').val('');
}
});
vajQuery('#sendBasicChangeMobileOneCaptchaByCSIS').click(function (e) {
if (vajQuery('#mobileOneCheckbox').is(':checked') && vajQuery('#mobileOneInput').val() === '') {
vajQuery('#mobileOneInput').addClass('inputIsEmpty');
vajQuery('#mobileOneInput').attr('placeholder', '請輸入手機號碼');
} else if (vajQuery('#mobileOneInput').hasClass('inputIsEmpty')) {
vajQuery('#mobileOneInput').removeClass('inputIsEmpty');
} else if (vajQuery('#mobileOneCheckbox').is(':checked') && vajQuery('#mobileOneInput').val() !== '') {
vajQuery('#mobileOneOtpTimer').prop('hidden', false);
vajQuery('#mobileOnePsrnOTPTimer').prop('hidden', false);
var elementText = vajQuery(e.target).data('text');
const data = {
phone: vajQuery('#mobileOneInput').val(),
sendTheOTPType: 'P',
returnCode: 'changeOTP',
policyNo: JSON.parse(policyDataList)[0].policyCode
};
va_sendWebSocket('openForm', 'formback', elementText, 'sendCaptchaByCSIS', data);
vajQuery('#changeMobileOneCaptchaCode').val('');
}
});
vajQuery('#ackToChangeConfirmSubmit').click(function (e) {
$('.loaderMain').show();
chatbotModal('basicChangeFormModal', 'hide');
$('.loaderMain').hide();
});
vajQuery('#postCodeInput').keyup(function () {
this.value = this.value.replace(/[^0-9]/g, '');
if (this.value > 6) {
this.value = this.value.substring(0, 7);
}
});
vajQuery('#mobileOneInput').keyup(function () {
this.value = this.value.replace(/[^0-9]/g, '');
if (this.value > 10) {
this.value = this.value.substring(0, 11);
}
});
vajQuery('#mobileTwoInput').keyup(function () {
this.value = this.value.replace(/[^0-9]/g, '');
if (this.value > 10) {
this.value = this.value.substring(0, 11);
}
});
vajQuery('#officeTelRegInput').keyup(function () {
this.value = this.value.replace(/[^0-9]/g, '');
});
vajQuery('#officeTelInput').keyup(function () {
this.value = this.value.replace(/[^0-9]/g, '');
});
vajQuery('#officeTelExtInput').keyup(function () {
this.value = this.value.replace(/[^0-9]/g, '');
});
vajQuery('#homeTelRegInput').keyup(function () {
this.value = this.value.replace(/[^0-9]/g, '');
});
vajQuery('#homeTelInput').keyup(function () {
this.value = this.value.replace(/[^0-9]/g, '');
});
vajQuery('#homeTelExtInput').keyup(function () {
this.value = this.value.replace(/[^0-9]/g, '');
});
vajQuery('#emailInput').keyup(function () {
this.value = this.value.replace(/[^0-9a-z@\.]/g, '');
});
vajQuery('#basicChangeFormSubmit').click(function (e) {
var hasInputIsEmpty = 'N';
if (vajQuery('#addressCheckbox').is(':checked')) {
if (vajQuery('#addressInput').val() === '') {
vajQuery('#addressInput').addClass('inputIsEmpty');
vajQuery('#addressInput').attr('placeholder', '請輸入住址');
hasInputIsEmpty = 'Y';
} else if (vajQuery('#addressInput').hasClass('inputIsEmpty')) {
vajQuery('#addressInput').removeClass('inputIsEmpty');
}
}
if (vajQuery('#mobileOneCheckbox').is(':checked') && vajQuery('#mobileOneInput').val() === '') {
vajQuery('#mobileOneInput').addClass('inputIsEmpty');
vajQuery('#mobileOneInput').attr('placeholder', '請輸入手機1');
hasInputIsEmpty = 'Y';
} else if (vajQuery('#mobileOneInput').hasClass('inputIsEmpty')) {
vajQuery('#mobileOneInput').removeClass('inputIsEmpty');
}
if (vajQuery('#mobileTwoCheckbox').is(':checked') && vajQuery('#mobileTwoInput').val() === '') {
vajQuery('#mobileTwoInput').addClass('inputIsEmpty');
vajQuery('#mobileTwoInput').attr('placeholder', '請輸入手機2');
hasInputIsEmpty = 'Y';
} else if (vajQuery('#mobileTwoInput').hasClass('inputIsEmpty')) {
vajQuery('#mobileTwoInput').removeClass('inputIsEmpty');
}
if (vajQuery('#officeTelCheckbox').is(':checked')) {
if (vajQuery('#officeTelRegInput').val() === '') {
vajQuery('#officeTelRegInput').addClass('inputIsEmpty');
vajQuery('#officeTelRegInput').attr('placeholder', '請輸入區碼');
hasInputIsEmpty = 'Y';
} else if (vajQuery('#officeTelRegInput').hasClass('inputIsEmpty')) {
vajQuery('#officeTelRegInput').removeClass('inputIsEmpty');
}
if (vajQuery('#officeTelInput').val() === '') {
vajQuery('#officeTelInput').addClass('inputIsEmpty');
vajQuery('#officeTelInput').attr('placeholder', '請輸入電話號碼');
hasInputIsEmpty = 'Y';
} else if (vajQuery('#officeTelInput').hasClass('inputIsEmpty')) {
vajQuery('#officeTelInput').removeClass('inputIsEmpty');
}
// if (vajQuery('#officeTelExtInput').val() === '') {
// vajQuery('#officeTelExtInput').addClass('inputIsEmpty');
// vajQuery('#officeTelExtInput').attr('placeholder', '請輸入分機');
// hasInputIsEmpty = 'Y';
// } else if (vajQuery('#officeTelExtInput').hasClass('inputIsEmpty')) {
// vajQuery('#officeTelExtInput').removeClass('inputIsEmpty');
// }
}
if (vajQuery('#homeTelCheckbox').is(':checked')) {
if (vajQuery('#homeTelRegInput').val() === '') {
vajQuery('#homeTelRegInput').addClass('inputIsEmpty');
vajQuery('#homeTelRegInput').attr('placeholder', '請輸入區碼');
hasInputIsEmpty = 'Y';
} else if (vajQuery('#homeTelRegInput').hasClass('inputIsEmpty')) {
vajQuery('#homeTelRegInput').removeClass('inputIsEmpty');
}
if (vajQuery('#homeTelInput').val() === '') {
vajQuery('#homeTelInput').addClass('inputIsEmpty');
vajQuery('#homeTelInput').attr('placeholder', '請輸入電話號碼');
hasInputIsEmpty = 'Y';
} else if (vajQuery('#homeTelInput').hasClass('inputIsEmpty')) {
vajQuery('#homeTelInput').removeClass('inputIsEmpty');
}
// if (vajQuery('#homeTelExtInput').val() === '') {
// vajQuery('#homeTelExtInput').addClass('inputIsEmpty');
// vajQuery('#officeTelExtInput').attr('placeholder', '請輸入分機');
// hasInputIsEmpty = 'Y';
// } else if (vajQuery('#homeTelExtInput').hasClass('inputIsEmpty')) {
// vajQuery('#homeTelExtInput').removeClass('inputIsEmpty');
// }
}
if (vajQuery('#emailCheckbox').is(':checked') && vajQuery('#emailInput').val() === '') {
vajQuery('#emailInput').addClass('inputIsEmpty');
vajQuery('#emailInput').attr('placeholder', '請輸入Email');
hasInputIsEmpty = 'Y';
} else if (vajQuery('#emailInput').hasClass('inputIsEmpty')) {
vajQuery('#emailInput').removeClass('inputIsEmpty');
}
if (vajQuery('#emailCheckbox').is(':checked') && vajQuery('#changeCaptchaCode').val() === '') {
vajQuery('#changeCaptchaCode').addClass('inputIsEmpty');
vajQuery('#changeCaptchaCode').attr('placeholder', '請輸入驗證碼');
hasInputIsEmpty = 'Y';
} else if (vajQuery('#changeCaptchaCode').hasClass('inputIsEmpty')) {
vajQuery('#changeCaptchaCode').removeClass('inputIsEmpty');
}
if (vajQuery('#mobileOneCheckbox').is(':checked') && vajQuery('#changeMobileOneCaptchaCode').val() === '') {
vajQuery('#changeMobileOneCaptchaCode').addClass('inputIsEmpty');
vajQuery('#changeMobileOneCaptchaCode').attr('placeholder', '請輸入驗證碼');
hasInputIsEmpty = 'Y';
} else if (vajQuery('#changeMobileOneCaptchaCode').hasClass('inputIsEmpty')) {
vajQuery('#changeMobileOneCaptchaCode').removeClass('inputIsEmpty');
}
if (vajQuery('#mobileOneCheckbox').is(':checked') && vajQuery('#changeMobileOneSuccess').is(':hidden')) {
hasInputIsEmpty = 'Y';
vaCreateVerifyModal('phone');
} else if (vajQuery('#emailCheckbox').is(':checked') && vajQuery('#changeEmailSuccess').is(':hidden')) {
hasInputIsEmpty = 'Y';
vaCreateVerifyModal('email');
}
try {
$('.loaderMain').show();
if (hasInputIsEmpty === 'N') {
var elementText = vajQuery(e.target).data('text');
var changeItems = [];
if (vajQuery('#addressCheckbox').is(':checked')) {
changeItems.push('A');
}
if (vajQuery('#mobileOneCheckbox').is(':checked')) {
changeItems.push('MO');
}
if (vajQuery('#mobileTwoCheckbox').is(':checked')) {
changeItems.push('MT');
}
if (vajQuery('#officeTelCheckbox').is(':checked')) {
changeItems.push('O');
}
if (vajQuery('#homeTelCheckbox').is(':checked')) {
changeItems.push('H');
}
if (vajQuery('#emailCheckbox').is(':checked')) {
changeItems.push('E');
}
var data = {
//policyList: policyList
policyDataList: policyDataList, //改
changeItems: changeItems,
addressOpt: $("input[name='address']:checked").val(),
postCode: vajQuery('#postCodeInput').val(),
address: vajQuery('#addressInput').val(),
mobileOne: vajQuery('#mobileOneInput').val(),
mobileTwo: vajQuery('#mobileTwoInput').val(),
officeTelReg: vajQuery('#officeTelRegInput').val(),
officeTel: vajQuery('#officeTelInput').val(),
officeTelExt: vajQuery('#officeTelExtInput').val(),
homeTelReg: vajQuery('#homeTelRegInput').val(),
homeTel: vajQuery('#homeTelInput').val(),
homeTelExt: vajQuery('#homeTelExtInput').val(),
email: vajQuery('#emailInput').val(),
captcha: vajQuery('#changeCaptchaCode').val()
};
va_sendWebSocket('openForm', 'formback', elementText, 'checkPolicyBasicChangeData', data);
} else {
$('.loaderMain').hide();
}
} catch (e) {
console.log(e);
$('.loaderMain').hide();
}
});
vajQuery('#checkChangeMobileOneCaptchaCode').click(function (e) {
try {
$('.loaderMain').show();
var hasInputIsEmpty = 'N';
if (vajQuery('#mobileOneCheckbox').is(':checked') && vajQuery('#changeMobileOneCaptchaCode').val() === '') {
vajQuery('#changeMobileOneCaptchaCode').addClass('inputIsEmpty');
vajQuery('#changeMobileOneCaptchaCode').attr('placeholder', '請輸入驗證碼');
hasInputIsEmpty = 'Y';
} else if (vajQuery('#changeMobileOneCaptchaCode').hasClass('inputIsEmpty')) {
vajQuery('#changeMobileOneCaptchaCode').removeClass('inputIsEmpty');
}
if (hasInputIsEmpty === 'N') {
var elementText = vajQuery(e.target).data('text');
var data = {
OTPCode: vajQuery('#changeMobileOneCaptchaCode').val(),
policyDataList: policyDataList,
phone: vajQuery('#mobileOneInput').val(),
type: 'phone'
};
va_sendWebSocket('openForm', 'formback', elementText, 'checkOTP', data);
} else {
$('.loaderMain').hide();
}
} catch (e) {
console.log(e);
$('.loaderMain').hide();
}
});
vajQuery('#checkChangeEmailCaptchaCode').click(function (e) {
try {
$('.loaderMain').show();
var hasInputIsEmpty = 'N';
if (vajQuery('#emailCheckbox').is(':checked') && vajQuery('#changeCaptchaCode').val() === '') {
vajQuery('#changeCaptchaCode').addClass('inputIsEmpty');
vajQuery('#changeCaptchaCode').attr('placeholder', '請輸入驗證碼');
hasInputIsEmpty = 'Y';
} else if (vajQuery('#changeCaptchaCode').hasClass('inputIsEmpty')) {
vajQuery('#changeCaptchaCode').removeClass('inputIsEmpty');
}
if (hasInputIsEmpty === 'N') {
var elementText = vajQuery(e.target).data('text');
var data = {
OTPCode: vajQuery('#changeCaptchaCode').val(),
policyDataList: policyDataList,
email: vajQuery('#emailInput').val(),
type: 'email'
};
va_sendWebSocket('openForm', 'formback', elementText, 'checkOTP', data);
} else {
$('.loaderMain').hide();
}
} catch (e) {
console.log(e);
$('.loaderMain').hide();
}
});
}
}
function vaCreateCheckBasicErrorMessageModal(data) {
if (vajQuery('#checkBasicError').length !== 0) {
chatbotModal('checkBasicError', 'hide');
vajQuery('#checkBasicError').remove();
vaCreateCheckBasicErrorMessageModal(data);
} else {
var modalWindow = vajQuery('
訊息通知
';
for (var index in data.errorMsg) {
if (data.errorMsg[index] !== '') {
body += '
• ';
body += data.errorMsg[index];
body += '
';
}
}
if (data.showtext === 'Y' && data.changeItems !== null) {
body += '
• 若您仍要變更至此' + data.changeItems + ',請本人攜帶身分證至全省分公司/服務中心櫃台辦理。
';
}
var modalBody = vajQuery(body);
var modalFooter = vajQuery('');
//webBotSettings
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
vajQuery('#checkBasicErrorClose').click(function () {
chatbotModal('checkBasicError', 'hide');
if (data.resetTime === 'Y') {
stopPsrnTimer(myPsrnOTPTimer);
}else if (data.resetPhoneTime === 'Y') {
stopMobileOnePsrnOTPTimer(myMobileOnePsrnOTPTimer);
}
});
chatbotModal('checkBasicError', 'show');
}
$('.loaderMain').hide();
}
function vaCreateOTPMessageModal(data) {
if (vajQuery('#OTPMessageModal').length !== 0) {
chatbotModal('OTPMessageModal', 'hide');
vajQuery('#OTPMessageModal').remove();
vaCreateOTPMessageModal(data);
} else {
let sentOTPDate = new Date();
if (data.sentOTPDate) {
sentOTPDate = data.sentOTPDate;
}
var modalWindow = vajQuery('
');
var modalDialog = vajQuery('
');
var modalContent = vajQuery('
');
//寄送成功
if (data.hasError === 'N') {
var modalBody = vajQuery(
`
`
);
if (data.returnCode === 'registerOTP') {
stopTimer(myRegisterOTPTimer);
myRegisterOTPTimer = setInterval(function () {
registerOTPTimer(addMinutes(new Date(sentOTPDate), 5), myRegisterOTPTimer);
}, 1000);
}
if (data.returnCode === 'changeOTP') {
if(data.step === 'confirm'){
if(data.sendTheOTPType === 'E'){
modalBody = vajQuery(
`
`
);
} else if(data.sendTheOTPType === 'P'){
modalBody = vajQuery(
`
`
);
}
stopChangeConfirmPsrnTimer(myChangeConfirmOTPTimer);
myChangeConfirmOTPTimer = setInterval(function () {
changePsrnOTPTimer(addMinutes(new Date(sentOTPDate), 5), myChangeConfirmOTPTimer);
}, 1000);
} else if(data.sendTheOTPType === 'E'){
modalBody = vajQuery(
`
`
);
stopPsrnTimer(myPsrnOTPTimer);
myPsrnOTPTimer = setInterval(function () {
psrnOTPTimer(addMinutes(new Date(sentOTPDate), 5), myPsrnOTPTimer);
}, 1000);
} else if(data.sendTheOTPType === 'P'){
modalBody = vajQuery(
`
`
);
stopMobileOnePsrnOTPTimer(myMobileOnePsrnOTPTimer);
myMobileOnePsrnOTPTimer = setInterval(function () {
mobileOnePsrnOTPTimer(addMinutes(new Date(sentOTPDate), 5), myMobileOnePsrnOTPTimer);
}, 1000);
}
}
if (data.returnCode === 'openNetworkOTP' || data.returnCode === 'openElectronicOTP') {
if(data.sendTheOTPType === 'E'){
modalBody = vajQuery(
`
`
);
} else if(data.sendTheOTPType === 'P'){
modalBody = vajQuery(
`
`
);
}
stopOTPTimer(myOTPTimer);
myOTPTimer = setInterval(function () {
OTPTimer(addMinutes(new Date(sentOTPDate), 5), myOTPTimer);
}, 1000);
}
if (data.returnCode === 'loanOTP') {
if(data.sendTheOTPType === 'E'){
modalBody = vajQuery(
`
`
);
} else if(data.sendTheOTPType === 'P'){
modalBody = vajQuery(
`
`
);
}
stopLoanPsrnTimer(myLoanOTPTimer);
myLoanOTPTimer = setInterval(function () {
loanPsrnOTPTimer(addMinutes(new Date(sentOTPDate), 5), myLoanOTPTimer);
}, 1000);
}
var modalFooter = vajQuery('');
} else if (data && data.msg === '電子郵件信箱格式不符合規格') {
var modalBody = vajQuery(
`
`
);
var modalFooter = vajQuery('');
} else if (data && data.msg === '手機格式不符合規格') {
var modalBody = vajQuery(
`
`
);
var modalFooter = vajQuery('');
} else {
//寄送失敗
var modalBody = vajQuery(
`
`
);
var modalFooter = vajQuery('');
}
//webBotSettings
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
vajQuery('#sendBotClose').click(function () {
chatbotModal('OTPMessageModal', 'hide');
});
chatbotModal('OTPMessageModal', 'show');
}
$('.loaderMain').hide();
}
function vaChangeFinalConfirmModal(data) {
let policyDataList = data.oaReturn.policyDataList;
let changeData = data.oaReturn.changeData;
let emailList = [];
let phoneList = [];
for(var index in policyDataList){
if(policyDataList[index].holderEmail && emailList.indexOf(policyDataList[index].holderEmail) == -1){
emailList.push(policyDataList[index].holderEmail);
}
if(policyDataList[index].holderMobile && phoneList.indexOf(policyDataList[index].holderMobile) == -1){
phoneList.push(policyDataList[index].holderMobile);
}
}
if (vajQuery('#basicChangeFormModal').length !== 0) {
chatbotModal('basicChangeFormModal', 'hide');
}
if (vajQuery('#changeFinalConfirmModal').length !== 0) {
chatbotModal('changeFinalConfirmModal', 'hide');
vajQuery('#changeFinalConfirmModal').remove();
vaChangeFinalConfirmModal(data);
} else {
let changeFinalConfirmModal = '';
changeFinalConfirmModal += '
';
vajQuery('#ibmchat').append(changeFinalConfirmModal);
$('.loaderMain').hide();
$(function () {
stopChangeConfirmPsrnTimer(myChangeConfirmOTPTimer);
});
vajQuery('#changeFinalModalClose').click(function () {
var modalWindow = vajQuery('
');
var modalDialog = vajQuery('
');
var modalContent = vajQuery('
');
var modalBody = vajQuery('
提醒
保單變更【聯絡資料】尚未完成,請問是否要離開呢?
');
var modalFooter = vajQuery('');
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
chatbotModal('finalNoticeModal', 'show');
vajQuery('#changeOKSubmit').click(function () {
chatbotModal('finalNoticeModal', 'hide');
});
vajQuery('#changeCancelSubmit').click(function () {
chatbotModal('finalNoticeModal', 'hide');
va_sendWebSocket('cancel', 'postback', '', 'F12_保單基本資料變更_取消');
chatbotModal('changeFinalConfirmModal', 'hide');
});
});
vajQuery('#checkChangeCaptchaCode').click(function (e) {
try {
$('.loaderMain').show();
var hasInputIsEmpty = 'N';
if (vajQuery('#changeConfirmCaptchaCode').val() === '') {
vajQuery('#changeConfirmCaptchaCode').addClass('inputIsEmpty');
vajQuery('#changeConfirmCaptchaCode').attr('placeholder', '請輸入驗證碼');
hasInputIsEmpty = 'Y';
} else if (vajQuery('#changeConfirmCaptchaCode').hasClass('inputIsEmpty')) {
vajQuery('#changeConfirmCaptchaCode').removeClass('inputIsEmpty');
}
if (hasInputIsEmpty === 'N') {
var data = null;
var elementText = vajQuery(e.target).data('text');
if(emailList.length > 0){
data = {
OTPCode: vajQuery('#changeConfirmCaptchaCode').val(),
email: vajQuery('#changeEmailInput').val(),
type: 'email',
step: 'confirm'
};
} else {
data = {
OTPCode: vajQuery('#changeConfirmCaptchaCode').val(),
phone: vajQuery('#changePhoneInput').val(),
type: 'phone',
step: 'confirm'
};
}
va_sendWebSocket('openForm', 'formback', elementText, 'checkOTP', data);
} else {
$('.loaderMain').hide();
}
} catch (e) {
console.log(e);
$('.loaderMain').hide();
}
});
vajQuery('#sendChangeCaptchaByCSIS').click(function (e) {
if (vajQuery('#changeEmailInput').val() === '請選擇電子郵件') {
vaCreateOTPErrorMessageModal(vajQuery('#changeEmailInput').val());
} else if(vajQuery('#changePhoneInput').val() === '請選擇手機號碼'){
vaCreateOTPErrorMessageModal(vajQuery('#changePhoneInput').val());
}
else {
vajQuery('#changeOtpTimer').prop('hidden', false);
vajQuery('#changePsrnOTPTimer').prop('hidden', false);
var elementText = vajQuery(e.target).data('text');
var endtime = addMinutes(new Date(), 5);
let year = endtime.getFullYear();
let month = ('0' + (endtime.getMonth() + 1)).slice(-2);
let day = ('0' + endtime.getDate()).slice(-2);
let hour = endtime.getHours();
let minute = endtime.getMinutes();
var endTime;
if (minute < 10) {
endTime = year + '/' + month + '/' + day + ' ' + hour + ':0' + minute;
} else{
endTime = year + '/' + month + '/' + day + ' ' + hour + ':' + minute;
}
let data = null;
if(emailList.length > 0){
data = {
email: vajQuery('#changeEmailInput').val(),
sendTheOTPType: 'E',
returnCode: 'changeOTP',
endTime: endTime,
step: 'confirm'
};
} else {
data = {
phone: vajQuery('#changePhoneInput').val(),
sendTheOTPType: 'P',
returnCode: 'changeOTP',
endTime: endTime,
step: 'confirm',
policyNo: policyDataList[0].policyCode
};
}
va_sendWebSocket('openForm', 'formback', elementText, 'sendCaptchaByCSIS', data);
vajQuery('#changeConfirmCaptchaCode').val('');
}
});
vajQuery('#finalConfirmSubmit').bind('click', function (e) {
var hasInputIsEmpty = 'N';
if (vajQuery('#changeSuccess').is(':hidden')) {
if(emailList.length > 0){
hasInputIsEmpty = 'Y';
vaCreateVerifyModal('email');
} else{
hasInputIsEmpty = 'Y';
vaCreateVerifyModal('phone');
}
}
try {
$('.loaderMain').show();
if (hasInputIsEmpty === 'N') {
va_sendWebSocket('openForm', 'formback', vajQuery(e.target).data('text'), 'uploadChangeData', data);
chatbotModal('changeFinalConfirmModal', 'hide');
} else{
$('.loaderMain').hide();
}
} catch (e) {
console.log(e);
$('.loaderMain').hide();
}
});
vajQuery('#previous').click(function () {
$('.loaderMain').show();
chatbotModal('changeFinalConfirmModal', 'hide');
vaCreateBasicChangeFormModal(data);
});
chatbotModal('changeFinalConfirmModal', 'show');
}
}
function vaCreateHitModal(data) {
let showitems = '';
if (data.hitItems.length > 1) {
for (let i = 0; i < data.hitItems.length; i++) {
showitems += data.hitItems[i];
if (i !== data.hitItems.length - 1) {
showitems += '、';
}
}
} else {
showitems = data.hitItems;
}
if (vajQuery('#hitNoticeModal').length !== 0) {
chatbotModal('hitNoticeModal', 'hide');
vajQuery('#hitNoticeModal').remove();
vaCreateHitModal(data);
} else {
$(function () {
var modalWindow = vajQuery('
');
var modalDialog = vajQuery('
');
var modalContent = vajQuery('
');
var modalBody = vajQuery('
注意
請確認下述聯絡資料是否正確
' + '
【' + showitems + '】
');
var modalFooter = vajQuery(
''
);
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
chatbotModal('hitNoticeModal', 'show');
$('.loaderMain').hide();
vajQuery('#changeNow').click(function () {
chatbotModal('hitNoticeModal', 'hide');
});
vajQuery('#notChange').click(function (e) {
try {
$('.loaderMain').show();
var elementText = vajQuery(e.target).data('text');
data.data.notChange = 'Y';
va_sendWebSocket('openForm', 'formback', elementText, 'checkPolicyBasicChangeData', data.data);
chatbotModal('hitNoticeModal', 'hide');
} catch (e) {
console.log(e);
$('.loaderMain').hide();
}
});
});
}
}
function vaCreateRatingModal(requestID) {
if (vajQuery('#ratingModal').length !== 0) {
chatbotModal('ratingModal', 'hide');
vajQuery('#ratingModal').remove();
vaCreateRatingModal(requestID);
} else {
let ratingModal = '';
ratingModal += '
';
vajQuery('#ibmchat').append(ratingModal);
chatbotModal('ratingModal', 'show');
$('.loaderMain').hide();
vajQuery('.rate').click(function (e) {
let rating = parseInt(e.target.id.split('rate')[1], 10);
for (let i = 1; i <= 5; i++) {
if (i <= rating && i === 5) {
vajQuery('#rate' + i).addClass('satisfy_star_y_5');
vajQuery('#rate' + i).removeClass('satisfy_star_w');
} else if (i <= rating) {
vajQuery('#rate' + i).addClass('satisfy_star_y');
vajQuery('#rate' + i).removeClass('satisfy_star_w');
} else {
vajQuery('#rate' + i).addClass('satisfy_star_w');
vajQuery('#rate' + i).removeClass('satisfy_star_y');
vajQuery('#rate' + i).removeClass('satisfy_star_y_5');
}
}
});
vajQuery('#ratingSubmit').click(function (e) {
let score = 0;
if ($('#ratingModal .satisfy_star_y_5').length === 1) {
score = 5;
} else {
score = $('#ratingModal .satisfy_star_y').length;
}
if (score < 3) {
let data = {
requestID: requestID,
score: score
};
chatbotModal('ratingModal', 'hide');
vaCreateRatingFeedbackModal(data);
} else {
//save to db
var obj = {
requestID: requestID,
isLike: score,
comment: '',
dislikeReason: ''
};
vajQuery
.ajax({
url: 'https://va.transglobe.com.tw/api/saveQASurvey',
type: 'POST',
cache: false,
data: obj,
datatype: 'json'
})
.done(function (res) {
console.log(res);
vaCreateRatingCompletedModal(requestID, score);
})
.fail(function (res) {
console.log(res);
})
.always(function (res) {
chatbotModal('ratingModal', 'hide');
});
}
});
}
}
function vaCreateRatingFeedbackModal(data) {
if (vajQuery('#ratingFeedbackModal').length !== 0) {
chatbotModal('ratingFeedbackModal', 'hide');
vajQuery('#ratingFeedbackModal').remove();
vaCreateRatingFeedbackModal(data);
} else {
let ratingFeedbackModal = '';
ratingFeedbackModal += '
';
vajQuery('#ibmchat').append(ratingFeedbackModal);
chatbotModal('ratingFeedbackModal', 'show');
$('.loaderMain').hide();
vajQuery('#feedbackSubmit').click(function () {
let f1 = $('#f1').is(':checked') ? '1' : '0';
let f2 = $('#f2').is(':checked') ? '1' : '0';
let f3 = $('#f3').is(':checked') ? '1' : '0';
let f4 = $('#f4').is(':checked') ? '1' : '0';
data.dislikeReason = f1 + f2 + f3 + f4;
if (f4 === '1') {
chatbotModal('ratingFeedbackModal', 'hide');
vaCreateRatingFeedback2Modal(data);
} else {
vajQuery
.ajax({
url: 'https://va.transglobe.com.tw/api/saveQASurvey',
type: 'POST',
cache: false,
data: data,
datatype: 'json'
})
.done(function (res) {
console.log(res);
vaCreateRatingCompletedModal(data.requestID, data.score);
})
.fail(function (res) {
console.log(res);
})
.always(function (res) {
chatbotModal('ratingFeedbackModal', 'hide');
});
}
});
}
}
function vaCreateRatingFeedback2Modal(data) {
if (vajQuery('#ratingFeedback2Modal').length !== 0) {
chatbotModal('ratingFeedback2Modal', 'hide');
vajQuery('#ratingFeedback2Modal').remove();
vaCreateRatingFeedback2Modal(data);
} else {
let ratingFeedbackModal = '';
ratingFeedbackModal += '
';
vajQuery('#ibmchat').append(ratingFeedbackModal);
chatbotModal('ratingFeedback2Modal', 'show');
$('.loaderMain').hide();
vajQuery('#feedback2Submit').click(function () {
//send to db
var obj = {
requestID: data.requestID,
isLike: data.score,
comment: $('#feedbackText').val(),
dislikeReason: data.dislikeReason
};
vajQuery
.ajax({
url: 'https://va.transglobe.com.tw/api/saveQASurvey',
type: 'POST',
cache: false,
data: obj,
datatype: 'json'
})
.done(function (res) {
console.log(res);
chatbotModal('ratingFeedback2Modal', 'hide');
vaCreateRatingCompletedModal(data.requestID, data.score);
})
.fail(function (res) {
console.log(res);
})
.always(function (res) {
chatbotModal('ratingModal', 'hide');
});
});
}
}
function vaCreateRatingCompletedModal(requestID, score) {
if (vajQuery('#ratingCompletedModal').length !== 0) {
chatbotModal('ratingCompletedModal', 'hide');
vajQuery('#ratingCompletedModal').remove();
vaCreateRatingCompletedModal(requestID, score);
} else {
vajQuery('.cbIntent')
.find('div[data-requestid="' + requestID + '"]')
.css('background-image', ' url(https://va.transglobe.com.tw/webChat/images/star_' + score + '.png');
vajQuery('.cbIntent')
.find('div[data-requestid="' + requestID + '"]')
.off('click');
let ratingModal = '';
ratingModal += '
';
vajQuery('#ibmchat').append(ratingModal);
chatbotModal('ratingCompletedModal', 'show');
$('.loaderMain').hide();
setTimeout(function () {
chatbotModal('ratingCompletedModal', 'hide');
}, 3000);
}
}
function vaConnectTextService() {
if (vajQuery('#connectCustomerServiceModal').length) {
chatbotModal('connectCustomerServiceModal', 'hide');
vajQuery('#connectCustomerServiceModal').remove();
vaConnectTextService();
} else {
var modalWindow = vajQuery('
');
var modalDialog = vajQuery('
');
var modalContent = vajQuery('
');
var modalBody = '';
modalBody += '
';
modalBody += '
與真人文字客服連線中
';
modalBody += '
';
modalBody += '
';
modalBody += '
';
modalBody += '
';
modalBody += '
';
modalBody += '
';
modalBody += '
';
modalBody += '
';
modalContent.append(modalBody);
// modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
chatbotModal('connectCustomerServiceModal', 'show');
}
}
function vaEndTextServiceModal() {
if (vajQuery('#endTextServiceModal').length) {
chatbotModal('endTextServiceModal', 'hide');
vajQuery('#endTextServiceModal').remove();
vaEndTextServiceModal();
} else {
var modalWindow = vajQuery('
');
var modalDialog = vajQuery('
');
var modalContent = vajQuery('
');
var modalBody = vajQuery('
你即將離開文字客服服務,請確認是否要結束與文字客服對話。
');
var footerContent = '';
var modalFooter = vajQuery(footerContent);
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
chatbotModal('endTextServiceModal', 'show');
//結束文字客服
vajQuery('#endTextServiceBtn').click(function () {
va_sendWebSocket('stopConnect', 'text', 'requestDisconnect', 99);
chatbotModal('endTextServiceModal', 'hide');
// eslint-disable-next-line no-undef
clearStopTextServiceMsg();
});
}
}
function vaIdleEndTextServiceModal() {
if (vajQuery('#idleEndTextServiceModal').length) {
chatbotModal('idleEndTextServiceModal', 'hide');
setTimeout(function () {
vajQuery('#idleEndTextServiceModal').remove();
vaIdleEndTextServiceModal();
}, 500);
} else {
var modalWindow = vajQuery('
');
var modalDialog = vajQuery('
');
var modalContent = vajQuery('
');
var modalBody = vajQuery('
');
var footerContent = '';
var modalFooter = vajQuery(footerContent);
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
chatbotModal('idleEndTextServiceModal', 'show');
//結束文字客服
vajQuery('#endTextServiceBtn').click(function () {
chatbotModal('idleEndTextServiceModal', 'hide');
va_sendWebSocket('alive', 'text', 'replyAlive', 'Y');
});
vajQuery('#endTextServiceCancelBtn').click(function () {
chatbotModal('idleEndTextServiceModal', 'hide');
va_sendWebSocket('alive', 'text', 'replyAlive', 'N');
});
}
}
function vaCreateTextServiceRatingModal(data) {
if (vajQuery('#textServiceRatingModal').length !== 0) {
chatbotModal('textServiceRatingModal', 'hide');
vajQuery('#textServiceRatingModal').remove();
vaCreateTextServiceRatingModal(data);
} else {
let components = [];
data.extraInfo.eventData.suveryList.forEach(function (ele) {
let component = '';
if (ele.answerType === 'S') {
component += '
' + ele.question + '
';
component += '
';
component += '
';
component += '
';
component += '
';
component += '
';
component += '
';
component += '
';
// component += '
(非常同意請給5顆星,非常不同意請給1顆星)
';
} else if (ele.answerType === 'T') {
component += '
' + ele.question + '
';
component += '
';
component += ' ';
component += '
';
}
components.push(component);
});
let ratingModal = '';
ratingModal += '
';
ratingModal += '
';
ratingModal += '
';
ratingModal += ' ';
ratingModal += '
';
ratingModal += components.join('
');
ratingModal += ' ';
ratingModal += ' ';
ratingModal += '
';
ratingModal += '
';
ratingModal += '
';
vajQuery('#ibmchat').append(ratingModal);
chatbotModal('textServiceRatingModal', 'show');
$('.loaderMain').hide();
vajQuery('.rate').click(function (e) {
let item = parseInt(e.target.id.split('rate')[1].split('_')[0], 10);
let rating = parseInt(e.target.id.split('_')[1], 10);
for (let i = 1; i <= 5; i++) {
if (i <= rating && i === 5) {
vajQuery('#rate' + item + '_' + i).addClass('satisfy_star_y_5');
vajQuery('#rate' + item + '_' + i).removeClass('satisfy_star_w');
} else if (i <= rating) {
vajQuery('#rate' + item + '_' + i).addClass('satisfy_star_y');
vajQuery('#rate' + item + '_' + i).removeClass('satisfy_star_w');
} else {
vajQuery('#rate' + item + '_' + i).addClass('satisfy_star_w');
vajQuery('#rate' + item + '_' + i).removeClass('satisfy_star_y');
vajQuery('#rate' + item + '_' + i).removeClass('satisfy_star_y_5');
}
}
});
vajQuery('#textServiceRatingSubmit').click(function (e) {
let rtnData = {
suveryList: []
};
data.extraInfo.eventData.suveryList.forEach(function (ele) {
let ans = {
item: ele.item
};
if (ele.answerType === 'T') {
ans.content = vajQuery('#feedbackText_' + ele.item).val();
} else if (ele.answerType === 'S') {
if (vajQuery('#textServiceRatingModal div[id^=rate' + ele.item + '][class*=satisfy_star_y_5]').length !== 0) {
ans.score = 5;
} else {
ans.score = vajQuery('#textServiceRatingModal div[id^=rate' + ele.item + '][class*=satisfy_star_y]').length;
}
}
rtnData.suveryList.push(ans);
});
va_sendWebSocket('sendSatisfaction', 'text', 'sendSatisfaction', '', rtnData);
chatbotModal('textServiceRatingModal', 'hide');
vaCreateTextServiceRatingCompletedModal();
});
}
}
function vaCreateTextServiceRatingCompletedModal() {
if (vajQuery('#textServiceRatingCompletedModal').length !== 0) {
chatbotModal('textServiceRatingCompletedModal', 'hide');
vajQuery('#textServiceRatingCompletedModal').remove();
vaCreateTextServiceRatingCompletedModal();
} else {
let ratingModal = '';
ratingModal += '
';
ratingModal += '
';
ratingModal += '
';
ratingModal += '
';
ratingModal += '
';
ratingModal += '
謝謝你的回饋,我會持續學習精進! ';
ratingModal += ' ';
ratingModal += '
';
ratingModal += '
';
ratingModal += '
';
ratingModal += '
';
ratingModal += '
';
ratingModal += '
';
ratingModal += '
';
vajQuery('#ibmchat').append(ratingModal);
chatbotModal('textServiceRatingCompletedModal', 'show');
$('.loaderMain').hide();
setTimeout(function () {
chatbotModal('textServiceRatingCompletedModal', 'hide');
}, 3000);
}
}
//unused
function vaCreateLoginTipsModal(tip) {
if (vajQuery('#loginTipsModal').length) {
chatbotModal('loginTipsModal', 'hide');
vajQuery('#loginTipsModal').remove();
vaCreateLoginTipsModal(tip);
} else {
var modalWindow = vajQuery('
');
var modalDialog = vajQuery('
');
var modalHeader = vajQuery('');
var modalClose = vajQuery('
× ');
var modalTitle;
var modalContent = vajQuery('
');
var bodyContent = '
';
if (tip === 'useracc') {
modalTitle = vajQuery('
「帳號」說明: ');
bodyContent += '
帳號為您的身分證字號 ';
bodyContent += '倘為外籍人士,請填寫投保時於要保書上所留之號碼,例如:護照號碼/居留證號碼/當地的身分證字號…等。 ';
} else if (tip === 'username') {
modalTitle = vajQuery('
「使用者名稱」設定規則: ');
bodyContent += '
長度最少6個字元,最多20個字元。 ';
bodyContent += '需同時含有英文字母及數字。 ';
bodyContent += '不可含有空白或全形字元。 ';
bodyContent += '不可含有:單引號(\')、雙引號(")、斜線(/)、反斜線(\\) 。 ';
bodyContent += '不可與「帳號」或「密碼」相同。 ';
} else if (tip === 'usersosi') {
modalTitle = vajQuery('
「密碼」設定規則: ');
bodyContent += '
長度最少8個字元,最多12個字元。 ';
bodyContent += '需同時含有英文字母及數字。 ';
bodyContent += '不可與目前的密碼重複。 ';
bodyContent += '不可含有空白或全形字元。 ';
bodyContent += '不可含有:單引號(\')、雙引號(")、斜線(/)、反斜線(\\)。 ';
bodyContent += '不可與「帳號」或「使用者名稱」相同。 ';
}
bodyContent += '
';
var modalBody = vajQuery(bodyContent);
modalHeader.append(modalClose);
modalHeader.append(modalTitle);
modalContent.append(modalHeader);
modalContent.append(modalBody);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
vajQuery('#loginTipsClose').bind('click', function (e) {
chatbotModal('loginTipsModal', 'hide');
});
chatbotModal('loginTipsModal', 'show');
}
$('.loaderMain').hide();
}
// eslint-disable-next-line no-unused-vars
function createTransfer() {
var content = '';
content += '
';
content += '
';
content += '
';
content += '
';
vajQuery('.chatbotFooter > input').hide();
vajQuery('.chatbotFooter').append(content);
// va_changeInput(inputMask);
$(function () {
initChatbotSelect();
resizeWindow();
$(window).resize(resizeWindow);
checkFormInput();
});
}
// resizeWindow
function resizeWindow() {
resetChatbotSelectHight();
}
// 選單list的高度,因為都是浮在視窗上面,所以另外計算高度
function resetChatbotSelectHight() {
$('.chatbot .select_wrap').each(function () {
var select_wrap = $(this);
var chatbot_height = $('.chatbot .chatbot-panel:not(.hide)').height();
var select_pos = select_wrap.position();
var select_height = select_wrap.height();
var select_list_height = chatbot_height - select_pos.top - select_height;
select_list_height = select_list_height > 150 ? select_list_height : 150;
select_wrap.find('.select_list_wrap').height(select_list_height);
});
}
// 選單的js
function initChatbotSelect() {
// 開闔選單
$(document).on('click', '.chatbot .select_wrap .js-toggle-select-list', function (e) {
e.stopPropagation();
e.preventDefault();
$(this).parents('.select_wrap').find('.select_list_wrap').toggleClass('hide');
});
// 選擇
$(document).on('click', '.chatbot .select_wrap .select_list li a', function (e) {
e.stopPropagation();
e.preventDefault();
$(this).parents('.select_wrap').find('input').val($(this).text()).keyup();
$(this).addClass('selected').parents('.select_list_wrap').addClass('hide');
});
}
// 檢查btn_submit是否要可以按
function checkFormInput() {
$(document).on('focusout, keyup', '.form input', function (e) {
var $form = $(this).parents('.form');
var empty_input = $form.find('input').filter(function () {
return !this.value;
}).length;
if (empty_input <= 0) {
$form.find('.js_confirm_form').removeClass('disabled');
} else {
$form.find('.js_confirm_form').addClass('disabled');
}
});
}
// eslint-disable-next-line no-unused-vars
function reloadCaptcha() {
var captchaSvg;
vajQuery
.ajax({
url: 'https://va.transglobe.com.tw/api/genCaptcha',
type: 'POST',
cache: false,
data: JSON.stringify({
uuid: sessionStorage.getItem('uid')
}),
contentType: 'application/json; charset=utf-8',
dataType: 'html',
async: false
})
.done(function (res) {
captchaSvg = res;
})
.fail(function (res) {
console.log('fail:' + JSON.stringify(res));
});
vajQuery('.captchaSvg').html(captchaSvg);
}
/**整體滿意度調查問卷
* @param uid sessionid
* @param pageNum 整體滿意度調查頁數
* @param data {} 整體滿意度、NPS、不建議原因、其它建議
*/
function vaWholeSatisfactionSurvey(uid, pageNum, data) {
if (pageNum === 1) {
sessionStorage.setItem('wholeSatisfactionSurvey', 'show');
}
if (vajQuery('#surveyModal').length !== 0) {
chatbotModal('surveyModal', 'hide');
vajQuery('#surveyModal').remove();
vajQuery('.modal-backdrop').remove(); //modal-dismiss:modal bootstrap
vaWholeSatisfactionSurvey(uid, pageNum, data);
} else {
//Page 3 出現之門檻值 滿意度<=60 || NPS<=6
let thres_satisfaction = 60;
let thres_nps = 6;
//Page 3 不推薦原因清單;
const reasonsList = [
'不考慮推薦—無推薦習慣',
'不考慮推薦—無適合推薦人選',
'無法找到理賠相關資訊',
'無法找到商品相關資訊',
'無法找到繳納保費/還款類相關資訊',
'無法找到保單變更/借款類相關資訊',
'系統操作流程不夠便利',
'網路連線緩慢或不穩定'
];
//Page 3 不推薦原因清單複選上限;
const reasonsCheckedMax = 3;
var next = true;
if (data) {
if (pageNum === 2 && data.satisfaction && data.satisfaction > thres_satisfaction) {
next = false;
} else if (pageNum === 3) {
next = false;
}
}
var header = vaSurveyHeader(pageNum, data.satisfaction);
if (pageNum === 3) {
var body = vaSurveyBody(pageNum, data.satisfaction, reasonsList);
} else {
var body = vaSurveyBody(pageNum, data.satisfaction, null);
}
var footer = vaSurveyFooter(pageNum, next);
//產出第一頁時,先發CreateAPI
if (pageNum === 1) {
vajQuery
.ajax({
url: 'https://va.transglobe.com.tw/api/questionnaire/' + uid + '/create',
type: 'POST',
cache: false,
data: JSON.stringify(data),
contentType: 'application/json; charset=utf-8',
async: false
})
.done(function (res) {
console.log('create done:' + JSON.stringify(res));
})
.fail(function (res) {
//status 400
console.log('create fail:' + JSON.stringify(res.status));
});
}
let surveyModal = '';
surveyModal += '
';
vajQuery('#ibmchat').append(surveyModal);
chatbotModal('surveyModal', 'show');
if (pageNum === 99) {
var feedBackTimeoutID = setTimeout(function () {
vajQuery('.surveyModalDialog #surveyClose').trigger('click');
}, 5000);
}
$('.loaderMain').hide();
vajQuery('.surveyModalDialog #surveyClose').bind('click', () => {
surveyClose(feedBackTimeoutID);
});
vajQuery('.surveyModalDialog #surveyRefuse').bind('click', () => {
vajQuery('.surveyModalDialog #surveyClose').trigger('click');
});
vajQuery('.surveyModalDialog #surveyFinish').bind('click', () => {
vajQuery('.surveyModalDialog #surveyClose').trigger('click');
});
vajQuery('.surveyModalDialog #surveySubmit').bind('click', function (e) {
var matchRequired = true;
//必填檢查
var hdrequired = vajQuery('.surveyModalDialog .survey-question-itm-hd p.required');
for (var i = 0; i < hdrequired.length; i++) {
var inputSelector = vajQuery(hdrequired[i]).parent().next().find('input');
var textAreaSelector = vajQuery(hdrequired[i]).parent().next().find('textarea');
if (inputSelector.length > 0) {
if (inputSelector.is(':checked') === false) {
matchRequired = false;
}
} else if (textAreaSelector.length > 0) {
if (textAreaSelector.val().length === 0) {
matchRequired = false;
}
}
}
const reasonsCheckedMax = 3;
if (matchRequired) {
var satisfaction = vajQuery('input[type=radio][name=WholeSatisfaction]:checked').val();
if (satisfaction) {
data['satisfaction'] = satisfaction;
}
var recommendation = vajQuery('input[type=radio][name=NPS]:checked').val();
if (recommendation) {
data['recommendation'] = recommendation;
}
var reasons = '';
var reasonsCheckedCount = 0;
$('input[name=reasonsmchoice]').each(function () {
reasons += ',';
if ($(this).prop('checked') === true) {
reasonsCheckedCount += 1;
var reason = $(this).next().html();
if (reasonsList.includes(reason)) {
reasons += reason;
}
}
});
reasons = reasons.substr(1);
if (reasons) {
data['reasons'] = reasons;
}
var otherFeedback = $('#otherFeedback').val();
if (otherFeedback) {
data['otherFeedback'] = otherFeedback;
}
if (reasonsCheckedCount <= reasonsCheckedMax) {
vajQuery
.ajax({
url: 'https://va.transglobe.com.tw/api/questionnaire/' + uid + '/update',
type: 'POST',
cache: false,
data: JSON.stringify(data),
contentType: 'application/json; charset=utf-8',
async: false
})
.done(function (res) {
console.log('done:' + JSON.stringify(res));
})
.fail(function (res) {
//status 400
console.log('fail:' + JSON.stringify(res.status));
// pageNum = 99;
});
if (pageNum === 1 || (pageNum === 2 && vajQuery(e.target).html() === '下一頁')) {
pageNum = pageNum + 1;
} else {
// GoTo feedback Page
pageNum = 99;
}
vaWholeSatisfactionSurvey(uid, pageNum, data);
} else {
vaCreateSurveyCheckErrModal('U3');
}
} else {
vaCreateSurveyCheckErrModal('L1');
}
});
vajQuery('input[type=radio][name=NPS]').bind('change', function () {
var nps = vajQuery(this).val();
var surveySubmitBtn = vajQuery('.surveyModalDialog #surveySubmit');
if (next || nps <= thres_nps) {
surveySubmitBtn.html('下一頁');
} else {
surveySubmitBtn.html('送出');
}
});
}
}
function surveyClose(feedBackTimeoutID) {
sessionStorage.removeItem('wholeSatisfactionSurvey');
chatbotModal('surveyModal', 'hide');
vajQuery('.chatbotModal #surveyModal').remove();
vajQuery('.modal-backdrop').remove(); //modal-dismiss:modal bootstrap
refreshChatEvent();
vajQuery('body').removeClass('no-scroll');
clearTimeout(feedBackTimeoutID);
}
/**
* @param pageNum 整體滿意度調查頁數
* @param satisfaction 整體滿意度調查(20,40,60,80,100)
* @return string modal-header內容
*/
function vaSurveyHeader(pageNum, satisfaction) {
var header = '
';
if (pageNum === 99) {
switch (satisfaction) {
case '100':
header += `
謝謝你對伊將的服務 非常滿意
`;
break;
case '80':
header += `
謝謝你對伊將的服務 滿意
`;
break;
case '60':
header += `
謝謝你給伊將的回饋
`;
break;
case '40':
header += `
謝謝你給伊將的回饋
`;
break;
case '20':
header += `
謝謝你給伊將的回饋
`;
break;
default:
header += `
謝謝你給伊將的回饋
`;
break;
}
} else {
header += `
整體滿意度調查
`;
}
return header;
}
/**
* @param pageNum 整體滿意度調查頁數
* @param next true:下一頁; false:送出
* @return string modal-footer內容
*/
function vaSurveyFooter(pageNum, next) {
let footer = '';
footer += '
';
//feedback
if (pageNum === 99) {
footer += '
完成作答 ';
} else {
if (next) {
footer += '
下一頁 ';
} else {
footer += '
送出 ';
}
footer += '
不作答 ';
}
footer += '
';
return footer;
}
/**
* @param pageNum 整體滿意度調查頁數
* @param satisfaction 整體滿意度調查(20,40,60,80,100)
* @param choice_list 問卷時需帶入的選項清單
* @return string modal-body內容
*
*/
function vaSurveyBody(pageNum, satisfaction, choice_list) {
let body = '';
if (pageNum === 1) {
//整體滿意度分數
body += '
';
// body += '
請問您對本次使用全球人壽智能客服 的整體滿意度為何?
';
body += '
很高興為您服務,請幫我評個分好嗎? 您的鼓勵就是『伊將』 的最佳活力泉源喔!
';
body += '
';
body += '
';
body += '
';
body += '
';
} else if (pageNum === 2) {
// NPS分數
body += '
';
// body += '
根據本次經驗,請問您會推薦全球人壽智能客服 給親友的意願有多高?
';
body += '
請問您願意把我介紹給親朋好友使用嗎?
';
body += '
';
body += '
';
body += '
';
body += '
';
body += '
';
body += '
';
body += '
';
body += '
';
} else if (pageNum === 3) {
//調查不推薦原因 & 其它回饋
var reasonsBody = genDynamicMultiChoice('reasonsmchoice', choice_list);
body += '
';
body += '
無法讓您滿意/不想推薦的原因?(可複選,最多三個)
';
body += '
';
body += '
';
body += reasonsBody;
body += '
';
body += '
';
body += '
';
body += '
請問您是否有其它意見回饋
';
body += '
';
body += '
';
body += '
';
body += '
';
body += ' ';
body += ' ';
body += '
';
body += '
';
} else if (pageNum === 99) {
let feedbackImg = `sat${satisfaction}f.svg`;
body += '
';
body += '
';
body += '
';
body += '
';
body += '
';
switch (satisfaction) {
case '20':
body += '
不好意思,伊將 會持續加油精進的!
';
break;
case '40':
body += '
已收到你的回饋, 伊將 會繼續努力學習的!
';
break;
case '60':
body += '
伊將 收到你的回饋, 希望能夠再次為你服務!
';
break;
case '80':
body += '
謝謝你,有保險問題都可以詢問伊將 喔!
';
break;
case '100':
body += '
謝謝你,伊將 很榮幸為你服務!
';
break;
default:
body += '
謝謝你,伊將 很榮幸為你服務!
';
break;
}
body += '
';
} else {
const mchoice = ['一試多選題最大字數十八字一二三四五。', '第二題', '第三題', '四多選題最大字數十八字一二三四五。', '第五題'];
var mReasonsBody = genDynamicMultiChoice('mchoice', mchoice);
const schoice = ['第一題', '第二題', '第三題', '四多選題最大字數十八字一二三四五。', '第五題', '六多選題最大字數十八字一二三四五。'];
var sReasonsBody = genDynamicSingleChoice('schoice', schoice);
body += '
';
body += '
多選題,我是第十字。多選題,我是第十字。多選題,我是第十字。多選題,我是第十字。多選題,我是第十字。一二三四五六七八
';
body += '
';
body += '
';
body += mReasonsBody;
body += '
';
body += '
';
body += '
';
body += '
單選題
';
body += '
';
body += '
';
body += sReasonsBody;
body += '
';
body += '
';
body += '
';
body += '
開放式問題
';
body += '
';
body += '
';
body += '
';
body += ' ';
body += '';
body += '
';
body += '
';
}
return body;
}
function genDynamicMultiChoice(name, choice_list) {
let multiChoiceBody = '';
multiChoiceBody += '
';
multiChoiceBody += '
';
multiChoiceBody += '
';
return multiChoiceBody;
}
function genDynamicSingleChoice(name, choice_list) {
let singleChoicBody = '';
singleChoicBody += '
';
singleChoicBody += '
';
singleChoicBody += '
';
return singleChoicBody;
}
/**
* @param checkOption L1:至少選擇一個選項;U3:最多僅可選擇三個選項
*/
function vaCreateSurveyCheckErrModal(checkOption) {
if (vajQuery('#surveyCheckErrModal').length) {
chatbotModal('surveyCheckErrModal', 'hide');
vajQuery('#surveyCheckErrModal').remove();
vaCreateSurveyCheckErrModal(checkOption);
} else {
switch (checkOption) {
case 'L1':
var optsMsg = '至少選擇一個選項';
break;
case 'U3':
var optsMsg = '最多僅可選擇三個選項';
break;
}
var checkDialog = '';
checkDialog += '
';
checkDialog += '
';
checkDialog += '
';
checkDialog += '
';
checkDialog += '
提醒 ';
checkDialog += '
' + optsMsg + '
';
checkDialog += '
';
checkDialog += ' ';
checkDialog += '
';
checkDialog += '
';
checkDialog += '
';
vajQuery('#ibmchatbox').after(checkDialog);
chatbotModal('surveyCheckErrModal', 'show');
$('.loaderMain').hide();
}
}
function vaCreateRegisterOTPModal(value) {
if (vajQuery('#registerOTPModal').length) {
chatbotModal('registerOTPModal', 'hide');
vajQuery('#registerOTPModal').remove();
vaCreateRegisterOTPModal(value);
} else {
let registerOTPModal = '';
let userPhone = '';
let userEmail = '';
let sentOTPDate = new Date();
if (value.toNextStepData) {
if (value.toNextStepData.userPhone) {
userPhone = value.toNextStepData.userPhone;
}
if (value.toNextStepData.userEmail) {
userEmail = value.toNextStepData.userEmail;
}
if (value.toNextStepData.sentOTPDate) {
sentOTPDate = value.toNextStepData.sentOTPDate;
}
}
registerOTPModal += '
';
vajQuery('#ibmchat').append(registerOTPModal);
chatbotModal('registerOTPModal', 'show');
$('.loaderMain').hide();
if (value) {
vajQuery('#inputRegisterOTP').val(value.toNextStepData.inputOTPCode);
}
$(function () {
stopTimer(myRegisterOTPTimer);
myRegisterOTPTimer = setInterval(function () {
registerOTPTimer(addMinutes(new Date(sentOTPDate), 5), myRegisterOTPTimer);
}, 1000);
});
vajQuery('#inputRegisterOTP').keyup(function () {
this.value = this.value.replace(/[^0-9]/g, '');
if (this.value > 8) {
this.value = this.value.substring(0, 9);
}
});
vajQuery('#registerOTPNotion').bind('click', function (e) {
vajQuery('.tiptext').css('visibility', 'visible');
});
vajQuery('#registerOTPNotionClose').bind('click', function (e) {
vajQuery('.tiptext').css('visibility', 'hidden');
});
vajQuery('#reSendRegisterOTPLink').bind('click', function (e) {
try {
$('.loaderMain').show();
const data = {
returnCode: 'registerOTP',
registerID: value.toNextStepData.registerId
};
var elementText = vajQuery(e.target).data('text');
va_sendWebSocket('openForm', 'formback', elementText, 'sendCaptchaByCSIS', data);
} catch (e) {
console.log(e);
$('.loaderMain').hide();
}
});
vajQuery('#registerOTPClose').bind('click', function (e) {
va_sendWebSocket('cancel', 'postback', '', 'F13_會員註冊_取消註冊');
chatbotModal('registerOTPModal', 'hide');
});
vajQuery('#registerOTPModalSubmit').bind('click', function (e) {
try {
$('.loaderMain').show();
var hasInputIsEmpty = 'N';
if (vajQuery('#inputRegisterOTP').val() === '') {
vajQuery('#inputRegisterOTP').addClass('inputIsEmpty');
vajQuery('#inputRegisterOTP').attr('placeholder', '請輸入驗證碼');
hasInputIsEmpty = 'Y';
} else if (vajQuery('#inputRegisterOTP').hasClass('inputIsEmpty')) {
vajQuery('#inputRegisterOTP').removeClass('inputIsEmpty');
hasInputIsEmpty = 'N';
}
if (hasInputIsEmpty === 'N') {
var elementText = vajQuery(e.target).data('text');
var data = {
OTPCode: vajQuery('#inputRegisterOTP').val(),
toNextStepData: value.toNextStepData
};
va_sendWebSocket('openForm', 'formback', elementText, 'checkRegisterOTP', data);
} else {
$('.loaderMain').hide();
}
} catch (e) {
console.log(e);
$('.loaderMain').hide();
}
});
vajQuery('#registerOTPModalPrePage').bind('click', function (e) {
value.toNextStepData.inputOTPCode = '';
vaCreateRegisterModal(value);
chatbotModal('registerOTPModal', 'hide');
});
}
}
function maskEmail(email) {
let maskMail = '';
if (email !== '' && email.includes('@')) {
let part1 = email.split('@')[0];
let maskLength = part1.length - 2;
let formatPart1 = part1.substring(0, 2);
for (let i = 0; i < maskLength; i++) {
formatPart1 += '*';
}
maskMail = formatPart1 + '@' + email.split('@')[1];
}
return maskMail;
}
function maskPhone(phone) {
let maskPhone = '';
maskPhone = phone.substring(0, 4);
for (let i = 0; i < 4; i++) {
maskPhone += '*';
}
maskPhone += phone.substring(7, 10);
return maskPhone;
}
function vaCreateOpenNetworkOTPModal(value) {
vajQuery('#OTPTimer').remove();
vajQuery('#reSendOTPLink').remove();
if (vajQuery('#openNetworkModal').length !== 0) {
chatbotModal('openNetworkModal', 'hide');
}
if (vajQuery('#openNetworkOTPModal').length) {
chatbotModal('openNetworkOTPModal', 'hide');
vajQuery('#openNetworkOTPModal').remove();
vaCreateOpenNetworkOTPModal(value);
} else {
let openNetworkOTPModal = '';
let userEmail = value.email;
let userPhone = value.phone;
let policyDataList = value.policyDataList;
let hasPhone = value.hasPhone;
let sentOTPDate = new Date();
openNetworkOTPModal += '
';
vajQuery('#ibmchat').append(openNetworkOTPModal);
chatbotModal('openNetworkOTPModal', 'show');
$('.loaderMain').hide();
$(function () {
stopOTPTimer(myOTPTimer);
myOTPTimer = setInterval(function () {
OTPTimer(addMinutes(new Date(sentOTPDate), 5), myOTPTimer);
}, 1000);
});
var endtime = addMinutes(new Date(sentOTPDate), 5);
let year = endtime.getFullYear();
let month = ('0' + (endtime.getMonth() + 1)).slice(-2);
let day = ('0' + endtime.getDate()).slice(-2);
let hour = endtime.getHours();
let minute = endtime.getMinutes();
var endTime;
if (minute < 10) {
endTime = year + '/' + month + '/' + day + ' ' + hour + ':0' + minute;
} else {
endTime = year + '/' + month + '/' + day + ' ' + hour + ':' + minute;
}
vajQuery('#inputOpenNetworkOTP').keyup(function () {
this.value = this.value.replace(/[^0-9]/g, '');
if (this.value > 8) {
this.value = this.value.substring(0, 9);
}
});
vajQuery('#openNetworkOTPNotion').bind('click', function (e) {
vajQuery('.tiptext').css('visibility', 'visible');
});
vajQuery('#openNetworkOTPNotionClose').bind('click', function (e) {
vajQuery('.tiptext').css('visibility', 'hidden');
});
vajQuery('#reSendOTPLink').bind('click', function (e) {
try {
$('.loaderMain').show();
const data = {
returnCode: 'openNetworkOTP',
email: userEmail,
sendTheOTPType: 'E',
IsReSend: 'Y',
endTime: endTime,
hasPhone: hasPhone,
type: value.type,
policyNo: policyDataList[0].policyCode
};
var elementText = vajQuery(e.target).data('text');
va_sendWebSocket('openForm', 'formback', elementText, 'sendCaptchaByCSIS', data);
} catch (e) {
console.log(e);
$('.loaderMain').hide();
}
});
vajQuery('#openNetworkOTPClose,#openNetworkOTPCancel').bind('click', function (e) {
va_sendWebSocket('cancel', 'postback', '', 'F15_開通網路變更_放棄');
chatbotModal('openNetworkOTPModal', 'hide');
});
vajQuery('#openNetworkOTPModalSubmit').bind('click', function (e) {
try {
$('.loaderMain').show();
var hasInputIsEmpty = 'N';
if (vajQuery('#inputOpenNetworkOTP').val() === '') {
vajQuery('#inputOpenNetworkOTP').addClass('inputIsEmpty');
vajQuery('#inputOpenNetworkOTP').attr('placeholder', '請輸入驗證碼');
hasInputIsEmpty = 'Y';
} else if (vajQuery('#inputOpenNetworkOTP').hasClass('inputIsEmpty')) {
vajQuery('#inputOpenNetworkOTP').removeClass('inputIsEmpty');
hasInputIsEmpty = 'N';
}
if (hasInputIsEmpty === 'N') {
var elementText = vajQuery(e.target).data('text');
var data = {
OTPCode: vajQuery('#inputOpenNetworkOTP').val(),
policyDataList: policyDataList,
email: userEmail,
phone: userPhone,
hasPhone: hasPhone,
type: value.type
};
va_sendWebSocket('openForm', 'formback', elementText, 'checkOTP', data);
} else {
$('.loaderMain').hide();
}
} catch (e) {
console.log(e);
$('.loaderMain').hide();
}
});
}
}
function OTPTimer(countDownDate, x) {
var now = new Date().getTime();
var distance = new Date(countDownDate).getTime() - now;
if (distance < 0) {
clearInterval(x);
vajQuery('#reSendOTPLink').addClass('hover');
vajQuery('#reSendOTPLink').removeClass('disabled');
document.getElementById('OTPTimer').innerHTML = '00:00';
} else {
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
if (+minutes < 10) {
minutes = '0' + minutes;
}
if (+seconds < 10) {
seconds = '0' + seconds;
}
vajQuery('#reSendOTPLink').removeClass('hover');
vajQuery('#reSendOTPLink').addClass('disabled');
document.getElementById('OTPTimer').innerHTML = minutes + ':' + seconds;
}
}
function registerOTPTimer(countDownDate, x) {
var now = new Date().getTime();
var distance = new Date(countDownDate).getTime() - now;
if (distance < 0) {
clearInterval(x);
vajQuery('#reSendRegisterOTPLink').addClass('hover');
vajQuery('#reSendRegisterOTPLink').removeClass('disabled');
document.getElementById('registerOTPTimer').innerHTML = '00:00';
} else {
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
if (+minutes < 10) {
minutes = '0' + minutes;
}
if (+seconds < 10) {
seconds = '0' + seconds;
}
vajQuery('#reSendRegisterOTPLink').removeClass('hover');
vajQuery('#reSendRegisterOTPLink').addClass('disabled');
document.getElementById('registerOTPTimer').innerHTML = minutes + ':' + seconds;
}
}
function psrnOTPTimer(countDownDate, x) {
var now = new Date().getTime();
var distance = new Date(countDownDate).getTime() - now;
if (distance < 0) {
clearInterval(x);
vajQuery('#sendBasicChangeCaptchaByCSIS').addClass('hover');
vajQuery('#sendBasicChangeCaptchaByCSIS').removeClass('disabled');
document.getElementById('psrnOTPTimer').innerHTML = '00:00';
} else {
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
if (+minutes < 10) {
minutes = '0' + minutes;
}
if (+seconds < 10) {
seconds = '0' + seconds;
}
vajQuery('#sendBasicChangeCaptchaByCSIS').removeClass('hover');
vajQuery('#sendBasicChangeCaptchaByCSIS').addClass('disabled');
document.getElementById('psrnOTPTimer').innerHTML = minutes + ':' + seconds;
}
}
function changePsrnOTPTimer(countDownDate, x) {
var now = new Date().getTime();
var distance = new Date(countDownDate).getTime() - now;
if (distance < 0) {
clearInterval(x);
vajQuery('#sendChangeCaptchaByCSIS').addClass('hover');
vajQuery('#sendChangeCaptchaByCSIS').removeClass('disabled');
document.getElementById('changePsrnOTPTimer').innerHTML = '00:00';
} else {
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
if (+minutes < 10) {
minutes = '0' + minutes;
}
if (+seconds < 10) {
seconds = '0' + seconds;
}
vajQuery('#sendChangeCaptchaByCSIS').removeClass('hover');
vajQuery('#sendChangeCaptchaByCSIS').addClass('disabled');
document.getElementById('changePsrnOTPTimer').innerHTML = minutes + ':' + seconds;
}
}
function mobileOnePsrnOTPTimer(countDownDate, x) {
var now = new Date().getTime();
var distance = new Date(countDownDate).getTime() - now;
if (distance < 0) {
clearInterval(x);
vajQuery('#sendBasicChangeMobileOneCaptchaByCSIS').removeClass('disabled');
vajQuery('#sendBasicChangeMobileOneCaptchaByCSIS').addClass('hover');
document.getElementById('mobileOnePsrnOTPTimer').innerHTML = '00:00';
} else {
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
if (+minutes < 10) {
minutes = '0' + minutes;
}
if (+seconds < 10) {
seconds = '0' + seconds;
}
vajQuery('#sendBasicChangeMobileOneCaptchaByCSIS').removeClass('hover');
vajQuery('#sendBasicChangeMobileOneCaptchaByCSIS').addClass('disabled');
document.getElementById('mobileOnePsrnOTPTimer').innerHTML = minutes + ':' + seconds;
}
}
function loanPsrnOTPTimer(countDownDate, x) {
var now = new Date().getTime();
var distance = new Date(countDownDate).getTime() - now;
if (distance < 0) {
clearInterval(x);
vajQuery('#sendloanCaptchaByCSIS').removeClass('disabled');
vajQuery('#sendloanCaptchaByCSIS').addClass('hover');
document.getElementById('loanPsrnOTPTimer').innerHTML = '00:00';
} else {
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
if (+minutes < 10) {
minutes = '0' + minutes;
}
if (+seconds < 10) {
seconds = '0' + seconds;
}
vajQuery('#sendloanCaptchaByCSIS').removeClass('hover');
vajQuery('#sendloanCaptchaByCSIS').addClass('disabled');
document.getElementById('loanPsrnOTPTimer').innerHTML = minutes + ':' + seconds;
vajQuery('#loanOtpTimer').prop('hidden', false);
vajQuery('#loanPsrnOTPTimer').prop('hidden', false);
}
}
function addMinutes(date, minutes) {
return new Date(date.getTime() + minutes * 60000);
}
function stopTimer(x) {
if (x) {
clearInterval(x);
}
if (vajQuery('#reSendRegisterOTPLink').hasClass('disabled')) {
vajQuery('#reSendRegisterOTPLink').addClass('hover');
vajQuery('#reSendRegisterOTPLink').removeClass('disabled');
}
document.getElementById('registerOTPTimer').innerHTML = '00:00';
}
function stopOTPTimer(x) {
if (x) {
clearInterval(x);
}
if (vajQuery('#reSendOTPLink').hasClass('disabled')) {
vajQuery('#reSendOTPLink').addClass('hover');
vajQuery('#reSendOTPLink').removeClass('disabled');
}
document.getElementById('OTPTimer').innerHTML = '00:00';
}
function stopPsrnTimer(x) {
if (x) {
clearInterval(x);
}
if (vajQuery('#sendBasicChangeCaptchaByCSIS').hasClass('disabled')) {
vajQuery('#sendBasicChangeCaptchaByCSIS').addClass('hover');
vajQuery('#sendBasicChangeCaptchaByCSIS').removeClass('disabled');
}
document.getElementById('psrnOTPTimer').innerHTML = '00:00';
}
function stopChangeConfirmPsrnTimer(x) {
if (x) {
clearInterval(x);
}
if (vajQuery('#sendChangeCaptchaByCSIS').hasClass('disabled')) {
vajQuery('#sendChangeCaptchaByCSIS').addClass('hover');
vajQuery('#sendChangeCaptchaByCSIS').removeClass('disabled');
}
document.getElementById('changePsrnOTPTimer').innerHTML = '00:00';
}
function stopMobileOnePsrnOTPTimer(x) {
if (x) {
clearInterval(x);
}
if (vajQuery('#sendBasicChangeMobileOneCaptchaByCSIS').hasClass('disabled')) {
vajQuery('#sendBasicChangeMobileOneCaptchaByCSIS').addClass('hover');
vajQuery('#sendBasicChangeMobileOneCaptchaByCSIS').removeClass('disabled');
}
document.getElementById('mobileOnePsrnOTPTimer').innerHTML = '00:00';
}
function stopLoanPsrnTimer(x) {
if (x) {
clearInterval(x);
}
if (vajQuery('#sendloanCaptchaByCSIS').hasClass('disabled')) {
vajQuery('#sendloanCaptchaByCSIS').addClass('hover');
vajQuery('#sendloanCaptchaByCSIS').removeClass('disabled');
}
document.getElementById('loanPsrnOTPTimer').innerHTML = '00:00';
}
function vaCreateCheckRegisterOTPErrorMessageModal(data) {
if (vajQuery('#checkRegisterOTPError').length !== 0) {
chatbotModal('checkRegisterOTPError', 'hide');
vajQuery('#checkRegisterOTPError').remove();
vaCreateCheckRegisterOTPErrorMessageModal(data);
} else {
var modalWindow = vajQuery('
');
var modalDialog = vajQuery('
');
var modalContent = vajQuery('
');
var body = '
檢核失敗
';
for (var index in data.errorMsg) {
body += '
';
body += data.errorMsg[index];
body += '
';
}
body += '
';
var modalBody = vajQuery(body);
var footerContent = '';
var modalFooter = vajQuery(footerContent);
//webBotSettings
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
vajQuery('#reInputOTP').click(function () {
chatbotModal('checkRegisterOTPError', 'hide');
if (data.resetTime === 'Y') {
stopTimer(myRegisterOTPTimer);
}
});
vajQuery('#inputOTPCancel').click(function () {
chatbotModal('checkRegisterOTPError', 'hide');
chatbotModal('registerOTPModal', 'hide');
});
chatbotModal('checkRegisterOTPError', 'show');
}
$('.loaderMain').hide();
}
function vaCreateCheckOpenNetworkOTPErrorMessageModal(data) {
if (vajQuery('#checkOpenNetworkOTPError').length !== 0) {
chatbotModal('checkOpenNetworkOTPError', 'hide');
vajQuery('#checkOpenNetworkOTPError').remove();
vaCreateCheckOpenNetworkOTPErrorMessageModal(data);
} else {
var modalWindow = vajQuery('
');
var modalDialog = vajQuery('
');
var modalContent = vajQuery('
');
var body = '
檢核失敗
';
for (var index in data.errorMsg) {
body += '
';
body += data.errorMsg[index];
body += '
';
}
body += '
';
var modalBody = vajQuery(body);
var footerContent = '';
var modalFooter = vajQuery(footerContent);
//webBotSettings
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
vajQuery('#openNetworkReInputOTP').click(function () {
chatbotModal('checkOpenNetworkOTPError', 'hide');
if (data.resetTime === 'Y' || data.resetPhoneTime === 'Y') {
stopOTPTimer(myOTPTimer);
}
});
chatbotModal('checkOpenNetworkOTPError', 'show');
}
$('.loaderMain').hide();
}
function vaCreateOpenNetworkrrorMessageModal(data) {
if (vajQuery('#OpenNetworkError').length !== 0) {
chatbotModal('OpenNetworkError', 'hide');
vajQuery('#OpenNetworkError').remove();
vaCreateOpenNetworkrrorMessageModal(data);
} else {
var modalWindow = vajQuery('
');
var modalDialog = vajQuery('
');
var modalContent = vajQuery('
');
var body = '
開通失敗
';
for (var index in data.errorMsg) {
body += '
';
body += data.errorMsg[index];
body += '
';
}
body += '
';
var modalBody = vajQuery(body);
var footerContent = '';
var modalFooter = vajQuery(footerContent);
//webBotSettings
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
vajQuery('#openReInput').click(function () {
chatbotModal('OpenNetworkError', 'hide');
});
chatbotModal('OpenNetworkError', 'show');
}
$('.loaderMain').hide();
}
function vaCreateCheckChangeOTPErrorMessageModal(data) {
if (vajQuery('#checkChangeOTPError').length !== 0) {
chatbotModal('checkChangeOTPError', 'hide');
vajQuery('#checkChangeOTPError').remove();
vaCreateCheckChangeOTPErrorMessageModal(data);
} else {
var modalWindow = vajQuery('
');
var modalDialog = vajQuery('
');
var modalContent = vajQuery('
');
var body = '
檢核失敗
';
for (var index in data.errorMsg) {
body += '
';
body += data.errorMsg[index];
body += '
';
}
body += '
';
var modalBody = vajQuery(body);
var footerContent = '';
var modalFooter = vajQuery(footerContent);
//webBotSettings
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
vajQuery('#changeReInputOTP').click(function () {
chatbotModal('checkChangeOTPError', 'hide');
if(data.step === 'confirm'){
stopChangeConfirmPsrnTimer(myChangeConfirmOTPTimer)
} else if(data.resetTime === 'Y'){
stopPsrnTimer(myPsrnOTPTimer);
} else if (data.resetPhoneTime === 'Y'){
stopMobileOnePsrnOTPTimer(myMobileOnePsrnOTPTimer);
}
});
chatbotModal('checkChangeOTPError', 'show');
}
$('.loaderMain').hide();
}
function vaCreateChangeOTPSuccessModal(data) {
if (vajQuery('#changeOTPSuccess').length !== 0) {
chatbotModal('changeOTPSuccess', 'hide');
vajQuery('#changeOTPSuccess').remove();
vaCreateChangeOTPSuccessModal(data);
} else {
var modalWindow = vajQuery('
');
var modalDialog = vajQuery('
');
var modalContent = vajQuery('
');
var body = '';
if(data.phone != null){
body = '
手機驗證成功
';
} else if(data.email != null){
body = '
';
var modalBody = vajQuery(body);
var footerContent = '';
var modalFooter = vajQuery(footerContent);
//webBotSettings
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
vajQuery('#changeOTPSubmit').click(function () {
if(data.step === 'confirm'){
chatbotModal('changeOTPSuccess', 'hide');
stopChangeConfirmPsrnTimer(myChangeConfirmOTPTimer);
document.getElementById("changeSuccess").style.display = '';
if(document.getElementById("changeEmailInput")){
document.getElementById("changeEmailInput").disabled=true;
}else{
document.getElementById("changePhoneInput").disabled=true;
}
document.getElementById("changeConfirmCaptchaCode").disabled=true;
document.getElementById("changeOtpTimer").remove();
document.getElementById("sendChangeCaptchaByCSIS").remove();
document.getElementById("checkChangeCaptchaCode").remove();
document.getElementById('changePsrnOTPTimer').remove();
} else if(data.phone){
chatbotModal('changeOTPSuccess', 'hide');
stopMobileOnePsrnOTPTimer(myMobileOnePsrnOTPTimer);
document.getElementById("changeMobileOneSuccess").style.display = '';
document.getElementById("mobileOneInput").disabled=true;
document.getElementById("changeMobileOneCaptchaCode").disabled=true;
document.getElementById("mobileOneOtpTimer").remove();
document.getElementById("sendBasicChangeMobileOneCaptchaByCSIS").remove();
document.getElementById("checkChangeMobileOneCaptchaCode").remove();
document.getElementById('mobileOnePsrnOTPTimer').remove();
} else if(data.email){
chatbotModal('changeOTPSuccess', 'hide');
stopPsrnTimer(myPsrnOTPTimer);
document.getElementById("changeEmailSuccess").style.display = '';
document.getElementById("emailInput").disabled=true;
document.getElementById("changeCaptchaCode").disabled=true;
document.getElementById("otpTimer").remove();
document.getElementById("sendBasicChangeCaptchaByCSIS").remove();
document.getElementById("checkChangeEmailCaptchaCode").remove();
document.getElementById('psrnOTPTimer').remove();
}
});
chatbotModal('changeOTPSuccess', 'show');
}
$('.loaderMain').hide();
}
function vaCreateLoanOTPSuccessModal(data) {
if (vajQuery('#loanOTPSuccess').length !== 0) {
chatbotModal('loanOTPSuccess', 'hide');
vajQuery('#loanOTPSuccess').remove();
vaCreateLoanOTPSuccessModal(data);
} else {
var modalWindow = vajQuery('
');
var modalDialog = vajQuery('
');
var modalContent = vajQuery('
');
var body = '';
if(data.phone != null){
body = '
手機驗證成功
';
} else if(data.email != null){
body = '
';
var modalBody = vajQuery(body);
var footerContent = '';
var modalFooter = vajQuery(footerContent);
//webBotSettings
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
vajQuery('#loanOTPSubmit').click(function () {
if(data.phone){
document.getElementById("phoneInput").disabled=true;
} else if(data.email){
document.getElementById("emailInput").disabled=true;
}
stopLoanPsrnTimer(myLoanOTPTimer);
document.getElementById("loanSuccess").style.display = '';
document.getElementById("loanCaptchaCode").disabled=true;
document.getElementById("loanOtpTimer").remove();
document.getElementById("sendloanCaptchaByCSIS").remove();
document.getElementById("checkloanCaptchaCode").remove();
document.getElementById('loanPsrnOTPTimer').remove();
chatbotModal('loanOTPSuccess', 'hide');
});
chatbotModal('loanOTPSuccess', 'show');
}
$('.loaderMain').hide();
}
function vaCreateCheckLoanOTPErrorMessageModal(data) {
if (vajQuery('#checkLoanOTPError').length !== 0) {
chatbotModal('checkLoanOTPError', 'hide');
vajQuery('#checkLoanOTPError').remove();
vaCreateCheckLoanOTPErrorMessageModal(data);
} else {
var modalWindow = vajQuery('
');
var modalDialog = vajQuery('
');
var modalContent = vajQuery('
');
var body = '
檢核失敗
';
for (var index in data.errorMsg) {
body += '
';
body += data.errorMsg[index];
body += '
';
}
body += '
';
var modalBody = vajQuery(body);
var footerContent = '';
var modalFooter = vajQuery(footerContent);
//webBotSettings
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
vajQuery('#loanReInputOTP').click(function () {
chatbotModal('checkLoanOTPError', 'hide');
if (data.resetTime === 'Y') {
stopLoanPsrnTimer(myLoanOTPTimer);
}
});
chatbotModal('checkLoanOTPError', 'show');
}
$('.loaderMain').hide();
}
function vaCreateVerifyModal(type) {
if (vajQuery('#changeVerify').length !== 0) {
chatbotModal('changeVerify', 'hide');
vajQuery('#changeVerify').remove();
vaCreateVerifyModal(type);
} else {
var modalWindow = vajQuery('
');
var modalDialog = vajQuery('
');
var modalContent = vajQuery('
');
var body = '';
if(type === 'phone'){
body = '
提醒
請完成手機驗證
';
} else if(type === 'email'){
body = '
';
var modalBody = vajQuery(body);
var footerContent = '';
var modalFooter = vajQuery(footerContent);
//webBotSettings
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
vajQuery('#changeVerifySubmit').click(function () {
chatbotModal('changeVerify', 'hide');
});
chatbotModal('changeVerify', 'show');
}
$('.loaderMain').hide();
}
function vaCreateOpenMessageModal() {
if (vajQuery('#OpenMessage').length !== 0) {
chatbotModal('OpenMessage', 'hide');
vajQuery('#OpenMessage').remove();
vaCreateOpenMessageModal();
} else {
var modalWindow = vajQuery('
');
var modalDialog = vajQuery('
');
var modalContent = vajQuery('
');
var modalBody = vajQuery('
');
var footerContent = '';
var modalFooter = vajQuery(footerContent);
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
vajQuery('#OpenMessageSubmit').click(function () {
chatbotModal('OpenMessage', 'hide');
});
chatbotModal('OpenMessage', 'show');
}
$('.loaderMain').hide();
}
function vaCreateOTPErrorMessageModal(message) {
if (vajQuery('#OTPErrorMessageModal').length !== 0) {
chatbotModal('OTPErrorMessageModal', 'hide');
vajQuery('#OTPErrorMessageModal').remove();
vaCreateOTPErrorMessageModal(message);
} else {
var modalWindow = vajQuery('
');
var modalDialog = vajQuery('
');
var modalContent = vajQuery('
');
var body = '
提醒
';
body += '
';
body += message;
body += '
';
body += '
';
var modalBody = vajQuery(body);
var footerContent = '';
var modalFooter = vajQuery(footerContent);
//webBotSettings
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
vajQuery('#OTPErrorSubmit').click(function () {
chatbotModal('OTPErrorMessageModal', 'hide');
});
chatbotModal('OTPErrorMessageModal', 'show');
}
$('.loaderMain').hide();
}
function vaCreateRegisterPasswordModal(value) {
if (vajQuery('#registerPasswordModal').length) {
chatbotModal('registerPasswordModal', 'hide');
vajQuery('#registerPasswordModal').remove();
vaCreateRegisterPasswordModal(value);
} else {
let registerPasswordModal = '';
registerPasswordModal += '
';
vajQuery('#ibmchat').append(registerPasswordModal);
chatbotModal('registerPasswordModal', 'show');
if (value) {
vajQuery('#inputRegisterConfirmPassword, #inputRegisterPassword').val(value.toNextStepData.inputRegisterPassword);
}
vajQuery('#registerPasswordClose').bind('click', function (e) {
va_sendWebSocket('cancel', 'postback', '', 'F13_會員註冊_取消註冊');
chatbotModal('registerPasswordModal', 'hide');
});
vajQuery('#inputRegisterPassword').keyup(function () {
this.value = this.value.replace(/[^0-9a-zA-Z]/g, '');
if (this.value > 15) {
this.value = this.value.substring(0, 16);
}
});
vajQuery('#inputRegisterConfirmPassword').keyup(function () {
this.value = this.value.replace(/[^0-9a-zA-Z]/g, '');
if (this.value > 15) {
this.value = this.value.substring(0, 16);
}
});
vajQuery('#registerPasswordModalSubmit').bind('click', function (e) {
try {
var hasInputIsEmpty = 'N';
if (vajQuery('#inputRegisterPassword').val() === '') {
vajQuery('#inputRegisterPassword').addClass('inputIsEmpty');
vajQuery('#inputRegisterPassword').attr('placeholder', '請填寫新密碼');
hasInputIsEmpty = 'Y';
} else if (vajQuery('#inputRegisterPassword').hasClass('inputIsEmpty')) {
vajQuery('#inputRegisterPassword').removeClass('inputIsEmpty');
hasInputIsEmpty = 'N';
}
if (vajQuery('#inputRegisterConfirmPassword').val() === '') {
vajQuery('#inputRegisterConfirmPassword').addClass('inputIsEmpty');
vajQuery('#inputRegisterConfirmPassword').attr('placeholder', '請填寫新密碼確認');
hasInputIsEmpty = 'Y';
} else if (vajQuery('#inputRegisterConfirmPassword').hasClass('inputIsEmpty')) {
vajQuery('#inputRegisterConfirmPassword').removeClass('inputIsEmpty');
hasInputIsEmpty = 'N';
}
if (hasInputIsEmpty === 'N') {
$('.loaderMain').show();
var elementText = vajQuery(e.target).data('text');
var jscrypto = new JSEncrypt();
jscrypto.setPublicKey(RSA_PUBLICKEY);
var data = {
inputRegisterPassword: value.toNextStepData.inputRegisterPassword && value.toNextStepData.inputRegisterPassword !== '' ? vajQuery('#inputRegisterPassword').val() : jscrypto.encrypt(vajQuery('#inputRegisterPassword').val()), //value有值應已加密
inputRegisterConfirmPassword: value.toNextStepData.inputRegisterPassword && value.toNextStepData.inputRegisterPassword !== '' ? vajQuery('#inputRegisterConfirmPassword').val() : jscrypto.encrypt(vajQuery('#inputRegisterConfirmPassword').val()),
toNextStepData: value.toNextStepData
};
va_sendWebSocket('openForm', 'formback', elementText, 'checkRegisterPassword', data);
}
} catch (e) {
console.log(e);
$('.loaderMain').hide();
}
});
vajQuery('#registerPasswordModalPrePage').bind('click', function (e) {
value.toNextStepData.inputRegisterPassword = '';
vaCreateRegisterOTPModal(value);
chatbotModal('registerPasswordModal', 'hide');
});
}
}
function vaCreateCheckRegisterPasswordErrorMessageModal(data) {
if (vajQuery('#checkRegisterPasswordError').length !== 0) {
chatbotModal('checkRegisterPasswordError', 'hide');
vajQuery('#checkRegisterPasswordError').remove();
vaCreateCheckRegisterPasswordErrorMessageModal(data);
} else {
var modalWindow = vajQuery('
');
var modalDialog = vajQuery('
');
var modalContent = vajQuery('
');
var body = '
檢核失敗
';
for (var index in data.errorMsg) {
body += '
';
body += data.errorMsg[index];
body += '
';
}
body += '
';
var modalBody = vajQuery(body);
var footerContent = '';
var modalFooter = vajQuery(footerContent);
//webBotSettings
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
vajQuery('#reInputOTP').click(function () {
chatbotModal('checkRegisterPasswordError', 'hide');
});
vajQuery('#inputOTPCancel').click(function () {
chatbotModal('checkRegisterPasswordError', 'hide');
chatbotModal('registerOTPModal', 'hide');
});
chatbotModal('checkRegisterPasswordError', 'show');
}
$('.loaderMain').hide();
}
function vaCreateCheckOpenNetworkErrorMessageModal(data) {
if (vajQuery('#checkOpenNetworkErrorr').length !== 0) {
chatbotModal('checkOpenNetworkErrorr', 'hide');
vajQuery('#checkOpenNetworkErrorr').remove();
vaCreateCheckOpenNetworkErrorMessageModal(data);
} else {
var modalWindow = vajQuery('
');
var modalDialog = vajQuery('
');
var modalContent = vajQuery('
');
var body = '
檢核失敗
';
for (var index in data.errorMsg) {
if (data.errorMsg[index] !== '') {
body += '
';
body += data.errorMsg[index];
body += '
';
}
}
if (data.changeItems && data.changeItems !== null) {
body += '
• 若您仍要變更至此' + data.changeItems + ',請本人攜帶身分證至全省分公司/服務中心櫃台辦理。
';
}
body += '
';
var modalBody = vajQuery(body);
var footerContent = '';
var modalFooter = vajQuery(footerContent);
//webBotSettings
modalContent.append(modalBody);
modalContent.append(modalFooter);
modalDialog.append(modalContent);
modalWindow.append(modalDialog);
vajQuery('#ibmchatbox').after(modalWindow);
vajQuery('#reInput').click(function () {
chatbotModal('checkOpenNetworkErrorr', 'hide');
});
chatbotModal('checkOpenNetworkErrorr', 'show');
}
$('.loaderMain').hide();
}
function vaCreateOpenNetworkConfirmModal(data) {
let policyDataList = data.policyDataList;
if (vajQuery('#openNetworkOTPModal').length !== 0) {
chatbotModal('openNetworkOTPModal', 'hide');
}
if (vajQuery('#openNetworkPhoneOTPModal').length !== 0) {
chatbotModal('openNetworkPhoneOTPModal', 'hide');
}
if (vajQuery('#openNetworkConfirmModal').length !== 0) {
chatbotModal('openNetworkConfirmModal', 'hide');
vajQuery('#openNetworkConfirmModal').remove();
vaCreateOpenNetworkConfirmModal(data);
} else {
let openNetworkChange = '';
openNetworkChange += '