You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

436 lines
12 KiB

  1. var if_com = "";
  2. var per = $('#allInfos').html();
  3. var company_personal_id = "";
  4. window.onload = function(){
  5. //加载省的信息
  6. reloadProvinceInfo();
  7. reloadCityInfo(1);
  8. //加载市的信息
  9. // reloadCityInfo();
  10. $('#company').css('display','none');
  11. $('#personal').css('display','none');
  12. var value = $('#select_company_personal input[name="company_personal"]:checked ').val();
  13. if(value == 0){
  14. $('#company').css('display','');
  15. $('#personal').css('display','');
  16. $('#company_check').attr('check',true);
  17. $('#company_show').css('display','');
  18. $('#personal_show').css('display','none');
  19. }else{
  20. $('#company').css('display','');
  21. $('#personal').css('display','');
  22. $('#personal_check').attr('check',true);
  23. $('#personal_show').css('display','');
  24. $('#company_show').css('display','none');
  25. }
  26. }
  27. //基本信息
  28. function basicInfo(){
  29. $('#user_infos').css('display','none');
  30. $('#infos').css('display','');
  31. $('#basic_info_btn').css('background-color','lightgray');
  32. $('#user_info_btn').css('background-color','white');
  33. }
  34. //个人信息
  35. function userInfo(){
  36. var value = $('#select_company_personal input[name="company_personal"]:checked ').val();
  37. $('#user_infos').css('display','');
  38. $('#infos').css('display','none');
  39. $('#basic_info_btn').css('background-color','white');
  40. $('#user_info_btn').css('background-color','lightgray');
  41. if(value == 0){
  42. $('#company_user_info').show();
  43. $('#personal_user_info').hide();
  44. }else{
  45. $('#company_user_info').hide();
  46. $('#personal_user_info').show();
  47. }
  48. }
  49. //个人信息保存
  50. function basicInfoSave(){
  51. var zzz = $('#select_company_personal input[name="company_personal"]:checked ').val();
  52. // var html1 = ''
  53. // html1 = per.replace('[select_company]',value);
  54. // console.log(html1)
  55. // html = per.replace('[select_company]',value);
  56. // $('#allInfos').html(html1);
  57. //value==0 企业
  58. if(zzz == 0){
  59. var saleStyle = $('#company input[name="saleStyle"]:checked').val();
  60. var channel_name = $('#channel_name').val();
  61. var linkman = $('#linkman').val();
  62. var teamwork = $('#teamwork').val();
  63. var com_tel = $('#com_tel').val();
  64. var channel_admin = $('#channel_admin').val();
  65. var saleStyle_company = $('#company input[name="saleStyle_company"]:checked ').val();
  66. var channel_id = $('#channel_id').val();
  67. var province = $("#province").find("option:selected").val();
  68. var cantonal = $("#cantonal").find("option:selected").val();
  69. if(!saleStyle){
  70. alert('未选择销售方式!');
  71. return;
  72. }else if(channel_name==""){
  73. alert('未输入渠道名称!');
  74. return;
  75. }else if(linkman==""){
  76. alert('未输入联系人!');
  77. return;
  78. }else if(com_tel==""){
  79. alert('未输入联系方式');
  80. return;
  81. }else if(channel_admin==""){
  82. alert('未输入渠道管理员');
  83. return;
  84. }else if(!saleStyle_company){
  85. alert('未选择渠道分类');
  86. return;
  87. }
  88. if( $("#basic_info_save_btn").text() == "保存成功" ) {
  89. return;
  90. }
  91. // $("#basic_info_save_btn").removeClass("btn-info");
  92. $("#basic_info_save_btn").text("保存中...");
  93. $.ajax({
  94. url:'./st-xm/control.php', //请求地址
  95. type: "post", //请求方式
  96. // data: data, //请求参数
  97. data:{
  98. type:"channel_addinfo",
  99. user_type:0,
  100. saleStyle:saleStyle,
  101. channel_name:channel_name,
  102. teamwork:teamwork,
  103. linkman:linkman,
  104. com_tel:com_tel,
  105. channel_admin:channel_admin,
  106. saleStyle_company:saleStyle_company,
  107. channel_id:channel_id,
  108. province:province,
  109. cantonal:cantonal
  110. },
  111. async:false,
  112. dataType: "json",
  113. success: function (date1) {
  114. if(date1.code == 0){
  115. alert('成功追加一条企业信息!');
  116. $("#basic_info_save_btn").text("成功保存");
  117. $("#basic_info_save_btn").addClass("removeClass");
  118. $("#personal_check").attr('disabled',true);
  119. $("#basic_info_save_btn").attr("onclick", "null");
  120. $("#basic_info_save_btn").removeClass("btn-primary");
  121. $("#basic_info_save_btn").css('color','white');
  122. company_personal_id = date1.list.user_id;
  123. }else{
  124. alert('添加企业信息失败!');
  125. }
  126. },
  127. fail: function (date) {
  128. }
  129. });
  130. // document.info_form_company.submit();
  131. }else{
  132. var saleStyle = $('#personal input[name="saleStyle_personal"]:checked ').val();
  133. var agency_name = $('#agency_name').val();
  134. var linkman_id = $('#linkman_id').val();
  135. var tel_personal = $('#tel_personal').val();
  136. var principal_personal = $('#principal_personal').val();
  137. var saleStyle_personal = $('#personal input[name="saleStyle_personal_channel"]:checked ').val();
  138. var com_name = $('#com_name').val();
  139. var province = $("#provincea").find("option:selected").val();
  140. var cantonal = $("#cantonala").find("option:selected").val();
  141. if(!saleStyle){
  142. alert('未选择销售方式!');
  143. return;
  144. }else if(agency_name==""){
  145. alert('未输入代理人姓名!');
  146. return;
  147. }else if(linkman_id==""){
  148. alert('未输入身份证号!');
  149. return;
  150. }else if(tel_personal==""){
  151. alert('未输入联系电话');
  152. return;
  153. }else if(principal_personal==""){
  154. alert('未输入负责业务人员');
  155. return;
  156. }else if(saleStyle_personal==""){
  157. alert('未输入负责业务人员');
  158. return;
  159. }
  160. // document.info_form_personal.submit();
  161. if( $("#basic_info_save_btn").text() == "保存成功" ) {
  162. return;
  163. }
  164. // $("#basic_info_save_btn").removeClass("btn-info");
  165. $("#basic_info_save_btn").text("保存中...");
  166. $.ajax({
  167. url:'./st-xm/control.php', //请求地址
  168. type: "post", //请求方式
  169. // data: data, //请求参数
  170. data:{
  171. type:"channel_addinfo",
  172. user_type:1,
  173. saleStyle_personal:saleStyle,
  174. agency_name:agency_name,
  175. linkman_id:linkman_id,
  176. tel_personal:tel_personal,
  177. principal_personal:principal_personal,
  178. com_name:com_name,
  179. saleStyle_personal_channel:saleStyle_personal,
  180. province:province,
  181. cantonal:cantonal
  182. },
  183. async:false,
  184. dataType: "json",
  185. success: function (date1) {
  186. if(date1.code == 0){
  187. //这个地方写按钮失效
  188. alert('成功追加一条个人信息!');
  189. $("#basic_info_save_btn").text("成功保存");
  190. $("#basic_info_save_btn").addClass("removeClass");
  191. $("#personal_check").attr('disabled',true);
  192. $("#basic_info_save_btn").attr("onclick", "null");
  193. $("#basic_info_save_btn").removeClass("btn-primary");
  194. $("#basic_info_save_btn").css('color','white');
  195. company_personal_id = date1.list.user_id;
  196. }else{
  197. alert('添加个人信息失败!');
  198. }
  199. },
  200. fail: function (date) {
  201. }
  202. });
  203. }
  204. }
  205. //账号信息保存
  206. function userInfoSave(){
  207. var zzz = $('#select_company_personal input[name="company_personal"]:checked ').val();
  208. if(zzz == 0){
  209. if(company_personal_id==""){
  210. alert('请先完善基本信息');
  211. }
  212. var company_login_name = $('#company_login_name').val();
  213. var company_bound_tel = $('#company_bound_tel').val();
  214. if(company_login_name==""){
  215. alert('未输入渠道登录名!');
  216. }else{
  217. if( $("#user_info_save_btn").text() == "保存成功" ) {
  218. return;
  219. }
  220. $("#user_info_save_btn").text("保存中...");
  221. $.ajax({
  222. url:'./st-xm/control.php', //请求地址
  223. type: "post", //请求方式
  224. // data: data, //请求参数
  225. data:{
  226. type:"channel_updateuser",
  227. user_type:0,
  228. bound_tel:company_bound_tel,
  229. login_name:company_login_name,
  230. id:company_personal_id
  231. },
  232. async:false,
  233. dataType: "json",
  234. success: function (date1) {
  235. if(date1.code == 0){
  236. //这个地方写按钮失效
  237. alert('成功添加企业账号!');
  238. $("#user_info_save_btn").text("成功保存");
  239. $("#user_info_save_btn").addClass("removeClass");
  240. // $("#personal_check").attr('disabled',true);
  241. $("#user_info_save_btn").attr("onclick", "null");
  242. $("#user_info_save_btn").removeClass("btn-primary");
  243. $("#user_info_save_btn").css('color','white');
  244. }else{
  245. alert('添加企业账号失败!');
  246. }
  247. },
  248. fail: function (date) {
  249. }
  250. });
  251. }
  252. }else{
  253. var personal_bound_tel = $('#personal_bound_tel').val();
  254. var personal_login_name = $('#personal_login_name').val();
  255. if(company_personal_id==""){
  256. alert('请先完善基本信息');
  257. }
  258. if(personal_bound_tel==""){
  259. alert('未输入绑定手机号!');
  260. }else{
  261. // document.userid_form_personal.submit();
  262. if( $("#user_info_save_btn").text() == "保存成功" ) {
  263. return;
  264. }
  265. $("#user_info_save_btn").text("保存中...");
  266. $.ajax({
  267. url:'./st-xm/control.php', //请求地址
  268. type: "post", //请求方式
  269. // data: data, //请求参数
  270. data:{
  271. type:"channel_updateuser",
  272. user_type:1,
  273. login_name:personal_login_name,
  274. bound_tel:personal_bound_tel,
  275. id:company_personal_id
  276. },
  277. async:false,
  278. dataType: "json",
  279. success: function (date1) {
  280. if(date1.code == 0){
  281. //这个地方写按钮失效
  282. alert('成功添加个人账号!');
  283. $("#user_info_save_btn").text("成功保存");
  284. $("#user_info_save_btn").addClass("removeClass");
  285. // $("#personal_check").attr('disabled',true);
  286. $("#user_info_save_btn").attr("onclick", "null");
  287. $("#user_info_save_btn").removeClass("btn-primary");
  288. $("#user_info_save_btn").css('color','white');
  289. }else{
  290. alert('添加个人账号失败!');
  291. }
  292. },
  293. fail: function (date) {
  294. }
  295. });
  296. }
  297. }
  298. }
  299. //选中企业
  300. function selectCompany(){
  301. reloadProvinceInfo();
  302. reloadCityInfo(1);
  303. $('#company').css('display','');
  304. $('#personal').css('display','');
  305. $('#company_check').attr('check',true);
  306. $('#company_show').css('display','');
  307. $('#personal_show').css('display','none');
  308. }
  309. //选中个人
  310. function selectPersonal(){
  311. reloadProvinceInfo();
  312. reloadCityInfo(1);
  313. $('#company').css('display','');
  314. $('#personal').css('display','');
  315. $('#personal_check').attr('check',true);
  316. $('#personal_show').css('display','');
  317. $('#company_show').css('display','none');
  318. }
  319. //加载省的信息
  320. function reloadProvinceInfo(){
  321. // alert('选择省份');
  322. $.ajax({
  323. url:'./st-xm/control.php', //请求地址
  324. type: "post", //请求方式
  325. // data: data, //请求参数
  326. data:{
  327. type:"channel_province",
  328. },
  329. async:false,
  330. dataType: "json",
  331. success: function (date1) {
  332. if(date1.code == 0){
  333. var HTML = "";
  334. var proList = date1.list;
  335. for (var i = 0; i<proList.length;i ++) {
  336. var dict = proList[i];
  337. var tempHTML = '<option value="0">请选择省</option>';
  338. tempHTML = tempHTML.replace('请选择省',proList[i]['AREA_NAME']);
  339. tempHTML = tempHTML.replace('0',proList[i]['ID']);
  340. HTML += tempHTML;
  341. }
  342. $('#province').html(HTML);
  343. $('#provincea').html(HTML);
  344. // $('#province').attr('size',1);
  345. }else{
  346. alert('获取省份列表失败');
  347. }
  348. },
  349. fail: function (date) {
  350. }
  351. });
  352. }
  353. //加载市的信息
  354. function reloadCityInfo(proid){
  355. $.ajax({
  356. url:'./st-xm/control.php', //请求地址
  357. type: "post", //请求方式
  358. data:{
  359. type:"channel_city",
  360. id:proid
  361. },
  362. async:false,
  363. dataType: "json",
  364. success: function (date1) {
  365. if(date1.code == 0){
  366. var HTML = "";
  367. var proList = date1.list;
  368. for (var i = 0; i<proList.length;i ++) {
  369. var dict = proList[i];
  370. var tempHTML = '<option value="0">请选择市</option>';
  371. tempHTML = tempHTML.replace('请选择市',proList[i]['AREA_NAME']);
  372. tempHTML = tempHTML.replace('0',proList[i]['ID']);
  373. HTML += tempHTML;
  374. }
  375. $('#cantonal').html(HTML);
  376. $('#cantonala').html(HTML);
  377. }else{
  378. alert('获取城市列表失败');
  379. }
  380. },
  381. fail: function (date) {
  382. }
  383. });
  384. }
  385. function selectOneProvince(selected){
  386. $("#province").find("option:selected").text();
  387. reloadCityInfo(selected.value);
  388. }