2 lines
30 KiB
JavaScript
2 lines
30 KiB
JavaScript
import{aM as e,aN as t,aO as a,U as i,V as n,W as r,A as s,p as l,q as o,h as u,i as c,w as d,j as m,E as h,F as f,G as p,n as y,J as g,K as _,l as v,I as x,S as $,H as b,L as k,M as C,t as w,aP as I,aQ as S,d as D,X as M,c as T,a as O,r as H,m as P,a9 as j,Y as V,aR as F,aS as B,an as z,x as N,aT as A}from"./index-849cf30e.js";import{_ as L}from"./u-avatar.2111318d.js";import{_ as R}from"./u-icon.e3aa4770.js";import{_ as Y}from"./u-loading-icon.d012ecbf.js";import{_ as U}from"./_plugin-vue_export-helper.1b428a4d.js";import{_ as W,a as Z,b as J}from"./u-action-sheet.27d0ae04.js";import{_ as E}from"./u-button.9fa3f2a0.js";import{_ as q}from"./app-link.vue_vue_type_script_setup_true_lang.d62f9cf3.js";import{_ as Q}from"./u-modal.081e9589.js";import{_ as X}from"./u-popup.e01742d2.js";import"./u-line.19eb5c40.js";import"./u-transition.75065529.js";import"./u-safe-bottom.2f6af56c.js";function G(e,t){return["[object Object]","[object File]"].includes(Object.prototype.toString.call(e))?Object.keys(e).reduce(((a,i)=>(t.includes(i)||(a[i]=e[i]),a)),{}):{}}function K(e){return e.tempFiles.map((e=>({...G(e,["path"]),url:e.path,size:e.size,name:e.name,type:e.type})))}function ee({accept:i,multiple:n,capture:r,compressed:s,maxDuration:l,sizeType:o,camera:u,maxCount:c}){return new Promise(((d,m)=>{switch(i){case"image":a({count:n?Math.min(c,9):1,sourceType:r,sizeType:o,success:e=>d(function(e){return e.tempFiles.map((e=>({...G(e,["path"]),type:"image",url:e.path,thumb:e.path,size:e.size,name:e.name})))}(e)),fail:m});break;case"video":t({sourceType:r,compressed:s,maxDuration:l,camera:u,success:e=>d(function(e){return[{...G(e,["tempFilePath","thumbTempFilePath","errMsg"]),type:"video",url:e.tempFilePath,thumb:e.thumbTempFilePath,size:e.size,name:e.name}]}(e)),fail:m});break;case"file":e({count:n?c:1,type:i,success:e=>d(K(e)),fail:m});break;default:e({count:n?c:1,type:"all",success:e=>d(K(e)),fail:m})}}))}const te=U({name:"u-upload",mixins:[n,r,{watch:{accept:{immediate:!0,handler(e){"all"!==e&&"media"!==e||uni.$u.error("只有微信小程序才支持把accept配置为all、media之一")}}}},{props:{accept:{type:String,default:i.upload.accept},capture:{type:[String,Array],default:i.upload.capture},compressed:{type:Boolean,default:i.upload.compressed},camera:{type:String,default:i.upload.camera},maxDuration:{type:Number,default:i.upload.maxDuration},uploadIcon:{type:String,default:i.upload.uploadIcon},uploadIconColor:{type:String,default:i.upload.uploadIconColor},useBeforeRead:{type:Boolean,default:i.upload.useBeforeRead},afterRead:{type:Function,default:null},beforeRead:{type:Function,default:null},previewFullImage:{type:Boolean,default:i.upload.previewFullImage},maxCount:{type:[String,Number],default:i.upload.maxCount},disabled:{type:Boolean,default:i.upload.disabled},imageMode:{type:String,default:i.upload.imageMode},name:{type:String,default:i.upload.name},sizeType:{type:Array,default:i.upload.sizeType},multiple:{type:Boolean,default:i.upload.multiple},deletable:{type:Boolean,default:i.upload.deletable},maxSize:{type:[String,Number],default:i.upload.maxSize},fileList:{type:Array,default:i.upload.fileList},uploadText:{type:String,default:i.upload.uploadText},width:{type:[String,Number],default:i.upload.width},height:{type:[String,Number],default:i.upload.height},previewImage:{type:Boolean,default:i.upload.previewImage}}}],data:()=>({lists:[],isInCount:!0}),watch:{fileList:{handler(){this.formatFileList()},immediate:!0,deep:!0}},emits:["error","beforeRead","oversize","afterRead","delete","clickPreview"],methods:{formatFileList(){const{fileList:e=[],maxCount:t}=this,a=e.map((e=>Object.assign(Object.assign({},e),{isImage:"image"===this.accept||uni.$u.test.image(e.url||e.thumb),isVideo:"video"===this.accept||uni.$u.test.video(e.url||e.thumb),deletable:"boolean"==typeof e.deletable?e.deletable:this.deletable})));this.lists=a,this.isInCount=a.length<t},chooseFile(){const{maxCount:e,multiple:t,lists:a,disabled:i}=this;if(i)return;let n;try{n=uni.$u.test.array(this.capture)?this.capture:this.capture.split(",")}catch(r){n=[]}ee(Object.assign({accept:this.accept,multiple:this.multiple,capture:n,compressed:this.compressed,maxDuration:this.maxDuration,sizeType:this.sizeType,camera:this.camera},{maxCount:e-a.length})).then((e=>{this.onBeforeRead(t?e:e[0])})).catch((e=>{this.$emit("error",e)}))},onBeforeRead(e){const{beforeRead:t,useBeforeRead:a}=this;let i=!0;uni.$u.test.func(t)&&(i=t(e,this.getDetail())),a&&(i=new Promise(((t,a)=>{this.$emit("beforeRead",Object.assign(Object.assign({file:e},this.getDetail()),{callback:e=>{e?t():a()}}))}))),i&&(uni.$u.test.promise(i)?i.then((t=>this.onAfterRead(t||e))):this.onAfterRead(e))},getDetail(e){return{name:this.name,index:null==e?this.fileList.length:e}},onAfterRead(e){const{maxSize:t,afterRead:a}=this;(Array.isArray(e)?e.some((e=>e.size>t)):e.size>t)?this.$emit("oversize",Object.assign({file:e},this.getDetail())):("function"==typeof a&&a(e,this.getDetail()),this.$emit("afterRead",Object.assign({file:e},this.getDetail())))},deleteItem(e){this.$emit("delete",Object.assign(Object.assign({},this.getDetail(e)),{file:this.fileList[e]}))},onPreviewImage(e){e.isImage&&this.previewFullImage&&s({urls:this.lists.filter((e=>"image"===this.accept||uni.$u.test.image(e.url||e.thumb))).map((e=>e.url||e.thumb)),current:e.url||e.thumb,fail(){uni.$u.toast("预览图片失败")}})},onPreviewVideo(e){if(!this.data.previewFullImage)return;const{index:t}=e.currentTarget.dataset,{lists:a}=this.data;wx.previewMedia({sources:a.filter((e=>isVideoFile(e))).map((e=>Object.assign(Object.assign({},e),{type:"video"}))),current:t,fail(){uni.$u.toast("预览视频失败")}})},onClickPreview(e){const{index:t}=e.currentTarget.dataset,a=this.data.lists[t];this.$emit("clickPreview",Object.assign(Object.assign({},a),this.getDetail(t)))}}},[["render",function(e,t,a,i,n,r){const s=k,I=l(o("u-icon"),R),S=C,D=w,M=l(o("u-loading-icon"),Y);return u(),c(D,{class:"u-upload",style:y([e.$u.addStyle(e.customStyle)])},{default:d((()=>[m(D,{class:"u-upload__wrap"},{default:d((()=>[e.previewImage?(u(!0),h(f,{key:0},p(n.lists,((t,a)=>(u(),c(D,{class:"u-upload__wrap__preview",key:a},{default:d((()=>[t.isImage||t.type&&"image"===t.type?(u(),c(s,{key:0,src:t.thumb||t.url,mode:e.imageMode,class:"u-upload__wrap__preview__image",onClick:e=>r.onPreviewImage(t),style:y([{width:e.$u.addUnit(e.width),height:e.$u.addUnit(e.height)}])},null,8,["src","mode","onClick","style"])):(u(),c(D,{key:1,class:"u-upload__wrap__preview__other"},{default:d((()=>[m(I,{color:"#80CBF9",size:"26",name:t.isVideo||t.type&&"video"===t.type?"movie":"folder"},null,8,["name"]),m(S,{class:"u-upload__wrap__preview__other__text"},{default:d((()=>[g(_(t.isVideo||t.type&&"video"===t.type?"视频":"文件"),1)])),_:2},1024)])),_:2},1024)),"uploading"===t.status||"failed"===t.status?(u(),c(D,{key:2,class:"u-upload__status"},{default:d((()=>[m(D,{class:"u-upload__status__icon"},{default:d((()=>["failed"===t.status?(u(),c(I,{key:0,name:"close-circle",color:"#ffffff",size:"25"})):(u(),c(M,{key:1,size:"22",mode:"circle",color:"#ffffff"}))])),_:2},1024),t.message?(u(),c(S,{key:0,class:"u-upload__status__message"},{default:d((()=>[g(_(t.message),1)])),_:2},1024)):v("v-if",!0)])),_:2},1024)):v("v-if",!0),"uploading"!==t.status&&(e.deletable||t.deletable)?(u(),c(D,{key:3,class:"u-upload__deletable",onClick:x((e=>r.deleteItem(a)),["stop"])},{default:d((()=>[m(D,{class:"u-upload__deletable__icon"},{default:d((()=>[m(I,{name:"close",color:"#ffffff",size:"10"})])),_:1})])),_:2},1032,["onClick"])):v("v-if",!0),"success"===t.status?(u(),c(D,{key:4,class:"u-upload__success"},{default:d((()=>[m(D,{class:"u-upload__success__icon"},{default:d((()=>[m(I,{name:"checkmark",color:"#ffffff",size:"12"})])),_:1})])),_:1})):v("v-if",!0)])),_:2},1024)))),128)):v("v-if",!0),n.isInCount?(u(),h(f,{key:1},[e.$slots.default||e.$slots.$default?(u(),c(D,{key:0,onClick:r.chooseFile},{default:d((()=>[$(e.$slots,"default",{},void 0,!0)])),_:3},8,["onClick"])):(u(),c(D,{key:1,class:b(["u-upload__button",[e.disabled&&"u-upload__button--disabled"]]),"hover-class":e.disabled?"":"u-upload__button--hover","hover-stay-time":"150",onClick:r.chooseFile,style:y([{width:e.$u.addUnit(e.width),height:e.$u.addUnit(e.height)}])},{default:d((()=>[m(I,{name:e.uploadIcon,size:"26",color:e.uploadIconColor},null,8,["name","color"]),e.uploadText?(u(),c(S,{key:0,class:"u-upload__button__text"},{default:d((()=>[g(_(e.uploadText),1)])),_:1})):v("v-if",!0)])),_:1},8,["hover-class","onClick","class","style"]))],64)):v("v-if",!0)])),_:3})])),_:3},8,["style"])}],["__scopeId","data-v-1941ac11"]]);const ae=U({name:"u-toolbar",mixins:[n,r,{props:{show:{type:Boolean,default:i.toolbar.show},cancelText:{type:String,default:i.toolbar.cancelText},confirmText:{type:String,default:i.toolbar.confirmText},cancelColor:{type:String,default:i.toolbar.cancelColor},confirmColor:{type:String,default:i.toolbar.confirmColor},title:{type:String,default:i.toolbar.title}}}],methods:{cancel(){this.$emit("cancel")},confirm(){this.$emit("confirm")}}},[["render",function(e,t,a,i,n,r){const s=C,l=w;return e.show?(u(),c(l,{key:0,class:"u-toolbar",onTouchmove:x(e.noop,["stop","prevent"])},{default:d((()=>[m(l,{class:"u-toolbar__cancel__wrapper","hover-class":"u-hover-class"},{default:d((()=>[m(s,{class:"u-toolbar__wrapper__cancel",onClick:r.cancel,style:y({color:e.cancelColor})},{default:d((()=>[g(_(e.cancelText),1)])),_:1},8,["onClick","style"])])),_:1}),e.title?(u(),c(s,{key:0,class:"u-toolbar__title u-line-1"},{default:d((()=>[g(_(e.title),1)])),_:1})):v("v-if",!0),m(l,{class:"u-toolbar__confirm__wrapper","hover-class":"u-hover-class"},{default:d((()=>[m(s,{class:"u-toolbar__wrapper__confirm",onClick:r.confirm,style:y({color:e.confirmColor})},{default:d((()=>[g(_(e.confirmText),1)])),_:1},8,["onClick","style"])])),_:1})])),_:1},8,["onTouchmove"])):v("v-if",!0)}],["__scopeId","data-v-88cf1536"]]);const ie=U({name:"u-picker",mixins:[n,r,{props:{show:{type:Boolean,default:i.picker.show},showToolbar:{type:Boolean,default:i.picker.showToolbar},title:{type:String,default:i.picker.title},columns:{type:Array,default:i.picker.columns},loading:{type:Boolean,default:i.picker.loading},itemHeight:{type:[String,Number],default:i.picker.itemHeight},cancelText:{type:String,default:i.picker.cancelText},confirmText:{type:String,default:i.picker.confirmText},cancelColor:{type:String,default:i.picker.cancelColor},confirmColor:{type:String,default:i.picker.confirmColor},visibleItemCount:{type:[String,Number],default:i.picker.visibleItemCount},keyName:{type:String,default:i.picker.keyName},closeOnClickOverlay:{type:Boolean,default:i.picker.closeOnClickOverlay},defaultIndex:{type:Array,default:i.picker.defaultIndex},immediateChange:{type:Boolean,default:i.picker.immediateChange}}}],data:()=>({lastIndex:[],innerIndex:[],innerColumns:[],columnIndex:0}),watch:{defaultIndex:{immediate:!0,handler(e){this.setIndexs(e,!0)}},columns:{immediate:!0,deep:!0,handler(e){this.setColumns(e)}}},emits:["close","cancel","confirm","change"],methods:{getItemText(e){return uni.$u.test.object(e)?e[this.keyName]:e},closeHandler(){this.closeOnClickOverlay&&this.$emit("close")},cancel(){this.$emit("cancel")},confirm(){this.$emit("confirm",{indexs:this.innerIndex,value:this.innerColumns.map(((e,t)=>e[this.innerIndex[t]])),values:this.innerColumns})},changeHandler(e){const{value:t}=e.detail;let a=0,i=0;for(let r=0;r<t.length;r++){let e=t[r];if(e!==(this.lastIndex[r]||0)){i=r,a=e;break}}this.columnIndex=i;const n=this.innerColumns;this.setLastIndex(t),this.setIndexs(t),this.$emit("change",{picker:this,value:this.innerColumns.map(((e,a)=>e[t[a]])),index:a,indexs:t,values:n,columnIndex:i})},setIndexs(e,t){this.innerIndex=uni.$u.deepClone(e),t&&this.setLastIndex(e)},setLastIndex(e){this.lastIndex=uni.$u.deepClone(e)},setColumnValues(e,t){this.innerColumns.splice(e,1,t);let a=uni.$u.deepClone(this.innerIndex);for(let i=0;i<this.innerColumns.length;i++)i>this.columnIndex&&(a[i]=0);this.setIndexs(a)},getColumnValues(e){return(async()=>{await uni.$u.sleep()})(),this.innerColumns[e]},setColumns(e){this.innerColumns=uni.$u.deepClone(e),0===this.innerIndex.length&&(this.innerIndex=new Array(e.length).fill(0))},getIndexs(){return this.innerIndex},getValues(){return(async()=>{await uni.$u.sleep()})(),this.innerColumns.map(((e,t)=>e[this.innerIndex[t]]))}}},[["render",function(e,t,a,i,n,r){const s=l(o("u-toolbar"),ae),x=C,$=I,b=S,k=l(o("u-loading-icon"),Y),D=w,M=l(o("u-popup"),X);return u(),c(M,{show:e.show,onClose:r.closeHandler},{default:d((()=>[m(D,{class:"u-picker"},{default:d((()=>[e.showToolbar?(u(),c(s,{key:0,cancelColor:e.cancelColor,confirmColor:e.confirmColor,cancelText:e.cancelText,confirmText:e.confirmText,title:e.title,onCancel:r.cancel,onConfirm:r.confirm},null,8,["cancelColor","confirmColor","cancelText","confirmText","title","onCancel","onConfirm"])):v("v-if",!0),m(b,{class:"u-picker__view",indicatorStyle:`height: ${e.$u.addUnit(e.itemHeight)}`,value:n.innerIndex,immediateChange:e.immediateChange,style:y({height:`${e.$u.addUnit(e.visibleItemCount*e.itemHeight)}`}),onChange:r.changeHandler},{default:d((()=>[(u(!0),h(f,null,p(n.innerColumns,((t,a)=>(u(),c($,{key:a,class:"u-picker__view__column"},{default:d((()=>[e.$u.test.array(t)?(u(!0),h(f,{key:0},p(t,((t,i)=>(u(),c(x,{class:"u-picker__view__column__item u-line-1",key:i,style:y({height:e.$u.addUnit(e.itemHeight),lineHeight:e.$u.addUnit(e.itemHeight),fontWeight:i===n.innerIndex[a]?"bold":"normal"})},{default:d((()=>[g(_(r.getItemText(t)),1)])),_:2},1032,["style"])))),128)):v("v-if",!0)])),_:2},1024)))),128))])),_:1},8,["indicatorStyle","value","immediateChange","style","onChange"]),e.loading?(u(),c(D,{key:1,class:"u-picker--loading"},{default:d((()=>[m(k,{mode:"circle"})])),_:1})):v("v-if",!0)])),_:1})])),_:1},8,["show","onClose"])}],["__scopeId","data-v-6971b6c7"]]),ne={props:{show:{type:Boolean,default:i.datetimePicker.show},showToolbar:{type:Boolean,default:i.datetimePicker.showToolbar},modelValue:{type:[String,Number],default:i.datetimePicker.value},title:{type:String,default:i.datetimePicker.title},mode:{type:String,default:i.datetimePicker.mode},maxDate:{type:Number,default:i.datetimePicker.maxDate},minDate:{type:Number,default:i.datetimePicker.minDate},minHour:{type:Number,default:i.datetimePicker.minHour},maxHour:{type:Number,default:i.datetimePicker.maxHour},minMinute:{type:Number,default:i.datetimePicker.minMinute},maxMinute:{type:Number,default:i.datetimePicker.maxMinute},filter:{type:[Function,null],default:i.datetimePicker.filter},formatter:{type:[Function,null],default:i.datetimePicker.formatter},loading:{type:Boolean,default:i.datetimePicker.loading},itemHeight:{type:[String,Number],default:i.datetimePicker.itemHeight},cancelText:{type:String,default:i.datetimePicker.cancelText},confirmText:{type:String,default:i.datetimePicker.confirmText},cancelColor:{type:String,default:i.datetimePicker.cancelColor},confirmColor:{type:String,default:i.datetimePicker.confirmColor},visibleItemCount:{type:[String,Number],default:i.datetimePicker.visibleItemCount},closeOnClickOverlay:{type:Boolean,default:i.datetimePicker.closeOnClickOverlay},defaultIndex:{type:Array,default:i.datetimePicker.defaultIndex}}};var re=1e3,se=6e4,le=36e5,oe="millisecond",ue="second",ce="minute",de="hour",me="day",he="week",fe="month",pe="quarter",ye="year",ge="date",_e="Invalid Date",ve=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,xe=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;const $e={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],a=e%100;return"["+e+(t[(a-20)%10]||t[a]||t[0])+"]"}};var be=function(e,t,a){var i=String(e);return!i||i.length>=t?e:""+Array(t+1-i.length).join(a)+e};const ke={s:be,z:function(e){var t=-e.utcOffset(),a=Math.abs(t),i=Math.floor(a/60),n=a%60;return(t<=0?"+":"-")+be(i,2,"0")+":"+be(n,2,"0")},m:function e(t,a){if(t.date()<a.date())return-e(a,t);var i=12*(a.year()-t.year())+(a.month()-t.month()),n=t.clone().add(i,fe),r=a-n<0,s=t.clone().add(i+(r?-1:1),fe);return+(-(i+(a-n)/(r?n-s:s-n))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:fe,y:ye,w:he,d:me,D:ge,h:de,m:ce,s:ue,ms:oe,Q:pe}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}};var Ce="en",we={};we[Ce]=$e;var Ie=function(e){return e instanceof Te},Se=function e(t,a,i){var n;if(!t)return Ce;if("string"==typeof t){var r=t.toLowerCase();we[r]&&(n=r),a&&(we[r]=a,n=r);var s=t.split("-");if(!n&&s.length>1)return e(s[0])}else{var l=t.name;we[l]=t,n=l}return!i&&n&&(Ce=n),n||!i&&Ce},De=function(e,t){if(Ie(e))return e.clone();var a="object"==typeof t?t:{};return a.date=e,a.args=arguments,new Te(a)},Me=ke;Me.l=Se,Me.i=Ie,Me.w=function(e,t){return De(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var Te=function(){function e(e){this.$L=Se(e.locale,null,!0),this.parse(e)}var t=e.prototype;return t.parse=function(e){this.$d=function(e){var t=e.date,a=e.utc;if(null===t)return new Date(NaN);if(Me.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var i=t.match(ve);if(i){var n=i[2]-1||0,r=(i[7]||"0").substring(0,3);return a?new Date(Date.UTC(i[1],n,i[3]||1,i[4]||0,i[5]||0,i[6]||0,r)):new Date(i[1],n,i[3]||1,i[4]||0,i[5]||0,i[6]||0,r)}}return new Date(t)}(e),this.$x=e.x||{},this.init()},t.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},t.$utils=function(){return Me},t.isValid=function(){return!(this.$d.toString()===_e)},t.isSame=function(e,t){var a=De(e);return this.startOf(t)<=a&&a<=this.endOf(t)},t.isAfter=function(e,t){return De(e)<this.startOf(t)},t.isBefore=function(e,t){return this.endOf(t)<De(e)},t.$g=function(e,t,a){return Me.u(e)?this[t]:this.set(a,e)},t.unix=function(){return Math.floor(this.valueOf()/1e3)},t.valueOf=function(){return this.$d.getTime()},t.startOf=function(e,t){var a=this,i=!!Me.u(t)||t,n=Me.p(e),r=function(e,t){var n=Me.w(a.$u?Date.UTC(a.$y,t,e):new Date(a.$y,t,e),a);return i?n:n.endOf(me)},s=function(e,t){return Me.w(a.toDate()[e].apply(a.toDate("s"),(i?[0,0,0,0]:[23,59,59,999]).slice(t)),a)},l=this.$W,o=this.$M,u=this.$D,c="set"+(this.$u?"UTC":"");switch(n){case ye:return i?r(1,0):r(31,11);case fe:return i?r(1,o):r(0,o+1);case he:var d=this.$locale().weekStart||0,m=(l<d?l+7:l)-d;return r(i?u-m:u+(6-m),o);case me:case ge:return s(c+"Hours",0);case de:return s(c+"Minutes",1);case ce:return s(c+"Seconds",2);case ue:return s(c+"Milliseconds",3);default:return this.clone()}},t.endOf=function(e){return this.startOf(e,!1)},t.$set=function(e,t){var a,i=Me.p(e),n="set"+(this.$u?"UTC":""),r=(a={},a[me]=n+"Date",a[ge]=n+"Date",a[fe]=n+"Month",a[ye]=n+"FullYear",a[de]=n+"Hours",a[ce]=n+"Minutes",a[ue]=n+"Seconds",a[oe]=n+"Milliseconds",a)[i],s=i===me?this.$D+(t-this.$W):t;if(i===fe||i===ye){var l=this.clone().set(ge,1);l.$d[r](s),l.init(),this.$d=l.set(ge,Math.min(this.$D,l.daysInMonth())).$d}else r&&this.$d[r](s);return this.init(),this},t.set=function(e,t){return this.clone().$set(e,t)},t.get=function(e){return this[Me.p(e)]()},t.add=function(e,t){var a,i=this;e=Number(e);var n=Me.p(t),r=function(t){var a=De(i);return Me.w(a.date(a.date()+Math.round(t*e)),i)};if(n===fe)return this.set(fe,this.$M+e);if(n===ye)return this.set(ye,this.$y+e);if(n===me)return r(1);if(n===he)return r(7);var s=(a={},a[ce]=se,a[de]=le,a[ue]=re,a)[n]||1,l=this.$d.getTime()+e*s;return Me.w(l,this)},t.subtract=function(e,t){return this.add(-1*e,t)},t.format=function(e){var t=this,a=this.$locale();if(!this.isValid())return a.invalidDate||_e;var i=e||"YYYY-MM-DDTHH:mm:ssZ",n=Me.z(this),r=this.$H,s=this.$m,l=this.$M,o=a.weekdays,u=a.months,c=a.meridiem,d=function(e,a,n,r){return e&&(e[a]||e(t,i))||n[a].slice(0,r)},m=function(e){return Me.s(r%12||12,e,"0")},h=c||function(e,t,a){var i=e<12?"AM":"PM";return a?i.toLowerCase():i};return i.replace(xe,(function(e,i){return i||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return Me.s(t.$y,4,"0");case"M":return l+1;case"MM":return Me.s(l+1,2,"0");case"MMM":return d(a.monthsShort,l,u,3);case"MMMM":return d(u,l);case"D":return t.$D;case"DD":return Me.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return d(a.weekdaysMin,t.$W,o,2);case"ddd":return d(a.weekdaysShort,t.$W,o,3);case"dddd":return o[t.$W];case"H":return String(r);case"HH":return Me.s(r,2,"0");case"h":return m(1);case"hh":return m(2);case"a":return h(r,s,!0);case"A":return h(r,s,!1);case"m":return String(s);case"mm":return Me.s(s,2,"0");case"s":return String(t.$s);case"ss":return Me.s(t.$s,2,"0");case"SSS":return Me.s(t.$ms,3,"0");case"Z":return n}return null}(e)||n.replace(":","")}))},t.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},t.diff=function(e,t,a){var i,n=this,r=Me.p(t),s=De(e),l=(s.utcOffset()-this.utcOffset())*se,o=this-s,u=function(){return Me.m(n,s)};switch(r){case ye:i=u()/12;break;case fe:i=u();break;case pe:i=u()/3;break;case he:i=(o-l)/6048e5;break;case me:i=(o-l)/864e5;break;case de:i=o/le;break;case ce:i=o/se;break;case ue:i=o/re;break;default:i=o}return a?i:Me.a(i)},t.daysInMonth=function(){return this.endOf(fe).$D},t.$locale=function(){return we[this.$L]},t.locale=function(e,t){if(!e)return this.$L;var a=this.clone(),i=Se(e,t,!0);return i&&(a.$L=i),a},t.clone=function(){return Me.w(this.$d,this)},t.toDate=function(){return new Date(this.valueOf())},t.toJSON=function(){return this.isValid()?this.toISOString():null},t.toISOString=function(){return this.$d.toISOString()},t.toString=function(){return this.$d.toUTCString()},e}(),Oe=Te.prototype;De.prototype=Oe,[["$ms",oe],["$s",ue],["$m",ce],["$H",de],["$W",me],["$M",fe],["$y",ye],["$D",ge]].forEach((function(e){Oe[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),De.extend=function(e,t){return e.$i||(e(t,Te,De),e.$i=!0),De},De.locale=Se,De.isDayjs=Ie,De.unix=function(e){return De(1e3*e)},De.en=we[Ce],De.Ls=we,De.p={};const He=U({name:"datetime-picker",mixins:[n,r,ne],data:()=>({columns:[],innerDefaultIndex:[],innerFormatter:(e,t)=>t}),watch:{show(e,t){e&&this.updateColumnValue(this.innerValue)},propsChange(){this.init()}},computed:{propsChange(){return[this.mode,this.maxDate,this.minDate,this.minHour,this.maxHour,this.minMinute,this.maxMinute,this.filter]}},mounted(){this.init()},emits:["close","cancel","confirm","change","update:modelValue"],methods:{init(){this.innerValue=this.correctValue(this.modelValue),this.updateColumnValue(this.innerValue)},setFormatter(e){this.innerFormatter=e},close(){this.closeOnClickOverlay&&this.$emit("close")},cancel(){this.$emit("cancel")},confirm(){this.$emit("confirm",{value:this.innerValue,mode:this.mode}),this.$emit("update:modelValue",this.innerValue)},intercept(e,t){let a=e.match(/\d+/g);return a.length>1?(uni.$u.error("请勿在过滤或格式化函数时添加数字"),0):t&&4==a[0].length?a[0]:a[0].length>2?(uni.$u.error("请勿在过滤或格式化函数时添加数字"),0):a[0]},change(e){const{indexs:t,values:a}=e;let i="";if("time"===this.mode)i=`${this.intercept(a[0][t[0]])}:${this.intercept(a[1][t[1]])}`;else{const e=parseInt(this.intercept(a[0][t[0]],"year")),n=parseInt(this.intercept(a[1][t[1]]));let r=parseInt(a[2]?this.intercept(a[2][t[2]]):1),s=0,l=0;const o=De(`${e}-${n}`).daysInMonth();"year-month"===this.mode&&(r=1),r=Math.min(o,r),"datetime"===this.mode&&(s=parseInt(this.intercept(a[3][t[3]])),l=parseInt(this.intercept(a[4][t[4]]))),i=Number(new Date(e,n-1,r,s,l))}i=this.correctValue(i),this.innerValue=i,this.updateColumnValue(i),this.$emit("change",{value:i,picker:this.$refs.picker,mode:this.mode})},updateColumnValue(e){this.innerValue=e,this.updateColumns(),this.updateIndexs(e)},updateIndexs(e){let t=[];const a=this.formatter||this.innerFormatter,i=uni.$u.padZero;if("time"===this.mode){const i=e.split(":");t=[a("hour",i[0]),a("minute",i[1])]}else t=[a("year",`${De(e).year()}`),a("month",i(De(e).month()+1))],"date"===this.mode&&t.push(a("day",i(De(e).date()))),"datetime"===this.mode&&t.push(a("day",i(De(e).date())),a("hour",i(De(e).hour())),a("minute",i(De(e).minute())));const n=this.columns.map(((e,a)=>Math.max(0,e.findIndex((e=>e===t[a])))));this.innerDefaultIndex=n},updateColumns(){const e=this.formatter||this.innerFormatter,t=this.getOriginColumns().map((t=>t.values.map((a=>e(t.type,a)))));this.columns=t},getOriginColumns(){return this.getRanges().map((({type:e,range:t})=>{let a=function(e,t){let a=-1;const i=Array(e<0?0:e);for(;++a<e;)i[a]=t(a);return i}(t[1]-t[0]+1,(a=>{let i=t[0]+a;return i="year"===e?`${i}`:uni.$u.padZero(i),i}));return this.filter&&(a=this.filter(e,a)),{type:e,values:a}}))},generateArray:(e,t)=>Array.from(new Array(t+1).keys()).slice(e),correctValue(e){const t="time"!==this.mode;if(t&&!uni.$u.test.date(e)?e=this.minDate:t||e||(e=`${uni.$u.padZero(this.minHour)}:${uni.$u.padZero(this.minMinute)}`),t)return e=De(e).isBefore(De(this.minDate))?this.minDate:e,e=De(e).isAfter(De(this.maxDate))?this.maxDate:e;{if(-1===String(e).indexOf(":"))return uni.$u.error("时间错误,请传递如12:24的格式");let[t,a]=e.split(":");return t=uni.$u.padZero(uni.$u.range(this.minHour,this.maxHour,Number(t))),a=uni.$u.padZero(uni.$u.range(this.minMinute,this.maxMinute,Number(a))),`${t}:${a}`}},getRanges(){if("time"===this.mode)return[{type:"hour",range:[this.minHour,this.maxHour]},{type:"minute",range:[this.minMinute,this.maxMinute]}];const{maxYear:e,maxDate:t,maxMonth:a,maxHour:i,maxMinute:n}=this.getBoundary("max",this.innerValue),{minYear:r,minDate:s,minMonth:l,minHour:o,minMinute:u}=this.getBoundary("min",this.innerValue),c=[{type:"year",range:[r,e]},{type:"month",range:[l,a]},{type:"day",range:[s,t]},{type:"hour",range:[o,i]},{type:"minute",range:[u,n]}];return"date"===this.mode&&c.splice(3,2),"year-month"===this.mode&&c.splice(2,3),c},getBoundary(e,t){const a=new Date(t),i=new Date(this[`${e}Date`]),n=De(i).year();let r=1,s=1,l=0,o=0;return"max"===e&&(r=12,s=De(a).daysInMonth(),l=23,o=59),De(a).year()===n&&(r=De(i).month()+1,De(a).month()+1===r&&(s=De(i).date(),De(a).date()===s&&(l=De(i).hour(),De(a).hour()===l&&(o=De(i).minute())))),{[`${e}Year`]:n,[`${e}Month`]:r,[`${e}Date`]:s,[`${e}Hour`]:l,[`${e}Minute`]:o}}}},[["render",function(e,t,a,i,n,r){const s=l(o("u-picker"),ie);return u(),c(s,{ref:"picker",show:e.show,closeOnClickOverlay:e.closeOnClickOverlay,columns:n.columns,title:e.title,itemHeight:e.itemHeight,showToolbar:e.showToolbar,visibleItemCount:e.visibleItemCount,defaultIndex:n.innerDefaultIndex,cancelText:e.cancelText,confirmText:e.confirmText,cancelColor:e.cancelColor,confirmColor:e.confirmColor,onClose:r.close,onCancel:r.cancel,onConfirm:r.confirm,onChange:r.change},null,8,["show","closeOnClickOverlay","columns","title","itemHeight","showToolbar","visibleItemCount","defaultIndex","cancelText","confirmText","cancelColor","confirmColor","onClose","onCancel","onConfirm","onChange"])}],["__scopeId","data-v-e4f68153"]]),Pe=U(D({__name:"personal",setup(e){const t=M(),a=T((()=>t.info)),i=O({modal:!1,value:a.nickname||""}),n=e=>{i.value=e.detail.value},r=()=>{uni.$u.test.isEmpty(i.value)?j({title:V("nicknamePlaceholder"),icon:"none"}):F({field:"nickname",value:i.value}).then((e=>{t.info.nickname=i.value,i.modal=!1}))},s=H(!1),h=T((()=>[{name:V("man"),value:1},{name:V("woman"),value:2}])),f=e=>{F({field:"sex",value:e.value}).then((a=>{t.info.sex_name=e.name}))},p=e=>{B({filePath:e.file.url,name:"file"}).then((e=>{F({field:"headimg",value:e.data.url}).then((()=>{t.info.headimg=e.data.url}))})).catch((()=>{}))},y=H(!1),x=e=>{F({field:"birthday",value:uni.$u.date(e.value,"yyyy-mm-dd")}).then((()=>{t.info.birthday=uni.$u.date(e.value,"yyyy-mm-dd"),y.value=!1}))};return(e,t)=>{const $=l(o("u-avatar"),L),b=w,k=l(o("u-upload"),te),C=l(o("u-cell"),W),I=l(o("u-button"),E),S=l(o("app-link"),q),D=l(o("u-cell-group"),Z),M=z,T=l(o("u-modal"),Q),O=l(o("u-action-sheet"),J),H=l(o("u-datetime-picker"),He);return P(a)?(u(),c(b,{key:0,class:"w-full h-screen bg-page"},{default:d((()=>[m(b,{class:"flex flex-col items-center pt-[30rpx]"},{default:d((()=>[m(k,{onAfterRead:p,maxCount:1},{default:d((()=>[m($,{src:P(N)(P(a).headimg),size:"60",leftIcon:"none"},null,8,["src"]),m(b,{class:"text-primary text-sm mt-[10rpx]"},{default:d((()=>[g(_(P(V)("updateHeadimg")),1)])),_:1})])),_:1})])),_:1}),m(b,{class:"m-[30rpx] bg-white rounded-md overflow-hidden px-[20rpx] py-[10rpx]"},{default:d((()=>[m(D,{border:!1},{default:d((()=>[m(C,{title:P(V)("nickname"),"is-link":!0,value:P(a).nickname,onClick:t[0]||(t[0]=e=>i.modal=!0)},null,8,["title","value"]),m(C,{title:P(V)("sex"),"is-link":!0,value:P(a).sex_name||P(V)("unknown"),onClick:t[1]||(t[1]=e=>s.value=!0)},null,8,["title","value"]),m(C,{title:P(V)("mobile")},{value:d((()=>[P(a).mobile?(u(),c(b,{key:0},{default:d((()=>[g(_(P(A)(P(a).mobile)),1)])),_:1})):v("v-if",!0),m(b,null,{default:d((()=>[m(S,{url:"/app/pages/auth/bind"},{default:d((()=>[m(I,{type:"primary",plain:!0,text:P(V)("bindMobile"),shape:"circle",size:"mini"},null,8,["text"])])),_:1})])),_:1})])),_:1},8,["title"]),m(C,{title:P(V)("birthday"),"is-link":!0,value:P(a).birthday||P(V)("unknown"),onClick:t[2]||(t[2]=e=>y.value=!0)},null,8,["title","value"])])),_:1})])),_:1}),m(T,{show:i.modal,closeOnClickOverlay:!0,onClose:t[4]||(t[4]=e=>i.modal=!1),"show-cancel-button":!0,onCancel:t[5]||(t[5]=e=>i.modal=!1),title:P(V)("updateNickname")},{confirmButton:d((()=>[m(b,{class:"mt-[10rpx]"},{default:d((()=>[m(I,{type:"primary",text:P(V)("confirm"),shape:"circle",onClick:r},null,8,["text"])])),_:1})])),default:d((()=>[m(b,{class:"w-full mt-[20rpx] border-0 border-b border-gray-300 border-solid py-[20rpx]"},{default:d((()=>[m(M,{type:"nickname",modelValue:i.value,"onUpdate:modelValue":t[3]||(t[3]=e=>i.value=e),placeholder:P(V)("nicknamePlaceholder"),onBlur:n},null,8,["modelValue","placeholder"])])),_:1})])),_:1},8,["show","title"]),m(O,{actions:P(h),show:s.value,closeOnClickOverlay:!0,safeAreaInsetBottom:!0,onClose:t[6]||(t[6]=e=>s.value=!1),onSelect:f},null,8,["actions","show"]),m(H,{show:y.value,mode:"date","confirm-text":P(V)("confirm"),maxDate:(new Date).valueOf(),minDate:0,"cancel-text":P(V)("cancel"),onCancel:t[7]||(t[7]=e=>y.value=!1),onConfirm:x},null,8,["show","confirm-text","maxDate","cancel-text"])])),_:1})):v("v-if",!0)}}}),[["__scopeId","data-v-fa9bd155"]]);export{Pe as default};
|