No Description
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.

shop_edit_addr.js 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // 获取联动地址
  2. function GetRegionData(t,type){
  3. var parent_id = $(t).val();
  4. if(!parent_id > 0){
  5. return false ;
  6. }
  7. var url = $('#GetRegionDataS').val();
  8. $.ajax({
  9. url: url,
  10. data: {parent_id:parent_id,_ajax:1},
  11. type:'post',
  12. dataType:'json',
  13. success:function(res){
  14. if ('province' == type) {
  15. res = '<option value="0">请选择城市</option>'+ res;
  16. $('#city').empty().html(res);
  17. $('#district').empty().html('<option value="0">请选择县/区/镇</option>');
  18. } else if ('city' == type) {
  19. res = '<option value="0">请选择县/区/镇</option>'+ res;
  20. $('#district').empty().html(res);
  21. }
  22. },
  23. error : function(e) {
  24. layer.closeAll();
  25. layer.alert(e.responseText, {icon: 5});
  26. }
  27. });
  28. }
  29. // 更新收货地址
  30. function EditAddress(){
  31. var parentObj = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  32. var url = $('#ShopEditAddress').val();
  33. if (url.indexOf('?') > -1) {
  34. url += '&';
  35. } else {
  36. url += '?';
  37. }
  38. url += '_ajax=1';
  39. $.ajax({
  40. url: url,
  41. data: $('#theForm').serialize(),
  42. type:'post',
  43. dataType:'json',
  44. success:function(res){
  45. if(res.code == 1){
  46. parent.layer.close(parentObj);
  47. EditHtml(res.data);
  48. parent.layer.msg(res.msg, {time: 1000});
  49. }else{
  50. layer.closeAll();
  51. layer.msg(res.msg, {icon: 5});
  52. }
  53. },
  54. error : function(e) {
  55. layer.closeAll();
  56. layer.alert(e.responseText, {icon: 5});
  57. }
  58. });
  59. };
  60. // 删除收货地址
  61. function DelAddress(addr_id, obj){
  62. var parentObj = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  63. layer.confirm('是否删除收货地址?', {
  64. title:false,
  65. closeBtn: false,
  66. btn: ['是', '否'] //按钮
  67. }, function () {
  68. // 是
  69. layer_loading('正在处理');
  70. $.ajax({
  71. url: $('#DelAddress').val(),
  72. data: {addr_id:addr_id,_ajax:1},
  73. type:'post',
  74. dataType:'json',
  75. success:function(res){
  76. layer.closeAll();
  77. if (1 == res.code) {
  78. var _parent = parent;
  79. _parent.layer.close(parentObj);
  80. _parent.$('#UlHtml').find("#"+addr_id+'_ul_li').remove();
  81. _parent.layer.msg(res.msg, {time: 1000});
  82. }else{
  83. layer.msg(res.msg, {time: 2000});
  84. }
  85. },
  86. error: function (e) {
  87. layer.closeAll();
  88. layer.alert(e.responseText, {icon: 5, title:false});
  89. }
  90. });
  91. }, function (index) {
  92. // 否
  93. layer.closeAll(index);
  94. });
  95. }
  96. // 更新收货地址html
  97. function EditHtml(data)
  98. {
  99. // 获取修改后的值
  100. var consignee = data.consignee;
  101. var mobile = data.mobile;
  102. var info = data.country+' '+data.province+' '+data.city+' '+data.district;
  103. var address = data.address;
  104. // 赋值到相应的ID下
  105. parent.$('#'+data.addr_id+'_consignee').html(consignee);
  106. parent.$('#'+data.addr_id+'_mobile').html(mobile);
  107. parent.$('#'+data.addr_id+'_info').html(info);
  108. parent.$('#'+data.addr_id+'_address').html(address);
  109. }