edit-description.uvue 999 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <cl-page>
  3. <cl-topbar safe-area-top :title="t('编辑简介')" background-color="transparent"> </cl-topbar>
  4. <view class="p-3">
  5. <cl-textarea
  6. v-model="content"
  7. :placeholder="t('介绍一下自己')"
  8. :border="false"
  9. :height="200"
  10. >
  11. </cl-textarea>
  12. </view>
  13. <cl-footer>
  14. <cl-button size="large" :disabled="content == ''" @tap="confirm">{{
  15. t("确认")
  16. }}</cl-button>
  17. </cl-footer>
  18. </cl-page>
  19. </template>
  20. <script setup lang="ts">
  21. import { router, useStore } from "@/cool";
  22. import { t } from "@/locale";
  23. import { useUi } from "@/uni_modules/cool-ui";
  24. import { ref } from "vue";
  25. const ui = useUi();
  26. const { user } = useStore();
  27. // 输入框内容
  28. const content = ref("");
  29. async function confirm() {
  30. if (content.value == "") {
  31. return ui.showToast({
  32. message: t("简介不能为空")
  33. });
  34. }
  35. await user.update({
  36. description: content.value
  37. });
  38. router.back();
  39. }
  40. onReady(() => {
  41. content.value = user.info.description ?? "";
  42. });
  43. </script>