123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- // pages/customerServe/customerServe.js
- const app = getApp();
- var inputVal = '';
- var msgList = [];
- var windowWidth = wx.getSystemInfoSync().windowWidth;
- var windowHeight = wx.getSystemInfoSync().windowHeight;
- var keyHeight = 0;
-
- /**
- * 初始化数据
- */
- function initData(that) {
- inputVal = '';
-
- msgList = [{
- speaker: 'server',
- contentType: 'text',
- content: '您好!我是小喃,有什么可以帮您?'
- },
- {
- speaker: 'customer',
- contentType: 'text',
- content: '南岸区核酸检测'
- }
- ]
- that.setData({
- msgList,
- inputVal
- })
- }
-
-
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- scrollHeight: '100vh',
- inputBottom: 0
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- initData(this);
- this.setData({
- // cusHeadIcon: app.globalData.userInfo.avatarUrl,
- });
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {
-
- },
-
- /**
- * 获取聚焦
- */
- focus: function(e) {
- keyHeight = e.detail.height;
- this.setData({
- scrollHeight: (windowHeight - keyHeight) + 'px'
- });
- this.setData({
- toView: 'msg-' + (msgList.length - 1),
- inputBottom: keyHeight + 'px'
- })
- //计算msg高度
- // calScrollHeight(this, keyHeight);
-
- },
-
- //失去聚焦(软键盘消失)
- blur: function(e) {
- this.setData({
- scrollHeight: '100vh',
- inputBottom: 0
- })
- this.setData({
- toView: 'msg-' + (msgList.length - 1)
- })
-
- },
-
- /**
- * 发送点击监听
- */
- sendClick: function(e) {
- msgList.push({
- speaker: 'customer',
- contentType: 'text',
- content: e.detail.value
- })
- inputVal = '';
- this.setData({
- msgList,
- inputVal
- });
-
-
- },
-
- /**
- * 退回上一页
- */
- toBackClick: function() {
- wx.navigateBack({})
- },
- onShareAppMessage: function () {
- return {
- title: '小喃客服'
- }
- }
-
- })
|