1
2
3
4
5
6
7
8
业务员-终审上传资料9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 var user_id = $api.getStorage('user_id');48 varstr0;49 varbiaotiid;50 var xinstr =[];51 var altimgArr =[];52 var list =[];53 vartypes;54 varvideo_vi;55
56
57 //var dd = '20180508171316363781'
58 apiready = function() {59 upnames =api.pageParam.upname;60 upnums =api.pageParam.upnum;61 console.log(JSON.stringify(upnames));62 console.log(JSON.stringify(upnums));63 //zsreceive();
64
65 xin();66
67 //加红点
68 var newdiv = '
69 $('.top').prepend(newdiv);70 };71
72 functionxin() {73 api.ajax({74 url: 'http://xxxxx/index/repay/getRepayDataNew',75 method: 'post',76 data: {77 values: {78 order_id: upnames79 }80 }81 }, function(ret, err) {82 if(ret) {83 //console.log(JSON.stringify(ret.data));
84 var retData =ret.data;85 console.log(retData.length);86
87 for (var i = 0; i < retData.length; i++) {88 //console.log(JSON.stringify(retData[i].list_content))
89 var means =retData[i].list_content90
91
92 //xinstr.length = 0;
93 for (var j = 0; j < means.length; j++) {94 //console.log(JSON.stringify(means[j].material_content[0].name))
95 var biaoti = means[j].material_content[0].name;96
97 var tj =means[j].material_content;98 //console.log(JSON.stringify(tj.length));
99 biaotiid =means[j].material_id;100 types =means[j].type;101
102
103 xinstr.push(biaotiid)104
105 var biaoti_html = ''
106 biaoti_html += '
107 '
108 '
109 '
110
111
112 '
113 '
114 '' +
115 '
116 '
117 '
118
119
120 '
121 '
122 '
123 '
124
125 $('#z').append(biaoti_html);126
127
128 for (var z = 0; z < tj.length; z++) {129 //console.log(JSON.stringify(tj));
130 var pss =tj[z].material_path;131 var wipelater = pss.replace(/http:\/\/[^\/]*/g, "").replace(/\"/g, "");132 str0 = pss.substring(pss.length - 5, pss.length - 9);133 var str = pss.substring(pss.length - 4, pss.length - 9);134 var pic_html = '';135 if (types == 3) {136 pic_html += '
137 '' +
138 '
139 '
140 } else{141 pic_html += '
142 '' +
143 '
144 '
145 }146
147 if (tj[z].material_path != '') {148 $('#' + biaotiid + '').before(pic_html);149 }150
151
152 var altimg = $('#' + str0 + '').children('img').attr("alt");153
154 //console.log(altimg);
155 altimgArr.push(altimg);156 list.push({157 [biaotiid]: wipelater158 })159
160 }161
162 }163
164 }165
166 } else{167 alert(JSON.stringify(err));168 }169 });170 }171
172 //操作数组
173 functionscy(roomNames) {174 //console.log(roomNames);
175 //console.log(roomNames.length);
176 allRoom ={};177 if (roomNames.length > 0) {178 for (var i = 0; i < roomNames.length; i++) {179 var map =roomNames[i];180 //console.log($api.strToJson(map));
181 for (var k inmap) {182 //console.log(k+','+map[k]);
183 if (k != null && k != 'null') {184 if (allRoom.hasOwnProperty(k)) { //true
185 allRoom[k] += ',' +map[k];186 } else{187 allRoom[k] =map[k];188 }189 }190 }191 }192 }193 //console.log(JSON.stringify(allRoom));
194 //list.push(allRoom)
195 }196
197 //播放
198 functionplay(thisVid, szi) {199 if (szi == 0) {200 var thVideo =thisVid.parentNode.firstChild.name;201 console.log(thVideo);202 api.openVideo({203 url: thVideo204 });205 } else{206 //'fs://res/1.mp4' /storage/emulated/0/相机/video_20190325_131837.mp4
207 var thVideo =thisVid.parentNode.firstChild.name;208
209 var urls = 'http://xxxxxx/' +thVideo;210 api.openVideo({211 url: urls212 });213
214 console.log();215 }216
217 }218
219
220 //删除图片、视频
221 functiondeletePic(btid, ever) {222 //console.log(btid);
223 var strbtid =JSON.stringify(btid);224 var strlist =JSON.stringify(list);225 //console.log();
226 for (var i = 0; i < list.length; i++) {227 var ks =JSON.stringify(list[i]);228 if (ks.indexOf(strbtid) != -1) {229 list.splice(i, 1);230 i--;231 }232 }233 //console.log(JSON.stringify(list));
234 ever.parentNode.parentNode.removeChild(ever.parentNode);235 }236
237 //点击图片放大
238 functionenlarge(everPic, str0) {239 //alert('点击放大')
240 var pics = (everPic.parentNode.firstChild.src) || ($('#' + str0 + '').attr('src'));241 //console.log(pics);
242 $('#bigpic').show();243 $('.z').hide();244 $('#bigpic img').attr('src', pics);245 }246 $(function() {247 $('#bigpic').click(function() {248 $('#bigpic').hide();249 $('.z').show();250 })251 })252
253 //添加弹窗
254 functionadd(biaotiid, typ) {255 var divlength = $('.img').children('#' + biaotiid + '').length;256 console.log(divlength);257
258 if (typ == 1 && divlength >= 2) {259 api.toast({260 msg: '本栏只可添加一张图片!',261 duration: 1000,262 location: 'middle'
263 });264 } else{265
266 if (typ == 3) {267 api.actionSheet({268 cancelTitle: '取消',269 buttons: ['视频']270 }, function(ret, err) {271 index =ret.buttonIndex;272 //console.log(JSON.stringify(index));
273 if(ret) {274 //console.log( JSON.stringify( ret ) );
275 if (index == 1) {276 //视频
277 api.getPicture({278 sourceType: 'camera',279 //encodingType: 'mp4',
280 mediaValue: 'video',281 videoQuality: 'medium',282 saveToPhotoAlbum: true,283 destinationType: 'url'
284 }, function(ret3, err) {285 if(ret3) {286 //console.log(JSON.stringify(ret));
287 video_vi =ret3.data;288 console.log(JSON.stringify(video_vi));289 //--------------------------------------------
290 if(video_vi) {291 uploadVideo(biaotiid, video_vi, typ)292 }293 } else{294 console.log(JSON.stringify(err));295 }296 });297 }298 } else{299 console.log(JSON.stringify(err));300 }301 })302
303 } else{304 api.actionSheet({305 cancelTitle: '取消',306 buttons: ['拍照', '手机相册']307 }, function(ret, err) {308 index =ret.buttonIndex;309 if(ret) {310 console.log(JSON.stringify(ret));311 if (index == 1) {312 api.getPicture({313 sourceType: 'camera',314 encodingType: 'jpg',315 mediaValue: 'pic',316 destinationType: 'url',317 allowEdit: false,318 quality: 100,319 saveToPhotoAlbum: false
320 }, function(ret1, err1) {321 if(ret1) {322 console.log(JSON.stringify(ret1));323 img_pic1 =ret1.data;324 if(img_pic1) {325 uploadPic(biaotiid, img_pic1, typ);326 }327 } else{328 alert(JSON.stringify(err));329 }330 });331
332 } else if (index == 2) {333 api.getPicture({334 sourceType: 'library',335 encodingType: 'png',336 mediaValue: 'pic',337 destinationType: 'url',338 allowEdit: true,339 quality: 100,340 preview: true,341 saveToPhotoAlbum: false
342 }, function(ret2, err2) {343 if(ret2) {344 //console.log(JSON.stringify(ret2));
345 img_pic2 =ret2.data;346 if(img_pic2) {347 uploadPic(biaotiid, img_pic2, typ);348 }349 } else{350 alert(JSON.stringify(err));351 }352 });353 }354 } else{355 alert(JSON.stringify(err));356 }357 });358
359 }360
361 }362
363 }364
365 //上传视频
366 functionuploadVideo(biaotiid, video_vi, typ) {367 api.showProgress({368 title: '加载中...',369 text: ''
370 });371 api.ajax({372 url: 'http://xxxxxxx/index/system/uploadVideo',373 method: 'post',374 data: {375 files: {376 video: video_vi377 }378 }379 }, function(ret, err) {380 if(ret) {381 //console.log( JSON.stringify( ret ) );
382 var uploadVideo_later =ret.data383
384 //add_video(video_vi, idname, uploadVideo_later);
385 addhtml(biaotiid, video_vi, uploadVideo_later, typ);386
387 api.hideProgress();388 } else{389 console.log(JSON.stringify(err));390 api.hideProgress();391 }392 });393
394 }395
396 //上传图片
397 functionuploadPic(biaotiid, img_pic, typ) {398 api.showProgress({399 style: 'default',400 animationType: 'fade',401 title: '努力加载中...',402 text: '请耐心等待...',403 modal: false
404 });405
406 api.ajax({407 url: 'http://xxxxxxxx/index/system/uploadImg',408 method: 'post',409 data: {410 files: {411 image: img_pic412 }413 }414 }, function(ret, err) {415 if(ret) {416 //console.log(JSON.stringify(ret));
417 var change =ret.data418 addhtml(biaotiid, img_pic, change, typ);419
420 api.hideProgress();421
422 } else{423 console.log(JSON.stringify(err));424 api.hideProgress();425 }426 });427 }428
429 //动态添加公用函数
430 functionaddhtml(biaotiid, dynamic, change, typ) {431 console.log(change);432 str1 = change.substring(change.length - 4, change.length - 9);433 var dongtai_html = '';434
435 if (typ == 3) {436 console.log(JSON.stringify(dynamic));437 var vi =JSON.stringify(dynamic);438 dynamic2 = vi.replace(/\"/g, "").replace(/\[/g, "").replace(/\]/g, "");439 console.log(dynamic2);440
441 dongtai_html += '
442 '' +
443 '
444 '
445 } else{446 dongtai_html += '
447 '' +
448 '
449 '
450 '
451 }452
453 $('#' + biaotiid + '').before(dongtai_html);454
455 //console.log($('#z').html());
456 list.push({457 [biaotiid]: change458 });459 //console.log(JSON.stringify(list));
460 }461
462 //提交
463 functionupdata() {464 //arrClass();
465 var dialogBox = api.require('dialogBox');466 dialogBox.alert({467 texts: {468 title: '提示',469 content: '您确定提交所有内容吗?',470 leftBtnTitle: '取消',471 rightBtnTitle: '确认'
472 },473 styles: {474 bg: '#fff',475 w: 300,476 corner: 2,477 title: {478 marginT: 20,479 icon: 'widget://res/gou.png',480 iconSize: 40,481 titleSize: 22,482 titleColor: '#000'
483 },484 content: {485 color: '#000',486 size: 16
487 },488 left: {489 marginB: 7,490 marginL: 20,491 w: 130,492 h: 35,493 corner: 2,494 bg: '#fff',495 color: '#F3544E',496 size: 14
497 },498 right: {499 marginB: 7,500 marginL: 10,501 w: 130,502 h: 35,503 corner: 2,504 bg: '#fff',505 color: '#F3544E',506 size: 14
507 }508 }509 }, function(ret) {510 if (ret.eventType == 'left') {511 //取消
512 var dialogBox = api.require('dialogBox');513 dialogBox.close({514 dialogName: 'alert'
515 });516
517 } else if (ret.eventType == 'right') {518 //确定
519 var dialogBox = api.require('dialogBox');520 dialogBox.close({521 dialogName: 'alert'
522 });523
524 var orid ={525 order_id: upnames526 }527 list.push(orid);528 scy(list);529 console.log(JSON.stringify(allRoom));530
531
532 //数据提交
533 api.ajax({534 url: 'http://xxxxxxx/index/repay/dataUploadNew',535 method: 'post',536 data: {537 values: allRoom538 }539 }, function(ret, err) {540 if(ret) {541 console.log(JSON.stringify(ret));542 //api.closeWin({});
543 //退出
544 api.openWin({545 name: 'tab',546 url: './tab.html',547 reload: true
548 });549 //刷新
550 api.sendEvent({551 name: 'ywydsx',552 extra: {553 key0: 'y'
554 }555 });556 } else{557 alert(JSON.stringify(err));558 }559 });560
561 }562 });563
564 }565
566
567 //function arrClass() {
568 //console.log(biaotiid);
569 //$('.' + biaotiid + '').each(function() {
570 //console.log($(this).children('img').attr("alt"));
571 //});
572 //}
573
574
575