采购经理、供应商、代理商嵌入客服
This commit is contained in:
68
src/utils/CustomerService.ts
Normal file
68
src/utils/CustomerService.ts
Normal file
@ -0,0 +1,68 @@
|
||||
/*客服系统专用*/
|
||||
//跨系统post传参
|
||||
|
||||
export const bizServiceCustomService = REACT_APP_CUSTOMERSERVICE_USERCENTER + '&client_id=' + REACT_APP_CUSTOMERSERVICE_CLIENT_ID + '&redirect_uri=' + REACT_APP_CUSTOMERSERVICE_REDIRECT + '/redirect?page=home&mall3_token=';//智慧客服
|
||||
//export const bizServiceCustomService = REACT_APP_CUSTOMERSERVICE_USERCENTER + '&client_id=S00hFPxc&redirect_uri=http://localhost:3000/redirect?page=home&mall3_token=';//智慧客服
|
||||
export function windowOpenChatUI(inputList:any,pathname:string) {
|
||||
if(inputList && inputList.length>0){
|
||||
var tempForm = document.getElementById('tempForm_CustomerService') as HTMLFormElement
|
||||
if(tempForm) document.body.removeChild(tempForm);
|
||||
tempForm = document.createElement("form")
|
||||
tempForm.id="tempForm_CustomerService"
|
||||
tempForm.method="post"
|
||||
tempForm.action = bizServiceCustomService + sessionStorage.getItem('Authorization')
|
||||
tempForm.target='_blank'
|
||||
inputList.map((input: any)=>{
|
||||
let labelName= input.label!=null?`_CustomerServiceLabel_${input.label}`:''
|
||||
var hideInput = document.createElement("input")
|
||||
hideInput.type="hidden"
|
||||
hideInput.name= input.paraName
|
||||
hideInput.value = input.isEncode?`${encodeURI(input.paraVal)}${labelName}`:`${input.paraVal}${labelName}`
|
||||
tempForm.appendChild(hideInput)
|
||||
})
|
||||
var input = document.createElement("input")
|
||||
input.id = 'tempInput_CustomerService'
|
||||
input.name= 'sceneUrl'
|
||||
input.value= pathname
|
||||
tempForm.appendChild(input)
|
||||
document.body.appendChild(tempForm);
|
||||
if(tempForm){
|
||||
tempForm.submit();
|
||||
document.body.removeChild(tempForm);
|
||||
}
|
||||
}
|
||||
}
|
||||
//创建临时表单
|
||||
export function createHiddenForm(inputList:any,pathname:string) {
|
||||
if(inputList && inputList.length>0){
|
||||
var tempForm = document.getElementById('tempForm_CustomerService') as HTMLFormElement
|
||||
if(tempForm) document.body.removeChild(tempForm);
|
||||
tempForm = document.createElement("form")
|
||||
tempForm.id="tempForm_CustomerService"
|
||||
tempForm.method="post"
|
||||
tempForm.action = bizServiceCustomService + sessionStorage.getItem('Authorization')
|
||||
tempForm.target='_blank'
|
||||
inputList.map((input: any)=>{
|
||||
let labelName= input.label!=null?`_CustomerServiceLabel_${input.label}`:''
|
||||
var hideInput = document.createElement("input")
|
||||
hideInput.type="hidden"
|
||||
hideInput.name= input.paraName
|
||||
hideInput.value = input.isEncode?`${encodeURI(input.paraVal)}${labelName}`:`${input.paraVal}${labelName}`
|
||||
tempForm.appendChild(hideInput)
|
||||
})
|
||||
var input = document.createElement("input")
|
||||
input.id = 'tempInput_CustomerService'
|
||||
input.name= 'sceneUrl'
|
||||
input.value= pathname
|
||||
tempForm.appendChild(input)
|
||||
document.body.appendChild(tempForm);
|
||||
}
|
||||
}
|
||||
//提交临时表单
|
||||
export function submitHiddenForm() {
|
||||
var tempForm = document.getElementById('tempForm_CustomerService') as HTMLFormElement
|
||||
if(tempForm){
|
||||
tempForm.submit();
|
||||
document.body.removeChild(tempForm);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user