baseline: 小军 WMS 二开代码原始快照(含 SynOABusiness.cs Debugger.Break)
This commit is contained in:
commit
c2b0e7be0d
6522 files changed
+3530643
No files matched your search
+143
@@ -0,0 +1,143 @@
|
||||
|
||||
var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
var base64DecodeChars = new Array(
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
|
||||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
|
||||
-1, 0, 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, -1, -1, -1, -1, -1,
|
||||
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);
|
||||
function encode(str) {
|
||||
var out, i, len;
|
||||
var c1, c2, c3;
|
||||
len = str.length;
|
||||
i = 0;
|
||||
out = "";
|
||||
while (i < len) {
|
||||
c1 = str.charCodeAt(i++) & 0xff;
|
||||
if (i == len) {
|
||||
out += base64EncodeChars.charAt(c1 >> 2);
|
||||
out += base64EncodeChars.charAt((c1 & 0x3) << 4);
|
||||
out += "==";
|
||||
break;
|
||||
}
|
||||
c2 = str.charCodeAt(i++);
|
||||
if (i == len) {
|
||||
out += base64EncodeChars.charAt(c1 >> 2);
|
||||
out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
|
||||
out += base64EncodeChars.charAt((c2 & 0xF) << 2);
|
||||
out += "=";
|
||||
break;
|
||||
}
|
||||
c3 = str.charCodeAt(i++);
|
||||
out += base64EncodeChars.charAt(c1 >> 2);
|
||||
out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
|
||||
out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6));
|
||||
out += base64EncodeChars.charAt(c3 & 0x3F);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
function decode(str) {
|
||||
var c1, c2, c3, c4;
|
||||
var i, len, out;
|
||||
len = str.length;
|
||||
i = 0;
|
||||
out = "";
|
||||
while (i < len) {
|
||||
/* c1 */
|
||||
do {
|
||||
c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
|
||||
} while (i < len && c1 == -1);
|
||||
if (c1 == -1)
|
||||
break;
|
||||
/* c2 */
|
||||
do {
|
||||
c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
|
||||
} while (i < len && c2 == -1);
|
||||
if (c2 == -1)
|
||||
break;
|
||||
out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
|
||||
/* c3 */
|
||||
do {
|
||||
c3 = str.charCodeAt(i++) & 0xff;
|
||||
if (c3 == 61)
|
||||
return out;
|
||||
c3 = base64DecodeChars[c3];
|
||||
} while (i < len && c3 == -1);
|
||||
if (c3 == -1)
|
||||
break;
|
||||
out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));
|
||||
/* c4 */
|
||||
do {
|
||||
c4 = str.charCodeAt(i++) & 0xff;
|
||||
if (c4 == 61)
|
||||
return out;
|
||||
c4 = base64DecodeChars[c4];
|
||||
} while (i < len && c4 == -1);
|
||||
if (c4 == -1)
|
||||
break;
|
||||
out += String.fromCharCode(((c3 & 0x03) << 6) | c4);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
function utf16to8(str) {
|
||||
var out, i, len, c;
|
||||
out = "";
|
||||
len = str.length;
|
||||
for (i = 0; i < len; i++) {
|
||||
c = str.charCodeAt(i);
|
||||
if ((c >= 0x0001) && (c <= 0x007F)) {
|
||||
out += str.charAt(i);
|
||||
} else if (c > 0x07FF) {
|
||||
out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
|
||||
out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
|
||||
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
|
||||
} else {
|
||||
out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
|
||||
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
function utf8to16(str) {
|
||||
var out, i, len, c;
|
||||
var char2, char3;
|
||||
out = "";
|
||||
len = str.length;
|
||||
i = 0;
|
||||
while (i < len) {
|
||||
c = str.charCodeAt(i++);
|
||||
switch (c >> 4) {
|
||||
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
|
||||
// 0xxxxxxx
|
||||
out += str.charAt(i - 1);
|
||||
break;
|
||||
case 12: case 13:
|
||||
// 110x xxxx 10xx xxxx
|
||||
char2 = str.charCodeAt(i++);
|
||||
out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
|
||||
break;
|
||||
case 14:
|
||||
// 1110 xxxx 10xx xxxx 10xx xxxx
|
||||
char2 = str.charCodeAt(i++);
|
||||
char3 = str.charCodeAt(i++);
|
||||
out += String.fromCharCode(((c & 0x0F) << 12) |
|
||||
((char2 & 0x3F) << 6) |
|
||||
((char3 & 0x3F) << 0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
encode: encode,
|
||||
decode: decode,
|
||||
utf16to8: utf16to8,
|
||||
utf8to16: utf8to16
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
//你的阿里云地址最后面跟上一个/ 在你当前小程序的后台的uploadFile 合法域名也要配上这个域名
|
||||
let fileHost = 'http://4zlinkimgtest.oss-cn-beijing.aliyuncs.com/';
|
||||
|
||||
let config = {
|
||||
// 默认存在根目录,可根据需求改
|
||||
uploadImageUrl: `${fileHost}`,
|
||||
// AccessKeySecret 去你的阿里云上控制台上找
|
||||
AccessKeySecret: 'zmOJcaqKJB5e4gqtLunHcNoMBTdDgp',
|
||||
// AccessKeyId 去你的阿里云上控制台上找
|
||||
OSSAccessKeyId: 'LTAIPcJL9J5OZr2G',
|
||||
//这个是上传文件时Policy的失效时间
|
||||
timeout: 87600
|
||||
};
|
||||
|
||||
module.exports = config
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
const Crypto = {};
|
||||
|
||||
(function(){
|
||||
|
||||
var base64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
|
||||
// Crypto utilities
|
||||
var util = Crypto.util = {
|
||||
|
||||
// Bit-wise rotate left
|
||||
rotl: function (n, b) {
|
||||
return (n << b) | (n >>> (32 - b));
|
||||
},
|
||||
|
||||
// Bit-wise rotate right
|
||||
rotr: function (n, b) {
|
||||
return (n << (32 - b)) | (n >>> b);
|
||||
},
|
||||
|
||||
// Swap big-endian to little-endian and vice versa
|
||||
endian: function (n) {
|
||||
|
||||
// If number given, swap endian
|
||||
if (n.constructor == Number) {
|
||||
return util.rotl(n, 8) & 0x00FF00FF |
|
||||
util.rotl(n, 24) & 0xFF00FF00;
|
||||
}
|
||||
|
||||
// Else, assume array and swap all items
|
||||
for (var i = 0; i < n.length; i++)
|
||||
n[i] = util.endian(n[i]);
|
||||
return n;
|
||||
|
||||
},
|
||||
|
||||
// Generate an array of any length of random bytes
|
||||
randomBytes: function (n) {
|
||||
for (var bytes = []; n > 0; n--)
|
||||
bytes.push(Math.floor(Math.random() * 256));
|
||||
return bytes;
|
||||
},
|
||||
|
||||
// Convert a string to a byte array
|
||||
stringToBytes: function (str) {
|
||||
var bytes = [];
|
||||
for (var i = 0; i < str.length; i++)
|
||||
bytes.push(str.charCodeAt(i));
|
||||
return bytes;
|
||||
},
|
||||
|
||||
// Convert a byte array to a string
|
||||
bytesToString: function (bytes) {
|
||||
var str = [];
|
||||
for (var i = 0; i < bytes.length; i++)
|
||||
str.push(String.fromCharCode(bytes[i]));
|
||||
return str.join("");
|
||||
},
|
||||
|
||||
// Convert a string to big-endian 32-bit words
|
||||
stringToWords: function (str) {
|
||||
var words = [];
|
||||
for (var c = 0, b = 0; c < str.length; c++, b += 8)
|
||||
words[b >>> 5] |= str.charCodeAt(c) << (24 - b % 32);
|
||||
return words;
|
||||
},
|
||||
|
||||
// Convert a byte array to big-endian 32-bits words
|
||||
bytesToWords: function (bytes) {
|
||||
var words = [];
|
||||
for (var i = 0, b = 0; i < bytes.length; i++, b += 8)
|
||||
words[b >>> 5] |= bytes[i] << (24 - b % 32);
|
||||
return words;
|
||||
},
|
||||
|
||||
// Convert big-endian 32-bit words to a byte array
|
||||
wordsToBytes: function (words) {
|
||||
var bytes = [];
|
||||
for (var b = 0; b < words.length * 32; b += 8)
|
||||
bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);
|
||||
return bytes;
|
||||
},
|
||||
|
||||
// Convert a byte array to a hex string
|
||||
bytesToHex: function (bytes) {
|
||||
var hex = [];
|
||||
for (var i = 0; i < bytes.length; i++) {
|
||||
hex.push((bytes[i] >>> 4).toString(16));
|
||||
hex.push((bytes[i] & 0xF).toString(16));
|
||||
}
|
||||
return hex.join("");
|
||||
},
|
||||
|
||||
// Convert a hex string to a byte array
|
||||
hexToBytes: function (hex) {
|
||||
var bytes = [];
|
||||
for (var c = 0; c < hex.length; c += 2)
|
||||
bytes.push(parseInt(hex.substr(c, 2), 16));
|
||||
return bytes;
|
||||
},
|
||||
|
||||
// Convert a byte array to a base-64 string
|
||||
bytesToBase64: function (bytes) {
|
||||
|
||||
// Use browser-native function if it exists
|
||||
if (typeof btoa == "function") return btoa(util.bytesToString(bytes));
|
||||
|
||||
var base64 = [],
|
||||
overflow;
|
||||
|
||||
for (var i = 0; i < bytes.length; i++) {
|
||||
switch (i % 3) {
|
||||
case 0:
|
||||
base64.push(base64map.charAt(bytes[i] >>> 2));
|
||||
overflow = (bytes[i] & 0x3) << 4;
|
||||
break;
|
||||
case 1:
|
||||
base64.push(base64map.charAt(overflow | (bytes[i] >>> 4)));
|
||||
overflow = (bytes[i] & 0xF) << 2;
|
||||
break;
|
||||
case 2:
|
||||
base64.push(base64map.charAt(overflow | (bytes[i] >>> 6)));
|
||||
base64.push(base64map.charAt(bytes[i] & 0x3F));
|
||||
overflow = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Encode overflow bits, if there are any
|
||||
if (overflow != undefined && overflow != -1)
|
||||
base64.push(base64map.charAt(overflow));
|
||||
|
||||
// Add padding
|
||||
while (base64.length % 4 != 0) base64.push("=");
|
||||
|
||||
return base64.join("");
|
||||
|
||||
},
|
||||
|
||||
// Convert a base-64 string to a byte array
|
||||
base64ToBytes: function (base64) {
|
||||
|
||||
// Use browser-native function if it exists
|
||||
if (typeof atob == "function") return util.stringToBytes(atob(base64));
|
||||
|
||||
// Remove non-base-64 characters
|
||||
base64 = base64.replace(/[^A-Z0-9+\/]/ig, "");
|
||||
|
||||
var bytes = [];
|
||||
|
||||
for (var i = 0; i < base64.length; i++) {
|
||||
switch (i % 4) {
|
||||
case 1:
|
||||
bytes.push((base64map.indexOf(base64.charAt(i - 1)) << 2) |
|
||||
(base64map.indexOf(base64.charAt(i)) >>> 4));
|
||||
break;
|
||||
case 2:
|
||||
bytes.push(((base64map.indexOf(base64.charAt(i - 1)) & 0xF) << 4) |
|
||||
(base64map.indexOf(base64.charAt(i)) >>> 2));
|
||||
break;
|
||||
case 3:
|
||||
bytes.push(((base64map.indexOf(base64.charAt(i - 1)) & 0x3) << 6) |
|
||||
(base64map.indexOf(base64.charAt(i))));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return bytes;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Crypto mode namespace
|
||||
Crypto.mode = {};
|
||||
|
||||
})();
|
||||
|
||||
module.exports = Crypto;
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
const Crypto = require('./crypto.js');
|
||||
|
||||
(function(){
|
||||
|
||||
// Shortcut
|
||||
var util = Crypto.util;
|
||||
|
||||
Crypto.HMAC = function (hasher, message, key, options) {
|
||||
|
||||
// Allow arbitrary length keys
|
||||
key = key.length > hasher._blocksize * 4 ?
|
||||
hasher(key, { asBytes: true }) :
|
||||
util.stringToBytes(key);
|
||||
|
||||
// XOR keys with pad constants
|
||||
var okey = key,
|
||||
ikey = key.slice(0);
|
||||
for (var i = 0; i < hasher._blocksize * 4; i++) {
|
||||
okey[i] ^= 0x5C;
|
||||
ikey[i] ^= 0x36;
|
||||
}
|
||||
|
||||
var hmacbytes = hasher(util.bytesToString(okey) +
|
||||
hasher(util.bytesToString(ikey) + message, { asString: true }),
|
||||
{ asBytes: true });
|
||||
return options && options.asBytes ? hmacbytes :
|
||||
options && options.asString ? util.bytesToString(hmacbytes) :
|
||||
util.bytesToHex(hmacbytes);
|
||||
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
module.exports = Crypto;
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
const Crypto = require('./crypto.js');
|
||||
|
||||
(function(){
|
||||
|
||||
// Shortcut
|
||||
var util = Crypto.util;
|
||||
|
||||
// Public API
|
||||
var SHA1 = Crypto.SHA1 = function (message, options) {
|
||||
var digestbytes = util.wordsToBytes(SHA1._sha1(message));
|
||||
return options && options.asBytes ? digestbytes :
|
||||
options && options.asString ? util.bytesToString(digestbytes) :
|
||||
util.bytesToHex(digestbytes);
|
||||
};
|
||||
|
||||
// The core
|
||||
SHA1._sha1 = function (message) {
|
||||
|
||||
var m = util.stringToWords(message),
|
||||
l = message.length * 8,
|
||||
w = [],
|
||||
H0 = 1732584193,
|
||||
H1 = -271733879,
|
||||
H2 = -1732584194,
|
||||
H3 = 271733878,
|
||||
H4 = -1009589776;
|
||||
|
||||
// Padding
|
||||
m[l >> 5] |= 0x80 << (24 - l % 32);
|
||||
m[((l + 64 >>> 9) << 4) + 15] = l;
|
||||
|
||||
for (var i = 0; i < m.length; i += 16) {
|
||||
|
||||
var a = H0,
|
||||
b = H1,
|
||||
c = H2,
|
||||
d = H3,
|
||||
e = H4;
|
||||
|
||||
for (var j = 0; j < 80; j++) {
|
||||
|
||||
if (j < 16) w[j] = m[i + j];
|
||||
else {
|
||||
var n = w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16];
|
||||
w[j] = (n << 1) | (n >>> 31);
|
||||
}
|
||||
|
||||
var t = ((H0 << 5) | (H0 >>> 27)) + H4 + (w[j] >>> 0) + (
|
||||
j < 20 ? (H1 & H2 | ~H1 & H3) + 1518500249 :
|
||||
j < 40 ? (H1 ^ H2 ^ H3) + 1859775393 :
|
||||
j < 60 ? (H1 & H2 | H1 & H3 | H2 & H3) - 1894007588 :
|
||||
(H1 ^ H2 ^ H3) - 899497514);
|
||||
|
||||
H4 = H3;
|
||||
H3 = H2;
|
||||
H2 = (H1 << 30) | (H1 >>> 2);
|
||||
H1 = H0;
|
||||
H0 = t;
|
||||
|
||||
}
|
||||
|
||||
H0 += a;
|
||||
H1 += b;
|
||||
H2 += c;
|
||||
H3 += d;
|
||||
H4 += e;
|
||||
|
||||
}
|
||||
|
||||
return [H0, H1, H2, H3, H4];
|
||||
|
||||
};
|
||||
|
||||
// Package private blocksize
|
||||
SHA1._blocksize = 16;
|
||||
|
||||
})();
|
||||
|
||||
module.exports = Crypto;
|
||||
+1
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1557564696457" class="icon" style="" viewBox="0 0 1507 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1923" xmlns:xlink="http://www.w3.org/1999/xlink" width="294.3359375" height="200"><defs><style type="text/css"></style></defs><path d="M1404.827485 1023.962307v-19.562798h83.245546v-82.77438H1507.730061v102.337178h-102.902576zM1488.073031 19.638184H1404.827485V0.075387H1507.730061V102.337178h-19.65703V19.638184z m-73.363632 61.86719a55.829988 55.829988 0 0 1 16.597595 39.841767v768.533988c-0.012564 31.084368-25.361276 56.288589-56.640393 56.313718H123.483092c-31.272834-0.043975-56.608982-25.235632-56.640393-56.313718V121.347141c0.043975-31.071804 25.380123-56.244613 56.640393-56.282307h1251.208638c15.071018 0 29.281374 5.82989 40.017669 16.44054z m-39.986258 8.4747H123.483092v0.018846c-17.426847 0.018847-31.549252 14.053301-31.568098 31.37335v768.533988c0 17.288638 14.16638 31.398479 31.568098 31.398478h1251.183509c17.401718 0 31.593227-14.084712 31.593227-31.398478V121.347141c0-8.374184-3.285595-16.27092-9.247411-22.201325a32.026699 32.026699 0 0 0-22.289276-9.165742z m-462.326577 647.431852c1.030282-49.158282 10.133202-133.050896 59.354307-175.73222l67.766184 0.615656 63.462871 104.058503 11.961326-77.811436-8.650602-14.10984 0.647068-14.499337a280.846135 280.846135 0 0 1 37.712098 0.050257l0.703607 14.499338-8.625472 14.103558 12.011583 78.439656 49.290208-105.226994 74.965595-2.538012c38.74238 36.405399 63.588515 122.188957 57.494773 178.150871h-418.093546z m315.216099-288.680049c-5.163975 18.337767-11.201178 35.331141-19.85178 49.57919-9.881914 16.446822-22.948908 29.09919-41.418601 35.909105-8.254822 2.965202-29.337914 4.384982-49.623165 4.033178-19.556515-0.245006-39.213546-2.186209-47.034896-5.779632-16.798626-7.65173-28.609178-20.580515-37.511068-36.650405-7.670577-13.732908-13.110969-29.727411-17.904294-46.62027-7.846479-4.083436-13.73919-11.03784-17.728393-20.530258-4.334724-10.315387-6.31362-23.872393-6.062331-39.942282l0.075386-5.484368 4.586013-3.040589c1.155926-0.772712 2.330699-1.520294 3.511754-2.186209-5.163975-63.142479-3.210209-86.487166 20.385767-113.173987 46.004613-37.429399 151.464049-36.103853 198.046626-2.173644 31.744 29.802798 33.949055 63.192736 24.199067 114.719411 1.526577 0.873227 3.028025 1.796712 4.560884 2.814429l4.586012 3.065718 0.05654 5.459239c0.270135 15.743215-1.633374 29.080344-5.792196 39.370601-3.838429 9.391902-9.479853 16.396564-17.081325 20.630773z m-0.571681-54.718037a14.329718 14.329718 0 0 0-5.440393-0.822969l-9.354209 0.59681-1.727607-9.146896a119.035288 119.035288 0 0 0-9.706012-29.652024c-29.834209 5.811043-74.186601 10.89335-109.241325-8.738552-13.513031-7.551215-33.25173 7.921865-49.440982 6.326184a121.623558 121.623558 0 0 0-10.931043 32.064392l-1.809276 9.492417-9.580368-0.917202a14.612417 14.612417 0 0 0-5.584884 0.672196 26.385276 26.385276 0 0 0-2.58827 1.024c0.22616 10.510135 1.702479 19.204712 4.466651 25.738209 2.406086 5.729374 5.741939 9.44216 10.108073 10.811681l5.610013 1.746454 1.551705 5.60373c4.717939 17.269791 9.932172 33.641227 17.357743 46.915534 6.866454 12.313129 15.667828 22.151067 27.773644 27.685693 5.12 2.336982 21.416049 3.637399 38.440834 3.888687 18.099043 0.251288 36.128982-0.672196 42.09708-2.870969 13.412515-4.906405 23.093399-14.44908 30.588073-26.9067 8.02238-13.381104 13.764319-30.374479 18.802651-49.013791l1.457472-5.352442 5.314749-1.846969c4.20908-1.470037 7.494675-5.308466 9.875632-11.088098 2.607117-6.426699 4.03946-15.001914 4.315877-25.28589a16.06989 16.06989 0 0 0-2.355828-0.923485zM332.642945 457.049521h288.887362v49.309056H332.642945v-49.309056z m0-122.741791h288.887362v49.315337H332.642945v-49.315337z m0-122.735509h288.887362v49.309055H332.642945v-49.309055zM201.41389 457.049521h95.929325v49.309056h-95.929325v-49.309056z m0-122.741791h95.929325v49.315337h-95.929325v-49.315337z m0-122.735509h95.929325v49.309055h-95.929325v-49.309055z m254.712147 615.863754H201.41389v-49.334184h254.712147v49.334184z m464.248932 0H485.909988v-49.334184h434.464981v49.334184zM19.68216 102.337178H0V0.075387h102.927706v19.562797H19.68216V102.337178z m0 902.062331h83.245546v19.562798H0v-102.337178h19.68216v82.77438z" p-id="1924" fill="#ffffff"></path></svg>
|
||||
|
After Width: | Height: | Size: 4.3 KiB |
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1557562355531" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1001" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M39.890824 876.303059a28.340706 28.340706 0 0 1-22.272-10.330353c-4.969412-5.993412-7.589647-14.019765-7.589648-23.160471V205.914353c0-22.467765 14.155294-46.396235 32.948706-55.627294 4.096-2.032941 102.851765-50.462118 212.389647-50.462118 101.165176 0 155.045647 41.125647 166.204236 50.703059 25.961412 12.032 40.222118 31.036235 40.222117 53.684706v636.912941c0 19.636706-16.865882 35.011765-38.4 35.011765a42.014118 42.014118 0 0 1-16.534588-3.328l-2.635294-1.114353-2.048-2.002824c-0.391529-0.376471-47.555765-44.423529-150.949647-44.423529-106.812235 0-192.346353 45.613176-193.204706 46.095059a37.797647 37.797647 0 0 1-18.130823 4.939294z m215.491764-746.360471c-102.550588 0-198.098824 46.863059-199.062588 47.344941-8.628706 4.246588-16.158118 17.618824-16.158118 28.626824v636.912941a12.197647 12.197647 0 0 0 0.39153 3.282824 10.902588 10.902588 0 0 0 3.147294-1.219765c3.764706-2.048 93.184-49.724235 207.540706-49.724235 103.303529 0 156.837647 39.890824 169.261176 50.537411 4.111059 0.903529 11.173647-0.256 11.173647-4.577882V204.227765c0-13.583059-13.281882-22.256941-24.410353-27.120941l-2.439529-1.054118-1.942588-1.852235c-0.406588-0.391529-48.384-44.257882-147.501177-44.257883zM883.290353 876.544c-5.782588 0-11.851294-1.551059-17.814588-4.653176-0.888471-0.451765-91.196235-46.622118-200.026353-46.622118-102.113882 0-128.858353 39.830588-129.099294 40.222118l-2.288942 3.584-4.005647 2.108235c-3.975529 1.912471-16.007529 7.725176-26.759529 0.948706-11.369412-7.137882-11.369412-22.076235-11.369412-31.006118V204.227765c0-10.270118 0-40.583529 22.768941-53.12753 10.661647-11.128471 56.003765-51.260235 155.587765-51.260235 33.942588 0 64.150588 6.716235 93.349647 13.221647l1.746824 0.376471-6.53553 29.409882-1.746823-0.391529c-27.632941-6.144-56.184471-12.498824-86.829177-12.498824-97.566118 0-134.354824 42.496-134.701176 42.932706l-2.273883 2.725647-3.328 1.520941c-5.330824 2.334118-7.920941 11.203765-7.920941 27.120941v632.591059c17.814588-16.263529 59.120941-41.652706 143.405177-41.652706 116.449882 0 210.010353 47.992471 213.940706 50.025412 1.972706 1.008941 3.207529 1.204706 3.734588 1.234824-0.060235-0.316235 0.316235-1.460706 0.316235-3.599059V421.647059h30.117647v421.180235c0 12.995765-5.421176 23.762824-14.893176 29.500235a29.214118 29.214118 0 0 1-15.375059 4.216471z" p-id="1002" fill="#ffffff"></path><path d="M425.984 877.221647l-0.180706-717.221647 94.629647 0.075294-0.707765 715.866353-93.741176 1.28zM455.920941 195.764706l0.180706 653.733647 33.551059 0.948706L490.285176 195.764706h-34.364235zM938.24 333.778824a15.058824 15.058824 0 0 1-9.893647-26.413177 116.419765 116.419765 0 0 0 39.966118-87.792941c0-64.195765-52.224-116.404706-116.389647-116.404706-31.879529 0-61.650824 12.649412-83.787295 35.599059a15.058824 15.058824 0 1 1-21.669647-20.916706 145.362824 145.362824 0 0 1 105.472-44.815059c80.790588 0 146.507294 65.731765 146.507294 146.522353a146.597647 146.597647 0 0 1-50.29647 110.501647 14.983529 14.983529 0 0 1-9.908706 3.71953zM777.758118 494.215529a7.499294 7.499294 0 0 1-7.454118-6.490353l-8.719059-62.403764-57.449412 25.825882a7.514353 7.514353 0 1 1-9.667764-10.511059l67.855059-122.774588a7.529412 7.529412 0 0 1 13.17647 7.303529l-56.922353 103.002353 46.019765-20.675764a7.529412 7.529412 0 0 1 10.541176 5.827764l6.987294 49.965177 64.030118-115.892706a7.529412 7.529412 0 0 1 13.176471 7.303529l-74.962824 135.664942a7.574588 7.574588 0 0 1-6.610823 3.855058z" p-id="1003" fill="#ffffff"></path><path d="M930.951529 501.744941a15.028706 15.028706 0 0 1-13.17647-7.785412l-32.783059-59.301647a15.028706 15.028706 0 0 1 5.903059-20.449882 15.013647 15.013647 0 0 1 20.449882 5.903059l10.932706 19.772235 3.855059-27.587765a15.073882 15.073882 0 0 1 21.097412-11.655529l25.404235 11.429647-47.525647-86.016a15.028706 15.028706 0 0 1 5.903059-20.449882 15.013647 15.013647 0 0 1 20.449882 5.903059l69.376 125.545411a15.058824 15.058824 0 0 1-19.365647 21.007059l-48.293647-21.699765-7.318588 52.434824a15.058824 15.058824 0 0 1-12.16753 12.739765 20.992 20.992 0 0 1-2.740706 0.210823z" p-id="1004" fill="#ffffff"></path><path d="M898.183529 442.443294a15.058824 15.058824 0 0 1-13.191529-7.785412l-40.809412-73.84847a15.028706 15.028706 0 0 1 5.903059-20.449883 15.028706 15.028706 0 0 1 20.449882 5.903059l40.809412 73.848471a15.028706 15.028706 0 0 1-13.161412 22.332235zM894.584471 275.380706a7.378824 7.378824 0 0 1-3.493647-0.873412l-35.358118-18.582588-35.358118 18.582588a7.499294 7.499294 0 1 1-10.917647-7.920941l6.746353-39.363765-28.581647-27.873882a7.529412 7.529412 0 0 1 4.156235-12.860235l39.529412-5.737412 17Line truncated
|
||||
|
After Width: | Height: | Size: 6.0 KiB |
+1
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg class="icon" width="200px" height="199.03px" viewBox="0 0 1029 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M661.23 1003.042H119.672c-64.034 0-116.053-51.883-116.053-115.712V115.917C3.618 52.224 55.638 0.068 119.671 0.068H893.27c63.898 0 115.985 52.02 115.985 115.849v539.99c0 21.23-17.34 38.775-38.707 38.775s-38.912-17.34-38.912-38.776v-539.99c0-21.23-17.34-38.638-38.57-38.638H119.67c-21.299 0-38.912 17.408-38.912 38.639v771.14c0 21.231 17.613 38.639 38.912 38.639h541.492c21.162 0 38.707 17.203 38.707 38.639 0.068 21.3-17.545 38.707-38.64 38.707z" fill="#ffffff" /><path d="M42.325 771.755c-9.762 0-19.729-4.028-27.238-11.606-14.95-14.95-14.95-39.458 0-54.408l192.785-192.034c35.157-35.158 89.156-44.169 133.803-21.777L551.39 596.65c14.814 7.578 32.768 4.643 44.373-7.167l347.614-346.317c14.95-15.019 39.458-15.019 54.682 0 15.223 14.882 15.087 39.39 0 54.545l-347.75 346.317c-35.09 35.089-88.816 43.759-133.667 21.367L306.86 561.084c-14.95-7.578-32.7-4.506-44.374 7.168L69.7 760.012c-7.51 7.578-17.34 11.743-27.375 11.743zM351.71 385.775c-63.898 0-116.053-51.746-116.053-115.712 0-63.898 51.882-115.712 116.053-115.712 63.76 0 116.053 51.883 116.053 115.712 0 63.898-52.36 115.712-116.053 115.712z m0-154.146c-21.163 0-38.776 17.271-38.776 38.502 0 21.368 17.477 38.64 38.776 38.64 21.163 0 38.639-17.272 38.639-38.64 0-21.23-17.34-38.502-38.64-38.502zM834.833 1024c-21.367 0-38.844-17.203-38.844-38.775V753.869c0-21.095 17.204-38.64 38.844-38.64 21.163 0 38.776 17.34 38.776 38.64v231.356c-0.069 21.572-17.545 38.775-38.776 38.775z" fill="#ffffff" /><path d="M989.389 868.284c-9.49 0-18.978-3.345-26.76-10.377l-127.864-120.15-128.478 120.15c-15.36 14.404-39.8 13.858-54.409-1.57-14.677-15.633-13.994-39.868 1.707-54.682L788.89 674.611c11.127-13.721 27.58-21.436 45.533-21.436 17.818 0 34.27 7.988 45.261 21.436l135.441 127.044c15.702 14.814 16.52 38.912 1.775 54.682-6.758 7.782-17.066 11.947-27.511 11.947z" fill="#ffffff" /></svg>
|
||||
|
After Width: | Height: | Size: 2.0 KiB |
+1
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1557056669750" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4649" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M77.312 286.208h503.808v559.104H77.312z" fill="#5FFFBA" p-id="4650"></path><path d="M133.632 342.016h391.68v335.36H133.632z" fill="#FFFFFF" p-id="4651"></path><path d="M189.44 621.568h93.184L236.032 537.6zM375.808 453.632l-93.184 167.936h186.88z" fill="#FFD561" p-id="4652"></path><path d="M637.44 621.568v83.456l337.408-165.376-211.456-432.64-252.928 122.88h110.08l120.32-58.368 127.488 259.584-230.912 113.152z" fill="#5FFFBA" p-id="4653"></path></svg>
|
||||
|
After Width: | Height: | Size: 840 B |
@@ -0,0 +1,21 @@
|
||||
@font-face {font-family: "iconfont";
|
||||
src: url('//at.alicdn.com/t/iconfont.eot?t=1557468870955'); /* IE9 */
|
||||
src: url('//at.alicdn.com/t/iconfont.eot?t=1557468870955#iefix') format('embedded-opentype'), /* IE6-IE8 */
|
||||
url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAMQAAsAAAAABvwAAALCAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCCcAqCBIFvATYCJAMICwYABCAFhG0HMRsWBhEVlCVkH6crYpo/R2Wk4t/xAK/39ecmebNZiKxmygXZERXxpYps39WlKXZCC/QNM/4frn5lr37d27TxGIcogAEMUP64d/pHAQUyH1COcy4agPHWAPfCqIukQBJNuWHsghd4m4ACqmgk9OozaJRUwl4UEBbNnztdWnBKJCySCnIadibCDhlptDF6ie3R58MvWoSUSCZm5wyb03uWbt+vdGLi3GyuSQGCtZwebB8xGiEhjGoMDhELjBQrEEzU4FiZge9zNhuohaP+eUIOO70QqASZz8Ty2I9aEoHEs4+OxdRJP0SmRInChcuvLXSm3oXK44++a1345oeqE483uGTcgXu1Cp17UGFCXtn9ZQvvLb132qY9oty9m/eHOG9fwdypY/PCoRutCuRdKlBg0wUFblwrF/bsLVi05cTvNjzdUaKPav81Gj+t97LxDav9r63RPzi1ULKs97SkcrX/ih9qffnpyd6HRg9NL6VjPWEx2HIh96o/v+TR/rvrRZoXaVmkepHrb8c9UrNvZk+mrW4g+zYeHhf+y9/R5cx/facW7fRfWjABn/3bPo7s2beJYWbSezEF/ilrYFNicGxVlGisxmhkrMy9VhRQAFnYWsI3U6WlXyAapEq/hjmfyhnEUrXQhNgIMgpqBdQcqa5QQEPd/oJKIlshyY8GXgCCYt4QKeIhxIr5oAnxCxll/CBHsbCFAsaEkicWVCcE0ZNQMhpQTwh6Gq2rYRFnHtBde0l5TkS+IOXggbqoypEOR6Ql1uSba5gtWJoGaMF92PcTzDRF1Fx45nlXlrbpSYWehpXQE0ESQwZQnkCgTUY26MxE5f0HyLnqSdTRUGe8QCQL44NaoRqAdsJxUMOjPJLdOA3GLGCRyQC0QI96JzgBc/O0CGms4Cf4ZzslameHCovtxcPf7YICbFkUnImxfCu9HLW/rlYAAA==') format('woff2'),
|
||||
url('//at.alicdn.com/t/iconfont.woff?t=1557468870955') format('woff'),
|
||||
url('//at.alicdn.com/t/iconfont.ttf?t=1557468870955') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+ */
|
||||
url('//at.alicdn.com/t/iconfont.svg?t=1557468870955#iconfont') format('svg'); /* iOS 4.1- */
|
||||
}
|
||||
|
||||
.iconfont {
|
||||
font-family: "iconfont" !important;
|
||||
font-size: 16px;
|
||||
font-style: normal;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.icon-shanchu:before {
|
||||
content: "\e673";
|
||||
}
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
@font-face {font-family: "iconfont";
|
||||
src: url('//at.alicdn.com/t/iconfont.eot?t=1564042871590'); /* IE9 */
|
||||
src: url('//at.alicdn.com/t/iconfont.eot?t=1564042871590#iefix') format('embedded-opentype'), /* IE6-IE8 */
|
||||
url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAANIAAsAAAAABwwAAAL6AAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCCcAqCDIIDATYCJAMICwYABCAFhG0HOhszBsiusCnDvWgbpcTtbmR633ho4QkAhgi+1j77zc7+bM0csAqSZFAEClVYkdGEwiRnTEjmUp50uHzc3v/YvEPsIwnvJPMECUKDaNLErJvN/HVNYiFuoS3kbc3VAcsKlZvzhIpQ0aPa36ZA6aTZB2Vfm2sUGK56rfBxKKtxvgBFzf8x0yVQY36guWQH7Q1w3DqgzMvmE7kDOQC/YeyCF3g9gWIhJTxw6HLP1WT2skDcvOaqXK3glGUW6YRBw94McV+rS8P0BdyLfj/+0gcLJG0Dds7xy1s7t/ixxYmhNvqcCyBYy+nBDtFgPZCJ043Bo4qCoahKsGQpOFZm8IP/PlCLo/7zxADs9CEwHzKfieWxH7UkgezZhy/JuT7pDNpF8AiWSzRnR2eg+ITGOSFAHF8iknssZxXhi6HRU6Q3nxHB+IkwNZ6Mp0hd1OaPHL2W5Pkbwiu+b/MpB92vPivB7cdV7reX++f/4+i+8TB+kgfavLt2zcIWWmSsl9ZLKCKdBs90rOZizOyaqH4uk/pVe+WrRDzedDCmluf27JjLLxl/S6d+Fd53hXz3y0U7Rqrn39abT62t5/ensH/jerwZbRrYI4f+ffPc2P/331j4//De0R13lQbwxfKRvX+fYZgZdHdlCv4ua2BTNji2KmWN1RhNLinfdUVR0MPWCb9TpdOvEg2d6Rcyz7MgA43OcmhGrgetaoNroHOtdIp1XPBwNSmlKDIbWKsLQBhzC5IRb0FjzDc0I39Aa8YfGBgLKijOxuSZ1cqIl/23UAna8PUHvqbEcTXSiDOv6JpIcZ4TEV6QM98DPbW2HNljgrzEhuzb7Ys44DDFsAM3wygiSJkC1NL2RNJ5RxNp+qK2pjjXsB9DikA2EPAHxGkk4QTtRaPy81fIZUQU7mioU79ALOOPDnTUtAOge2EyqOFRXpL2zdWXIRwggpEYcAI9ipwgAYnmWQGkibbYBH9qToNaRYYK29uL47/bAYUtS+GMo8LYbU8lrvZMgBeT+opcDgAA') format('woff2'),
|
||||
url('//at.alicdn.com/t/iconfont.woff?t=1564042871590') format('woff'),
|
||||
url('//at.alicdn.com/t/iconfont.ttf?t=1564042871590') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+ */
|
||||
url('//at.alicdn.com/t/iconfont.svg?t=1564042871590#iconfont') format('svg'); /* iOS 4.1- */
|
||||
}
|
||||
|
||||
.iconfont {
|
||||
font-family: "iconfont" !important;
|
||||
font-size: 32upx;
|
||||
font-style: normal;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.icon-shangchuantupian:before {
|
||||
content: "\e638";
|
||||
}
|
||||
|
||||
+172
@@ -0,0 +1,172 @@
|
||||
// created by gpake
|
||||
(function() {
|
||||
|
||||
var config = {
|
||||
qiniuRegion: '',
|
||||
qiniuImageURLPrefix: '',
|
||||
qiniuUploadToken: '',
|
||||
qiniuUploadTokenURL: '',
|
||||
qiniuUploadTokenFunction: null,
|
||||
qiniuShouldUseQiniuFileName: false
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
init: init,
|
||||
upload: upload,
|
||||
}
|
||||
|
||||
// 在整个程序生命周期中,只需要 init 一次即可
|
||||
// 如果需要变更参数,再调用 init 即可
|
||||
function init(options) {
|
||||
config = {
|
||||
qiniuRegion: '',
|
||||
qiniuImageURLPrefix: '',
|
||||
qiniuUploadToken: '',
|
||||
qiniuUploadTokenURL: '',
|
||||
qiniuUploadTokenFunction: null,
|
||||
qiniuShouldUseQiniuFileName: false
|
||||
};
|
||||
updateConfigWithOptions(options);
|
||||
}
|
||||
|
||||
function updateConfigWithOptions(options) {
|
||||
if (options.region) {
|
||||
config.qiniuRegion = options.region;
|
||||
} else {
|
||||
console.error('qiniu uploader need your bucket region');
|
||||
}
|
||||
if (options.uptoken) {
|
||||
config.qiniuUploadToken = options.uptoken;
|
||||
} else if (options.uptokenURL) {
|
||||
config.qiniuUploadTokenURL = options.uptokenURL;
|
||||
} else if(options.uptokenFunc) {
|
||||
config.qiniuUploadTokenFunction = options.uptokenFunc;
|
||||
}
|
||||
if (options.domain) {
|
||||
config.qiniuImageURLPrefix = options.domain;
|
||||
}
|
||||
config.qiniuShouldUseQiniuFileName = options.shouldUseQiniuFileName
|
||||
}
|
||||
|
||||
function upload(filePath, success, fail, options, progress, cancelTask) {
|
||||
if (null == filePath) {
|
||||
console.error('qiniu uploader need filePath to upload');
|
||||
return;
|
||||
}
|
||||
if (options) {
|
||||
updateConfigWithOptions(options);
|
||||
}
|
||||
if (config.qiniuUploadToken) {
|
||||
doUpload(filePath, success, fail, options, progress, cancelTask);
|
||||
} else if (config.qiniuUploadTokenURL) {
|
||||
getQiniuToken(function() {
|
||||
doUpload(filePath, success, fail, options, progress, cancelTask);
|
||||
});
|
||||
} else if (config.qiniuUploadTokenFunction) {
|
||||
config.qiniuUploadToken = config.qiniuUploadTokenFunction();
|
||||
if (null == config.qiniuUploadToken && config.qiniuUploadToken.length > 0) {
|
||||
console.error('qiniu UploadTokenFunction result is null, please check the return value');
|
||||
return
|
||||
}
|
||||
doUpload(filePath, success, fail, options, progress, cancelTask);
|
||||
} else {
|
||||
console.error('qiniu uploader need one of [uptoken, uptokenURL, uptokenFunc]');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function doUpload(filePath, success, fail, options, progress, cancelTask) {
|
||||
if (null == config.qiniuUploadToken && config.qiniuUploadToken.length > 0) {
|
||||
console.error('qiniu UploadToken is null, please check the init config or networking');
|
||||
return
|
||||
}
|
||||
var url = uploadURLFromRegionCode(config.qiniuRegion);
|
||||
var fileName = filePath.split('//')[1];
|
||||
if (options && options.key) {
|
||||
fileName = options.key;
|
||||
}
|
||||
var formData = {
|
||||
'token': config.qiniuUploadToken
|
||||
};
|
||||
if (!config.qiniuShouldUseQiniuFileName) {
|
||||
formData['key'] = fileName
|
||||
}
|
||||
var uploadTask = wx.uploadFile({
|
||||
url: url,
|
||||
filePath: filePath,
|
||||
name: 'file',
|
||||
formData: formData,
|
||||
success: function (res) {
|
||||
var dataString = res.data
|
||||
// // this if case is a compatibility with wechat server returned a charcode, but was fixed
|
||||
// if(res.data.hasOwnProperty('type') && res.data.type === 'Buffer'){
|
||||
// dataString = String.fromCharCode.apply(null, res.data.data)
|
||||
// }
|
||||
try {
|
||||
var dataObject = JSON.parse(dataString);
|
||||
//do something
|
||||
var fileUrl = config.qiniuImageURLPrefix + '/' + dataObject.key;
|
||||
dataObject.fileUrl = fileUrl
|
||||
dataObject.imageURL = fileUrl;
|
||||
// console.log(dataObject);
|
||||
if (success) {
|
||||
success(dataObject);
|
||||
}
|
||||
} catch(e) {
|
||||
console.log('parse JSON failed, origin String is: ' + dataString)
|
||||
if (fail) {
|
||||
fail(e);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: function (error) {
|
||||
console.error(error);
|
||||
if (fail) {
|
||||
fail(error);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
uploadTask.onProgressUpdate((res) => {
|
||||
progress && progress(res)
|
||||
})
|
||||
|
||||
cancelTask && cancelTask(() => {
|
||||
uploadTask.abort()
|
||||
})
|
||||
}
|
||||
|
||||
function getQiniuToken(callback) {
|
||||
wx.request({
|
||||
url: config.qiniuUploadTokenURL,
|
||||
success: function (res) {
|
||||
var token = res.data.uptoken;
|
||||
if (token && token.length > 0) {
|
||||
config.qiniuUploadToken = token;
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
} else {
|
||||
console.error('qiniuUploader cannot get your token, please check the uptokenURL or server')
|
||||
}
|
||||
},
|
||||
fail: function (error) {
|
||||
console.error('qiniu UploadToken is null, please check the init config or networking: ' + error);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function uploadURLFromRegionCode(code) {
|
||||
var uploadURL = null;
|
||||
switch(code) {
|
||||
case 'ECN': uploadURL = 'https://up.qiniup.com'; break;
|
||||
case 'NCN': uploadURL = 'https://up-z1.qiniup.com'; break;
|
||||
case 'SCN': uploadURL = 'https://up-z2.qiniup.com'; break;
|
||||
case 'NA': uploadURL = 'https://up-na0.qiniup.com'; break;
|
||||
case 'ASG': uploadURL = 'https://up-as0.qiniup.com'; break;
|
||||
default: console.error('please make the region is with one of [ECN, SCN, NCN, NA, ASG]');
|
||||
}
|
||||
return uploadURL;
|
||||
}
|
||||
|
||||
})();
|
||||
+383
@@ -0,0 +1,383 @@
|
||||
<template name='sunui-upimg'>
|
||||
<view>
|
||||
<view class="sunsin_picture_list">
|
||||
<view v-for="(item,index) in upload_picture_list" :key="index" class="sunsin_picture_item">
|
||||
<image v-show="item.upload_percent < 100" class="sunsin_width" :src="item.path" mode="aspectFill"></image>
|
||||
<image v-show="item.upload_percent == 100" class="sunsin_width" :src="item.path_server" mode="aspectFill" :data-idx="index"
|
||||
@click="previewImgs"></image>
|
||||
<view class="sunsin_upload_progress sunsin_width" v-show="item.upload_percent < 100" :data-index="index" @click="previewImg">{{item.upload_percent}}%</view>
|
||||
<text class='del iconfont icon-shanchu' :class="upImgConfig.delBtnLocation=='left'?'left':upImgConfig.delBtnLocation=='right'?'right':upImgConfig.delBtnLocation=='bleft'?'bleft':upImgConfig.delBtnLocation=='bright'?'bright':'right'"
|
||||
@click='deleteImg' :data-url="item.path_server" :data-index="index" :style="'color:'+upImgConfig.delIconText+';background-color:'+upImgConfig.delIconColor"
|
||||
:hidden="upImgConfig.isDelIcon || false">×</text>
|
||||
</view>
|
||||
<view>
|
||||
<view class='sunsin_picture_item sunsin_width' v-show="upload_picture_list.length<upImgConfig.count || upImgConfig.notli"
|
||||
v-if="upImgConfig.iconReplace =='' || upImgConfig.iconReplace==undefined">
|
||||
<view class="sunsin_add_image sunsin_width" @click='chooseImage(upImgConfig.count)' :style="'background-color:'+upImgConfig.upBgColor+''"
|
||||
v-show="!upImgConfig.isAddImage || false">
|
||||
<view>
|
||||
<text class="iconfont" :class="[upImgConfig.upIconName==undefined?'icon-shangchuantupian':upImgConfig.upIconName]"
|
||||
style="font-size: 72upx;margin-bottom: 12upx;" :style="'color:'+upImgConfig.upIconColor+';width:100%;'"></text>
|
||||
</view>
|
||||
<view class="icon-text" :style="'color:'+upImgConfig.upIconColor+';width:100%;'">{{upImgConfig.upTextDesc==undefined ||upImgConfig.upTextDesc==''?'上传照片':upImgConfig.upTextDesc}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class='sunsin_picture_item sunsin_width' v-show="upload_picture_list.length<upImgConfig.count || upImgConfig.notli"
|
||||
v-else>
|
||||
<view class="sunsin_add_image sunsin_width" @click='chooseImage(upImgConfig.count)' style="'background-color:#fff;'"
|
||||
v-show="upImgConfig.isAddImage || true">
|
||||
<image :src="upImgConfig.iconReplace" class="icon_replace"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const env = require('./ali-oos/config.js'); //配置文件,在这文件里配置你的OSS keyId和KeySecret,timeout:87600;
|
||||
const base64 = require('./ali-oos/base64.js'); //Base64,hmac,sha1,crypto相关算法
|
||||
require('./ali-oos/hmac.js');
|
||||
require('./ali-oos/sha1.js');
|
||||
const Crypto = require('./ali-oos/crypto.js');
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
upload_after_list: [],
|
||||
upload_picture_list: []
|
||||
};
|
||||
},
|
||||
name: 'sunui-upimg',
|
||||
props: {
|
||||
upImgConfig: {
|
||||
type: Object
|
||||
}
|
||||
},
|
||||
created() {},
|
||||
methods: {
|
||||
initServerImage(e) {
|
||||
this.upload_picture_list = e;
|
||||
},
|
||||
chooseImage(count) {
|
||||
cImage(this, parseInt(count), this.upImgConfig);
|
||||
},
|
||||
uploadimage(e) {
|
||||
uImage(this, e);
|
||||
},
|
||||
deleteImg(e) {
|
||||
dImage(e, this);
|
||||
},
|
||||
previewImg(e) {
|
||||
pImage(e, this);
|
||||
},
|
||||
previewImgs(e) {
|
||||
puImage(e, this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
const getPolicyBase64 = () => {
|
||||
let date = new Date();
|
||||
date.setHours(date.getHours() + env.timeout);
|
||||
let srcT = date.toISOString();
|
||||
const policyText = {
|
||||
"expiration": srcT,
|
||||
"conditions": [
|
||||
["content-length-range", 0, 5 * 1024 * 1024] //上传容量最大为5M
|
||||
]
|
||||
};
|
||||
const policyBase64 = base64.encode(JSON.stringify(policyText));
|
||||
return policyBase64;
|
||||
}
|
||||
const getSignature = (_this, policyBase64) => {
|
||||
const accesskey = _this.upImgConfig.aliConfig.AccessKeySecret || env.AccessKeySecret;
|
||||
const bytes = Crypto.HMAC(Crypto.SHA1, policyBase64, accesskey, {
|
||||
asBytes: true
|
||||
});
|
||||
const signature = Crypto.util.bytesToBase64(bytes);
|
||||
return signature;
|
||||
}
|
||||
|
||||
// 上传文件
|
||||
const upload_file_server = async (_this, configs, upload_picture_list, j) => {
|
||||
let aliConfig = {
|
||||
aliyunFileKey: `${configs.aliConfig.oosDirectory}/` + new Date().getTime() + Math.floor(Math.random() *
|
||||
150) +
|
||||
'.png',
|
||||
aliyunServerURL: configs.aliConfig.url,
|
||||
accessid: configs.aliConfig.OSSAccessKeyId,
|
||||
url: configs.aliConfig.url || "",
|
||||
oos: configs.aliConfig.oos || false
|
||||
}
|
||||
|
||||
const aliyunFileKey = aliConfig.aliyunFileKey ? aliConfig.aliyunFileKey : "";
|
||||
const aliyunServerURL = aliConfig.aliyunServerURL ? aliConfig.aliyunServerURL : "";
|
||||
const accessid = aliConfig.accessid ? aliConfig.accessid : "";
|
||||
const policyBase64 = getPolicyBase64();
|
||||
const signature = getSignature(_this, policyBase64);
|
||||
|
||||
|
||||
const upload_task = await uni.uploadFile({
|
||||
url: aliConfig.url,
|
||||
filePath: upload_picture_list[j]['path'],
|
||||
name: 'file',
|
||||
formData: {
|
||||
'key': aliyunFileKey,
|
||||
'policy': policyBase64,
|
||||
'OSSAccessKeyId': accessid,
|
||||
'signature': signature,
|
||||
'success_action_status': '200',
|
||||
},
|
||||
async success(res) {
|
||||
if (res.statusCode == 200) {
|
||||
// console.log('打印后端反馈的信息:',data);
|
||||
// 先获取图片url(各个后端返回值不一,所以造成出入)
|
||||
// 修改获取的图片返回值路径
|
||||
// 提示:data.info改为你图片返回地址即可
|
||||
let filename = aliyunServerURL + aliyunFileKey;
|
||||
console.log(`%c 阿里云上传(成功返回地址):${filename}`, 'color:#1AAD19');
|
||||
upload_picture_list[j]['path_server'] = filename;
|
||||
_this.upload_picture_list = upload_picture_list;
|
||||
await _this.$emit('onUpImg', _this.upload_picture_list);
|
||||
uni.hideLoading();
|
||||
} else {
|
||||
uni.showLoading({
|
||||
title: `上传失败!`
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
}, 2000);
|
||||
_this.upload_picture_list = [];
|
||||
_this.upload_after_list = [];
|
||||
console.warn(`阿里云上传图片失败,返回状态码:`, res.statusCode);
|
||||
}
|
||||
},
|
||||
async fail(err) {
|
||||
uni.showLoading({
|
||||
title: `上传失败!`
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
}, 2000);
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
upload_task.onProgressUpdate(async (res) => {
|
||||
for (let i = 0, len = _this.upload_picture_list.length; i < len; i++) {
|
||||
upload_picture_list[i]['upload_percent'] = await res.progress;
|
||||
}
|
||||
_this.upload_picture_list = upload_picture_list
|
||||
});
|
||||
}
|
||||
|
||||
// 上传图片(通用)
|
||||
const uImage = async (_this, config) => {
|
||||
for (let j = 0, len = _this.upload_picture_list.length; j < len; j++) {
|
||||
if (_this.upload_picture_list[j]['upload_percent'] == 0) {
|
||||
await upload_file_server(_this, config, _this.upload_picture_list, j)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 删除图片(通用)
|
||||
const dImage = async (e, _this) => {
|
||||
await _this.$emit('onImgDel', {
|
||||
url: e.currentTarget.dataset.url,
|
||||
index: e.currentTarget.dataset.index
|
||||
});
|
||||
_this.upload_picture_list.splice(e.currentTarget.dataset.index, 1);
|
||||
_this.upload_after_list.splice(e.currentTarget.dataset.index, 1);
|
||||
_this.upload_picture_list = _this.upload_picture_list;
|
||||
}
|
||||
|
||||
|
||||
// 选择图片(通用)
|
||||
const cImage = (_this, count, configs) => {
|
||||
let config = {
|
||||
aliConfig: {
|
||||
AccessKeySecret: configs.aliConfig.AccessKeySecret,
|
||||
OSSAccessKeyId: configs.aliConfig.OSSAccessKeyId,
|
||||
oosDirectory: configs.aliConfig.oosDirectory,
|
||||
url: configs.aliConfig.url
|
||||
},
|
||||
count,
|
||||
tips: configs.tips || false,
|
||||
notli: configs.notli,
|
||||
sourceType: configs.sourceType,
|
||||
sizeType: configs.sizeType
|
||||
}
|
||||
uni.chooseImage({
|
||||
count: config.notli ? config.count = 9 : _this.upload_after_list.length == 0 ? config.count : config.count -
|
||||
_this.upload_after_list.length,
|
||||
sizeType: config.sizeType == "" || config.sizeType == undefined || config.sizeType == true ? ['compressed'] : [
|
||||
'original'
|
||||
],
|
||||
sourceType: config.sourceType == "" || config.sourceType == undefined ? ['album', 'camera'] : config.sourceType ==
|
||||
'camera' ? ['camera'] : config.sourceType == 'album' ? ['album'] : ['album', 'camera'],
|
||||
success: async (res) => {
|
||||
for (let i = 0, len = res.tempFiles.length; i < len; i++) {
|
||||
res.tempFiles[i]['upload_percent'] = 0;
|
||||
res.tempFiles[i]['path_server'] = '';
|
||||
_this.upload_picture_list.push(res.tempFiles[i]);
|
||||
_this.upload_picture_list.length > config.count ? _this.upload_picture_list = _this.upload_picture_list.slice(
|
||||
0,
|
||||
config.count) : '';
|
||||
}
|
||||
// 过滤多出的预览图片
|
||||
await fImage(_this, res, config);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 过滤超出的图片以及上传(通用)
|
||||
const fImage = (_this, res, config) => {
|
||||
!config.notli && config.count == _this.upload_picture_list.length ? uImage(_this, config) : '';
|
||||
config.notli && config.count == 9 ? uImage(_this, config) : '';
|
||||
_this.upload_after_list = _this.upload_after_list.concat(res.tempFilePaths).slice(0, config.count);
|
||||
_this.upload_picture_list = _this.upload_picture_list.slice(0, config.count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 上传前预览图片(通用)
|
||||
const pImage = (e, _this) => {
|
||||
uni.previewImage({
|
||||
current: _this.upload_after_list[e.currentTarget.dataset.index],
|
||||
urls: _this.upload_after_list
|
||||
})
|
||||
}
|
||||
|
||||
// 上传后预览(通用)
|
||||
const puImage = async (e, _this) => {
|
||||
let prevImgArr = [];
|
||||
for (let i = 0, len = _this.upload_picture_list.length; i < len; i++) {
|
||||
prevImgArr.push(_this.upload_picture_list[i].path_server);
|
||||
}
|
||||
uni.previewImage({
|
||||
current: e.currentTarget.dataset.src,
|
||||
urls: prevImgArr
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@import url("iconfont");
|
||||
/*
|
||||
2019-07-25 更改图标为字体图标
|
||||
*/
|
||||
|
||||
.icon-text {
|
||||
font-size: 26upx;
|
||||
}
|
||||
|
||||
|
||||
/* 图片宽高+遮罩层宽高+遮罩层行高 */
|
||||
.sunsin_width {
|
||||
width: 160upx !important;
|
||||
height: 160upx !important;
|
||||
line-height: 160upx !important;
|
||||
}
|
||||
|
||||
/* 循环列表样式 */
|
||||
.sunsin_picture_list {
|
||||
width: 96%;
|
||||
padding: 2%;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sunsin_picture_list image {
|
||||
width: 40upx;
|
||||
height: 40upx;
|
||||
margin: 0 4%;
|
||||
}
|
||||
|
||||
/* 添加图片样式 */
|
||||
.sunsin_add_image {
|
||||
color: #ddd;
|
||||
font-size: 144upx;
|
||||
text-align: center;
|
||||
line-height: 0 !important;
|
||||
margin: 2% 0 0 4%;
|
||||
background-color: #eee;
|
||||
cursor: pointer;
|
||||
border-radius: 8upx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
/* 预览图片 */
|
||||
.sunsin_picture_item {
|
||||
position: relative;
|
||||
margin: 20upx 21upx 0 0;
|
||||
}
|
||||
|
||||
/* 删除按钮样式 */
|
||||
.sunsin_picture_item .del {
|
||||
position: absolute;
|
||||
color: #fff;
|
||||
border-radius: -4upx;
|
||||
border-top-right-radius: 6upx;
|
||||
width: 40upx;
|
||||
height: 40upx;
|
||||
line-height: 40upx;
|
||||
z-index: 2;
|
||||
text-align: center;
|
||||
background-color: #E54D42;
|
||||
}
|
||||
|
||||
/* 删除图标位置(上左) */
|
||||
.sunsin_picture_item .del.left {
|
||||
top: 0;
|
||||
left: 0;
|
||||
margin-left: 4%;
|
||||
border-top-right-radius: 0;
|
||||
border-top-left-radius: 6upx;
|
||||
}
|
||||
|
||||
/* 删除图标位置(上右) */
|
||||
.sunsin_picture_item .del.right {
|
||||
top: 0;
|
||||
right: -4.2%;
|
||||
}
|
||||
|
||||
/* 删除图标位置(下左) */
|
||||
.sunsin_picture_item .del.bleft {
|
||||
bottom: 0;
|
||||
left: 4%;
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 6upx;
|
||||
}
|
||||
|
||||
/* 删除图标位置(下右) */
|
||||
.sunsin_picture_item .del.bright {
|
||||
right: -4.2%;
|
||||
bottom: 0;
|
||||
border-top-right-radius: 0;
|
||||
}
|
||||
|
||||
/* 进度遮罩层样式 */
|
||||
.sunsin_upload_progress {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
color: #fff;
|
||||
font-size: 24upx;
|
||||
text-align: center;
|
||||
line-height: 160upx;
|
||||
margin-left: 4%;
|
||||
border-radius: 8upx;
|
||||
background-color: rgba(0, 0, 0, .7);
|
||||
}
|
||||
|
||||
/* 自定义添加图片样式 */
|
||||
.sunsin_picture_item image {
|
||||
box-shadow: 6upx 6upx 12upx rgba(112, 128, 144, 0.7);
|
||||
border-radius: 15upx;
|
||||
}
|
||||
</style>
|
||||
+331
@@ -0,0 +1,331 @@
|
||||
<template name='sunui-upimg'>
|
||||
<view>
|
||||
<view class="sunsin_picture_list">
|
||||
<view v-for="(item,index) in upload_picture_list" :key="index" class="sunsin_picture_item">
|
||||
<image v-show="item.upload_percent < 100" class="sunsin_width" :src="item.path" mode="aspectFill"></image>
|
||||
<image v-show="item.upload_percent == 100" class="sunsin_width" :data-src="item.path_server" :src="item.path_server"
|
||||
mode="aspectFill" :data-idx="index" @click="previewImgs"></image>
|
||||
<view class="sunsin_upload_progress sunsin_width" v-show="item.upload_percent < 100" :data-index="index" @click="previewImg">{{item.upload_percent}}%</view>
|
||||
<text class='del iconfont icon-shanchu' :class="upImgConfig.delBtnLocation=='left'?'left':upImgConfig.delBtnLocation=='right'?'right':upImgConfig.delBtnLocation=='bleft'?'bleft':upImgConfig.delBtnLocation=='bright'?'bright':'right'"
|
||||
@click='deleteImg' :data-url="item.path_server" :data-index="index" :style="'color:'+upImgConfig.delIconText+';background-color:'+upImgConfig.delIconColor"
|
||||
:hidden="upImgConfig.isDelIcon || false">×</text>
|
||||
</view>
|
||||
<view>
|
||||
<view class='sunsin_picture_item sunsin_width' v-show="upload_picture_list.length<upImgConfig.count || upImgConfig.notli"
|
||||
v-if="upImgConfig.iconReplace =='' || upImgConfig.iconReplace==undefined">
|
||||
<view class="sunsin_add_image sunsin_width" @click='chooseImage(upImgConfig.count)' :style="'background-color:'+upImgConfig.upBgColor+''"
|
||||
v-show="!upImgConfig.isAddImage || false">
|
||||
<view>
|
||||
<text class="iconfont" :class="[upImgConfig.upIconName==undefined?'icon-shangchuantupian':upImgConfig.upIconName]"
|
||||
style="font-size: 72upx;margin-bottom: 12upx;" :style="'color:'+upImgConfig.upIconColor+';width:100%;'"></text>
|
||||
</view>
|
||||
<view class="icon-text" :style="'color:'+upImgConfig.upIconColor+';width:100%;'">{{upImgConfig.upTextDesc==undefined ||upImgConfig.upTextDesc==''?'上传照片':upImgConfig.upTextDesc}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class='sunsin_picture_item sunsin_width' v-show="upload_picture_list.length<upImgConfig.count || upImgConfig.notli"
|
||||
v-else>
|
||||
<view class="sunsin_add_image sunsin_width" @click='chooseImage(upImgConfig.count)' style="'background-color:#fff;'"
|
||||
v-show="upImgConfig.isAddImage || true">
|
||||
<image :src="upImgConfig.iconReplace" class="icon_replace"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
upload_after_list: [],
|
||||
upload_picture_list: []
|
||||
};
|
||||
},
|
||||
name: 'sunui-upimg',
|
||||
props: {
|
||||
upImgConfig: {
|
||||
type: Object
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
initServerImage(e) {
|
||||
this.upload_picture_list = e;
|
||||
},
|
||||
chooseImage(count) {
|
||||
cImage(this, parseInt(count), this.upImgConfig);
|
||||
},
|
||||
uploadimage(e) {
|
||||
uImage(this, e);
|
||||
},
|
||||
deleteImg(e) {
|
||||
dImage(e, this);
|
||||
},
|
||||
previewImg(e) {
|
||||
pImage(e, this);
|
||||
},
|
||||
previewImgs(e) {
|
||||
puImage(e, this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 上传文件
|
||||
const upload_file_server = async (_this, configs, upload_picture_list, j) => {
|
||||
|
||||
let basicConfig = {
|
||||
url: configs.basicConfig.url || ""
|
||||
}
|
||||
|
||||
const upload_task = await uni.uploadFile({
|
||||
url: basicConfig.url,
|
||||
filePath: upload_picture_list[j]['path'],
|
||||
name: 'file',
|
||||
formData: {},
|
||||
async success(res) {
|
||||
if (res.statusCode == 200) {
|
||||
let data = JSON.parse(res.data);
|
||||
console.log(`%c 后端上传(成功返回地址):${data.info}`, 'color:#1AAD19');
|
||||
// 先获取图片url(各个后端返回值不一,所以造成出入)
|
||||
// 修改获取的图片返回值路径
|
||||
// 提示:data.info改为你图片返回地址即可
|
||||
upload_picture_list[j]['path_server'] = data.info; //修改返回图片地址即可(2019/05/06) => 无论是腾讯云还是阿里云或者其它(只要返回图片地址以及引入对应的js文件进行一些配置即可扩展本插件)
|
||||
_this.upload_picture_list = upload_picture_list;
|
||||
await tImage(_this, upload_picture_list, configs.count);
|
||||
uni.hideLoading();
|
||||
}
|
||||
},
|
||||
async fail(err) {
|
||||
uni.showLoading({
|
||||
title: `上传失败!`
|
||||
});
|
||||
_this.upload_picture_list = [];
|
||||
_this.upload_after_list = [];
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
}, 2000)
|
||||
console.warn(err, '请检查是否CORB/CORS错误!')
|
||||
}
|
||||
});
|
||||
upload_task.onProgressUpdate(async (res) => {
|
||||
for (let i = 0, len = _this.upload_picture_list.length; i < len; i++) {
|
||||
upload_picture_list[i]['upload_percent'] = await res.progress;
|
||||
}
|
||||
_this.upload_picture_list = upload_picture_list
|
||||
});
|
||||
}
|
||||
|
||||
// 上传图片子组件->父组件(通用)
|
||||
const tImage = async (_this, upload_picture_list, count) => {
|
||||
await _this.$emit('onUpImg', _this.upload_picture_list);
|
||||
}
|
||||
|
||||
|
||||
// 上传图片(通用)
|
||||
const uImage = async (_this, config) => {
|
||||
for (let j = 0, len = _this.upload_picture_list.length; j < len; j++) {
|
||||
if (_this.upload_picture_list[j]['upload_percent'] == 0) {
|
||||
await upload_file_server(_this, config, _this.upload_picture_list, j)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 删除图片(通用)
|
||||
const dImage = async (e, _this) => {
|
||||
await _this.$emit('onImgDel', {
|
||||
url: e.currentTarget.dataset.url,
|
||||
index: e.currentTarget.dataset.index
|
||||
});
|
||||
_this.upload_picture_list.splice(e.currentTarget.dataset.index, 1);
|
||||
_this.upload_after_list.splice(e.currentTarget.dataset.index, 1);
|
||||
_this.upload_picture_list = _this.upload_picture_list;
|
||||
}
|
||||
|
||||
// 选择图片(通用)
|
||||
const cImage = (_this, count, configs) => {
|
||||
let config = {
|
||||
basicConfig: {
|
||||
url: configs.basicConfig.url
|
||||
},
|
||||
count,
|
||||
notli: configs.notli,
|
||||
sourceType: configs.sourceType,
|
||||
sizeType: configs.sizeType,
|
||||
tips: configs.tips || false
|
||||
}
|
||||
uni.chooseImage({
|
||||
count: config.notli ? config.count = 9 : _this.upload_after_list.length == 0 ? config.count : config.count -
|
||||
_this.upload_after_list.length,
|
||||
sizeType: config.sizeType == "" || config.sizeType == undefined || config.sizeType == true ? ['compressed'] : [
|
||||
'original'
|
||||
],
|
||||
sourceType: config.sourceType == "" || config.sourceType == undefined ? ['album', 'camera'] : config.sourceType ==
|
||||
'camera' ? ['camera'] : config.sourceType == 'album' ? ['album'] : ['album', 'camera'],
|
||||
success: async (res) => {
|
||||
for (let i = 0, len = res.tempFiles.length; i < len; i++) {
|
||||
res.tempFiles[i]['upload_percent'] = 0;
|
||||
res.tempFiles[i]['path_server'] = '';
|
||||
_this.upload_picture_list.push(res.tempFiles[i]);
|
||||
_this.upload_picture_list.length > config.count ? _this.upload_picture_list = _this.upload_picture_list.slice(
|
||||
0,
|
||||
config.count) : '';
|
||||
}
|
||||
// 过滤多出的预览图片
|
||||
await fImage(_this, res, config);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 过滤超出的预览图片以及上传(通用)
|
||||
const fImage = (_this, res, config) => {
|
||||
!config.notli && config.count == _this.upload_picture_list.length ? uImage(_this, config) : '';
|
||||
config.notli && config.count == 9 ? uImage(_this, config) : '';
|
||||
_this.upload_after_list = _this.upload_after_list.concat(res.tempFilePaths).slice(0, config.count);
|
||||
_this.upload_picture_list = _this.upload_picture_list.slice(0, config.count);
|
||||
}
|
||||
|
||||
|
||||
// 上传前预览图片(通用)
|
||||
const pImage = (e, _this) => {
|
||||
uni.previewImage({
|
||||
current: _this.upload_after_list[e.currentTarget.dataset.index],
|
||||
urls: _this.upload_after_list
|
||||
})
|
||||
}
|
||||
|
||||
// 上传后预览(通用)
|
||||
const puImage = async (e, _this) => {
|
||||
let prevImgArr = [];
|
||||
for (let i = 0, len = _this.upload_picture_list.length; i < len; i++) {
|
||||
prevImgArr.push(_this.upload_picture_list[i].path_server);
|
||||
}
|
||||
uni.previewImage({
|
||||
current: e.currentTarget.dataset.src,
|
||||
urls: prevImgArr
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style scoped>
|
||||
@import url("iconfont");
|
||||
/*
|
||||
2019-07-25 更改图标为字体图标
|
||||
*/
|
||||
|
||||
.icon-text {
|
||||
font-size: .2em;
|
||||
}
|
||||
|
||||
/* 宽度 */
|
||||
.sunsin_width {
|
||||
width: 160upx !important;
|
||||
height: 160upx !important;
|
||||
line-height: 160upx !important;
|
||||
}
|
||||
|
||||
/* 循环列表样式 */
|
||||
.sunsin_picture_list {
|
||||
width: 96%;
|
||||
padding: 2%;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sunsin_picture_list image {
|
||||
width: 40upx;
|
||||
height: 40upx;
|
||||
margin: 0 4%;
|
||||
}
|
||||
|
||||
/* 添加图片样式 */
|
||||
.sunsin_add_image {
|
||||
color: #ddd;
|
||||
font-size: 144upx;
|
||||
text-align: center;
|
||||
line-height: 0 !important;
|
||||
margin: 2% 0 0 4%;
|
||||
background-color: #eee;
|
||||
cursor: pointer;
|
||||
border-radius: 8upx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
/* 预览图片 */
|
||||
.sunsin_picture_item {
|
||||
position: relative;
|
||||
margin: 20upx 21upx 0 0;
|
||||
}
|
||||
|
||||
/* 删除按钮样式 */
|
||||
.sunsin_picture_item .del {
|
||||
position: absolute;
|
||||
color: #fff;
|
||||
border-radius: -4upx;
|
||||
border-top-right-radius: 6upx;
|
||||
width: 40upx;
|
||||
height: 40upx;
|
||||
line-height: 40upx;
|
||||
z-index: 2;
|
||||
text-align: center;
|
||||
background-color: #E54D42;
|
||||
}
|
||||
|
||||
/* 删除图标位置(上左) */
|
||||
.sunsin_picture_item .del.left {
|
||||
top: 0;
|
||||
left: 0;
|
||||
margin-left: 4%;
|
||||
border-top-right-radius: 0;
|
||||
border-top-left-radius: 6upx;
|
||||
}
|
||||
|
||||
/* 删除图标位置(上右) */
|
||||
.sunsin_picture_item .del.right {
|
||||
top: 0;
|
||||
right: -4.2%;
|
||||
}
|
||||
|
||||
/* 删除图标位置(下左) */
|
||||
.sunsin_picture_item .del.bleft {
|
||||
bottom: 0;
|
||||
left: 4%;
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 6upx;
|
||||
}
|
||||
|
||||
/* 删除图标位置(下右) */
|
||||
.sunsin_picture_item .del.bright {
|
||||
right: -4.2%;
|
||||
bottom: 0;
|
||||
border-top-right-radius: 0;
|
||||
}
|
||||
|
||||
/* 进度遮罩层样式 */
|
||||
.sunsin_upload_progress {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
color: #fff;
|
||||
font-size: 24upx;
|
||||
text-align: center;
|
||||
line-height: 160upx;
|
||||
margin-left: 4%;
|
||||
border-radius: 8upx;
|
||||
background-color: rgba(0, 0, 0, .7);
|
||||
}
|
||||
|
||||
/* 自定义添加图片样式 */
|
||||
.sunsin_picture_item image {
|
||||
box-shadow: 6upx 6upx 12upx rgba(112, 128, 144, 0.7);
|
||||
border-radius: 15upx;
|
||||
}
|
||||
</style>
|
||||
+344
@@ -0,0 +1,344 @@
|
||||
<template name='sunui-upimg'>
|
||||
<view>
|
||||
<view class="sunsin_picture_list">
|
||||
<view v-for="(item,index) in upload_picture_list" :key="index" class="sunsin_picture_item">
|
||||
<image v-show="item.upload_percent < 100" class="sunsin_width" :src="item.path" mode="aspectFill"></image>
|
||||
<image v-show="item.upload_percent == 100" class="sunsin_width" :data-src="item.path_server" :src="item.path_server"
|
||||
mode="aspectFill" :data-idx="index" @click="previewImgs"></image>
|
||||
<view class="sunsin_upload_progress sunsin_width" v-show="item.upload_percent < 100" :data-index="index" @click="previewImg">{{item.upload_percent}}%</view>
|
||||
<text class='del iconfont icon-shanchu' :class="upImgConfig.delBtnLocation=='left'?'left':upImgConfig.delBtnLocation=='right'?'right':upImgConfig.delBtnLocation=='bleft'?'bleft':upImgConfig.delBtnLocation=='bright'?'bright':'right'"
|
||||
@click='deleteImg' :data-url="item.path_server" :data-index="index" :style="'color:'+upImgConfig.delIconText+';background-color:'+upImgConfig.delIconColor"
|
||||
:hidden="upImgConfig.isDelIcon || false">×</text>
|
||||
</view>
|
||||
<view>
|
||||
<view class='sunsin_picture_item sunsin_width' v-show="upload_picture_list.length<upImgConfig.count || upImgConfig.notli"
|
||||
v-if="upImgConfig.iconReplace =='' || upImgConfig.iconReplace==undefined">
|
||||
<view class="sunsin_add_image sunsin_width" @click='chooseImage(upImgConfig.count)' :style="'background-color:'+upImgConfig.upBgColor+''"
|
||||
v-show="!upImgConfig.isAddImage || false">
|
||||
<!-- 这里可以改为字体图标/iconfont -->
|
||||
<view>
|
||||
<text class="iconfont" :class="[upImgConfig.upIconName==undefined?'icon-shangchuantupian':upImgConfig.upIconName]"
|
||||
style="font-size: 72upx;margin-bottom: 12upx;" :style="'color:'+upImgConfig.upIconColor+';width:100%;'"></text>
|
||||
</view>
|
||||
<view class="icon-text" :style="'color:'+upImgConfig.upIconColor+';width:100%;'">{{upImgConfig.upTextDesc==undefined ||upImgConfig.upTextDesc==''?'上传照片':upImgConfig.upTextDesc}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class='sunsin_picture_item sunsin_width' v-show="upload_picture_list.length<upImgConfig.count || upImgConfig.notli"
|
||||
v-else>
|
||||
<view class="sunsin_add_image sunsin_width" @click='chooseImage(upImgConfig.count)' style="'background-color:#fff;'"
|
||||
v-show="upImgConfig.isAddImage || true">
|
||||
<image :src="upImgConfig.iconReplace" class="icon_replace"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const qiniuUploader = require('./qiniu/qiniuUploader.js');
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
upload_after_list: [],
|
||||
upload_picture_list: []
|
||||
};
|
||||
},
|
||||
name: 'sunui-upimg',
|
||||
props: {
|
||||
upImgConfig: {
|
||||
type: Object
|
||||
}
|
||||
},
|
||||
created() {},
|
||||
methods: {
|
||||
initServerImage(e) {
|
||||
this.upload_picture_list = e;
|
||||
},
|
||||
chooseImage(count) {
|
||||
cImage(this, parseInt(count), this.upImgConfig);
|
||||
},
|
||||
uploadimage(e) {
|
||||
uImage(this, e);
|
||||
},
|
||||
deleteImg(e) {
|
||||
dImage(e, this);
|
||||
},
|
||||
previewImg(e) {
|
||||
pImage(e, this);
|
||||
},
|
||||
previewImgs(e) {
|
||||
puImage(e, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 上传文件
|
||||
const upload_file_server = async (_this, configs, upload_picture_list, j) => {
|
||||
let qiniuConfig = {
|
||||
region: configs.qiniuConfig.region,
|
||||
uptokenURL: configs.qiniuConfig.uptokenURL,
|
||||
uptoken: configs.qiniuConfig.uptoken,
|
||||
domain: configs.qiniuConfig.domain,
|
||||
shouldUseQiniuFileName: configs.qiniuConfig.shouldUseQiniuFileName || false,
|
||||
fileHead: configs.qiniuConfig.fileHead || 'file',
|
||||
key: configs.qiniuConfig.key || (new Date()).getTime()
|
||||
}
|
||||
await initQiniu(qiniuConfig);
|
||||
qiniuUploader.upload(upload_picture_list[j]['path'], async (res) => {
|
||||
if (res.error == "expired token") {
|
||||
uni.showToast({
|
||||
title: `token未获取到,${res.error}`,
|
||||
icon: 'none'
|
||||
});
|
||||
_this.upload_picture_list = [];
|
||||
_this.upload_after_list = [];
|
||||
console.warn('七牛云上传图片失败,错误信息:', res.error);
|
||||
return;
|
||||
}
|
||||
upload_picture_list[j]['path_server'] = `http://${res.fileUrl}`;
|
||||
console.log(`%c 七牛云上传(成功返回地址):http://${res.fileUrl}`, 'color:#1AAD19');
|
||||
_this.upload_picture_list = upload_picture_list;
|
||||
await _this.$emit('onUpImg', _this.upload_picture_list);
|
||||
}, (error) => {
|
||||
console.error('error: ' + JSON.stringify(error));
|
||||
},
|
||||
null,
|
||||
(progress) => {
|
||||
for (let i = 0, len = _this.upload_picture_list.length; i < len; i++) {
|
||||
upload_picture_list[i]['upload_percent'] = progress.progress;
|
||||
}
|
||||
_this.upload_picture_list = upload_picture_list
|
||||
// console.log('上传进度', progress.progress)
|
||||
// console.log('已经上传的数据长度', progress.totalBytesSent)
|
||||
// console.log('预期需要上传的数据总长度', progress.totalBytesExpectedToSend)
|
||||
});
|
||||
|
||||
}
|
||||
const initQiniu = async (qiniuConfig) => {
|
||||
let timestamp = (new Date()).getTime();
|
||||
let options = {
|
||||
region: qiniuConfig.region || 'NCN', // 华北区
|
||||
uptokenURL: qiniuConfig.uptokenURL || 'https://[yourserver.com]/api/uptoken',
|
||||
uptoken: qiniuConfig.uptoken || 'xxxx=',
|
||||
domain: qiniuConfig.domain || 'http://[yourBucketId].bkt.clouddn.com',
|
||||
shouldUseQiniuFileName: qiniuConfig.shouldUseQiniuFileName || false,
|
||||
fileHead: qiniuConfig.fileHead || 'file',
|
||||
key: qiniuConfig.key || timestamp
|
||||
};
|
||||
await qiniuUploader.init(options);
|
||||
}
|
||||
|
||||
|
||||
// 上传图片(通用)
|
||||
const uImage = async (_this, config) => {
|
||||
for (let j = 0, len = _this.upload_picture_list.length; j < len; j++) {
|
||||
if (_this.upload_picture_list[j]['upload_percent'] == 0) {
|
||||
await upload_file_server(_this, config, _this.upload_picture_list, j)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 删除图片(通用)
|
||||
const dImage = async (e, _this) => {
|
||||
await _this.$emit('onImgDel', {
|
||||
url: e.currentTarget.dataset.url,
|
||||
index: e.currentTarget.dataset.index
|
||||
});
|
||||
_this.upload_picture_list.splice(e.currentTarget.dataset.index, 1);
|
||||
_this.upload_after_list.splice(e.currentTarget.dataset.index, 1);
|
||||
_this.upload_picture_list = _this.upload_picture_list;
|
||||
}
|
||||
|
||||
|
||||
// 选择图片(通用)
|
||||
const cImage = (_this, count, configs) => {
|
||||
let config = {
|
||||
qiniuConfig: {
|
||||
region: configs.qiniuConfig.region,
|
||||
uptokenURL: configs.qiniuConfig.uptokenURL,
|
||||
uptoken: configs.qiniuConfig.uptoken,
|
||||
domain: configs.qiniuConfig.domain,
|
||||
shouldUseQiniuFileName: configs.qiniuConfig.shouldUseQiniuFileName,
|
||||
fileHead: 'file',
|
||||
key: configs.qiniuConfig.key || (new Date()).getTime(),
|
||||
qiniu: configs.qiniuConfig.qiniu
|
||||
},
|
||||
count,
|
||||
tips: configs.tips || false,
|
||||
notli: configs.notli,
|
||||
sourceType: configs.sourceType,
|
||||
sizeType: configs.sizeType
|
||||
}
|
||||
uni.chooseImage({
|
||||
count: config.notli ? config.count = 9 : _this.upload_after_list.length == 0 ? config.count : config.count -
|
||||
_this.upload_after_list.length,
|
||||
sizeType: config.sizeType == "" || config.sizeType == undefined || config.sizeType == true ? ['compressed'] : [
|
||||
'original'
|
||||
],
|
||||
sourceType: config.sourceType == "" || config.sourceType == undefined ? ['album', 'camera'] : config.sourceType ==
|
||||
'camera' ? ['camera'] : config.sourceType == 'album' ? ['album'] : ['album', 'camera'],
|
||||
success: async (res) => {
|
||||
for (let i = 0, len = res.tempFiles.length; i < len; i++) {
|
||||
res.tempFiles[i]['upload_percent'] = 0;
|
||||
res.tempFiles[i]['path_server'] = '';
|
||||
_this.upload_picture_list.push(res.tempFiles[i]);
|
||||
_this.upload_picture_list.length > config.count ? _this.upload_picture_list = _this.upload_picture_list.slice(
|
||||
0,
|
||||
config.count) : '';
|
||||
}
|
||||
// 过滤多出的预览图片
|
||||
await fImage(_this, res, config);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 过滤超出的预览图片以及上传(通用)
|
||||
const fImage = (_this, res, config) => {
|
||||
!config.notli && config.count == _this.upload_picture_list.length ? uImage(_this, config) : '';
|
||||
config.notli && config.count == 9 ? uImage(_this, config) : '';
|
||||
_this.upload_after_list = _this.upload_after_list.concat(res.tempFilePaths).slice(0, config.count);
|
||||
_this.upload_picture_list = _this.upload_picture_list.slice(0, config.count);
|
||||
}
|
||||
|
||||
// 上传前预览图片(通用)
|
||||
const pImage = (e, _this) => {
|
||||
uni.previewImage({
|
||||
current: _this.upload_after_list[e.currentTarget.dataset.index],
|
||||
urls: _this.upload_after_list
|
||||
})
|
||||
}
|
||||
|
||||
// 上传后预览(通用)
|
||||
const puImage = async (e, _this) => {
|
||||
let prevImgArr = [];
|
||||
for (let i = 0, len = _this.upload_picture_list.length; i < len; i++) {
|
||||
prevImgArr.push(_this.upload_picture_list[i].path_server);
|
||||
}
|
||||
uni.previewImage({
|
||||
current: e.currentTarget.dataset.src,
|
||||
urls: prevImgArr
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style scoped>
|
||||
@import url("iconfont");
|
||||
/*
|
||||
2019-07-25 更改图标为字体图标
|
||||
*/
|
||||
|
||||
.icon-text {
|
||||
font-size: .2em;
|
||||
}
|
||||
|
||||
/* 宽度 */
|
||||
.sunsin_width {
|
||||
width: 160upx !important;
|
||||
height: 160upx !important;
|
||||
line-height: 160upx !important;
|
||||
}
|
||||
|
||||
/* 循环列表样式 */
|
||||
.sunsin_picture_list {
|
||||
width: 96%;
|
||||
padding: 2%;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sunsin_picture_list image {
|
||||
width: 40upx;
|
||||
height: 40upx;
|
||||
margin: 0 4%;
|
||||
}
|
||||
|
||||
/* 添加图片样式 */
|
||||
.sunsin_add_image {
|
||||
color: #ddd;
|
||||
font-size: 144upx;
|
||||
text-align: center;
|
||||
line-height: 0 !important;
|
||||
margin: 2% 0 0 4%;
|
||||
background-color: #eee;
|
||||
cursor: pointer;
|
||||
border-radius: 8upx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
/* 预览图片 */
|
||||
.sunsin_picture_item {
|
||||
position: relative;
|
||||
margin: 20upx 21upx 0 0;
|
||||
}
|
||||
|
||||
/* 删除按钮样式 */
|
||||
.sunsin_picture_item .del {
|
||||
position: absolute;
|
||||
color: #fff;
|
||||
border-radius: -4upx;
|
||||
border-top-right-radius: 6upx;
|
||||
width: 40upx;
|
||||
height: 40upx;
|
||||
line-height: 40upx;
|
||||
z-index: 2;
|
||||
text-align: center;
|
||||
background-color: #E54D42;
|
||||
}
|
||||
|
||||
/* 删除图标位置(上左) */
|
||||
.sunsin_picture_item .del.left {
|
||||
top: 0;
|
||||
left: 0;
|
||||
margin-left: 4%;
|
||||
border-top-right-radius: 0;
|
||||
border-top-left-radius: 6upx;
|
||||
}
|
||||
|
||||
/* 删除图标位置(上右) */
|
||||
.sunsin_picture_item .del.right {
|
||||
top: 0;
|
||||
right: -4.2%;
|
||||
}
|
||||
|
||||
/* 删除图标位置(下左) */
|
||||
.sunsin_picture_item .del.bleft {
|
||||
bottom: 0;
|
||||
left: 4%;
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 6upx;
|
||||
}
|
||||
|
||||
/* 删除图标位置(下右) */
|
||||
.sunsin_picture_item .del.bright {
|
||||
right: -4.2%;
|
||||
bottom: 0;
|
||||
border-top-right-radius: 0;
|
||||
}
|
||||
|
||||
/* 进度遮罩层样式 */
|
||||
.sunsin_upload_progress {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
color: #fff;
|
||||
font-size: 24upx;
|
||||
text-align: center;
|
||||
line-height: 160upx;
|
||||
margin-left: 4%;
|
||||
border-radius: 8upx;
|
||||
background-color: rgba(0, 0, 0, .7);
|
||||
}
|
||||
|
||||
/* 自定义添加图片样式 */
|
||||
.sunsin_picture_item image {
|
||||
box-shadow: 6upx 6upx 12upx rgba(112, 128, 144, 0.7);
|
||||
border-radius: 15upx;
|
||||
}
|
||||
</style>
|
||||
+348
@@ -0,0 +1,348 @@
|
||||
<template name='sunui-upimg'>
|
||||
<view>
|
||||
<view class="sunsin_picture_list">
|
||||
<view v-for="(item,index) in upload_picture_list" :key="index" class="sunsin_picture_item">
|
||||
<image v-show="item.upload_percent < 100" class="sunsin_width" :src="item.path" mode="aspectFill"></image>
|
||||
<image v-show="item.upload_percent == 100" class="sunsin_width" :src="item.path_server" :data-src="item.path_server"
|
||||
mode="aspectFill" :data-idx="index" @click="previewImgs"></image>
|
||||
<view class="sunsin_upload_progress sunsin_width" v-show="item.upload_percent < 100" :data-index="index" @click="previewImg">{{item.upload_percent}}%</view>
|
||||
<text class='del iconfont icon-shanchu' :class="upImgConfig.delBtnLocation=='left'?'left':upImgConfig.delBtnLocation=='right'?'right':upImgConfig.delBtnLocation=='bleft'?'bleft':upImgConfig.delBtnLocation=='bright'?'bright':'right'"
|
||||
@click='deleteImg' :data-url="item.path_server" :data-index="index" :style="'color:'+upImgConfig.delIconText+';background-color:'+upImgConfig.delIconColor"
|
||||
:hidden="upImgConfig.isDelIcon || false">×</text>
|
||||
</view>
|
||||
<view>
|
||||
<view class='sunsin_picture_item sunsin_width' v-show="upload_picture_list.length<upImgConfig.count || upImgConfig.notli"
|
||||
v-if="upImgConfig.iconReplace =='' || upImgConfig.iconReplace==undefined">
|
||||
<view class="sunsin_add_image sunsin_width" @click='chooseImage(upImgConfig.count)' :style="'background-color:'+upImgConfig.upBgColor+''"
|
||||
v-show="!upImgConfig.isAddImage || false">
|
||||
<view>
|
||||
<text class="iconfont" :class="[upImgConfig.upIconName==undefined?'icon-shangchuantupian':upImgConfig.upIconName]"
|
||||
style="font-size: 72upx;margin-bottom: 12upx;" :style="'color:'+upImgConfig.upIconColor+';width:100%;'"></text>
|
||||
</view>
|
||||
<view class="icon-text" :style="'color:'+upImgConfig.upIconColor+';width:100%;'">{{upImgConfig.upTextDesc==undefined ||upImgConfig.upTextDesc==''?'上传照片':upImgConfig.upTextDesc}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class='sunsin_picture_item sunsin_width' v-show="upload_picture_list.length<upImgConfig.count || upImgConfig.notli"
|
||||
v-else>
|
||||
<view class="sunsin_add_image sunsin_width" @click='chooseImage(upImgConfig.count)' style="'background-color:#fff;'"
|
||||
v-show="upImgConfig.isAddImage || true">
|
||||
<image :src="upImgConfig.iconReplace" class="icon_replace"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
let COS = require('./tencent-cos/cos-wx-sdk-v5.js');
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
upload_after_list: [],
|
||||
upload_picture_list: [
|
||||
|
||||
]
|
||||
};
|
||||
},
|
||||
name: 'sunui-upimg',
|
||||
props: {
|
||||
upImgConfig: {
|
||||
type: Object
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initServerImage(e) {
|
||||
this.upload_picture_list = e;
|
||||
},
|
||||
chooseImage(count) {
|
||||
cImage(this, parseInt(count), this.upImgConfig);
|
||||
},
|
||||
uploadimage(e) {
|
||||
uImage(this, e);
|
||||
},
|
||||
deleteImg(e) {
|
||||
dImage(e, this);
|
||||
},
|
||||
previewImg(e) {
|
||||
pImage(e, this);
|
||||
},
|
||||
previewImgs(e) {
|
||||
puImage(e, this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 上传文件
|
||||
const upload_file_server = async (_this, configs, upload_picture_list, j) => {
|
||||
// 腾讯云配置
|
||||
let cosConfig = {
|
||||
Bucket: configs.cosConfig.Bucket,
|
||||
Region: configs.cosConfig.Region,
|
||||
SecretId: configs.cosConfig.SecretId,
|
||||
SecretKey: configs.cosConfig.SecretKey
|
||||
}
|
||||
|
||||
let cos = new COS({
|
||||
getAuthorization: (params, callback) => { //获取签名 必填参数
|
||||
// 推荐(服务器计算签名接口)
|
||||
// uni.request({
|
||||
// url: 'SIGN_SERVER_URL',
|
||||
// data: {
|
||||
// Method: params.Method,
|
||||
// Key: params.Key
|
||||
// },
|
||||
// dataType: 'text',
|
||||
// success: function (result) {
|
||||
// callback(result.data);
|
||||
// }
|
||||
// });
|
||||
// 方便前端调试
|
||||
let authorization = COS.getAuthorization({
|
||||
SecretId: cosConfig.SecretId,
|
||||
SecretKey: cosConfig.SecretKey,
|
||||
Method: params.Method,
|
||||
Key: params.Key
|
||||
});
|
||||
callback(authorization);
|
||||
}
|
||||
});
|
||||
|
||||
let filePath = upload_picture_list[j]['path'];
|
||||
let Key = filePath.substr(filePath.lastIndexOf('/') + 1); // 这里指定上传的文件名
|
||||
|
||||
cos.postObject({
|
||||
Bucket: cosConfig.Bucket,
|
||||
Region: cosConfig.Region,
|
||||
Key: Key,
|
||||
FilePath: filePath
|
||||
}, (err, data) => {
|
||||
if (err == null) {
|
||||
console.log(`%c 腾讯云上传(成功返回地址):${data.headers.Location}`, 'color:#1AAD19');
|
||||
upload_picture_list[j]['path_server'] = data.headers.Location;
|
||||
upload_picture_list[j]['upload_percent'] = 100;
|
||||
} else {
|
||||
console.log(`%c 腾讯云上传失败:${JSON.stringify(err)}`, 'color:#f00');
|
||||
return;
|
||||
}
|
||||
});
|
||||
await _this.$emit('onUpImg', upload_picture_list);
|
||||
_this.upload_picture_list = upload_picture_list;
|
||||
}
|
||||
|
||||
|
||||
// 上传图片(通用)
|
||||
const uImage = async (_this, config) => {
|
||||
for (let j = 0, len = _this.upload_picture_list.length; j < len; j++) {
|
||||
if (_this.upload_picture_list[j]['upload_percent'] == 0) {
|
||||
await upload_file_server(_this, config, _this.upload_picture_list, j)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 删除图片(通用)
|
||||
const dImage = async (e, _this) => {
|
||||
await _this.$emit('onImgDel', {
|
||||
url: e.currentTarget.dataset.url,
|
||||
index: e.currentTarget.dataset.index
|
||||
});
|
||||
_this.upload_picture_list.splice(e.currentTarget.dataset.index, 1);
|
||||
_this.upload_after_list.splice(e.currentTarget.dataset.index, 1);
|
||||
_this.upload_picture_list = _this.upload_picture_list;
|
||||
}
|
||||
|
||||
// 选择图片(通用)
|
||||
const cImage = (_this, count, configs) => {
|
||||
let config = {
|
||||
cosConfig: {
|
||||
Bucket: configs.cosConfig.Bucket, //replace with yours
|
||||
Region: configs.cosConfig.Region, //replace with yours
|
||||
SecretId: configs.cosConfig.SecretId, //replace with yours
|
||||
SecretKey: configs.cosConfig.SecretKey //replace with yours
|
||||
},
|
||||
count,
|
||||
notli: configs.notli,
|
||||
sourceType: configs.sourceType,
|
||||
sizeType: configs.sizeType,
|
||||
tips: configs.tips || false
|
||||
}
|
||||
|
||||
|
||||
uni.chooseImage({
|
||||
count: config.notli ? config.count = 9 : _this.upload_after_list.length == 0 ? config.count : config.count -
|
||||
_this.upload_after_list.length,
|
||||
sizeType: config.sizeType == "" || config.sizeType == undefined || config.sizeType == true ? ['compressed'] : [
|
||||
'original'
|
||||
],
|
||||
sourceType: config.sourceType == "" || config.sourceType == undefined ? ['album', 'camera'] : config.sourceType ==
|
||||
'camera' ? ['camera'] : config.sourceType == 'album' ? ['album'] : ['album', 'camera'],
|
||||
success: async (res) => {
|
||||
for (let i = 0, len = res.tempFiles.length; i < len; i++) {
|
||||
res.tempFiles[i]['upload_percent'] = 0;
|
||||
res.tempFiles[i]['path_server'] = '';
|
||||
_this.upload_picture_list.push(res.tempFiles[i]);
|
||||
_this.upload_picture_list.length > config.count ? _this.upload_picture_list = _this.upload_picture_list.slice(
|
||||
0,
|
||||
config.count) : '';
|
||||
}
|
||||
// 过滤多出的预览图片
|
||||
await fImage(_this, res, config);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 过滤超出的预览图片以及上传(通用)
|
||||
const fImage = (_this, res, config) => {
|
||||
!config.notli && config.count == _this.upload_picture_list.length ? uImage(_this, config) : '';
|
||||
config.notli && config.count == 9 ? uImage(_this, config) : '';
|
||||
_this.upload_after_list = _this.upload_after_list.concat(res.tempFilePaths).slice(0, config.count);
|
||||
_this.upload_picture_list = _this.upload_picture_list.slice(0, config.count);
|
||||
}
|
||||
|
||||
// 上传前预览图片(通用)
|
||||
const pImage = (e, _this) => {
|
||||
let _cacheImg = [];
|
||||
for (let i = 0, len = _this.upload_picture_list.length; i < len; i++) {
|
||||
_cacheImg.push(_this.upload_picture_list[i].path);
|
||||
}
|
||||
uni.previewImage({
|
||||
current: _this.upload_picture_list[e.currentTarget.dataset.index].path,
|
||||
urls: _cacheImg
|
||||
});
|
||||
}
|
||||
|
||||
// 上传后预览(通用)
|
||||
const puImage = async (e, _this) => {
|
||||
let prevImgArr = [];
|
||||
for (let i = 0, len = _this.upload_picture_list.length; i < len; i++) {
|
||||
prevImgArr.push(_this.upload_picture_list[i].path_server);
|
||||
}
|
||||
uni.previewImage({
|
||||
current: e.currentTarget.dataset.src,
|
||||
urls: prevImgArr
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style scoped>
|
||||
@import url("iconfont");
|
||||
/*
|
||||
2019-07-25 更改图标为字体图标
|
||||
*/
|
||||
|
||||
.icon-text {
|
||||
font-size: .2em;
|
||||
}
|
||||
|
||||
/* 宽度 */
|
||||
.sunsin_width {
|
||||
width: 160upx !important;
|
||||
height: 160upx !important;
|
||||
line-height: 160upx !important;
|
||||
}
|
||||
|
||||
/* 循环列表样式 */
|
||||
.sunsin_picture_list {
|
||||
width: 96%;
|
||||
padding: 2%;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sunsin_picture_list image {
|
||||
width: 40upx;
|
||||
height: 40upx;
|
||||
margin: 0 4%;
|
||||
}
|
||||
|
||||
/* 添加图片样式 */
|
||||
.sunsin_add_image {
|
||||
color: #ddd;
|
||||
font-size: 144upx;
|
||||
text-align: center;
|
||||
line-height: 0 !important;
|
||||
margin: 2% 0 0 4%;
|
||||
background-color: #eee;
|
||||
cursor: pointer;
|
||||
border-radius: 8upx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
/* 预览图片 */
|
||||
.sunsin_picture_item {
|
||||
position: relative;
|
||||
margin: 20upx 21upx 0 0;
|
||||
}
|
||||
|
||||
/* 删除按钮样式 */
|
||||
.sunsin_picture_item .del {
|
||||
position: absolute;
|
||||
color: #fff;
|
||||
border-radius: -4upx;
|
||||
border-top-right-radius: 6upx;
|
||||
width: 40upx;
|
||||
height: 40upx;
|
||||
line-height: 40upx;
|
||||
z-index: 2;
|
||||
text-align: center;
|
||||
background-color: #E54D42;
|
||||
}
|
||||
|
||||
/* 删除图标位置(上左) */
|
||||
.sunsin_picture_item .del.left {
|
||||
top: 0;
|
||||
left: 0;
|
||||
margin-left: 4%;
|
||||
border-top-right-radius: 0;
|
||||
border-top-left-radius: 6upx;
|
||||
}
|
||||
|
||||
/* 删除图标位置(上右) */
|
||||
.sunsin_picture_item .del.right {
|
||||
top: 0;
|
||||
right: -4.2%;
|
||||
}
|
||||
|
||||
/* 删除图标位置(下左) */
|
||||
.sunsin_picture_item .del.bleft {
|
||||
bottom: 0;
|
||||
left: 4%;
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 6upx;
|
||||
}
|
||||
|
||||
/* 删除图标位置(下右) */
|
||||
.sunsin_picture_item .del.bright {
|
||||
right: -4.2%;
|
||||
bottom: 0;
|
||||
border-top-right-radius: 0;
|
||||
}
|
||||
|
||||
/* 进度遮罩层样式 */
|
||||
.sunsin_upload_progress {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
color: #fff;
|
||||
font-size: 24upx;
|
||||
text-align: center;
|
||||
line-height: 160upx;
|
||||
margin-left: 4%;
|
||||
border-radius: 8upx;
|
||||
background-color: rgba(0, 0, 0, .7);
|
||||
}
|
||||
|
||||
/* 自定义添加图片样式 */
|
||||
.sunsin_picture_item image {
|
||||
box-shadow: 6upx 6upx 12upx rgba(112, 128, 144, 0.7);
|
||||
border-radius: 15upx;
|
||||
}
|
||||
</style>
|
||||
+344
@@ -0,0 +1,344 @@
|
||||
<!--
|
||||
版本号:3.0
|
||||
各位可以按需求更改兼容阿里云、七牛云、腾讯云以及其它(从老项目抽取导入一些JavaScript即可) - 有时间就进行迭代以前的版本
|
||||
-->
|
||||
|
||||
<template name='sunui-upimg'>
|
||||
<view class="sunui-uploader-bd">
|
||||
<view class="sunui-uploader-files">
|
||||
<block v-for="(item,index) in upload_before_list" :key='index'>
|
||||
<view class="sunui-uploader-file" :class="[item.upload_percent<100?'sunui-uploader-file-status':'']" @click="previewImage(index)">
|
||||
<image class="sunui-uploader-img" :style="'width:'+upload_img_wh+'rpx;height:'+upload_img_wh+'rpx;'" :src="item.path"
|
||||
mode="aspectFill" />
|
||||
<view class="sunui-img-removeicon right" @click.stop="removeImage(index)">x</view>
|
||||
<view class="sunui-loader-filecontent" v-if="item.upload_percent<100">{{item.upload_percent}}%</view>
|
||||
</view>
|
||||
</block>
|
||||
<view v-show="upload_before_list.length<upload_count" hover-class="sunui-uploader-hover" class="sunui-uploader-inputbox"
|
||||
@click="chooseImage" :style="'width:'+upload_img_wh+'rpx;height:'+upload_img_wh+'rpx;'">
|
||||
<view :style="'line-height:'+upload_img_wh+'rpx;'"><text class="iconfont icon-mn_shangchuantupian" style="color: #666;"></text></view>
|
||||
<!-- <view style="color: #666;">上传图片</view> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var _self;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
// 选择图片tempFile
|
||||
upload_cache: [],
|
||||
// 预览数组->支持从服务器拉取
|
||||
upload_cache_list: [],
|
||||
// 上传数组
|
||||
upload_before_list: [],
|
||||
// 图片大小
|
||||
upload_img_size: [],
|
||||
// 超出限制数组
|
||||
upload_exceeded_list: [],
|
||||
// 上传数量
|
||||
upload_count: 9,
|
||||
// 最大上传容量(M)
|
||||
upload_max: 1,
|
||||
// 图片/选择宽高
|
||||
upload_img_wh: 162,
|
||||
// 测试接口(建议七牛、阿里云、腾讯云都采用后端对接,直接调用后端上传)
|
||||
url: 'https://a3.dns06.net.cn/app/index.php?i=2&c=entry&a=wxapp&do=Upload_qiniu_b&m=jzwx_a'
|
||||
}
|
||||
},
|
||||
name: 'sunui-upimg',
|
||||
props: {
|
||||
upload_auto: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
_self = this;
|
||||
},
|
||||
mounted() {
|
||||
_self.$nextTick(function() {
|
||||
_self.upload_before_list.map(function(item) {
|
||||
_self.upload_cache_list.push(item.path);
|
||||
});
|
||||
_self.emit();
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
upImage(paths) {
|
||||
const promises = paths.map((path) => {
|
||||
return promisify(upload)({
|
||||
url: _self.url,
|
||||
path: path,
|
||||
name: 'file',
|
||||
extra: {},
|
||||
})
|
||||
})
|
||||
uni.showLoading({
|
||||
title: '正在上传...',
|
||||
});
|
||||
Promise.all(promises).then((data) => {
|
||||
uni.hideLoading();
|
||||
_self.upload_cache_list.push(...data);
|
||||
_self.emit();
|
||||
}).catch((res) => {
|
||||
console.log(res);
|
||||
uni.hideLoading();
|
||||
});
|
||||
},
|
||||
chooseImage() {
|
||||
uni.chooseImage({
|
||||
count: _self.upload_count - _self.upload_before_list.length,
|
||||
sizeType: ['compressed', 'original'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: async (res) => {
|
||||
for (let i = 0, len = res.tempFiles.length; i < len; i++) {
|
||||
res.tempFiles[i]['upload_percent'] = 0;
|
||||
if (Math.ceil(res.tempFiles[i].size / 1024) < _self.upload_max * 1024) {
|
||||
await _self.upload_img_size.push(Math.ceil(res.tempFiles[i].size / 1024));
|
||||
await _self.upload_before_list.push(res.tempFiles[i]);
|
||||
// TODO v3.1增加图片格式限制
|
||||
} else {
|
||||
res.tempFilePaths.splice(i, 1);
|
||||
_self.upload_exceeded_list.push(i === 0 ? 1 : i + 1);
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: `第${[...new Set(_self.upload_exceeded_list)].join(',')}张图片超出限制${_self.upload_max}M,已过滤`,
|
||||
showCancel: false,
|
||||
confirmText: '确认',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
_self.upload_img_size.splice(i--, 1);
|
||||
_self.upload_exceeded_list.splice(i--, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
_self.upload_cache = await res.tempFilePaths;
|
||||
_self.upload(_self.upload_auto);
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
},
|
||||
async upload(upload_auto) {
|
||||
upload_auto ? await _self.upImage(_self.upload_cache) : console.warn(
|
||||
`传输参数:this.$refs.xx.upload(true)才可上传,默认false`);
|
||||
},
|
||||
previewImage(idx) {
|
||||
uni.previewImage({
|
||||
current: idx,
|
||||
urls: _self.upload_cache_list
|
||||
});
|
||||
},
|
||||
removeImage(idx) {
|
||||
_self.upload_before_list.splice(idx, 1);
|
||||
_self.upload_cache_list.splice(idx, 1);
|
||||
_self.emit();
|
||||
},
|
||||
emit() {
|
||||
_self.$emit('change', _self.upload_cache_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const promisify = (api) => {
|
||||
return (options, ...params) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
api(Object.assign({}, options, {
|
||||
success: resolve,
|
||||
fail: reject
|
||||
}), ...params);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const upload = options => {
|
||||
var url = options.url,
|
||||
path = options.path,
|
||||
name = options.name,
|
||||
// data = options.data,
|
||||
extra = options.extra,
|
||||
success = options.success,
|
||||
progress = options.progress,
|
||||
fail = options.fail
|
||||
|
||||
const uploadTask = uni.uploadFile({
|
||||
url: url,
|
||||
filePath: path,
|
||||
name: name,
|
||||
formData: extra,
|
||||
success: function(res) {
|
||||
var data = res.data
|
||||
try {
|
||||
//Tip : 切记->主要修改这里图片的返回值为真实返回路径!!! 详情见示例
|
||||
data = JSON.parse(res.data).info
|
||||
} catch (e) {
|
||||
throw (e)
|
||||
}
|
||||
// 根据自己的返回数据做相应判断,服务器返回200即代表成功请求
|
||||
if (res.statusCode == 200) {
|
||||
if (success) {
|
||||
success(data)
|
||||
}
|
||||
} else {
|
||||
if (fail) {
|
||||
fail(data)
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
fail: function(res) {
|
||||
console.log(res)
|
||||
if (fail) {
|
||||
fail(res)
|
||||
}
|
||||
}
|
||||
})
|
||||
uploadTask.onProgressUpdate(async (res) => {
|
||||
for (let i = 0, len = _self.upload_before_list.length; i < len; i++) {
|
||||
_self.upload_before_list[i]['upload_percent'] = await res.progress;
|
||||
}
|
||||
_self.upload_before_list = _self.upload_before_list;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@font-face {
|
||||
font-family: "iconfont";
|
||||
src: url('//at.alicdn.com/iconfont.eot?t=1574391686418');
|
||||
/* IE9 */
|
||||
src: url('//at.alicdn.com/iconfont.eot?t=1574391686418#iefix') format('embedded-opentype'),
|
||||
/* IE6-IE8 */
|
||||
url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAMkAAsAAAAAB2QAAALYAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCCcAqCYIJEATYCJAMICwYABCAFhG0HPRt3BhEVlCNkH4dxmzUXNsJHc1SNfR9KTkCtiXv/l+QDBQSFRBJdKoEsg60HUgCsOpWVnWxNx3BvVITqkj3fepbtzM/OfDo4D86iFEIiJAeX02+Bh/O84TLmsrEnYBxQoHtgm6xACoxTkN0zFsgEdQynCShpq7cwbsK0eTKROSkgbNu8cbUspRFrkoNMkC9ZGYWjcrJkX/IIR/zPhz/6hIxELmWmzdowfp1RvxdbYWm1VrUMCO54JvDrSNEbkTCv1DJDGvp6S5VUX9SRdSUHfi+u1cBZ7R+PQMgzEyugNcU5J67DO9VfJiCigD042iuNQqXSunGRfvrWV6/mvX49/+3bhW/eLHr4puOFtxMfvO5w9tX8yv7rIbf3Rrl84Mbe66XSzWet46nn/etMuALua5LqNZUqpKdfDKjsv2qef+yambJsTWM2zDtKIQ0pS7msvSTUpn1tNyts2xZmWUyw3LI4bPisSZNyOUc2y4/scfZs3QZ1UcgqUWtkVednsvnVs7NOHzmqglXIBnqU7+/M9Hp3y3L2RLWYA9uhlat61/LGGwVqt9Nvafv/8R2fmg/pu7LesH9ZOYL3/6e3P6Z2O0rbIztra+Dtc1u2RY1vapOocEtDiT0Kd1VUUkIN42joS19Fk1s1BVmKy0OioA2kMp1REdcbcsr6QV5mJJT0MnF9mbQRchZiET29CAT1fSBR1y1I1fdFRdwPcpr6Q179cIaSBaHRjmVdgxFjCSvGFuonmGYcpK1nESRfUC1dRUm+T3ggeeOEOIiywRwHpDHm+FUlzBIkjT1k5DzsuhEmGi02HGjmKQ1DWfaioBn7gzAWQRWGWqD2BIzGaCDRm4nc+y+QsuhUqKaqyviAiGcGB7FA1AKVS4ZWVddyibdSEoxJQCKjHsjIMNTpjMBUPsxCDRbQPTyTVGh1k20lwfyy/un2QYmpTII1I9Vo+1B4XQ2q0QvwvExGfTgA') format('woff2'),
|
||||
url('//at.alicdn.com/iconfont.woff?t=1574391686418') format('woff'),
|
||||
url('//at.alicdn.com/iconfont.ttf?t=1574391686418') format('truetype'),
|
||||
/* chrome, firefox, opera, Safari, Android, iOS 4.2+ */
|
||||
url('//at.alicdn.com/iconfont.svg?t=1574391686418#iconfont') format('svg');
|
||||
/* iOS 4.1- */
|
||||
}
|
||||
|
||||
.iconfont {
|
||||
font-family: "iconfont" !important;
|
||||
font-size: 16px;
|
||||
font-style: normal;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.icon-mn_shangchuantupian:before {
|
||||
content: "\e559";
|
||||
}
|
||||
|
||||
.icon-mn_shangchuantupian {
|
||||
font-size: 3em;
|
||||
}
|
||||
|
||||
.sunui-uploader-img {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.sunui-uploader-input {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.sunui-uploader-inputbox {
|
||||
position: relative;
|
||||
margin-bottom: 16rpx;
|
||||
box-sizing: border-box;
|
||||
background-color: #ededed;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.sunui-img-removeicon {
|
||||
position: absolute;
|
||||
color: #fff;
|
||||
width: 30upx;
|
||||
height: 30upx;
|
||||
line-height: 30upx;
|
||||
z-index: 2;
|
||||
text-align: center;
|
||||
background-color: #E54D42;
|
||||
border-radius: 50%;
|
||||
|
||||
&.right {
|
||||
top: 0;
|
||||
// right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.sunui-uploader-file {
|
||||
position: relative;
|
||||
margin-right: 16rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.sunui-uploader-file-status:before {
|
||||
content: " ";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.sunui-loader-filecontent {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
color: #fff;
|
||||
z-index: 9;
|
||||
}
|
||||
|
||||
.sunui-uploader-bd {
|
||||
padding: 26rpx;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.sunui-uploader-files {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.sunui-uploader-file:nth-child(4n+0) {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.sunui-uploader-inputbox {
|
||||
&>view {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.sunui-uploader-file-status:after {
|
||||
content: " ";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.sunui-uploader-hover {
|
||||
box-shadow: 0 0 0 #e5e5e5;
|
||||
background: #e5e5e5;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,7 @@
|
||||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.COS=e():t.COS=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="D:\\github\\cos-wx-sdk-v5\\demo\\lib",e(e.s=2)}([function(t,e,n){"use strict";(function(e){function r(t){return encodeURIComponent(t).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")}function o(t){return u(t,function(t){return"object"==typeof t?o(t):t})}function i(t,e){return s(e,function(n,r){t[r]=e[r]}),t}function a(t){return t instanceof Array}function s(t,e){for(var n in t)t.hasOwnProperty(n)&&e(t[n],n)}function u(t,e){var n=a(t)?[]:{};for(var r in t)t.hasOwnProperty(r)&&(n[r]=e(t[r],r));return n}var c=n(8),l=n(9),f=n(10),h=n(11),d=function(t){t=t||{};var e=t.SecretId,n=t.SecretKey,o=(t.method||t.Method||"get").toLowerCase(),i=t.pathname||t.Key||"/",a=t.params||"",s=t.headers||"";if(0!==i.indexOf("/")&&(i="/"+i),!e)return console.error("lack of param SecretId");if(!n)return console.error("lack of param SecretKey");var u=function(t){var e=[];for(var n in t)t.hasOwnProperty(n)&&e.push(n);return e.sort()},c=function(t){var e,n,o,i=[],a=u(t);for(e=0;e<a.length;e++)n=a[e],o=t[n]||"",n=n.toLowerCase(),i.push(r(n)+"="+r(o));return i.join("&")},f=parseInt((new Date).getTime()/1e3)-1,h=f,d=t.Expires||t.expires;h+=void 0===d?900:1*d||0;var p=e,g=f+";"+h,y=f+";"+h,v=u(s).join(";").toLowerCase(),C=u(a).join(";").toLowerCase(),m=l.HmacSHA1(y,n).toString(),A=[o,i,c(a),c(s),""].join("\n"),_=["sha1",g,l.SHA1(A).toString(),""].join("\n");return["q-sign-algorithm=sha1","q-ak="+p,"q-sign-time="+g,"q-key-time="+y,"q-header-list="+v,"q-url-param-list="+C,"q-signature="+l.HmacSHA1(_,m).toString()].join("&")},p=function(t){var e={};for(var n in t)void 0!==t[n]&&null!==t[n]&&(e[n]=t[n]);return e},g=function(t){var n,r,o,i=[];for(n=0,r=t.length/2;n<r;n++)o=parseInt(t[2*n]+t[2*n+1],16),i.push(o);return new e(i).toString("base64")},y=function(){var t=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()},v=function(t,e){var n=e.Bucket,r=e.Region,o=e.Key;return t.indexOf("Bucket")>-1||"deleteMultipleObject"===t||"multipartList"===t?n&&r:!(t.indexOf("Object")>-1||t.indexOf("multipart")>-1||"sliceUploadFile"===t||"abortUploadTask"===t)||n&&r&&o},C=function(t,e){var n={gz:"ap-guangzhou",tj:"ap-beijing-2",sh:"ap-shanghai",cd:"ap-chengdu"};return function(r,o){if(o=o||function(){},"getService"!==t&&"abortUploadTask"!==t){if(!v(t,r))return void o({error:"lack of required params"});if(r.Region&&n[r.Region])return void o({error:"Region should be "+n[r.Region]});if(r.Region&&r.Region.indexOf("cos.")>-1)return void o({error:'Region should not be start with "cos."'});if(r.Bucket){if(!/^(.+)-(\d+)$/.test(r.Bucket))if(r.AppId)r.Bucket=r.Bucket+"-"+r.AppId;else{if(!this.options.AppId)return void o({error:'Bucket should format as "test-1250000000".'});r.Bucket=r.Bucket+"-"+this.options.AppId}r.AppId&&(console.warn('warning: AppId has been deprecated, Please put it at the end of parameter Bucket(E.g Bucket:"test-1250000000" ).'),delete r.AppId)}r.Key&&"/"===r.Key.substr(0,1)&&(r.Key=r.Key.substr(1))}var i=e.call(this,r,o);if("getAuth"===t||"getObjectUrl"===t)return i}},m=function(t,e){function n(){if(o=0,e&&"function"==typeof e){r=Date.now();var n,i=Math.max(0,Math.round((s-a)/((r-u)/1e3)*100)/100);n=0===s&&0===t?1:Math.round(s/t*100)/100||0,u=r,a=s;try{e({loaded:s,total:t,speed:i,percent:n})}catch(t){}}}var r,o,i=this,a=0,s=0,u=Date.now();return function(e,r){if(e&&(s=e.loaded,t=e.total),r)clearTimeout(o),n();else{if(o)return;o=setTimeout(n,i.options.ProgressInterval)}}},A={apiWrapper:C,getAuth:d,xml2json:f,json2xml:h,md5:c,clearKey:p,binaryBase64:g,extend:i,isArray:a,each:s,map:u,clone:o,uuid:y,throttleOnProgress:m};t.exports=A}).call(e,n(1).Buffer)},function(t,e,n){"use strict";(function(t){function r(){return i.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(t,e){if(r()<e)throw new RangeError("Invalid typed array length");return i.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=i.prototype):(null===t&&(t=new i(e)),t.length=e),t}function i(t,e,n){if(!(i.TYPED_ARRAY_SUPPORT||this instanceof i))return new i(t,e,n);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return c(this,t)}return a(this,t,e,n)}function a(t,e,n,r){if("number"==typeof e)throw new TypeError('"value" argument mLine truncated
|
||||
* The buffer module from node.js, for the browser.
|
||||
*
|
||||
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
||||
* @license MIT
|
||||
*/
|
||||
var Z=n(5),V=n(6),$=n(7);e.Buffer=i,e.SlowBuffer=g,e.INSPECT_MAX_BYTES=50,i.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=r(),i.poolSize=8192,i._augment=function(t){return t.__proto__=i.prototype,t},i.from=function(t,e,n){return a(null,t,e,n)},i.TYPED_ARRAY_SUPPORT&&(i.prototype.__proto__=Uint8Array.prototype,i.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&i[Symbol.species]===i&&Object.defineProperty(i,Symbol.species,{value:null,configurable:!0})),i.alloc=function(t,e,n){return u(null,t,e,n)},i.allocUnsafe=function(t){return c(null,t)},i.allocUnsafeSlow=function(t){return c(null,t)},i.isBuffer=function(t){return!(null==t||!t._isBuffer)},i.compare=function(t,e){if(!i.isBuffer(t)||!i.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,o=0,a=Math.min(n,r);o<a;++o)if(t[o]!==e[o]){n=t[o],r=e[o];break}return n<r?-1:r<n?1:0},i.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},i.concat=function(t,e){if(!$(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return i.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=i.allocUnsafe(e),o=0;for(n=0;n<t.length;++n){var a=t[n];if(!i.isBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(r,o),o+=a.length}return r},i.byteLength=y,i.prototype._isBuffer=!0,i.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)C(this,e,e+1);return this},i.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)C(this,e,e+3),C(this,e+1,e+2);return this},i.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)C(this,e,e+7),C(this,e+1,e+6),C(this,e+2,e+5),C(this,e+3,e+4);return this},i.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?k(this,0,t):v.apply(this,arguments)},i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===i.compare(this,t)},i.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),"<Buffer "+t+">"},i.prototype.compare=function(t,e,n,r,o){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,r>>>=0,o>>>=0,this===t)return 0;for(var a=o-r,s=n-e,u=Math.min(a,s),c=this.slice(r,o),l=t.slice(e,n),f=0;f<u;++f)if(c[f]!==l[f]){a=c[f],s=l[f];break}return a<s?-1:s<a?1:0},i.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},i.prototype.indexOf=function(t,e,n){return m(this,t,e,n,!0)},i.prototype.lastIndexOf=function(t,e,n){return m(this,t,e,n,!1)},i.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-e;if((void 0===n||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return _(this,t,e,n);case"utf8":case"utf-8":return x(this,t,e,n);case"ascii":return w(this,t,e,n);case"latin1":case"binary":return R(this,t,e,n);case"base64":return B(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Q=4096;i.prototype.slice=function(t,e){var n=this.length;t=~~t,e=void 0===e?n:~~e,t<0?(t+=n)<0&&(t=0):t>n&&(t=n),e<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);var r;if(i.TYPED_ARRAY_SUPPORT)r=this.subarray(t,e),r.__proto__=i.prototype;else{var o=e-t;r=new i(o,void 0);for(var a=0;a<o;++a)r[a]=this[a+t]}return r},i.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||D(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r},i.prototype.readUIntBE=function(t,e,n){t|=0,eLine truncated
|
||||
Reference in new issue
Block a user