(function(w) { // 格式化地址栏参数 将对象自动拼接成地址栏传参形式 w.formatParams = function(data) { let temp = '' Object.keys(data).map((key, index) => { temp += '&' + key + '=' + data[key] }) let firstCharAt = temp.charAt(0) temp = temp.replace(firstCharAt, '?') return temp; } w.topPopoverClick = function(type) { if (type === '操作指导') { console.log('操作指导') } else if (type === '成品追溯') { console.log('成品追溯') } else if (type === '退出登录') { const data = { userid: localStorage.getItem('userid'), usercode: localStorage.getItem('usercode'), username: localStorage.getItem('username'), usertype: localStorage.getItem('usertype') } post('Login/LoginAppOut' + formatParams(data)).then(res => { if (res.code === '200') { window.location.href = '../login/index.html' } }) } // return 1 } })(window);