Commit 6e8f7760 by 前端

Merge branch 'dev_v2.6.0_0718' into 'master'

Dev v2.6.0 0718

See merge request !15
2 parents 79cfb2f0 b71cc2c0
...@@ -29,5 +29,13 @@ export default { ...@@ -29,5 +29,13 @@ export default {
url, url,
data data
}) })
} },
uploadMaterial (data = {}) {
data.method = 'marketing.api.material.sop.upload'
return window.$HTTP({
url,
data
})
},
} }
\ No newline at end of file \ No newline at end of file
...@@ -76,7 +76,7 @@ export default { ...@@ -76,7 +76,7 @@ export default {
let { materialName, businessType, groupId, sort } = this let { materialName, businessType, groupId, sort } = this
marketingApi.getPsdList({ materialName, businessType, groupId }).then(data => { marketingApi.getPsdList({ materialName, businessType, groupId }).then(data => {
console.log('素材列表', data) console.log('素材列表', data)
if (sort != 0 && data && data.length) data = this.sortList(data, sort == 1 ? 'sendNum' : 'readNum') if (sort != 0 && data && data.materialToCRpcResponses && data.materialToCRpcResponses.length) data.materialToCRpcResponses = this.sortList(data.materialToCRpcResponses, sort == 1 ? 'sendNum' : 'readNum')
this.list = data.materialToCRpcResponses || [] this.list = data.materialToCRpcResponses || []
this.flag = true this.flag = true
this.hideLoading() this.hideLoading()
......
import { wxConfig, marketingApi } from '@/api' import { wxConfig, marketingApi } from '@/api'
// import { resolve } from 'core-js/fn/promise'
export default { export default {
data () { data () {
return { return {
...@@ -66,9 +67,22 @@ export default { ...@@ -66,9 +67,22 @@ export default {
desc: description || '', desc: description || '',
imgUrl: titleUrl || imgUrl imgUrl: titleUrl || imgUrl
} }
wxConfig.getContext().then((res) => {
if (entry != 'normal') this.sendChatMessage(params, { id, merchantId, uuid }) if (res.entry != 'normal'){
else this.shareAppMessage(params, { id, merchantId, uuid }) let pdfParam = {
msgtype: 'news',
news: params,
enterChat: false
}
if(i.materialType==1){
this.sendChatMessage(pdfParam, { id, merchantId, uuid })
}else{
this.getParam(i, { id, merchantId, uuid })
}
}else{
this.shareAppMessage(params, { id, merchantId, uuid })
}
})
} }
}) })
}, },
...@@ -80,21 +94,102 @@ export default { ...@@ -80,21 +94,102 @@ export default {
staffUuid: uuid staffUuid: uuid
}) })
}, },
sendChatMessage (params, sendParams) { getParam(item,sendParams){
wxConfig let str = decodeURIComponent(item.materialUrl)
.sendChatMessage({ let testReg = /\>(.*?)\<|img(.*?)src.*?(.jpg|.peg|.png|.gif|.webp|.pjp|.jfif|.pjpeg|.bmp|.dib)|video(.*?)src.*?(.ogm|.wmv|.asx|.mpg|.webm|.mp4|.ogv|.mpeg|.mov|.m4v|.avi)/g
msgtype: 'news', let arr = str.match(testReg)
news: params, let imgLabelReg = /img(.*?)src.*?(.jpg|.peg|.png|.gif|.webp|.pjp|.jfif|.pjpeg|.bmp|.dib)/
let videoLabelReg = /video(.*?)src.*?(.ogm|.wmv|.asx|.mpg|.webm|.mp4|.ogv|.mpeg|.mov|.m4v|.avi)/
let imgLinkReg = /https?:\/\/(.*?)(.jpg|.peg|.png|.gif|.webp|.pjp|.jfif|.pjpeg|.bmp|.dib)/
let videoLinkReg = /https?:\/\/(.*?)(.ogm|.wmv|.asx|.mpg|.webm|.mp4|.ogv|.mpeg|.mov|.m4v|.avi)/
arr = arr.map(item => {
if (imgLabelReg.test(item)) {
if (item.match(imgLinkReg)) return item.match(imgLinkReg)[0]
} else if (videoLabelReg.test(item)) {
if (item.match(videoLinkReg)) return item.match(videoLinkReg)[0]
} else if (item && item.length > 2 && item != '><') {
return item.slice(1, -1) ? item.slice(1, -1).replaceAll('&amp;','&').replaceAll('&gt;','>').replaceAll('&lt;','<') : ''
}
})
arr = arr.filter(item => item)
let newArr = []
arr.forEach((ele, id) => {
let mediaType = 5
let myParam = {}
// let fileReg = /^https?:\/\/[\s\S]+\./
if (!ele) return
if(imgLinkReg.test(ele) || videoLinkReg.test(ele)){
let imgArr = ['jpg','jpeg','png','gif','webp','pjp','jfif','pjpeg','bmp','dib']
let idx = ele.lastIndexOf('.')
if(idx>-1 && imgArr.includes(ele.slice(idx+1))){
mediaType= 3
}else{
mediaType= 4
}
myParam = this.uploadMaterial({materialName:item.materialName, data:ele, mediaType},mediaType)
}else{
myParam = this.getTextPromise(ele)
}
newArr.push(myParam)
});
Promise.allSettled(newArr).then(async res=>{
for(let i=0;i<res.length;i++){
await this.sendChatMessage(res[i].value, sendParams)
}
})
},
getTextPromise(ele){
return new Promise((resolve,reject)=>{
resolve({
msgtype: 'text',
text: {content: ele},
enterChat: false enterChat: false
}) })
})
},
uploadMaterial(param,type){
return new Promise((resolve,reject)=>{
marketingApi.uploadMaterial(param).then(res =>{
console.log(res,456)
if(res?.mediaId){
if(type==1){
resolve({
msgtype: 'file',
file: {mediaid: res.mediaId},
enterChat: false
})
}else if(type==3){
resolve({
msgtype: 'image',
image: {mediaid: res.mediaId},
enterChat: false
})
}else{
resolve({
msgtype: 'video',
video: {mediaid: res.mediaId},
enterChat: false
})
}
}
})
})
},
sendChatMessage (params, sendParams) {
return new Promise((resolve,reject)=>{
this.showLoading()
wxConfig
.sendChatMessage(params)
.then(res => { .then(res => {
this.hideLoading() this.hideLoading()
this.sendReadBuriedPoint(sendParams) this.sendReadBuriedPoint(sendParams)
}) resolve()
.catch(err => { }).catch(err => {
console.log(err) console.log(err)
this.hideLoading() this.hideLoading()
}) })
})
}, },
shareAppMessage (params, sendParams) { shareAppMessage (params, sendParams) {
wxConfig wxConfig
......
...@@ -63,7 +63,8 @@ const actions = { ...@@ -63,7 +63,8 @@ const actions = {
ssoApi ssoApi
.login({ .login({
code, code,
corpId corpId,
getUserInfoFlag: false
}) })
.then(({ code, data, message }) => { .then(({ code, data, message }) => {
let route = state.lastPath == 'coupon' ? '' : state.lastPath || '' let route = state.lastPath == 'coupon' ? '' : state.lastPath || ''
...@@ -114,21 +115,21 @@ const actions = { ...@@ -114,21 +115,21 @@ const actions = {
util.showLoading() util.showLoading()
let appid = getParams('corpId') //从链接获取 let appid = getParams('corpId') //从链接获取
let dj_scrm = util.getLocalStorage('dj_scrm_corpId') let dj_scrm = util.getLocalStorage('dj_scrm_corpId')
if (!appid) appid = (dj_scrm && dj_scrm.corpId) || 'ww7ee69c648ae1b7e6' if (!appid) appid = (dj_scrm && dj_scrm.corpId) || 'wwc33bc9a3c72d45f3'
util.setLocalStorage('dj_scrm_corpId', { corpId: appid }) util.setLocalStorage('dj_scrm_corpId', { corpId: appid })
// 'ww657a2d4ae89a4424' // 'ww657a2d4ae89a4424'
const wxUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize' const wxUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize'
window.location.href = `${wxUrl}?appid=${appid}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect` window.location.href = `${wxUrl}?appid=${appid}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`
} }
} else { } else {
const storage_corpId = util.getLocalStorage('dj_scrm_corpId') const { corpId, agentId } = util.getLocalStorage('dj_scrm_corpId')
const { baseURL } = window.$fetchConfig.request const { baseURL } = window.$fetchConfig.request
let url = `${baseURL}/dj-scrm-wx-work-main/#/` let url = `${baseURL}/dj-scrm-wx-work-main/#/`
window.location.href = `${url}?redirect_uri=${encodeURIComponent(redirectUrl)}&corpId=${storage_corpId.corpId}` window.location.href = `${url}?redirect_uri=${encodeURIComponent(redirectUrl)}&corpId=${corpId}&agentId=${agentId}`
} }
}, },
navigation({ dispatch }) { navigation({ dispatch }) {
let { sessionId, corpId } = getParams() let { sessionId, corpId, agentId } = getParams()
const storage_corpId = util.getLocalStorage('dj_scrm_corpId') const storage_corpId = util.getLocalStorage('dj_scrm_corpId')
if (!corpId) corpId = storage_corpId && storage_corpId.corpId if (!corpId) corpId = storage_corpId && storage_corpId.corpId
if (corpId && storage_corpId) { if (corpId && storage_corpId) {
...@@ -137,7 +138,9 @@ const actions = { ...@@ -137,7 +138,9 @@ const actions = {
util.clearSessionId() util.clearSessionId()
} }
} }
util.setLocalStorage('dj_scrm_corpId', { corpId }) let dj_scrm_storage = { corpId }
if (agentId) dj_scrm_storage.agentId = agentId
util.setLocalStorage('dj_scrm_corpId', dj_scrm_storage)
const storage_sessionId = util.getSessionId() const storage_sessionId = util.getSessionId()
if (sessionId || storage_sessionId) { if (sessionId || storage_sessionId) {
state.showWindow = true state.showWindow = true
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!