quanyawei
2023-10-31 5fecc9e46d448df3de987504440c4fdd582f858e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<template>
    <view class="">
        <u-modal :show="showUserSculpture" :title="title">
            <view class="slot-content">
                <view class="">
                    <u-avatar :src="avatarUrl" size="60"></u-avatar>
                </view>
            </view>
            <view class="" slot="confirmButton">
                <view class="confirmButton">
                    <button type="primary" open-type="chooseAvatar" @chooseavatar="onChooseAvatar" plain="true"
                        style="border: none;position: relative;">
                        <image :src="avatar" mode="aspectFill"
                            style="width: 150rpx;height: 150rpx;border-radius: 20rpx;" v-if="avatar">
                        </image>
                        <image src="../../static/home/noavatar.jpg" mode="aspectFill"
                            style="width: 150rpx;height: 150rpx;border-radius: 20rpx;" v-else></image>
                        <view class="tips">点击授权头像</view>
                    </button>
                    <button type="primary" open-type="chooseAvatar" @chooseavatar="onChooseAvatar" plain="true"
                        style="border: none;position: relative; width: 200px;">
                        <u-button text="确定" class="buts"></u-button> </button>
                    <button type="primary" plain="true" style="border: none;position: relative; width: 200px;">
                        <u-button text="取消" class="buts"></u-button>
                    </button>
                </view>
            </view>
        </u-modal>
    </view>
</template>
<script>
    export default {
        props: {
            showUserSculpture: {
                type: Boolean,
                default: false
            },
        },
        data() {
            return {
                title: '设置头像',
                avatarUrl: ''
            }
        },
        methods: {
            onChooseAvatar(e) {
                const {
                    avatarUrl
                } = e.detail // 此返回的路径为临时路径,需转换为永久路径保存使用
                this.avatarUrl = avatarUrl
            }
        }
    }
</script>
<style lang="scss" scoped>
    .slot-content {
        display: flex;
        width: 100%;
        align-items: center;
        flex-wrap: wrap;
        justify-content: center;
    }
 
    .confirmButton {
        display: flex;
    }
</style>