2 lines
8.6 KiB
JavaScript
2 lines
8.6 KiB
JavaScript
"use strict";var l=(l,e,a)=>new Promise(((u,v)=>{var b=l=>{try{t(a.next(l))}catch(e){v(e)}},o=l=>{try{t(a.throw(l))}catch(e){v(e)}},t=l=>l.done?u(l.value):Promise.resolve(l.value).then(b,o);t((a=a.apply(l,e)).next())}));const e=require("../../common/vendor.js");require("../../store/index.js");const a=require("../../utils/commUtils.js"),u=require("../../utils/http.js"),v=require("../../store/user.js");if(!Array){(e.resolveComponent("wd-img")+e.resolveComponent("wd-icon")+e.resolveComponent("wd-picker")+e.resolveComponent("layout-default-uni"))()}Math||((()=>"../../node-modules/wot-design-uni/components/wd-img/wd-img.js")+(()=>"../../node-modules/wot-design-uni/components/wd-icon/wd-icon.js")+(()=>"../../node-modules/wot-design-uni/components/wd-picker/wd-picker.js"))();const b={__name:"pet-add-page",setup(b){const o=e.ref(""),t=e.ref(""),n=e.ref(""),s=e.ref(""),i=e.ref(""),r=e.ref("https://via.placeholder.com/150"),d=e.ref(""),c=e.ref(null),p=l=>{r.value="https://via.placeholder.com/150"},m=v.useUserStore(),h=e.ref([{value:"其他",label:"其他"},{value:"阿比西尼亚猫",label:"阿比西尼亚猫"},{value:"安哥拉猫",label:"安哥拉猫"},{value:"埃及猫",label:"埃及猫"},{value:"奥西猫",label:"奥西猫"},{value:"巴厘猫",label:"巴厘猫"},{value:"波米拉猫",label:"波米拉猫"},{value:"伯曼猫",label:"伯曼猫"},{value:"布偶猫",label:"布偶猫"},{value:"波斯猫",label:"波斯猫"}]),f=e.ref([{value:"黑白色",label:"黑白色"},{value:"白色",label:"白色"},{value:"黑色",label:"黑色"},{value:"橘色",label:"橘色"},{value:"蓝色",label:"蓝色"},{value:"蓝白色",label:"蓝白色"},{value:"橘白色",label:"橘白色"},{value:"灰色",label:"灰色"},{value:"灰白色",label:"灰白色"},{value:"乳色",label:"乳色"},{value:"乳白色",label:"乳白色"},{value:"棕色",label:"棕色"},{value:"棕白色",label:"棕白色"},{value:"银色",label:"银色"},{value:"银白色",label:"银白色"},{value:"雪色",label:"雪色"},{value:"木炭色",label:"木炭色"},{value:"金渐层",label:"金渐层"},{value:"蓝金渐层",label:"蓝金渐层"},{value:"银渐层",label:"银渐层"},{value:"金点",label:"金点"},{value:"银点",label:"银点"},{value:"重点色",label:"重点色"},{value:"手套色",label:"手套色"},{value:"海豹色",label:"海豹色"},{value:"火焰色",label:"火焰色"},{value:"蓝双色",label:"蓝双色"},{value:"海豹双色",label:"海豹双色"},{value:"梵色",label:"梵色"},{value:"玳瑁色",label:"玳瑁色"},{value:"三花色",label:"三花色"},{value:"烟灰色",label:"烟灰色"},{value:"虎斑纹",label:"虎斑纹"},{value:"棕虎斑",label:"棕虎斑"},{value:"银虎斑",label:"银虎斑"},{value:"红虎斑",label:"红虎斑"},{value:"山猫纹",label:"山猫纹"},{value:"玫瑰纹",label:"玫瑰纹"},{value:"大理石纹",label:"大理石纹"},{value:"其他",label:"其他"},{value:"褐色",label:"褐色"},{value:"红色",label:"红色"},{value:"小鹿色",label:"小鹿色"},{value:"纯色",label:"纯色"},{value:"渐层色",label:"渐层色"},{value:"烟色",label:"烟色"},{value:"补丁",label:"补丁"},{value:"蓝虎斑",label:"蓝虎斑"},{value:"凯米尔虎斑",label:"凯米尔虎斑"},{value:"虎斑加白",label:"虎斑加白"},{value:"渐层加白",label:"渐层加白"},{value:"烟色加白",label:"烟色加白"},{value:"双色",label:"双色"},{value:"杂色",label:"杂色"},{value:"金吉拉银色",label:"金吉拉银色"},{value:"金吉拉金色",label:"金吉拉金色"},{value:"重点色加白",label:"重点色加白"},{value:"渐层重点色",label:"渐层重点色"},{value:"貂色",label:"貂色"},{value:"香槟色",label:"香槟色"},{value:"铂色",label:"铂色"},{value:"海豹山猫双色",label:"海豹山猫双色"},{value:"蓝山猫双色",label:"蓝山猫双色"},{value:"其他双色",label:"其他双色"},{value:"重点双色",label:"重点双色"},{value:"巧克力重点色",label:"巧克力重点色"},{value:"海豹重点色",label:"海豹重点色"},{value:"蓝重点色",label:"蓝重点色"},{value:"丁香重点色",label:"丁香重点色"},{value:"金色",label:"金色"},{value:"浅三花色",label:"浅三花色"},{value:"鱼骨纹色",label:"鱼骨纹色"},{value:"混合色",label:"混合色"},{value:"橙褐色",label:"橙褐色"},{value:"柏色",label:"柏色"},{value:"布伦海姆色",label:"布伦海姆色"},{value:"纯红色",label:"纯红色"},{value:"橙色",label:"橙色"},{value:"紫色",label:"紫色"},{value:"淡灰色",label:"淡灰色"},{value:"黄色",label:"黄色"},{value:"浅红色",label:"浅红色"},{value:"野猪色",label:"野猪色"},{value:"巧克力色",label:"巧克力色"},{value:"黑铁灰色",label:"黑铁灰色"},{value:"盐与胡椒色",label:"盐与胡椒色"},{value:"红褐色",label:"红褐色"},{value:"黑褐色",label:"黑褐色"},{value:"花斑色",label:"花斑色"},{value:"马斑色",label:"马斑色"},{value:"灰褐色",label:"灰褐色"},{value:"银灰色",label:"银灰色"},{value:"椒盐色",label:"椒盐色"},{value:"金黄色",label:"金黄色"},{value:"桃红色",label:"桃红色"},{value:"火烈鸟红色",label:"火烈鸟红色"},{value:"麦色",label:"麦色"},{value:"浅黄褐色",label:"浅黄褐色"},{value:"浅黄色",label:"浅黄色"},{value:"浅米色",label:"浅米色"},{value:"灰黄色",label:"灰黄色"},{value:"黄褐色",label:"黄褐色"},{value:"杏色",label:"杏色"},{value:"沙色",label:"沙色"},{value:"沙褐色",label:"沙褐色"},{value:"蓝灰色",label:"蓝灰色"},{value:"浅麦色",label:"浅麦色"},{value:"黑银色",label:"黑银色"},{value:"棕褐色",label:"棕褐色"},{value:"淡棕色",label:"淡棕色"},{value:"赤褐色",label:"赤褐色"},{value:"浅棕色",label:"浅棕色"},{value:"浅巧克力色",label:"浅巧克力色"},{value:"深棕色",label:"深棕色"},{value:"灰白色",label:"灰白色"},{value:"柠檬色",label:"柠檬色"},{value:"浅褐色",label:"浅褐色"},{value:"深红褐色",label:"深红褐色"},{value:"斑点色",label:"斑点色"},{value:"虎斑色",label:"虎斑色"},{value:"淡黄色",label:"淡黄色"},{value:"粉红色",label:"粉红色"},{value:"深灰色",label:"深灰色"},{value:"黑棕色",label:"黑棕色"},{value:"铁锈色",label:"铁锈色"},{value:"棕红色",label:"棕红色"},{value:"深红色",label:"深红色"},{value:"深褐色",label:"深褐色"},{value:"奶油色",label:"奶油色"},{value:"鹿皮色",label:"鹿皮色"},{value:"橙黄色",label:"橙黄色"}]);e.onLoad((e=>l(this,null,(function*(){e&&e.id&&(c.value=e.id,yield w(c.value))}))));const w=v=>l(this,null,(function*(){const l=yield u.httpGet(`/petInfo/find_by_id/${v}`);if(200===l.code){const e=l.data;o.value=e.name||"",t.value=e.age||"",n.value=1===e.sex?"男孩":"女孩",s.value=e.breed||"",i.value=e.hairColor||"",r.value=a.baseUrl+e.profileUrl||"https://via.placeholder.com/150",d.value=e.userId||"-1"}else e.index.showToast({title:"获取宠物信息失败",icon:""})})),g=()=>{e.index.chooseImage({count:1,success:l=>{r.value=l.tempFilePaths[0]}})},x=l=>{t.value=l.detail.value},y=()=>{const l={id:c.value||void 0,name:o.value,age:t.value+" 00:00:00",sex:"男孩"===n.value?1:0,breed:s.value,hairColor:i.value};c.value&&(l.userId=d.value);const a=c.value?"/petInfo/update":"/petInfo/addPet";r.value.startsWith("http"),e.index.uploadFile({url:a,filePath:r.value,name:"file",formData:l,header:{satoken:`Bearer ${m.token}`},success:l=>{const a=JSON.parse(l.data);200===a.code?(e.index.showToast({title:c.value?"更新成功":"创建成功",icon:"success"}),k(),e.index.navigateBack()):e.index.showToast({title:a.message,icon:"none"})},fail:l=>{e.index.showToast({title:"上传失败",icon:"none"})}})},j=()=>{e.index.showModal({title:"确认删除",content:"你确定要删除这个宠物档案吗?",success:l=>{l.confirm&&u.httpPost("/petInfo/delete",{id:c.value}).then((()=>{e.index.showToast({title:"删除成功",icon:"success"}),e.index.navigateBack()}))}})},k=()=>{o.value="",t.value="",n.value="",s.value="",i.value="",r.value="https://via.placeholder.com/150"};return(l,a)=>e.e({a:e.o(p),b:e.p({round:!0,src:r.value,mode:"aspectFill"}),c:e.o(g),d:e.p({name:"add",color:"#ffc107"}),e:o.value,f:e.o((l=>o.value=l.detail.value)),g:e.t(t.value||"请选择生日"),h:t.value,i:e.o(x),j:e.n("男孩"===n.value?"bg-blue-500 text-white":"bg-gray-200"),k:e.o((l=>n.value="男孩")),l:e.n("女孩"===n.value?"bg-pink-500 text-white":"bg-gray-200"),m:e.o((l=>n.value="女孩")),n:e.o((l=>s.value=l)),o:e.p({columns:h.value,modelValue:s.value}),p:e.o((l=>i.value=l)),q:e.p({columns:f.value,modelValue:i.value}),r:e.t(c.value?"更新电子身份证":"创建电子身份证"),s:e.o(y),t:c.value},c.value?{v:e.o(j)}:{})}},o=e._export_sfc(b,[["__scopeId","data-v-e6a92610"]]);wx.createPage(o);
|