﻿var web960vue = {
    robotassistant: function (el, cfg) {
        var data = $.extend({
            questions: [
                { words: "Hi~欢迎访问药筛网！我是小药，快来告诉我你想做什么吧！", waitinput: false },
                { words: "您怎么称呼？", field: "contact", waitinput: true },
                {
                    words: "给我留个联系方式吧 ！", field: "imtype", options: [
                        { title: "电话", value: "电话", selected: true },
                        { title: "微信", value: "微信" },
                        { title: "QQ", value: "QQ" }
                    ], waitinput: true
                },
                { words: "", field: "imcontact", waitinput: true },
                { words: "好的，我们尽快与您取得联系", waitinput: false }
            ],
            startindex: 0,
            mined: true,
            firstclicked: true,
            formdata: {
                contact: "",
                imtype: "",
                imcontact: ""
            }, speekword: "",
            speeklog: [],
            submited: false,
            canspeek: true,

            thisoptionwords: { options: [] }
        }, cfg);
        window.robotassistant = new Vue({
            el: el,
            data: data,
            methods: {
                open: function () {

                    var _s = this;
                    _s.mined = false;
                    if (_s.firstclicked) {
                        _s.begintalk();
                        _s.firstclicked = false;
                    }
                },
                begintalk: function () {
                    var _s = this;
                    if (_s.startindex < _s.questions.length) {
                        var witem = _s.questions[_s.startindex];
                        _s.speeklog.push({ role: "master", speek: witem });

                        if (witem.options != null) {
                            _s.thisoptionwords = JSON.parse(JSON.stringify(witem));

                        }
                        else {

                            _s.thisoptionwords = { options: [] };

                        }

                        if (witem.waitinput == false) {

                            setTimeout(function () { _s.startindex++; _s.begintalk() }, 1000);
                        }


                    }
                    else {
                        _s.canspeek = false;
                        if (!_s.submited) {
                            //提交到后台

                            var postdata = {
                                title: "智能客服交互留言",
                                user: _s.formdata.contact
                            };


                            postdata.usecap = 0;

                            postdata.otherinfo = JSON.stringify(_s.formdata);

                            postdata.t = 103;


                            jQuery.post("/index.aspx?a=g",
                                postdata
                                , function (ret) {

                                    if (ret.result == "1") {

                                    }

                                });

                            console.log(_s.formdata);
                            _s.submited = true;
                        }
                    }
                    setTimeout(function () {
                        var container = _s.$el.querySelector(".robotassistant_content");

                        container.scrollTop = container.scrollHeight;
                    }, 200);

                },
                speekinput: function () {
                    var _s = this;
                    if (_s.speekword != "") {

                        if (this.startindex < this.questions.length) {
                            var witem = this.questions[this.startindex];
                            if (witem.field != null && witem.field != "") {
                                _s.formdata[witem.field] = _s.speekword;
                            }
                        }
                        else {


                        }
                        _s.speeklog.push({ role: "user", speek: { words: _s.speekword } });
                        _s.speekword = "";
                        this.startindex++;
                        _s.begintalk();
                    }
                },
                seloption: function (item) {
                    var _s = this;
                    if (_s.thisoptionwords.field != null && _s.thisoptionwords.field != "") {
                        _s.formdata[_s.thisoptionwords.field] = item.value;
                    }
                    _s.speeklog.push({ role: "user", speek: { words: item.title } });
                    this.startindex++;
                    _s.begintalk();
                }
            },
            computed: {
                haveoptions: function () {
                    return this.thisoptionwords.options.length > 0;
                }
            },
            mounted: function mounted() {

            }
        });
    },
    userinfo: null,
    userinfoloaded:false,
    search: function (el, cfg) {
        var data = $.extend({
            querykeytype: { title: "", value: "" },
            searchtype: 100,
            querykeytypes: [],
            searchkey: "",
            shopcartcount: 0,
            userinfo: {
                shopcartcount:0
            }
        }, cfg);
        window.search = new Vue({
            el: el,
            data: data,
            methods: {
                gosearch: function () {
                    if (this.searchkey != "") {
                        if (this.querykeytype.value == "") {
                            alert("请选择搜索类型");
                        }
                        else {
                            if (this.querykeytype.value == "smiles") {
                                var inputdata = {
                                    query: this.searchkey ,
                                    min: "",
                                    max: "",
                                    country: "CHINA",
                                    matchtype: "DUPLICATE",
                                    chemtype: "",
                                    proviewtype: "bestinpack",
                                };
                                if ($("#batchsearchform").length == 0) {
                                    $("body").append('<form target="_self" id="batchsearchform" name="batchsearchform" method="post" action="/search.do?a=batchsearch" ><input type="hidden" id="batchquery" name="batchquery" /> </form>');
                                }
                                var _s = this;

                                $("#batchquery").val(JSON.stringify(inputdata));
                                $("#batchsearchform").eq(0).submit();
                            }
                            else {
                                location.href = "/search.do?s=a&querykeytype=" + this.querykeytype.value + "&searchtype=" + this.searchtype + "&q=" + escape(this.searchkey);
                            }
                        }
                    }


                },
                loaduserinfo: function () {
                    var _s = this;
                    if (web960vue.userinfoloaded == false) {

                        web960vue.userinfoloaded = true;
                        wucapi.post("user/checkinfo", { scope: ["shopcartitems"] }).then(function (ret) {
                            if (ret.data["notlogin"] == undefined) {
                                _s.userinfo = ret.data;
                                web960vue.userinfo = _s.userinfo;
                                console.log($("span[dataref='shopcartcount']").length);
                            }
                            $("span[dataref='shopcartcount']").html(_s.userinfo.shopcartcount);
                        });
                    }
                    else {
                        _s.userinfo = web960vue.userinfo;
                        console.log(_s.userinfo);
                    }
                  
                }
            },
            mounted: function mounted() {
                this.loaduserinfo();
            }
        });
    },
    chemicalsearch: function (el, cfg) {
        var data = $.extend(true,{
            currentnav: "structruesearch",
            structruesearch: {
                changeMrvToSmilesUrl: "https://query.hitstructure.com:8443/webservices/rest-v0/util/calculate/molExport",

                couponList: [

                    {
                        id: 'FULL',
                        name: '完美搜索'
                    },
                    {
                        id: 'DUPLICATE',
                        name: '接受消旋/异构体'
                    },

                    {
                        id: 'SUBSTRUCTURE',
                        name: '亚结构搜索'
                    },
                    {
                        id: 'SIMILARITY',
                        name: '相似度搜索'
                    },
                ],
                data: {
                    couponSelected: "FULL",
                    similarity: 80,
                    getcount: 100,
                    filteroption:"aa"
                }
            },
            batchsearch: {
                searchtype: "input",
                inputdata: {
                    query: "",
                    min: "",
                    max: "",
                    country: "CHINA",
                    matchtype: "DUPLICATE",
                    chemtype: "",
                    proviewtype: "bestinpack",
                },
                importdata: {
                    min: "",
                    max: "",
                    query:"",
                    country: "CHINA",
                    matchtype: "DUPLICATE",
                    chemtype: "",
                    proviewtype: "bestinpack",
                    filepath: "",
                    uploaded:false
                }
            },

            customsynthesis: {
                formdata: {
                    customsynthesis: {
                        shuliang: "",
                        price: "",
                        huoqi: "",
                        chundu: "",
                        lxr: "",
                        danwei: "",
                        email: "",
                        shouji: "",
                        structure:""
                    },
                    content:""
                }
            },
            initmol:""

        }, cfg);
        window.chemicalsearch = new Vue({
            el: el,
            data: data,
            computed: {
                showSimilarity: function () {
                    return this.structruesearch.data.couponSelected == "SIMILARITY";
                },
                batchsearchinputformvalid: function () {
                    _s = this;
                    return _s.batchsearch.inputdata.query != "" && _s.batchsearch.inputdata.min != "" && _s.batchsearch.inputdata.country != "";
                },
                batchsearchimportformvalid: function () {
                    _s = this;
                    return _s.batchsearch.importdata.query != "" && _s.batchsearch.importdata.min != ""  && _s.batchsearch.importdata.country != "";
                }
            },
            methods: {
                gosearch: function () {

                },
                gotocustomsynthesis: function () {
                    $("#mycustomdingzhiModal").modal();
                },
                savecustomsynthesis: function () {
                    var _s = this;
                    MarvinJSUtil.getEditor("#custom_sketch").then(function (sketcherInstance) {
                        sketcherInstance.exportStructure("mrv").then(function (source) {


                            if (sketcherInstance.isEmpty() || !source || null == source || "" == source) {

                                alert("请画出结构式");
                                return false;
                            }

                            var r = _s.changeMrvToSmiles(source);
                            if (r != null && r["structure"] != null) {


                                var formdata = _s.customsynthesis.formdata;
                                var postdata = {
                                    title: "定制合成",
                                    user: formdata.customsynthesis.lxs
                                };
                                formdata.customsynthesis["structure"] = r.structure;

                                postdata.usecap = 0;
                                postdata.content = formdata.content
                                postdata.otherinfo = JSON.stringify({ customsynthesis: formdata.customsynthesis  });

                                postdata.t = 106;


                                jQuery.post("/index.aspx?a=g",
                                    postdata
                                    , function (ret) {

                                        if (ret.result == "1") {
                                            alert("提交成功");
                                            $("#mycustomdingzhiModal").modal("hide");
                                        }

                                    });
                            }
                        });

                    }, function (error) {
                    });
                   
                    

                },
                uploadfile: function (e) {
                    var _s = this;
                    _s.batchsearch.importdata.query = "";
                  
                    let file = e.target.files[0];
                    let param = new FormData(); //创建form对象
                    param.append('imsearch_file_upload', file);//通过append向form对象添加数据
                  //  console.log(param.get('file')); //FormData私有类对象，访问不到，可以通过get判断值是否传进去
                    let config = {
                        headers: { 'Content-Type': 'multipart/form-data' }
                    }; //添加请求头
                    axios.post('/ucapi.aspx?action=file/import', param, config)
                        .then(response => {
                            var ret = response.data;
                            if (ret.data.result == "1") {
                                _s.batchsearch.importdata.uploaded = true;
                                _s.batchsearch.importdata.query = ret.data.data;
                            }
                            else {
                                alert(ret.data.message);
                            }
                            console.log(response.data);
                        })
                },
                batchsearchbyinput: function () {

                    if ($("#batchsearchform").length == 0) {
                        $("body").append('<form target="_self" id="batchsearchform" name="batchsearchform" method="post" action="/search.do?a=batchsearch" ><input type="hidden" id="batchquery" name="batchquery" /> </form>');
                    }
                    var _s = this;

                    $("#batchquery").val(JSON.stringify(_s.batchsearch.inputdata));
                    $("#batchsearchform").eq(0).submit();

                    console.log(this.batchsearch.inputdata);
                },
                batchsearchbyimport: function () {
                    if ($("#batchsearchform").length == 0) {
                        $("body").append('<form target="_self" id="batchsearchform" name="batchsearchform" method="post" action="/search.do?a=batchsearch" ><input type="hidden" id="batchquery" name="batchquery" /> </form>');
                    }
                    var _s = this;

                    $("#batchquery").val(JSON.stringify(_s.batchsearch.importdata));
                    $("#batchsearchform").eq(0).submit();
                    console.log(this.batchsearch.importdata);
                },

                gotostructruesearch: function () {
                    var _s = this;
                    //marvinSketcherInstance.exportStructure("mol").then(function (source) {
                    //    console.log(source);
                    //});
                    //return false;
                    marvinSketcherInstance.exportStructure("mrv").then(function (source) {


                        if (marvinSketcherInstance.isEmpty() || !source || null == source || "" == source) {

                            alert("请画出结构式");
                            return false;
                        }

                        var r = _s.changeMrvToSmiles(source);
                        if (r != null && r["structure"] != null) {
                            if ($("#structruesearchform").length == 0) {
                                $("body").append('<form target="_self" id="structruesearchform" name="structruesearchform" method="post" action="/search.do?a=structuresearch" ><input type="hidden" id="structruesearchquery" name="structuresearchquery" /> </form>');
                            }
                            var postdata = JSON.parse(JSON.stringify(_s.structruesearch.data));
                            postdata["structure"] = r["structure"];

                            postdata["cml"] = source;


                            $("#structruesearchquery").val(JSON.stringify(postdata));
                            $("#structruesearchform").eq(0).submit();
                            return false;
                            var smiles = r["structure"];
                            let searchOptions = {};
                            if (_s.structruesearch.data.couponSelected === "SIMILARITY") {
                                searchOptions = {
                                    "queryStructure": smiles,
                                    "searchType": _s.structruesearch.data.couponSelected,
                                    "similarity": {
                                        "descriptor": "CFP",
                                        "threshold": _s.structruesearch.data.similarity / 100
                                    }
                                }
                            } else {
                                searchOptions = {
                                    "queryStructure": smiles,
                                    "searchType": _s.structruesearch.data.couponSelected,
                                }
                            }
                            var conditionsData = {};

                            if (_s.structruesearch.data.filteroption != "" && _s.structruesearch.data.filteroption != "aa") {
                                conditionsData[_s.structruesearch.data.filteroption] = { $eq: 1 };
                            }

                            var searchData = {
                                "searchOptions": searchOptions,
                                "filter": {
                                    "conditions": conditionsData,
                                    "orderBy": "-cd_id"
                                },
                                "paging": {
                                    "offset": 0,
                                    "limit": 10
                                },
                                "display": {

                                    "include": ["cd_id", "cd_structure", "cd_molweight", "type"],

                                    "additionalFields": {
                                        "mrv": "chemicalTerms(molformat(\"mrv\"))"
                                    }
                                }
                            };
                            searchData = { "searchOptions": { "queryStructure": "<cml xmlns=\"http://www.chemaxon.com\" version=\"ChemAxon file format v18.11.0, generated by vunknown\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.chemaxon.com http://www.chemaxon.com/marvin/schema/mrvSchema_18_11_0.xsd\"><MDocument><MChemicalStruct><molecule molID=\"m1\"><atomArray><atom id=\"a1\" elementType=\"C\" x2=\"-3.9167599999992513\" y2=\"0.06092665434591904\"/><atom id=\"a2\" elementType=\"C\" x2=\"-5.250306655997546\" y2=\"-0.70907333949408\"/><atom id=\"a3\" elementType=\"C\" x2=\"-5.250306655997546\" y2=\"-2.249259993839254\"/><atom id=\"a4\" elementType=\"C\" x2=\"-3.9167599999992513\" y2=\"-3.019259987679254\"/><atom id=\"a5\" elementType=\"C\" x2=\"-2.583026677335787\" y2=\"-2.249259993839254\"/><atom id=\"a6\" elementType=\"C\" x2=\"-2.583026677335787\" y2=\"-0.70907333949408\"/></atomArray><bondArray><bond id=\"b1\" atomRefs2=\"a1 a2\" order=\"2\"/><bond id=\"b2\" atomRefs2=\"a2 a3\" order=\"1\"/><bond id=\"b3\" atomRefs2=\"a3 a4\" order=\"2\"/><bond id=\"b4\" atomRefs2=\"a4 a5\" order=\"1\"/><bond id=\"b5\" atomRefs2=\"a5 a6\" order=\"2\"/><bond id=\"b6\" atomRefs2=\"a6 a1\" order=\"1\"/></bondArray></molecule></MChemicalStruct></MDocument></cml>", "searchType": "duplicate" }, "filter": { "conditions": {} }, "paging": { "offset": 0, "limit": 101 }, "display": { "include": ["cd_id", "cd_structure", "cd_molweight", "hit_id", "iupac", "traditionalaname", "smiles_str", "cas", "inchikey", "similarity", "type", "cd_formula"], "additionalFields": { "mrv": "chemicalTerms(molformat(\"mrv\"))" } } };

                            $.ajax({
                                type: "POST",
                                cache: false,
                                async: false,
                                url: "https://query.hitstructure.com:8443/webservices/rest-v0/data/taosu/table/compound_test/search",
                                contentType: 'application/json',
                                data: JSON.stringify(searchData),
                                success: function (data) {
                                    console.log(data);
                                    //dom_image.empty();

                                    //let rows = data.data;

                                    //for (var a = 0; a < rows.length; a++) {

                                    //    var imageData = rows[a]["cd_structure"]["image"];
                                    //    //   console.log("mrv :" +mrv);
                                    //    //     var aa ='<cml><MDocument><MChemicalStruct><molecule molID="m1"><atomArray><atom id="a1" elementType="C" x2="-10.333426666665918" y2="1.081759987679253"/><atom id="a2" elementType="C" x2="-11.666973322664212" y2="0.3117599938392539"/><atom id="a3" elementType="C" x2="-11.666973322664212" y2="-1.22842666050592"/><atom id="a4" elementType="C" x2="-10.333426666665918" y2="-1.99842665434592"/><atom id="a5" elementType="C" x2="-8.999693344002454" y2="-1.22842666050592"/><atom id="a6" elementType="C" x2="-8.999693344002454" y2="0.3117599938392539"/></atomArray><bondArray><bond atomRefs2="a1 a2" order="2" id="b1"/><bond atomRefs2="a2 a3" order="1" id="b2"/><bond atomRefs2="a3 a4" order="2" id="b3"/><bond atomRefs2="a4 a5" order="1" id="b4"/><bond atomRefs2="a5 a6" order="2" id="b5"/><bond atomRefs2="a6 a1" order="1" id="b6"/></bondArray></molecule></MChemicalStruct></MDocument></cml>' ;
                                    //    // var mol =    changeSmilesToMrv(mrv );
                                    //    // console.log("imageData :" +imageData["image"]);
                                    //    mrvToImg(imageData, a);
                                    //}
                                },
                                error: function (data) {
                                    alert("error");
                                },
                            });


                        }
                        //var data = {

                        //    inputFormat: "mrv",
                        //    parameters: "smiles",
                        //    structure: source,
                        //};
                        //wucapi.post("chemstructure/molExport", data).then(function (ret) {
                        //    console.log(ret);
                        //});

                    }, function (error) {
                        alert("Molecule export failed:" + error);
                    });

                },
                changeMrvToSmiles: function (source) {
                    var _s = this;
                    console.log("changeMrvToSmiles");
                    var smiles = "";
                    var data = {

                        inputFormat: "mrv",
                        parameters: "smiles",
                        structure: source,
                    };
                    $.ajax({
                        type: "POST",
                        cache: false,
                        async: false,
                        url: _s.structruesearch.changeMrvToSmilesUrl,
                        contentType: 'application/json',
                        data: JSON.stringify(data),
                        success: function (data) {
                            smiles = data;
                        },
                        error: function (data) {
                            alert("error");
                        },
                    });

                    return smiles;
                }


            },
            mounted: function mounted() {
                var _s = this;
                MarvinJSUtil.getEditor("#sketch").then(function (sketcherInstance) {
                    marvinSketcherInstance = sketcherInstance;
                    if (_s.initmol != null && _s.initmol != "") {
                        marvinSketcherInstance.importStructure("mol", _s.initmol).catch(function (error) {
                            console.log(error);
                        });
                    }
                   
                }, function (error) {
                });
                $('body').append($('<iframe>', { id: "marvinjs-iframe", src: "/content/marvinjs/marvinpack.html" }));
                MarvinJSUtil.getPackage("#marvinjs-iframe").then(function (marvinNameSpace) {
                    marvinNameSpace.onReady(function () {
                        marvin = marvinNameSpace;
                        // exportImages()
                    });
                }, function (error) {
                    alert("Cannot retrieve marvin instance from iframe:" + error);
                });
                if (location.hash == "#batchsearch") {
                    this.currentnav = "batchsearch";
                }
                else if (location.href == "#customsynthesis") {

                }
                /*
                var loginUrl = "http://81.68.71.34:8080/webservices/taoshu/rest-v0/login";
                var loginData = {
                    "username": "admin",
                    "password": "U1nAlvfm"
                }

                $.ajax({
                    type: "POST",
                    url: loginUrl,
                    xhrFields: {
                        withCredentials: true
                    },
                    data: JSON.stringify(loginData),
                    contentType: "application/json",
                    success: function (_data) {
                        console.log(_data);
                    }
                });
                */
            }
        });
    },
    loginapp: function (el, cfg) {
        var data = $.extend({
            currentnav: "login",
            logincallback:null,
            login: {
                error: "",
                verifybtndisabled: false,
                verifybtntxt: "获取验证码",
                verifyresult:"",
                pwdstrong: 0,

                formvalid: false,
                formerrs: [],
                formerrfield: [],
                data: {
                    username: "",
                    password: "",
                    remberpwd: false,
                    loginmethod: "password",
                    verifyid:"",
                    verifycode: ""
                }
            },
            regformdata: {
                contactuser: "",
                company: "",
                email: "",
                phone: "",
                verifycode: "",
                password: "",
                password2: "",
                verifycode: "",
                setsession: "1",
                regtype: "phone",
                verifytype: "sms",
                verifyid: ""
            },
            reg: {
                verifybtndisabled: false,
                verifybtntxt: "获取验证码",
                pwdstrong: 0,
                formvalid: false,
                formerrs: [],
                formerrfield: []
            },
            findpassword: {

                verifybtndisabled: false,
                verifybtntxt: "获取验证码",
                pwdstrong: 0,
                formvalid: false,
                formerrs: [],
                formerrfield: [],
                findwasswordsuccess: false
            },
            findpasswordformdata: {
                username: "",
                verifyid: "",
                password: "",
                password2: "",
                verifycode: ""
            },

            pwdstrongcolor: "#bbb",
            pwdstrongcolors: ["#f00", "#ff4a00", "green", "green", "green"]
        }, cfg);
        window.loginapp = new Vue({
            el: el,
            data: data,
            methods: {
       
                gologin: function () {
                    var _s = this;
                    var postdata = JSON.parse(JSON.stringify(this.login.data));
                    if (postdata.loginmethod == "password" && (postdata.username == '' || postdata.password == '')) {
                        return false;
                    }
                    else if (postdata.loginmethod == "verifycode" && (postdata.username == '' || postdata.verifycode == '')) {
                        return false;
                    }
                    $.post("/index.aspx?a=ajaxuserlogin", postdata, function (rv) {

                        if (rv.Status == "1") {
                            if (_s.logincallback != null) {
                                _s.logincallback();
                            }
                            else {
                                location.href = rv.StrResult;
                            }
                           
                        }
                        else {
                            _s.login.error = rv.ClientMsg;
                           // alert(rv.ClientMsg);
                        }
                    }, "json");
                },

                sendloginverifycode: function (verifytype, verifynum) {

                    var _s = this;

                    if (verifytype == "email") {
                        var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                        if (!reg.test(verifynum)) {
                            alert(rclng.erroremailformat);
                            return;
                        }
                    }
                    else {
                        var reg = /^1[123456789]\d{9}$/;
                        if (!reg.test(verifynum)) {
                            alert(rclng.errorphonenum);
                            return;
                        }
                    }
                    var downcountsecond = 120;
                    var downcount = function () {
                        if (downcountsecond == 0) {
                            _s.login.verifybtndisabled = false;
                            _s.login.verifybtntxt = "获取验证码";
                        }
                        else {
                            _s.login.verifybtntxt = downcountsecond;
                            setTimeout(function () {
                                downcountsecond--;
                                downcount();
                            }, 1000);
                        }
                    };
                    var postdata = {
                        phonenum: verifynum,
                        loginnum: verifynum
                    };
                    var url = "/index.aspx?a=sendloginverifycode";
                   
                    _s.reg.verifybtndisabled = true;
                    $.post(url, postdata, function (ret) {
                        if (ret.result == "1") {

                            _s.login.data.verifyid = ret.verifyid;
                            _s.login.verifyresult = "验证码发送成功，请注意查收";
                          //  $(".geetest_success_radar_tip_content").html("验证码发送成功，请注意查收");
                            _s.login.verifybtndisabled = true;
                            downcount();
                        }
                        else {
                            _s.login.verifybtndisabled = false;
                            _s.login.verifyresult = "无法发送：" + ret.message;

                          //  alert("无法发送：" + ret.message);
                            _s.login.data.verifyid = "";
                        }
                    }, "json");
                },
                goreg: function () {

                    var postdata = JSON.parse(JSON.stringify(this.regformdata));
                    postdata["regnum"] = postdata.phone;

                    $.post("/index.aspx?a=savereguserbyajax", postdata, function (rv) {

                        if (rv.result == "1") {
                            //alert(rclng.plugin_membership_regsuccess);
                            $('.login_pop_box').hide();
                            //$('.reg_success_bg').show();
                            $('.reg_success_box').show();
                            // location.href = "/user/";
                        }
                        else {
                            alert(rv.message);

                        }
                    }, "json");
                },
                checkStrong(sValue) {
                    var modes = 0;
                    //正则表达式验证符合要求的
                    if (sValue.length < 6) return modes;
                    if (/\d/.test(sValue)) modes++; //数字
                    if (/[a-z]/.test(sValue)) modes++; //小写
                    if (/[A-Z]/.test(sValue)) modes++; //大写
                    if (/\W/.test(sValue)) modes++; //特殊字符

                    //逻辑处理
                    switch (modes) {
                        case 1:
                            return 1;
                            break;
                        case 2:
                            return 2;
                            break;
                        case 3:
                        case 4:
                            return sValue.length < 4 ? 3 : 4;
                            break;
                    }
                    return modes;
                },
                regformvalid: function (key) {
                    if (this.reg.formerrfield.indexOf(key) != -1) {
                        return "form-group-error";
                    }
                },
                getsmsverifycode: function (verifytype, verifynum) {

                    var _s = this;

                    if (verifytype == "email") {
                        var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                        if (!reg.test(verifynum)) {
                            alert(rclng.erroremailformat);
                            return;
                        }
                    }
                    else {
                        var reg = /^1[123456789]\d{9}$/;
                        if (!reg.test(verifynum)) {
                            alert(rclng.errorphonenum);
                            return;
                        }
                    }
                    var downcountsecond = 120;
                    var downcount = function () {
                        if (downcountsecond == 0) {
                            _s.reg.verifybtndisabled = false;
                            _s.reg.verifybtntxt = "获取验证码";
                        }
                        else {
                            _s.reg.verifybtntxt = downcountsecond;
                            setTimeout(function () {
                                downcountsecond--;
                                downcount();
                            }, 1000);
                        }
                    };
                    var postdata = {
                        phonenum: verifynum
                    };
                    var url = "/index.aspx?a=sendmobileverifycode";
                    if (verifytype == "email") {
                        url = "/index.aspx?a=sendemailverifycode";
                        postdata = {

                            email: verifynum
                        };
                    }
                    _s.reg.verifybtndisabled = true;
                    $.post(url, postdata, function (ret) {
                        if (ret.result == "1") {

                            _s.regformdata.verifyid = ret.verifyid;
                            $(".geetest_success_radar_tip_content").html("验证码发送成功，请注意查收");
                            _s.reg.verifybtndisabled = true;
                            downcount();
                        }
                        else {
                            _s.reg.verifybtndisabled = false;
                            alert("无法发送：" + ret.message);
                            _s.reg.verifyid = "";
                        }
                    }, "json");
                },
                getsmsverifycodeforfindpassword: function (verifytype, verifynum) {

                    var _s = this;

                    if (verifytype == "email") {
                        var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                        if (!reg.test(verifynum)) {
                            alert(rclng.erroremailformat);
                            return;
                        }
                    }
                    else {
                        var reg = /^1[123456789]\d{9}$/;
                        if (!reg.test(verifynum)) {
                            alert(rclng.errorphonenum);
                            return;
                        }
                    }
                    var downcountsecond = 120;
                    var downcount = function () {
                        if (downcountsecond == 0) {
                            _s.findpassword.verifybtndisabled = false;
                            _s.findpassword.verifybtntxt = "获取验证码";
                        }
                        else {
                            _s.findpassword.verifybtntxt = downcountsecond;
                            setTimeout(function () {
                                downcountsecond--;
                                downcount();
                            }, 1000);
                        }
                    };
                    var postdata = {
                        loginnum: verifynum
                    };
                    var url = "/index.aspx?a=sendfindpasswordverifycode";

                    _s.findpassword.verifybtndisabled = true;
                    $.post(url, postdata, function (ret) {
                        if (ret.result == "1") {

                            _s.findpasswordformdata.verifyid = ret.verifyid;
                            _s.findpassword.verifybtndisabled = true;
                            downcount();
                        }
                        else {
                            _s.findpassword.verifybtndisabled = false;
                            alert("无法发送：" + ret.message);
                            _s.findpasswordformdata.verifyid = "";
                        }
                    }, "json");
                },
                findpasswordformvalid: function (key) {
                    if (this.findpassword.formerrfield.indexOf(key) != -1) {
                        return "form-group-error";
                    }
                },
                gofindpassword: function () {
                    var postdata = JSON.parse(JSON.stringify(this.findpasswordformdata));
                    var _s = this;
                    $.post("/index.aspx?a=ajaxpro_ajax&method=UserFindPasswordByVerifyCode", postdata, function (rv) {

                        if (rv.Status == 1) {
                            _s.findpassword.findwasswordsuccess = true;
                        }
                        else {
                            alert(rv.ClientMsg);
                        }
                    }, "json");
                }
            },
            watch: {
                regformdata: {
                    handler(value) {
                        var _s = this;
                        var valid = true;
                        var errs = [];
                        var errfield = [];


                        if (value.contactuser.length == 0) {
                            errs.push("联系人不能为空");
                            errfield.push('contactuser');
                            valid = false;
                        }
                        if (value.company.length == 0) {
                            errs.push("公司名称不能为空");
                            errfield.push('company');
                            valid = false;
                        }
                        var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                        if (value.email.length == 0) {
                            errs.push("邮箱不能为空");
                            errfield.push('email');
                        }
                        if (!reg.test(value.email)) {
                            errs.push("邮箱格式不正确");
                            errfield.push('email');
                        }
                        if (value.phone.length == 0) {
                            errs.push("手机号码不能为空");
                            valid = false;
                            errfield.push('phone');
                        }
                        var reg = /^1[123456789]\d{9}$/;
                        if (!reg.test(value.phone)) {
                            errs.push("手机号码格式错误");
                            valid = false;
                            errfield.push('phone');
                        }
                        if (value.verifyid.length == 0) {
                            errs.push("请获取手机验证码");
                            valid = false;
                        }
                        if (value.verifycode.length == 0) {
                            errs.push("手机验证码不能为空");
                            valid = false;
                            errfield.push('verifycode');
                        }


                        var v = _s.checkStrong(value.password);
                        _s.reg.pwdstrong = v;
                        if (value.password.length > 0) {
                            _s.pwdstrongcolor = _s.pwdstrongcolors[v];
                            if (v < 2) {
                                valid = false;
                                errs.push("密码强度不够,必须包含数字和字母");
                                errfield.push('password');
                            }
                        }
                        else {
                            _s.pwdstrongcolor = "#bbb";
                            errs.push("密码不能为空");
                            errfield.push('password');
                        }

                        if (value.password.length > 0 && value.password != value.password2) {
                            valid = false;
                            errs.push("两次输入密码不相同");
                            errfield.push('password2');
                        }
                        _s.reg.formvalid = valid;
                        _s.reg.formerrs = errs;
                        _s.reg.formerrfield = errfield;
                    },
                    deep: true
                },

                findpasswordformdata: {
                    handler(value) {
                        var _s = this;
                        var valid = true;
                        var errs = [];
                        var errfield = [];



                        if (value.username.length == 0) {
                            errs.push("手机号码不能为空");
                            valid = false;
                            errfield.push('username');
                        }
                        var reg = /^1[123456789]\d{9}$/;
                        if (!reg.test(value.username)) {
                            errs.push("手机号码格式错误");
                            valid = false;
                            errfield.push('username');
                        }
                        if (value.verifyid.length == 0) {
                            errs.push("请获取手机验证码");
                            valid = false;
                        }
                        if (value.verifycode.length == 0) {
                            errs.push("手机验证码不能为空");
                            valid = false;
                            errfield.push('verifycode');
                        }


                        var v = _s.checkStrong(value.password);
                        _s.findpassword.pwdstrong = v;
                        if (value.password.length > 0) {

                            if (v < 2) {
                                valid = false;
                                errs.push("密码强度不够,必须包含数字和字母");
                                errfield.push('password');
                            }
                        }
                        else {

                            errs.push("密码不能为空");
                            errfield.push('password');
                        }

                        if (value.password.length > 0 && value.password != value.password2) {
                            valid = false;
                            errs.push("两次输入密码不相同");
                            errfield.push('password2');
                        }
                        _s.findpassword.formvalid = valid;
                        _s.findpassword.formerrs = errs;
                        _s.findpassword.formerrfield = errfield;
                    },
                    deep: true
                }
            },
            mounted: function mounted() {

            }
        });
    },
    loginandreg: function (el, cfg) {
        var data = $.extend({
            currentnav: "login",
            login: {
                data: {
                    username: "",
                    password: "",
                    remberpwd: false,
                    loginmethod: "password",
                    verifycode: ""
                }
            },
            regformdata: {
                contactuser: "",
                company: "",
                email: "",
                phone: "",
                verifycode: "",
                password: "",
                password2: "",
                verifycode: "",
                setsession:"1",
                regtype: "phone",
                verifytype: "sms",
                verifyid: ""
            },
            reg: {
                verifybtndisabled: false,
                verifybtntxt: "获取验证码",
                pwdstrong: 0,
                formvalid: false,
                formerrs: [],
                formerrfield: []
            },
            findpassword: {

                verifybtndisabled: false,
                verifybtntxt: "获取验证码",
                pwdstrong: 0,
                formvalid: false,
                formerrs: [],
                formerrfield: [],
                findwasswordsuccess: false
            },
            findpasswordformdata: {
                username: "",
                verifyid: "",
                password: "",
                password2: "",
                verifycode: ""
            },

            pwdstrongcolor: "#bbb",
            pwdstrongcolors: ["#f00", "#ff4a00", "green", "green", "green"]
        }, cfg);
        window.loginandreg = new Vue({
            el: el,
            data: data,
            methods: {
                loginasysw: function () {
                    
                    $.post("/view/loginasysw.aspx", {}, function (rv) {
                        if (rv["redirectURL"] != null) {
                            location.href = rv.redirectURL;
                        }
                 
                    }, "json");
                },
                gologin: function () {
                    var postdata = JSON.parse(JSON.stringify(this.login.data));;
                    $.post("/index.aspx?a=ajaxuserlogin", postdata, function (rv) {

                        if (rv.Status == "1") {
                            location.href = rv.StrResult;
                        }
                        else {
                            alert(rv.ClientMsg);
                        }
                    }, "json");
                },
                goreg: function () {
                   
                    var postdata = JSON.parse(JSON.stringify(this.regformdata));
                    postdata["regnum"] = postdata.phone;

                    $.post("/index.aspx?a=savereguserbyajax", postdata, function (rv) {

                        if (rv.result == "1") {
                            //alert(rclng.plugin_membership_regsuccess);
                            $('.login_pop_box').hide();
                            //$('.reg_success_bg').show();
                            $('.reg_success_box').show();
                           // location.href = "/user/";
                        }
                        else {
                            alert(rv.message);
                            
                        }
                    }, "json");
                },
                checkStrong(sValue) {
                    var modes = 0;
                    //正则表达式验证符合要求的
                    if (sValue.length < 6) return modes;
                    if (/\d/.test(sValue)) modes++; //数字
                    if (/[a-z]/.test(sValue)) modes++; //小写
                    if (/[A-Z]/.test(sValue)) modes++; //大写
                    if (/\W/.test(sValue)) modes++; //特殊字符

                    //逻辑处理
                    switch (modes) {
                        case 1:
                            return 1;
                            break;
                        case 2:
                            return 2;
                            break;
                        case 3:
                        case 4:
                            return sValue.length < 4 ? 3 : 4;
                            break;
                    }
                    return modes;
                },
                regformvalid: function (key) {
                    if (this.reg.formerrfield.indexOf(key) != -1) {
                        return "form-group-error";
                    }
                },
                getsmsverifycode: function (verifytype, verifynum) {

                    var _s = this;

                    if (verifytype == "email") {
                        var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                        if (!reg.test(verifynum)) {
                            alert(rclng.erroremailformat);
                            return;
                        }
                    }
                    else {
                        var reg = /^1[123456789]\d{9}$/;
                        if (!reg.test(verifynum)) {
                            alert(rclng.errorphonenum);
                            return;
                        }
                    }
                    var downcountsecond = 120;
                    var downcount = function () {
                        if (downcountsecond == 0) {
                            _s.reg.verifybtndisabled = false;
                            _s.reg.verifybtntxt = "获取验证码";
                        }
                        else {
                            _s.reg.verifybtntxt = downcountsecond;
                            setTimeout(function () {
                                downcountsecond--;
                                downcount();
                            }, 1000);
                        }
                    };
                    var postdata = {
                        phonenum: verifynum
                    };
                    var url = "/index.aspx?a=sendmobileverifycode";
                    if (verifytype == "email") {
                        url = "/index.aspx?a=sendemailverifycode";
                        postdata = {

                            email: verifynum
                        };
                    }
                    _s.reg.verifybtndisabled = true;
                    $.post(url, postdata, function (ret) {
                        if (ret.result == "1") {

                            _s.regformdata.verifyid = ret.verifyid;
                            $(".geetest_success_radar_tip_content").html("验证码发送成功，请注意查收");
                            _s.reg.verifybtndisabled = true;
                            downcount();
                        }
                        else {
                            _s.reg.verifybtndisabled = false;
                            alert("无法发送：" + ret.message);
                            _s.reg.verifyid = "";
                        }
                    }, "json");
                },
                getsmsverifycodeforfindpassword: function (verifytype, verifynum) {

                    var _s = this;

                    if (verifytype == "email") {
                        var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                        if (!reg.test(verifynum)) {
                            alert(rclng.erroremailformat);
                            return;
                        }
                    }
                    else {
                        var reg = /^1[123456789]\d{9}$/;
                        if (!reg.test(verifynum)) {
                            alert(rclng.errorphonenum);
                            return;
                        }
                    }
                    var downcountsecond = 120;
                    var downcount = function () {
                        if (downcountsecond == 0) {
                            _s.findpassword.verifybtndisabled = false;
                            _s.findpassword.verifybtntxt = "获取验证码";
                        }
                        else {
                            _s.findpassword.verifybtntxt = downcountsecond;
                            setTimeout(function () {
                                downcountsecond--;
                                downcount();
                            }, 1000);
                        }
                    };
                    var postdata = {
                        loginnum: verifynum
                    };
                    var url = "/index.aspx?a=sendfindpasswordverifycode";

                    _s.findpassword.verifybtndisabled = true;
                    $.post(url, postdata, function (ret) {
                        if (ret.result == "1") {

                            _s.findpasswordformdata.verifyid = ret.verifyid;
                            _s.findpassword.verifybtndisabled = true;
                            downcount();
                        }
                        else {
                            _s.findpassword.verifybtndisabled = false;
                            alert("无法发送：" + ret.message);
                            _s.findpasswordformdata.verifyid = "";
                        }
                    }, "json");
                },
                findpasswordformvalid: function (key) {
                    if (this.findpassword.formerrfield.indexOf(key) != -1) {
                        return "form-group-error";
                    }
                },
                gofindpassword: function () {
                    var postdata = JSON.parse(JSON.stringify(this.findpasswordformdata));
                    var _s = this;
                    $.post("/index.aspx?a=ajaxpro_ajax&method=UserFindPasswordByVerifyCode", postdata, function (rv) {

                        if (rv.Status == 1) {
                            _s.findpassword.findwasswordsuccess = true;
                        }
                        else {
                            alert(rv.ClientMsg);
                        }
                    }, "json");
                }
            },
            watch: {
                regformdata: {
                    handler(value) {
                        var _s = this;
                        var valid = true;
                        var errs = [];
                        var errfield = [];


                        if (value.contactuser.length == 0) {
                            errs.push("联系人不能为空");
                            errfield.push('contactuser');
                            valid = false;
                        }
                        if (value.company.length == 0) {
                            errs.push("公司名称不能为空");
                            errfield.push('company');
                            valid = false;
                        }
                        var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                        if (value.email.length == 0) {
                            errs.push("邮箱不能为空");
                            errfield.push('email');
                        }
                        if (!reg.test(value.email)) {
                            errs.push("邮箱格式不正确");
                            errfield.push('email');
                        }
                        if (value.phone.length == 0) {
                            errs.push("手机号码不能为空");
                            valid = false;
                            errfield.push('phone');
                        }
                        var reg = /^1[123456789]\d{9}$/;
                        if (!reg.test(value.phone)) {
                            errs.push("手机号码格式错误");
                            valid = false;
                            errfield.push('phone');
                        }
                        if (value.verifyid.length == 0) {
                            errs.push("请获取手机验证码");
                            valid = false;
                        }
                        if (value.verifycode.length == 0) {
                            errs.push("手机验证码不能为空");
                            valid = false;
                            errfield.push('verifycode');
                        }


                        var v = _s.checkStrong(value.password);
                        _s.reg.pwdstrong = v;
                        if (value.password.length > 0) {
                            _s.pwdstrongcolor = _s.pwdstrongcolors[v];
                            if (v < 2) {
                                valid = false;
                                errs.push("密码强度不够,必须包含数字和字母");
                                errfield.push('password');
                            }
                        }
                        else {
                            _s.pwdstrongcolor = "#bbb";
                            errs.push("密码不能为空");
                            errfield.push('password');
                        }

                        if (value.password.length > 0 && value.password != value.password2) {
                            valid = false;
                            errs.push("两次输入密码不相同");
                            errfield.push('password2');
                        }
                        _s.reg.formvalid = valid;
                        _s.reg.formerrs = errs;
                        _s.reg.formerrfield = errfield;
                    },
                    deep: true
                },

                findpasswordformdata: {
                    handler(value) {
                        var _s = this;
                        var valid = true;
                        var errs = [];
                        var errfield = [];



                        if (value.username.length == 0) {
                            errs.push("手机号码不能为空");
                            valid = false;
                            errfield.push('username');
                        }
                        var reg = /^1[123456789]\d{9}$/;
                        if (!reg.test(value.username)) {
                            errs.push("手机号码格式错误");
                            valid = false;
                            errfield.push('username');
                        }
                        if (value.verifyid.length == 0) {
                            errs.push("请获取手机验证码");
                            valid = false;
                        }
                        if (value.verifycode.length == 0) {
                            errs.push("手机验证码不能为空");
                            valid = false;
                            errfield.push('verifycode');
                        }


                        var v = _s.checkStrong(value.password);
                        _s.findpassword.pwdstrong = v;
                        if (value.password.length > 0) {

                            if (v < 2) {
                                valid = false;
                                errs.push("密码强度不够,必须包含数字和字母");
                                errfield.push('password');
                            }
                        }
                        else {

                            errs.push("密码不能为空");
                            errfield.push('password');
                        }

                        if (value.password.length > 0 && value.password != value.password2) {
                            valid = false;
                            errs.push("两次输入密码不相同");
                            errfield.push('password2');
                        }
                        _s.findpassword.formvalid = valid;
                        _s.findpassword.formerrs = errs;
                        _s.findpassword.formerrfield = errfield;
                    },
                    deep: true
                }
            },
            mounted: function mounted() {

            }
        });
    },
    loginregapp: function (el, cfg) {
        var data = $.extend({
            currentnav: "login",
            login: {
                data: {
                    username: "",
                    password: "",
                    remberpwd: false,
                    loginmethod: "password",
                    verifycode: ""
                }
            },
            regformdata: {
                contactuser: "",
                company: "",
                email: "",
                phone: "",
                verifycode: "",
                password: "",
                password2: "",
                verifycode: "",
                setsession: "1",
                regtype: "phone",
                verifytype: "sms",
                verifyid: ""
            },
            reg: {
                verifybtndisabled: false,
                verifybtntxt: "获取验证码",
                pwdstrong: 0,
                formvalid: false,
                formerrs: [],
                formerrfield: []
            },
            findpassword: {

                verifybtndisabled: false,
                verifybtntxt: "获取验证码",
                pwdstrong: 0,
                formvalid: false,
                formerrs: [],
                formerrfield: [],
                findwasswordsuccess: false
            },
            findpasswordformdata: {
                username: "",
                verifyid: "",
                password: "",
                password2: "",
                verifycode: ""
            },
            findpwdstrongcolor:"#bbb",
            pwdstrongcolor: "#bbb",
            pwdstrongcolors: ["#f00", "#ff4a00", "green", "green", "green"]
        }, cfg);
        window.loginregapp = new Vue({
            el: el,
            data: data,
            methods: {
                loginasysw: function () {

                    $.post("/view/loginasysw.aspx", {}, function (rv) {
                        if (rv["redirectURL"] != null) {
                            location.href = rv.redirectURL;
                        }

                    }, "json");
                },
                gologin: function () {
                    var postdata = JSON.parse(JSON.stringify(this.login.data));;
                    $.post("/index.aspx?a=ajaxuserlogin", postdata, function (rv) {

                        if (rv.Status == "1") {
                            location.href = rv.StrResult;
                        }
                        else {
                            alert(rv.ClientMsg);
                        }
                    }, "json");
                },
                goreg: function () {

                    var postdata = JSON.parse(JSON.stringify(this.regformdata));
                    postdata["regnum"] = postdata.phone;

                    $.post("/index.aspx?a=savereguserbyajax", postdata, function (rv) {

                        if (rv.result == "1") {
                            alert(rclng.plugin_membership_regsuccess);
                            //$('.login_pop_box').hide();
                            ////$('.reg_success_bg').show();
                            //$('.reg_success_box').show();
                            location.href = "/user/#/myprofile";
                        }
                        else {
                            alert(rv.message);

                        }
                    }, "json");
                },
                checkStrong(sValue) {
                    var modes = 0;
                    //正则表达式验证符合要求的
                    if (sValue.length < 6) return modes;
                    if (/\d/.test(sValue)) modes++; //数字
                    if (/[a-z]/.test(sValue)) modes++; //小写
                    if (/[A-Z]/.test(sValue)) modes++; //大写
                    if (/\W/.test(sValue)) modes++; //特殊字符

                    //逻辑处理
                    switch (modes) {
                        case 1:
                            return 1;
                            break;
                        case 2:
                            return 2;
                            break;
                        case 3:
                        case 4:
                            return sValue.length < 4 ? 3 : 4;
                            break;
                    }
                    return modes;
                },
                regformvalid: function (key) {
                    if (this.reg.formerrfield.indexOf(key) != -1) {
                        return "has-error";
                    }
                },
                getsmsverifycode: function (verifytype, verifynum) {

                    var _s = this;

                    if (verifytype == "email") {
                        var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                        if (!reg.test(verifynum)) {
                            alert(rclng.erroremailformat);
                            return;
                        }
                    }
                    else {
                        var reg = /^1[123456789]\d{9}$/;
                        if (!reg.test(verifynum)) {
                            alert(rclng.errorphonenum);
                            return;
                        }
                    }
                    var downcountsecond = 120;
                    var downcount = function () {
                        if (downcountsecond == 0) {
                            _s.reg.verifybtndisabled = false;
                            _s.reg.verifybtntxt = "获取验证码";
                        }
                        else {
                            _s.reg.verifybtntxt = downcountsecond;
                            setTimeout(function () {
                                downcountsecond--;
                                downcount();
                            }, 1000);
                        }
                    };
                    var postdata = {
                        phonenum: verifynum
                    };
                    var url = "/index.aspx?a=sendmobileverifycode";
                    if (verifytype == "email") {
                        url = "/index.aspx?a=sendemailverifycode";
                        postdata = {

                            email: verifynum
                        };
                    }
                    _s.reg.verifybtndisabled = true;
                    $.post(url, postdata, function (ret) {
                        if (ret.result == "1") {

                            _s.regformdata.verifyid = ret.verifyid;
                            $(".geetest_success_radar_tip_content").html("验证码发送成功，请注意查收");
                            _s.reg.verifybtndisabled = true;
                            downcount();
                        }
                        else {
                            _s.reg.verifybtndisabled = false;
                            if (ret.message.indexOf("已经认证") != -1) {
                                bootbox.confirm({
                                    message: ret.message,
                                    buttons: {
                                        confirm: {
                                            label: '去登陆',
                                            className: 'btn-success'
                                        },
                                        cancel: {
                                            label: '确定',
                                            className: 'btn-default'
                                        }
                                    },
                                    callback: function (result) {
                                        if (result) {
                                            regHide();
                                            loginShow_new();
                                        }
                                    }
                                });
                            }
                            else {
                                alert("无法发送：" + ret.message);
                            }
                           
                            _s.reg.verifyid = "";
                        }
                    }, "json");
                },
                getsmsverifycodeforfindpassword: function (verifytype, verifynum) {

                    var _s = this;

                    if (verifytype == "email") {
                        var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                        if (!reg.test(verifynum)) {
                            alert(rclng.erroremailformat);
                            return;
                        }
                    }
                    else {
                        var reg = /^1[123456789]\d{9}$/;
                        if (!reg.test(verifynum)) {
                            alert(rclng.errorphonenum);
                            return;
                        }
                    }
                    var downcountsecond = 120;
                    var downcount = function () {
                        if (downcountsecond == 0) {
                            _s.findpassword.verifybtndisabled = false;
                            _s.findpassword.verifybtntxt = "获取验证码";
                        }
                        else {
                            _s.findpassword.verifybtntxt = downcountsecond;
                            setTimeout(function () {
                                downcountsecond--;
                                downcount();
                            }, 1000);
                        }
                    };
                    var postdata = {
                        loginnum: verifynum
                    };
                    var url = "/index.aspx?a=sendfindpasswordverifycode";

                    _s.findpassword.verifybtndisabled = true;
                    $.post(url, postdata, function (ret) {
                        if (ret.result == "1") {

                            _s.findpasswordformdata.verifyid = ret.verifyid;
                            _s.findpassword.verifybtndisabled = true;
                            downcount();
                        }
                        else {
                            _s.findpassword.verifybtndisabled = false;
                            alert("无法发送：" + ret.message);
                            _s.findpasswordformdata.verifyid = "";
                        }
                    }, "json");
                },
                findpasswordformvalid: function (key) {
                    if (this.findpassword.formerrfield.indexOf(key) != -1) {
                        return "has-error";
                    }
                },
                gofindpassword: function () {
                    var postdata = JSON.parse(JSON.stringify(this.findpasswordformdata));
                    var _s = this;
                    $.post("/index.aspx?a=ajaxpro_ajax&method=UserFindPasswordByVerifyCode", postdata, function (rv) {

                        if (rv.Status == 1) {
                            _s.findpassword.findwasswordsuccess = true;
                        }
                        else {
                            alert(rv.ClientMsg);
                        }
                    }, "json");
                }
            },
            watch: {
                regformdata: {
                    handler(value) {
                        var _s = this;
                        var valid = true;
                        var errs = [];
                        var errfield = [];


                        //if (value.contactuser.length == 0) {
                        //    errs.push("联系人不能为空");
                        //    errfield.push('contactuser');
                        //    valid = false;
                        //}
                        //if (value.company.length == 0) {
                        //    errs.push("公司名称不能为空");
                        //    errfield.push('company');
                        //    valid = false;
                        //}
                        //var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                        //if (value.email.length == 0) {
                        //    errs.push("邮箱不能为空");
                        //    errfield.push('email');
                        //}
                        //if (!reg.test(value.email)) {
                        //    errs.push("邮箱格式不正确");
                        //    errfield.push('email');
                        //}
                        if (value.phone.length == 0) {
                            errs.push("手机号码不能为空");
                            valid = false;
                            errfield.push('phone');
                        }
                        var reg = /^1[123456789]\d{9}$/;
                        if (!reg.test(value.phone)) {
                            errs.push("手机号码格式错误");
                            valid = false;
                            errfield.push('phone');
                        }
                        if (value.verifyid.length == 0) {
                            errs.push("请获取手机验证码");
                            valid = false;
                        }
                        if (value.verifycode.length == 0) {
                            errs.push("手机验证码不能为空");
                            valid = false;
                            errfield.push('verifycode');
                        }


                        var v = _s.checkStrong(value.password);
                        _s.reg.pwdstrong = v;
                        if (value.password.length > 0) {
                            _s.pwdstrongcolor = _s.pwdstrongcolors[v];
                            if (v < 2) {
                                valid = false;
                                errs.push("密码强度不够,必须包含数字和字母");
                                errfield.push('password');
                            }
                        }
                        else {
                            _s.pwdstrongcolor = "#bbb";
                            errs.push("密码不能为空");
                            errfield.push('password');
                        }

                        if (value.password.length > 0 && value.password != value.password2) {
                            valid = false;
                            errs.push("两次输入密码不相同");
                            errfield.push('password2');
                        }
                        _s.reg.formvalid = valid;
                        _s.reg.formerrs = errs;
                        _s.reg.formerrfield = errfield;
                    },
                    deep: true
                },

                findpasswordformdata: {
                    handler(value) {
                        var _s = this;
                        var valid = true;
                        var errs = [];
                        var errfield = [];



                        if (value.username.length == 0) {
                            errs.push("手机号码不能为空");
                            valid = false;
                            errfield.push('username');
                        }
                        var reg = /^1[123456789]\d{9}$/;
                        if (!reg.test(value.username)) {
                            errs.push("手机号码格式错误");
                            valid = false;
                            errfield.push('username');
                        }
                        if (value.verifyid.length == 0) {
                            errs.push("请获取手机验证码");
                            valid = false;
                        }
                        if (value.verifycode.length == 0) {
                            errs.push("手机验证码不能为空");
                            valid = false;
                            errfield.push('verifycode');
                        }


                        var v = _s.checkStrong(value.password);
                        _s.findpassword.pwdstrong = v;
                        if (value.password.length > 0) {
                            _s.findpwdstrongcolor = _s.pwdstrongcolors[v];
                            if (v < 2) {
                                valid = false;
                                errs.push("密码强度不够,必须包含数字和字母");
                                errfield.push('password');
                            }
                        }
                        else {
                            _s.findpwdstrongcolor = "#bbb";
                            errs.push("密码不能为空");
                            errfield.push('password');
                        }

                        if (value.password.length > 0 && value.password != value.password2) {
                            valid = false;
                            errs.push("两次输入密码不相同");
                            errfield.push('password2');
                        }
                        _s.findpassword.formvalid = valid;
                        _s.findpassword.formerrs = errs;
                        _s.findpassword.formerrfield = errfield;
                    },
                    deep: true
                }
            },
            mounted: function mounted() {

            }
        });
    },
    searchnodataapp: function (el, cfg) {
        var data = $.extend({
            searchkey:"",
            nodataform: {
                email: "",
                content: ""
            }
        }, cfg);
        window.searchnodataapp = new Vue({
            el: el,
            data: data,
            methods: {
                submitnodata: function () {
                    var _s = this;
                    var _form = this.nodataform;
                    if (_form.email != "" && _form.content != "") {


                        var postdata = {
                            title: "搜索无结果时留言",
                            im: _form.email,
                            content: _form.content + '\n搜索关键词：' + _s.searchkey
                        };

                        postdata.usecap = 0;

                        postdata.otherinfo = JSON.stringify({});

                        postdata.t = 104;


                        jQuery.post("/index.aspx?a=g",
                            postdata
                            , function (ret) {

                                if (ret.result == "1") {
                                    _s.nodataform.email = "";
                                    _s.nodataform.content = "";
                                    alert("提交成功");

                                }

                            });
                    }
                }
            }
        });
    },
    structuresearchresult: function (el, cfg) {
        var data = $.extend({
            formdata: {
                couponSelected: "FULL",
                similarity: 80,
                getcount: 100,
                structure: "",
                cml: "",
                filteroption:"aa"
            },
            viewtype:"list",
            structrueresult: [],
            hitids: [],
            zminquantity:"",
            nowhitinfo: null,
            isselectedall: false,
            nodataform: {
                email: "",
                content:""
            }
        }, cfg);
        window.structuresearchresult = new Vue({
            el: el,
            data: data,
            components: {
                "hit-info": httpVueLoader(vmucrootpath + "/hitinfo.vue"),
                "pro-inquiry": httpVueLoader(vmucrootpath + "/proinquiry.vue"),
            },
            methods: {
               
                gotoinquiry: function (item) {

                    this.$refs.productinquiry.gotoinquiry(item);

                  
                },
                submitnodata: function () {
                    var _s = this;
                    var _form = this.nodataform;
                    if (_form.email != "" && _form.content != "") {


                        console.log(this.nodataform);



                        var postdata = {
                            title: "结构式搜索无结果时留言",
                            im: _form.email,
                            content: _form.content + '\n搜索结构：' + _s.formdata.structure
                        };

                        postdata.usecap = 0;

                        postdata.otherinfo = JSON.stringify({});

                        postdata.t = 104;


                        jQuery.post("/index.aspx?a=g",
                            postdata
                            , function (ret) {

                                if (ret.result == "1") {
                                    _s.nodataform.email = "";
                                    _s.nodataform.content = "";
                                    alert("提交成功");

                                }

                            });
                    }
                },
                goback: function () {
                    this.nowhitinfo = null;
                },
                selectall: function (v) {
                    var _s = this;
                    _s.isselectedall = v;
                    for (var i = 0; i < _s.structrueresult.length; i++) {
                        var item = _s.structrueresult[i];
                        if (v) {
                            item.checked = true;
                        }
                        else {
                            item.checked = !item.checked;
                        }
                    }
                },
                search: function () {
                    var _s = this;
                    var searchData = {
                        "searchOptions": { "queryStructure": _s.formdata.cml, "searchType": _s.formdata.couponSelected },
                        "filter": { "conditions": {} }, "paging": { "offset": 0, "limit": _s.formdata.getcount },
                        "display": {
                            "include": [
                                "cd_id", "cd_structure", "cd_molweight", "hit_id", "iupac", "traditionalaname", "log_p", "logp", "logP","logD", "smiles_str", "cas", "inchikey", "similarity", "type", "cd_formula"
                            ],
                            "additionalFields": { "mrv": "chemicalTerms(molformat(\"mrv\"))", "mol": "chemicalTerms(molformat(\"mol\"))"}
                        }
                    };
                    if (_s.formdata.filteroption != "" && _s.formdata.filteroption != "aa") {
                        searchData.filter.conditions[_s.formdata.filteroption] = { $eq: 1 };
                    }
                    $.ajax({
                        type: "POST",
                        cache: false,
                        async: false,
                        url: "https://query.hitstructure.com:8443/webservices/rest-v0/data/taosu/table/compound_test/search",
                        contentType: 'application/json',
                        data: JSON.stringify(searchData),
                        success: function (data) {
                            console.log(data);
                            var r = [];
                            for (var i = 0; i < data.data.length; i++) {
                                var item = data.data[i];
                                data.data[i]["suppliers"] = [];
                                data.data[i]["checked"] = false;
                                if (item.hit_id != null && item.hit_id != "") {
                                    r.push({ hitid: item.hit_id, index: i });
                                }
                            }
                            _s.hitids = r;
                            _s.structrueresult = data.data;
                            _s.matchproduct();
                            //dom_image.empty();

                            //let rows = data.data;

                            //for (var a = 0; a < rows.length; a++) {

                            //    var imageData = rows[a]["cd_structure"]["image"];
                            //    //   console.log("mrv :" +mrv);
                            //    //     var aa ='<cml><MDocument><MChemicalStruct><molecule molID="m1"><atomArray><atom id="a1" elementType="C" x2="-10.333426666665918" y2="1.081759987679253"/><atom id="a2" elementType="C" x2="-11.666973322664212" y2="0.3117599938392539"/><atom id="a3" elementType="C" x2="-11.666973322664212" y2="-1.22842666050592"/><atom id="a4" elementType="C" x2="-10.333426666665918" y2="-1.99842665434592"/><atom id="a5" elementType="C" x2="-8.999693344002454" y2="-1.22842666050592"/><atom id="a6" elementType="C" x2="-8.999693344002454" y2="0.3117599938392539"/></atomArray><bondArray><bond atomRefs2="a1 a2" order="2" id="b1"/><bond atomRefs2="a2 a3" order="1" id="b2"/><bond atomRefs2="a3 a4" order="2" id="b3"/><bond atomRefs2="a4 a5" order="1" id="b4"/><bond atomRefs2="a5 a6" order="2" id="b5"/><bond atomRefs2="a6 a1" order="1" id="b6"/></bondArray></molecule></MChemicalStruct></MDocument></cml>' ;
                            //    // var mol =    changeSmilesToMrv(mrv );
                            //    // console.log("imageData :" +imageData["image"]);
                            //    mrvToImg(imageData, a);
                            //}
                        },
                        error: function (data) {
                            alert("error");
                        },
                    });
                }, matchproduct: function () {
                    var _s = this;
                    var gotoqu = function (i) {
                        if (i < _s.hitids.length) {
                            var item = _s.hitids[i];
                            wucapi.post("batchsearch/match", { query: item.hitid, searchtype: "HIT", maxprice: _s.maxprice, min: _s.min, max: _s.max }).then(function (ret) {


                                _s.structrueresult[item.index]["suppliers"] = ret.data.suppliers;
                                gotoqu(i + 1);
                            });
                        }
                        else {



                            console.log("搜索完毕");
                        }
                    }
                    gotoqu(0);
                },
                suppliersubtotal: function (sp) {
                    var r = 0;
                    if (sp.goods != null && sp.goods.length > 0) {
                        for (var k = 0; k < sp.goods.length; k++) {
                            var g = sp.goods[k];
                            if (g.quantity > 0) {
                                r += g.quantity * parseFloat(g.finalprice);
                            }
                        }
                    }
                    sp.subtotal = r;
                    return r.toFixed(2);
                },
                addtocart: function (sp, event) {
                    console.log(sp);
                    var _s = this;
                    var postlist = [];
                    for (var i = 0; i < sp.goods.length; i++) {
                        var it = sp.goods[i];
                        if (it.haveinv && it.quantity > 0) {
                            postlist.push(it);
                        }
                    }
                    if (postlist.length > 0) {
                        web960vue.shopcart.addtocart({ items: postlist }, function (r) {
                            web960vue.shopcart.animatesuccess(event);
                            console.log(r);
                        });
                    }
                },
                exportsdf: function (type,item) {
                    var _s = this;
                    var items = _s.structrueresult;
                    if (type == 2) {
                        //全部
                        items = $.grep(items, function (v) {
                            return v.checked == true;
                        });
                    }
                    else if (type == 3) {
                        items = [item];
                    }
                    if (items.length > 0) {
                        var r = "";
                        $.each(items, function (index,item) {
                            r += item.mol + "\r\n";
                            r += ">  <HIT ID>\r\n" + item.hit_id + "\r\n\r\n";
                            r += ">  <IUPAC>\r\n" + item.iupac + "\r\n\r\n";
                            r += ">  <SMILES>\r\n" + item.smiles_str + "\r\n\r\n";
                            r += ">  <Molecular formula>\r\n" + item.cd_formula + "\r\n\r\n";
                            r += ">  <Molecular weight>\r\n" + item.cd_molweight + "\r\n\r\n";
                            r += "$$$$\r\n";
                        });

                        if ($("#sdfexportform").length == 0) {
                            $("body").append('<form target="_self" id="sdfexportform" name="sdfexportform" method="post" action="/view/fileexport.aspx" ><input type="hidden" id="sdfexportinput" name="sdf" /></form>');
                        }
                       

                        $("#sdfexportinput").val(r);
                        $("#sdfexportform").eq(0).submit();
                    }
                 
                },
                hitdetail: function (item) {
                    this.nowhitinfo = item;
                },
                seebigimg: function (img) {
                    var div = `<div class="modal fade" tabindex="-1" role="dialog" id="seebigimgdiv">
                    <div class="modal-dialog" role="document" style="background-color:#fff;">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title">查看大图</h4>
                        </div>
                        <div class="modal-body"></div>
                    </div>
                    </div>`;
                    if ($("#seebigimgdiv").length == 0) {
                        $("body").append(div);
                    }
                    $(".modal-body", "#seebigimgdiv").html('<img src="' + img + '" class="center-block img-responsive" />');
                    $("#seebigimgdiv").modal();
                },
                gotobulksearch: function () {
                    var _s = this;
                    var minquantity = parseFloat(_s.zminquantity);
                    if (!isNaN(minquantity) && minquantity > 0) {
                        var rv = [];

                        var items = _s.structrueresult;
                        $.each(items, function (index, item) {
                            if (item.checked) {
                                rv.push(item.hit_id);
                            }
                   
                        });


                        if (rv.length > 0) {

                            var inputdata = {
                                query: rv.join("\n"),
                                min: minquantity,
                                max: "",
                                country: "CHINA",
                                matchtype: "DUPLICATE",
                                chemtype: "",
                                proviewtype: "bestinpack",
                            };
                            if ($("#batchsearchform").length == 0) {
                                $("body").append('<form target="_self" id="batchsearchform" name="batchsearchform" method="post" action="/search.do?a=batchsearch" ><input type="hidden" id="batchquery" name="batchquery" /> </form>');
                            }
                            var _s = this;

                            $("#batchquery").val(JSON.stringify(inputdata));
                            $("#batchsearchform").eq(0).submit();
                        }
                        else {
                            alert("请选择您批量搜索的产品");
                        }
                    }
                    else {
                        alert("请输入您需要的规格");
                    }
                }
            },
            computed: {

            },
            mounted: function mounted() {
                var _s = this;
                _s.search();

                MarvinJSUtil.getEditor("#sketch").then(function (sketcherInstance) {
                    marvinSketcherInstance = sketcherInstance;
                }, function (error) {
                });
                $('body').append($('<iframe>', { id: "marvinjs-iframe", src: "/content/marvinjs/marvinpack.html" }));
                MarvinJSUtil.getPackage("#marvinjs-iframe").then(function (marvinNameSpace) {
                    marvinNameSpace.onReady(function () {
                        marvin = marvinNameSpace;
                        // exportImages()
                    });
                }, function (error) {
                    alert("Cannot retrieve marvin instance from iframe:" + error);
                });
            }
        });
    },
    batchsearchresult: function (el, cfg) {
        var data = $.extend({
            totalcount: 0,//总数
            //  selectedcount: 0,//选中数
            //  unableprovide: 0,//无法提供
            expectdeliverydate: "",//预计货期
            selectedprice: {
                moneyunit: "¥",
                price: 0
            },
            suppliers: [
                // {name:"",selected:false}
            ],

            deliverys: [
                { name: "一周", value: 1, selected: false },
                { name: "两周", value: 2, selected: false },
                { name: "三周", value: 3, selected: false },
                { name: "四周", value: 4, selected: false },
                { name: "五周", value: 5, selected: false },
                { name: "六周", value: 6, selected: false },
                { name: "七周", value: 7, selected: false }
            ],
            maxprice: "",
            min: "",
            max: "",
            lesspurity: "",
            matchtype: "",
            proviewtype: "bestinpack",
            query: "",
            searchtype: "SMILES",//HIT
            viewenablemodel: "",
            querysall: [],
            querys: [
                //{
                //    query: "xxx", enable: true, message: "", default: {
                //        name: "",
                //        packaging: "",
                //        purity: "",
                //        finalprice: 0,
                //        quantity: 0,
                //        subtotal: 0,
                //        deliveryweek:1
                //viewgoods:false,
                //    }, suppliers: [
                //        {
                //            name: "Chemdiv",
                //            type: "BB",
                //            subtotal: 0,
                //            moneyunit:"¥",
                //            stock: "",
                //            goods: [
                //                { packaging: "1g", finalprice: 0, moneyunit: "¥", purity: "95%", quantity: 0, invid: 0, haveinv: false, Measure: "mg", Conv: 0, puritydecimal: 99, goodshuoqi: "", deliveryweek:1}
                //            ]
                //        }
                //    ]
                //}
            ]
        }, cfg);
        window.batchsearchresult = new Vue({
            el: el,
            data: data,
            components: {
                "pro-inquiry": httpVueLoader(vmucrootpath + "/proinquiry.vue")
            },
            methods: {
                gotoinquiry: function (item) {
                    this.$refs.productinquiry.gotoinquiry(item);
                },
                load: function () {
                    var _s = this;
                    console.log(_s.query);

                    var qarr = _s.query.split('\n');
                    var kwds = [];
                    _s.querysall.length = 0;
                    for (var i = 0; i < qarr.length; i++) {
                        var kwd = $.trim(qarr[i]);
                        if (kwd != "") {
                            var _thissearchtype = "SMILES";
                            if (kwd.length >= 3 && kwd.substr(0, 3).toUpperCase() == "HIT") {
                                _thissearchtype = "HIT";
                            }
                            if (kwds.length == 0) {
                                //第一条判断搜索的时 SMILES 还是 HITID
                                _s.searchtype = _thissearchtype;
                            }

                            var kwdidx = kwds.indexOf(kwd);
                            var enable = true;
                            var msg = "";
                            if (_s.searchtype != _thissearchtype) {
                                enable = false;
                                msg = "不支持HIT ID 和 SMILES 混合检索";
                            }
                            else if (kwdidx == -1) {
                                kwds.push(kwd);
                            }
                            else {
                                enable = false;
                                msg = "与" + (kwdidx + 1) + "号重复";
                            }
                            _s.querysall.push({
                                query: kwd, enable: enable, message: msg, setdefault: false, default: {}, isdelete: false, suppliers: []
                            })
                        }
                    }

                    _s.fliterquerys();
                    _s.matchproduct();

                },
                deleterow: function (row) {
                    var _s = this;
                    row.isdelete = true;
                    _s.fliterquerys();
                },
                fliterquerys: function () {
                    var _s = this;
                    var final = [];
                    var selectedcount = 0;
                    for (var i = 0; i < _s.querysall.length; i++) {
                        var item = _s.querysall[i];
                        if (item.isdelete == false) {

                            if (item.setdefault == false) {
                                if (item.suppliers != null && item.suppliers.length > 0) {

                                }
                                item.setdefault = true;
                            }

                            var nitem = JSON.parse(JSON.stringify(item));



                            var maxprice = parseFloat(_s.maxprice);
                            if (!isNaN(maxprice)) {
                                //过滤最高价格

                            }

                            if (_s.viewenablemodel == "" || (_s.viewenablemodel == "enable" && item.enable) || (_s.viewenablemodel == "disable" && !item.enable)) {

                                final.push(item);


                            }

                        }
                    }
                    _s.querys = final;

                    _s.totalcount = _s.querys.length;

                },
                viewenablemodelchange: function () {
                    this.fliterquerys();
                },
                matchproduct: function () {
                    var _s = this;
                    var suppliers = [];
                    for (var i = 0; i < _s.suppliers.length; i++) {
                        var it = _s.suppliers[i];
                        if (it.selected) {
                            suppliers.push(it.name);
                        }
                    }
                    var deliveryweeks = [];
                    for (var i = 0; i < _s.deliverys.length; i++) {
                        var it = _s.deliverys[i];
                        if (it.selected) {
                            deliveryweeks.push(it.value);
                        }
                    }
                    var gotoqu = function (i) {
                        if (i < _s.querysall.length) {
                            var item = _s.querysall[i];
                            if (item.enable) {
                                wucapi.post("batchsearch/match", { deliveryweeks: deliveryweeks, suppliers: suppliers, query: item.query, matchtype: _s.matchtype, searchtype: _s.searchtype, maxprice: _s.maxprice, min: _s.min, max: _s.max }).then(function (ret) {
                                    if (ret.data.suppliers.length == 0) {
                                        item.enable = false;
                                        if (suppliers.length > 0) {
                                            item.message = "不符合筛选条件（供应商）";
                                        }
                                        else {
                                            item.message = "暂时不能提供";
                                        }
                                    }
                                    else {
                                        item.suppliers = ret.data.suppliers;
                                        item.default = ret.data.def;
                                        for (var j = 0; j < item.suppliers.length; j++) {
                                            var sp = item.suppliers[j];
                                            var ck = $.grep(_s.suppliers, function (rv) {
                                                return rv.name == sp.name;
                                            });
                                            if (ck.length == 0) {
                                                _s.suppliers.push({ name: sp.name, selected: false });
                                            }
                                        }
                                    }
                                    gotoqu(i + 1);
                                });
                            }
                            else {
                                gotoqu(i + 1);
                            }
                        }
                        else {
                            _s.fliterquerys();
                            console.log("搜索完毕");
                        }
                    }
                //    _s.suppliers = [];
                    gotoqu(0);
                },

                exportexcel: function () {
                    var headcolumn = [

                        { title: "序号", field: "index" },
                        { title: "搜索条件", field: "query" },
                        { title: "供应商", field: "brandname" },
                        { title: "规格", field: "packaging" },
                        { title: "纯度", field: "purity" },
                        { title: "单价(￥)", field: "finalprice" },
                        { title: "预计货期(周)", field: "deviveryweek" },
                        { title: "检索结果", field: "message" },
                    ];
                    var _s = this;
                    var rowindex = 0;
                    var rows = [];
                    $.each(_s.querys, function (i, v) {
                        var id = i + 1;
                        if (v.enable) {
                            var sps = v.suppliers;
                            $.each(sps, function (idx, it) {
                                var goods = it.goods;
                                $.each(goods, function (gidx, g) {
                                    rows.push({
                                        index: id,
                                        query: v.query,
                                        brandname: g.brandname,
                                        packaging: g.packaging,
                                        purity: g.purity,
                                        finalprice: g.finalprice,
                                        deviveryweek: _s.deviveryweek(g),
                                        message: ""
                                    })
                                });
                            })
                        }
                        else {

                            rows.push({
                                index: id,
                                query: v.query,
                                message: v.message
                            })
                        }
                    });
                    if (rows.length > 0) {
                        if ($("#excelexportform").length == 0) {
                            $("body").append('<form target="_self" id="excelexportform" name="excelexportform" method="post" action="/view/excelexport.aspx" ><input type="hidden" id="excelexportinput" name="excel" /></form>');
                        }
                        var postdata = {
                            columns: headcolumn,
                            rows: rows
                        };
                        $("#excelexportinput").val(JSON.stringify(postdata));
                        $("#excelexportform").eq(0).submit();
                    }
                    console.log(rows);
                },
                deviveryweek: function (def) {
                    if (def != null && def.deviveryweek != null && def.deviveryweek > 0) {
                        var v = def.deliveryweek;
                        if (v != null && v != "") {
                            var _f = parseFloat(v);
                            if (!isNaN(_f)) {
                                if (_f > 0) {
                                    var min = Math.floor(_f);
                                    var max = Math.ceil(_f);
                                    return min + "-" + max + "周";
                                }
                            }
                        }
                    }
                    else if (def != null && def.goodshuoqi != null) {
                        return def.goodshuoqi;
                    }
                    
                    return "";
                },
                suppliersubtotal: function (sp) {
                    var r = 0;
                    if (sp.goods != null && sp.goods.length > 0) {
                        for (var k = 0; k < sp.goods.length; k++) {
                            var g = sp.goods[k];
                            if (g.quantity > 0) {
                                r += g.quantity * parseFloat(g.finalprice);
                            }
                        }
                    }
                    sp.subtotal = r;
                    return r.toFixed(2);
                },
                addtocart: function (sp, event) {
                    console.log(sp);
                    var _s = this;
                    var postlist = [];
                    for (var i = 0; i < sp.goods.length; i++) {
                        var it = sp.goods[i];
                        if (it.haveinv && it.quantity > 0) {
                            postlist.push(it);
                        }
                    }
                    if (postlist.length > 0) {
                        web960vue.shopcart.addtocart({ items: postlist }, function (r) {
                            web960vue.shopcart.animatesuccess(event);
                            console.log(r);
                        });
                    }
                },
                addtocartall: function (event) {
                    var _s = this;
                    var postlist = [];
                    for (var j = 0; j < _s.querys.length; j++) {
                        var row = _s.querys[j];
                        if (row.enable) {

                            for (var m = 0; m < row.suppliers.length; m++) {
                                var sp = row.suppliers[m];
                                for (var i = 0; i < sp.goods.length; i++) {
                                    var it = sp.goods[i];
                                    if (it.haveinv && it.quantity > 0) {
                                        postlist.push(it);
                                    }
                                }

                            }

                        }
                    }
                    if (postlist.length > 0) {
                        web960vue.shopcart.addtocart({ items: postlist }, function (r) {
                            web960vue.shopcart.animatesuccess(event);
                            console.log(r);
                        });
                    }
                },
                changequantity: function (opt,good,row) {
                    if (opt == -1) {
                        if (good.quantity > 0) {
                            good.quantity--;
                        }
                    }
                    else {
                        good.quantity++;
                    }
                    row["default"] = good;
                },
                defaultsubtotal: function (def) {
                    if (def != null) {
                        if (def["quantity"] != null) {
                            return (def.quantity * parseFloat(def.finalprice)).toFixed(2);
                        }
                    }
                    return "";
                }

            },
            computed: {
                unableprovide: function () {
                    var _s = this;
                    var r = 0;
                    for (var i = 0; i < _s.querys.length; i++) {
                        var item = _s.querys[i];
                        if (item.enable == false) {
                            r++;
                        }
                    }
                    return r;
                },
                selectedcount: function () {
                    var selectedcount = 0;
                    var _s = this;
                    for (var i = 0; i < _s.querys.length; i++) {
                        var item = _s.querys[i];
                        var selectedpro = false;

                        if (item.enable && item.suppliers != null && item.suppliers.length > 0) {
                            for (var j = 0; j < item.suppliers.length; j++) {
                                var sp = item.suppliers[j];
                                if (sp.goods != null && sp.goods.length > 0 && !selectedpro) {
                                    for (var k = 0; k < sp.goods.length; k++) {
                                        var g = sp.goods[k];
                                        if (g.quantity > 0) {
                                            selectedpro = true;
                                            break;
                                        }
                                    }
                                }
                                if (selectedpro) {
                                    break;
                                }
                            }
                        }
                        if (selectedpro) {
                            selectedcount++;
                        }
                    }
                    return selectedcount;
                },
                selectedtotalprice: function () {
                    var totalprice = 0;
                    var _s = this;
                    for (var i = 0; i < _s.querys.length; i++) {
                        var item = _s.querys[i];
                      

                        if (item.enable && item.suppliers != null && item.suppliers.length > 0) {
                            for (var j = 0; j < item.suppliers.length; j++) {
                                var sp = item.suppliers[j];
                                if (sp.goods != null && sp.goods.length > 0 ) {
                                    for (var k = 0; k < sp.goods.length; k++) {
                                        var g = sp.goods[k];
                                        if (g.quantity > 0) {
                                            totalprice += g.quantity * parseFloat(g.finalprice);
                                        }
                                    }
                                }
                            }
                        }
                      
                    }
                    return totalprice.toFixed(2);
                }
            },
            mounted: function mounted() {
                var _s = this;
                _s.load();
            }
        });
    },


    checkout: function (el, cfg) {
        var data = $.extend({
            address: [],
            cartids: [],
            billaddress: [],
            viewinvoicediv: true,
            viewdiscountdiv: true,
            istryuse:0,
            invoices: [],
            invoicecontenttype: { name: "商品明细", value: "商品明细", desc: "发票内容将显示：详细订购清单及优惠金额信息" },
            invoicecontenttypes: [
                { name: "商品明细", value: "商品明细", desc: "发票内容将显示：详细订购清单及优惠金额信息" },
                { name: "商品类别", value: "商品类别", desc: "发票内容将显示：小分子化合物1kit及总金额" }
            ],
            yunfei: "",
            ponumber: "",
            orderremark: "",
            invoice: {
                type: "1",//1电子，0纸质
                info: {},
                contenttype: "",//发票信息
                addresssameasshippingaddress: "1",//收票地址与收货地址相同
                invoiceemail:"",//接收电子发票的邮箱
            },
            goods: [
            ],
            payment: {
                type: "1",//100 按账期付款,2在线付款,1线下支付
            },
            latestsubmitorderconfig: {},
            agreement: [
                { title: '我承诺将所采购的商品仅用作科研用途，不针对个人治疗使用，并已阅读、接受<a href="/pages/510.html" target="_blank">销售条款</a>', agree: false },
              //  { title: '我已同意并接受 <a href="javascript:void(0)">《销售条款》</a>、 <a href="javascript:void(0)">《隐私政策》</a>', agree: false }
            ],
            moneyunit: "CNY",
            moneyunitlabel: "¥",
            money: {
                goodstotal: 0,//商品总计额,
                yunfei: 0,//运费,
                memberdiscount: 0,//会员优惠
                coupon: 0,//优惠券
                pointexchange: 0,//积分抵扣
                pointexchangesrc: "0.00",
                usepoints: 0,//使用了多少积分
                balance: 0,//余额
                balancesrc: "0.00"
            },
            useraccount: {
                money: 0,
                integral: 0,
                ismonthly: false,//是否是月结
            },
            usecoupon: false,//是否使用优惠券，此版暂时不支持
            useintegral: false,//是否使用积分抵扣
            usebalance: false,//使用余额
            integramoneyrate: 1,//积分余额换算比例
            globalset: {},
            PointSet: { Use: 0, AmountOfPoint: 0 },
            isintegralorder: 0,//是否是积分兑换订单
            token: "",
            goodsitemprop: {
                goodscolumns: {
                    purity: "goodsinfo.purity",
                    goodshuoqi: "goodsinfo.goodshuoqi",
                    packaging: "goodsinfo.packaging",
                },
                procolumns: {
                    hitid: "erpinfo.结构式编号",
                    OriginalNo: "erpinfo.OriginalNo",
                    originalNo: "originalNo"

                }
            },
            submitsuccess: false,//是否下单成功
            submitsuccessorderno:"",
        }, cfg);
        window.checkout = new Vue({
            el: el,
            data: data,
            components: {
                "invoice-edit": httpVueLoader(vmucrootpath + "/usercenter/views/invoiceEdit.vue"),
                "address-edit": httpVueLoader(vmucrootpath + "/usercenter/views/addressEdit.vue"),
            },
            methods: {
                newaddress: function (addtype) {
                    this.$refs.addressedit.addnew(addtype);
                },
                editaddress: function (row) {
                    this.$refs.addressedit.edit(row, false);
                },
                deleteaddress: function (row) {
                    this.$refs.addressedit.deleterow(row);
                },
                addresssuccess: function (item) {
                    console.log(item);
                    this.loadaddress();
                },
                setaddressdefault: function (row) {
                    var _s = this;
                    for (var i = 0; i < _s.address.length; i++) {
                        if (_s.address[i]["selected"]) {
                            _s.$refs.addressedit.setDefault(_s.address[i]);
                        }
                    }

                },
                selectshipaddress: function (item) {
                    var _s = this;
                    for (var i = 0; i < _s.address.length; i++) {
                        if (item.Id == _s.address[i]["Id"]) {
                            _s.address[i]["selected"] = true;

                        }
                        else {
                            _s.address[i]["selected"] = false;
                        }

                    }
                },

                selectbilladdress: function (item) {
                    var _s = this;
                    for (var i = 0; i < _s.billaddress.length; i++) {
                        if (item.Id == _s.billaddress[i]["Id"]) {
                            _s.billaddress[i]["selected"] = true;

                        }
                        else {
                            _s.billaddress[i]["selected"] = false;
                        }

                    }
                },
                loadaddress: function () {
                    var _s = this;
                    _s.address.length = 0;
                    _s.billaddress.length = 0;
                    wucapi.post("address/list", {
                        pageindex: 1,
                        psize: 1000,
                        totalrows: 0
                    }).then(function (ret) {
                        var defadd = null;
                        var defbilladd = null;

                        for (var i = 0; i < ret.data.rows.length; i++) {
                            var item = ret.data.rows[i];
                            item["selected"] = false;
                            if (item.IsDefault == 1) {
                                item["selected"] = true;
                            }

                            if (_s.latestsubmitorderconfig["AddressId"] != null) {
                                if (_s.latestsubmitorderconfig["AddressId"] == item.Id) {
                                    defadd = item;
                                }
                            }
                            if (_s.latestsubmitorderconfig["BillAddressId"] != null) {
                                if (_s.latestsubmitorderconfig["BillAddressId"] == item.Id) {
                                    defbilladd = item;
                                }
                            }

                            if (item.AddressType == 0) {
                                _s.address.push(JSON.parse(JSON.stringify(item)));
                                _s.billaddress.push(JSON.parse(JSON.stringify(item)));
                            }
                            else if (item.AddressType == 1) {
                                _s.address.push(item);
                            }
                            else if (item.AddressType == 2) {
                                _s.billaddress.push(item);
                            }
                        }

                        if (defadd != null) {
                            _s.selectshipaddress(defadd);
                        }
                        if (defbilladd != null) {
                            _s.selectbilladdress(defbilladd);
                        }


                    });
                },
                loadinvoice: function () {
                    var _s = this;
                    _s.invoices.length = 0;
                    wucapi.post("invoice/list", {
                        pageindex: 1,
                        psize: 1000,
                        totalrows: 0
                    }).then(function (ret) {
                        var definfoice = null;
                        for (var i = 0; i < ret.data.rows.length; i++) {
                            var item = ret.data.rows[i];
                            item["selected"] = false;
                            if (item.IsDefault == 1) {
                                item["selected"] = true;
                            }

                            if (_s.latestsubmitorderconfig["InvoiceId"] != null) {
                                if (_s.latestsubmitorderconfig["InvoiceId"] == item.Id) {
                                    definfoice = item;
                                }
                            }

                            _s.invoices.push(item);
                        }
                        if (definfoice != null) {
                            _s.selectedinvoice(definfoice);
                        }
                    });
                },
                setinvoicedefault: function (row) {
                    var _s = this;
                    for (var i = 0; i < _s.invoices.length; i++) {
                        if (_s.invoices[i]["selected"]) {
                            _s.$refs.invoiceedit.setDefault(_s.invoices[i]);
                        }
                    }

                },
                selectedinvoice: function (item) {
                    var _s = this;
                    for (var i = 0; i < _s.invoices.length; i++) {
                        if (item.Id == _s.invoices[i]["Id"]) {
                            _s.invoices[i]["selected"] = true;
                            item["selected"] = true;
                        }
                        else {
                            _s.invoices[i]["selected"] = false;
                        }

                    }
                },
                invoicesuccess: function (item) {
                    this.loadinvoice();
                },
                deleteinvoice: function (row) {
                    this.$refs.invoiceedit.deleterow(row);
                },
                newinvoice: function () {
                    this.$refs.invoiceedit.addnew();
                },
                editinvoice: function (row) {
                    this.$refs.invoiceedit.edit(row);
                },
                submitorder: function () {
                    var _s = this;

                    if (_s.goods.length == 0) {
                        alert("无商品数据无法提交");
                        return false;
                    }

                    var addresssellist = $.grep(_s.address, function (r) {
                        return r.selected == true;
                    });
                    var postdata = {};
                    if (addresssellist.length == 0) {
                        alert("请选择收货地址");
                        return false;
                    }
                    else {
                        postdata["address"] = addresssellist[0];
                    }
                    postdata["ponumber"] = _s.ponumber;
                    postdata["orderremark"] = _s.orderremark;

                    postdata["BillKind"] = "0";
                    postdata["InvoiceEmail"] = "";
                    postdata["invoicecontenttype"] = "商品明细";
                    if (_s.viewinvoicediv) {
                        postdata["BillKind"] = _s.invoice.type;
                        var emailreg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                        if (_s.invoice.type == "1" && !emailreg.test(_s.invoice.invoiceemail)) {
                            alert("请正确填写收票邮箱");
                            return false;
                        }

                        if (_s.invoice.type == "1") {
                            postdata["InvoiceEmail"] = _s.invoice.invoiceemail;
                        }

                        var invoicesellist = $.grep(_s.invoices, function (r) {
                            return r.selected == true;
                        });

                        if (invoicesellist.length == 0) {
                            alert("请选择开票信息");
                            return false;
                        }
                        else {
                            postdata["invoice"] = invoicesellist[0];
                        }
                        postdata["invoicecontenttype"] = _s.invoicecontenttype.value;

                        if (_s.invoice.addresssameasshippingaddress == "1") {
                            postdata["billaddress"] = postdata["address"];
                        }
                        else {
                            var billaddresssellist = $.grep(_s.billaddress, function (r) {
                                return r.selected == true;
                            });

                            if (billaddresssellist.length == 0) {
                                alert("请选择收票地址");
                                return false;
                            }
                            else {
                                postdata["billaddress"] = billaddresssellist[0];
                            }
                        }

                    }

                   
                    postdata["payment"] = _s.payment.type;
                    postdata["money"] = _s.money;
                    postdata["totalneedpay"] = _s.totalneedpay;
                    postdata["token"] = _s.token;
                    postdata["cartids"] = _s.cartids;
                    postdata["istryuse"] = _s.istryuse;
                    postdata["isintegralorder"] = _s.isintegralorder;
                    postdata["goodsitemprop"] = _s.goodsitemprop;
                    postdata["moneyunit"] = _s.moneyunit;
                    if (_s.agreement.length > 0) {
                        var gp = $.grep(_s.agreement, function (r) {
                            return r.agree == false;
                        });
                        if (gp.length > 0) {
                            alert("请需要同意并接受我们的相关服务条款,才能提交订单");
                            return false;
                        }
                    }
                    console.log(postdata);
                    wucapi.post("checkout/submitorder", postdata).then(function (ret) {
                        if (ret.result == 1) {
                            if (_s.payment.type == 2) {
                                //在线支付
                                location.href = "/order/pay/?orderno=" + ret.data.OrderId;
                            }
                            else {
                                _s.submitsuccessorderno = ret.data.OrderNo;
                                _s.submitsuccess = true;
                            }
                           
                        }
                    });
                    //console.log(postdata);
                },
                loadgoods: function () {
                    _s = this;
                    wucapi.post("shopcart/checkoutgoods", {
                        cartids: _s.cartids,
                        itemprop: _s.goodsitemprop
                    }).then(function (ret) {
                        _s.goods = ret.data.enable;
                        _s.token = ret.data.token;
                        _s.money.yunfei = ret.data.yunfee;
                        var totalgoodsmoney = 0;
                        var membertotalgoodsmoney = 0;
                        for (var i = 0; i < _s.goods.length; i++) {

                            var g = _s.goods[i];

                            if (g.CartProTypeId == "1" || g.CartProTypeId == "3") {
                                _s.viewinvoicediv = false;
                                _s.viewdiscountdiv = false;
                            }
                            if (g.CartProTypeId == "1") {
                                _s.istryuse = 1;
                            }
                            if (g.CartProTypeId == "3") {
                                _s.isintegralorder = 1;
                            }

                            totalgoodsmoney += g.CartOriginalPrice * g.CartAmount;
                            membertotalgoodsmoney += g.CartPrice * g.CartAmount;
                        }
                        _s.money.goodstotal = totalgoodsmoney;
                        if (membertotalgoodsmoney != totalgoodsmoney) {
                            _s.money.memberdiscount = membertotalgoodsmoney - totalgoodsmoney;
                        }
                    });
                },
                loaduserinfo: function (callback) {
                    var _s = this;
                    wucapi.post("user/info", { scope: ["info", "globalsetting","userconfig"] }).then(function (ret) {
                        _s.useraccount = ret.data;

                        if (_s.useraccount["latestsubmitorderconfig"] != null) {
                            var lsc = _s.useraccount["latestsubmitorderconfig"];
                            _s.latestsubmitorderconfig = lsc;
                            if (lsc.BillKind != null) {
                                _s.invoice.type = lsc.BillKind;
                            }
                            if (lsc.invoicecontenttype != null & lsc.invoicecontenttype != "") {
                                var df = $.grep(_s.invoicecontenttypes, function (it) {
                                    return it.value == lsc.invoicecontenttype;
                                });
                                if (df.length > 0) {
                                    _s.invoicecontenttype = df[0];
                                }
                            }
                            if (lsc.InvoiceEmail != null && lsc.InvoiceEmail != "") {
                                _s.invoice.invoiceemail = lsc.InvoiceEmail
                            } 
                        }

                        if (ret.data.globalsetting != "") {
                            _s.globalset = JSON.parse(ret.data.globalsetting);
                            if (_s.globalset["PointSet"] != null) {
                                _s.PointSet = JSON.parse(_s.globalset["PointSet"]);
                            }

                            console.log(_s.globalset);
                            console.log(_s.PointSet);
                        }
                        callback();
                    });
                },
                usebalancemoney: function () {
                    //使用余额换算
                    var _s = this;
                    _s.money.balance = 0;
                    _s.money.balancesrc = "0.00";
                    if (_s.usebalance) {
                        if (_s.useraccount.money > 0) {
                            if (_s.useraccount.money <= (_s.money.goodstotal + _s.money.yunfei + _s.money.memberdiscount + _s.money.pointexchange )) {
                                _s.money.balance = -1 * _s.useraccount.money;
                                _s.money.balancesrc = _s.useraccount.money.toFixed(2);
                            }
                            else {
                                _s.money.balance = -1 * (_s.money.goodstotal + _s.money.yunfei + _s.money.memberdiscount + _s.money.pointexchange );
                                _s.money.balancesrc = (_s.money.goodstotal + _s.money.yunfei + _s.money.memberdiscount + _s.money.pointexchange ).toFixed(2);
                            }
                        }
                    }

                },
                useintegralmoney: function () {
                    //使用积分换算
                    var _s = this;
                    _s.money.pointexchange = 0;
                    _s.money.pointexchangesrc = "0.00";
                    _s.money.usepoints = 0;
                    if (_s.useintegral) {
                        if (_s.PointSet.Use == 1) {
                            var AmountOfPoint = parseFloat(_s.PointSet["AmountOfPoint"]);
                            if (!isNaN(AmountOfPoint)) {
                                var f = _s.useraccount.integral * AmountOfPoint;
                                if (f > 0) {
                                    if (f <= (_s.money.goodstotal + _s.money.yunfei + _s.money.memberdiscount + _s.money.balance)) {
                                        _s.money.pointexchange = -1 * f;
                                        _s.money.pointexchangesrc = f.toFixed(2);
                                        _s.money.usepoints = _s.useraccount.integral;
                                    }
                                    else {
                                        _s.money.pointexchange = -1 * (_s.money.goodstotal + _s.money.yunfei + _s.money.memberdiscount + _s.money.balance);

                                        _s.money.pointexchangesrc = (_s.money.goodstotal + _s.money.yunfei + _s.money.memberdiscount + _s.money.balance).toFixed(2);
                                        _s.money.usepoints = (_s.money.goodstotal + _s.money.yunfei + _s.money.memberdiscount + _s.money.balance) / AmountOfPoint;
                                    }
                                }
                            }
                        }
                    }

                },
                moneyview: function (r) {
                    return r.toFixed(2);
                }
            },
            computed: {
                ordertotalmoney: function () {
                    var s = this;
                    return s.money.goodstotal + s.money.yunfei + s.money.memberdiscount + s.money.coupon + s.money.pointexchange;
                },
                totalneedpay: function () {
                    var s = this;
                    return s.money.goodstotal + s.money.yunfei + s.money.memberdiscount + s.money.coupon + s.money.pointexchange + s.money.balance;
                },
                canpointexchangesrc: function () {
                    var _s = this;
                    var r = "0.00";
                    if (_s.PointSet.Use == 1) {
                        var AmountOfPoint = parseFloat(_s.PointSet["AmountOfPoint"]);
                        if (!isNaN(AmountOfPoint)) {
                            var f = _s.useraccount.integral * AmountOfPoint;
                            if (f > 0) {
                                if (f <= (_s.money.goodstotal + _s.money.yunfei)) {

                                    r = f.toFixed(2);

                                }
                                else {


                                    r = (_s.money.goodstotal + _s.money.yunfei).toFixed(2);

                                }
                            }
                        }
                    }
                    return r;
                },
                canpusmoneysrc: function () {
                    var _s = this;
                    var _r = "0.00";
                    if (_s.useraccount.money > 0) {
                        if (_s.useraccount.money <= (_s.money.goodstotal + _s.money.yunfei + _s.money.memberdiscount)) {

                            _r = _s.useraccount.money.toFixed(2);
                        }
                        else {

                            _r = (_s.money.goodstotal + _s.money.yunfei + _s.money.memberdiscount).toFixed(2);
                        }
                    }
                    return _r;
                }
            },
            mounted: function mounted() {
                var _s = this;
                this.loaduserinfo(function () {
                    _s.loadaddress();
                    _s.loadinvoice();
                    _s.loadgoods();
                });
            }
        });
    },

    goodslistview: function (el, cfg) {
        var data = $.extend({
            moneyunit: "¥",
            list: [],
            ableaddtocart: true,
            viewprice: true,
            thisloaded:false,
            pricetext:"",
            totalquantity: 0

        }, cfg);
        new Vue({
            el: el,
            data: data,
            components: {

                "pro-inquiry": httpVueLoader(vmucrootpath + "/proinquiry.vue")
            },
            methods: {
                gotoinquiry: function (item) {
                    this.$refs.productinquiry.gotoinquiry(item);
                },
                addtocart: function (event) {
                    var _s = this;
                    var postlist = [];
                    for (var i = 0; i < _s.list.length; i++) {
                        var it = _s.list[i];
                        if (it.haveinv && it.quantity > 0) {
                            postlist.push(it);
                        }
                    }
                    if (postlist.length > 0) {
                        web960vue.shopcart.addtocart({ items: postlist }, function (r) {
                            web960vue.shopcart.animatesuccess(event);
                            console.log(r);
                        });
                    }
                }
            },
            computed: {
                subtotal: function () {
                    var _s = this;
                    var r = 0;
                    var q = 0;
                    for (var i = 0; i < _s.list.length; i++) {
                        var it = _s.list[i];
                        if (it.haveinv) {
                            q += it.quantity;
                            r += it.quantity * parseFloat(it.finalprice);
                        }
                    }
                    _s.totalquantity = q;

                    return r.toFixed(2);
                }
            },
            mounted: function mounted() {
                var _s = this;
                setTimeout(function () { $(_s.$el).show(); }, 100);
            }
        });
    },
    productinquiry: function (el, cfg) {
        var data = $.extend({
            inquiryform: {
                supplier: null,
                hitid: "",
                goodsno: "",
                quantity: "",
                price: "",
                standard: "",
                prov: "",
                city: "",
                area: "",
                address: "",
                cas: "",
                purity: "",
                company: "",
            },
            required: [
                "supplier",
                "hitid",
                "goodsno",
                "quantity",
                "price",
                "standard",
                "prov",
                "city",
                "area",
                "address",
                "company"
            ],
            required2: [
                "im",
                "tel",
                "user"
            ],
            inquiryform2: {
                indexid: 0,
                content: "",
                im: "",
                tel: "",
                user: ""
            },
            item: {  },
            inquiryformsuppliers: []

        }, cfg);
        window.productinquiry= new Vue({
            el: el,
            data: data,
            methods: {
                inquiry: function (pid) {
                    var _s = this;
                    if (prodatacfg['p' + pid] != null) {
                        _s.gotoinquiry(prodatacfg['p' + pid]);
                    }
                },
                gotoinquiry: function (item) {

                    var _s = this;
                    var _item = JSON.parse(JSON.stringify(item));
                    if (_item.suppliers != null) {
                        _s.inquiryformsuppliers = _item.suppliers;
                        if (_s.inquiryformsuppliers.length > 0) {
                            _s.inquiryform.supplier = _s.inquiryformsuppliers[0];
                            _s.inquiryform.goodsno = _s.inquiryformsuppliers[0].customno;
                        }
                    }
                   
                    _s.inquiryform.hitid = _item.hit_id;

                    console.log(item);
                    $(".modal", _s.$el).modal();
                },
                saveinquiry: function () {
                    var _s = this;
                    var indexid = ""
                    for (var xk in _s.required) {
                        var k = _s.required[xk];
                        if (_s.inquiryform[k] == null || _s.inquiryform[k] == "") {
                            alert("请填写完整");
                            console.log(k);
                            return false;
                        }
                    }
                    if (_s.inquiryform2.im == "" || _s.inquiryform2.tel == "" || _s.inquiryform2.user == "") {
                        alert("请填写完整");
                        return false;
                    }

                    if (_s.inquiryform.supplier != null) {
                        indexid = _s.inquiryform.supplier.pd_id;
                    }

                    console.log(_s.inquiryform);



                    var postdata = {
                        title: "产品询价：" + _s.inquiryform.hitid,
                        indexid: indexid,
                        content: _s.inquiryform2.content,
                        im: _s.inquiryform2.im,
                        tel: _s.inquiryform2.tel,
                        user: _s.inquiryform2.user
                    };


                    postdata.usecap = 0;

                    var _extform = JSON.parse(JSON.stringify(_s.inquiryform));
                    if (_extform.supplier != null) {
                        _extform.supplier = _extform.supplier["name"];
                        _extform.goodsno = _extform.supplier["customno"];
                    }

                    postdata.otherinfo = JSON.stringify({ inquiry: _extform });

                    postdata.t = 1;


                    jQuery.post("/index.aspx?a=g",
                        postdata
                        , function (ret) {

                            if (ret.result == "1") {
                                alert("提交成功");
                                $(".modal", _s.$el).modal("hide");
                            }

                        });

                },
                 
            },
            computed: {
                
            },
            mounted: function mounted() {

            }
        });
    },
    cadd: function (el, cfg) {
        var data = $.extend({
            currenttype: 107,
            currentproject: {
                title: "虚拟筛选", icon: "fa fa-edit", typeid: 107, classname: "cadd_virtualscreening"
            },
            projects: [
                {
                    title: "虚拟筛选", icon: "fa fa-edit", typeid: 107, classname: "cadd_virtualscreening"
                },
                { title: "分子对接", icon: "fa fa-edit", typeid: 108, classname:"cadd_moleculardocking"},
                { title: "分子动力学", icon: "fa fa-edit", typeid: 109, classname:"cadd_moleculardynamics" },
                { title: "靶点垂钓", icon: "fa fa-edit", typeid: 110, classname:"cadd_targetfishing" },
                { title: "计算参数", icon: "fa fa-edit", typeid: 111, classname:"cadd_calculationparameters"},
                { title: "QSAR模型", icon: "fa fa-edit", typeid: 112, classname:"cadd_qsarmodal" },
                { title: "同源模建", icon: "fa fa-edit",  typeid: 113 ,classname:"cadd_samesorucemodal"},
                { title: "其它", icon: "fa fa-edit", typeid: 114, classname: "cadd_other"}

            ],
            classkeys: {
                cadd_virtualscreening: {
                    required: ["kind",],
                    formdata: {
                        "kind": "蛋白信息",
                        "proteininfo": "",
                        "proteinfile": "",
                        "activecompoundfile": "",
                        "activecompound": "",
                        "targets": "",
                        "function": "",
                        "additional": "",
                        "expectedcycle": "一周",
                        "budget": ""
                    },
                    clearform: function (v) {
                        return $.extend(v, {
                            "kind": "蛋白信息",
                            "proteininfo": "",
                            "proteinfile": "",
                            "activecompoundfile": "",
                            "activecompound": "",
                            "targets": "",
                            "function": "",
                            "additional": "",
                            "expectedcycle": "一周",
                            "budget": ""
                        })
                    },
                    check: function (v) {
                        var msg = [];
                        if (v.kind == "蛋白信息" && v.proteininfo == "" && v.proteinfile == "") {
                            msg.push({ msg: "请输入蛋白信息或者上传相关文件", key: "proteininfo" });
                        }
                        if (v.kind == "活性化合物" && v.activecompoundfile == "" && v.activecompound == "") {
                      
                            msg.push({ msg: "请输入活性化合物或者上传相关文件", key: "activecompound" });
                        }
                        return msg;
                    }
                },
                cadd_moleculardocking: {
                    required: [],
                    formdata: {
                        
                        "proteininfo": "",
                        "proteinfile": "",
                        "ligandfile": "",
                        "ligand": "",
                        "function": "",
                        "additional": "",
                        "expectedcycle": "一周",
                        "budget": ""
                    },
                    clearform: function (v) {
                        return $.extend(v, {
                            "proteininfo": "",
                            "proteinfile": "",
                            "ligandfile": "",
                            "ligand": "",
                            "function": "",
                            "additional": "",
                            "expectedcycle": "一周",
                            "budget": ""
                        })
                    },
                    check: function (v) {
                        var msg = [];
                        if (v.proteininfo == "" && v.proteinfile == "") {
                       
                            msg.push({ msg: "请输入蛋白信息或者上传相关文件", key: "proteininfo" });
                        }
                        if (v.ligand == "" && v.ligandfile == "") {
                        
                            msg.push({ msg: "请输入配体信息或者上传相关文件", key: "ligand" });
                        }
                        return msg;
                    }
                },
                cadd_moleculardynamics: {
                    required: [],
                    formdata: {

                        "simulationsystem": "",
                        "simulationsystemfile": "",
                        "function": "",
                        "additional": "",
                        "expectedcycle": "一周",
                        "budget": ""
                    },
                    clearform: function (v) {
                        return $.extend(v, {
                            "simulationsystem": "",
                            "simulationsystemfile": "",
                            "function": "",
                            "additional": "",
                            "expectedcycle": "一周",
                            "budget": ""
                        })
                    },
                    check: function (v) {
                        var msg = [];
                        if (v.simulationsystem == "" && v.simulationsystemfile=="") {
                        
                            msg.push({ msg: "请输入模拟体系或者上传相关文件", key: "simulationsystem" });
                        }
                      
                        return msg;
                    }
                },
                cadd_targetfishing: {
                    required: [],
                    formdata: {

                        "ligandfile": "",
                        "ligand": "",
                        "additional": "",
                        "expectedcycle": "一周",
                        "budget": ""
                    },
                    clearform: function (v) {
                        return $.extend(v, {
                            "ligandfile": "",
                            "ligand": "",
                            "additional": "",
                            "expectedcycle": "一周",
                            "budget": ""
                        });
                    },
                    check: function (v) {
                        var msg = [];
                       
                        if (v.ligand == "" && v.ligandfile == "") {
                        
                            msg.push({ msg: "请输入配体信息或者上传相关文件", key: "ligand" });
                        }
                        return msg;
                    }
                },
                cadd_calculationparameters: {
                    required: [],
                    formdata: {

                        "ligandfile": "",
                        "ligand": "",
                        "parameters":"",
                        "additional": "",
                        "expectedcycle": "一周",
                        "budget": ""
                    },
                    clearform: function (v) {
                        return $.extend(v, {
                            "ligandfile": "",
                            "ligand": "",
                            "parameters": "",
                            "additional": "",
                            "expectedcycle": "一周",
                            "budget": ""
                        });
                    },
                    check: function (v) {
                        var msg = [];

                        if (v.ligand == "" && v.ligandfile == "") {
                  
                            msg.push({ msg: "请输入配体信息或者上传相关文件", key: "ligand" });
                        }
                        if (v.parameters == "") {
                       
                            msg.push({ msg: "请输入需要计算的化合物参数", key: "parameters" });
                        }
                        return msg;
                    }
                },
                cadd_qsarmodal: {
                    required: [],
                    formdata: {

                        "ligandfile": "",
                        "ligand": "",
                        "comc50": "",
                        "comc50file":"",
                        "additional": "",
                        "expectedcycle": "一周",
                        "budget": ""
                    },
                    clearform: function (v) {
                        return $.extend(v, {
                            "ligandfile": "",
                            "ligand": "",
                            "comc50": "",
                            "comc50file": "",
                            "additional": "",
                            "expectedcycle": "一周",
                            "budget": ""
                        });
                    },
                    check: function (v) {
                        var msg = [];

                        if (v.ligand == "" && v.ligandfile == "") {
                      
                            msg.push({ msg: "请输入配体信息或者上传相关文件", key: "ligand" });
                        }
                        if (v.comc50 == "" && v.comc50file == "") {
                          
                            msg.push({ msg: "请输入化合物的IC₅₀信息或者上传相关文件", key: "comc50" });
                        }
                        return msg;
                    }
                },
                cadd_samesorucemodal: {
                    required: [],
                    formdata: {

                        "sequencefile": "",
                        "sequence": "",
                      
                        "additional": "",
                        "expectedcycle": "一周",
                        "budget": ""
                    },
                    clearform: function (v) {
                        return $.extend(v, {
                            "sequencefile": "",
                            "sequence": "",

                            "additional": "",
                            "expectedcycle": "一周",
                            "budget": ""
                        });
                    },
                    check: function (v) {
                        var msg = [];

                        if (v.sequence == "" && v.sequencefile == "") {
                         
                            msg.push({ msg: "请输入序列信息或者上传相关文件", key: "sequence" });
                        }
                       
                        return msg;
                    }
                },
                cadd_other: {
                    required: [],
                    formdata: {

                        "service": "",
                        "additional": "",
                        "expectedcycle": "一周",
                        "budget": ""
                    },
                    clearform: function (v) {
                        return $.extend(v, {
                            "service": "",
                            "additional": "",
                            "expectedcycle": "一周",
                            "budget": ""
                        });
                    },
                    check: function (v) {
                        var msg = [];

                        if (v.service == "") {
                   
                            msg.push({ msg: "请输入您需要的服务", key: "service" });
                        }

                        return msg;
                    }
                }
            },
            currentcontacttype:"",
            contacttypes: [
                "电话","微信","QQ"
            ],
            contactinfo: {
                name: "",
                contacttype: "",
                contact: "",
                address: "",
                company: "",
                email:""
            }

        }, cfg);
        window.cadd = new Vue({
            el: el,
            data: data,
            methods: {
               
                saveinquiry: function (classname) {
                    var _s = this;
                    var formdata = _s.classkeys[classname].formdata;
                    for (var key in _s.contactinfo) {
                        if (_s.contactinfo[key] == "") {
                            alert("请填写完整");
                            _s.$refs["contactinfo." + key].focus();
                            return false;
                        }
                    }

           
                    var ckmsg = _s.classkeys[classname].check(_s.classkeys[classname].formdata);
                    if (ckmsg.length > 0) {
                        _s.$refs["classkeys." + classname + ".formdata." + ckmsg[0].key].focus();
                        alert(ckmsg[0].msg);
                        return false;
                    }
           

                    var postdata = {
                        title: "CADD自动评估：" + _s.currentproject.title,
                       
                        content: "",
                        im: _s.contactinfo.email,
                        tel: _s.contactinfo.contacttype + ":" + _s.contactinfo.contact,
                        user: _s.contactinfo.name,
                        company: _s.contactinfo.company,
                        address: _s.contactinfo.address
                    };


                    postdata.usecap = 0;
                    var rxt = {};
                    rxt[classname] = formdata;
                  //  rxt["contactinfo"] = _s.contactinfo;
                  
                    postdata.otherinfo = JSON.stringify(rxt);

                    postdata.t = _s.currentproject.typeid;

                    console.log(postdata);

                   
                    jQuery.post("/index.aspx?a=g",
                        postdata
                        , function (ret) {

                            if (ret.result == "1") {

                                _s.classkeys[classname].formdata=  _s.classkeys[classname].clearform(_s.classkeys[classname].formdata);

                                alert("提交成功");
                         
                            }

                        });

                },
                columnview: function (key) {
                    return true;
                },
                upfile: function (key, msg, allowext) {
                    var _s = this;
                    $("#fileupload_modal_msg").html(msg);
                    try {
                        $("#fileupload_modal input[type='file']").fileinput("destroy");
                    }
                    catch (e) {}
                    $("#fileupload_modal input[type='file']").fileinput({
                        language: "zh",
                        overwriteInitial: true,
                        browseLabel: "选择文件",
                        browseIcon: "<i class=\"fa fa-folder-open-o\"></i> ",
                        'showUpload': true,
                        showPreview: false,
                        showCaption: true,
                        dropZoneEnabled: false,
                        allowedFileExtensions: allowext,
                        maxFileCount: 1,
                        uploadUrl: "/view/userupload.aspx"

                    }).on("fileuploaded", function (event, data, previewId, index) {
                        console.log(data);
                        if (data.response["result"] == "1") {
                            var path = data.response["filepath"];
                            eval('_s.' + key + '="' + path + '"');
                            $("#fileupload_modal").modal("hide");
                        }
                        else {
                            alert(data.response["message"]);
                        }
                    });
                    $("#fileupload_modal").modal();
                }

            },
            computed: {

            },
            mounted: function mounted() {
                this.currentproject = this.projects[0];
            }
        });
    },
    shopcart: {
        animatesuccess: function (event) {
            var ax = function (event) {
                var e = event || window.event;
                var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
                var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
                var x = e.pageX || e.clientX + scrollX;
                var y = e.pageY || e.clientY + scrollY;
                return { 'left': x - 5, 'top': y - 5 };
            };
            var of = ax(event);

            var goleft = of.left;
            var gotop = of.top - 80;
            var gift = $('<div style="position:absolute;left:' + of.left + 'px;top:' + of.top + 'px"><i class="fa fa-gift fa-3x" style="color:#ff6600;"></i></div>')
            $("body").append(gift);
            gift.animate({ left: goleft + "px", top: gotop + "px", opacity: 0 }, 1000, function () {
                gift.remove();
            });
        },
        addtocart: function (dto, callback) {

            wucapi.post("shopcart/add", dto).then(function (ret) {
                if (ret.result == 1) {
                    if (ret.data.cartcount != null) {
                        $("span[dataref='shopcartcount']").html(ret.data.cartcount);
                    }
      
                }
                if (callback != null) {
                    callback(ret);
                }
            });
        }
    }
    ,
    shopcartview: function (el, cfg) {
        var data = $.extend({
            itemtypes: {
                g_0: "化合物", g_4: "仪器耗材", g_1: "试用装", g_2: "积分兑换", g_3: "生日礼物"
            },
            list: {
                enable: {},
                disable: []
            },
            disableja:[],
            currentgkey: "",
            totalyunfee:0,
            isselectedall: false,
            isempty:false
        }, cfg);
        new Vue({
            el: el,
            data: data,
            methods: {
                load: function () {
                    _s = this;
                    wucapi.post("shopcart/list", {
                        goodscolumns: {
                            purity: "goodsinfo.purity",
                            goodshuoqi: "goodsinfo.goodshuoqi",
                            packaging: "goodsinfo.packaging",
                        },
                        procolumns: {
                            hitid: "erpinfo.结构式编号",
                            originalNo:"originalNo"
                        }
                    }).then(function (ret) {
                        if (ret.result == 1) {
                            _s.list = ret.data;
                            if (_s.list['enable'] == null) {
                                _s.isempty = true;
                            }
                            else {
                                var im = 0;
                                for (var ik in _s.list['enable']) {
                                    im++;
                                }
                                if (im == 0) {
                                    _s.isempty = true;
                                }
                            }
                            console.log(_s.list);
                        }
                    });
                },
                deleterow: function (item) {
                    var _s = this;

                    bootbox.confirm({
                        title: "删除购物车商品",
                        locale: "zh_CN",
                        message: '确定要删除购物车商品吗？',
                        className: 'bootbox-sm',

                        callback: function (result) {

                            if (result) {
                                blockform($(_s.$el))

                                wucapi.post("shopcart/delete", [item.CartId]).then(function (ret) {
                                    $(_s.$el).unblock();
                                    if (ret.result == 1) {

                                        _s.load()

                                        toastr_success(ret.message);
                                    }

                                });
                            }

                        }
                    });
                },
                clearcart: function () {
                    var _s = this;

                    bootbox.confirm({
                        title: "清空购物车",
                        locale: "zh_CN",
                        message: '确定要清空购物车吗？',
                        className: 'bootbox-sm',

                        callback: function (result) {

                            if (result) {
                                blockform($(_s.$el))

                                wucapi.post("shopcart/clear", {}).then(function (ret) {
                                    $(_s.$el).unblock();
                                    if (ret.result == 1) {

                                        _s.load()

                                        toastr_success(ret.message);
                                    }

                                });
                            }

                        }
                    });
                },
                checkout: function () {
                    if ($("#checkoutform").length == 0) {
                        $("body").append('<form target="_self" id="checkoutform" name="checkoutform" method="post" action="/order/checkout/" ><input type="hidden" id="checkoutcartids" name="checkoutcartids" /> </form>');
                    }
                    var _s = this;
                    var ids = [];
                    if (_s.currentgkey != null && _s.currentgkey != "") {
                        var _list = _s.list.enable[_s.currentgkey];
                        for (var i = 0; i < _list.length; i++) {
                            if (_list[i].selected) {
                                ids.push(_list[i].CartId);
                            }
                        }
                    }
                    if (ids.length > 0) {
                        $("#checkoutcartids").val(ids.join(","));
                        $("#checkoutform").eq(0).submit();
                    }
                    else {
                        alert("请选择您要结算的商品");
                    }
                },
                selectall: function (gkey, o) {
                    var _s = this;
                    var ckd = $(o.target).is(":checked");
                    if (ckd) {
                        //不能混合结算
                        var mixed = false;
                        for (var key in _s.list.enable) {
                            if (key != gkey) {
                                if (mixed) {
                                    break;
                                }
                                var _ilist = _s.list.enable[key];
                                for (var i = 0; i < _ilist.length; i++) {
                                    var it = _ilist[i];
                                    if (it.selected) {
                                        mixed = true;
                                        break;
                                    }
                                }
                            }
                        }
                        if (mixed) {
                            alert("暂不支持混合提交订单");
                            $(o.target).prop("checked", false);
                        }
                        else {
                            var _ilist = _s.list.enable[gkey];
                            for (var i = 0; i < _ilist.length; i++) {
                                _ilist[i]["selected"] = true;
                            }
                            _s.currentgkey = gkey;
                            _s.calyunfee();
                        }
                    }
                    else {
                        var _ilist = _s.list.enable[gkey];
                        for (var i = 0; i < _ilist.length; i++) {
                            _ilist[i]["selected"] = false;
                        }

                        _s.calyunfee();
                    }
                    //var ckd = !this.isselectedall;
                    //var _s = this;
                    //for (var i = 0; i < _s.list.enable.length; i++) {
                    //    _s.list.enable[i].selected = ckd;
                    //}
                },
                reverseselection: function () {
                    var _s = this;
                    for (var i = 0; i < _s.list.enable.length; i++) {
                        var ckd = (_s.list.enable[i].selected ? false : true);
                        _s.list.enable[i].selected = ckd;
                    }
                },
                totalmoney: function () {
                    var _s = this;
                    var r = 0;
                    if (_s.currentgkey != null && _s.currentgkey != "") {
                        var _list = _s.list.enable[_s.currentgkey];
                        for (var i = 0; i < _list.length; i++) {
                            var item = _list[i];
                            if (item.selected) {
                                r += item.CartPrice * item.CartAmount
                            }
                        }
                    }
                    r = r + parseInt(_s.totalyunfee);
                    return r.toFixed(2);
                },
                calyunfee: function () {
                    //计算运费
                    var _s = this;
                    var cartids = [];
                    if (_s.currentgkey != null && _s.currentgkey != "") {
                        var _list = _s.list.enable[_s.currentgkey];
                        for (var i = 0; i < _list.length; i++) {
                            var item = _list[i];
                            if (item.selected) {
                                cartids.push(item.CartId);
                            }
                        }
                    }

                    if (cartids.length > 0) {
                        wucapi.post("checkout/getyunfee", { cartids: cartids }).then(function (ret) {
                            _s.totalyunfee = ret.data.yunfee.toFixed(2);
                            console.log(ret);
                        });
                    }
                    else {
                        _s.totalyunfee = "0.00";
                        console.log("无选中数据");
                    }


                },
                changequantity: function (gkey, t, item) {
                    var _s = this;
                    if (gkey == "g_0" || gkey == "g_4") {
                        //试用装，积分兑换，生日礼物不能修改数量
                        if (t == -1) {
                            item.CartAmount = (item.CartAmount > 1 ? --item.CartAmount : 1)
                        }
                        else {
                            item.CartAmount++;
                        }
                        console.log(item);
                        var cartitem = { invid: item.CartInventoryID, quantity: item.CartAmount, finalprice: item.CartPrice, isintegral: 0, istryuse: 0 };
                        wucapi.post("shopcart/add", { appendQuantity: false, items: [cartitem] }).then(function (ret) {
                            if (ret.data["list"] != null && ret.data["list"].length > 0) {
                                item.CartPrice = ret.data.list[0].item.finalprice;
                            }
                          
                            _s.calyunfee();

                        });

                    }

                },
                totalmoneybykey: function (gkey) {
                    var _s = this;
                    var r = 0;
                    var list = _s.list.enable[gkey];
                    for (var i = 0; i < list.length; i++) {
                        var item = list[i];
                        if (item.selected) {
                            r += item.CartPrice * item.CartAmount
                        }
                    }
                    return r.toFixed(2);
                },
                subtotalmoney: function (item) {
                    return (item.CartPrice * item.CartAmount).toFixed(2);
                },
                cartitemclick: function (gkey, o, item) {
                    var _s = this;
                    var ckd = $(o.target).is(":checked");
                    item.selected = ckd;
                    if (ckd) {
                        //不能混合结算
                        var mixed = false;
                        var prechecked = false;
                        for (var key in _s.list.enable) {
                            if (mixed) {
                                break;
                            }
                            var _ilist = _s.list.enable[key];
                            for (var i = 0; i < _ilist.length; i++) {
                                var it = _ilist[i];
                                if (it.selected) {
                                    if (prechecked == false) {
                                        prechecked = true;
                                        break;
                                    }
                                    else {
                                        mixed = true;
                                        break;
                                    }
                                }
                            }
                        }
                        if (mixed) {
                            alert("暂不支持混合提交订单");
                            item.selected = false;
                            $(o.target).prop("checked", false);
                        }
                        else {
                            _s.currentgkey = gkey;
                            _s.calyunfee();
                        }
                    }
                    else {
                        _s.calyunfee();
                    }
                },
                selectedcountbykey: function (gkey) {
                    var _s = this;
                    var r = 0;
                    var list = _s.list.enable[gkey];
                    for (var i = 0; i < list.length; i++) {
                        if (list[i].selected) {
                            r++;
                        }
                    }
                    return r;
                },
                exportfile: function (type) {
                    var _s = this;
                    var columns = [
                        { title: "产品名称", field: "Pd_name" },
                        { title: "货号", field: "CartGoodsNo" },
                       // { title: "药筛网ID", field: "HitId" },
                        { title: "供应商", field: "GoodsBrand" },
                        { title: "纯度", field: "Purity" },
                        { title: "规格", field: "Packaging" },
                        { title: "货期", field: "Huoqi" },
                        { title: "单价", field: "CartPrice" },
                        { title: "数量", field: "CartAmount" }
                    ];
                    var rows = [];
                    if (_s.currentgkey != null && _s.currentgkey != "") {
                        var _list = _s.list.enable[_s.currentgkey];
                        for (var i = 0; i < _list.length; i++) {
                            if (_list[i].selected) {
                                var item = JSON.parse(JSON.stringify(_list[i]));

                                item["HitId"] = item.proinfo.hitid;
                                item["Purity"] = item.goodsinfo.purity;
                                item["Packaging"] = item.goodsinfo.packaging;
                                item["Huoqi"] = item.goodsinfo.goodshuoqi;

                                rows.push(item);
                            }
                        }
                    }
                    if (rows.length > 0) {
                        if (type == 'pdf') {
                            if ($("#exportpdfform").length == 0) {
                                $("body").append('<form target="_self" id="exportpdfform" name="exportpdfform" method="post" action="/view/pdfexport.aspx" ><input type="hidden" id="pdfexporttype" name="exporttype" /> <input type="hidden" id="pdfcolumns" name="columns" />  <input type="hidden" id="pdfcontent" name="content" /> </form>');
                            }

                            $("#pdfexporttype").val("baojia");
                            $("#pdfcolumns").val(JSON.stringify(columns));
                            $("#pdfcontent").val(JSON.stringify(rows));
                            $("#exportpdfform").eq(0).submit();
                        }
                        else {
                            if ($("#exportexcelform").length == 0) {
                                $("body").append('<form target="_self" id="exportexcelform" name="exportexcelform" method="post" action="/view/excelexport.aspx" ><input type="hidden" id="excel_content" name="excel" /> </form>');
                            }
                            var excelcontent = { columns: columns, rows: rows };
                            $("#excel_content").val(JSON.stringify(excelcontent));

                            $("#exportexcelform").eq(0).submit();
                        }


                    }
                    else {
                        alert("请选择您要导出的数据");
                    }

                },
                downloaddisable: function () {
                    var _s = this;
                    var columns = [
                        //{ title: "药筛网ID", field: "HitId" },
                        { title: "供应商", field: "GoodsBrand" },
                        { title: "货号", field: "CartGoodsNo" },
                        { title: "纯度", field: "Purity" },
                        { title: "规格", field: "Packaging" }
                    ];
                    var rows = [];
                    for (var i = 0; i < _s.disableja.length; i++) {
                        var item = _s.disableja[i];
                        rows.push({
                            HitId: item.proinfo.hitid,
                            GoodsBrand: item.GoodsBrand,
                            CartGoodsNo: item.CartGoodsNo,
                            Purity: item.goodsinfo.purity,
                            Packaging: item.goodsinfo.packaging
                        });

                    }
                    if (rows.length > 0) {
                        if ($("#exportexcelform").length == 0) {
                            $("body").append('<form target="_self" id="exportexcelform" name="exportexcelform" method="post" action="/view/excelexport.aspx" ><input type="hidden" id="excel_content" name="excel" /> </form>');
                        }
                        var excelcontent = { columns: columns, rows: rows };
                        $("#excel_content").val(JSON.stringify(excelcontent));

                        $("#exportexcelform").eq(0).submit();
                    }
                }
            },
            computed: {
                selectedcount: function () {
                    var _s = this;
                    var r = 0;
                    for (var key in _s.list.enable) {
                        var list = _s.list.enable[key];
                        for (var i = 0; i < list.length; i++) {
                            if (list[i].selected) {
                                r++;
                            }
                        }
                    }
                    return r;
                },
                cansupplycount: function () {
                    var count = 0;
                    var _s = this;
                    for (var key in _s.list.enable) {
                        count += _s.list.enable[key].length;
                    }
                    return count;
                }
            },
            mounted: function mounted() {
                var _s = this;
                _s.load();
                if (_s.disableja.length > 0) {
                    $("#model_cannotsupply", this.$el).modal();
                }
           
            }
        });
    }

    ,productsearch: {
        gotobulksearch: function () {
            var minquantity = parseFloat($("#zminquantity").val());
            if (!isNaN(minquantity) && minquantity > 0) {
                var rv = [];
                $("input[name='productsearchresultitem']:checked").each(function () {
                    var v = $.trim($(this).val());
                    if (v != "" && rv.indexOf(v) == -1) {
                        rv.push(v);
                    }
                });

                if (rv.length > 0) {

                    var inputdata = {
                        query: rv.join("\n"),
                        min: minquantity,
                        max: "",
                        country: "CHINA",
                        matchtype: "DUPLICATE",
                        chemtype: "",
                        proviewtype: "bestinpack",
                    };
                    if ($("#batchsearchform").length == 0) {
                        $("body").append('<form target="_self" id="batchsearchform" name="batchsearchform" method="post" action="/search.do?a=batchsearch" ><input type="hidden" id="batchquery" name="batchquery" /> </form>');
                    }
                    var _s = this;

                    $("#batchquery").val(JSON.stringify(inputdata));
                    $("#batchsearchform").eq(0).submit();
                }
                else {
                    alert("请选择您批量搜索的产品");
                }
            }
            else {
                alert("请输入您需要的规格");
                $("#zminquantity").focus();
            }
        }
    }


    , postform: function (cfg) {
        cfg = $.extend({
            target: "_self",
            method: "post",
            action: "",
           

        }, cfg);
        if ($("#___tmpform").length == 0) {
            $("body").append('<form target="_self" id="___tmpform" name="___tmpform" method="post" action="" ></form>');
        }
        $("#___tmpform").empty();
        $("#___tmpform").attr("action", cfg.action);
        if (cfg["data"] != null) {
            for (var key in cfg.data) {
                var ipt = $('<input type="hidden" name="' + key + '" />');
                ipt.val(cfg.data[key]);
                $("#___tmpform").append(ipt);
            }
        }
        $("#___tmpform").eq(0).submit();
    }
    , guestbook: function (el, cfg) {
        var data = $.extend({
            typeid:0,
            dataform: {
           
            },
            tempform: {
            },
            formcheck: function (data,cbk) {
                cbk(data)
            },
            callback: null
        }, cfg);

        data["dataform"] = JSON.parse(JSON.stringify(data["tempform"]));
        new Vue({
            el: el,
            data: data,
            methods: {
                submitdata: function () {
                    var _s = this;
                    var _formxx = this.dataform;

                    _s.formcheck(_formxx, function (_form) {
                        var postdata = JSON.parse(JSON.stringify(_form));

                        postdata.usecap = 0;
                        postdata.otherinfo = JSON.stringify({});
                        if (_form["otherinfo"] != null) {
                            postdata.otherinfo = JSON.stringify(_form["otherinfo"]);
                        }

                        postdata.t = _s.typeid;


                        jQuery.post("/index.aspx?a=g",
                            postdata
                            , function (ret) {
                                if (_s.callback != null) {
                                    _s.callback(ret);
                                }
                                else {
                                    if (ret.result == "1") {
                                        _s["dataform"] = JSON.parse(JSON.stringify(_s["tempform"]));
                                        alert("提交成功");

                                    }
                                }

                            });
                    });

                    
                }
            }
        });
    }
};