Commit 04c1abcd by liangjianmin

js

parent dca65964
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
"quickapp" : {}, "quickapp" : {},
/* 小程序特有相关 */ /* 小程序特有相关 */
"mp-weixin" : { "mp-weixin" : {
"appid" : "wx47674efb6eef06e1", "appid" : "wx61a41a064fa2fb3c",
"setting" : { "setting" : {
"urlCheck" : false, "urlCheck" : false,
"es6" : true, "es6" : true,
......
...@@ -71,7 +71,7 @@ export default { ...@@ -71,7 +71,7 @@ export default {
fail: function(res) { fail: function(res) {
console.log(res); console.log(res);
uni.showToast({ uni.showToast({
title: '上传失败', title: '扫码失败',
icon: 'none' icon: 'none'
}); });
} }
......
...@@ -59,32 +59,37 @@ export default { ...@@ -59,32 +59,37 @@ export default {
chooseImageChange() { chooseImageChange() {
var self = this; var self = this;
var time = parseInt(new Date().getTime() / 1000); var time = parseInt(new Date().getTime() / 1000);
uni.chooseImage({ uni.chooseImage({
count: 4, count: 4,
sourceType: ['album', 'camera'],
success: chooseImageRes => { success: chooseImageRes => {
uni.showLoading({
title: '上传中...'
});
const tempFilePaths = chooseImageRes.tempFilePaths; const tempFilePaths = chooseImageRes.tempFilePaths;
let maxNum = tempFilePaths.length * 1 + self.attachAddress.length * 1; let maxNum = tempFilePaths.length * 1 + self.attachAddress.length * 1;
if (maxNum > 4) { if (maxNum > 4) {
uni.hideLoading();
uni.showToast({ uni.showToast({
title: '图片不超过4张' title: '图片不超过4张'
}); });
return false; return false;
} }
for (let i = 0; i < tempFilePaths.length; i++) { for (let i = 0; i < tempFilePaths.length; i++) {
console.log(tempFilePaths[i]);
uni.uploadFile({ uni.uploadFile({
url: 'https://api.ichunt.com/oss/upload', url: 'https://api.ichunt.com/oss/upload',
filePath: tempFilePaths[i], filePath: tempFilePaths[i],
name: 'upload', name: 'upload',
formData: { formData: {
source: '1', source: '1',
pf: 20,
k1: time, k1: time,
k2: w_md5.hex_md5_32(w_md5.hex_md5_32(String(time)) + 'fh6y5t4rr351d2c3bryi') k2: w_md5.hex_md5_32(w_md5.hex_md5_32(String(time)) + 'fh6y5t4rr351d2c3bryi')
}, },
success: uploadFileRes => { success: uploadFileRes => {
uni.hideLoading();
var data = JSON.parse(uploadFileRes.data); var data = JSON.parse(uploadFileRes.data);
console.log(data);
if (data.code === 200) { if (data.code === 200) {
self.attachAddress.push(data.data[0]); self.attachAddress.push(data.data[0]);
} else { } else {
...@@ -94,6 +99,7 @@ export default { ...@@ -94,6 +99,7 @@ export default {
} }
}, },
fail: error => { fail: error => {
uni.hideLoading();
console.log(error); console.log(error);
} }
}); });
...@@ -123,7 +129,7 @@ export default { ...@@ -123,7 +129,7 @@ export default {
}, 2000); }, 2000);
} else { } else {
uni.showToast({ uni.showToast({
title: res.msg, title: res.err_msg,
icon: 'none' icon: 'none'
}); });
} }
......
//const API_BASE = 'https://api.ichunt.com'; const API_BASE = 'https://api.ichunt.com';
const API_BASE = 'http://supplyapi.liexin.com' //const API_BASE = 'http://supplyapi.liexin.com'
const API = { const API = {
/** /**
* 上传数据 * 上传数据
...@@ -16,7 +16,7 @@ const API = { ...@@ -16,7 +16,7 @@ const API = {
/** /**
* 上传文件 * 上传文件
* */ * */
upload: API_BASE + '/oss/upload', upload: API_BASE + '/oss/upload'
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment