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.
 
 
 
 

74 lines
1.3 KiB

  1. var prod_id = '';
  2. window.onload = function(){
  3. prod_id = getPar('prod_id');
  4. }
  5. function saveBtnDidClicked(){
  6. var user_name = $('#user_name').val();
  7. var name = $('#name').val();
  8. var tel = $('#tel').val();
  9. if (user_name == '') {
  10. alert('用户名不能为空!');
  11. return;
  12. }
  13. if (name == '') {
  14. alert('真实姓名不能为空!');
  15. return;
  16. }
  17. if (tel == '') {
  18. alert('手机号不能为空!');
  19. return;
  20. }
  21. var urlstr = base_path+'control.php';
  22. var data = {
  23. type:'data_user',
  24. supplier_id:prod_id,
  25. user_name:user_name,
  26. true_name:name,
  27. phone_no:tel,
  28. operate:'insert'
  29. }
  30. console.log(urlstr);
  31. console.log(data);
  32. $.ajax({
  33. url:urlstr, //请求地址
  34. data:data,
  35. type: "post",
  36. dataType: "json",
  37. success: function (data) {
  38. if(data.code == "0"){
  39. console.log(data);
  40. alert(data.info);
  41. window.location.href = './account_list.html?prod_id='+prod_id;
  42. }else{
  43. alert(data.info);
  44. }
  45. }
  46. });
  47. }
  48. //得到url上的参数
  49. function getPar(par){
  50. var local_url = document.location.href;
  51. local_url = decodeURI(local_url);
  52. var get = local_url.indexOf(par +"=");
  53. if(get == -1){
  54. return false;
  55. }
  56. var get_par = local_url.slice(par.length + get + 1);
  57. var nextPar = get_par.indexOf("&");
  58. if(nextPar != -1){
  59. get_par = get_par.slice(0, nextPar);
  60. }
  61. return get_par;
  62. }