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.

IndexOfDC.cshtml 13 KiB

4 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. @{
  2. ViewBag.Title = "学生学籍";
  3. Layout = "~/Views/Shared/_Index.cshtml";
  4. }
  5. <div class="lr-layout ">
  6. <div class="lr-layout-center">
  7. <div class="lr-layout-wrap lr-layout-wrap-notitle ">
  8. <div class="lr-layout-tool">
  9. <div class="lr-layout-tool-left">
  10. <div class="lr-layout-tool-item">
  11. <div id="multiple_condition_query">
  12. <div class="lr-query-formcontent">
  13. <div class="col-xs-6 lr-form-item">
  14. <div class="lr-form-item-title">学号</div>
  15. <input id="StuNo" type="text" class="form-control" />
  16. </div>
  17. <div class="col-xs-6 lr-form-item">
  18. <div class="lr-form-item-title">姓名</div>
  19. <input id="StuName" type="text" class="form-control" />
  20. </div>
  21. <div class="col-xs-12 lr-form-item">
  22. <div class="lr-form-item-title">专业</div>
  23. <div id="MajorNo"></div>
  24. </div>
  25. <div class="col-xs-12 lr-form-item">
  26. <div class="lr-form-item-title">班级</div>
  27. <div id="ClassNo"></div>
  28. </div>
  29. <div class="col-xs-12 lr-form-item">
  30. <div class="lr-form-item-title">备注</div>
  31. <input id="Remark" type="text" class="form-control" />
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. <div class="lr-layout-tool-right">
  38. <div class=" btn-group btn-group-sm">
  39. <a id="lr_refresh" class="btn btn-default"><i class="fa fa-refresh"></i></a>
  40. </div>
  41. <div class=" btn-group btn-group-sm" learun-authorize="yes">
  42. <a id="lr_add" class="btn btn-default"><i class="fa fa-plus"></i>&nbsp;录入</a>
  43. <a id="lr_edit" class="btn btn-default"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a>
  44. <a id="lr_delete" class="btn btn-default"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
  45. <a id="lr_view" class="btn btn-default"><i class="fa fa-pencil-square-o"></i>&nbsp;查看</a>
  46. <a id="lr_print" class="btn btn-default"><i class="fa fa-print"></i>&nbsp;打印</a>
  47. <a id="check" class="btn btn-default"><i class="fa fa-lock"></i>&nbsp;审核</a>
  48. <a id="uncheck" class="btn btn-default"><i class="fa fa-unlock"></i>&nbsp;去审</a>
  49. <a id="checkall" class="btn btn-default"><i class="fa fa-print"></i>&nbsp;审核全部</a>
  50. <a id="lr_generate" class="btn btn-default"><i class="fa fa-linode"></i>&nbsp;生成帐号</a>
  51. <a id="lr_update" class="btn btn-default"><i class="fa fa-braille"></i>&nbsp;更新帐号</a>
  52. <a id="lr_synPhoto" class="btn btn-default"><i class="fa fa-braille"></i>&nbsp;同步照片</a>
  53. <a id="lr_searchChange" class="btn btn-default"><i class="fa fa-search"></i>&nbsp;查看异动</a>
  54. <a id="lr_photo" class="btn btn-default"><i class="fa fa-search"></i>&nbsp;拍照</a>
  55. </div>
  56. </div>
  57. </div>
  58. <div class="lr-layout-body" id="gridtable"></div>
  59. <div style="display: none" class="tailoring-container">
  60. <div class="black-cloth" onclick="closeTailor(this)"></div>
  61. <div class="tailoring-content">
  62. <div class="tailoring-content-one">
  63. <label title="上传图片" for="chooseImg" class="l2-btn choose-btn">
  64. <input type="file" accept="image/jpg,image/jpeg,image/png" name="file" id="chooseImg" class="hidden" onchange="selectImg(this)">
  65. 本地上传
  66. </label>
  67. <label title="拍照" class="l2-btn choose-btn" id='capture' style="margin-left: 2%;">拍照</label>
  68. <label title="重拍" class="l2-btn choose-btn" id='takeAgain' style="margin-left: 2%;">重拍</label>
  69. <div class="close-tailoring" onclick="closeTailor(this)">×</div>
  70. </div>
  71. <div class="tailoring-content-two">
  72. <div class="tailoring-box-parcel">
  73. <video id="video" width="100%" height="100%" style="float: left;"></video>
  74. <canvas id="canvas" width="482px" height="448px" style="float: left;" hidden="hidden"></canvas>
  75. <div id="showImg" hidden="hidden" style="width: 100%;height:100%;">
  76. <img id="tailoringImg">
  77. </div>
  78. </div>
  79. <div class="preview-box-parcel">
  80. <p>图片预览:</p>
  81. <div class="square previewImg"></div>
  82. <div class="circular previewImg"></div>
  83. </div>
  84. </div>
  85. <div class="tailoring-content-three">
  86. <button class="l2-btn cropper-reset-btn">复位</button>
  87. <button class="l2-btn cropper-rotate-btn">旋转</button>
  88. <button class="l2-btn cropper-scaleX-btn">换向</button>
  89. <button class="l2-btn sureCut" id="sureCut">确定</button>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. @Html.AppendJsFile("/Areas/EducationalAdministration/Views/StuInfoBasic/IndexOfDC.js", "/Content/camera/cropper.min.js",
  97. "/Areas/EducationalAdministration/Views/StuEnroll/LodopFuncs.js")
  98. @Html.AppendCssFile("/Content/camera/cropper.min.css", "/Content/camera/ImgCropping.css")
  99. <script>
  100. //弹出框水平垂直居中
  101. (window.onresize = function () {
  102. var win_height = $(window).height();
  103. var win_width = $(window).width();
  104. if (win_width <= 768) {
  105. $(".tailoring-content").css({
  106. "top": (win_height - $(".tailoring-content").outerHeight()) / 2,
  107. "left": 0
  108. });
  109. } else {
  110. $(".tailoring-content").css({
  111. "top": (win_height - $(".tailoring-content").outerHeight()) / 2,
  112. "left": (win_width - $(".tailoring-content").outerWidth()) / 2
  113. });
  114. }
  115. })();
  116. //图像上传
  117. function selectImg(file) {
  118. if (!file.files || !file.files[0]) {
  119. return;
  120. }
  121. var reader = new FileReader();
  122. reader.onload = function (evt) {
  123. var replaceSrc = evt.target.result;
  124. //更换cropper的图片
  125. $('#tailoringImg').cropper('replace', replaceSrc, false);//默认false,适应高度,不失真
  126. }
  127. reader.readAsDataURL(file.files[0]);
  128. mediaStreamTrack && mediaStreamTrack.stop();
  129. $("#video").hide();
  130. $("#showImg").show();
  131. }
  132. //cropper图片裁剪
  133. $('#tailoringImg').cropper({
  134. aspectRatio: 5 / 7,//默认比例
  135. preview: '.previewImg',//预览视图
  136. guides: false, //裁剪框的虚线(九宫格)
  137. autoCropArea: 0.5, //0-1之间的数值,定义自动剪裁区域的大小,默认0.8
  138. movable: false, //是否允许移动图片
  139. dragCrop: true, //是否允许移除当前的剪裁框,并通过拖动来新建一个剪裁框区域
  140. movable: true, //是否允许移动剪裁框
  141. resizable: true, //是否允许改变裁剪框的大小
  142. zoomable: false, //是否允许缩放图片大小
  143. mouseWheelZoom: false, //是否允许通过鼠标滚轮来缩放图片
  144. touchDragZoom: true, //是否允许通过触摸移动来缩放图片
  145. rotatable: true, //是否允许旋转图片
  146. crop: function (e) {
  147. // 输出结果数据裁剪图像。
  148. }
  149. });
  150. //旋转
  151. $(".cropper-rotate-btn").on("click", function () {
  152. $('#tailoringImg').cropper("rotate", 45);
  153. });
  154. //复位
  155. $(".cropper-reset-btn").on("click", function () {
  156. $('#tailoringImg').cropper("reset");
  157. });
  158. //换向
  159. var flagX = true;
  160. $(".cropper-scaleX-btn").on("click", function () {
  161. if (flagX) {
  162. $('#tailoringImg').cropper("scaleX", -1);
  163. flagX = false;
  164. } else {
  165. $('#tailoringImg').cropper("scaleX", 1);
  166. flagX = true;
  167. }
  168. flagX != flagX;
  169. });
  170. //裁剪后的处理
  171. $("#sureCut").on("click", function () {
  172. var cas = $('#tailoringImg').cropper('getCroppedCanvas');//获取被裁剪后的canvas
  173. var base64url = cas.toDataURL('image/png'); //转换为base64地址形式
  174. base64url = base64url.replace("\r", "");
  175. top.learun.postForm(top.$.rootUrl + '/EducationalAdministration/StuInfoBasic/IsPhoto', { stuId: StuId, base64url: base64url },
  176. function (res) {
  177. //关闭裁剪框
  178. StuId = "";
  179. closeTailor();
  180. refreshGirdData();
  181. });
  182. });
  183. //关闭裁剪框
  184. function closeTailor() {
  185. StuId = "";
  186. $(".tailoring-container").toggle();
  187. mediaStreamTrack && mediaStreamTrack.stop();
  188. }
  189. let video = document.getElementById('video');
  190. let canvas = document.getElementById('canvas');
  191. let context = canvas.getContext('2d');
  192. var mediaStreamTrack;
  193. document.getElementById('capture').addEventListener('click',
  194. function () {
  195. context.drawImage(video, 0, 0, 518, 420);
  196. mediaStreamTrack && mediaStreamTrack.stop();
  197. $('#tailoringImg').cropper('replace', canvas.toDataURL("image/png"), false); //默认false,适应高度,不失真
  198. $("#video").hide(); //隐藏拍照框
  199. $("#showImg").show(); //将拍照结果显示
  200. });
  201. //请求拍照
  202. $("#takeAgain").bind("click", function () {
  203. takePhoto();
  204. });
  205. //开始拍照
  206. function takeImg() {
  207. $(".tailoring-container").toggle();
  208. takePhoto();
  209. }
  210. //请求摄像头
  211. function takePhoto() {
  212. // 老的浏览器可能根本没有实现 mediaDevices,所以我们可以先设置一个空的对象
  213. if (navigator.mediaDevices === undefined) {
  214. navigator.mediaDevices = {};
  215. }
  216. if (navigator.mediaDevices.getUserMedia === undefined) {
  217. navigator.mediaDevices.getUserMedia = function (constraints) {
  218. // 首先,如果有getUserMedia的话,就获得它
  219. var getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
  220. // 一些浏览器根本没实现它 - 那么就返回一个error到promise的reject来保持一个统一的接口
  221. if (!getUserMedia) {
  222. return Promise.reject(new Error('不支持此浏览器,请更换Chrome或360浏览器'));
  223. }
  224. // 否则,为老的navigator.getUserMedia方法包裹一个Promise
  225. return new Promise(function (resolve, reject) {
  226. getUserMedia.call(navigator, constraints, resolve, reject);
  227. });
  228. }
  229. }
  230. const constraints = {
  231. video: true,
  232. audio: false
  233. };
  234. let videoPlaying = false;
  235. let promise = navigator.mediaDevices.getUserMedia(constraints);
  236. promise.then(stream => {
  237. // 旧的浏览器可能没有srcObject
  238. if ("srcObject" in video) {
  239. video.srcObject = stream;
  240. mediaStreamTrack = stream.getTracks()[0];
  241. } else {
  242. // 防止再新的浏览器里使用它,应为它已经不再支持了
  243. video.src = window.URL.createObjectURL(stream);
  244. }
  245. video.onloadedmetadata = function (e) {
  246. video.play();
  247. videoPlaying = true;
  248. };
  249. }).catch(err => {
  250. console.error(err.name + ": " + err.message);
  251. });
  252. $("#showImg").hide();//隐藏拍照结果显示框
  253. //$('#showImg').html('<img id="tailoringImg" hidden="hidden">')
  254. $("#video").show();//开启拍照框
  255. }
  256. </script>