company-register.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. $(function(){
  2. $(document).ready(function () {
  3. $('#uploadButton').click(function () {
  4. $('#imagePic').click();
  5. });
  6. $("#imagePic").on("change", function (e) {
  7. var file = e.target.files[0]; //获取图片资源
  8. var fileTypes = ["bmp", "jpg", "png", "jpeg"];
  9. var bTypeMatch = false
  10. for (var i = 0; i < fileTypes.length; i++) {
  11. var start = file.name.lastIndexOf(".");
  12. var fileType = file.name.substring(start + 1);
  13. if (fileType.toLowerCase() == fileTypes[i]) {
  14. bTypeMatch = true;
  15. break;
  16. }
  17. }
  18. if (bTypeMatch) {
  19. if (file.size <= 1024 * 1024 * 10) {
  20. var reader = new FileReader();
  21. reader.readAsDataURL(file); // 读取文件
  22. // 渲染文件
  23. reader.onload = function (arg) {
  24. $("#uploadButtonInput").val(arg.target.result);
  25. $("#uploadButton").css("background", "url("+arg.target.result+") no-repeat center")
  26. $("#uploadButton").css("border", '1px solid #b8b9ba')
  27. $("#uploadButton").css("border-radius",'10px')
  28. }
  29. } else {
  30. alert('仅支持不超过10M的图片');
  31. // btnUploadText = '上传'
  32. // $("#uploadButton").text(btnUploadText)
  33. return false;
  34. }
  35. } else {
  36. alert('仅限bmp,jpg,png,jpeg图片格式');
  37. // btnUploadText = '上传'
  38. // $("#uploadButton").text(btnUploadText)
  39. return false;
  40. }
  41. });
  42. })
  43. //---------初始化数据部分-----------
  44. var contact_number_list=["+86","+87","+88"]
  45. var location=[{
  46. icon:"🇨🇳",
  47. name:"China"
  48. },{
  49. icon:"🇺🇸",
  50. name:"USA"
  51. },{
  52. icon:"🇪🇸",
  53. name:"Spain"
  54. }
  55. ]
  56. var province=["aaa","bbb","ccc"]
  57. var city=["aaa1","bbb2","ccc3"]
  58. //---------初始化数据部分end-----------
  59. //页面初始化
  60. contact_number_list.forEach(item=>{
  61. var li=$("<option>"+item+"</option>")
  62. $(".showqulist").append(li)
  63. })
  64. location.forEach(item=>{
  65. var li=$("<option>"+item.icon+' '+item.name+"</li>")
  66. $(".showlistLocation1").append(li)
  67. })
  68. province.forEach(item=>{
  69. //var li=$("<li class='contact_location2_li' txt="+item+"><a >"+item+"</a></li>")
  70. var li=$("<option>"+item+"</option>")
  71. $(".showlistLocation2").append(li)
  72. })
  73. city.forEach(item=>{
  74. //var li=$("<li class='contact_location3_li' txt="+item+"><a >"+item+"</a></li>")
  75. var li=$("<option>"+item+"</option>")
  76. $(".showlistLocation3").append(li)
  77. })
  78. var html_contact_number=$("#contact_number").html();
  79. var html_contact_email=$("#contact_email").html();
  80. var html_contact_location=$("#contact_location").html();
  81. $("#contact_number_add").click(function(){
  82. $("#contact_number").append(html_contact_number)
  83. $("#contact_number_remove").show()
  84. })
  85. $("#contact_number_remove").click(function(){
  86. $("#contact_number .row-fluid").eq(-1).remove();
  87. if($("#contact_number .row-fluid").length==1){
  88. $("#contact_number_remove").hide()
  89. }
  90. })
  91. $("#contact_email_add").click(function(){
  92. $("#contact_email").append(html_contact_email)
  93. $("#contact_email_remove").show()
  94. })
  95. $("#contact_email_remove").click(function(){
  96. $("#contact_email input").eq(-1).remove();
  97. if($("#contact_email input").length==1){
  98. $("#contact_email_remove").hide()
  99. }
  100. })
  101. $("#contact_location_add").click(function(){
  102. $("#contact_location").append(html_contact_location)
  103. $("#contact_location_remove").show()
  104. })
  105. $("#contact_location_remove").click(function(){
  106. $("#contact_location .row-fluid").eq(-1).remove();
  107. if($("#contact_location .row-fluid").length==1){
  108. $("#contact_location_remove").hide()
  109. }
  110. })
  111. $.validator.setDefaults({
  112. submitHandler: function() {
  113. var submitlogo=$("#uploadButtonInput").val();
  114. if(!submitlogo){
  115. alert("请上传公司logo")
  116. }
  117. }
  118. });
  119. $("#form").validate()
  120. //页面初始化end
  121. })