update adout upload adout tencentCOS #43

Merged
cmx merged 1 commits from cmx into master 2020-08-12 15:18:55 +08:00
3 changed files with 90 additions and 63 deletions

7
common/cos-wx-sdk-v5.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -80,7 +80,7 @@
<!-- 已发货 -->
<view class="pushtimeline" v-if="type == 2">
<view class="timelinetitle">物流信息</view>
<view class="timelineid">订单单号:{{ info.order_sn }}</view>
<view class="timelineid">订单单号:&nbsp;&nbsp;&nbsp;{{ info.order_sn }}</view>
<view class="timelinebox" v-for="list in info.express_list">
<view class="timelinecontent">{{list.content}}</view>
<view class="timelinetime">{{list.kd_time}}</view>
@ -463,7 +463,6 @@ export default {
font-weight: 500;
color: #333333;
background-color: #ffffff;
border-bottom: 2rpx solid #ececec;
}
.refunds-user {
padding: 25rpx 30rpx;

View File

@ -25,7 +25,7 @@
<view>
<view class="titles">标签</view>
<view class="form-view active" @click="show_add()">+ 新建标签</view>
<view :class="['form-view',item.state == true ? 'active' : '']" v-for="(item, index) in fileListes" :key="index" @click="changeselect(index)">
<view :class="['form-view', item.state == true ? 'active' : '']" v-for="(item, index) in fileListes" :key="index" @click="changeselect(index)">
{{ item.name }}
</view>
</view>
@ -40,14 +40,7 @@
<view class="listes_shoping" v-for="(item, index) in list" :key="index">
<view>
<u-checkbox-group>
<u-checkbox
shape="circle"
size="40"
active-color="#FF780F"
v-model="item.checked"
:name="index"
@change="checkboxChange"
></u-checkbox>
<u-checkbox shape="circle" size="40" active-color="#FF780F" v-model="item.checked" :name="index" @change="checkboxChange"></u-checkbox>
</u-checkbox-group>
</view>
<view><image :src="item.goods_image" mode="widthFix"></image></view>
@ -84,6 +77,75 @@
</template>
<script>
let COS = require('../../common/cos-wx-sdk-v5.js');
//
const upload_file_server = (_this, filepath) => {
//
let cosConfig = {
Bucket: 'dmmall-1300406074', //replace with yours
Region: 'ap-shanghai', //replace with yours
SecretId: 'AKIDjDPJhni9gTzEB9iGNWQ3PTVGjv74q7EL', //replace with yours
SecretKey: 'ye3SZOvAQO5X5LK3Vy933h6G86h4mqpG' //replace with yours
};
//
let filePath = filepath;
//
let time = new Date();
var y = time.getFullYear();
var m = time.getMonth() + 1;
m = m < 10 ? '0' + m : m;
var d = time.getDate();
d = d < 10 ? '0' + d : d;
let str = y + m + d;
let Key = 'video/' + str + '/' + filePath.substr(filePath.lastIndexOf('/') + 1);
//
var cos = new COS({
SecretId: cosConfig.SecretId,
SecretKey: cosConfig.SecretKey
});
//
cos.postObject(
{
Bucket: cosConfig.Bucket,
Region: cosConfig.Region,
Key: Key,
StorgeClass: 'STANDARD', //
FilePath: filePath
},
(err, data) => {
console.log(err, data, 12345);
if (err == null) {
if (data.statusCode == 200) {
_this.videopath = 'https://dmmall-1300406074.cos.ap-shanghai.myqcloud.com/' + Key;
uni.hideLoading();
_this.videostate = true;
} else {
uni.showToast({
title: '上传失败!',
icon: 'none'
});
}
} else {
return;
}
}
);
};
// ()
const cImage = _this => {
uni.chooseVideo({
count: 1,
sourceType: ['camera', 'album'],
success: function(res) {
uni.showLoading({
title: '上传中'
});
const tempFilePaths = res.tempFilePath;
console.log(tempFilePaths);
upload_file_server(_this, tempFilePaths);
}
});
};
export default {
data() {
return {
@ -114,7 +176,7 @@ export default {
tagcontent: '', //
selectvideo: '', //
videostate: false, //
progress:0
progress: 0
};
},
onLoad() {
@ -158,11 +220,11 @@ export default {
title: res.message,
type: 'success'
});
setTimeout(function(){
setTimeout(function() {
uni.navigateBack({
delta:1
})
},1000)
delta: 1
});
}, 1000);
}
});
},
@ -236,48 +298,7 @@ export default {
},
//
uploadvideo() {
let url = this.action;
let that = this;
uni.showLoading({
title:'上传中'+that.progress+'%'
})
uni.chooseVideo({
count: 1,
sourceType: ['camera', 'album'],
success: function(res) {
that.src = res.tempFilePath;
const tempFilePaths = res.tempFilePath;
const uploadTask = uni.uploadFile({
url: url, //
filePath: tempFilePaths,
name: 'article_video',
formData: {
name: 'article_video'
},
header: {
Authorization: 'Bearer' + ' ' + uni.getStorageSync('token')
},
success: uploadFileRes => {
console.log(uploadFileRes);
let obj = JSON.parse(uploadFileRes.data);
that.videopath = obj.data.url;
that.selectvideo = obj.data.key;
uni.hideLoading()
that.videostate = true;
},
fail: function(error) {
console.log(error);
}
});
uploadTask.onProgressUpdate((res) => {
console.log("上传进度",res.progress)
that.progress = res.progress
//
if (res.progress == 100) {
}
});
}
});
cImage(this);
},
//
show_add() {
@ -291,13 +312,13 @@ export default {
// checkbox
checkboxChange(e) {
let that = this;
let num =Number(e.name)
let num = Number(e.name);
if (e.value == true) {
that.pushes(that.list[num].goods_id);
that.list[num].checked=true
that.list[num].checked = true;
} else {
that.delarr(that.list[num].goods_id);
that.list[num].checked=false
that.list[num].checked = false;
}
},
//
@ -456,7 +477,7 @@ export default {
-webkit-line-clamp: 2;
}
.form-view {
background: #CDC7C8;
background: #cdc7c8;
border-radius: 6rpx;
margin-right: 20rpx;
font-size: 24rpx;
@ -466,7 +487,7 @@ export default {
color: #fff;
}
.active {
background: #FF780F;
background: #ff780f;
}
.titles {
font-size: 30rpx;