- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡 - 药品百科: 搜索 + 分类筛选 + 20种药品静态数据 - 惠教中心: 4条药品使用指南课程 - 我的: 家庭成员信息管理 - 自定义TabBar + navigation-bar组件 - SVG药品分类插图
1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
"use strict";function _typeof2(e){return _typeof2="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof2(e)}module.exports=function(e){var t={};function o(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=e,o.c=t,o.d=function(e,t,r){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"===_typeof2(e)&&e&&e.__esModule)return e;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)o.d(r,i,function(t){return e[t]}.bind(null,i));return r},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=2)}([function(e,t,o){var r=!1,i=void 0,n=void 0;!function(){var e=wx.getSystemInfoSync();r="ios"===e.platform;var t=e.screenWidth||375,o=e.pixelRatio||2;t===i&&o===n||(i=t,n=o)}();var h=/([+-]?\d+(?:\.\d+)?)rpx/gi;e.exports={transformRpx:function(e,t){if("string"!=typeof e)return e;var o=h;return e.replace(o,function(e,o){return(0===(h=Number(o))?0:(h=h/750*i,0===(h=Math.floor(h+1e-4))?1!==n&&r?.5:1:h))+(t?"px":"");var h})}}},function(e,t,o){e.exports={}},function(e,t,o){var r=o(3);e.exports=function(e){return new r(e)}},function(e,t,o){var r="function"==typeof Symbol&&"symbol"===_typeof2(Symbol.iterator)?function(e){return _typeof2(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":_typeof2(e)},i=o(1),n=o(4),h=o(0),a=200;function s(e){var t=this,o=e.id,i=e.dataKey,h=e.page,a=e.itemSize,s=e.useInPage,c=e.placeholderClass,l=e.root;if(!(o&&i&&h&&a))throw new Error("parameter id, dataKey, page, itemSize is required");if("function"!=typeof a&&"object"!==(void 0===a?"undefined":r(a)))throw new Error("parameter itemSize must be function or object with key width and height");if(!("object"!==(void 0===a?"undefined":r(a))||a.width&&a.height||a.props&&a.queryClass&&a.dataKey))throw new Error("parameter itemSize must be function or object with key width and height");if(this.id=o,this.dataKey=i,this.page=h,this.root=l,this.placeholderClass=c,h._recycleViewportChange=n,this.comp=h.selectComponent("#"+o),this.itemSize=a,this.itemSizeOpt=a,this.useInPage=s||!1,this.comp&&(this.comp.context=this,this.comp.setPage(h),this.comp.setUseInPage(this.useInPage)),this.useInPage&&!this.root)throw new Error("parameter root is required when useInPage is true");this.useInPage&&(this.oldPageScroll=this.root.onPageScroll,this.root.onPageScroll=function(e){t.comp&&t.comp._scrollViewDidScroll({detail:{scrollLeft:0,scrollTop:e.scrollTop}}),t.oldPageScroll.apply(t.root,[e])},this.oldReachBottom=this.root.onReachBottom,this.root.onReachBottom=function(e){t.comp&&t.comp.triggerEvent("scrolltolower",{}),t.oldReachBottom.apply(t.root,[e])},this.oldPullDownRefresh=this.root.onPullDownRefresh,this.root.onPullDownRefresh=function(e){t.comp&&t.comp.triggerEvent("scrolltoupper",{}),t.oldPullDownRefresh.apply(t.root,[e])})}function c(e,t){if(!t)return e;if(void 0!==e[t])return e[t];for(var o=t.split("."),i=0;i<o.length;i++)if(void 0===(e=e[o[i]])||"object"===(void 0===e?"undefined":r(e))&&!e)return;return e}function l(e,t){"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]);for(var o={},r=0;r<t.length;r++)o[t[r]]=c(e,t[r]);return o}function p(e){return"[object Array]"===Object.prototype.toString.call(e)}function u(e,t){if((void 0===e?"undefined":r(e))!==(void 0===t?"undefined":r(t)))return!1;if(p(e)&&p(t)){if(e.length!==t.length)return!1;for(var o=0;o<e.length;o++)if(e[o]!==t[o])return!1;return!0}return e===t}function f(e,t,o){p(o)||(o=[o]);for(var r=0;r<o.length;r++)if(!u(c(e,o[r]),c(t,o[r])))return!1;return!0}s.prototype.checkComp=function(){if(!this.comp){if(this.comp=this.page.selectComponent("#"+this.id),!this.comp)throw new Error("the recycle-view correspond to this context is detached, pls create another RecycleContext");this.comp.setUseInPage(this.useInPage),this.comp.context=this,this.comp.setPage(this.page)}},s.prototype.appendList=function(e,t){this.checkComp();var o=this.id,r=this.dataKey;return i[o]?(i[o].dataKey=r,i[o].list=i[o].list.concat(e)):i[o]={key:r,id:o,list:e,sizeMap:{},sizeArray:[]},this._forceRerender(o,t),this},s.prototype._forceRerender=function(e,t){this.isDataReady=!0;var o=this,r=null,n=null,h=0;function a(){if(r&&n){for(var e=[],t=0;t<h;t++)e.push({left:r[t].left-n.left,top:r[t].top-n.top,width:r[t].width,height:r[t].height});o.comp.setPlaceholderImage(e,{width:n.width,height:n.height})}}function s(){if(t&&t(),o.autoCalculateSize&&o.placeholderClass){var e=[];o.placeholderClass.forEach(function(t){e.push("."+o.itemSizeOpt.queryClass+" ."+t)}),h=e.length,wx.createSelectorQuery().selectAll(e.join(",")).boundingClientRect(function(e){e.length<h||(r=e,a())}).exec(),wx.createSelectorQuery().select("."+o.itemSizeOpt.queryClass).boundingClientRect(function(e){n=e,a()}).exec()}}if("[object Object]"!==Object.prototype.toString.call(this.itemSizeOpt)||!this.itemSizeOpt||this.itemSizeOpt.width){var c=this._recalculateSize(i[e].list);i[e].sizeMap=c.map,i[e].sizeArray=c.array,this.comp.forceUpdate(t)}else this._recalculateSizeByProp(i[e].list,function(t){i[e].sizeMap=t.map,i[e].sizeArray=t.array,o.comp.forceUpdate(s)})},s.prototype._recalculateSizeByProp=function(e,t){var o=this.itemSizeOpt,r=this.propValueMap||[],i=[],n=[];o.cacheKey&&(r=wx.getStorageSync(o.cacheKey)||[]),this.autoCalculateSize=!0;for(var h=[],a=0;a<e.length;a++){var s=r.length;if(r.length){for(var c=!1,p=0;p<r.length;p++)if(f(r[p],e[a],o.props)){s=p,c=!0;break}if(!c){var u=l(e[a],o.props);u.__index__=a,r.push(u),i.push(e[a]),n.push(s)}h.push({index:a,sizeIndex:s})}else{var d=l(e[a],o.props);d.__index__=a,r.push(d),i.push(e[a]),n.push(s),h.push({index:a,sizeIndex:s})}}this.propValueMap=r,r.length>10&&console.warn("[recycle-view] get itemSize count exceed maximum of 10, now got",r);var g=this;function y(e,t){var o=h[t];if(!o)throw console.error("[recycle-view] auto calculate size array error, no map size found",e,t,h),new Error("[recycle-view] auto calculate size array error, no map size found");var i=r[o.sizeIndex];if(!i)throw console.log("[recycle-view] auto calculate size array error, no size found",e,t,o,r),new Error("[recycle-view] auto calculate size array error, no size found");return{width:i.width,height:i.height}}if(i.length){var m={};m[o.dataKey]=i,this.page.setData(m,function(){wx.createSelectorQuery().selectAll("."+o.queryClass).boundingClientRect(function(i){!function(i){i.forEach(function(e,t){var o=n[t];r[o].width=e.width,r[o].height=e.height}),g.itemSize=y;var h=g._recalculateSize(e);o.cacheKey&&wx.setStorageSync(o.cacheKey,r),t&&t(h)}(i)}).exec()})}else{g.itemSize=y;var v=g._recalculateSize(e);t&&t(v)}},s.prototype._recalculateSize=function(e){for(var t={},o=this.itemSize,r="function"==typeof o,i=this.comp,n=i.data,h=0,s=0,c=0,l=0,p=[],u=e.length,f=0;f<u;f++){e[f].__index__=f;var d={};if(d=r?o&&o.call(this,e[f],f):{width:o.width,height:o.height},d=Object.assign({},d),p.push(d),h+d.width>n.width){if(l=0,h=d.width,p.length>=2?s+=p[p.length-2].height||0:s+=d.height,s>=a*(c+1)){var g=f-1,y=c;c+=parseInt((s-a*c)/a,10);for(var m=y;m<c;m++){var v=m+"."+l;t[v]||(t[v]=[]),t[v].push(g)}}if(0===f)d.beforeHeight=0;else{var w=p[p.length-2];d.beforeHeight=w.beforeHeight+w.height}}else h>=a*(l+1)&&l++,h+=d.width,d.beforeHeight=0===f?0:p[p.length-2].beforeHeight;var S=c+"."+l;if(t[S]||(t[S]=[]),t[S].push(f),u-1===f&&d.height>a){var b=c;s+=d.height,c+=parseInt((s-a*c)/a,10);for(var x=b;x<=c;x++){var z=x+"."+l;t[z]||(t[z]=[]),t[z].push(f)}}}var _={array:p,map:t,totalHeight:p.length?p[p.length-1].beforeHeight+p[p.length-1].height:0};return i.setItemSize(_),_},s.prototype.deleteList=function(e,t,o){this.checkComp();var r=this.id;return i[r]?(i[r].list.splice(e,t),this._forceRerender(r,o),this):this},s.prototype.updateList=function(e,t,o){this.checkComp();var r=this.id;if(!i[r])return this;for(var n=i[r].list.length,h=0;h<t.length&&e<n;h++)i[r].list[e++]=t[h];return this._forceRerender(r,o),this},s.prototype.update=s.prototype.updateList,s.prototype.splice=function(e,t,o,n){this.checkComp();var h=this.id,a=this.dataKey;if("object"===(void 0===e?"undefined":r(e))&&e.length&&(n=t,o=e),"function"==typeof o&&(n=o,o=[]),i[h]){i[h].dataKey=a;var s=i[h].list;o&&o.length?s.splice.apply(s,[e,t].concat(o)):s.splice(e,t)}else i[h]={key:a,id:h,list:o||[],sizeMap:{},sizeArray:[]};return this._forceRerender(h,n),this},s.prototype.append=s.prototype.appendList,s.prototype.destroy=function(){return this.useInPage&&(this.page.onPullDownRefresh=this.oldPullDownRefresh,this.page.onReachBottom=this.oldReachBottom,this.page.onPageScroll=this.oldPageScroll,this.oldPageScroll=this.oldReachBottom=this.oldPullDownRefresh=null),this.page=null,this.comp=null,i[this.id]&&delete i[this.id],this},s.prototype.forceUpdate=function(e,t){var o=this;return this.checkComp(),t?this.comp.reRender(function(){o._forceRerender(o.id,e)}):this._forceRerender(this.id,e),this},s.prototype.getBoundingClientRect=function(e){if(this.checkComp(),!i[this.id])return null;var t=i[this.id].sizeArray;if(!t||!t.length)return null;if(void 0===e){for(var o=[],r=0;r<t.length;r++)o.push({left:0,top:t[r].beforeHeight,width:t[r].width,height:t[r].height});return o}return(e=parseInt(e,10))>=t.length||e<0?null:{left:0,top:t[e].beforeHeight,width:t[e].width,height:t[e].height}},s.prototype.getScrollTop=function(){return this.checkComp(),this.comp.currentScrollTop||0},s.prototype.transformRpx=s.transformRpx=function(e,t){return"number"==typeof e&&(e+="rpx"),parseFloat(h.transformRpx(e,t))},s.prototype.getViewportItems=function(e){this.checkComp();var t=this.comp.getIndexesInViewport(e);if(t.length<=0)return[];for(var o=[],r=i[this.id].list,n=0;n<t.length;n++)o.push(r[t[n]]);return o},s.prototype.getTotalHeight=function(){return this.checkComp(),this.comp.getTotalHeight()},s.prototype.getList=function(){return i[this.id]?i[this.id].list:[]},e.exports=s},function(e,t,o){var r=o(1);e.exports=function(e,t){var o=e.detail,i=[],n=r[o.id];if(n&&n.list){var h=n.list,a=o.data,s=a.beginIndex,c=a.endIndex;if(n.pos=a,void 0===s||-1===s||void 0===c||-1===c)i=[];else{var l=-1;for(l=s;l<h.length&&l<=c;l++)l>=a.ignoreBeginIndex&&l<=a.ignoreEndIndex||i.push(h[l])}var p={};p[n.key]=i;var u=this.selectComponent("#"+o.id);p[u.data.batchKey]=!this.data.batchSetRecycleData,u._setInnerBeforeAndAfterHeight({beforeHeight:a.minTop,afterHeight:a.afterHeight}),this.setData(p,function(){"function"==typeof t&&t()})}}}]); |