- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡 - 药品百科: 搜索 + 分类筛选 + 20种药品静态数据 - 惠教中心: 4条药品使用指南课程 - 我的: 家庭成员信息管理 - 自定义TabBar + navigation-bar组件 - SVG药品分类插图
1 line
27 KiB
JavaScript
1 line
27 KiB
JavaScript
"use strict";var _constant=require("../../../utils/constant"),_comment=require("../../../utils/comment"),_autoReply=require("../../../utils/autoReply"),_notification=require("../../../utils/notification"),_theme=require("../../../utils/theme"),_utils=_interopRequireDefault(require("../../../utils/utils"));function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}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)}function _regeneratorRuntime(){_regeneratorRuntime=function(){return t};var t={},e=Object.prototype,o=e.hasOwnProperty,r=Object.defineProperty||function(t,e,o){t[e]=o.value},n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",l=n.toStringTag||"@@toStringTag";function s(t,e,o){return Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,o){return t[e]=o}}function u(t,e,o,n){var i=e&&e.prototype instanceof h?e:h,a=Object.create(i.prototype),l=new A(n||[]);return r(a,"_invoke",{value:I(t,o,l)}),a}function c(t,e,o){try{return{type:"normal",arg:t.call(e,o)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var d={};function h(){}function f(){}function m(){}var p={};s(p,i,function(){return this});var v=Object.getPrototypeOf,_=v&&v(v(L([])));_&&_!==e&&o.call(_,i)&&(p=_);var y=m.prototype=h.prototype=Object.create(p);function g(t){["next","throw","return"].forEach(function(e){s(t,e,function(t){return this._invoke(e,t)})})}function C(t,e){function n(r,i,a,l){var s=c(t[r],t,i);if("throw"!==s.type){var u=s.arg,d=u.value;return d&&"object"==_typeof(d)&&o.call(d,"__await")?e.resolve(d.__await).then(function(t){n("next",t,a,l)},function(t){n("throw",t,a,l)}):e.resolve(d).then(function(t){u.value=t,a(u)},function(t){return n("throw",t,a,l)})}l(s.arg)}var i;r(this,"_invoke",{value:function(t,o){function r(){return new e(function(e,r){n(t,o,e,r)})}return i=i?i.then(r,r):r()}})}function I(t,e,o){var r="suspendedStart";return function(n,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===n)throw i;return{value:void 0,done:!0}}for(o.method=n,o.arg=i;;){var a=o.delegate;if(a){var l=R(a,o);if(l){if(l===d)continue;return l}}if("next"===o.method)o.sent=o._sent=o.arg;else if("throw"===o.method){if("suspendedStart"===r)throw r="completed",o.arg;o.dispatchException(o.arg)}else"return"===o.method&&o.abrupt("return",o.arg);r="executing";var s=c(t,e,o);if("normal"===s.type){if(r=o.done?"completed":"suspendedYield",s.arg===d)continue;return{value:s.arg,done:o.done}}"throw"===s.type&&(r="completed",o.method="throw",o.arg=s.arg)}}}function R(t,e){var o=e.method,r=t.iterator[o];if(void 0===r)return e.delegate=null,"throw"===o&&t.iterator.return&&(e.method="return",e.arg=void 0,R(t,e),"throw"===e.method)||"return"!==o&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+o+"' method")),d;var n=c(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,d;var i=n.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,d):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function b(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function L(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r<t.length;)if(o.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return n.next=n}}return{next:S}}function S(){return{value:void 0,done:!0}}return f.prototype=m,r(y,"constructor",{value:m,configurable:!0}),r(m,"constructor",{value:f,configurable:!0}),f.displayName=s(m,l,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,m):(t.__proto__=m,s(t,l,"GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},g(C.prototype),s(C.prototype,a,function(){return this}),t.AsyncIterator=C,t.async=function(e,o,r,n,i){void 0===i&&(i=Promise);var a=new C(u(e,o,r,n),i);return t.isGeneratorFunction(o)?a:a.next().then(function(t){return t.done?t.value:a.next()})},g(y),s(y,l,"Generator"),s(y,i,function(){return this}),s(y,"toString",function(){return"[object Generator]"}),t.keys=function(t){var e=Object(t),o=[];for(var r in e)o.push(r);return o.reverse(),function t(){for(;o.length;){var r=o.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=L,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!t)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(o,r){return a.type="throw",a.arg=t,e.next=o,r&&(e.method="next",e.arg=void 0),!!r}for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var l=o.call(i,"catchLoc"),s=o.call(i,"finallyLoc");if(l&&s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(l){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.finallyLoc===t)return this.complete(o.completion,o.afterLoc),b(o),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc===t){var r=o.completion;if("throw"===r.type){var n=r.arg;b(o)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,o){return this.delegate={iterator:L(t),resultName:e,nextLoc:o},"next"===this.method&&(this.arg=void 0),d}},t}function _toConsumableArray(t){return _arrayWithoutHoles(t)||_iterableToArray(t)||_unsupportedIterableToArray(t)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var o=Object.prototype.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?_arrayLikeToArray(t,e):void 0}}function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var o=0,r=new Array(e);o<e;o++)r[o]=t[o];return r}function asyncGeneratorStep(t,e,o,r,n,i,a){try{var l=t[i](a),s=l.value}catch(t){return void o(t)}l.done?e(s):Promise.resolve(s).then(r,n)}function _asyncToGenerator(t){return function(){var e=this,o=arguments;return new Promise(function(r,n){var i=t.apply(e,o);function a(t){asyncGeneratorStep(i,r,n,a,l,"next",t)}function l(t){asyncGeneratorStep(i,r,n,a,l,"throw",t)}a(void 0)})}}function ownKeys(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,r)}return o}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(o),!0).forEach(function(e){_defineProperty(t,e,o[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):ownKeys(Object(o)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))})}return t}function _defineProperty(t,e,o){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var r=o.call(t,e||"default");if("object"!==_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}var MAX_IMAGE_WIDTH_RPX=240,MAX_IMAGE_HEIGHT_RPX=240,MIN_IMAGE_SIZE_RPX=96,DEFAULT_IMAGE_STYLE="width: ".concat(MAX_IMAGE_WIDTH_RPX,"rpx; height: ").concat(MAX_IMAGE_WIDTH_RPX,"rpx;"),DEFAULT_AUDIENCE_AVATAR_URL="https://p1-live.byteimg.com/tos-cn-i-gjr78lqtd0/f74a4e2ec63e461ba760a4a70d8e933f~tplv-gjr78lqtd0-image.image",DEFAULT_PRESENTER_AVATAR_URL="https://p1-live.byteimg.com/tos-cn-i-gjr78lqtd0/0acb611f9d304c368b45d15373ac2542~tplv-gjr78lqtd0-image.image",DEFAULT_PRESENTER_NAME="主持人",DEFAULT_PRESENTER_TAG_BACKGROUND_COLOR="#FA9600";Component({properties:{sdkInstance:{type:Object,value:null},chatFontSize:{type:Number,value:null},isLandscape:{type:Boolean,value:!1}},data:{_chatFontSize:28,_chatFontSizeStyle:_utils.default.scaleNumberBySystemFont(28,"rpx"),chatList:[],filterListCount:0,hasHistory:!0,loading:!1,enhanced:!0,ColorThemeIndex:"light",MobileChatBackgroundColor:_utils.default.hexToRGBA("#000","24"),FontColor:"#FFFFFF",InteractionColor:"#FAFBFC",IsUseDarkTheme:!1,PresenterChatColor:DEFAULT_PRESENTER_TAG_BACKGROUND_COLOR,PresenterTagBackgroundColor:DEFAULT_PRESENTER_TAG_BACKGROUND_COLOR,PresenterName:DEFAULT_PRESENTER_NAME,scrollIntoViewId:"",newCount:0,isShowMoreNote:!1,scrollHeight:0,scrollViewHeight:320,isViewerLevelEnable:!1,viewerLevelMetas:[],topComment:[],topCommentPopupVisible:!1,autoReplyPanelVisible:!1,autoReplyPanelItem:null,autoReplyNoticeVisible:!1,autoReplyNoticeItem:null,dismissedAutoReplyId:"",imageStyleMap:{},showAvatar:!1,avatarErrorMap:{},systemNoticeVisible:!0},lifetimes:{created:function(){this._emojiMap={}},ready:function(){var t=this;try{wx.createSelectorQuery().in(this).select("#chat-scrollview").boundingClientRect(function(e){e&&e.height&&_utils.default.setDataIfChanged(t,{scrollViewHeight:e.height})}).exec()}catch(t){console.error("measure scroll-view height failed",t)}},detached:function(){var t;null===(t=this.unsub)||void 0===t||t.call(this),this._clearAutoReplyNoticeTimer()}},observers:{"chatFontSize, sdkInstance":function(t,e){var o=28;if(null!==t)o=t;else if(e){var r=e.store.get("mainInfo.chatFontSize");"number"==typeof r&&(o=r)}var n=_utils.default.scaleNumberBySystemFont(o,"rpx");this.data._chatFontSize===o&&this.data._chatFontSizeStyle===n||this.setData({_chatFontSize:o,_chatFontSizeStyle:n})},sdkInstance:function(t){var e=this;if(t){this.sdkInstance=t,this.store=t.store;var o=this;this._normalizeMsgId=function(t){return null==t||""===t?null:String(t)},this._getItemMsgIds=function(t){var o,r,n;return[null==t||null===(o=t.Common)||void 0===o?void 0:o.MsgId,null==t||null===(r=t.Common)||void 0===r?void 0:r.H5MsgId,null==t||null===(n=t.Common)||void 0===n?void 0:n._formerMsgId_].map(e._normalizeMsgId).filter(Boolean)};var r=1;"function"==typeof this.unsub&&this.unsub(),this.unsub=null,this.unsub=this.store.get({"chat.chatList":function(t){var e=o._refreshChatListState(t);1===r&&e.filterListCount&&(o.scrollToBottom(),r++)},"chat.topComment":function(t){o._refreshChatState({topComment:t})},"chat.emojiMap":function(t){o.updateEmojiMap(t||{})},"chat.addComment":function(t){var r=t||{},n=r.data,i=r.isSend;if(n&&n.length)if(o._tryShowAutoReplyNotice(n),o.data.scrollHeight<40||i)o.scrollToBottom();else if(e.data.scrollHeight>40){var a=n.filter(_autoReply.shouldCountAddCommentForUnread);if(!a.length)return;o.setData({newCount:o.data.newCount+a.length,isShowMoreNote:!0})}},liveInfo:function(t){if(null!=t&&t.CommentConfig){var e=t.CommentConfig.PresenterName||DEFAULT_PRESENTER_NAME;_utils.default.setDataIfChanged(o,{PresenterName:e},function(){var t=o.store.get("chat.topComment")||[];o._refreshRenderedChatList(o.store.get("chat.chatList")||[],t),o.setData({topComment:o._getProcessedTopComment(t)})})}if(null!=t&&t.Basic){var r,n=null!==(r=null==t?void 0:t.Basic)&&void 0!==r?r:{},i=n.ViewerLevelConfig,a=n.IsAvatarShowEnable,l=(0,_theme.resolveLiveThemeConfig)(t.Basic),s=o.data.isLandscape||1===Number(t.Basic.IsColorSync),u=(0,_theme.resolveLiveThemeConfig)({ColorThemeIndex:"dark"}),c=s?l.PresenterChatColor:DEFAULT_PRESENTER_TAG_BACKGROUND_COLOR,d=s?l:_objectSpread(_objectSpread({},l),{},{MobileChatBackgroundColor:"#000000",FontColor:"#FFFFFF",PresenterChatColor:u.PresenterChatColor}),h={MobileChatBackgroundColor:_utils.default.hexToRGBA(d.MobileChatBackgroundColor,"24"),PresenterChatColor:d.PresenterChatColor,PresenterTagBackgroundColor:c,FontColor:d.FontColor,InteractionColor:l.InteractionColor,ColorThemeIndex:l.ColorThemeIndex,IsUseDarkTheme:(0,_theme.isUseDarkTheme)(t.Basic)};(0,_theme.isThemeStateChanged)(h,o.data,_theme.CHAT_THEME_STATE_KEYS)&&o.setData(h);var f=1===(null==i?void 0:i.IsViewerLevelEnable),m=(null==i?void 0:i.ViewerLevelMetas)||[];(o.data.isViewerLevelEnable!==f||JSON.stringify(o.data.viewerLevelMetas)!==JSON.stringify(m))&&o.setData({isViewerLevelEnable:f,viewerLevelMetas:m},function(){o._refreshRenderedChatList(o.store.get("chat.chatList")||[])});var p=(0,_notification.isOpenSwitch)(a);_utils.default.setDataIfChanged(o,{showAvatar:p},function(){o._refreshRenderedChatList(o.store.get("chat.chatList")||[])}),(0,_notification.syncNotificationState)(o.store,t)}},"notification.isNotificationOpen":function(t){_utils.default.setDataIfChanged(o,{systemNoticeVisible:!!t})}})}},chatList:function(t){}},methods:{_capChatList:function(t){return t.length>_constant.MAX_CHAT_COUNT?t.slice(-_constant.MAX_CHAT_COUNT):t},_getProcessedTopComment:function(t){var e=this._processChatListWithLevel(t||[]);return this._normalizeRenderedChatList(e)},_getDeletedMsgIdSet:function(){return new Set((this.store.get("chat.deletedMsgIds")||[]).map(this._normalizeMsgId).filter(Boolean))},_filterVisibleChatItems:function(t,e){var o=this,r=this._getDeletedMsgIdSet();return(t||[]).filter(function(n){var i,a,l;return!(null!==(i=n.Extra)&&void 0!==i&&i.IsDelete||(null==n||null===(a=n.Common)||void 0===a?void 0:a.MsgId)===e||!(null!==(l=n.Extra)&&void 0!==l&&l.TextContent||(0,_autoReply.isAutoReplyComment)(n))||!(0,_autoReply.isAutoReplyAnchorVisible)(n,t)||o._getItemMsgIds(n).some(function(t){return r.has(t)}))})},_getDerivedListState:function(t,e){var o=this._capChatList(this._filterVisibleChatItems(t,e));return{chatList:this._normalizeRenderedChatList(this._processChatListWithLevel(o)),filterListCount:this._capChatList(o.filter(function(t){var e,o;return!(null!==(e=t.Extra)&&void 0!==e&&e._welcomeInfo_||null!==(o=t.Extra)&&void 0!==o&&o._operationInfo_)})).length}},_getProcessedChatList:function(t){var e,o,r,n,i,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.store.get("chat.topComment")||[],l=(null===(e=this.data.topComment)||void 0===e||null===(o=e[0])||void 0===o||null===(r=o.Common)||void 0===r?void 0:r.MsgId)||(null==a||null===(n=a[0])||void 0===n||null===(i=n.Common)||void 0===i?void 0:i.MsgId),s=this._capChatList(this._filterVisibleChatItems(t,l));return this._normalizeRenderedChatList(this._processChatListWithLevel(s))},updateEmojiMap:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=Object.keys(this._emojiMap||{}).length>0,o=Object.keys(t).length>0;this._emojiMap=t,(e||o)&&this._refreshChatState()},_getDerivedChatState:function(t,e){var o,r,n=this._getProcessedTopComment(e),i=null===(o=n[0])||void 0===o||null===(r=o.Common)||void 0===r?void 0:r.MsgId,a=this._getDerivedListState(t,i);return{topComment:n,chatList:a.chatList,filterListCount:a.filterListCount}},_refreshChatListState:function(t){var e,o,r,n,i,a=this,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.store.get("chat.topComment")||[],s=(null===(e=this.data.topComment)||void 0===e||null===(o=e[0])||void 0===o||null===(r=o.Common)||void 0===r?void 0:r.MsgId)||(null==l||null===(n=l[0])||void 0===n||null===(i=n.Common)||void 0===i?void 0:i.MsgId),u=this._getDerivedListState(t,s);return this.setData(u,function(){a._markInitialCommentRendered()}),u},_markInitialCommentRendered:function(){var t,e,o,r;null===(t=this.store)||void 0===t||null===(e=t.get)||void 0===e||!e.call(t,"ui.commentInitialDataLoaded")||null!==(o=this.store)&&void 0!==o&&null!==(r=o.get)&&void 0!==r&&r.call(o,"ui.commentInitialRendered")||this.store.set("ui.commentInitialRendered",!0)},_refreshRenderedChatList:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.store.get("chat.topComment")||[],o=this._getProcessedChatList(t,e);return this.setData({chatList:o}),o},_refreshImageRenderState:function(){var t,e,o=(null===(t=this.store)||void 0===t?void 0:t.get("chat.chatList"))||[],r=(null===(e=this.store)||void 0===e?void 0:e.get("chat.topComment"))||[];this.setData({chatList:this._getProcessedChatList(o,r),topComment:this._getProcessedTopComment(r)})},_refreshChatState:function(){var t,e,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=this._getDerivedChatState(null!==(t=o.chatList)&&void 0!==t?t:this.store.get("chat.chatList")||[],null!==(e=o.topComment)&&void 0!==e?e:this.store.get("chat.topComment")||[]);return this.setData(r),r},handleTopCommentTap:function(){var t,e,o=null===(t=this.data.topComment)||void 0===t?void 0:t[0],r=null==o||null===(e=o.Extra)||void 0===e?void 0:e._renderType_;o&&"photo"!==r&&"big-emoji"!==r&&this.setData({topCommentPopupVisible:!0})},closeTopCommentPopup:function(){this.data.topCommentPopupVisible&&this.setData({topCommentPopupVisible:!1})},catchNone:function(){},onTopCommentDrawerClose:function(){this.closeTopCommentPopup()},newCountClick:function(){this.scrollToBottom(),this.setData({newCount:0,isShowMoreNote:!1})},scrollToBottom:function(){var t=this;setTimeout(function(){var e,o,r,n=null===(e=t.data.chatList)||void 0===e?void 0:e.length;_utils.default.setDataIfChanged(t,{scrollIntoViewId:"view"+(null===(o=t.data.chatList[n-1])||void 0===o||null===(r=o.Common)||void 0===r?void 0:r.MsgId)})},500)},getHistoryList:function(){var t=this;return _asyncToGenerator(_regeneratorRuntime().mark(function e(){var o,r,n,i,a,l,s,u,c,d,h,f,m,p,v,_,y,g,C,I,R,E,b;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,n=t.data,i=n.hasHistory,a=n.loading,l=t.store.get("mainInfo"),(s=l.activityId)&&i&&!a){e.next=5;break}return e.abrupt("return");case 5:if(!((null==(u=t.store.get("chat.chatList")||[])?void 0:u.length)>=_constant.MAX_CHAT_COUNT)){e.next=9;break}return t.setData({loading:!1,hasHistory:!1}),e.abrupt("return");case 9:return c=t.store.get("userInfo"),d=c.userId,h={ActivityId:s,Id:t.store.get("chat.commentStartId"),UserId:d,Count:25,Status:2,Context:""},t.setData({loading:!0}),e.next=14,t.sdkInstance.request(_constant.REQUEST_URL_MAP.SEARCH_COMMENT,{method:"GET",data:h});case 14:f=e.sent,(m=(null==f?void 0:f.Data)||[]).reverse(),p=new Set((t.store.get("chat.deletedMsgIds")||[]).map(t._normalizeMsgId).filter(Boolean)),v=m.filter(function(e){return!u.some(function(o){var r,n;return t._normalizeMsgId(null===(r=o.Common)||void 0===r?void 0:r.MsgId)===t._normalizeMsgId(null===(n=e.Common)||void 0===n?void 0:n.MsgId)})&&!t._getItemMsgIds(e).some(function(t){return p.has(t)})}),m.length&&(g=t.store.get("userInfo.userId"),C=(0,_autoReply.suppressAutoReplyPanelOnInit)((0,_autoReply.expandAutoReplyComments)(v,g,u,!0),!0),I=C.filter(function(t){return!(0,_autoReply.isAutoReplyComment)(t)}),R=C.filter(_autoReply.isAutoReplyComment),E=(0,_autoReply.mergeAutoReplyByAnchor)([].concat(_toConsumableArray(I),_toConsumableArray(u)),R),b=E.length>_constant.MAX_CHAT_COUNT?E.slice(-_constant.MAX_CHAT_COUNT):E,t.store.set("chat.chatList",b),t.store.set("chat.commentStartId",null===(_=m[0])||void 0===_||null===(y=_.Common)||void 0===y?void 0:y.MsgId)),t.setData({loading:!1,hasHistory:m.length>=25,scrollIntoViewId:"view"+((null===(o=v[v.length-1])||void 0===o||null===(r=o.Common)||void 0===r?void 0:r.MsgId)||"")}),e.next=27;break;case 23:e.prev=23,e.t0=e.catch(0),console.error("error",e.t0),t.setData({loading:!1});case 27:case"end":return e.stop()}},e,null,[[0,23]])}))()},bindscroll:function(t){var e=t.detail||{},o=e.scrollHeight,r=e.scrollTop;this.data.scrollHeight=o-r-this.data.scrollViewHeight,this.data.scrollHeight<40&&this.data.newCount&&this.setData({newCount:0,isShowMoreNote:!1})},getLevelMeta:function(t){if(!this.data.isViewerLevelEnable||!t)return null;var e=String(t);return this.data.viewerLevelMetas.find(function(t){return String(t.LevelId)===e})||null},previewCommentImage:function(t){var e=t.currentTarget.dataset.src;e&&this.triggerEvent("previewimage",{src:e})},handleCommentImageLoad:function(t){var e=this,o=t.detail||{},r=o.width,n=o.height,i=t.currentTarget.dataset||{},a=i.msgId,l=i.src;if(r&&n&&(a||l)){var s=this.buildImageStyle(r,n),u=_objectSpread(_objectSpread(_objectSpread({},this.data.imageStyleMap),a?_defineProperty({},"msg_".concat(a),s):{}),l?_defineProperty({},"src_".concat(l),s):{});(this.data.imageStyleMap["msg_".concat(a)]||this.data.imageStyleMap["src_".concat(l)])!==s&&this.setData({imageStyleMap:u},function(){e._refreshImageRenderState()})}},buildImageStyle:function(t,e){if(!t||!e)return DEFAULT_IMAGE_STYLE;var o=t/e,r=MAX_IMAGE_WIDTH_RPX,n=Math.round(r/o);return n>MAX_IMAGE_HEIGHT_RPX&&(n=MAX_IMAGE_HEIGHT_RPX,r=Math.round(n*o)),r=Math.max(MIN_IMAGE_SIZE_RPX,r),n=Math.max(MIN_IMAGE_SIZE_RPX,n),"width: ".concat(r,"rpx; height: ").concat(n,"rpx;")},handleAvatarError:function(t){var e=this,o=t.currentTarget.dataset||{},r=o.msgId,n=o.src;if(r||n){var i=_objectSpread(_objectSpread(_objectSpread({},this.data.avatarErrorMap),r?_defineProperty({},"msg_".concat(r),!0):{}),n?_defineProperty({},"src_".concat(n),!0):{});r&&this.data.avatarErrorMap["msg_".concat(r)]||n&&this.data.avatarErrorMap["src_".concat(n)]||this.setData({avatarErrorMap:i},function(){var t;e._refreshRenderedChatList((null===(t=e.store)||void 0===t?void 0:t.get("chat.chatList"))||[])})}},_normalizeRenderedChatList:function(t){var e=this;return(t||[]).map(function(t){return e._normalizeRenderedChatItem(t)})},_normalizeRenderedChatItem:function(t){var e,o,r,n,i,a,l,s,u,c,d=(0,_comment.normalizeCommentItem)(t,{emojiMap:this._emojiMap||{}}),h=null==d||null===(e=d.Extra)||void 0===e?void 0:e._previewSrc_,f=this.data.imageStyleMap["msg_".concat(null==d||null===(o=d.Common)||void 0===o?void 0:o.MsgId)]||this.data.imageStyleMap["src_".concat(h)]||("photo"===(null==d||null===(r=d.Extra)||void 0===r?void 0:r._renderType_)?DEFAULT_IMAGE_STYLE:""),m=(0,_autoReply.buildAutoReplyDisplayMeta)(d),p=(null==d||null===(n=d.Extra)||void 0===n||null===(i=n.User)||void 0===i?void 0:i.AvatarUrl)||"",v=this.data.avatarErrorMap["msg_".concat(null==d||null===(a=d.Common)||void 0===a?void 0:a.MsgId)]||this.data.avatarErrorMap["src_".concat(p)],_=null!=d&&null!==(l=d.Extra)&&void 0!==l&&l.IsPresenter?DEFAULT_PRESENTER_AVATAR_URL:DEFAULT_AUDIENCE_AVATAR_URL,y=null!=d&&null!==(s=d.Extra)&&void 0!==s&&s.IsPresenter?this.data.PresenterName||DEFAULT_PRESENTER_NAME:"";return _objectSpread(_objectSpread({},d),{},{id:(null==d||null===(u=d.Common)||void 0===u?void 0:u.MsgId)||(null==d||null===(c=d.Common)||void 0===c?void 0:c.H5MsgId)||(null==d?void 0:d.id),Extra:_objectSpread(_objectSpread({},d.Extra),{},{_imageStyle_:f,_avatarUrl_:p,_avatarLoadFailed_:!!v,_avatarDefaultUrl_:_,_presenterNickname_:y,_systemNoticeInfo_:this.isSystemNoticeItem(d)},m?{_autoReplyDisplay_:m}:{})})},_clearAutoReplyNoticeTimer:function(){null!=this._autoReplyNoticeTimer&&(clearTimeout(this._autoReplyNoticeTimer),this._autoReplyNoticeTimer=null)},_dismissAutoReplyNotice:function(t){this._clearAutoReplyNoticeTimer(),this.setData({autoReplyNoticeVisible:!1,autoReplyNoticeItem:null,dismissedAutoReplyId:t||this.data.dismissedAutoReplyId})},_tryShowAutoReplyNotice:function(t){for(var e,o=this,r=this.store.get("chat.chatList")||[],n=function(){var e,n=t[i],a=null==n||null===(e=n.Extra)||void 0===e?void 0:e._autoReplyInfo_;if(null==a||!a.IsAutoReply||!a.AutoShowPanel)return 0;if(!(0,_autoReply.isAutoReplyAnchorVisible)(n,r))return 0;var l=a.AutoReplyId;if(!l||o.data.dismissedAutoReplyId===l)return{v:void 0};var s=o._normalizeRenderedChatItem(n);return o._clearAutoReplyNoticeTimer(),o.setData({autoReplyNoticeVisible:!0,autoReplyNoticeItem:s,autoReplyPanelVisible:!1,autoReplyPanelItem:null}),o._autoReplyNoticeTimer=setTimeout(function(){o._dismissAutoReplyNotice(l)},1e3*_autoReply.AUTO_REPLY_DISPLAY.AUTO_DISMISS_SECONDS),{v:void 0}},i=t.length-1;i>=0;i-=1)if(0!==(e=n())&&e)return e.v},_openAutoReplyPanel:function(t){var e,o;null!=t&&null!==(e=t.Extra)&&void 0!==e&&null!==(o=e._autoReplyInfo_)&&void 0!==o&&o.IsAutoReply&&this.setData({autoReplyPanelVisible:!0,autoReplyPanelItem:t})},onAutoReplyTap:function(t){var e,o,r=t.currentTarget.dataset.item;if(null!=r&&null!==(e=r.Extra)&&void 0!==e&&null!==(o=e._autoReplyInfo_)&&void 0!==o&&o.IsAutoReply){var n=this._normalizeRenderedChatItem(r);this._openAutoReplyPanel(n)}},onAutoReplyNoticeView:function(){var t,e,o=this.data.autoReplyNoticeItem;if(o){var r=null==o||null===(t=o.Extra)||void 0===t||null===(e=t._autoReplyInfo_)||void 0===e?void 0:e.AutoReplyId;this._dismissAutoReplyNotice(r),this._openAutoReplyPanel(o)}},closeAutoReplyNotice:function(){var t,e,o,r=null===(t=this.data.autoReplyNoticeItem)||void 0===t||null===(e=t.Extra)||void 0===e||null===(o=e._autoReplyInfo_)||void 0===o?void 0:o.AutoReplyId;this._dismissAutoReplyNotice(r)},closeAutoReplyPanel:function(){this.data.autoReplyPanelVisible&&this.setData({autoReplyPanelVisible:!1,autoReplyPanelItem:null})},isSystemNoticeItem:function(t){var e=(null==t?void 0:t.Extra)||{};if(e._welcomeInfo_||e._operationInfo_)return!1;var o=String(e.MessageType||e.MsgType||e.NoticeType||e.SystemType||"").toLowerCase();return 1===e.IsSystemNotice||1===e.IsSystemNotification||o.includes("systemnotice")||o.includes("notification")},_processChatListWithLevel:function(t){var e,o=this;if(!this.data.isViewerLevelEnable||!t||!t.length)return t;var r=null===(e=this.store)||void 0===e?void 0:e.get("userInfo.levelId");return t.map(function(t){var e,n,i,a=1===(null==t||null===(e=t.Extra)||void 0===e?void 0:e.IsOwn),l=null==t||null===(n=t.Extra)||void 0===n||null===(i=n.User)||void 0===i?void 0:i.LevelId,s=a&&!l?r:l;if(!s)return t;var u=o.getLevelMeta(s);return u?_objectSpread(_objectSpread({},t),{},{Extra:_objectSpread(_objectSpread({},t.Extra),{},{_levelMeta_:u})}):t})}}}); |