wangzhibo
4 天以前 10595d8632f959d0954d1939243196f4eed02372
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>
    <cl-page>
        <view class="page">
            <view class="form">
                <cl-form label-position="top">
                    <cl-form-item label="昵称">
                        <cl-input
                            v-model="form.nickName"
                            type="nickname"
                            :border="false"
                            :height="80"
                            :border-radius="12"
                            placeholder="请填写昵称"
                        />
                    </cl-form-item>
                </cl-form>
            </view>
 
            <cl-footer>
                <cl-button custom type="primary" :loading="loading" @tap="save"> 保存 </cl-button>
            </cl-footer>
        </view>
    </cl-page>
</template>
 
<script lang="ts" setup>
import { reactive, ref } from "vue";
import { useCool, useStore } from "/@/cool";
import { useUi } from "/$/cool-ui";
import { onReady } from "@dcloudio/uni-app";
 
const { router } = useCool();
const { user } = useStore();
const ui = useUi();
 
const loading = ref(false);
 
const form = reactive({
    nickName: "",
});
 
async function save() {
    loading.value = true;
 
    await user.update(form).catch((err) => {
        ui.showToast(err.message);
    });
 
    loading.value = false;
 
    ui.showTips("用户信息保存成功", () => {
        router.back();
    });
}
 
onReady(() => {
    form.nickName = user.info?.nickName || "";
});
</script>
 
<style lang="scss" scoped>
.page {
    .form {
        padding: 20rpx 24rpx;
    }
}
</style>