头像优化

This commit is contained in:
仲么了
2023-09-18 16:21:24 +08:00
parent 5f6a924233
commit 5c8b716ef1

View File

@@ -1,14 +1,25 @@
<template> <template>
<Cn-page :loading='loading'> <Cn-page :loading="loading">
<view slot='body' class='index'> <view slot="body" class="index">
<uni-list> <uni-list>
<uni-list-item :title="renderData.masterUser.name" :note="renderData.masterUser.phone" <uni-list-item
:thumb="renderData.masterUser.avatar" thumb-size="lg" rightText="主用户"> :title="renderData.masterUser.name"
:note="renderData.masterUser.phone"
:thumb="renderData.masterUser.avatar"
thumb-size="lg"
rightText="主用户"
>
</uni-list-item> </uni-list-item>
<uni-list-item :title="item.name" :note="item.phone" :thumb="item.avatar" thumb-size="lg" <uni-list-item
v-for="item in renderData.subUsers" :key="item.id"> :title="item.name"
:note="item.phone"
:thumb="item.avatar"
thumb-size="lg"
v-for="item in renderData.subUsers"
:key="item.id"
>
<template v-slot:footer v-if="options.isPrimaryUser"> <template v-slot:footer v-if="options.isPrimaryUser">
<view class="footer-btn mt20" style="background:#e47470" @click="del(item)">移除</view> <view class="footer-btn mt20" style="background: #e47470" @click="del(item)">移除</view>
</template> </template>
</uni-list-item> </uni-list-item>
</uni-list> </uni-list>
@@ -17,68 +28,70 @@
</Cn-page> </Cn-page>
</template> </template>
<script> <script>
import {queryDeviceUser, cancelShare} from '@/common/api/device' import { queryDeviceUser, cancelShare } from '@/common/api/device'
export default { export default {
data() { data() {
return { return {
loading: true, loading: true,
renderData: { renderData: {
masterUser:{}, masterUser: {},
subUsers:[] subUsers: [],
}, },
options: {} options: {},
} }
}, },
methods: { methods: {
jump() { jump() {
uni.navigateTo({ uni.navigateTo({
url: '/pages/mine/userDetail' url: '/pages/mine/userDetail',
}) })
}, },
del(e) { del(e) {
console.log(e); console.log(e)
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '确定要移除该成员吗?', content: '确定要移除该成员吗?',
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
cancelShare({eid: this.renderData.devId, userId: e.id}).then(res => { cancelShare({ eid: this.renderData.devId, userId: e.id }).then((res) => {
console.log(res); console.log(res)
uni.showToast({ uni.showToast({
title: '移除成功', title: '移除成功',
icon: 'none' icon: 'none',
}) })
this.init() this.init()
}) })
console.log('用户点击确定') console.log('用户点击确定')
} else if (res.cancel) { } else if (res.cancel) {
console.log('用户点击取消') console.log('用户点击取消')
} }
} },
}) })
}, },
init() { init() {
queryDeviceUser(this.options.id).then(res => { queryDeviceUser(this.options.id).then((res) => {
console.log(res); console.log(res)
this.renderData = res.data this.renderData = res.data
this.renderData.masterUser.avatar = this.renderData.masterUser.headSculpture ? this.$config.staticUrl + this.renderData.masterUser.headSculpture : '/static/head.png' this.renderData.masterUser.avatar = this.renderData.masterUser.headSculpture
this.renderData.subUsers.forEach(item => { ? this.$config.static + this.renderData.masterUser.headSculpture
item.avatar = item.headSculpture ? this.$config.staticUrl + item.headSculpture : '/static/head.png' : '/static/head.png'
this.renderData.subUsers.forEach((item) => {
item.avatar = item.headSculpture ? this.$config.static + item.headSculpture : '/static/head.png'
}) })
console.log(this.renderData)
this.loading = false this.loading = false
}) })
} },
}, },
onLoad(options) { onLoad(options) {
this.options = options this.options = options
console.log(this.loading) console.log(this.loading)
this.init() this.init()
} },
} }
</script> </script>
<style lang='scss'> <style lang="scss">
.index { .index {
padding: 20rpx; padding: 20rpx;
@@ -93,4 +106,4 @@ export default {
border-radius: 10rpx; border-radius: 10rpx;
} }
} }
</style> </style>