/* HTTP API 公共模块业务
 * Copyright 2020, CAIMEI365
 * Date   2020/06/16
 * auther ZHJY
 */
var PublicApi = {
        uploadimg: function (params, callback) {//供应商添加物流上传图片
            Http.uploadImage({ url:'/formData/MultiPictareaddData',data:params},callback)
        },
        GetProvince:function(params,callback){ //获取省份信息
            Http.AjaxService({ url:'/club/province', type:'get', data:params, json:false})
                .then(function(res){
                    callback(res)
                });
        },
        GetCity:function(params,callback){ //获取区分信息
            Http.AjaxService({ url:'/club/city', type:'get', data:params, json:true})
                .then(function(res){
                    callback(res)
                });
        },
        GetTown:function(params,callback){ //获取市信息
            Http.AjaxService({ url:'/club/town', type:'get', data:params, json:true})
                .then(function(res){
                    callback(res)
                });
        },
        GetFirstClassFication:function(params,callback){ //获取一级分类
            Http.AjaxService({ url:'/supplier/primaryClassification', type:'get', data:params, json:true})
            .then(function(res){
                callback(res)
            });
        },
        GetTwoClassFication:function(params,callback){ //获取二级分类
            Http.AjaxService({ url:'/supplier/secondaryClassification', type:'get', data:params, json:true})
            .then(function(res){
                callback(res)
            });
        },
        GetThreeClassFication:function(params,callback){ //获取三级分类
            Http.AjaxService({ url:'/supplier/threeLevelClassification', type:'get', data:params, json:true})
            .then(function(res){
                callback(res)
            });
        },
        addCart : function (params,callback) { //加入购物车
            Http.AjaxService({ url:'/shoppingCart/addCart', type:'post', data:params, json:false})
            .then(function(res){
                callback(res)
            });
        },
        getImgVerifyCode : function (params,callback){ //获取图形验证图形
            Http.AjaxService({ url:'/user/getImgVerifyCode', type:'get', data:params, json:true})
            .then(function(res){
                if (res.code == 0) {
                    callback(res);
                }
            });
        },
        getMobileSMScode : function (params,callback){//直接获取手机短信验证码
            Http.AjaxService({ url:'/user/activateCodeByReg', type:'get', data:params, json:true})
            .then(function(res){
                callback(res);
            });
        },
        getNoteSMScode : function (params,callback){//绑定机构运营人员获取短信验证码
            Http.AjaxService({ url:'/user/note', type:'get', data:params, json:true})
            .then(function(res){
                callback(res);
            });
        },
        getEmailSMScode : function (params,callback) { //获取邮箱短信验证码
            Http.AjaxService({ url:'/user/mailbox', type:'get', data:params, json:true})
            .then(function(res){
                callback(res);
            });
        },
        getClubMobileCode : function (params,callback) { //获取手机短信验证码
            Http.AjaxService({ url:'/club/modifyPhoneNumber', type:'get', data:params, json:true})
            .then(function(res){
                callback(res);
            });
        },
        getEmailsms : function (opts) {// 直接获取邮箱验证码
            var _email = {
                    ele : opts.$email,
                    value : opts.$email.val(),
                    boolean : true,
                    nullTip : '请输入邮箱地址',
                    errTip : '邮箱格式不正确',
                    subBtn : opts.$subBtn,
                    regExp : new RegExp(_RegExp.email)
                };
            if(!_util.validateFn(_email)){
                return;
            }else{
                var params = {
                    email : opts.$email.val(),
                    status : opts.$codeBtn.attr('data-codeType')
                };
                request.getEmailSMScode(params,function (response) {
                    if(response.code == 0){
                        cmModal.toast('邮箱验证码已发送',2000)
                        opts.$codeBtn.val('(120s)重新获取');
                        var _time = 120;
                        var _timer = setInterval(function () {
                            --_time;
                            if (_time < 0) {
                                clearInterval(_timer);
                                opts.$codeBtn.val('获取校验码');
                                opts.$codeBtn.attr("disabled", false);
                            } else {
                                opts.$codeBtn.val('(' + _time + 's)重新获取');
                            }
                        }, 1000);
                    }else{
                        opts.$codeBtn.val('获取校验码');
                        opts.$email.siblings('.err-tip').show().html(response.msg);
                        _util.hideTip(opts.$email.siblings('.err-tip'));
                    }
                })
            }
        },
        findCompanyPwd : function(params,callback) {//用户找回密码
            Http.AjaxService({ url:'/user/findCompanyPwd', type:'post', data:params, json:true})
            .then(function(res){
                callback(res);
            });
        },
        clubChangeMobile:function(params,callback){//更换手机号
            Http.AjaxService({ url:'/club/changeMobile', type:'post', data:params, json:true})
            .then(function(res){
                callback(res);
            });
        },
        editCompanyInfo : function (params,callback) {//获取要修改的企业信息
            Http.AjaxService({ url:'/user/club/applicationData', type:'get', data:params, json:true})
            .then(function(res){
                callback(res);
            });
        },
        updateCompanyInfo : function (params,callback) {//提交机构修改申请信息
            Http.AjaxService({ url:'/user/club/updateCompanyInfo', type:'post', data:params, json:true})
            .then(function(res){
                callback(res);
            });
        },
        modifiedData : function (params,callback) {//提交个人中心修改机构信息
            Http.AjaxService({ url:'/operation/modifiedData', type:'post', data:params, json:false})
            .then(function(res){
                callback(res);
            });
        },
        bindIngUseEmail : function(params,callback) { //未绑定邮箱账户绑定邮箱
            Http.AjaxService({ url:'/user/binding', type:'post', data:params, json:true})
            .then(function(res){
                callback(res)
            });
        },
        getOperationList : function (params,callback) { //获取机构运营人员列表
            Http.AjaxService({ url:'/user/bindOrganization', type:'post', data:params, json:false})
            .then(function(res){
                callback(res)
            });
        },
        addOperation : function (params,callback) { //机构员工管理添加运营人员
            Http.AjaxService({ url:'/operation/add', type:'post', data:params, json:false})
            .then(function(res){
                callback(res)
            });
        },
        deleteOperation : function (params,callback) { //机构员工管理删除运营人员
            Http.AjaxService({ url:'/operation/delete', type:'post', data:params, json:false})
            .then(function(res){
                callback(res)
            });
        },
        updateInvitationCode : function (params,callback) { //机构员工管理更新邀请码
            Http.AjaxService({ url:'/operation/updateInvitationCode', type:'post', data:params, json:false})
            .then(function(res){
                callback(res)
            });
        },
        queryShoppingCartList:function(params,callback){ //购物车数据列表
            Http.AjaxService({ url:'/shoppingCart/shoppingInfo', type:'get', data:params, json:false})
            .then(function(res){
                callback(res)
            });
        },
        shoppingCartUpdate:function(params,callback){//更新商品增减
            Http.AjaxService({ url:'/shoppingCart/update', type:'post', data:params, json:false})
            .then(function(res){
                callback(res)
            });
        },
        shoppingCartDelete:function(params,callback) {//删除购物车商品
            Http.AjaxService({ url:'/shoppingCart/delete', type:'post', data:params, json:false})
            .then(function(res){
                callback(res)
            });
        },
        queryOrderConfirmInfo:function(params,callback){ //购物车数据列表
            Http.AjaxService({ url:'/order/confirm', type:'get', data:params, json:true})
            .then(function(res){
                callback(res)
            });
        },
        queryAddressList:function(params,callback){ //地址列表
            Http.AjaxService({ url:'/personalCenter/findAddress', type:'get', data:params, json:true})
            .then(function(res){
                callback(res)
            });
        },
        deleteNewAddress:function(params,callback){ //删除地址
            Http.AjaxService({ url:'/personalCenter/deleteAddress', type:'get', data:params, json:true})
            .then(function(res){
                callback(res)
            });
        },
        addNewAddress:function(params,callback) {//保存地址
            Http.AjaxService({ url:'/personalCenter/saveAddress', type:'post', data:params, json:false})
            .then(function(res){
                callback(res)
            });
        },
        defaultAddress:function(params,callback) {//设为默认地址
            Http.AjaxService({ url:'/personalCenter/defaultAddress', type:'post', data:params, json:false})
            .then(function(res){
                callback(res)
            });
        },
        getOrderPostage:function(params,callback){ //获取邮费信息
            Http.AjaxService({ url:'/order/postage', type:'get', data:params, json:true})
            .then(function(res){
                callback(res)
            });
        },
        getFindInvoice:function(params,callback){ //获取发票信息
            Http.AjaxService({ url:'/personalCenter/findInvoice', type:'get', data:params, json:true})
            .then(function(res){
                callback(res)
            });
        },
        confirmOrder:function (params,callback) {//提交订单
            Http.AjaxService({ url:'/order/submit', type:'post', data:params, json:false})
            .then(function(res){
                callback(res)
            });
        },
        updateInvoice:function (params,callback) {//保存发票信息
            Http.AjaxService({ url:'/personalCenter/invoice', type:'post', data:params, json:false})
            .then(function(res){
                callback(res)
            });
        },
};


