Commit c37aa6233946b409ae558a646d5862d739719008
1 parent
08f28d27
1、修改lubanPageForZip.html,添加替换deviceId组件属性的功能(通过window.location.search获取外部参数,具体看代码)
Showing
1 changed file
with
19 additions
and
0 deletions
src/main/resources/templates/lubanPageForZip.html
| ... | ... | @@ -60,6 +60,17 @@ |
| 60 | 60 | |
| 61 | 61 | <!-- 处理后台work对象 --> |
| 62 | 62 | <script type="text/javascript" th:inline="javascript"> |
| 63 | + // 获取url查询参数,queryName:参数名 | |
| 64 | + function getQueryValue(queryName) { | |
| 65 | + var reg = new RegExp("(^|&)" + queryName + "=([^&]*)(&|$)", "i"); | |
| 66 | + // window.location.search(设置或获取 href 属性中跟在问号后面的部分) | |
| 67 | + var r = window.location.search.substr(1).match(reg); | |
| 68 | + if (r != null) { | |
| 69 | + return decodeURIComponent(r[2]); | |
| 70 | + } | |
| 71 | + return null; | |
| 72 | + } | |
| 73 | + | |
| 63 | 74 | (function() { |
| 64 | 75 | var work = [[${work}]]; |
| 65 | 76 | var urlItems = [[${urlItems}]]; |
| ... | ... | @@ -103,6 +114,14 @@ |
| 103 | 114 | }) |
| 104 | 115 | }); |
| 105 | 116 | |
| 117 | + // 替换deviceId属性 | |
| 118 | + var actualDeviceId = getQueryValue("id"); | |
| 119 | + $jQuery.each(elements, function(index, element) { | |
| 120 | + if (element.pluginProps.device_id && actualDeviceId) { | |
| 121 | + element.pluginProps.device_id = actualDeviceId; | |
| 122 | + } | |
| 123 | + }); | |
| 124 | + | |
| 106 | 125 | // console.log(work); |
| 107 | 126 | window.__work = work; |
| 108 | 127 | }()); | ... | ... |