address.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. ;
  2. layui.define(['form'], function (e) {
  3. var s = layui.$,
  4. t = (layui.layer, layui.laytpl, layui.setter, layui.view, layui.admin),
  5. form = layui.form;
  6. form.on('submit(LAY-address-add)',function(data){
  7. s.post('add.html',data.field,function(r){
  8. layer.msg(r.msg,{time:1000,end:function(){
  9. if (!r.code) {
  10. var qfsc = layui.data('qfsc');
  11. var history_url = qfsc['history'];
  12. if (history_url != null) {
  13. window.location.replace(history_url)
  14. }else{
  15. history.go(-1)
  16. }
  17. }
  18. }})
  19. })
  20. return false;
  21. })
  22. form.on('submit(LAY-address-edit)',function(data){
  23. s.post('edit.html',data.field,function(r){
  24. layer.msg(r.msg,{time:1000,end:function(){
  25. if (!r.code) {
  26. var qfsc = layui.data('qfsc');
  27. var history_url = qfsc['history'];
  28. if (history_url != null) {
  29. window.location.replace(history_url)
  30. }else{
  31. history.go(-1)
  32. }
  33. }
  34. }})
  35. })
  36. return false;
  37. })
  38. var address = function(){
  39. if (s('.city-picker').length > 0) {
  40. var head = document.getElementsByTagName('head')[0];
  41. var script = document.createElement('script');
  42. script.type = 'text/javascript';
  43. script.src = '/static/plugins/city-picker/js/city-picker.min.js';
  44. script.onload = script.onreadystatechange = function () {
  45. if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete"){
  46. script.onload = script.onreadystatechange = null;
  47. }
  48. };
  49. head.appendChild(script);
  50. }
  51. }
  52. e('address',new address());
  53. })