|
- //每页显示的数据个数
- var pagesize = 10;
- var tttHTML = '';
-
-
-
- window.onload = function(){
- var cur = "";
- var currpage = getPar("currpage");
- var select_sale_style = '';
- var select_user_style = '';
- var select_sale_shop = '';
- var keywords = '';
- var data = '';
-
- if(!currpage){
- cur = 1;
- select_sale_style = $('#select_sale_style').val();
-
- select_user_style = $('#select_user_style').val();
-
- select_sale_shop = $('#select_sale_shop').val();
-
- keywords = $('#keywords').val();
-
- data = '{type:"sale_channel",select_sale_style:'+select_sale_style+',select_user_style:'+select_user_style+',select_sale_shop:'+select_sale_shop+',keywords:'+keywords+',currpage:'+cur+'}';
- }else{
- cur = currpage;
- select_sale_style = getPar('select_sale_style');
- $('#select_sale_style').val(select_sale_style);
-
- select_user_style = getPar('select_user_style');
- $('#select_user_style').val(select_user_style);
-
- select_sale_shop = getPar('select_sale_shop');
- $('#select_sale_shop').val(select_sale_shop);
-
- keywords = getPar('keywords');
- $('#keywords').val(keywords);
-
- data = '{type:"sale_channel",select_sale_style:'+select_sale_style+',select_user_style:'+select_user_style+',select_sale_shop:'+select_sale_shop+',keywords:'+keywords+',currpage:'+cur+'}';
- }
- tttHTML = $('#list').html();
- searchInfo(cur,select_sale_style,select_user_style,select_sale_shop,keywords,data);
-
- }
-
-
- //得到url上的参数
- function getPar(par){
- var local_url = document.location.href;
- local_url = decodeURI(local_url);
- var get = local_url.indexOf(par +"=");
- if(get == -1){
- return false;
- }
- var get_par = local_url.slice(par.length + get + 1);
- var nextPar = get_par.indexOf("&");
- if(nextPar != -1){
- get_par = get_par.slice(0, nextPar);
- }
- return get_par;
- }
-
-
- //查询相关信息
- function searchInfo(cur,select_sale_style,select_user_style,select_sale_shop,keywords,data){
- if(!cur){
- cur = 1;
- }
- if(!select_sale_style||!select_user_style||!select_sale_shop||!keywords){
- select_sale_style = $('#select_sale_style').val();
-
- select_user_style = $('#select_user_style').val();
-
- select_sale_shop = $('#select_sale_shop').val();
-
- keywords = $('#keywords').val();
- }
-
-
- $.ajax({
- url:'./st-xm/control.php', //请求地址
- type: "post", //请求方式
- // data: data, //请求参数
- data:{
- type:"sale_channel",
- select_sale_style:select_sale_style,
- select_user_style:select_user_style,
- select_sale_shop:select_sale_shop,
- keywords:keywords,
- currpage:cur,
- pagesize:pagesize
- },
- async:false,
- dataType: "json",
- success: function (date1) {
- console.log(date1);
- if(date1.code == 0){
- console.log(date1.info);
- // alert('订单提交成功!订单号:' + date.order_id);
- // location.href = '/order_list.html';
- var sum = date1.totalNum;
- var tag = "test";
- var sendurl = './sale_channel.html?select_sale_style='+select_sale_style+'&select_user_style='+select_user_style+'&select_sale_shop='+select_sale_shop+'&keywords='+keywords;
- getPager(sendurl, sum, cur, pagesize,tag,'currpage');
-
- reloadInfo(date1);
-
- }else if(date1.code == -1){
- alert('没有相关数据');
- var sum = date1.totalNum;
- var tag = "test";
- var sendurl = './sale_channel.html?select_sale_style='+select_sale_style+'&select_user_style='+select_user_style+'&select_sale_shop='+select_sale_shop+'&keywords='+keywords;
- getPager(sendurl, sum, cur, pagesize,tag,'currpage');
- reloadInfo(date1);
-
- }
- },
- fail: function (date) {
-
- // 此处放失败后执行的代码
- }
- });
- if(cur!=1){
- var select_sale_style = getPar('select_sale_style');
- $('#select_sale_style').val(select_sale_style);
-
- var select_user_style = getPar('select_user_style');
- $('#select_user_style').val(select_user_style);
-
- var select_sale_shop = getPar('select_sale_shop');
- $('#select_sale_shop').val(select_sale_shop);
-
- var keywords = getPar('keywords');
- $('#keywords').val(keywords);
- }
-
- }
- //复选框判断
- function select_checked(index) {
- //index=0最上面的全选 index=1表示的是下面所有的
- var cur_check = $('.ace_check')[0];
- var checkList = $('.ace_check');
- var checkCount = checkList.length - 1;
- var true_count = 0;
- for (var i = 1; i < checkList.length; i++) {
- if (index == '0') {
- checkList[i].checked = cur_check.checked;
- } else {
- if (checkList[i].checked == false) {
- cur_check.checked = false
- } else {
- true_count = true_count + 1;
- }
- }
- }
- //判断下面是否选中完
- if (checkCount == true_count) {
- cur_check.checked = true;
- }
- }
-
-
- //加载数据
- function reloadInfo(data){
- var list = data.list;
- console.log(tttHTML)
- var newHTML='';
- for(var i=0;i<list.length;i++){
- var tempHTML=tttHTML;
- tempHTML=tempHTML.replace('[渠道性质]',list[i].CHAN_QUALITY);
- tempHTML=tempHTML.replace('[渠道分类]',list[i].CHAN_TYPE);
- tempHTML=tempHTML.replace('[渠道名称]',list[i].CHAN_NAME);
- tempHTML=tempHTML.replace('[所属区域]',list[i].AREA_ID);
- tempHTML=tempHTML.replace('[联系人]',list[i].LINKMAN);
- tempHTML=tempHTML.replace('[负责业务人员]',list[i].RESMAN);
- tempHTML=tempHTML.replace('[销售方式]',list[i].SELA_TYPE);
- tempHTML=tempHTML.replace('[账号状态]',list[i].STATUS);
- tempHTML=tempHTML.replace('[userid_style]','userid_style'+list[i].CUST_ID);
- tempHTML=tempHTML.replace('[oneCheck]','oneCheck'+list[i].CUST_ID);
- tempHTML=tempHTML.replace('[oneCheckName]',list[i].CUST_ID);
- if(list[i].STATUS=='待审核'){
- var str = '<a target="_Blank" onclick="open_new_path(this)" go_path="change_channel.html?org_id=' +list[i].CUST_ID + '&channel_style='+list[i].CHAN_QUALITY+'">管理</a>';
- tempHTML=tempHTML.replace('[操作]',str);
- }else if(list[i].STATUS=='启用'){
- var str = '<a target="_Blank" onclick="open_new_path(this)" go_path="change_channel.html?org_id=' +list[i].CUST_ID + '&channel_style='+list[i].CHAN_QUALITY+'">管理</a>'+'<a id ="start_or_stop'+list[i].CUST_ID+'" onclick="startOrStop(this.innerHTML,'+list[i].CUST_ID+')" style="margin-left: 20px;cursor:pointer;">停用</a>';
- tempHTML=tempHTML.replace('[操作]',str);
- }else{
- var str = '<a target="_Blank" onclick="open_new_path(this)" go_path="change_channel.html?org_id=' +list[i].CUST_ID + '&channel_style='+list[i].CHAN_QUALITY+'">管理</a>'+'<a id ="start_or_stop'+list[i].CUST_ID+'" onclick="startOrStop(this.innerHTML,'+list[i].CUST_ID+')" style="margin-left: 20px;cursor:pointer;">启用</a>';
- tempHTML=tempHTML.replace('[操作]',str);
- }
- newHTML+=tempHTML;
- }
- $('#list').html(newHTML);
- }
- //停用 启用按钮
- function startOrStop(status,orgid){
- if(status=='停用'){
- $.ajax({
- url:'./st-xm/control.php', //请求地址
- type: "post", //请求方式
- // data: data, //请求参数
- data:{
- type:"sale_stop",
- prod_id:orgid
- },
- async:false,
- dataType: "json",
- success: function (date1) {
- if(date1.code==0){
- //改变按钮状态
- $('#start_or_stop'+orgid).html('启用');
- //改变账号状态
- $('#userid_style'+orgid).html('停用');
- }
- },
- fail: function (date) {
- alert('停用失败');
- }
- });
-
- }else{
- $.ajax({
- url:'./st-xm/control.php', //请求地址
- type: "post", //请求方式
- // data: data, //请求参数
- data:{
- type:"sale_start",
- prod_id:orgid
- },
- async:false,
- dataType: "json",
- success: function (date1) {
- if(date1.code==0){
- //改变按钮状态
- $('#start_or_stop'+orgid).html('停用');
- //改变账号状态
- $('#userid_style'+orgid).html('启用');
- }
- },
- fail: function (date) {
- alert('启用失败');
- }
- });
- }
- }
-
- //新增销售渠道
- function addChannel(){
- // window.location.href='./channel_manager.html';
- // window.open('./channel_manager.html');
- $.cookie("path_url",cookie_path+"channel_manager.html",{domain:domain_path});
- window.open(system_path);
- }
-
- //停用选中项
- function stopSelect(){
- var ary = new Array();
- $('.ace_check').each(function(index, item) {
- if (this.checked && index != 0) {
- ary.push($(this).attr('name'));
- }
- });
- if (ary.length <= 0) {
- alert('请勾选!!!');
- return;
- }
- var pro_str = ary.join(',');
- //记录选中的未审核的个数
- var n = 0;
- $.ajax({
- url:'./st-xm/control.php', //请求地址
- type: "post", //请求方式
- // data: data, //请求参数
- data:{
- type:"sale_stop",
- prod_id:pro_str
- },
- async:false,
- dataType: "json",
- success: function (date1) {
- if(date1.code == 0){
- $('.ace_check').each(function(index, item) {
- if (this.checked && index != 0) {
- var stopid = $(this).attr('name');
-
- if($('#userid_style'+stopid).html() != "待审核"){
- //改变按钮状态
- $('#start_or_stop'+stopid).html('启用');
- //改变账号状态
- $('#userid_style'+stopid).html('停用');
- }else{
- n++;
- }
- }
-
- });
- if(n != 0){
- alert('所选有'+n+'条记录未通过审核,无法修改状态!');
- }
- }
- },
- fail: function (date) {
- alert('停用失败');
- }
- });
- }
|