<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>SIPJS DEMO</title> <script src="https://guest.feige.cn/feige.im/js/sip.js"></script> </head> <body> <div class="step"> <h4>1,登录注册</h4> <p><span>分机号</span> <input type="text" id="extensionNumber"></p> <p><span>密码</span> <input type="text" id="password"></p> <p><span>公司ID</span> <input type="text" id="companyId"></p> <p><span>域名</span> <input type="text" id="domain"></p> <p><span>端口</span> <input type="text" id="wssPort"></p> <p><span></span> <button onclick="login()">登录注册</button></p> <h4>2,输入被叫号码点拨打</h4> <p><span>被叫号码</span> <input type="text" id="phone"></p> <p><span>回调地址</span> <input type="text" id="callBackurl"></p> <p><span></span> <button onclick="call()">拨打</button> <button onclick="answer()">接听</button></p> <h4>3,发送dtmf</h4> <p class="keys"> <span onclick="dtmf(0)">0</span> <span onclick="dtmf(1)">1</span> <span onclick="dtmf(2)">2</span> <span onclick="dtmf(3)">3</span> <span onclick="dtmf(4)">4</span> <span onclick="dtmf(5)">5</span> <span onclick="dtmf(6)">6</span> <span onclick="dtmf(7)">7</span> <span onclick="dtmf(8)">8</span> <span onclick="dtmf(9)">9</span> <span onclick="dtmf('*')">*</span> <span onclick="dtmf('#')">#</span> </p> <h4>4,静音 取消静音</h4> <button onclick="mute()">静音</button> <button onclick="unmute()">取消静音</button> <h4>5,挂断 登出</h4> <button onclick="hangup()">挂断</button> <button onclick="logout()">登出</button> </div> <script> // 登录 function login () { var extensionNumber = document.getElementById("extensionNumber").value var password = document.getElementById("password").value var companyId = document.getElementById("companyId").value var domain = document.getElementById("domain").value var wssPort = document.getElementById("wssPort").value webPhone.fgLogin(extensionNumber, password, companyId, domain, wssPort, fgCallback) } // 拨打 function call () { var phone = document.getElementById("phone").value var callBackurl = document.getElementById("callBackurl").value webPhone.fgCall(phone, callBackurl) } // 接听 function answer() { webPhone.fganswer() } // 发送dtmf function dtmf(num) { webPhone.fgsendDtmf(num) } // 静音 function mute() { webPhone.fgmute() } // 取消静音 function unmute() { webPhone.fgunmute() } // 挂断 function hangup () { webPhone.fghangup() } // 登出 function logout () { webPhone.fglogout() } // 通话状态回调 function fgCallback (response) { console.log(response); } </script> </body> </html>