提交 10064323 编写于 作者: fxy060608's avatar fxy060608

build v3 service

上级 f5fa4b19
...@@ -3838,17 +3838,19 @@ var serviceContext = (function () { ...@@ -3838,17 +3838,19 @@ var serviceContext = (function () {
* 动态设置 tabBar 某一项的内容 * 动态设置 tabBar 某一项的内容
*/ */
function setTabBarItem$1 (index, text, iconPath, selectedIconPath) { function setTabBarItem$1 (index, text, iconPath, selectedIconPath) {
const item = {}; const item = {
index
};
if (text !== undefined) {
item.text = text;
}
if (iconPath) { if (iconPath) {
item.iconPath = getRealPath$1(iconPath); item.iconPath = getRealPath$1(iconPath);
} }
if (selectedIconPath) { if (selectedIconPath) {
item.selectedIconPath = getRealPath$1(selectedIconPath); item.selectedIconPath = getRealPath$1(selectedIconPath);
} }
tabBar && tabBar.setTabBarItem(Object.assign({ tabBar && tabBar.setTabBarItem(item);
index,
text
}, item));
} }
/** /**
* 动态设置 tabBar 的整体样式 * 动态设置 tabBar 的整体样式
...@@ -7056,12 +7058,27 @@ var serviceContext = (function () { ...@@ -7056,12 +7058,27 @@ var serviceContext = (function () {
errMsg: 'setTabBarStyle:fail not TabBar page' errMsg: 'setTabBarStyle:fail not TabBar page'
} }
} }
tabBar$1.setTabBarStyle({ const style = {};
color, const borderStyles = {
selectedColor, black: 'rgba(0,0,0,0.4)',
backgroundColor, white: 'rgba(255,255,255,0.4)'
borderStyle: borderStyle === 'white' ? '#ffffff' : '#c6c6c6' };
}); if (color) {
style.color = color;
}
if (selectedColor) {
style.selectedColor = selectedColor;
}
if (backgroundColor) {
style.backgroundColor = backgroundColor;
}
if (borderStyle in borderStyles) {
borderStyle = borderStyles[borderStyle];
}
if (borderStyle) {
style.borderStyle = borderStyle;
}
tabBar$1.setTabBarStyle(style);
return { return {
errMsg: 'setTabBarStyle:ok' errMsg: 'setTabBarStyle:ok'
} }
...@@ -8994,7 +9011,7 @@ var serviceContext = (function () { ...@@ -8994,7 +9011,7 @@ var serviceContext = (function () {
} }
const handleVdData = { const handleVdData = {
[UI_EVENT]: function onUIEvent(vdBatchEvent, vd) { [UI_EVENT]: function onUIEvent (vdBatchEvent, vd) {
vdBatchEvent.forEach(([cid, nid, event]) => { vdBatchEvent.forEach(([cid, nid, event]) => {
console.log(`[EVENT]`, cid, nid, event); console.log(`[EVENT]`, cid, nid, event);
event.preventDefault = noop; event.preventDefault = noop;
...@@ -9008,14 +9025,14 @@ var serviceContext = (function () { ...@@ -9008,14 +9025,14 @@ var serviceContext = (function () {
} }
}; };
function onVdSync$1(vdBatchData, vd) { function onVdSync$1 (vdBatchData, vd) {
vdBatchData.forEach(([type, vdData]) => { vdBatchData.forEach(([type, vdData]) => {
handleVdData[type](vdData, vd); handleVdData[type](vdData, vd);
}); });
} }
class VDomSync { class VDomSync {
constructor(pageId, pagePath) { constructor (pageId, pagePath) {
this.pageId = pageId; this.pageId = pageId;
this.pagePath = pagePath; this.pagePath = pagePath;
this.batchData = []; this.batchData = [];
...@@ -9027,47 +9044,47 @@ var serviceContext = (function () { ...@@ -9027,47 +9044,47 @@ var serviceContext = (function () {
this._init(); this._init();
} }
_init() { _init () {
registerVdSync(this.pageId, (vdBatchData) => { registerVdSync(this.pageId, (vdBatchData) => {
onVdSync$1(vdBatchData, this); onVdSync$1(vdBatchData, this);
}); });
} }
addMountedVm(vm) { addMountedVm (vm) {
vm._$mounted(); // 触发vd数据同步 vm._$mounted(); // 触发vd数据同步
this.addVdSyncCallback(function mounted() { this.addVdSyncCallback(function mounted () {
vm.__call_hook('mounted'); vm.__call_hook('mounted');
}); });
} }
addUpdatedVm(vm) { addUpdatedVm (vm) {
vm._$updated(); // 触发vd数据同步 vm._$updated(); // 触发vd数据同步
this.addVdSyncCallback(function mounted() { this.addVdSyncCallback(function mounted () {
vm.__call_hook('updated'); vm.__call_hook('updated');
}); });
} }
addVdSyncCallback(callback) { addVdSyncCallback (callback) {
isFn(callback) && vdSyncCallbacks.push(callback); isFn(callback) && vdSyncCallbacks.push(callback);
} }
getVm(id) { getVm (id) {
return this.vms[id] return this.vms[id]
} }
addVm(vm) { addVm (vm) {
this.vms[vm._$id] = vm; this.vms[vm._$id] = vm;
} }
removeVm(vm) { removeVm (vm) {
delete this.vms[vm._$id]; delete this.vms[vm._$id];
} }
addElement(elm) { addElement (elm) {
this.elements.indexOf(elm) === -1 && this.elements.push(elm); this.elements.indexOf(elm) === -1 && this.elements.push(elm);
} }
removeElement(elm) { removeElement (elm) {
const elmIndex = this.elements.indexOf(elm); const elmIndex = this.elements.indexOf(elm);
if (elmIndex === -1) { if (elmIndex === -1) {
return console.error(`removeElement[${elm.cid}][${elm.nid}] not found`) return console.error(`removeElement[${elm.cid}][${elm.nid}] not found`)
...@@ -9075,11 +9092,11 @@ var serviceContext = (function () { ...@@ -9075,11 +9092,11 @@ var serviceContext = (function () {
this.elements.splice(elmIndex, 1); this.elements.splice(elmIndex, 1);
} }
push(type, cid, data) { push (type, cid, data) {
this.batchData.push([type, [cid, data]]); this.batchData.push([type, [cid, data]]);
} }
flush() { flush () {
if (!this.initialized) { if (!this.initialized) {
this.initialized = true; this.initialized = true;
this.batchData.push([PAGE_CREATED, [this.pageId, this.pagePath]]); this.batchData.push([PAGE_CREATED, [this.pageId, this.pagePath]]);
...@@ -9095,7 +9112,7 @@ var serviceContext = (function () { ...@@ -9095,7 +9112,7 @@ var serviceContext = (function () {
} }
} }
destroy() { destroy () {
this.batchData.length = 0; this.batchData.length = 0;
this.vms = Object.create(null); this.vms = Object.create(null);
this.initialized = false; this.initialized = false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册