123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- // pages/LiveCustomer/LiveCustomer.js
- const app = getApp();
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- pullUrl: {
- type: String
- },
- kid : {
- type : String
- },
- online_sum : {
- type : Number
- }
- },
- /**
- * 组件的初始数据
- */
- data: {
- bool : true,
- x: 0,
- y: 0,
- chatText : "",
- chatList : [],
- playData : null,
- scrollTop : 300,
- time : 0,
- num : 1,
- timer : null
- },
- ready : function() {
- var _this = this;
- // _this.getTime();
- // console.log(this.data.kid)
- _this.getChatList();
- },
- /**
- * 组件的方法列表
- */
- methods: {
- doubleClick : function(e) {
- var that = this
- // 控制点击事件在350ms内触发,加这层判断是为了防止长按时会触发点击事件
- if (that.data.touchEndTime - that.data.touchStartTime < 350) {
- // 当前点击的时间
- var currentTime = e.timeStamp
- var lastTapTime = that.lastTapTime
- // 更新最后一次点击时间
- that.lastTapTime = currentTime
- // 如果两次点击时间在300毫秒内,则认为是双击事件
- if (currentTime - lastTapTime < 300) {
- console.log("double tap")
- // 成功触发双击事件时,取消单击事件的执行
- this.setData({
- bool : !this.data.bool
- },function(){
- setInterval(() => {
- that.getChatList();
- },1000)
- })
- }
- }
- },
- touchStart: function (e) {
- this.setData({
- touchStartTime: e.timeStamp
- })
- },
- /// 按钮触摸结束触发的事件
- touchEnd: function (e) {
- this.setData({
- touchEndTime: e.timeStamp
- })
- },
- send(e) {
- let _this = this;
- if (_this.data.chatText !== '') {
- wx.request({
- url: app.globalData.prodUrl + 'web-pm/wx/pm/add_chitchat',
- data: {
- content: _this.data.chatText,
- liveroom_id: _this.data.kid
- },
- header: { 'ydw-token': wx.getStorageSync('key').ydw_token },
- method: 'GET',
- dataType: 'json',
- responseType: 'text',
- success: function (data) {
- console.log(data)
- _this.setData({
- chatText: ''
- },function() {
- _this.getChatList()
- })
- }
- })
- } else {
-
- }
- },
- chatText(e) {
- this.setData({
- chatText: e.detail.value
- })
- },
- getChatList() {
- var _this = this;
- wx.request({
- url: app.globalData.prodUrl + 'web-pm/wx/pm/get_chatting_records',
- data: {
- live_room_id : _this.data.kid,
- chat_time: _this.data.time
- },
- header: {
- 'ydw-token': wx.getStorageSync('key').ydw_token
- },
- method: 'GET',
- dataType: 'json',
- responseType: 'text',
- success: function (data) {
- var chatList = data.data.data;
- var time = data.data.data[0].created;
- _this.setData({
- chatList: chatList,
- time
- },function() {
- _this.pageScrollToBottom();
- })
- }
- })
- },
- pageScrollToBottom: function () {
- var _this = this;
- this.setData({
- scrollTop : this.data.scrollTop + 40
- },function() {
- // console.log(_this.data.scrollTop)
- }
- )
- },
- Caeel : function() {
- return false;
- },
- getTime : function() {
- var _this = this;
- wx.request({
- url: app.globalData.prodUrl + 'web-pm/wx/pm/select_list',
- data: {
- kid: _this.data.kid
- },
- header: {
- 'ydw-token': wx.getStorageSync('key').ydw_token
- },
- success: function (data) {
- _this.setData({
- time: data.data.nowtime
- },function(){
- // setInterval(function () {
- // _this.getChatList();
- // }, 1000)
- })
- }
- })
- },
- updataUserInfo : function(e) {
- console.log(e)
- }
- }
- })
|