|
-
- var user_id = '';
- var prod_id = '';
-
- window.onload = function(){
- user_id = getPar('user_id');
- prod_id = getPar('prod_id');
- var data = {
- type:'data_user',
- user_id:user_id,
- operate:'detail'
- }
- console.log(data);
- $.ajax({
- url: base_path+'control.php', //请求地址
- type: "post", //请求方式
- data: data,
- async: false,
- dataType: "json",
- success: function(data) {
- if(data.code == 0) {
- console.log(data);
- reloadData(data);
- }else{
- console.log(data.info);
- }
- }
- });
- }
-
-
- //加载内容
- function reloadData(data){
- $('#user_name').val(data.list[0].user_name);
- $('#real_name').val(data.list[0].true_name);
- $('#tel').val(data.list[0].phone_no);
- $('#change_pwd').attr('resetid',data.list[0].id);
- $('#total_save_btn').attr('saveid',data.list[0].id);
- }
-
- //重置密码
- function changePassword(obj){
- var value = $(obj).attr('resetid');
- var data = {
- type:'data_user',
- user_id:value,
- operate:'update_password'
- }
- console.log('重置参数');
- console.log(data);
- $.ajax({
- url: base_path+'control.php', //请求地址
- type: "post", //请求方式
- data: data,
- async: false,
- dataType: "json",
- success: function(data) {
- if(data.code == 0) {
- alert(data.info);
- }else{
- alert(data.info);
- }
- }
- });
- }
-
- //保存按钮
- function saveInfo(obj){
- var value = $(obj).attr('saveid');
- var user_name = $('#user_name').val();
- var real_name = $('#real_name').val();
- var tel = $('#tel').val();
-
- var data = {
- type:'data_user',
- user_id:value,
- operate:'update',
- phone_no:tel,
- true_name:real_name,
- user_name:user_name
- }
- console.log('更新参数');
- console.log(data);
- $.ajax({
- url: base_path+'control.php', //请求地址
- type: "post", //请求方式
- data: data,
- async: false,
- dataType: "json",
- success: function(data) {
- if(data.code == 0) {
- alert(data.info);
- window.location.href = './account_list.html?prod_id='+prod_id;
- }else{
- alert(data.info);
- }
- }
- });
- }
-
-
- //得到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;
- }
|