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

2 lines
1.9 KiB
JavaScript

"use strict";var e=(e,t,o)=>new Promise(((a,l)=>{var n=e=>{try{u(o.next(e))}catch(t){l(t)}},s=e=>{try{u(o.throw(e))}catch(t){l(t)}},u=e=>e.done?a(e.value):Promise.resolve(e.value).then(n,s);u((o=o.apply(e,t)).next())}));const t=require("../../common/vendor.js"),o=require("../../utils/http.js"),a=require("../../store/user.js");if(!Array){(t.resolveComponent("wd-icon")+t.resolveComponent("layout-default-uni"))()}Math;const l={__name:"share",setup(l){const n=t.ref([]),s=t.ref(""),u=t.ref(""),i=t.ref(""),r=t.ref(!0),c=t.ref(["#搞笑日常","#快乐无限供应","#生活随拍","#日常碎片"]);a.useUserStore();const v=()=>{t.index.navigateBack()},d=()=>{t.index.chooseImage({count:1,success:e=>{n.value.push({url:e.tempFilePaths[0]})}})},h=e=>{r.value=e.detail.value},f=a=>e(this,null,(function*(){try{const e=yield o.httpUploadFile("/file/upload",a);if(200===e.code)return e.data.url;throw new Error("图片上传失败")}catch(e){throw t.index.showToast({title:"图片上传失败,请稍后重试",icon:"none"}),e}})),p=()=>e(this,null,(function*(){if(s.value&&u.value)try{const e=[];for(const t of n.value){const o=yield f(t.url);e.push(o)}const a={title:s.value,content:u.value,location:i.value,isPublic:r.value,images:e},l=yield o.httpPost("/posts/create",a);200===l.code?(t.index.showToast({title:"发布成功",icon:"success"}),v()):t.index.showToast({title:l.message||"发布失败,请稍后再试",icon:"none"})}catch(e){t.index.showToast({title:"发布失败,请检查网络",icon:"none"})}else t.index.showToast({icon:"none",title:"请填写标题和内容"})}));return(e,o)=>({a:t.o(v),b:t.f(n.value,((e,t,o)=>({a:e.url,b:t}))),c:t.p({name:"add",size:"22px",color:"#888"}),d:t.o(d),e:s.value,f:t.o((e=>s.value=e.detail.value)),g:u.value,h:t.o((e=>u.value=e.detail.value)),i:t.f(c.value,((e,o,a)=>({a:t.t(e),b:o}))),j:i.value,k:t.o((e=>i.value=e.detail.value)),l:r.value,m:t.o(h),n:t.o(p)})}},n=t._export_sfc(l,[["__scopeId","data-v-e70858dc"]]);wx.createPage(n);