81 lines
1.8 KiB
Vue
81 lines
1.8 KiB
Vue
<template>
|
|
<view>
|
|
<u-cell-group>
|
|
<u-cell-item title="选择内置背景图" :title-style="titleStyle"
|
|
:border-bottom="false" :border-top="false"
|
|
@click="linkToBuiltinBgImg"></u-cell-item>
|
|
</u-cell-group>
|
|
<u-gap :height="16" bg-color="#f4f4f5"></u-gap>
|
|
<u-cell-group>
|
|
<u-cell-item title="通过手机选择" :title-style="titleStyle"
|
|
:border-bottom="false" :border-top="false"
|
|
@click="chooseImg"></u-cell-item>
|
|
</u-cell-group>
|
|
|
|
<u-toast ref="uToast" />
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
titleStyle:{
|
|
marginLeft:"20rpx",
|
|
fontSize:"32rpx",
|
|
color:"#000000"
|
|
}
|
|
};
|
|
},
|
|
methods: {
|
|
chooseImg() {
|
|
let that=this;
|
|
uni.chooseImage({
|
|
count: 1, //默认9
|
|
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
|
sourceType: ['camera','album'], //从相册选择
|
|
success: function(res) {
|
|
console.log("res",res);
|
|
let tempFilePaths = res.tempFilePaths;
|
|
that.myUpload(tempFilePaths[0]);
|
|
return;
|
|
}
|
|
});
|
|
return;
|
|
},
|
|
|
|
//上传返回图片
|
|
myUpload(filePath) {
|
|
let that=this;
|
|
let obj = {
|
|
filePath:filePath,
|
|
savePath: "friendCircle" //文件存放目录
|
|
}
|
|
console.log("通过手机选择",obj);
|
|
this.globalUtil.globalUpload(that,{
|
|
param:obj,
|
|
success: (res1) => {
|
|
console.log("上传成功",res1);
|
|
let avatar= res1.result.url;
|
|
that.$u.vuex('circleBgImg',avatar);
|
|
uni.navigateBack();
|
|
},
|
|
fail:(res1) => {
|
|
console.log("上传失败",res1);
|
|
},
|
|
complete: (res1) => {
|
|
console.log("上传完成",res1);
|
|
}
|
|
});
|
|
},
|
|
|
|
linkToBuiltinBgImg() {
|
|
this.$u.route('/pages/tabbar/find/friend-circle/builtinBgImg');
|
|
},
|
|
},
|
|
|
|
};
|
|
</script>
|
|
|
|
<style></style>
|