- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡 - 药品百科: 搜索 + 分类筛选 + 20种药品静态数据 - 惠教中心: 4条药品使用指南课程 - 我的: 家庭成员信息管理 - 自定义TabBar + navigation-bar组件 - SVG药品分类插图
1 line
12 KiB
JavaScript
1 line
12 KiB
JavaScript
"use strict";function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}module.exports=function(t){var e={};function i(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,o){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"===_typeof(t)&&t&&t.__esModule)return t;var o=Object.create(null);if(i.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(o,r,function(e){return t[e]}.bind(null,r));return o},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=6)}({0:function(t,e,i){var o=!1,r=void 0,n=void 0;!function(){var t=wx.getSystemInfoSync();o="ios"===t.platform;var e=t.screenWidth||375,i=t.pixelRatio||2;e===r&&i===n||(r=e,n=i)}();var l=/([+-]?\d+(?:\.\d+)?)rpx/gi;t.exports={transformRpx:function(t,e){if("string"!=typeof t)return t;var i=l;return t.replace(i,function(t,i){return(0===(l=Number(i))?0:(l=l/750*r,0===(l=Math.floor(l+1e-4))?1!==n&&o?.5:1:l))+(e?"px":"");var l})}}},6:function(t,e,i){var o=wx.getSystemInfoSync(),r=i(0).transformRpx;Component({options:{multipleSlots:!0},relations:{"../recycle-item/recycle-item":{type:"child",linked:function(t){if(!this._hasCheckSize){this._hasCheckSize=!0;var e=this.boundingClientRect(this._pos.beginIndex);if(!e)return;setTimeout(function(){try{t.createSelectorQuery().select(".wx-recycle-item").boundingClientRect(function(t){!t||t.width===e.width&&t.height===e.height||console.warn("[recycle-view] the size in <recycle-item> is not the same with param itemSize, expect {width: "+t.width+", height: "+t.height+"} but got {width: "+e.width+", height: "+e.height+"}")}).exec()}catch(t){}},10)}}}},properties:{debug:{type:Boolean,value:!1},scrollY:{type:Boolean,value:!0},batch:{type:Boolean,value:!1,public:!0,observer:"_recycleInnerBatchDataChanged"},batchKey:{type:String,value:"batchSetRecycleData",public:!0},scrollTop:{type:Number,value:0,public:!0,observer:"_scrollTopChanged",observeAssignments:!0},height:{type:Number,value:o.windowHeight,public:!0,observer:"_heightChanged"},width:{type:Number,value:o.windowWidth,public:!0,observer:"_widthChanged"},upperThreshold:{type:Number,value:50,public:!0},lowerThreshold:{type:Number,value:50,public:!0},scrollToIndex:{type:Number,public:!0,value:0,observer:"_scrollToIndexChanged",observeAssignments:!0},scrollWithAnimation:{type:Boolean,public:!0,value:!1},enableBackToTop:{type:Boolean,public:!0,value:!1},throttle:{type:Boolean,public:!0,value:!0},placeholderImage:{type:String,public:!0,value:""},screen:{type:Number,public:!0,value:4}},data:{innerBeforeHeight:0,innerAfterHeight:0,innerScrollTop:0,innerScrollIntoView:"",placeholderImageStr:"",totalHeight:0,useInPage:!1},attached:function(){this.data.placeholderImage&&this.setData({placeholderImageStr:r(this.data.placeholderImage,!0)}),this.setItemSize({array:[],map:{},totalHeight:0})},ready:function(){var t=this;this._initPosition(function(){t._isReady=!0,t._updateTimerId||t._scrollViewDidScroll({detail:{scrollLeft:t._pos.left,scrollTop:t._pos.top,ignoreScroll:!0}},!0)})},detached:function(){this.page=null,this.context&&(this.context.destroy(),this.context=null)},methods:{_log:function(){var t;if(this.data.debug){for(var e=new Date,i=e.getHours()+":"+e.getMinutes()+":"+e.getSeconds()+"."+e.getMilliseconds(),o=arguments.length,r=Array(o),n=0;n<o;n++)r[n]=arguments[n];Array.prototype.splice.call(r,0,0,i),(t=console).log.apply(t,r)}},_scrollToUpper:function(t){this.triggerEvent("scrolltoupper",t.detail)},_scrollToLower:function(t){this.triggerEvent("scrolltolower",t.detail)},_beginToScroll:function(){this._lastScrollTop||(this._lastScrollTop=this._pos&&(this._pos.top||0))},_clearList:function(t){this.currentScrollTop=0,this._lastScrollTop=0;var e=this._pos;e.beginIndex=this._pos.endIndex=-1,e.afterHeight=e.minTop=e.maxTop=0,this.page._recycleViewportChange({detail:{data:e,id:this.id}},t)},_isValid:function(){return this.page&&this.context&&this.context.isDataReady},_scrollViewDidScroll:function(t,e){if(this._isValid())if(t.detail.ignoreScroll||this.triggerEvent("scroll",t.detail),this.currentScrollTop=t.detail.scrollTop,this._pos.height&&this.sizeArray.length)if(this._isScrollingWithAnimation)this._isScrollingWithAnimation=!1;else{var i=this._pos,o=this,r=t.detail.scrollLeft,n=t.detail.scrollTop,l=Math.abs(n-this._lastScrollTop);if(!e&&Math.abs(n-i.top)<1.5*i.height)this._log("【not exceed height");else{this._lastScrollTop=n;var s=this.data.screen;this._log("SHOW_SCREENS",s,n),this._calcViewportIndexes(r,n,function(s,h,a,c,d){o._log("scrollDistance",l,"indexes",s,h),e||i.beginIndex!==s||i.endIndex!==h||i.minTop!==a||i.afterHeight!==c?(o._log("【check】before setData, old pos is",i.minTop,i.maxTop,a,d),o._throttle=!1,i.left=r,i.top=n,i.beginIndex=s,i.endIndex=h,i.minTop=a,i.maxTop=d,i.afterHeight=c,i.ignoreBeginIndex=i.ignoreEndIndex=-1,o.page._recycleViewportChange({detail:{data:o._pos,id:o.id}},function(){t.detail.cb&&t.detail.cb()})):o._log("------------is the same beginIndex and endIndex")})}}else this._clearList(t.detail.cb)},_calcViewportIndexes:function(t,e,i){var o=this;this._getBeforeSlotHeight(function(){var r=o.__calcViewportIndexes(t,e),n=r.beginIndex,l=r.endIndex,s=r.minTop,h=r.afterHeight,a=r.maxTop;i&&i(n,l,s,h,a)})},_getBeforeSlotHeight:function(t){void 0!==this.data.beforeSlotHeight?t&&t(this.data.beforeSlotHeight):this.reRender(t)},_getAfterSlotHeight:function(t){void 0!==this.data.afterSlotHeight?t&&t(this.data.afterSlotHeight):this.reRender(t)},_getIndexes:function(t,e){if(t===e&&0===e)return{beginIndex:-1,endIndex:-1};for(var i=Math.floor(t/200),o=Math.ceil(e/200),r=Math.floor(this.data.width/200),n=void 0,l=void 0,s=this.sizeMap,h=i;h<=o;h++)for(var a=0;a<r;a++){var c=h+"."+a;if(s[c])for(var d=0;d<s[c].length;d++)void 0!==n?n>s[c][d]?n=s[c][d]:l<s[c][d]&&(l=s[c][d]):n=l=s[c][d]}return{beginIndex:n,endIndex:l}},_isIndexValid:function(t,e){return!(void 0===t||-1===t||void 0===e||-1===e||e>=this.sizeArray.length)},__calcViewportIndexes:function(t,e){if(!this.sizeArray.length)return{};var i=this._pos;void 0===t&&(t=i.left),void 0===e&&(e=i.top);var o=this.data.beforeSlotHeight||0,r=this.data.screen,n=e-i.height*r-o,l=e+i.height*r-o;l>this.totalHeight&&(n-=l-this.totalHeight,l=this.totalHeight),n<o&&(l+=Math.min(o-n,this.totalHeight),n=0);var s=this._getIndexes(n,l),h=s.beginIndex,a=s.endIndex;if(a>=this.sizeArray.length&&(a=this.sizeArray.length-1),!this._isIndexValid(h,a))return{beginIndex:-1,endIndex:-1,minTop:0,afterHeight:0,maxTop:0};var c=this.sizeArray[a].beforeHeight+this.sizeArray[a].height;return{beginIndex:h,endIndex:a,minTop:this.sizeArray[h].beforeHeight,afterHeight:this.totalHeight-c,maxTop:l}},setItemSize:function(t){this.sizeArray=t.array,this.sizeMap=t.map,t.totalHeight!==this.totalHeight&&this.setData({totalHeight:t.totalHeight,useInPage:this.useInPage||!1}),this.totalHeight=t.totalHeight},setList:function(t,e){this._currentSetDataKey=t,this._currentSetDataList=e},setPage:function(t){this.page=t},forceUpdate:function(t,e){var i=this;if(!this._isReady)return this._updateTimerId&&clearTimeout(this._updateTimerId),void(this._updateTimerId=setTimeout(function(){i.forceUpdate(t,e)},10));this._updateTimerId=null;var o=this;e?this.reRender(function(){o._scrollViewDidScroll({detail:{scrollLeft:o._pos.left,scrollTop:o.currentScrollTop||o.data.scrollTop||0,ignoreScroll:!0,cb:t}},!0)}):this._scrollViewDidScroll({detail:{scrollLeft:o._pos.left,scrollTop:o.currentScrollTop||o.data.scrollTop||0,ignoreScroll:!0,cb:t}},!0)},_initPosition:function(t){var e=this;e._pos={left:e.data.scrollLeft||0,top:e.data.scrollTop||0,width:this.data.width,height:Math.max(500,this.data.height),direction:0},this.reRender(t)},_widthChanged:function(t){return this._isReady?(this._pos.width=t,this.forceUpdate(),t):t},_heightChanged:function(t){return this._isReady?(this._pos.height=Math.max(500,t),this.forceUpdate(),t):t},reRender:function(t){var e=this,i=void 0,o=void 0,r=this;function n(){r._lastBeforeSlotHeight===i&&r._lastAfterSlotHeight===o||r.setData({hasBeforeSlotHeight:!0,hasAfterSlotHeight:!0,beforeSlotHeight:i,afterSlotHeight:o}),r._lastBeforeSlotHeight=i,r._lastAfterSlotHeight=o,t&&t()}var l=!1,s=!1;this.setData({hasBeforeSlotHeight:!1,hasAfterSlotHeight:!1},function(){e.createSelectorQuery().select(".slot-before").boundingClientRect(function(t){i=t.height,l=!0,s&&n&&n()}).exec(),e.createSelectorQuery().select(".slot-after").boundingClientRect(function(t){o=t.height,s=!0,l&&n&&n()}).exec()})},_setInnerBeforeAndAfterHeight:function(t){void 0!==t.beforeHeight&&(this._tmpBeforeHeight=t.beforeHeight),t.afterHeight&&(this._tmpAfterHeight=t.afterHeight)},_recycleInnerBatchDataChanged:function(t){var e=this;if(void 0!==this._tmpBeforeHeight){var i={innerBeforeHeight:this._tmpBeforeHeight||0,innerAfterHeight:this._tmpAfterHeight||0};void 0!==this._tmpInnerScrollTop&&(i.innerScrollTop=this._tmpInnerScrollTop);var o={},r=!1;void 0!==this._currentSetDataKey&&(o[this._currentSetDataKey]=this._currentSetDataList,r=!0);var n=this.data.scrollWithAnimation;r&&e.page.setData(o),e.setData(i,function(){e.setData({scrollWithAnimation:n}),"function"==typeof t&&t()}),delete this._currentSetDataKey,delete this._currentSetDataList,this._tmpBeforeHeight=void 0,this._tmpAfterHeight=void 0,this._tmpInnerScrollTop=void 0}},_renderByScrollTop:function(t){this._scrollViewDidScroll({detail:{scrollLeft:this._pos.scrollLeft,scrollTop:t,ignoreScroll:!0}},!0),this.data.scrollWithAnimation&&(this._isScrollingWithAnimation=!0),this.setData({innerScrollTop:t})},_scrollTopChanged:function(t,e){var i=this;return this._isInitScrollTop||0!==t?(this.currentScrollTop=t,this._isReady?(this._isInitScrollTop=!0,this._scrollTopTimerId=null,void 0===this._lastScrollTop&&(this._lastScrollTop=this.data.scrollTop),Math.abs(t-this._lastScrollTop)<this._pos.height?(this.setData({innerScrollTop:t}),t):(this._isScrollTopChanged?this._renderByScrollTop(t):setTimeout(function(){i._isScrollTopChanged=!0,i._renderByScrollTop(t)},10),t)):(this._scrollTopTimerId&&clearTimeout(this._scrollTopTimerId),this._scrollTopTimerId=setTimeout(function(){i._scrollTopChanged(t,e)},10),t)):(this._isInitScrollTop=!0,t)},_scrollToIndexChanged:function(t,e){var i=this;if(!this._isInitScrollToIndex&&0===t)return this._isInitScrollToIndex=!0,t;if(!this._isReady)return this._scrollToIndexTimerId&&clearTimeout(this._scrollToIndexTimerId),this._scrollToIndexTimerId=setTimeout(function(){i._scrollToIndexChanged(t,e)},10),t;this._isInitScrollToIndex=!0,this._scrollToIndexTimerId=null,void 0===this._lastScrollTop&&(this._lastScrollTop=this.data.scrollTop);var o=this.boundingClientRect(t);if(!o)return t;var r=o.top+(this.data.beforeSlotHeight||0);return this.currentScrollTop=r,Math.abs(r-this._lastScrollTop)<this._pos.height?(this.setData({innerScrollTop:r}),t):(this._isScrollToIndexChanged?this._renderByScrollTop(r):setTimeout(function(){i._isScrollToIndexChanged=!0,i._renderByScrollTop(r)},10),t)},boundingClientRect:function(t){return t<0||t>=this.sizeArray.length?null:{left:0,top:this.sizeArray[t].beforeHeight,width:this.sizeArray[t].width,height:this.sizeArray[t].height}},getIndexesInViewport:function(t){t||(t=1);var e=this.currentScrollTop,i=e+t;i<0&&(i=0);var o=e+this.data.height-t;o>this.totalHeight&&(o=this.totalHeight);for(var r=[],n=0;n<this.sizeArray.length&&(this.sizeArray[n].beforeHeight+this.sizeArray[n].height>=i&&this.sizeArray[n].beforeHeight<=o&&r.push(n),!(this.sizeArray[n].beforeHeight>o));n++);return r},getTotalHeight:function(){return this.totalHeight},setUseInPage:function(t){this.useInPage=t},setPlaceholderImage:function(t,e){var i=["data:image/svg+xml,%3Csvg height='"+e.height+"' width='"+e.width+"' xmlns='http://www.w3.org/2000/svg'%3E"];t.forEach(function(t){i.push("%3Crect width='"+t.width+"' x='"+t.left+"' height='"+t.height+"' y='"+t.top+"' style='fill:rgb(204,204,204);' /%3E")}),i.push("%3C/svg%3E"),this.setData({placeholderImageStr:i.join("")})}}})}}); |