portal html css js resource

upload.js 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. $(".IdentityUp").show();
  62. $('.IdentityState').hide();
  63. /*if(authStatus==0 && authStatus==4 && authStatus==5){
  64. $(".IdentityUp").show();
  65. $('.IdentityState').hide();
  66. }else if(authStatus==1){
  67. $(".IdentityUp").show();
  68. $('.IdentityState').hide();
  69. }*/
  70. })
  71. //提交上传
  72. $('.subUp').on("click", function() {
  73. var imglen = $(".uploader-list .thumbnail").length;
  74. if(imglen == 0) {
  75. $.MsgBox.Alert("消息提醒","请上传能够证明您身份的相关证件");
  76. } else {
  77. typename(userid, typenum);
  78. }
  79. })
  80. //添加认证申请信息
  81. function typename(userid, usertype) {
  82. $.ajax("/ajax/authApply",{
  83. data:{"professorId":userid,"applyType":usertype},
  84. type:"post",
  85. dataType: 'json',
  86. async: false,
  87. success:function(data){
  88. if(data.success) {
  89. var authapplyid = data.data;
  90. $(".uploader-list img").each(function() {
  91. var str = $(this).attr("src");
  92. var base64 = str.replace("data:image/jpeg;base64,", "");
  93. //console.log(base64);
  94. typeimg(authapplyid, base64);
  95. });
  96. }else{
  97. $.MsgBox.Alert("消息提醒","系统异常!");
  98. }
  99. },
  100. error:function(){
  101. $.MsgBox.Alert("消息提醒","系统异常!");
  102. }
  103. });
  104. }
  105. //添加申请认证图片
  106. function typeimg(authapplyid, base64) {
  107. $.ajax("/ajax/authImage",{
  108. data:{"authApplyId":authapplyid,"base64":base64},
  109. type:"post",
  110. dataType: 'json',
  111. async: false,
  112. success:function(data){
  113. if(data.success) {
  114. $.MsgBox.Alert("消息提醒","认证图片上传成功");
  115. window.location.href="account-set.html?set=3";
  116. }
  117. },
  118. error:function(){
  119. $.MsgBox.Alert("消息提醒","系统异常!");
  120. }
  121. });
  122. }
  123. /*图片上传*/
  124. var uploader = WebUploader.create({
  125. auto: true,// 选完文件后,是否自动上传。
  126. swf: 'webuploader/Uploader.swf',// swf文件路径
  127. pick: '#filePicker', // 选择文件的按钮。可选。
  128. duplicate :true ,//允许图片重复上传
  129. // 只允许选择图片文件。
  130. accept: {
  131. title: 'Images',
  132. extensions: 'gif,jpg,jpeg,bmp,png',
  133. mimeTypes: 'image/*'
  134. }
  135. });
  136. // 当有文件添加进来的时候
  137. uploader.on( 'fileQueued', function( file ) {
  138. var $li = $(
  139. '<div id="' + file.id + '" class="file-item thumbnail">' +
  140. '<img>' +
  141. //'<div class="info">' + file.name + '</div>' +
  142. '</div>'
  143. ),
  144. $btns = $('<div class="file-panel">' +
  145. '<span class="cancel">删除</span>' +
  146. '</div>').appendTo( $li ),
  147. $img = $li.find('img');
  148. var $list = $("#fileList");
  149. $list.prepend( $li );
  150. // 创建缩略图
  151. // 如果为非图片文件,可以不用调用此方法。
  152. // thumbnailWidth x thumbnailHeight 为 100 x 100
  153. uploader.makeThumb( file, function( error, src ) {
  154. if ( error ) {
  155. $img.replaceWith('<span>不能预览</span>');
  156. return;
  157. }
  158. $img.attr( 'src', src );
  159. }, 1000, 1000 );
  160. $li.on( 'mouseenter', function() {
  161. $btns.stop().animate({height: 30});
  162. });
  163. $li.on( 'mouseleave', function() {
  164. $btns.stop().animate({height: 0});
  165. });
  166. });
  167. /*
  168. // 文件上传成功,给item添加成功class, 用样式标记上传成功。
  169. uploader.on( 'uploadSuccess', function( file ) {
  170. });*/
  171. $("#fileList").on("click",".cancel",function(){
  172. $(this).parent().parent().remove();
  173. })
  174. $(".webuploader-pick").css({"width":"100px","height":"100px"});
  175. /*图片上传结束*/