js_code: res.code | js_code: res.code | ||||
}, | }, | ||||
success: (result) => { | success: (result) => { | ||||
console.log("微信LOGIN result") | |||||
if (!!result.data && result.data.openid) { | if (!!result.data && result.data.openid) { | ||||
this.globalData.openid = result.data.openid; | this.globalData.openid = result.data.openid; | ||||
this.globalData.appid = result.data.appid; | this.globalData.appid = result.data.appid; | ||||
this.globalData.businessCommunicationCustomer = businessCommunicationCustomer; | this.globalData.businessCommunicationCustomer = businessCommunicationCustomer; | ||||
this.globalData.customerId = businessCommunicationCustomer.customerId; | this.globalData.customerId = businessCommunicationCustomer.customerId; | ||||
} | } | ||||
console.log(`初始化拿到的缓存`,this.globalData) | |||||
} | } | ||||
} | } | ||||
}) | }) |
app.goLogin(); | app.goLogin(); | ||||
return | return | ||||
} | } | ||||
console.log(`点击了聊一聊`) | |||||
let item = e.currentTarget.dataset.item; | let item = e.currentTarget.dataset.item; | ||||
let businessCommunicationDemandId = item.businessCommunicationDemandId; | let businessCommunicationDemandId = item.businessCommunicationDemandId; | ||||
$request.post('/statisticsBusinessCommunicationDemand/saveDemandCollect.action', | $request.post('/statisticsBusinessCommunicationDemand/saveDemandCollect.action', |
// 获取当前路由 | // 获取当前路由 | ||||
getChatRecordTable() { | getChatRecordTable() { | ||||
$request.get('/businessCommunicationDemand/getChatRecordTable.action').then(res => { | $request.get('/businessCommunicationDemand/getChatRecordTable.action').then(res => { | ||||
// console.log(res,'res'); | |||||
if(res.status == 0){ | if(res.status == 0){ | ||||
let chatRecordTable = res.data.chatRecordTable; | let chatRecordTable = res.data.chatRecordTable; | ||||
let sum = 0; | let sum = 0; | ||||
}, | }, | ||||
// tab切换 | // tab切换 | ||||
tabChange(e) { | tabChange(e) { | ||||
console.log(e); | |||||
if (e.detail.item.text == "发布需求" || e.detail.item.text == "消息") { | if (e.detail.item.text == "发布需求" || e.detail.item.text == "消息") { | ||||
if (!app.globalData.customerId) { | if (!app.globalData.customerId) { | ||||
app.goLogin(); | app.goLogin(); |
const eventChannel = this.getOpenerEventChannel() | const eventChannel = this.getOpenerEventChannel() | ||||
// 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据 | // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据 | ||||
eventChannel.on('customerid', data => { | eventChannel.on('customerid', data => { | ||||
console.log(data, 'customerid') | |||||
this.setData({ | this.setData({ | ||||
customerId: data.customerid, | customerId: data.customerid, | ||||
pageLoading: true, | pageLoading: true, | ||||
}, | }, | ||||
// 底部按钮点击 | // 底部按钮点击 | ||||
footBtnClick() { | footBtnClick() { | ||||
console.log(`点击了底部按钮`) | |||||
console.log(this.data.isOther) | |||||
// 前往聊一聊 | // 前往聊一聊 | ||||
if (this.data.isOther) { | if (this.data.isOther) { | ||||
console.log(this.data.customer) | |||||
let customer = this.data.customer; | let customer = this.data.customer; | ||||
wx.navigateTo({ | wx.navigateTo({ | ||||
url: "/pages/msgModule/wechat2/wechat2", | url: "/pages/msgModule/wechat2/wechat2", | ||||
this.setData({ | this.setData({ | ||||
pageLoading: false, | pageLoading: false, | ||||
}) | }) | ||||
console.log(res) | |||||
let tempListData = this.data.listData; | let tempListData = this.data.listData; | ||||
if (res.status == 0) { | if (res.status == 0) { | ||||
let datas = res.data; | let datas = res.data; | ||||
console.log(datas, 'datas') | |||||
// 先push数据 | // 先push数据 | ||||
tempListData.push(...datas.demandList); | tempListData.push(...datas.demandList); | ||||
tempListData.forEach(el => { | tempListData.forEach(el => { | ||||
page: page + 1 | page: page + 1 | ||||
}) | }) | ||||
} | } | ||||
console.log('-------------个人主页 beg-------------------') | |||||
console.log(this.data.listData); | |||||
console.log('-------------个人主页 end-------------------') | |||||
} | } | ||||
}).catch(error => { | }).catch(error => { | ||||
console.log(error, 'error appletLogin') | console.log(error, 'error appletLogin') |
* 生命周期函数--监听页面加载 | * 生命周期函数--监听页面加载 | ||||
*/ | */ | ||||
onLoad(option) { | onLoad(option) { | ||||
// console.log(option,`option触发--11`) | |||||
this.setData({ | this.setData({ | ||||
businessCommunicationDemandId: option.businessCommunicationDemandId | businessCommunicationDemandId: option.businessCommunicationDemandId | ||||
}) | }) | ||||
listDetail.createdOn = listDetail.createdOn.replaceAll('/', '-'); | listDetail.createdOn = listDetail.createdOn.replaceAll('/', '-'); | ||||
if (typeof listDetail.type == 'string') { | if (typeof listDetail.type == 'string') { | ||||
listDetail.type = listDetail.type.split(','); | listDetail.type = listDetail.type.split(','); | ||||
// console.log(listDetail.type) | |||||
} | } | ||||
this.setData({ | this.setData({ | ||||
currentData: listDetail, | currentData: listDetail, |
this.setData({ | this.setData({ | ||||
paramIsInterest | paramIsInterest | ||||
}) | }) | ||||
console.log(`本次接口:type`,type) | |||||
$request.get('/businessCommunicationDemand/getDemandByKeywordOrType.action', | $request.get('/businessCommunicationDemand/getDemandByKeywordOrType.action', | ||||
{ page, size, keyword, type, isInterest: paramIsInterest } | { page, size, keyword, type, isInterest: paramIsInterest } | ||||
).then(res => { | ).then(res => { |
}, | }, | ||||
// 获取手机号授权 | // 获取手机号授权 | ||||
getPhoneNumber(e) { | getPhoneNumber(e) { | ||||
console.log(e); | |||||
if (!!e.detail.iv && !!e.detail.encryptedData) { | if (!!e.detail.iv && !!e.detail.encryptedData) { | ||||
const iv = e.detail.iv | const iv = e.detail.iv | ||||
const encryptedData = e.detail.encryptedData | const encryptedData = e.detail.encryptedData | ||||
province, | province, | ||||
city | city | ||||
}).then(res => { | }).then(res => { | ||||
console.log(res, '保存用户信息返回的Res') | |||||
this.getUserSession() | this.getUserSession() | ||||
}).catch(error => { | }).catch(error => { | ||||
console.log(error, 'error appletLogin') | console.log(error, 'error appletLogin') | ||||
let that = this | let that = this | ||||
$request.post('/script/getSession.action', {}).then(res => { | $request.post('/script/getSession.action', {}).then(res => { | ||||
wx.hideLoading() | wx.hideLoading() | ||||
console.log(res, '返回的res') | |||||
let businessCommunicationCustomer = res.data.businessCommunicationCustomer; | let businessCommunicationCustomer = res.data.businessCommunicationCustomer; | ||||
app.globalData.customerId = businessCommunicationCustomer.customerId; | app.globalData.customerId = businessCommunicationCustomer.customerId; | ||||
app.globalData.customer = res.data.customer; | app.globalData.customer = res.data.customer; |
el.type = el.type.split(','); | el.type = el.type.split(','); | ||||
} | } | ||||
if (el.customer) { | if (el.customer) { | ||||
// console.log(el.customer.paidByMonth,el.customer.nickName) | |||||
if (el.customer.paidByMonth) { | if (el.customer.paidByMonth) { | ||||
el.businessCommunicationCustomerVO.nickName = el.customer.nickName | el.businessCommunicationCustomerVO.nickName = el.customer.nickName | ||||
} | } | ||||
msgData: tempListData, | msgData: tempListData, | ||||
total: datas.total, | total: datas.total, | ||||
}) | }) | ||||
// // 如果数据大于了返回的总数 | |||||
// if (tempListData.length >= this.data.total) { | |||||
// // 停止累加数据 | |||||
// this.setData({ | |||||
// onRefresh: false, | |||||
// itemLoading: false, | |||||
// }) | |||||
// } else { | |||||
// this.setData({ | |||||
// onRefresh: true, | |||||
// itemLoading: false, | |||||
// page: page + 1 | |||||
// }) | |||||
// } | |||||
console.log('-------------消息 beg-------------------') | |||||
console.log(this.data.msgData); | |||||
console.log('-------------消息 end-------------------') | |||||
} | } | ||||
this.setData({ | this.setData({ | ||||
pageLoading: false, | pageLoading: false, | ||||
msgData: msgData | msgData: msgData | ||||
}) | }) | ||||
$request.post('/businessCommunicationDemand/delChatRecordTable/' + customerId + '/' + lastChatRecordCode + '.action').then(res => { | $request.post('/businessCommunicationDemand/delChatRecordTable/' + customerId + '/' + lastChatRecordCode + '.action').then(res => { | ||||
// console.log() | |||||
// if (res.status == 0) { | // if (res.status == 0) { | ||||
// let msgData = this.data.msgData; | // let msgData = this.data.msgData; | ||||
// msgData.forEach((el, inx) => { | // msgData.forEach((el, inx) => { |
initWebSocket: function () { | initWebSocket: function () { | ||||
var _this = this; | var _this = this; | ||||
let { receiveMemberId, sendMemberId } = _this.data; | let { receiveMemberId, sendMemberId } = _this.data; | ||||
// console.log() | |||||
//建立连接 | //建立连接 | ||||
wx.connectSocket({ | wx.connectSocket({ | ||||
url: `ws://` + app.webSocketUrl + `/webSocket/{"userno":${receiveMemberId},"messageModule":"010"}`,//本地 | url: `ws://` + app.webSocketUrl + `/webSocket/{"userno":${receiveMemberId},"messageModule":"010"}`,//本地 | ||||
}) | }) | ||||
_this.setMsgRead('newsList', _this.data.newsList, 0) | _this.setMsgRead('newsList', _this.data.newsList, 0) | ||||
_this.scrollBottom() | _this.scrollBottom() | ||||
console.log('--------------对方给你发消息拉 beg -------------') | |||||
console.log(_data); | |||||
console.log('--------------对方给你发消息拉 end -------------') | |||||
}, | }, | ||||
) | ) | ||||
this.setData({ | this.setData({ | ||||
historyList | historyList | ||||
}) | }) | ||||
console.log(this.data.historyList, '历史记录数据') | |||||
} | } | ||||
// 如果产品ID存在 | // 如果产品ID存在 | ||||
console.log(businessCommunicationDemandId, '产品ID是否存在') | |||||
if (businessCommunicationDemandId) { | if (businessCommunicationDemandId) { | ||||
if (historyList.length > 0) { | if (historyList.length > 0) { | ||||
let tempArr = []; | let tempArr = []; | ||||
// 滚动到底部 | // 滚动到底部 | ||||
scrollBottom: function () { | scrollBottom: function () { | ||||
console.log(`触发了吗?`) | |||||
// wx.createSelectorQuery().select('#sendmessage').boundingClientRect(rect => { | |||||
// console.log(rect.height); | |||||
// console.log(`触发了吗2?`) | |||||
// wx.pageScrollTo({ | |||||
// scrollTop:rect.height | |||||
// }) | |||||
// }).exec() | |||||
// var { newsList } = this.data | |||||
// var scrollid = `scrollid${newsList.length - 1}`; | |||||
// if (newsList.length == 0) { | |||||
// scrollid = "scrollid0" | |||||
// } | |||||
this.setData({ | this.setData({ | ||||
scrollid:"sendmessage" | scrollid:"sendmessage" | ||||
}) | }) | ||||
input: null, | input: null, | ||||
inputShowed: true, | inputShowed: true, | ||||
}) | }) | ||||
console.log(this.data.newsList, 'this.data.newsList') | |||||
this.scrollBottom() | this.scrollBottom() | ||||
// 表情选择隐藏 | // 表情选择隐藏 | ||||
this.setData({ | this.setData({ | ||||
emotionVisible: false, | emotionVisible: false, | ||||
}) | }) | ||||
const client = wx.getSystemInfoSync().windowHeight // 获取当前窗口的高度 | const client = wx.getSystemInfoSync().windowHeight // 获取当前窗口的高度 | ||||
console.log(client, '当前消息高度') | |||||
}, | }, | ||||
bindChange: function (res) { | bindChange: function (res) { | ||||
this.setData({ | this.setData({ | ||||
console.log('连接断开'); | console.log('连接断开'); | ||||
}, | }, | ||||
emotionChange() { | emotionChange() { | ||||
console.log(`测试打开表情`) | |||||
this.setData({ | this.setData({ | ||||
emotionVisible: !this.data.emotionVisible | emotionVisible: !this.data.emotionVisible | ||||
}) | }) | ||||
}, | }, | ||||
addemotion: function (e) { | addemotion: function (e) { | ||||
console.log(e.currentTarget.dataset.index, "点了设默默") | |||||
let { connectemoji, input } = this.data | let { connectemoji, input } = this.data | ||||
if (input) { | if (input) { | ||||
input = input + connectemoji[e.currentTarget.dataset.index]; | input = input + connectemoji[e.currentTarget.dataset.index]; | ||||
} else { | } else { | ||||
input = connectemoji[e.currentTarget.dataset.index] | input = connectemoji[e.currentTarget.dataset.index] | ||||
} | } | ||||
console.log(input, '输入框额值') | |||||
this.setData({ | this.setData({ | ||||
input, | input, | ||||
emotionVisible: false, | emotionVisible: false, | ||||
viewImg(e) { | viewImg(e) { | ||||
let url = e.currentTarget.dataset.url; | let url = e.currentTarget.dataset.url; | ||||
url += "?time=" + Date.now(); | url += "?time=" + Date.now(); | ||||
console.log(url) | |||||
wx.previewImage({ | wx.previewImage({ | ||||
current: url, // 当前显示图片的http链接 | current: url, // 当前显示图片的http链接 | ||||
urls: [url] // 需要预览的图片http链接列表 | urls: [url] // 需要预览的图片http链接列表 |
const eventChannel = this.getOpenerEventChannel() | const eventChannel = this.getOpenerEventChannel() | ||||
// 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据 | // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据 | ||||
eventChannel.on('customerid', data => { | eventChannel.on('customerid', data => { | ||||
console.log(data) | |||||
this.setData({ | this.setData({ | ||||
customerId: data.customerid, | customerId: data.customerid, | ||||
pageLoading: true, | pageLoading: true, | ||||
$request.get(`/businessCommunicationCustomer/getAttentionTypeIds.action`, | $request.get(`/businessCommunicationCustomer/getAttentionTypeIds.action`, | ||||
{ customerId } | { customerId } | ||||
).then(res => { | ).then(res => { | ||||
// console.log(res); | |||||
if (res.status == 0) { | if (res.status == 0) { | ||||
let selectedTags = res.data ? res.data.split(',') : []; | let selectedTags = res.data ? res.data.split(',') : []; | ||||
this.setData({ selectedTags }) | this.setData({ selectedTags }) | ||||
} | } | ||||
}) | }) | ||||
this.setData({ types }) | this.setData({ types }) | ||||
console.log(types, 'types') | |||||
}, | }, | ||||
// 设置关注类型 | // 设置关注类型 | ||||
setAttentionTypeIds() { | setAttentionTypeIds() { |
delCollect(e) { | delCollect(e) { | ||||
let businessCommunicationDemandId = e.currentTarget.dataset.id; | let businessCommunicationDemandId = e.currentTarget.dataset.id; | ||||
let customerId = this.data.customerId; | let customerId = this.data.customerId; | ||||
console.log({ customerId, businessCommunicationDemandId }); | |||||
wx.showLoading({ | wx.showLoading({ | ||||
title: '操作中...', | title: '操作中...', | ||||
mask: true | mask: true | ||||
let tempListData = this.data.listData; | let tempListData = this.data.listData; | ||||
if (res.status == 0) { | if (res.status == 0) { | ||||
let datas = res.data; | let datas = res.data; | ||||
console.log(datas, 'datas') | |||||
// 先push数据 | // 先push数据 | ||||
tempListData.push(...datas.demandList); | tempListData.push(...datas.demandList); | ||||
tempListData.forEach(el => { | tempListData.forEach(el => { |
const eventChannel = this.getOpenerEventChannel() | const eventChannel = this.getOpenerEventChannel() | ||||
// 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据 | // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据 | ||||
eventChannel.on('customerid', data => { | eventChannel.on('customerid', data => { | ||||
console.log(data) | |||||
this.setData({ | this.setData({ | ||||
customerId: data.customerid, | customerId: data.customerid, | ||||
listLoading: true, | listLoading: true, | ||||
let tempListData = this.data.listData; | let tempListData = this.data.listData; | ||||
if (res.status == 0) { | if (res.status == 0) { | ||||
let datas = res.data; | let datas = res.data; | ||||
console.log(datas, 'datas') | |||||
// 先push数据 | // 先push数据 | ||||
tempListData.push(...datas.demandList); | tempListData.push(...datas.demandList); | ||||
tempListData.forEach(el => { | tempListData.forEach(el => { | ||||
page: page + 1 | page: page + 1 | ||||
}) | }) | ||||
} | } | ||||
console.log('-------------个人主页 beg-------------------') | |||||
console.log(this.data.listData); | |||||
console.log('-------------个人主页 end-------------------') | |||||
} | } | ||||
this.setData({ | this.setData({ | ||||
listLoading: false, | listLoading: false, |
user: app.globalData.businessCommunicationCustomer, | user: app.globalData.businessCommunicationCustomer, | ||||
isLogin: true | isLogin: true | ||||
}) | }) | ||||
console.log(`------------------当前登录用户-----------------------`) | |||||
console.log(app.globalData.businessCommunicationCustomer); | |||||
console.log(`------------------当前登录用户-----------------------`) | |||||
} | } | ||||
}, | }, | ||||
onShow() { | onShow() { |
tags, | tags, | ||||
setTags: true | setTags: true | ||||
}) | }) | ||||
// console.log(this.data.selectedTag,'selectedTag'); | |||||
// console.log(this.data.tags,'tags'); | |||||
}, | }, | ||||
// 发布需求 | // 发布需求 | ||||
releaseDemands() { | releaseDemands() { |