2 lines
4.7 KiB
JavaScript
2 lines
4.7 KiB
JavaScript
import{Y as e,Z as t,_ as a,s,a0 as i,o,c as r,w as l,a as n,v as u,i as d,d as c,n as m,b as f,j as p,k as h}from"./index.953fb5a2.js";import{r as g,_ as I}from"./watermark.5346bec0.js";import{_ as y}from"./plugin-vue_export-helper.21dcd24c.js";import{_ as v}from"./tool-list-wx.55d0c6db.js";import"./uni-badge.d91cbc89.js";import"./uni-icons.9a92e175.js";var k=y({name:"zmm-upload-avatar",emits:["update:modelValue","change"],props:{modelValue:{type:[String]},imgSize:{type:Number,default:120},imgRadius:{type:Number,default:12},disabled:{type:Boolean,default:!1},action:{type:String,default:e.baseUrl+"/file/upload"},formData:{type:Object},header:{type:Object,default:()=>({Authorization:t("Authorization"),device:t("device"),version:t("version")})},fileKey:{type:String,default:"file"}},data:()=>({isDestroyed:!1,showUploadProgress:!0}),mounted:function(){},destroyed:function(){this.isDestroyed=!0},computed:{},methods:{selectImage:function(){var e=this;a({count:1,sourceType:["album","camera"],success:function(t){var a=t.tempFilePaths;if(e.action){s({title:"上传中",icon:"none",mask:!1});var o=1-a.length,r=[],l=e.fileKey?e.fileKey:"upload-images";for(let t=0;t<a.length;t++)r.push(new Promise(((r,n)=>{let u=o+t;i({url:e.action,fileType:"image",header:e.header,formData:e.formData,filePath:a[t],name:l,success:function(t){if(200===t.statusCode){if(e.isDestroyed)return;e.showUploadProgress&&s({title:"上传中",icon:"none",mask:!1,duration:500}),r(t.data)}else console.log("fail to upload image:"+t.data),n("fail to upload image:"+u)},fail:function(e){s({title:"上传失败请检查网络",icon:"none"}),console.log("fail to upload image:"+e),n("fail to upload image:"+u)}})})));Promise.all(r).then((t=>{if(!e.isDestroyed)for(let s=0;s<t.length;s++){var a=JSON.parse(t[s]);e.$emit("update:modelValue",a.data.fullPath),e.$emit("change",a.data.fullPath)}}))}else e.$emit("update:modelValue","../../static/img/avatar/avatar2.jpg"),e.$emit("change","../../static/img/avatar/avatar2.jpg")}})}}},[["render",function(e,t,a,s,i,m){const f=d,p=c;return o(),r(p,null,{default:l((()=>[n(f,{class:"zmm-upload-avatar",src:a.modelValue,style:u({width:a.imgSize+"rpx",height:a.imgSize+"rpx","border-radius":a.imgRadius+"rpx"}),mode:"aspectFill",onClick:m.selectImage},null,8,["src","style","onClick"])])),_:1})}],["__scopeId","data-v-fc300958"]]);var C=y({data(){return{avatar:this.$store.state.userInfo.portrait,list2:[{title:"二维码名片",path:"#",else:[{type:"img",content:"../../static/wx/t05.png"}]}]}},computed:{userInfo(){return this.$store.state.userInfo},list1(){return[{title:"名字",path:"#",else:[{type:"text",content:this.$store.state.userInfo.nickName}]},{title:"微聊号",path:"#",else:[{type:"text",content:this.$store.state.userInfo.chatNo}]}]},list3(){return[{title:"性别",path:"#",else:[{type:"text",content:this.$store.state.userInfo.genderLabel}]},{title:"地区",path:"#",else:[{type:"text",content:this.$store.state.userInfo.provinces+" "+this.$store.state.userInfo.city}]},{title:"个性签名",path:"#",else:[{type:"text",content:this.$store.state.userInfo.intro}]}]}},onLoad(){},methods:{itemClick(e,t){switch(t){case 0:m({url:"editNikeName?userId="+this.userInfo.userId+"&nickName="+this.userInfo.nickName});break;case 1:m({url:"editchatNo?userId="+this.userInfo.userId+"&chatNo="+this.userInfo.chatNo})}},itemClick2(e,t){if(0===t)m({url:"QRcode"})},itemClick3(e,t){switch(t){case 0:m({url:"editGender?userId="+this.userInfo.userId+"&gender="+this.userInfo.gender});break;case 1:m({url:"editAddress?userId="+this.userInfo.userId+"&provinces="+this.userInfo.provinces+"&city="+this.userInfo.city});break;case 2:m({url:"editIntro?userId="+this.userInfo.userId+"&intro="+this.userInfo.intro})}},avatarChange(e){this.$http.request({url:"/my/editPortrait",method:"POST",data:JSON.stringify({portrait:e}),success:e=>{200==e.data.code&&(s({title:"修改成功",icon:"none"}),this.$store.dispatch("get_UserInfo"))}})}}},[["render",function(e,t,a,s,i,u){const d=g(p("watermark"),I),m=h,y=g(p("zmm-upload-avatar"),k),C=c,b=g(p("tool-list-wx"),v);return o(),r(C,{class:"bgColor"},{default:l((()=>[n(d),n(C,{class:"xw-tool-list"},{default:l((()=>[n(C,{class:"xw-tool-list-content"},{default:l((()=>[n(C,{class:"xw-tool-item"},{default:l((()=>[n(m,{class:"xw-tool-text"},{default:l((()=>[f("头像")])),_:1}),n(y,{modelValue:i.avatar,"onUpdate:modelValue":t[0]||(t[0]=e=>i.avatar=e),onChange:u.avatarChange},null,8,["modelValue","onChange"])])),_:1})])),_:1})])),_:1}),n(b,{list:u.list1,onItemClick:u.itemClick},null,8,["list","onItemClick"]),n(b,{list:i.list2,onItemClick:u.itemClick2},null,8,["list","onItemClick"]),n(b,{list:u.list3,onItemClick:u.itemClick3},null,8,["list","onItemClick"])])),_:1})}],["__scopeId","data-v-2f1f025d"]]);export{C as default};
|