|
@ -17,8 +17,7 @@ |
|
|
:data-uid="userId" |
|
|
:data-uid="userId" |
|
|
:pluginInfo="pluginInfo" |
|
|
:pluginInfo="pluginInfo" |
|
|
:change:pluginInfo="project.renderDom" |
|
|
:change:pluginInfo="project.renderDom" |
|
|
:pluginTaskId="pluginTaskId" |
|
|
|
|
|
:change:pluginTaskId="project.initPluginTaskId" |
|
|
|
|
|
></view> |
|
|
></view> |
|
|
</view> |
|
|
</view> |
|
|
</template> |
|
|
</template> |
|
@ -39,18 +38,25 @@ export default { |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
pluginInfo: null, |
|
|
pluginInfo: null, |
|
|
|
|
|
configInfo: null |
|
|
}; |
|
|
}; |
|
|
}, |
|
|
}, |
|
|
computed: { |
|
|
computed: { |
|
|
...mapState(['allPlugin']), |
|
|
...mapState(['allPlugin', 'businessPlugin']), |
|
|
...mapState('role', ['roleId']), |
|
|
...mapState('role', ['roleId']), |
|
|
...mapState('user', ['token']), |
|
|
...mapState('user', ['token']), |
|
|
...mapGetters('project', ['projectId']), |
|
|
...mapGetters('project', ['projectId']), |
|
|
...mapGetters('user', ['userId']), |
|
|
...mapGetters('user', ['userId']), |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
mounted() { |
|
|
async mounted() { |
|
|
this.getPlugin(); |
|
|
await this.getPlugin(); |
|
|
|
|
|
if (this.param && this.pluginInfo) { |
|
|
|
|
|
let configParam = JSON.parse(this.param); |
|
|
|
|
|
this.pluginInfo.config = `var p${this.pluginId}_config = ${this.param}`; |
|
|
|
|
|
} else { |
|
|
|
|
|
await this.getConfig(); |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
getPlugin() { |
|
|
getPlugin() { |
|
@ -59,8 +65,9 @@ export default { |
|
|
// 有本地数据 |
|
|
// 有本地数据 |
|
|
try { |
|
|
try { |
|
|
const pluginLists = JSON.parse(allPlugin); |
|
|
const pluginLists = JSON.parse(allPlugin); |
|
|
// pluginLists 肯能没有find方法,交给catch处理 |
|
|
// pluginLists 可能没有find方法,交给catch处理 |
|
|
const pluginTarget = pluginLists.find(item => item.id === this.pluginId); |
|
|
const pluginTarget = pluginLists.find(item => item.id === this.pluginId); |
|
|
|
|
|
pluginTarget.pluginTaskId = this.pluginTaskId; |
|
|
this.pluginInfo = pluginTarget || null; |
|
|
this.pluginInfo = pluginTarget || null; |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.error('error: ', error); |
|
|
console.error('error: ', error); |
|
@ -74,11 +81,39 @@ export default { |
|
|
console.error('err: ', err); |
|
|
console.error('err: ', err); |
|
|
this.pluginInfo = null; |
|
|
this.pluginInfo = null; |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
res.pluginTaskId = this.pluginTaskId; |
|
|
this.pluginInfo = res || null; |
|
|
this.pluginInfo = res || null; |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
getConfig() { |
|
|
|
|
|
const businessPlugin = this.businessPlugin || uni.$storage.getStorageSync('businessPlugin'); |
|
|
|
|
|
if (businessPlugin && JSON.parse(businessPlugin)) { |
|
|
|
|
|
// 有本地数据 |
|
|
|
|
|
const businessPluginLists = JSON.parse(businessPlugin); |
|
|
|
|
|
businessPluginLists.forEach(item => { |
|
|
|
|
|
if (item.pluginConfigs) { |
|
|
|
|
|
const pluginConfig = item.pluginConfigs.find(plugin => plugin.businessPluginId === this.businessPluginId); |
|
|
|
|
|
if (pluginConfig && pluginConfig.config && this.pluginInfo) { |
|
|
|
|
|
this.pluginInfo.config = pluginConfig.config; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
// 没有本地数据 API 查询 |
|
|
|
|
|
// const params = { businessPluginId: this.businessPluginId }; |
|
|
|
|
|
// uni.$catchReq.getOtherPlugin(params, (err, res) => { |
|
|
|
|
|
// if (err) { |
|
|
|
|
|
// console.error('err: ', err); |
|
|
|
|
|
// this.pluginInfo = null; |
|
|
|
|
|
// } else { |
|
|
|
|
|
// this.pluginInfo = res || null; |
|
|
|
|
|
// } |
|
|
|
|
|
// }); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
}; |
|
|
}; |
|
|
</script> |
|
|
</script> |
|
@ -99,10 +134,16 @@ export default { |
|
|
if (res.html) { |
|
|
if (res.html) { |
|
|
// 注意: 截止目前版本2022年1月30日 直接this.pluginTaskId在APP端是不能行的 |
|
|
// 注意: 截止目前版本2022年1月30日 直接this.pluginTaskId在APP端是不能行的 |
|
|
// 已向官方提交bug 后期等待修复后 再做调整 |
|
|
// 已向官方提交bug 后期等待修复后 再做调整 |
|
|
const content = window.document.getElementById(`render-${pluginTaskId}`); |
|
|
const content = window.document.getElementById(`render-${res.pluginTaskId}`); |
|
|
content.innerHTML = res.html; |
|
|
content.innerHTML = res.html; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (res.config) { |
|
|
|
|
|
const script = window.document.createElement('script'); |
|
|
|
|
|
script.innerHTML = res.config; |
|
|
|
|
|
window.document.body.appendChild(script); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (res.js) { |
|
|
if (res.js) { |
|
|
const script = window.document.createElement('script'); |
|
|
const script = window.document.createElement('script'); |
|
|
script.innerHTML = res.js; |
|
|
script.innerHTML = res.js; |
|
@ -116,9 +157,9 @@ export default { |
|
|
* 因为目前这里没办法通过this拿到prop data下的数据 |
|
|
* 因为目前这里没办法通过this拿到prop data下的数据 |
|
|
* @param {string} propsPluginTaskId |
|
|
* @param {string} propsPluginTaskId |
|
|
*/ |
|
|
*/ |
|
|
initPluginTaskId(propsPluginTaskId) { |
|
|
// initPluginTaskId(propsPluginTaskId) { |
|
|
pluginTaskId = propsPluginTaskId; |
|
|
// pluginTaskId = propsPluginTaskId; |
|
|
} |
|
|
// } |
|
|
}, |
|
|
}, |
|
|
}; |
|
|
}; |
|
|
</script> |
|
|
</script> |
|
|