base.requestApi('/admin/api/site/getKeyVal', {'id': id, 'tpl': 'site/pop/page_tip'}, function (res) {
                if (res.result == 1) {
                    base.showTip('ok', '获取数据成功!', 1000);
                    base.showPop('#catPopup');

                    $('#catPopup').find('.field-area').html(res.data);
                }
            });
            base.requestApi('/admin/api/site/getKeyVal', {'id': id, 'tpl': tpl}, function (res) {
                if (res.result == 1) {
                    base.showTip('ok', '获取数据成功!', 1000);
                    base.showPop('#catPopup');
                    // mail
                    if (type == 'mail') {
                        editor.init('#catPopup .mailContent');
                    }

                    $('#catPopup').find('.field-area').html(res.data);
                }
            });
        obj.on('click', '.resetBtn', function (e) {
            var account = obj.find('.account').val();
            var code = obj.find('.code').val();
            var state_code = obj.find('.state_code').val();
            var new_password = obj.find('.password').val();

            base.requestApi('/home/api/account/forgot', {
                account: account,
                code: code,
                state_code: state_code,
                type: type,
                new_password: new_password
            }, function (res) {
                if (res.result == 1) {
                    tip.showTip('ok', '恭喜您,密码重置成功!', 3000);
                    setTimeout(function () {
                        window.location.href = '/account/login';
                    }, 1000);
                    $(".reset-area").fadeIn();
                    $(".verify-area").hide();
                }
            });

            e.stopImmediatePropagation();
        });
        obj.on('click', '.verifyBtn', function (e) {
            var account = obj.find('.account').val();
            var code = obj.find('.code').val();
            var name = type == "phone" ? '手机号' : '邮箱';
            if (!account) {
                tip.showTip('err', name + '不能为空', '3000');
                obj.find('.account').focus();
                return;
            }

            if (!code) {
                tip.showTip('err', '验证码不能为空', '3000');
                obj.find('.code').focus();
                return;
            }

            base.requestApi('/home/api/account/checkVerifyCode', {
                account: account,
                code: code,
                type: 'forgot'
            }, function (res) {
                if (res.result == 1) {
                    tip.showTip('ok', '身份验证成功,请重置密码', 3000);
                    $(".reset-area").fadeIn();
                    $(".verify-area").hide();
                } else {
                    obj.find('.code').focus();
                }
            });
            e.stopImmediatePropagation();
        });
        $('.regForm').on('click', '.emailRegBtn', function (e) {
            var isDisabled = $(this).attr('data-disabled');
            if (isDisabled && isDisabled == 'true') {
                tip.showTip("err", "该邮箱已经注册, 请直接登录!", 1000);
                $('.regForm .email').focus();
                return false;
            }

            var data = $('.regForm').serializeObject();

            if (!checkField('.regForm .name', '请输入姓名', /^([\u4E00-\uFA29]|[\uE7C7-\uE7F3]|[A-Za-z]){1}([\u4E00-\uFA29]|[\uE7C7-\uE7F3]|[A-Za-z0-9]){1,19}$/)) {
                return false;
            }

            if (!checkField('.regForm .email', '请输入邮箱')) {
                return false;
            }

            if (!checkField('.regForm .password', '请输入密码', /[A-Za-z0-9-_!@#$%^&*.,]{6,16}$/)) {
                return false;
            }

            base.requestApi('/home/api/account/reg', data, function (res) {
                if (res.result == 1) {
                    tip.showTip('ok', '恭喜您,注册成功!', 5000);
                    setTimeout(function () {
                        window.location.href = "/user/guide";
                    }, 2000);
                }
            });

            e.stopImmediatePropagation();
        });
        obj.on('click', '.loginBtn', function (e) {
            var data = $(form).serializeObject();
            console.log(data);
            if (data.login_type == 'phone') {
                if (!new RegExp(/1[0-9]{10}/).test(data.account)) {
                    tip.showTip('err', "手机格式不正确!", 2000);
                    obj.find('#account-phone').focus();
                    return;
                }
            } else {
                if (!new RegExp(/(\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)/).test(data.account)) {
                    tip.showTip('err', "邮箱格式不正确!", 2000);
                    obj.find('#account-email').focus();
                    return;
                }
            }


            if (data.password.length < 5 || data.password.length > 16) {
                tip.showTip('err', "密码长度为6-16位", 2000);
                return;
            }

            base.requestApi('/home/api/account/login', data, function (res) {
                if (res.result == 1) {
                    setTimeout(function () {
                        window.location.reload();
                    }, 1500);
                    tip.showTip("ok", '恭喜您,登陆成功!', 2000);
                }
            });

            e.stopImmediatePropagation();
        });
        $('#catPopup .saveBtn').click(function (e) {
            var data = $('#catPopup .form').serializeObject();
            var id = $('#catPopup #data_id').val();
            var type = $('#catPopup #data_id').attr('data-type');
            if (!data.val) {
                $('#catPopup .tplContent').focus();
                tip.showTip('err', '请填写模板内容', 3000);
                return;
            }
            if (type == 'mail' && !data.param) {
                $('#catPopup .param').focus();
                tip.showTip('err', '请填写邮件主题', 3000);
                return;
            }

            if (data.val.indexOf('${code}') === -1) {
                $('#catPopup .tplContent').focus();
                tip.showTip('err', '不能缺少验证码变量${code}', 3000);
                return;
            }

            // api request
            base.requestApi('/admin/api/site/saveKeyVal', {'data': data, id: id}, function (res) {
                if (res.result == 1) {
                    base.showTip('ok', '数据保存成功!', 3000);
                    setTimeout(function () {
                        base.hidePop();
                        window.location.reload();
                    }, 1000);
                }
            });

            e.stopImmediatePropagation();
        });
Exemple #8
0
 $(document).on('click', '.setAvatarBtn', function (e) {
     base.showPop('#avatarPopup');
     if (!init) {
         cropperInit();
         init = true;
     }
     e.stopImmediatePropagation();
 });
 base.requestApi('/admin/api/site/saveKeyVal', {'data': data, id: id}, function (res) {
     if (res.result == 1) {
         base.showTip('ok', '数据保存成功!', 3000);
         setTimeout(function () {
             base.hidePop();
             window.location.reload();
         }, 1000);
     }
 });
Exemple #10
0
        $('.upBtn').click(function (e) {
            var id = $(this).attr('data-id');
            // api request
            base.requestApi('/admin/api/site/getKeyVal', {'id': id, 'tpl': 'site/pop/page_tip'}, function (res) {
                if (res.result == 1) {
                    base.showTip('ok', '获取数据成功!', 1000);
                    base.showPop('#catPopup');

                    $('#catPopup').find('.field-area').html(res.data);
                }
            });

            e.stopImmediatePropagation();
        });
Exemple #11
0
        $(".submitBtn").on('click', function (e) {
            var data = $(".field textarea").val();
            var id = $(this).attr('data-id');

            // api request
            base.requestApi('/admin/api/page/save', {data: data, id: id}, function (res) {
                if (res.result == 1) {
                    tip.showTip('ok', "信息保存成功", 2000);
                    setTimeout(function () {
                        window.location.href = res.data;
                    }, 1000);
                }
            });
            e.stopImmediatePropagation();
        });
Exemple #12
0
 $('.regForm').on('change', '.email', function () {
     if (!checkField(".regForm .email", '邮箱格式不正确', /^([a-zA-Z0-9_%+-])+@([a-zA-Z0-9_-])+([.][A-Za-z]{2,4})+$/)) {
         return false;
     }
     var email = $(this).val();
     base.requestApi('/home/api/account/checkEmail', {email: email}, function (res) {
         if (res.result == 1) {
             if (res.data == 1000) {
                 okCall();
             } else {
                 failCall();
             }
         }
     }, true);
 });
Exemple #13
0
 $('.guideForm').on('change', '.select-province', function (e) {
     var id = $(this).val();
     base.requestApi('/home/api/area/getCities', {province_id: id}, function (res) {
         if (res.result == 1) {
             console.log(res);
             var str = '<option value="">请选择城市</option>';
             for (var i = 0; i < res.data.length; i++) {
                 var item = res.data[i];
                 str += '<option value="' + item.id + '">' + item.name + '</option>';
             }
             $('.guideForm .select-city').html(str).fadeIn();
         }
     }, true);
     e.stopImmediatePropagation();
 }).on('change', '.select-city', function (e) {
Exemple #14
0
 $('.regForm .phone').on('change', function () {
     var state_code = $(".state-code").val();
     if (!checkField(".regForm .phone", '手机号码格式不正确', /^(1[\d]{10})$/)) {
         return false;
     }
     var phone = $('.phone').val();
     base.requestApi('/home/api/account/checkPhone', {phone: phone, state_code: state_code}, function (res) {
         if (res.result == 1) {
             if (res.data == 1000) {
                 okCall();
             } else {
                 failCall();
             }
         }
     }, true);
 });
Exemple #15
0
        $('#catPopup .saveBtn').click(function (e) {
            var data = $('#catPopup .form').serializeObject();
            var id = $('#catPopup #data_id').val();

            // api request
            base.requestApi('/admin/api/site/saveKeyVal', {'data': data, id: id}, function (res) {
                if (res.result == 1) {
                    base.showTip('ok', '数据保存成功!', 3000);
                    setTimeout(function () {
                        base.hidePop();
                        window.location.reload();
                    }, 1000);
                }
            });

            e.stopImmediatePropagation();
        });
Exemple #16
0
                $('.saveAvatarBtn').on('click', function (e) {
                    var img = $('.image-wrapper img').attr('src');
                    if (!rectData) {
                        tip.showTip('err', '请先选择头像', 3000);
                        return;
                    }

                    base.requestApi('/home/api/user/saveAvatar', {rect: rectData, file: img}, function (res) {
                        if (res.result == 1) {
                            tip.showTip('ok', '恭喜您,头像上传成功', 2000);
                            $('.user-avatar img.avatar').attr('src', res.data);
                            setTimeout(function () {
                                base.hidePop('#avatarPopup');
                            }, 1000);
                        }
                    });

                    e.stopImmediatePropagation();
                });
Exemple #17
0
 }).on('change', '.select-city', function (e) {
     var city_id = $(this).val();
     base.requestApi('/home/api/area/getDepartment', {city_id: city_id}, function (res) {
         if (res.result == 1) {
             if (res.data.length == 0) {
                 $('.field-department').fadeOut();
             } else {
                 var str = '<option value="0">请选择中心</option>';
                 for (var i = 0; i < res.data.length; i++) {
                     var item = res.data[i];
                     str += '<option value="' + item.id + '">' + item.name + '</option>';
                 }
                 $('.guideForm .department_id').html(str);
                 $('.field-department').fadeIn();
             }
         }
     }, true);
     e.stopImmediatePropagation();
 }).on('click', '.saveBtn', function (e) {
Exemple #18
0
 }).on('click', '.saveBtn', function (e) {
     var data = $('.guideForm').serializeObject();
     var step = $(this).attr('data-step');
     if (step == 1) {
         var city_name = $('.select-city option:selected').html();
         data.base_info.city_name = city_name == "请选择城市" ? "" : city_name;
         var department = $('.department_id option:selected').html();
         data.base_info.department = department == "请选择中心" ? "" : department;
         var province_name = $('.province_id option:selected').html();
         data.base_info.province_name = province_name == "请选择省份" ? "" : province_name;
     }
     if (step == 4) {
         if (data.demand.cid == 0) {
             tip.showTip('err', '请选择需求分类', 3000);
             $('.demand_cid').focus();
             return;
         }
         if (data.demand.content == 0) {
             tip.showTip('err', '请填写需求详情', 3000);
             $('.demand_content').focus();
             return;
         }
     }
     base.requestApi('/home/api/user/saveProfile', {
         base_info: JSON.stringify(data.base_info),
         interest: data.interest,
         service: data.service,
         demand: JSON.stringify(data.demand)
     }, function (res) {
         if (res.result == 1) {
             tip.showTip('ok', '恭喜您,资料保存成功', 10000);
             setTimeout(function () {
                 if (step == 4) {
                     window.location.href = '/user';
                 } else {
                     window.location.href = '?step=' + (1 + parseInt(step));
                 }
             }, 1500);
         }
     });
     e.stopImmediatePropagation();
 });
Exemple #19
0
        $('.upBtn').click(function (e) {
            var id = $(this).attr('data-id');
            var type = $(this).attr('data-type');
            var tpl = 'site/pop/' + type + '_tpl';
            // api request
            base.requestApi('/admin/api/site/getKeyVal', {'id': id, 'tpl': tpl}, function (res) {
                if (res.result == 1) {
                    base.showTip('ok', '获取数据成功!', 1000);
                    base.showPop('#catPopup');
                    // mail
                    if (type == 'mail') {
                        editor.init('#catPopup .mailContent');
                    }

                    $('#catPopup').find('.field-area').html(res.data);
                }
            });

            e.stopImmediatePropagation();
        });
Exemple #20
0
        $('#sendMailBtn').on('click', function (e) {
            var email = obj.find(".email").val();
            if (!/(\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)/.test(email)) {
                obj.find('.email').focus();
                tip.showTip('err', '请输入正确的邮箱', 3000);
                return false;
            }

            if ($(this).hasClass('btn-disabled')) {
                tip.showTip('err', ' 一分钟只能发送一次,请等待', 3000);
                return;
            }

            var check_unique = $(this).attr('data-checkUnique');
            var disabled = $(this).attr('disabled');
            if (disabled && disabled == 'true') {
                return false;
            }

            if (!(type && type !== 'null')) {
                type = '';
            }

            base.requestApi('/home/api/account/sendEmailVerifyCode', {
                email: email,
                check_unique: check_unique,
                type: type
            }, function (res) {
                if (res.result == 1) {
                    tip.showTip('ok', '邮箱验证码已经发送,请注意查收!', 3000);
                    codeTimer('sendCodeBtn', 60);
                } else {
                    console.log(res);
                }
            }, true);

            e.stopImmediatePropagation();
        });
Exemple #21
0
        $('#sendCodeBtn').on('click', function (e) {
            var phone = obj.find(".phone").val();
            if (!/^1[\d]{10}$/.test(phone)) {
                obj.find('.phone').focus();
                tip.showTip('err', '请输入正确的手机号码', 3000);
                return false;
            }

            if ($(this).hasClass('btn-disabled')) {
                tip.showTip('err', ' 一分钟只能发送一次,请等待', 3000);
                return;
            }

            var check_unique = $(this).attr('data-checkUnique');
            var disabled = $(this).attr('disabled');
            if (disabled && disabled == 'true') {
                return false;
            }

            if (!(type && type !== 'null')) {
                type = '';
            }

            base.requestApi('/home/api/account/sendPhoneVerifyCode', {
                phone: phone,
                check_unique: check_unique,
                type: type
            }, function (res) {
                if (res.result == 1) {
                    tip.showTip('ok', '短信验证码已经发送!', 3000);
                    codeTimer('sendCodeBtn', 60);
                } else {
                    console.log(res);
                }
            }, true);

            e.stopImmediatePropagation();
        });
Exemple #22
0
 setTimeout(function () {
     base.hidePop();
     window.location.reload();
 }, 1000);
Exemple #23
0
 setTimeout(function () {
     base.hidePop('#avatarPopup');
 }, 1000);
Exemple #24
0
 $(document).on('click', '.openLoginBox', function () {
     base.showPop('#loginPopup');
 });