This commit is contained in:
cansnow
2025-11-27 07:40:32 +08:00
parent 198c3dd4a5
commit ab625e6463
17 changed files with 1092 additions and 1135 deletions
@@ -0,0 +1,71 @@
<template>
<view class="content">
<u-navbar title="选择背景图" :background="{ background: '#ffffff'}"
:border-bottom="false">
<view class="slot-wrap" slot="right">
<u-button :custom-style="customBtnStyle" size="mini" :disabled="submitFlag"
:type="submitFlag?'info ':'success'" @click="handleLink()">设置</u-button>
</view>
</u-navbar>
<u-grid @click="clickGrid">
<u-grid-item v-for="(item, index) in bgList" :key="index" :index="index" :custom-style="item.isCheck?girdItemCustomStyle:{}">
<u-image :src="item.src" width="200rpx" height="200rpx" mode="aspectFill"></u-image>
</u-grid-item>
</u-grid>
</view>
</template>
<script>
export default {
data() {
return {
bgList:[],
customBtnStyle: {
fontSize: '30rpx',
padding: '28rpx',
width:'100rpx'
},
submitFlag:true,
girdItemCustomStyle:{
backgroundColor:'#71d5a1',
// maring:'0rpx',
padding:'20rpx'
}
};
},
methods: {
clickGrid(index){
this.bgList.forEach((item,i)=>{
if(index == i) item.isCheck = !item.isCheck;
else item.isCheck = false;
})
this.submitFlag=false;
},
//处理跳转逻辑
handleLink(){
const item = this.bgList.find(it=>it.isCheck);
if(item){
this.$u.vuex('circleBgImg', item.src);
uni.navigateBack({
delta:2
})
}
},
},
onShow() {
this.bgList = JSON.parse(JSON.stringify(this.circleBgList))
}
};
</script>
<style lang="scss" scoped>
.content {
.slot-wrap {
display: flex;
align-items: center;
padding: 0 30rpx;
}
}
</style>
@@ -0,0 +1,80 @@
<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>
@@ -0,0 +1,24 @@
<template>
<view class="locationContainer">
<view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
};
}
}
</script>
<style lang="scss" scoped>
.locationContainer{
padding: 20rpx;
}
</style>