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.

3 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. var user_id = '';
  2. var prod_id = '';
  3. window.onload = function(){
  4. user_id = getPar('user_id');
  5. prod_id = getPar('prod_id');
  6. var data = {
  7. type:'data_user',
  8. user_id:user_id,
  9. operate:'detail'
  10. }
  11. console.log(data);
  12. $.ajax({
  13. url: base_path+'control.php', //请求地址
  14. type: "post", //请求方式
  15. data: data,
  16. async: false,
  17. dataType: "json",
  18. success: function(data) {
  19. if(data.code == 0) {
  20. console.log(data);
  21. reloadData(data);
  22. }else{
  23. console.log(data.info);
  24. }
  25. }
  26. });
  27. }
  28. //加载内容
  29. function reloadData(data){
  30. $('#user_name').val(data.list[0].user_name);
  31. $('#real_name').val(data.list[0].true_name);
  32. $('#tel').val(data.list[0].phone_no);
  33. $('#change_pwd').attr('resetid',data.list[0].id);
  34. $('#total_save_btn').attr('saveid',data.list[0].id);
  35. }
  36. //重置密码
  37. function changePassword(obj){
  38. var value = $(obj).attr('resetid');
  39. var data = {
  40. type:'data_user',
  41. user_id:value,
  42. operate:'update_password'
  43. }
  44. console.log('重置参数');
  45. console.log(data);
  46. $.ajax({
  47. url: base_path+'control.php', //请求地址
  48. type: "post", //请求方式
  49. data: data,
  50. async: false,
  51. dataType: "json",
  52. success: function(data) {
  53. if(data.code == 0) {
  54. alert(data.info);
  55. }else{
  56. alert(data.info);
  57. }
  58. }
  59. });
  60. }
  61. //保存按钮
  62. function saveInfo(obj){
  63. var value = $(obj).attr('saveid');
  64. var user_name = $('#user_name').val();
  65. var real_name = $('#real_name').val();
  66. var tel = $('#tel').val();
  67. var data = {
  68. type:'data_user',
  69. user_id:value,
  70. operate:'update',
  71. phone_no:tel,
  72. true_name:real_name,
  73. user_name:user_name
  74. }
  75. console.log('更新参数');
  76. console.log(data);
  77. $.ajax({
  78. url: base_path+'control.php', //请求地址
  79. type: "post", //请求方式
  80. data: data,
  81. async: false,
  82. dataType: "json",
  83. success: function(data) {
  84. if(data.code == 0) {
  85. alert(data.info);
  86. window.location.href = './account_list.html?prod_id='+prod_id;
  87. }else{
  88. alert(data.info);
  89. }
  90. }
  91. });
  92. }
  93. //得到url上的参数
  94. function getPar(par){
  95. var local_url = document.location.href;
  96. local_url = decodeURI(local_url);
  97. var get = local_url.indexOf(par +"=");
  98. if(get == -1){
  99. return false;
  100. }
  101. var get_par = local_url.slice(par.length + get + 1);
  102. var nextPar = get_par.indexOf("&");
  103. if(nextPar != -1){
  104. get_par = get_par.slice(0, nextPar);
  105. }
  106. return get_par;
  107. }