acdr-ui/dist/dev/mp-weixin/pages/push/share.js.map

1 line
7.4 KiB
Plaintext

{"version":3,"file":"share.js","sources":["../../../../../src/pages/push/share.vue","../../../../../uniPage:/cGFnZXMvcHVzaC9zaGFyZS52dWU"],"sourcesContent":["<route lang=\"json5\">\r\n{\r\n style: {\r\n navigationBarTitleText: '发布页面',\r\n },\r\n}\r\n</route>\r\n\r\n<template>\r\n <view class=\"flex flex-col h-full p-5 bg-[#f8f8f8]\">\r\n <!-- 顶部导航栏 -->\r\n <view class=\"flex items-center py-2\">\r\n <icon type=\"back\" size=\"20\" @click=\"goBack\"></icon>\r\n <view class=\"ml-3 text-lg font-bold\">发布笔记</view>\r\n </view>\r\n\r\n <!-- 图片上传区域 -->\r\n <view class=\"flex flex-nowrap overflow-x-scroll mt-4\">\r\n <view\r\n class=\"w-25 h-25 bg-white border border-[#eaeaea] flex items-center justify-center mr-2\"\r\n v-for=\"(image, index) in images\"\r\n :key=\"index\"\r\n >\r\n <image :src=\"image.url\" mode=\"aspectFill\" class=\"w-full h-full\"></image>\r\n </view>\r\n <view\r\n class=\"w-25 h-25 bg-white border-dashed border-[#eaeaea] flex items-center justify-center mr-2 cursor-pointer\"\r\n @click=\"chooseImage\"\r\n >\r\n <wd-icon name=\"add\" size=\"22px\" color=\"#888\"></wd-icon>\r\n </view>\r\n </view>\r\n\r\n <!-- 文本输入区域 -->\r\n <view class=\"mt-5\">\r\n <input\r\n type=\"text\"\r\n placeholder=\"填写标题会有更多赞哦~\"\r\n class=\"w-full h-10 mt-2 p-2 border border-[#eaeaea] rounded-md\"\r\n v-model=\"title\"\r\n />\r\n <textarea\r\n placeholder=\"添加正文\"\r\n class=\"w-full h-25 mt-2 p-2 border border-[#eaeaea] rounded-md\"\r\n v-model=\"content\"\r\n ></textarea>\r\n </view>\r\n\r\n <!-- 标签区域 -->\r\n <view class=\"flex flex-wrap mt-5\">\r\n <view\r\n class=\"bg-[#f0f0f0] rounded-full px-3 py-1 m-1 text-sm\"\r\n v-for=\"(tag, index) in tags\"\r\n :key=\"index\"\r\n >\r\n {{ tag }}\r\n </view>\r\n </view>\r\n\r\n <!-- 添加地点和公开可见选项 -->\r\n <view class=\"mt-5\">\r\n <view class=\"flex justify-between items-center py-2 border-b border-[#eaeaea]\">\r\n <text>添加地点</text>\r\n <input\r\n type=\"text\"\r\n placeholder=\"请输入地点\"\r\n class=\"text-sm text-[#888]\"\r\n v-model=\"location\"\r\n />\r\n </view>\r\n <view class=\"flex justify-between items-center py-2 border-b border-[#eaeaea]\">\r\n <text>公开可见</text>\r\n <switch :checked=\"isPublic\" @change=\"togglePublic\"></switch>\r\n </view>\r\n </view>\r\n\r\n <!-- 底部操作栏 -->\r\n <view class=\"flex justify-center mt-5\">\r\n <button\r\n class=\"w-full font-bold bg-[#FCD038] text-white rounded-md py-2 text-lg\"\r\n @click=\"postNote\"\r\n >\r\n 发布笔记\r\n </button>\r\n </view>\r\n </view>\r\n</template>\r\n\r\n<script lang=\"js\" setup>\r\nimport { ref } from 'vue'\r\nimport { httpPost, httpUploadFile } from '@/utils/http'\r\nimport { useUserStore } from '@/store/user'\r\n\r\nconst images = ref([])\r\nconst title = ref('')\r\nconst content = ref('')\r\nconst location = ref('')\r\nconst isPublic = ref(true) // 公开可见的状态\r\nconst tags = ref(['#搞笑日常', '#快乐无限供应', '#生活随拍', '#日常碎片'])\r\n\r\nconst userStore = useUserStore()\r\n\r\n// 返回上一页\r\nconst goBack = () => {\r\n uni.navigateBack()\r\n}\r\n\r\n// 选择图片\r\nconst chooseImage = () => {\r\n uni.chooseImage({\r\n count: 1,\r\n success: (res) => {\r\n images.value.push({ url: res.tempFilePaths[0] })\r\n },\r\n })\r\n}\r\n\r\n// 切换公开状态\r\nconst togglePublic = (event) => {\r\n isPublic.value = event.detail.value\r\n}\r\n\r\n// 上传图片文件并获取URL\r\nconst uploadImage = async (filePath) => {\r\n try {\r\n const response = await httpUploadFile('/file/upload', filePath)\r\n if (response.code === 200) {\r\n return response.data.url\r\n } else {\r\n throw new Error('图片上传失败')\r\n }\r\n } catch (error) {\r\n uni.showToast({\r\n title: '图片上传失败,请稍后重试',\r\n icon: 'none',\r\n })\r\n throw error\r\n }\r\n}\r\n\r\n// 发布笔记\r\nconst postNote = async () => {\r\n if (!title.value || !content.value) {\r\n uni.showToast({\r\n icon: 'none',\r\n title: '请填写标题和内容',\r\n })\r\n return\r\n }\r\n\r\n try {\r\n // 1. 上传每张图片并获取其URL\r\n const uploadedImages = []\r\n for (const image of images.value) {\r\n const imageUrl = await uploadImage(image.url)\r\n uploadedImages.push(imageUrl)\r\n }\r\n\r\n // 2. 组织帖子数据并创建帖子\r\n const postData = {\r\n title: title.value,\r\n content: content.value,\r\n location: location.value,\r\n isPublic: isPublic.value,\r\n images: uploadedImages,\r\n }\r\n\r\n // 发送发布帖子请求\r\n const postResponse = await httpPost('/posts/create', postData)\r\n if (postResponse.code === 200) {\r\n uni.showToast({\r\n title: '发布成功',\r\n icon: 'success',\r\n })\r\n goBack()\r\n } else {\r\n uni.showToast({\r\n title: postResponse.message || '发布失败,请稍后再试',\r\n icon: 'none',\r\n })\r\n }\r\n } catch (error) {\r\n uni.showToast({\r\n title: '发布失败,请检查网络',\r\n icon: 'none',\r\n })\r\n }\r\n}\r\n</script>\r\n\r\n<style scoped>\r\n.border-dashed {\r\n border-style: dashed !important;\r\n}\r\n</style>\r\n","import MiniProgramPage from 'D:/App/Work/addr/acdr-ui/src/pages/push/share.vue'\nwx.createPage(MiniProgramPage)"],"names":["ref","useUserStore","uni","httpUploadFile","httpPost"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMQ,UAAA,SAAAA,cAAA,IAAA,EAAA;AAAA,UAAA,QAAAA,cAAA,IAAA,EAAA;AAAA,UAAA,UAAAA,cAAA,IAAA,EAAA;AAAA,UAAA,WAAAA,cAAA,IAAA,EAAA;AAAA,UAAA,WAAAA,cAAA,IAAA,IAAA;AAAA,UAAA,OAAAA,cAAA,IAAA,CAAA,SAA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