Commit 80a0d76d authored by lvtz's avatar lvtz

fix

parents 81d894ad fe3d06c0
import constants from './constants.js';
const api = constants.host + '/v3/'; // 打卡通用接口
const apiv4 = constants.host + '/v4/'; // 打卡通用接口
const apiv2 = constants.host2 + '/shop/api/'; // 打卡登录注册忘记密码接口
const apis = {
......@@ -41,9 +42,9 @@ const apis = {
// login: `${api}member/login`,
// verifyCode: 'http://biz.wp53.cn/v2/api/service/user/verify_code',
// register: `${api}common/qx_login/register`,
cOssAccess: `${api}student/oss/access`,
cOssAccess: `${apiv4}student/oss/access`,
circleUserShow: `${api}consumer/clock/circle/userShow`,
cMediaOssAccess: `${api}student/media_access`,
cMediaOssAccess: `${apiv4}student/media_access`,
generateBusinessQrcode: `${api}common/qr_code_unlimit`,
generateCustomerQrcode: `${api}common/qr_code_unlimit`,
updateUserinfo: `${api}consumer/clock/userinfo/edit`,
......
......@@ -6,21 +6,18 @@ import {
} from '../utilities/index.js';
import apis from '../constants/api.js';
// 原本c端公用的方法
function cOssAccess () {
function cOssAccess (data) {
return wxRequest({
url: apis.customer.common.cOssAccess,
data: {
},
data: data || {},
method: 'GET',
errorresolve: 1,
})
}
function cMediaOssAccess ({type}) {
function cMediaOssAccess (data) {
return wxRequest({
url: apis.customer.common.cMediaOssAccess,
data: {
type
},
data,
method: 'GET',
errorresolve: 1,
})
......
// src/pages/activityindex/index.js
import {
wxChooseImage,
wxUploadFile
} from '../../../utilities/wxApi.js';
import {
......
......@@ -384,14 +384,8 @@ Page({
this.setData({
imageUploaded: false
})
cOssAccess().then((acc) => {
access = acc.data;
if(!tempFiles.currentTarget){
return {tempFiles,};
}
return wxChooseImage({
count: this.data.maxImgCount - imgCount
})
wxChooseImage({
count: this.data.maxImgCount - imgCount
}).then((res) => {
const {tempFiles} = res;
let imageBox = this.data.imageBox;
......@@ -419,16 +413,17 @@ Page({
this.setData({
imageBox: res.imageBox,
})
this.singleUploadFile(access)
this.singleUploadFile()
}).catch((e) => {
wx.hideLoading()
})
},
singleUploadFile(access) {
singleUploadFile() {
wx.showLoading({
title: '图片上传中...',
mask: true
})
let access = {};
let imageBox = this.data.imageBox;
if (this.data.currentIndex == (imageBox.length)) {
wx.hideLoading();
......@@ -440,34 +435,45 @@ Page({
}
return;
}
let filename = `${access.dir}${getRandomFilename(imageBox[this.data.currentIndex].src)}`;
imageBox[this.data.currentIndex].status = 'resolving';
this.setData({
imageBox
})
wxUploadFile({
url: access.host,
formData: {
key: filename,
policy: access.policy,
OSSAccessKeyId: access.accessid,
signature: access.signature,
callback: access.callback,
success_action_status: '200'
},
filePath: imageBox[this.data.currentIndex].src,
name: 'file',
const path = imageBox[this.data.currentIndex].src;
const fileType = path.substr(path.lastIndexOf('.') + 1);
cOssAccess({
school_id: this.data.sid,
ext: fileType
}).then((acc) => {
access = acc.data;
// if(!tempFiles.currentTarget){
// return {tempFiles,};
// }
// imageBox[this.data.currentIndex].src = access.path;
return wxUploadFile({
url: access.host,
formData: {
key: access.path,
policy: access.policy,
OSSAccessKeyId: access.accessid,
signature: access.signature,
callback: access.callback,
success_action_status: '200'
},
filePath: imageBox[this.data.currentIndex].src,
name: 'file',
})
}).then((res) => {
let data = JSON.parse(res.data);
if (data.status == 'ok') {
imageBox[this.data.currentIndex].status = 'fullfilled';
imageBox[this.data.currentIndex].src = filename;
imageBox[this.data.currentIndex].src = access.path;
let currentIndex = this.data.currentIndex + 1;
this.setData({
imageBox,
currentIndex
})
this.singleUploadFile(access);
this.singleUploadFile();
} else {
imageBox[this.data.currentIndex].status = 'fail';
let currentIndex = this.data.currentIndex + 1;
......@@ -475,16 +481,16 @@ Page({
imageBox,
currentIndex
})
this.singleUploadFile(access);
this.singleUploadFile();
}
}).catch(() => {
}).catch((e) => {
imageBox[this.data.currentIndex].status = 'fail';
let currentIndex = this.data.currentIndex + 1;
this.setData({
imageBox,
currentIndex
})
this.singleUploadFile(access);
this.singleUploadFile();
})
},
delimg (e) {
......@@ -783,18 +789,16 @@ Page({
const that = this;
let access = {};
let filename = '';
cMediaOssAccess({
type: 1
}).then((res) => {
access = res.data;
if(tempFile){
return tempFile
}
return wxChooseVideo({
})
let videoInsertIndex = 0;
let imageBox = this.data.imageBox;
let size = 0;
let duration = 0;
let tempFilePath ='';
wxChooseVideo({
}).then((res) => {
let tempFilePath ='';
const { duration, size} = res;
// access = res.data;
size = res.size;
duration = res.duration;
if(tempFile){
tempFilePath = res.path;
}else{
......@@ -818,11 +822,19 @@ Page({
})
return
}
let imageBox = this.data.imageBox
let videoInsertIndex = imageBox.filter(ele => ele.type == 'video').length;
filename = `${access.dir}${getRandomFilename(tempFilePath)}`;
videoInsertIndex = imageBox.filter(ele => ele.type == 'video').length;
// filename = `${access.dir}${getRandomFilename(tempFilePath)}`;
const path = tempFilePath;
const fileType = path.substr(path.lastIndexOf('.') + 1).toLowerCase();
return cMediaOssAccess({
school_id: this.data.sid,
ext: fileType,
type: 1
})
}).then((res) => {
access = res.data;
imageBox.splice(videoInsertIndex, 0, {
src: filename,
src: access.path,
status: 'resolving',
type: 'video',
size: size,
......@@ -831,10 +843,10 @@ Page({
that.setData({
imageBox
})
that.data.uploadVideoTask[`${filename}`] = wx.uploadFile({
that.data.uploadVideoTask[`${access.path}`] = wx.uploadFile({
url: access.host,
formData: {
key: filename,
key: access.path,
policy: access.policy,
OSSAccessKeyId: access.accessid,
signature: access.signature,
......@@ -846,9 +858,9 @@ Page({
success (res) {
const {data} = res;
if (data == '{"status":"ok"}') {
console.log(videoInsertIndex, 'videoInsertIndex');
let imageBox = that.data.imageBox;
imageBox[videoInsertIndex].src = filename;
console.log(access.path, 'filenamefilenamefilename');
imageBox[videoInsertIndex].src = access.path;
imageBox[videoInsertIndex].status = 'fullfilled';
imageBox[videoInsertIndex].videoprogress = 100;
that.setData({
......@@ -1255,6 +1267,7 @@ audioStorage[value].isWaiting = true;
const videoList = tempFiles.filter(ele=>{
return ele.type == 'video'
})
console.log(imgList, 'tempFilestempFiles');
this.addImg(imgList);
videoList.forEach((ele)=>{
this.addVideoMethod(ele)
......
// src/pages/activityindex/index.js
import {
wxChooseImage,
wxUploadFile
} from '../../../utilities/wxApi.js';
import {
......
......@@ -129,26 +129,36 @@ Page({
});
},
// .then((acc) => {
// access = acc.data;
// return access;
// })
proMainImgUpload (e) {
let access = {};
let tempFiles = null;
let filename = '';
const {type} = e.currentTarget.dataset;
cOssAccess({
school_id: this.data.sid
}).then((acc) => {
access = acc.data;
return wxChooseImage({})
}).then((res) => {
const {tempFiles} = res;
filename = `${access.dir}${getRandomFilename(tempFiles[0].path)}`;
wxChooseImage({}).then((res) => {
tempFiles = res.tempFiles;
const path = tempFiles[0].path;
const fileType = path.substr(path.lastIndexOf('.') + 1);
return cOssAccess({
school_id: this.data.sid,
ext: fileType
})
}).then((data) => {
const acc = data.data;
// filename = `${access.dir}${getRandomFilename(tempFiles[0].path)}`;
filename = acc.path;
console.log(filename, 'filename ');
return wxUploadFile({
url: access.host,
url: acc.host,
formData: {
key: filename,
policy: access.policy,
OSSAccessKeyId: access.accessid,
signature: access.signature,
callback: access.callback,
policy: acc.policy,
OSSAccessKeyId: acc.accessid,
signature: acc.signature,
callback: acc.callback,
success_action_status: '200'
},
filePath: tempFiles[0].path,
......@@ -156,6 +166,7 @@ Page({
})
}).then((res) => {
const {data} = res;
console.log(data, 'data')
if (data == '{"status":"ok"}') {
this.setData({
cropperSrc: imagify(filename, 'image/resize,w_1280/format,jpg'),
......@@ -196,6 +207,8 @@ Page({
},
clickcut (e) {
let filepath = e.detail.url;
const fileType = filepath.substr(filepath.lastIndexOf('.') + 1);
let fileName = '';
this.setData({
showCropper: false,
cropperSrc: '',
......@@ -203,18 +216,18 @@ Page({
})
let filename = '';
cOssAccess({
school_id: this.data.sid
}).then((acc) => {
return acc.data;
}).then((access) => {
filename = `${access.dir}${getRandomFilename(filepath)}`;
school_id: this.data.sid,
ext: fileType
}).then((res) => {
const access = res.data;
wx.showLoading({
title: '图片上传中'
})
fileName = access.path;
return wxUploadFile({
url: access.host,
formData: {
key: filename,
key: access.path,
policy: access.policy,
OSSAccessKeyId: access.accessid,
signature: access.signature,
......@@ -235,7 +248,7 @@ Page({
})
this.mycropper = null;
this.setData({
'userInfo.avatar': filename,
'userInfo.avatar': fileName,
})
} else {
wx.hideLoading();
......
......@@ -4,7 +4,7 @@
<view class="listitem">
<text class="listtitle">头像</text>
<view class="listcontent" bindtap="proMainImgUpload">
<image class="avatar" src="{{filter.imagify(userInfo.avatar, 'image/resize,w_320/format,jpg/quality,q_50')}}" wx:if="{{userInfo.avatar}}"></image>
<image class="avatar" mode="aspectFill" src="{{filter.imagify(userInfo.avatar, 'image/resize,w_320/format,jpg/quality,q_50')}}" wx:if="{{userInfo.avatar}}"></image>
<image class="avatar" src="{{imageRoot}}2c/ucenter2/empty_avatar.png?{{imageVersion}}" wx:else></image>
<image class="arrowsmall" src="{{imageRoot}}2b/organizationalmgt/right.png?{{imageVersion}}"></image>
</view>
......
// src/pages/activityindex/index.js
import {
wxChooseImage,
wxUploadFile
} from '../../../utilities/wxApi.js';
import {
......
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 to comment