portal html css js resource

upload.js 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. var typenum,authStatus;
  2. var userid = $.cookie("userid");
  3. var sett = GetQueryString("set");
  4. if(sett==3){
  5. $("#sfnav").addClass("bgcolor").siblings().removeClass("bgcolor");
  6. $("#sfbox").show().siblings().hide();
  7. }
  8. //角色切换
  9. $(".IdentityChoice").on("click",".boxnav li",function(){
  10. $(this).addClass("set").siblings().removeClass("set");
  11. })
  12. //初始化身份状态
  13. $.ajax("/ajax/professor/auth",{
  14. data:{"id":userid},
  15. type:"GET",
  16. dataType: 'json',
  17. async: false,
  18. success:function(data){
  19. var $info = data.data || {};
  20. if(data.success && data.data) {
  21. authStatus=$info.authStatus;
  22. console.log(authStatus)
  23. if($info.authStatus==0){
  24. $(".identProcess").text("暂时还未进行身份认证");
  25. $(".identBtn").text("现在去认证");
  26. }else if($info.authStatus==1){
  27. $(".identProcess").text("已经通过身份认证");
  28. $(".identBtn").text("重新认证");
  29. }else if($info.authStatus==2){
  30. $(".identProcess").text("身份待审核 ");
  31. $(".identts").text("(认证审核期间不能重复认证操作) ");
  32. $(".identBtn").hide();
  33. }else if($info.authStatus==3){
  34. $(".identProcess").text("身份审核中");
  35. $(".identts").text("(认证审核期间不能重复认证操作) ");
  36. $(".identBtn").hide();
  37. }else if($info.authStatus==4){
  38. $(".identProcess").text("身份认证通过,请重新认证");
  39. $(".identBtn").text("重新认证");
  40. }else if($info.authStatus==5){
  41. $(".identProcess").text("身份认证失败,请重新认证");
  42. $(".identBtn").text("重新认证");
  43. }
  44. typenum = $info.authentication;
  45. authStatus=$info.authStatus;
  46. }else{
  47. $.MsgBox.Alert("消息提醒","系统异常!");
  48. }
  49. },
  50. error:function(){
  51. $.MsgBox.Alert("消息提醒","系统异常!");
  52. }
  53. });
  54. $(".boxnav span").each(function () {
  55. var datanum =$(this).attr("data-num");
  56. if(datanum==typenum){
  57. $(this).parent().addClass("set");
  58. }
  59. });
  60. $(".identBtn").on("click",function(){
  61. if(authStatus==0 && authStatus==4 && authStatus==5){
  62. $(".IdentityUp").show();
  63. $('.IdentityState').hide();
  64. }else if(authStatus==1){
  65. $(".IdentityUp").show();
  66. $('.IdentityState').hide();
  67. }
  68. })
  69. //提交上传
  70. $('.subUp').on("click", function() {
  71. var imglen = $(".uploader-list .thumbnail").length;
  72. if(imglen == 0) {
  73. $.MsgBox.Alert("消息提醒","请上传能够证明您身份的相关证件");
  74. } else {
  75. typename(userid, typenum);
  76. }
  77. })
  78. //添加认证申请信息
  79. function typename(userid, usertype) {
  80. $.ajax("/ajax/authApply",{
  81. data:{"professorId":userid,"applyType":usertype},
  82. type:"post",
  83. dataType: 'json',
  84. async: false,
  85. success:function(data){
  86. if(data.success) {
  87. var authapplyid = data.data;
  88. $(".uploader-list img").each(function() {
  89. var str = $(this).attr("src");
  90. var base64 = str.replace("data:image/jpeg;base64,", "");
  91. //console.log(base64);
  92. typeimg(authapplyid, base64);
  93. });
  94. }else{
  95. $.MsgBox.Alert("消息提醒","系统异常!");
  96. }
  97. },
  98. error:function(){
  99. $.MsgBox.Alert("消息提醒","系统异常!");
  100. }
  101. });
  102. }
  103. //添加申请认证图片
  104. function typeimg(authapplyid, base64) {
  105. $.ajax("/ajax/authImage",{
  106. data:{"authApplyId":authapplyid,"base64":base64},
  107. type:"post",
  108. dataType: 'json',
  109. async: false,
  110. success:function(data){
  111. if(data.success) {
  112. $.MsgBox.Alert("消息提醒","认证图片上传成功");
  113. window.location.href="account-set.html?set=3";
  114. }
  115. },
  116. error:function(){
  117. $.MsgBox.Alert("消息提醒","系统异常!");
  118. }
  119. });
  120. }
  121. /*图片上传*/
  122. var uploader = WebUploader.create({
  123. auto: true,// 选完文件后,是否自动上传。
  124. swf: 'webuploader/Uploader.swf',// swf文件路径
  125. pick: '#filePicker', // 选择文件的按钮。可选。
  126. duplicate :true ,//允许图片重复上传
  127. // 只允许选择图片文件。
  128. accept: {
  129. title: 'Images',
  130. extensions: 'gif,jpg,jpeg,bmp,png',
  131. mimeTypes: 'image/*'
  132. }
  133. });
  134. // 当有文件添加进来的时候
  135. uploader.on( 'fileQueued', function( file ) {
  136. var $li = $(
  137. '<div id="' + file.id + '" class="file-item thumbnail">' +
  138. '<img>' +
  139. //'<div class="info">' + file.name + '</div>' +
  140. '</div>'
  141. ),
  142. $btns = $('<div class="file-panel">' +
  143. '<span class="cancel">删除</span>' +
  144. '</div>').appendTo( $li ),
  145. $img = $li.find('img');
  146. var $list = $("#fileList");
  147. $list.prepend( $li );
  148. // 创建缩略图
  149. // 如果为非图片文件,可以不用调用此方法。
  150. // thumbnailWidth x thumbnailHeight 为 100 x 100
  151. uploader.makeThumb( file, function( error, src ) {
  152. if ( error ) {
  153. $img.replaceWith('<span>不能预览</span>');
  154. return;
  155. }
  156. $img.attr( 'src', src );
  157. }, 1000, 1000 );
  158. $li.on( 'mouseenter', function() {
  159. $btns.stop().animate({height: 30});
  160. });
  161. $li.on( 'mouseleave', function() {
  162. $btns.stop().animate({height: 0});
  163. });
  164. });
  165. /*
  166. // 文件上传成功,给item添加成功class, 用样式标记上传成功。
  167. uploader.on( 'uploadSuccess', function( file ) {
  168. });*/
  169. $("#fileList").on("click",".cancel",function(){
  170. $(this).parent().parent().remove();
  171. })
  172. $(".webuploader-pick").css({"width":"100px","height":"100px"});
  173. /*图片上传结束*/