'!'
This commit is contained in:
@@ -35,6 +35,7 @@ const msgChatFn = function () {
|
||||
*/
|
||||
let useData: AnyObject = {}
|
||||
let ebStore: AnyObject = {}
|
||||
let jdStore: AnyObject = {}
|
||||
onLoad((potion: any) => {
|
||||
let res:any = getStorage('vendorUserInfo')
|
||||
if(JSON.stringify(potion) === '{}') {
|
||||
@@ -50,13 +51,14 @@ const msgChatFn = function () {
|
||||
useData = useInfo
|
||||
}
|
||||
if (store.state.storeInfo.allStoreInfo.StoreMaps && store.state.storeInfo.allStoreInfo.StoreMaps.length > 0) ebStore = store.state.storeInfo.allStoreInfo.StoreMaps.find((item: { vendorID: number }) => item.vendorID === 3) // 饿百
|
||||
if (store.state.storeInfo.allStoreInfo.StoreMaps && store.state.storeInfo.allStoreInfo.StoreMaps.length > 0) jdStore = store.state.storeInfo.allStoreInfo.StoreMaps.find((item: { vendorID: number }) => item.vendorID === 0) // 京东
|
||||
|
||||
// 修改标题
|
||||
uni.setNavigationBarTitle({
|
||||
title:
|
||||
useData.vendorID == 1
|
||||
? `【美团${useData.orderDesc}】${useData.userID === '0' ? '群发消息' : useData.userID}`
|
||||
: `【饿了么】${useData.userID}`,
|
||||
: useData.vendorID == 3 ? `【淘宝闪购】${useData.userID}` : `【京东】${useData.userID}`,
|
||||
})
|
||||
|
||||
// 获取聊天数据
|
||||
@@ -74,8 +76,8 @@ const msgChatFn = function () {
|
||||
async function SetMsgRead() {
|
||||
let venderIDInfo = store.state.storeInfo.vendorStoreIDS
|
||||
let data = {
|
||||
appID: useData.vendorID === 1 ? venderIDInfo.appID : ebStore.vendorOrgCode,
|
||||
vendorStoreID: useData.vendorID === 1 ? venderIDInfo.MT : ebStore.vendorStoreID,
|
||||
appID: useData.vendorID === 1 ? venderIDInfo.appID : useData.vendorID === 3 ? ebStore.vendorOrgCode : jdStore.vendorOrgCode,
|
||||
vendorStoreID: useData.vendorID === 1 ? venderIDInfo.MT : useData.vendorID === 3 ? ebStore.vendorStoreID : jdStore.vendorStoreID,
|
||||
vendorID: "" + useData.vendorID,
|
||||
orderID: "" + useData.orderID ? useData.orderID : '0',
|
||||
userID: useData.userID
|
||||
@@ -92,9 +94,9 @@ const msgChatFn = function () {
|
||||
let venderIDInfo = store.state.storeInfo.vendorStoreIDS
|
||||
let data = {
|
||||
payLoad: JSON.stringify([{
|
||||
vendorStoreID: useData.vendorID === 1 ? venderIDInfo.MT : ebStore.vendorStoreID,
|
||||
vendorStoreID: useData.vendorID === 1 ? venderIDInfo.MT : useData.vendorID === 3 ? ebStore.vendorStoreID : jdStore.vendorStoreID,
|
||||
vendorID: "" + useData.vendorID,
|
||||
appID: useData.vendorID === 1 ? venderIDInfo.appID : ebStore.vendorOrgCode,
|
||||
appID: useData.vendorID === 1 ? venderIDInfo.appID : useData.vendorID === 3 ? ebStore.vendorOrgCode : jdStore.vendorOrgCode,
|
||||
userID: useData.userID
|
||||
}])
|
||||
}
|
||||
@@ -121,7 +123,7 @@ const msgChatFn = function () {
|
||||
newArr.push(msgList)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
} else if(useData.vendorID === 3){
|
||||
// 饿百
|
||||
let newMsg = res.data[`${ebStore.vendorOrgCode}:${ebStore.vendorStoreID}:${useData.vendorID}:${useData.userID}`] || []
|
||||
newMsg.map((element: any, index: number) => {
|
||||
@@ -162,6 +164,25 @@ const msgChatFn = function () {
|
||||
newArr.push(msgList)
|
||||
}
|
||||
})
|
||||
}else if(useData.vendorID === 0){
|
||||
let newMsg = res.data[`${jdStore.vendorOrgCode}:${jdStore.vendorStoreID}:${useData.vendorID}:${useData.userID}`] || []
|
||||
newMsg.forEach((element:string) => {
|
||||
let resData = jxParse(element)
|
||||
if(resData.msgContent){
|
||||
let msg = JSON.parse(resData.msgContent.extendJsonData)
|
||||
let content = msg.body.type === 'text' ? msg.body.content : msg.body.type === 'image' ? msg.body.url : msg.body.content
|
||||
// console.log(msg,'msg','获取聊天详情,resData',resData,'useData',useData.userID)
|
||||
|
||||
let msgList = {
|
||||
sendType:'jd',
|
||||
...msg,
|
||||
msg_content: msg.body.type === 'text' ? analyEmoji(content) : msg.body.type === 'image' ? content : '未知' ,
|
||||
msg_source: useData.userID === msg.from.pin ? 2 : 1, // 目前全是客户发的消息
|
||||
msg_type: msg.body.type === 'text' ? 1 : msg.body.type === 'image' ? 2 : 99 // 目前只支持文本消息
|
||||
}
|
||||
newArr.push(msgList)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
chatData.value = newArr
|
||||
@@ -355,11 +376,11 @@ const msgChatFn = function () {
|
||||
* 发送数据
|
||||
*/
|
||||
async function sendClick(msgData: AnyObject) {
|
||||
let venderIDInfo = useData.vendorID === 1 ? store.state.storeInfo.vendorStoreIDS : ebStore.vendorOrgCode
|
||||
let venderIDInfo = useData.vendorID === 1 ? store.state.storeInfo.vendorStoreIDS : useData.vendorID === 3 ? ebStore.vendorOrgCode : jdStore.vendorOrgCode
|
||||
let data = {
|
||||
sendType: useData.vendorID === 1 ? "mt" : "elm",
|
||||
app_id: useData.vendorID === 1 ? venderIDInfo.appID : ebStore.vendorOrgCode,
|
||||
app_poi_code: useData.vendorID === 1 ? venderIDInfo.MT : ebStore.vendorStoreID,
|
||||
sendType: useData.vendorID === 1 ? "mt" : useData.vendorID === 3 ? "elm" : 'jd',
|
||||
app_id: useData.vendorID === 1 ? venderIDInfo.appID : useData.vendorID === 3 ? ebStore.vendorOrgCode : jdStore.vendorOrgCode,
|
||||
app_poi_code: useData.vendorID === 1 ? venderIDInfo.MT : useData.vendorID === 3 ? ebStore.vendorStoreID : jdStore.vendorStoreID,
|
||||
cts: Math.round(new Date().getTime() / 1000).toString(),
|
||||
msg_content: msgData.type === 1 ? analyEmoji(msgData.msg) : msgData.msg,
|
||||
msg_id: Math.round(new Date().getTime()).toString(),
|
||||
@@ -396,7 +417,7 @@ const msgChatFn = function () {
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
} else if(useData.vendorID === 3){
|
||||
let chatDataItem = chatData.value.filter(item => item.msg_source === 2)
|
||||
sendMsg = {
|
||||
platformShopId: chatDataItem[0].platformShopId,
|
||||
@@ -426,6 +447,44 @@ const msgChatFn = function () {
|
||||
data: { ...sendMsg }
|
||||
})
|
||||
}
|
||||
}else if(useData.vendorID === 0){
|
||||
sendMsg = {
|
||||
vendorOrgCode: jdStore.vendorOrgCode,
|
||||
sendData:JSON.stringify({
|
||||
vendorID: 0,
|
||||
storeId:jdStore.storeID,
|
||||
data:{
|
||||
id: '' + Math.round(new Date().getTime()).toString() + 184572 , // uuid //随机生成一个字符串
|
||||
lang: "zh_CN",
|
||||
type: "chat_message",
|
||||
from: {
|
||||
pin:chatData.value[0].to.pin,
|
||||
app:'im.waiter', // 固定不变
|
||||
clientType:'android'
|
||||
},
|
||||
to: {
|
||||
pin:chatData.value[0].from.pin,
|
||||
app:'im.customer', // 固定不变
|
||||
},
|
||||
body: {
|
||||
type:msgData.type === 1 ? "text" : "image", // 消息类型
|
||||
content:msgData.msg,
|
||||
chatinfo:{
|
||||
venderId:chatData.value[0].body.chatinfo.venderId,
|
||||
askAllocateType:chatData.value[0].body.chatinfo.askAllocateType,
|
||||
sid:chatData.value[0].body.chatinfo.sid,
|
||||
source:chatData.value[0].body.chatinfo.source
|
||||
},
|
||||
template:{
|
||||
source:'dd_msg_583984a984834b1889f853be6e449f39_e66c448b9fbe4704901925d3217081a3' // 文本固定不变 //卡片类消息必传
|
||||
},
|
||||
mt:60,
|
||||
},
|
||||
timestamp:new Date().getTime(), // 时间戳
|
||||
clientTime:new Date().getTime() // 客户端时间
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
let res = await message.send_to_vendor(sendMsg)
|
||||
|
||||
Reference in New Issue
Block a user