index.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <!-- 公告编辑 -->
  3. <div class="showGoodsIdx">
  4. <s-header :name="$t('announcement.header')" :noback="false"></s-header>
  5. <van-cell-group inset>
  6. <van-field v-model="title" label="标题" placeholder="请输入标题" />
  7. </van-cell-group>
  8. <div style="width: 100%">
  9. <TinymceEditor v-model="content" @input="inputContent" />
  10. </div>
  11. <div class="o-mt-50" style="display: flex; justify-content: center; align-items: center;">
  12. <van-button class="btn" round type="primary" @click="sumbitNotice">提交</van-button>
  13. </div>
  14. </div>
  15. </template>
  16. <script setup>
  17. import { ref } from "vue";
  18. import sHeader from "@/components/SimpleHeader";
  19. import TinymceEditor from "../../components/TinymceEditor/index";
  20. import { addNotice } from "@/service/user";
  21. import { useI18n } from "vue-i18n";
  22. import { useRouter } from "vue-router";
  23. import { showFailToast, showSuccessToast } from "vant";
  24. const { t } = useI18n();
  25. const router = useRouter();
  26. const title = ref("");
  27. const content = ref("");
  28. const inputContent = (newVal) => {
  29. // console.log(newVal)
  30. content.value = newVal;
  31. }
  32. const sumbitNotice = async () => {
  33. let params = {
  34. title: title.value,
  35. content: content.value
  36. };
  37. const { data } = await addNotice(params)
  38. if (data.code == "00000") {
  39. // console.log(data);
  40. showSuccessToast(t('announcement.successfully'));
  41. setTimeout(() => {
  42. router.push("/home");
  43. }, 1500);
  44. } else {
  45. showFailToast(`${t('announcement.failed')} ${data.message}`);
  46. }
  47. }
  48. </script>
  49. <style lang="less" scoped>
  50. @import "../../common/style/common.less";
  51. .btn {
  52. position: relative;
  53. width: 200px;
  54. }
  55. </style>