123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- var packageParser = function () {
- return function () {
- var e = {
- singleAllow: 314572800,
- openLargeAppUpload: 0,
- qndomain: "",
- gettoken: "/qiniuoss/getToken",
- flash_swf_url: "/static/default/images/Moxie.swf",
- autoClickUploadStart: 0,
- mime_types: [{title: "app files", extensions: "apk"}, {title: "ipa files", extensions: "ipa"}, {title: "mobileconfig files", extensions: "mobileconfig"}],
- postField: {},
- upload: "",
- saveCallback: function () {
- },
- parseCallback: function () {
- }
- };
- this.init = function (i) {
- e = $.extend(e, i);
- var a = {};
- $.ajax({
- type: "GET", url: e.gettoken, success: function (i) {
- var o = Qiniu.uploader({
- runtimes: "html5,flash,html4",
- browse_button: "uploadstart",
- uptoken: i,
- unique_names: !0,
- save_key: !1,
- domain: e.qndomain,
- get_new_uptoken: !1,
- container: "container",
- flash_swf_url: e.flash_swf_url,
- max_retries: 3,
- dragdrop: !0,
- drop_element: "container",
- chunk_size: "4mb",
- auto_start: !1,
- multi_selection: !1,
- filters: {max_file_size: "5000mb", prevent_duplicates: !0, mime_types: e.mime_types},
- init: {
- PostInit: function (i, a) {
- 0 != e.autoClickUploadStart && (console.log("autoupload"), $("#uploadstart").click())
- }, FilesAdded: function (i, n) {
- if(n[0].name&&n[0].name.indexOf('mobileconfig')>-1){
- console.log(n[0]);o.start()
- }else{
- console.log(n), plupload.each(n, function (i) {
- new AppInfoParser(i.getNative()).parse().then(n => {
- a.icon = n.icon, a.fileSize = i.size, a.originalName = i.name, n.package ? (a.appName = "string" == typeof n.application.label ? n.application.label : n.application.label[0], a.version = n.versionName, a.versionCode = n.versionCode, a.packageName = n.package, a.ext = "apk", a.minSdkVersion = n.usesSdk.minSdkVersion) : (a.appName = n.CFBundleDisplayName ? n.CFBundleDisplayName : n.CFBundleName, a.version = n.CFBundleShortVersionString, a.versionCode = n.CFBundleVersion, a.packageName = n.CFBundleIdentifier, a.ext = "ipa", a.minSdkVersion = n.MinimumOSVersion, a.teamName = n.mobileProvision.TeamName, a.udids = "", a.teamId = n.mobileProvision.TeamIdentifier, n.mobileProvision.ProvisionsAllDevices ? a.teamType = 1 : n.mobileProvision.ProvisionedDevices ? (n.mobileProvision.Entitlements["get-task-allow"] ? a.teamType = 2 : a.teamType = 3, a.udids = n.mobileProvision.ProvisionedDevices) : a.teamType = 4), e.parseCallback(i, a), $(".upload-app-icon").find("img").attr("src", a.icon), $("#upload-app-name").text(a.appName), o.start()
- }).catch(e => {
- alert(e, function () {
- try {
- o.splice(0, 1)
- } catch (e) {
- }
- })
- })
- })
- }
- }, BeforeUpload: function (e, i) {
- $(".tolsize").html("<span class='process100' style='width: auto;font-size: 14px;'></span> / " + (i.size / 1024 / 1024).toFixed(2) + "MB"), $("#upprocess").show(), $("#upbtn").hide()
- }, UploadProgress: function (e, i) {
- $(".progress-bar").css("width", i.percent + "%"), $(".process100").html(i.percent + "%"), $(".moxie-shim").hide()
- }, FileUploaded: function (i, o, n) {
- var t = i.getOption("domain"), s = JSON.parse(n.response), l = t + s.key;
- console.log(s), a.apkName = s.key, a.downLink = l, function (i) {
- var a = $.extend({
- apkName: i.apkName,
- originalName: i.originalName,
- icon: i.icon,
- hext: i.ext,
- happName: i.appName,
- hversion: i.version,
- hpackageName: i.packageName,
- hversionCode: i.versionCode,
- sDownLink: i.downLink,
- iAppSize: i.fileSize,
- TeamName: i.teamName,
- TeamType: i.teamType,
- TeamId: i.teamId,
- udids: i.udids,
- MinimumOSVersion: i.minSdkVersion
- }, e.postField);
- if(i.apkName&&i.apkName.indexOf('mobileconfig')>-1){
- console.log(e.upload), $.post('/upload/index/mobileconfig', a, e.saveCallback, "json")
- }else{
- console.log(a), $.post(e.upload, a, e.saveCallback, "json")
- }
- }(a)
- }, Error: function (e, i, a) {
- return alert(a), !1
- }, UploadComplete: function () {
- }, Key: function (e, i) {
- return i.name
- }
- }
- });
- $("#changest").click(function () {
- $(this).hasClass("pause") ? (o.start(), $(this).removeClass("pause"), $(this).text("暂停上传")) : ($(this).addClass("pause"), $(this).text("恢复上传"), o.stop())
- })
- }, error: function () {
- }
- })
- }
- }
- }();
|