75 lines
1.7 KiB
Vue
75 lines
1.7 KiB
Vue
<template>
|
|
<view>
|
|
<uni-nav-bar
|
|
left-icon="back"
|
|
@clickLeft="uni.$u.route({type:'back'})"
|
|
statusBar
|
|
backgroundColor="#ffffff"
|
|
title="选择背景图">
|
|
</uni-nav-bar>
|
|
<uni-list>
|
|
<uni-list-item disabled="true" title="选择内置背景图" @click="linkToBuiltinBgImg" clickable showArrow></uni-list-item>
|
|
<uni-list-item title="通过手机选择" @click="chooseImg" clickable showArrow></uni-list-item>
|
|
</uni-list>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {upload} from "@/api/login"
|
|
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 _this=this;
|
|
let obj = {
|
|
filePath:filePath,
|
|
'url':"/friendcircle/upload_bg",
|
|
savePath: "circle" //文件存放目录
|
|
}
|
|
console.log("通过手机选择",obj);
|
|
upload(filePath,obj).then((res1) => {
|
|
_this.$store.commit('circle/SET_SETTINGS',{
|
|
..._this.$store.storeCircleSettings,
|
|
bg:res1.data.url
|
|
});
|
|
uni.navigateBack();
|
|
}).catch((res1) => {
|
|
console.log("上传失败",res1);
|
|
});
|
|
},
|
|
|
|
linkToBuiltinBgImg() {
|
|
this.$u.route('/pages/tabbar/find/friend-circle/builtinBgImg');
|
|
},
|
|
},
|
|
|
|
};
|
|
</script>
|
|
|
|
<style></style>
|