亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

我寫過了模擬智能在線客服系統

Original 2019-07-13 14:02:26 480
abstract:<!DOCTYPE html><html lang="en"><head>   <meta charset="UTF-8">   <title>DOM實戰(zhàn):模擬智能在線客服系統</title>   <style type="text/css&

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>DOM實戰(zhàn):模擬智能在線客服系統</title>
  <style type="text/css">
     div:nth-child(1) {
        width: 450px;
        height: 650px;
        background-color: lightskyblue;
        margin: 30px auto;
        color: #333;
        box-shadow: 2px 2px 2px #808080
}
     
     h2 {
        text-align: center;
        margin-bottom: -10px;
     }
     div:nth-child(2) {
        width: 400px;
        height: 500px;
        border: 4px double green;
        background-color: #efefef;
        margin: 20px auto 10px;
     }
     
     ul {
        list-style: none;
        line-height: 2em;
        /*border: 1px solid red;*/
overflow: hidden;
        padding: 15px;
     }

     table {
        width: 90%;
        height:80px;
        margin: auto;
     }

     textarea{
        /*width: 300px;*/
border: none;
        resize: none;
        background-color: lightyellow;
       
     }
     button {
        width: 60px;
        height: 40px;
        background-color: seagreen;
        color: white;
        border: none;
        /*text-align: left;*/

}
     button:hover {
        cursor: pointer;
        background-color: orange;
     }
  </style>
</head>
<body>
  <div>
     <h2>在線客服</h2>
     <div contenteditable="true">
        <ul>
           <li></li>
        </ul>
     </div>
     <table>
        <tr>
           <td align="right"><textarea cols="50" rows="4" name="text"></textarea></td>
           <td align="left"><button type=button>發(fā)送</button></td>
        </tr>
     </table>  
  </div>
  <script type="text/javascript">
     //獲取到頁面中的按鈕,文本域,對話內容區(qū)
let btn = document.getElementsByTagName('button')[0];
     let text = document.getElementsByName('text')[0];
     let list = document.getElementsByTagName('ul')[0];
     let sum = 0;

     //添加按鈕點擊事件,獲取用戶數據并推送到對話窗口中
btn.onclick = function () {
        // alert(text.value)
        //獲取用戶提交的內容
if (text.value.length === 0) {
           alert('客官:是不是忘記輸入內容了~~');
           return false;
        }
        let userComment = text.value;

        //立即清空用戶信息區(qū)
text.value = '';

        //創(chuàng)建一個新節(jié)點li
let li = document.createElement('li');
        li.innerHTML = userComment;  //將用戶輸入的內容添加到新節(jié)點中
let userPic = '<img src="inc/peter.jpg" width="30" style="border-radius:50%">'; // 設置用戶頭像
li.innerHTML = userPic + ' ' + userComment; // 將用戶頭像與用戶的聊天內容合并
list.appendChild(li);  //發(fā)送聊天內容,實際上就是將新節(jié)點插入到對話列表中
sum += 1;  // 聊天記錄自增1

        //設置定時器,默認2秒后會自動回復
setTimeout(function(){
        let info = [
            '真煩人,有話快說,別耽誤我玩抖音',
           '除了退貨,退款,咱們什么都可以聊',
           '說啥,本姑娘怎么聽不懂呢?再說一遍',
           '在我方便的時候再回復你吧~~',
           '投訴我的人多了,你算老幾~~~'
];
        let temp = info[Math.floor(Math.random()*3)];
        //取1-5之間的一個整數:Math.floor(Math.random()*6 + 1)
let reply = document.createElement('li');
        let kefuPic = '<img src="inc/zly.jpg" width="30" style="border-radius:50%;">';
        // reply.innerHTML = '你有啥事呀,我的帥哥哥' +kefuPic
reply.innerHTML = kefuPic + ' ' + '<span style="color:red">'+temp+'</span>';

        list.appendChild(reply);
        sum += 1;

        },2000);
       
        // 當聊天記錄達到10條時清空窗口
if (sum > 10) {
           list.innerHTML = '';
           sum = 0;
        }
     }


  </script>
</body>
</html>

Correcting teacher:查無此人Correction time:2019-07-15 13:05:40
Teacher's summary:完成的不錯。即時聊天算一個技術活。繼續(xù)加油

Release Notes

Popular Entries