/**
 * Created by Administrator on 2021/4/5.
 */
define(['jquery', "template", "Tools", "user", "paging","cupload","kindeditor"], function ($, template, Tools ) {
    //数据存储
    var module = {
        data: {
            userInformationDetail:[],
            userSupplyInformationList:'',
            consultingInformationList:'',
            biddingInformationList:'',
            //页码
            pageNum: 1,
            //页码集合
            pageList: [],
            //每页数量
            pageSize: 5,
            //总页数
            pageCount:0,
            //用户ID
            memberId:0,
            //用户资料form
            form:{

            },
            modifyUrl:'',
            detailUrl:''
        },
    };
    var tools = new Tools();
    module.init = function (page) {
        //底部友情链接
        tools.doGet(friendsLinks, {}, module.bottomFriendsLinks, true);
        //用户资料
        tools.doGet(userData, {}, module.userData);

        if(!tools.getCookie('Admin-Token')){
            tools.skip('../../index.html')
        }

        //用户资料
        //tools.doPut(userData, {id:}, module.userData,true);

        //个人中心选项卡鼠标悬浮
        module.userListHover();

        //网站配置信息（网站名称 底部联系方式 公安备案号 网站备案号）
        tools.getWebConfig();

        window.KindEditor.create('#editor_id')

        //console.log(tools.getParam('type'))

        var type = tools.getParam('type');

        module.getType(type);
        setTimeout(function(){
            //主题图片切换
            module.switchTheme();
        },500)

    };

    //主题图片切换
    module.switchTheme = function(){
        if(themeColor == 'red'){
            module.data.modifyUrl = '../../static/images/modify_red.png';
            module.data.detailUrl = '../../static/images/detail_red.png';
        }else if(themeColor == 'green'){
            module.data.modifyUrl = '../../static/images/modify.png';
            module.data.detailUrl = '../../static/images/detail.png';
        }
    }
    //底部友情链接
    module.bottomFriendsLinks = function (data) {
        if (data.code == 200) {
            var content = data.data;
            //console.log(content)
            module.data.friendsLinksList = content;
            var friendsLinksData = template('friendsLinksData', module.data);
            $("#friendsLinksContent").html(friendsLinksData);
        }
    }

    //获取类型
    module.getType = function(type){
        if (type == 'info'){
            document.getElementById("icon-list1").click();
        }
        if (type == 'demand'){
            document.getElementById("icon-list2").click();
        }
        if (type == 'interact'){
            document.getElementById("icon-list3").click();
        }
        if (type == 'bidding'){
            document.getElementById("icon-list4").click();
        }
        if (type == 'goDemand'){
            document.getElementById("icon-list2").click();
            document.getElementById("goSupply").click();
        }
        if (type == 'goInteract'){
            document.getElementById("icon-list3").click();
            document.getElementById("goRelease").click();
        }
    }

    //个人中心用户信息
    module.userData = function(data){
        if (data.code == 200) {
            var content = data.user;
            //console.log(content)
            module.data.userId = content.userId;
            tools.doGet(userMember + '/' + content.userId, {}, module.userMember);//memberType 1个人 2单位
        }
    }

    //个人中心用户资料
    module.userMember = function(data){
        if (data.code == 200) {
            var content = data.data;
            //console.log(data)
            module.data.userInformationDetail = content;
            module.data.memberType = content.memberType;


            if(content.memberType == '1'){
                document.getElementById('companyInformationContent').style.display = 'none';
                document.getElementById('userInformationContent').style.display = 'block';
                var userInformationData = template('userInformationData', module.data);
                $("#userInformationContent").html(userInformationData);
            }else{
                document.getElementById('companyInformationContent').style.display = 'block';
                document.getElementById('userInformationContent').style.display = 'none';
                var companyInformationData = template('companyInformationData', module.data);
                $("#companyInformationContent").html(companyInformationData);
            }
            document.getElementById('bankAddress').value = content.bankAddress;
            document.getElementById('bankCardName').value = content.bankCardName;
            document.getElementById('bankCardNum').value = content.bankCardNum;
            document.getElementById('phone').innerHTML = content.phone;

            module.data.memberId = content.id;
            //console.log(module.data.userId)

            //用户图片
            tools.doGet(showUserImg+'/'+module.data.memberId, {}, module.showUserImage);
            //我的供求
            tools.doGet(userSupply, {memberId:content.id,pageNum:module.data.pageNum,pageSize:10}, module.userSupply);
            //我的咨询
            tools.doGet(userConsulting, {memberId:content.id,pageNum:module.data.pageNum,pageSize:module.data.pageSize}, module.consulting);
            //我的竞价
            tools.doGet(userBidding, {memberId:content.id,pageNum:module.data.pageNum,pageSize:module.data.pageSize}, module.bidding);
            //个人资料提交
            $('#supplyAction').on('click', module.supplyAction)
            $('#releaseAction').on('click', module.releaseAction)

            //获取附件的值
            //$('#upLoadBtn').on('click',module.upLoadAction)

            //document.getElementById('userAction').addEventListener('click',module.formAction);
        }
    }

    module.showUserImage = function(data){
        //console.log(data)
        if (data.code == 200) {
            var content = data.data;
            var fileUrlList = [];
            var fileNum = [];
            for (var i = 0 ; i < content.length ; i++){
                fileUrlList[i] = serverApi + content[i].fileUrl ;
                fileNum[i] = content[i].id;
            }
            if (fileUrlList.length == 0){
                fileUrlList = '';
            }
            //console.log(fileUrlList)
            module.data.fileNum = fileNum;
            if(module.data.memberType == '1'){
                var cupload2 = new Cupload ({
                    ele: '#cupload-3',
                    num: 5,
                    data:fileUrlList
                });
            }else{
                var cupload2 = new Cupload ({
                    ele: '#cupload-2',
                    num: 5,
                    data:fileUrlList
                });
            }
        }
    }

    module.showSupplyImage = function(data){
        //console.log(data)
        if (data.code == 200) {
            var content = data.data;
            var fileUrlList = [];
            var fileNum = [];
            for (var i = 0 ; i < content.length ; i++){
                fileUrlList[i] = serverApi + content[i].fileUrl ;
                fileNum[i] = content[i].id;
            }
            if (fileUrlList.length == 0){
                fileUrlList = '';
            }
            //console.log(fileUrlList)
            document.getElementById('cupload-1').innerHTML = '';
            module.data.fileNum = fileNum;
            var cupload1 = new Cupload ({
                ele: '#cupload-1',
                num: 5,
                data:fileUrlList
            });
        }
    }

    deleteList = function(){
         //console.log(module.data.fileNum[deleteNum])
        tools.doGet(deleteUserImg+'/'+module.data.fileNum[deleteNum], {}, module.Tips);
    }

    module.getData = function(data){
        upLoadAction(data.data)
    }

     //获取上传图片list
    upLoadAction = function(type){
        //console.log(type)
        var upLoadList = [];
        var data = {};
        if(type == 'user'){
            if(module.data.memberType == '1'){
                $('#cupload-3').find('input').each(function() {
                    if($(this).val()!=''&&$(this).val().indexOf('http') == -1){
                        upLoadList.push($(this).val())
                    }
                })
            }else{
                $('#cupload-2').find('input').each(function() {
                    if($(this).val()!=''&&$(this).val().indexOf('http') == -1){
                        upLoadList.push($(this).val())
                    }
                })
            }
            data["tableName"] = 't_transaction_member';
            data["tableId"] = module.data.memberId;
        }else{
            $('#cupload-1').find('input').each(function() {
                if($(this).val()!=''&&$(this).val().indexOf('http') == -1){
                    upLoadList.push($(this).val())
                }
            })
            data["tableName"] = 't_transaction_supply_demand';
            data["tableId"] = type;
            setTimeout(function(){
                tools.doGet(userSupply, {memberId:module.data.memberId,pageNum:module.data.pageNum,pageSize:module.data.pageSize}, module.userSupply)
                document.getElementById('supplyInformation').style.display = "block";
                document.getElementById('releaseSupply').style.display = "none";
                $('#demandType').val('');
                $('#projectName').val('');
                $('#location').val('');
                $('#projectRealName').val('');
                $('#projectPhone').val('');
                $('#projectContent').val('');
            },2000)
        }

        data["files"] = upLoadList;
        data["fileType"] = '';
        data["bizPath"] = 'transaction';
        tools.doPostImg(base64Attach, data, module.upLoadOver);//memberType 1个人 2单位
        tools.initError('发布成功');

    }

    module.upLoadOver = function(){

    }

    //删除供求
    deleteUserSupply = function(ids){
        tools.doGet(deleteSupply+'/'+ids, {}, module.Tips);
    }

    //个人中心我的供求
    module.userSupply = function(data){
        //console.log(data)
        if (data.code == 200) {
            var content = data.rows;
            //console.log(data)
            var pageCount = (data.total/10).toFixed(0);
            if (pageCount < 1){
                pageCount = 1;
            }
            if(module.data.userSupplyInformationList == ''){
                $('.page_s1').html('');
                // 初始化 分页器
                var page_s1 = createPage('.page_s1');
                // 设置分页
                setPage(page_s1, {
                    pageTotal: data.total, // 数据总条数
                    pageSize: 10,    // 每页显示条数
                    pageCurrent: 1,  //  当前页
                    maxBtnNum: 5,   // 最多按钮个数  （最少5个）
                })
                $('#page_s1').html('共' + pageCount + '页')

            }
            module.data.userSupplyInformationList = content;
            var userSupplyInformationData = template('userSupplyInformationData', module.data);
            $("#userSupplyInformationContent").html(userSupplyInformationData);
        }
    }

    //个人中心我的咨询
    module.consulting = function(data){
        if (data.code == 200) {
            var content = data.rows;
            //console.log(data )
            var pageCount = (data.total/module.data.pageSize).toFixed(0);
            if (pageCount < 1){
                pageCount = 1;
            }
            $('.page_s2').html('');
            // 初始化 分页器
            var page_s1 = createPage('.page_s2');
            // 设置分页
            setPage(page_s1, {
                pageTotal: data.total, // 数据总条数
                pageSize: module.data.pageSize,    // 每页显示条数
                pageCurrent: 1,  //  当前页
                maxBtnNum: 5,   // 最多按钮个数  （最少5个）
            })
            module.data.consultingInformationList = content;
            $('#page_s2').html('共'+pageCount+'页')
            var consultingInformationData = template('consultingInformationData', module.data);
            $("#consultingInformationContent").html(consultingInformationData);
        }
    }

    //个人中心我的竞价
    module.bidding = function(data){
        if (data.code == 200) {
            var content = data.rows;
            //console.log(content)
            var pageCount = (data.total/module.data.pageSize).toFixed(0);
            if (pageCount < 1){
                pageCount = 1;
            }
            if(module.data.biddingInformationList == '') {
                // 初始化 分页器
                var page_s1=createPage('.page_s3');
                // 设置分页
                setPage(page_s1, {
                    pageTotal: data.total, // 数据总条数
                    pageSize: module.data.pageSize,    // 每页显示条数
                    pageCurrent: 1,  //  当前页
                    maxBtnNum: 5,   // 最多按钮个数  （最少5个）
                })
                $('#page_s3').html('共' + pageCount + '页')
            }
            module.data.biddingInformationList = content;
            var biddingInformationData = template('biddingInformationData', module.data);
            $("#biddingInformationContent").html(biddingInformationData);
        }
    }

    tabCheck = function(type){
        document.getElementById('user').className = '';
        document.getElementById('bank').className = '';
        document.getElementById('passWord').className = '';
        document.getElementById(type).className = 'active';

        //console.log(type)
        document.getElementById('userInformationContent').style.display = 'none';
        document.getElementById('companyInformationContent').style.display = 'none';
        document.getElementById('bankInformationContent').style.display = 'none';
        document.getElementById('phoneInformationContent').style.display = 'none';
        document.getElementById('passWordInformationContent').style.display = 'none';
        if (module.data.memberType == '2' && type == 'user'){
            document.getElementById('companyInformationContent').style.display = 'block';
        }else if (module.data.memberType == '1' && type == 'user'){
            document.getElementById('userInformationContent').style.display = 'block';
        }else{
            document.getElementById(type+'InformationContent').style.display = 'block';
        }

    }

    phoneUpdate = function(type){
        document.getElementById(type+'InformationContent').style.display = 'none';
        document.getElementById('phoneInformationContent').style.display = 'block';
    }

    tabLeftCheck = function(type){
        for (var i = 1 ; i < 5 ; i++){
            document.getElementById('icon-list'+i).className = '';
        }
        document.getElementById(type).className = 'active';
        document.getElementById('userInformation').style.display = 'none';
        document.getElementById('supplyInformation').style.display = 'none';
        document.getElementById('consultingInformation').style.display = 'none';
        document.getElementById('biddingInformation').style.display = 'none';

        document.getElementById('releaseSupply').style.display = 'none';
        document.getElementById('release').style.display = 'none';

        if(type == 'icon-list1'){
            document.getElementById('userInformation').style.display = 'block';
        }
        if(type == 'icon-list2'){
            document.getElementById('supplyInformation').style.display = 'block';
            module.data.clickType = 'supply';
            $('#demandType').val('');
            $('#projectName').val('');
            $('#location').val('');
            $('#projectRealName').val('');
            $('#projectPhone').val('');
            $('#projectContent').val('');
        }
        if(type == 'icon-list3'){
            document.getElementById('consultingInformation').style.display = 'block';
            module.data.clickType = 'consulting';
            $('#title').val('');
            $('#releaseContent').val('');
            $('#releaseRealName').val('');
            $('#releasePhone').val('');
        }
        if(type == 'icon-list4'){
            document.getElementById('biddingInformation').style.display = 'block';
            module.data.clickType = 'bidding';
        }
        module.data.pageNum = 1 ;
    }

    goSupply = function(){
        document.getElementById('supplyInformation').style.display = "none";
        document.getElementById('releaseSupply').style.display = "block";
        document.getElementById('cupload-1').innerHTML = '';
        var cupload1 = new Cupload ({
            ele: '#cupload-1',
            num: 5,
        });
    }

    gosupplyTable = function(){
        document.getElementById('supplyInformation').style.display = "block";
        document.getElementById('releaseSupply').style.display = "none";
        $('#demandType').val('');
        $('#projectName').val('');
        $('#location').val('');
        $('#projectRealName').val('');
        $('#projectPhone').val('');
        $('#projectContent').val('');
    }

    goRelease = function(){
        document.getElementById('consultingInformation').style.display = "none";
        document.getElementById('release').style.display = "block";
    }

    goReleaseTable = function(){
        document.getElementById('consultingInformation').style.display = "block";
        document.getElementById('release').style.display = "none";
        $('#title').val('');
        $('#releaseContent').val('');
        $('#releaseRealName').val('');
        $('#releasePhone').val('');
    }

    //翻页
    turnThePage = function (pageNum) {
        module.data.pageNum = pageNum ;
        if(module.data.clickType == 'supply'){
            tools.doGet(userSupply, {memberId:module.data.memberId,pageNum:pageNum,pageSize:module.data.pageSize}, module.userSupply);
        }
        if(module.data.clickType == 'consulting'){
            tools.doGet(userConsulting, {memberId:module.data.memberId,pageNum:pageNum,pageSize:module.data.pageSize}, module.consulting);
        }
        if(module.data.clickType == 'bidding'){
            tools.doGet(userBidding, {memberId:module.data.memberId,pageNum:pageNum,pageSize:module.data.pageSize}, module.bidding);
        }
    }

    //个人用户资料修改
    formAction = function (type){
        var data = {};
        //var password = $('#password').val();
        module.data.userFormType = type ;
        if(type == 'company'){
            //公司用户信息
            var companyName = $('#companyName').val();
            var idCardNum = $('#idCardNum').val();
            var realname = $('#realname').val();
            var companyCode = $('#companyCode').val();
            var companyNature = $('#companyNature').val();
            var companyScope = $('#companyScope').val();
            var companyTimeLimit = $('#companyTimeLimit').val();
            var companySetupTime = $('#companySetupTime').val();
            var companyCapital = $('#companyCapital').val();
            var companyLicense = $('#companyLicense').val();
            var address = $('#address').val();
            data['companyName'] = companyName;
            data['idCardNum'] = idCardNum;
            data['realname'] = realname;
            data['companyCode'] = companyCode;
            data['companyName'] = companyName;
            data['companyNature'] = companyNature;
            data['companyScope'] = companyScope;
            data['companyTimeLimit'] = companyTimeLimit;
            data['companySetupTime'] = companySetupTime;
            data['companyCapital'] = companyCapital;
            data['companyLicense'] = companyLicense;
            data['address'] = address;

            tools.setCookie('userName',realname,24 * 60 * 60)
            tools.setCookie('idCardNum',idCardNum,24 * 60 * 60)
            tools.setCookie('address',address,24 * 60 * 60)
            upLoadAction('user');
        }
        if(type == 'user'){
            //个人用户信息
            var userFormRealName = $('#userFormRealName').val();
            var userFormIdCard = $('#userFormIdCard').val();
            var userFormAddress = $('#userFormAddress').val();
            data['idCardNum'] = userFormIdCard;
            data['realname'] = userFormRealName;
            data['address'] = userFormAddress;

            tools.setCookie('userName',userFormRealName,24 * 60 * 60)
            tools.setCookie('idCardNum',userFormIdCard,24 * 60 * 60)
            tools.setCookie('address',userFormAddress,24 * 60 * 60)
            upLoadAction('user');
        }
        if(type == 'bank'){
            //银行卡信息
            var bankCardName = $('#bankCardName').val();
            var bankCardNum = $('#bankCardNum').val();
            var bankAddress = $('#bankAddress').val();
            data['bankCardName'] = bankCardName;
            data['bankCardNum'] = bankCardNum;
            data['bankAddress'] = bankAddress;
            tools.setCookie('bankCardName',bankCardName,24 * 60 * 60)
            tools.setCookie('bankCardNum',bankCardNum,24 * 60 * 60)
            tools.setCookie('bankAddress',bankAddress,24 * 60 * 60)
        }
        //data['password'] = password;
        data['id'] = module.data.memberId;

        tools.doPost(userUpdate, data, module.Tips)
    }

    editPassword = function(){
        var data = {};
        if(module.passWordCompare()){
            var oldPassWord = $('#originalPassWord').val();
            var newPassWord = $('#newPassWord').val();
            data['oldPassword'] = oldPassWord;
            data['newPassword'] = newPassWord;
            tools.doPost(updatePwd, data, module.Tips)
        }
    }

    //手动验证密码是否一致
    module.passWordCompare = function(){
        var newPassword = $('#newPassWord').val();
        var determinePassWord = $('#determinePassWord').val();
        var originalPassWord = $('#originalPassWord').val();
        /*原密码*/
        if (originalPassWord == '') {
            $('#originalPassWord')[0].focus()
            tools.initTips('请输入原密码', 'right', $('#originalPassWord')[0], 2000)
            return false;
        }
        /* 新密码 */
        if (newPassword == '') {
            $('#newPassWord')[0].focus()
            tools.initTips('请输入新密码', 'right', $('#newPassWord')[0], 2000)
            return false;
        }
        /* 确认密码 */
        if (determinePassWord == '') {
            $('#determinePassWord')[0].focus()
            tools.initTips('请确认密码', 'right', $('#determinePassWord')[0], 2000)
            return false;
        }
        return true;
    }

    //发布供求
    module.supplyAction = function (){
        var data = {};
        if(module.supplyCheck()){
            //供求信息
            var demandType = $('#demandType').val();
            var projectName = $('#projectName').val();
            var location = $('#location').val();
            var projectRealName = $('#projectRealName').val();
            var projectPhone = $('#projectPhone').val();
            var projectContent = $('#projectContent').val();
            var logintime = tools.getNowFormatDate();

            //console.log(demandType);
            data['projectName'] = projectName;
            data['location'] = location;
            data['realname'] = projectRealName;
            data['phone'] = projectPhone;
            data['projectContent'] = projectContent;
            data['logintime'] = logintime;
            data['supplyDemandType'] = demandType;
            data['deptId'] = 100;

            data['memberId'] = module.data.memberId;

            if(module.data.supplyType == 'edit'){
                tools.doPost(userEdit, data, module.getData)
            }else{
                tools.doPost(userDemand, data, module.getData)
            }

        }
    }

    //发布咨询
    module.releaseAction = function (){
        var data = {};
        if(module.releaseCheck()){
            //供求信息
            var title = $('#title').val();
            var releaseContent = $('#releaseContent').val();
            var releaseRealName = $('#releaseRealName').val();
            var releasePhone = $('#releasePhone').val();
            var logintime = tools.getNowFormatDate();

            data['title'] = title;
            data['content'] = releaseContent;
            data['realname'] = releaseRealName;
            data['phone'] = releasePhone;
            data['logintime'] = logintime;
            data['deptId'] = 100;
            data['memberId'] = module.data.memberId;

            tools.doPost(userCommunicate, data, module.releaseActionYes)
        }
    }
    module.releaseActionYes = function(data){
        tools.initError(data.msg);
        setTimeout(function(){
            tools.doGet(userConsulting, {memberId:module.data.memberId,pageNum:module.data.pageNum,pageSize:module.data.pageSize}, module.consulting);
            document.getElementById('consultingInformation').style.display = "block";
            document.getElementById('release').style.display = "none";
            $('#title').val('');
            $('#releaseContent').val('');
            $('#releaseRealName').val('');
            $('#releasePhone').val('');
        },2000)

    }
    module.Tips = function(data){

        tools.initError(data.msg);
    }

    //手动验证表单
    module.check = function () {
        var usernameVal = $('#username').val();
        var passwordVal = $('#password').val();
        var codeVal = $('#code').val();
        /* 手机号 */
        if (usernameVal == '') {
            $('#username')[0].focus()
            tools.initTips('请输入用户名', 'right', $('#username')[0], 2000)
            return false;
        }
        /* 密码 */
        if (passwordVal == '') {
            $('#password')[0].focus()
            tools.initTips('请输入密码', 'right', $('#password')[0], 2000)
            return false;
        } else if (parseInt(passwordVal.length) < 6 || parseInt(passwordVal.length) > 18) {
            $('#password')[0].focus()
            tools.initTips('请输入正确格式密码', 'right', $('#password')[0], 2000)
            return false;
        }
        /*图形验证码*/
        if (module.uuid == '' || codeVal == '') {
            $('#code')[0].focus()
            tools.initTips('请输入图形验证码', 'right', $('#code')[0], 2000)
            return false;
        }
        return true;
    }

    module.supplyCheck = function () {
        var projectName = $('#projectName').val();
        var location = $('#location').val();
        var projectRealName = $('#projectRealName').val();
        var projectPhone = $('#projectPhone').val();
        var projectContent = $('#projectContent').val();
        if (projectName == '') {
            $('#projectName')[0].focus()
            tools.initTips('请输入项目名称', 'right', $('#projectName')[0], 2000)
            return false;
        }
        if (location == '') {
            $('#location')[0].focus()
            tools.initTips('请输入项目地址', 'right', $('#location')[0], 2000)
            return false;
        }
        if (projectRealName == '') {
            $('#projectRealName')[0].focus()
            tools.initTips('请输入姓名', 'right', $('#projectRealName')[0], 2000)
            return false;
        }
        if (projectPhone == '') {
            $('#projectPhone')[0].focus()
            tools.initTips('请输入联系电话', 'right', $('#projectPhone')[0], 2000)
            return false;
        }
        if (projectContent == '') {
            $('#projectContent')[0].focus()
            tools.initTips('请输入项目详情', 'right', $('#projectContent')[0], 2000)
            return false;
        }
        return true;
    }

    module.releaseCheck = function () {
        var title = $('#title').val();
        var releaseContent = $('#releaseContent').val();
        var releaseRealName = $('#releaseRealName').val();
        var releasePhone = $('#releasePhone').val();
        if (title == '') {
            $('#title')[0].focus()
            tools.initTips('请输入标题', 'right', $('#title')[0], 2000)
            return false;
        }
        if (releaseContent == '') {
            $('#releaseContent')[0].focus()
            tools.initTips('请输入咨询内容', 'right', $('#releaseContent')[0], 2000)
            return false;
        }
        if (releaseRealName == '') {
            $('#releaseRealName')[0].focus()
            tools.initTips('请输入姓名', 'right', $('#releaseRealName')[0], 2000)
            return false;
        }
        if (releasePhone == '') {
            $('#releasePhone')[0].focus()
            tools.initTips('请输入联系电话', 'right', $('#releasePhone')[0], 2000)
            return false;
        }
        return true;
    }

    //个人中心选项卡鼠标悬浮
    module.userListHover = function(){
        document.getElementById('icon-list1').onmouseout = function(){
            document.getElementById('icon1').src = '../../static/images/user_index_icon1.png'
        }
        document.getElementById('icon-list1').onmouseover = function(){
            if(themeColor == 'red'){
                document.getElementById('icon1').src = '../../static/images/user_index_icon5_red.png'
            }else if(themeColor == 'green'){
                document.getElementById('icon1').src = '../../static/images/user_index_icon5.png'
            }
        }

        document.getElementById('icon-list2').onmouseout = function(){
            document.getElementById('icon2').src = '../../static/images/user_index_icon2.png'
        }
        document.getElementById('icon-list2').onmouseover = function(){
            if(themeColor == 'red'){
                document.getElementById('icon2').src = '../../static/images/user_index_icon6_red.png'
            }else if(themeColor == 'green') {
                document.getElementById('icon2').src = '../../static/images/user_index_icon6.png'
            }
        }

        document.getElementById('icon-list3').onmouseout = function(){
            document.getElementById('icon3').src = '../../static/images/user_index_icon3.png'
        }
        document.getElementById('icon-list3').onmouseover = function(){
            if(themeColor == 'red'){
                document.getElementById('icon3').src = '../../static/images/user_index_icon7_red.png'
            }else if(themeColor == 'green') {
                document.getElementById('icon3').src = '../../static/images/user_index_icon7.png'
            }
        }

        document.getElementById('icon-list4').onmouseout = function(){
            document.getElementById('icon4').src = '../../static/images/user_index_icon4.png'
        }
        document.getElementById('icon-list4').onmouseover = function(){
            if(themeColor == 'red'){
                document.getElementById('icon4').src = '../../static/images/user_index_icon8_red.png'
            }else if(themeColor == 'green') {
                document.getElementById('icon4').src = '../../static/images/user_index_icon8.png'
            }
        }


    }

    goSearch = function () {
        var searchTitle = $('#searchTitle').val();
        var searchContent = $('#searchContent').val();
        //console.log(searchTitle)
        module.data.searchType = 'YES';
        tools.doGet(userConsulting,{title:searchTitle,content:searchContent,memberId:module.data.memberId,pageNum:module.data.pageNum,pageSize:module.data.pageSize},module.consulting);
    }

    selectUserSupply = function(ids) {
        module.data.supplyType = 'edit'
        //console.log('点击修改')
        tools.doGet(selectSupply + '/' + ids, {}, module.selectSupplyDetail);//memberType 1个人 2单位
    }
    module.selectSupplyDetail = function(data){
        console.log('进入修改供求')
        document.getElementById('supplyInformation').style.display = "none";
        document.getElementById('releaseSupply').style.display = "block";

        var content = data.data

        $('#demandType').val(content.supplyDemandType);
        $('#projectName').val(content.projectName);
        $('#location').val(content.location);
        $('#projectRealName').val(content.realname);
        $('#projectPhone').val(content.phone);
        $('#projectContent').val(content.projectContent);

        tools.doGet(supplyDemandImg+'/'+content.id, {}, module.showSupplyImage);
    }

    goProject = function(id){
        tools.skip('../listingItems/itemsDetail.html?id='+id)
    }

    return module;
});