var aLead, iLead, oLead, aPerson, iPerson;
|
|
$(document).ready( onDocumentReady );
|
|
function onDocumentReady() {
|
Origami.fastclick(document.body);
|
if (isAgent("micromessenger")) {
|
weixinShare("绩效达人 推广进度管理",
|
"登记潜在客户 跟踪推广进度 管理推广资源",
|
"http://localhost:8080/sfez/lead.html",
|
"http://localhost:8080/sfez/icon/geggee_logo.png");
|
weixinInit();
|
weixinGuide();
|
$("#page_splash").fadeIn();
|
} else {
|
showLeadList();
|
}
|
}
|
|
function showAccountList() {
|
pageGo("account_list");
|
loadAccountList();
|
}
|
|
function loadAccountList() {
|
jsonRequest("lead", "load_account_list", {}, onAccountListResponse, "正在获取体验用户名单……请稍候");
|
}
|
|
function onAccountListResponse(res) {
|
var aAccount=res.account_list;
|
var title=["手机号", "公司", "姓名", "邀请码"];
|
var width=["30%", "30%", "25%", "15%"];
|
var f=field(title, width);
|
$("#div_account_field").html(f);
|
|
var html="";
|
for (var i=0; i<aAccount.length; i++) {
|
var acc=aAccount[i];
|
html+=div("div_row",
|
cell(acc.phone, "30%")+
|
cell(acc.company, "30%")+
|
cell(acc.name, "25%")+
|
cell(acc.inviter, "15%"));
|
}
|
$("#div_account_sheet").html(html);
|
}
|
|
function showLeadList() {
|
aPage=['lead_list'];
|
$("#page_lead_list").fadeIn();
|
loadLeadList();
|
}
|
|
function loadLeadList() {
|
jsonRequest("lead", "load_lead_list", {}, onLeadListResponse, "正在获取推广状态……请稍候");
|
}
|
|
function onLeadListResponse(res) {
|
aLead=res.lead_list;
|
var title=["公司", "客户", "用户数"];
|
var width=["60%", "20%", "20%"];
|
var f=field(title, width);
|
$("#div_lead_field").html(f);
|
|
var html="";
|
for (var i=0; i<aLead.length; i++) {
|
var lead=aLead[i];
|
html+=div("div_row",
|
cell(lead.hospital_name, "60%", "left")+
|
cell(lead.person_name, "20%", "center")+
|
cell(lead.users, "18%", "right"),
|
"iLead="+i+"; showLeadInfo()");
|
}
|
$("#div_lead_sheet").html(html);
|
}
|
|
function showLeadAdd() {
|
pageGo("lead_edit");
|
oLead={present:"", deploy:"", module:""};
|
initLeadEdit();
|
}
|
|
function showLeadInfo() {
|
pageGo("lead_edit");
|
jsonRequest("lead", "load_lead_info", {lead_uid:aLead[iLead].uid}, onLeadInfoResponse, "正在获取详情……请稍候");
|
}
|
|
function onLeadInfoResponse(res) {
|
oLead=res;
|
initLeadEdit();
|
}
|
|
function initLeadEdit() {
|
$("#row_department_name").hide();
|
$("#row_hospital_name").hide();
|
$("#row_create").hide();
|
$("#row_update").hide();
|
$("#row_update").hide();
|
$("#prompt_person_name").html("请选择");
|
$("#prompt_meet_date").html("请选择");
|
promptSelection("person_name", oLead.person_name);
|
promptSelection("hospital_name", oLead.hospital_name);
|
promptSelection("department_name", oLead.department_name);
|
promptSelection("meet_date", oLead.meet_date);
|
$("#input_phone").val(oLead.phone);
|
$("#input_requirement").val(oLead.requirement);
|
$("#input_users").val(oLead.users);
|
$("#input_timeline").val(oLead.timeline);
|
$("#input_budget").val(oLead.budget);
|
$("#input_systems").val(oLead.systems);
|
$("#input_infotech").val(oLead.infotech);
|
$("#input_info").val(oLead.info);
|
promptSelection("create", oLead.create);
|
if (oLead.update) {
|
promptSelection("update", oLead.update);
|
}
|
toggleInit("present", 3, oLead.present);
|
toggleInit("deploy", 3, oLead.deploy);
|
for (var i=1; i<10; i++) {
|
$("#module_"+i).attr("class", "div_form_check_off");
|
var s=$("#module_"+i).html()+" ";
|
if (oLead.module.indexOf(s)>=0) {
|
setModule(i);
|
oLead.module=oLead.module.replace(s,"");
|
}
|
}
|
$("#input_module").val(oLead.module);
|
$("#row_close").toggle(oLead.owner==1);
|
}
|
|
function toggleInit(series, n, val) {
|
for (var i=1; i<=n; i++) {
|
var s=$("#switch_"+series+"_"+i).html();
|
if (val.indexOf(s)>=0) {
|
toggleSwitch(series, i);
|
}
|
}
|
}
|
|
function promptSelection(field, content) {
|
if (content) {
|
var p=$("#prompt_"+field);
|
p.html(content);
|
p.attr("class", "div_form_content");
|
$("#row_"+field).show();
|
}
|
}
|
|
function selectPerson() {
|
var person=aPerson[iPerson];
|
oLead.person_uid=person.uid;
|
promptSelection("person_name", person.name);
|
promptSelection("department_name", person.department_name);
|
promptSelection("hospital_name", person.hospital_name);
|
pageBack();
|
if ($("#row_meet_objective").is(":visible")) {
|
$("#input_meet_objective").focus();
|
} else {
|
$("#input_meet_content").focus();
|
}
|
}
|
|
function promptDate() {
|
var html="";
|
var di0=getDateInfo();
|
var ms=di0.ms-1000*60*60*24*(di0.day-1);
|
var di=getDateInfo(ms);
|
|
for (var m=0; m<2; m++) {
|
html+=div("div_date_month", di.year+"年"+di.month+"月");
|
for (var w=0; w<di.week; w++) {
|
var b=(w==0)?"off":"on";
|
html+=div("div_date_item_"+b);
|
}
|
var m1=di.month;
|
while (m1==di.month) {
|
var b=(di.week==0 || di.week==6)?"off":"on";
|
var today=(di.str==di0.str)?" div_date_today":"";
|
html+=div("div_date_item_"+b+today, di.day, "selectDate('"+di.str+"');");
|
ms+=1000*60*60*24;
|
di=getDateInfo(ms);
|
}
|
for (var w=di.week; w<7; w++) {
|
var b=w==6?"off":"on";
|
html+=div("div_date_item_"+b);
|
}
|
}
|
$("#div_date_group").html(html);
|
pageGo("date_selection");
|
}
|
|
function getDateInfo(ms) {
|
var di={};
|
di.date=ms?new Date(ms):new Date();
|
di.year=di.date.getFullYear();
|
di.month=di.date.getMonth()+1;
|
di.day=di.date.getDate();
|
di.week=di.date.getDay();
|
di.str=di.year+(di.month<10?"-0":"-")+di.month+(di.day<10?"-0":"-")+di.day;
|
di.ms=Date.parse(di.date)
|
return di;
|
}
|
|
function selectDate(s) {
|
promptSelection("meet_date", s);
|
oLead.meet_date=s;
|
pageBack();
|
}
|
|
function promptPerson() {
|
pageGo("person_selection");
|
loadPersonList();
|
}
|
|
function loadPersonList() {
|
var req={};
|
jsonRequest("lead", "load_person_list", req, onPersonListResponse, "正在获取客户列表……请稍候");
|
}
|
|
function onPersonListResponse(res) {
|
aPerson=res.person_list;
|
var html="", code="";
|
for (var i=0; i<aPerson.length; i++) {
|
var person=aPerson[i];
|
if (person.hospital_code != code) {
|
html+=div("div_person_hospital", person.hospital_name+" ("+person.hospital_code+") ");
|
code=person.hospital_code;
|
}
|
html+=div("div_person_item",
|
div("div_person_doctor_"+person.gender, "")+
|
div("div_person_name", person.name)+
|
div("div_person_title", person.title)+
|
div("div_person_department_name", person.department_name),
|
"selectPerson("+i+")");
|
}
|
$("#div_person_group").html(html);
|
}
|
|
function selectPerson(i) {
|
iPerson=i;
|
oLead.person_uid=aPerson[iPerson].uid;
|
promptSelection("person_name", aPerson[iPerson].name);
|
promptSelection("department_name", aPerson[iPerson].department_name);
|
promptSelection("hospital_name", aPerson[iPerson].hospital_name);
|
pageBack();
|
}
|
|
function setPresent(i) {
|
oLead.present=$("#switch_present_"+i).html();
|
toggleSwitch("present", i);
|
}
|
|
function setDeploy(i) {
|
oLead.deploy=$("#switch_deploy_"+i).html();
|
toggleSwitch("deploy", i);
|
}
|
|
function setModule(i) {
|
if ($("#module_"+i).attr("class")=="div_form_check_on") {
|
$("#module_"+i).attr("class", "div_form_check_off");
|
} else {
|
$("#module_"+i).attr("class", "div_form_check_on");
|
}
|
}
|
|
function confirmLeadEdit() {
|
oLead.users=$("#input_users").val();
|
if (!oLead.uid && !oLead.person_uid) {
|
alertMessage("请选择客户");
|
} else if (!oLead.meet_date) {
|
alertMessage("请选择最近会谈日期");
|
} else if (!oLead.users) {
|
alertMessage("请填写预估用户数规模");
|
} else {
|
oLead.phone=$("#input_phone").val();
|
var module="";
|
for (var i=1; i<10; i++) {
|
if ($("#module_"+i).attr("class")=="div_form_check_on") {
|
module+=$("#module_"+i).html()+" ";
|
}
|
}
|
oLead.module=module+$("#input_module").val();
|
oLead.requirement=$("#input_requirement").val();
|
oLead.timeline=$("#input_timeline").val();
|
oLead.budget=$("#input_budget").val();
|
oLead.systems=$("#input_systems").val();
|
oLead.infotech=$("#input_infotech").val();
|
oLead.info=$("#input_info").val();
|
if (oLead.uid) {
|
jsonRequest("lead", "do_lead_update", oLead, onLeadUpdate, "正在更新信息……请稍候");
|
} else {
|
jsonRequest("lead", "do_lead_add", oLead, onLeadUpdate, "正在创建信息……请稍候");
|
}
|
}
|
}
|
|
function promptLeadClose() {
|
showConfirm("是否删除推广信息?", "confirmLeadClose()");
|
}
|
|
function confirmLeadClose() {
|
jsonRequest("lead", "do_lead_close", {lead_uid:oLead.uid}, onLeadUpdate, "正在删除信息……请稍候");
|
}
|
|
function onLeadUpdate() {
|
pageBack();
|
loadLeadList();
|
}
|