phizclip-uniapp-demo/finclip-uniapp-test/unpackage/resources/__UNI__87380BE/www/__uniapppicker.js

4 lines
15 KiB
JavaScript
Executable File

"use weex:vue";
(()=>{var T=Object.create;var d=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var I=e=>d(e,"__esModule",{value:!0});var L=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var V=(e,t,a,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of M(t))!D.call(e,s)&&(a||s!=="default")&&d(e,s,{get:()=>t[s],enumerable:!(r=x(t,s))||r.enumerable});return e},N=(e,t)=>V(I(d(e!=null?T(C(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var A=L((K,v)=>{v.exports=Vue});var _={data(){return{locale:"en",fallbackLocale:"en",localization:{en:{done:"OK",cancel:"Cancel"},zh:{done:"\u5B8C\u6210",cancel:"\u53D6\u6D88"},"zh-hans":{},"zh-hant":{},messages:{}}}},onLoad(){this.initLocale()},created(){this.initLocale()},methods:{initLocale(){if(this.__initLocale)return;this.__initLocale=!0;let e=(plus.webview.currentWebview().extras||{}).data||{};if(e.messages&&(this.localization.messages=e.messages),e.locale){this.locale=e.locale.toLowerCase();return}let t={chs:"hans",cn:"hans",sg:"hans",cht:"hant",tw:"hant",hk:"hant",mo:"hant"},a=plus.os.language.toLowerCase().split("/")[0].replace("_","-").split("-"),r=a[1];r&&(a[1]=t[r]||r),a.length=a.length>2?2:a.length,this.locale=a.join("-")},localize(e){let t=this.locale,a=t.split("-")[0],r=this.fallbackLocale,s=this.localization;function n(c){return s[c]||{}}return n("messages")[e]||n(t)[e]||n(a)[e]||n(r)[e]||e}}},b={onLoad(){this.initMessage()},methods:{initMessage(){let{from:e,callback:t,runtime:a,data:r={},useGlobalEvent:s}=plus.webview.currentWebview().extras||{};this.__from=e,this.__runtime=a,this.__page=plus.webview.currentWebview().id,this.__useGlobalEvent=s,this.data=JSON.parse(JSON.stringify(r)),plus.key.addEventListener("backbutton",()=>{typeof this.onClose=="function"?this.onClose():plus.webview.currentWebview().close("auto")});let n=this,c=function(o){let u=o.data&&o.data.__message;!u||n.__onMessageCallback&&n.__onMessageCallback(u.data)};if(this.__useGlobalEvent)weex.requireModule("globalEvent").addEventListener("plusMessage",c);else{let o=new BroadcastChannel(this.__page);o.onmessage=c}},postMessage(e={},t=!1){let a=JSON.parse(JSON.stringify({__message:{__page:this.__page,data:e,keep:t}})),r=this.__from;if(this.__runtime==="v8")this.__useGlobalEvent?plus.webview.postMessageToUniNView(a,r):new BroadcastChannel(r).postMessage(a);else{let s=plus.webview.getWebviewById(r);s&&s.evalJS(`__plusMessage&&__plusMessage(${JSON.stringify({data:a})})`)}},onMessage(e){this.__onMessageCallback=e}}};var i=N(A());var m=(e,t)=>{let a=e.__vccOpts||e;for(let[r,s]of t)a[r]=s;return a};var f=e=>e>9?e:"0"+e;function E({date:e=new Date,mode:t="date"}){return t==="time"?f(e.getHours())+":"+f(e.getMinutes()):e.getFullYear()+"-"+f(e.getMonth()+1)+"-"+f(e.getDate())}var O={data(){return{safeAreaInsets:{left:0,right:0,top:0,bottom:0}}},onLoad(){this.initSafeAreaInsets()},created(){this.initSafeAreaInsets()},methods:{initSafeAreaInsets(){if(this.__initSafeAreaInsets)return;this.__initSafeAreaInsets=!0;let e=plus.webview.currentWebview();e.addEventListener("resize",()=>{setTimeout(()=>{this.updateSafeAreaInsets(e)},20)}),this.updateSafeAreaInsets(e)},updateSafeAreaInsets(e){let t=e.getSafeAreaInsets(),a=this.safeAreaInsets;Object.keys(a).forEach(r=>{a[r]=t[r]})}}},z={content:{"":{position:"absolute",top:0,left:0,bottom:0,right:0}},"uni-mask":{"":{position:"absolute",top:0,left:0,bottom:0,right:0,backgroundColor:"rgba(0,0,0,0.4)",opacity:0,transitionProperty:"opacity",transitionDuration:200,transitionTimingFunction:"linear"}},"uni-mask-android":{"":{backgroundColor:"rgba(0,0,0,0.6)"}},"uni-mask-visible":{"":{opacity:1}},"uni-picker":{"":{position:"absolute",left:0,bottom:0,right:0,backgroundColor:"#ffffff",color:"#000000",flexDirection:"column",transform:"translateY(295px)"}},"uni-picker-header":{"":{height:45,borderBottomWidth:0,backgroundColor:"#E6E6E6",fontSize:20}},"uni-picker-action":{"":{position:"absolute",textAlign:"center",top:0,height:45,paddingTop:0,paddingRight:14,paddingBottom:0,paddingLeft:14,fontSize:17,lineHeight:45}},"uni-picker-action-cancel":{"":{left:0,color:"#888888"}},"uni-picker-action-confirm":{"":{right:0,color:"#007aff"}},"uni-picker-content":{"":{flex:1}},"uni-picker-item":{"":{lineHeight:34,textAlign:"center",color:"#000000"}},"@TRANSITION":{"uni-mask":{property:"opacity",duration:200,timingFunction:"linear"}}};function k(){if(this.mode===l.TIME)return"00:00";if(this.mode===l.DATE){let e=new Date().getFullYear()-61;switch(this.fields){case h.YEAR:return e;case h.MONTH:return e+"-01";default:return e+"-01-01"}}return""}function w(){if(this.mode===l.TIME)return"23:59";if(this.mode===l.DATE){let e=new Date().getFullYear()+61;switch(this.fields){case h.YEAR:return e;case h.MONTH:return e+"-12";default:return e+"-12-31"}}return""}var S=weex.requireModule("animation"),l={SELECTOR:"selector",MULTISELECTOR:"multiSelector",TIME:"time",DATE:"date",REGION:"region"},h={YEAR:"year",MONTH:"month",DAY:"day"},R={name:"Picker",mixins:[_,O],props:{pageId:{type:Number,default:0},range:{type:Array,default(){return[]}},rangeKey:{type:String,default:""},value:{type:[Number,String,Array],default:0},mode:{type:String,default:l.SELECTOR},fields:{type:String,default:h.DAY},start:{type:String,default:k},end:{type:String,default:w},disabled:{type:[Boolean,String],default:!1},visible:{type:Boolean,default:!1}},data(){return{valueSync:null,timeArray:[],dateArray:[],valueArray:[],oldValueArray:[],fontSize:16,height:261,android:weex.config.env.platform.toLowerCase()==="android"}},computed:{rangeArray(){var e=this.range;switch(this.mode){case l.SELECTOR:return[e];case l.MULTISELECTOR:return e;case l.TIME:return this.timeArray;case l.DATE:{let t=this.dateArray;switch(this.fields){case h.YEAR:return[t[0]];case h.MONTH:return[t[0],t[1]];default:return[t[0],t[1],t[2]]}}}return[]},startArray(){return this._getDateValueArray(this.start,k.bind(this)())},endArray(){return this._getDateValueArray(this.end,w.bind(this)())},textMaxLength(){return Math.floor(Math.min(weex.config.env.deviceWidth,weex.config.env.deviceHeight)/(this.fontSize*weex.config.env.scale+1)/this.rangeArray.length)}},watch:{value(){this._setValueSync()},mode(){this._setValueSync()},range(){this._setValueSync()},valueSync(){this._setValueArray()},valueArray(e){if(this.mode===l.TIME||this.mode===l.DATE){let t=this.mode===l.TIME?this._getTimeValue:this._getDateValue,a=this.valueArray,r=this.startArray,s=this.endArray;if(this.mode===l.DATE){let n=this.dateArray,c=n[2].length,o=Number(n[2][a[2]])||1,u=new Date(`${n[0][a[0]]}/${n[1][a[1]]}/${o}`).getDate();u<o&&(a[2]-=u+c-o)}t(a)<t(r)?this._cloneArray(a,r):t(a)>t(s)&&this._cloneArray(a,s)}e.forEach((t,a)=>{t!==this.oldValueArray[a]&&(this.oldValueArray[a]=t,this.mode===l.MULTISELECTOR&&this.$emit("columnchange",{column:a,value:t}))})},visible(e){e?setTimeout(()=>{S.transition(this.$refs.picker,{styles:{transform:"translateY(0)"},duration:200})},20):S.transition(this.$refs.picker,{styles:{transform:`translateY(${283+this.safeAreaInsets.bottom}px)`},duration:200})}},created(){this._createTime(),this._createDate(),this._setValueSync()},methods:{getTexts(e,t){let a=this.textMaxLength;return e.map(r=>{let s=String(typeof r=="object"?r[this.rangeKey]||"":this._l10nItem(r,t));if(a>0&&s.length>a){let n=0,c=0;for(let o=0;o<s.length;o++){let u=s.charCodeAt(o);if(u>127||u===94?n+=1:n+=.65,n<=a-1&&(c=o),n>=a)return o===s.length-1?s:s.substr(0,c+1)+"\u2026"}}return s||" "}).join(`
`)},_createTime(){var e=[],t=[];e.splice(0,e.length);for(let a=0;a<24;a++)e.push((a<10?"0":"")+a);t.splice(0,t.length);for(let a=0;a<60;a++)t.push((a<10?"0":"")+a);this.timeArray.push(e,t)},_createDate(){var e=[],t=new Date().getFullYear();for(let s=t-61,n=t+61;s<=n;s++)e.push(String(s));var a=[];for(let s=1;s<=12;s++)a.push((s<10?"0":"")+s);var r=[];for(let s=1;s<=31;s++)r.push((s<10?"0":"")+s);this.dateArray.push(e,a,r)},_getTimeValue(e){return e[0]*60+e[1]},_getDateValue(e){return e[0]*31*12+(e[1]||0)*31+(e[2]||0)},_cloneArray(e,t){for(let a=0;a<e.length&&a<t.length;a++)e[a]=t[a]},_setValueSync(){let e=this.value;switch(this.mode){case l.MULTISELECTOR:Array.isArray(e)||(e=[]),Array.isArray(this.valueSync)||(this.valueSync=[]);let t=this.valueSync.length=Math.max(e.length,this.range.length);for(let a=0;a<t;a++){let r=Number(e[a]),s=Number(this.valueSync[a]),n=isNaN(r)?isNaN(s)?0:s:r,c=this.range[a]?this.range[a].length-1:0;this.valueSync.splice(a,1,n<0||n>c?0:n)}break;case l.TIME:case l.DATE:this.valueSync=String(e);break;default:{let a=Number(e);this.valueSync=a<0?0:a;break}}},_setValueArray(){var e=this.valueSync,t;switch(this.mode){case l.MULTISELECTOR:t=[...e];break;case l.TIME:t=this._getDateValueArray(e,E({mode:l.TIME}));break;case l.DATE:t=this._getDateValueArray(e,E({mode:l.DATE}));break;default:t=[e];break}this.oldValueArray=[...t],this.valueArray=[...t]},_getValue(){var e=this.valueArray;switch(this.mode){case l.SELECTOR:return e[0];case l.MULTISELECTOR:return e.map(t=>t);case l.TIME:return this.valueArray.map((t,a)=>this.timeArray[a][t]).join(":");case l.DATE:return this.valueArray.map((t,a)=>this.dateArray[a][t]).join("-")}},_getDateValueArray(e,t){let a=this.mode===l.DATE?"-":":",r=this.mode===l.DATE?this.dateArray:this.timeArray,s=3;switch(this.fields){case h.YEAR:s=1;break;case h.MONTH:s=2;break}let n=String(e).split(a),c=[];for(let o=0;o<s;o++){let u=n[o];c.push(r[o].indexOf(u))}return c.indexOf(-1)>=0&&(c=t?this._getDateValueArray(t):c.map(()=>0)),c},_change(){this.$emit("change",{value:this._getValue()})},_cancel(){this.$emit("cancel")},_pickerViewChange(e){this.valueArray=this._l10nColumn(e.detail.value,!0)},_l10nColumn(e,t){if(this.mode===l.DATE){let a=this.locale;if(!a.startsWith("zh"))switch(this.fields){case h.YEAR:return e;case h.MONTH:return[e[1],e[0]];default:switch(a){case"es":case"fr":return[e[2],e[1],e[0]];default:return t?[e[2],e[0],e[1]]:[e[1],e[2],e[0]]}}}return e},_l10nItem(e,t){if(this.mode===l.DATE){let a=this.locale;if(a.startsWith("zh"))return e+["\u5E74","\u6708","\u65E5"][t];if(this.fields!==h.YEAR&&t===(this.fields!==h.MONTH&&(a==="es"||a==="fr")?1:0)){let r;switch(a){case"es":r=["enero","febrero","marzo","abril","mayo","junio","\u200B\u200Bjulio","agosto","septiembre","octubre","noviembre","diciembre"];break;case"fr":r=["janvier","f\xE9vrier","mars","avril","mai","juin","juillet","ao\xFBt","septembre","octobre","novembre","d\xE9cembre"];break;default:r=["January","February","March","April","May","June","July","August","September","October","November","December"];break}return r[Number(e)-1]}}return e}}};function Y(e,t,a,r,s,n){let c=(0,i.resolveComponent)("picker-view-column"),o=(0,i.resolveComponent)("picker-view");return(0,i.openBlock)(),(0,i.createElementBlock)("div",{class:"content"},[(0,i.createElementVNode)("div",{ref:"mask",class:"uni-mask",style:(0,i.normalizeStyle)({opacity:a.visible?1:0,"background-color":s.android?"rgba(0, 0, 0, 0.6)":"rgba(0, 0, 0, 0.4)"}),onClick:t[0]||(t[0]=(...u)=>n._cancel&&n._cancel(...u))},null,4),(0,i.createElementVNode)("div",{style:(0,i.normalizeStyle)(`padding-bottom:${e.safeAreaInsets.bottom}px;height:${s.height+e.safeAreaInsets.bottom}px;`),ref:"picker",class:"uni-picker"},[(0,i.createElementVNode)("div",{class:"uni-picker-header"},[(0,i.createElementVNode)("u-text",{style:(0,i.normalizeStyle)(`left:${e.safeAreaInsets.left}px`),class:"uni-picker-action uni-picker-action-cancel",onClick:t[1]||(t[1]=(...u)=>n._cancel&&n._cancel(...u))},(0,i.toDisplayString)(e.localize("cancel")),5),(0,i.createElementVNode)("u-text",{style:(0,i.normalizeStyle)(`right:${e.safeAreaInsets.right}px`),class:"uni-picker-action uni-picker-action-confirm",onClick:t[2]||(t[2]=(...u)=>n._change&&n._change(...u))},(0,i.toDisplayString)(e.localize("done")),5)]),a.visible?((0,i.openBlock)(),(0,i.createBlock)(o,{key:0,style:(0,i.normalizeStyle)(`margin-left:${e.safeAreaInsets.left}px`),height:"216","indicator-style":"height: 34px;border-color:#C8C9C9;border-top-width:0.5px;border-bottom-width:0.5px;",value:n._l10nColumn(s.valueArray),class:"uni-picker-content",onChange:n._pickerViewChange},{default:(0,i.withCtx)(()=>[((0,i.openBlock)(!0),(0,i.createElementBlock)(i.Fragment,null,(0,i.renderList)(n._l10nColumn(n.rangeArray),(u,y)=>((0,i.openBlock)(),(0,i.createBlock)(c,{length:u.length,key:y},{default:(0,i.withCtx)(()=>[(0,i.createCommentVNode)(" iOS\u6E32\u67D3\u901F\u5EA6\u6709\u95EE\u9898\u4F7F\u7528\u5355\u4E2Atext\u4F18\u5316 "),(0,i.createElementVNode)("u-text",{class:"uni-picker-item",style:(0,i.normalizeStyle)({fontSize:s.fontSize+"px","line-height":"34px","text-align":"center",color:"#000"})},(0,i.toDisplayString)(n.getTexts(u,y)),5),(0,i.createCommentVNode)(` <text v-for="(item,index) in range" :key="index" class="uni-picker-item uni-picker-item-line" :style="{fontSize: fontSize + 'px'}">{{ typeof item==='object'?item[rangeKey]||'':_l10nItem(item) }}</text> `)]),_:2},1032,["length"]))),128))]),_:1},8,["style","value","onChange"])):(0,i.createCommentVNode)("v-if",!0)],4)])}var B=m(R,[["render",Y],["styles",[z]]]),j={page:{"":{flex:1}}},F={mixins:[b],components:{picker:B},data(){return{range:[],rangeKey:"",value:0,mode:"selector",fields:"day",start:"",end:"",disabled:!1,visible:!1}},onLoad(){this.data===null?this.postMessage({event:"created"},!0):this.showPicker(this.data),this.onMessage(e=>{this.showPicker(e)})},onReady(){this.$nextTick(()=>{this.visible=!0})},methods:{showPicker(e={}){let t=e.column;for(let a in e)a!=="column"&&(typeof t=="number"?this.$set(this.$data[a],t,e[a]):this.$data[a]=e[a])},close(e,{value:t=-1}={}){this.visible=!1,setTimeout(()=>{this.postMessage({event:e,value:t})},210)},onClose(){this.close("cancel")},columnchange({column:e,value:t}){this.$set(this.value,e,t),this.postMessage({event:"columnchange",column:e,value:t},!0)}}};function H(e,t,a,r,s,n){let c=(0,i.resolveComponent)("picker");return(0,i.openBlock)(),(0,i.createElementBlock)("scroll-view",{scrollY:!0,showScrollbar:!0,enableBackToTop:!0,bubble:!0,style:{flexDirection:"column"}},[(0,i.createElementVNode)("view",{class:"page"},[(0,i.createVNode)(c,{range:s.range,rangeKey:s.rangeKey,value:s.value,mode:s.mode,fields:s.fields,start:s.start,end:s.end,disabled:s.disabled,visible:s.visible,onChange:t[0]||(t[0]=o=>n.close("change",o)),onCancel:t[1]||(t[1]=o=>n.close("cancel",o)),onColumnchange:n.columnchange},null,8,["range","rangeKey","value","mode","fields","start","end","disabled","visible","onColumnchange"])])])}var g=m(F,[["render",H],["styles",[j]]]);var p=plus.webview.currentWebview();if(p){let e=parseInt(p.id),t="template/__uniapppicker",a={};try{a=JSON.parse(p.__query__)}catch{}g.mpType="page";let r=Vue.createPageApp(g,{$store:getApp({allowDefault:!0}).$store,__pageId:e,__pagePath:t,__pageQuery:a});r.provide("__globalStyles",Vue.useCssStyles([...__uniConfig.styles,...g.styles||[]])),r.mount("#root")}})();