Commit 4b231b83 by 前端

Merge branch 'master' into 'develop'

Master

See merge request !18
2 parents c32052dc 828e78d4
const url = '/rop-scrm-marketing/router'
export default {
/**素材列表 */
getPsdList (data) {
getPsdList(data) {
data.method = 'marketing.api.material.list'
data.pageNum = 1
data.pageSize = 9999
......@@ -12,7 +12,7 @@ export default {
})
},
/** 素材组列表 */
getPsdGroupList (data = {}) {
getPsdGroupList(data = {}) {
data.method = 'marketing.api.material.group.list'
return window.$HTTP({
url,
......@@ -20,7 +20,7 @@ export default {
})
},
/** 素材发送/阅读埋点 */
sendReadBuriedPoint (params) {
sendReadBuriedPoint(params) {
let data = {
method: 'marketing.api.open.material.sendReadBuriedPoint',
list: [params]
......@@ -31,11 +31,19 @@ export default {
})
},
uploadMaterial (data = {}) {
uploadMaterial(data = {}) {
data.method = 'marketing.api.material.sop.upload'
return window.$HTTP({
url,
data
})
},
}
\ No newline at end of file
getTextDetail(data = {}) {
data.method = 'marketing.api.material.detail'
return window.$HTTP({
url,
data
})
}
}
......@@ -180,6 +180,7 @@ const WxConfig = {
shareToExternalMoments (params) {
return new Promise((resolve, reject) => {
wx.invoke('shareToExternalMoments', params, res => {
util.hideLoading()
if (res.err_msg == 'shareToExternalMoments:ok') {
resolve()
} else {
......
.sprite-icon { background-image: url(../images/sprite.png);background-size: 105px 86px;}
.icon-down { width: 12px; height: 12px; background-position: 0px -74px;}
.icon-eye { width: 13px; height: 8px; background-position: -22px -74px;}
.sprite-icon { background-image: url(../images/sprite.png);background-size: 105px 90px;}
.icon-down { width: 12px; height: 12px; background-position: -26px -74px;}
.icon-eye { width: 13px; height: 8px; background-position: -48px -74px;}
.icon-gift-del { width: 18px; height: 18px; background-position: -84px -30px;}
.icon-grctx { width: 16px; height: 16px; background-position: 0px -74px;}
.icon-link { width: 32px; height: 32px; background-position: -42px 0px;}
.icon-menu-active { width: 22px; height: 20px; background-position: 0px -44px;}
.icon-menu { width: 22px; height: 20px; background-position: -32px -44px;}
......

9.32 KB | W: | H:

10 KB | W: | H:

src/assets/images/sprite.png
src/assets/images/sprite.png
src/assets/images/sprite.png
src/assets/images/sprite.png
  • 2-up
  • Swipe
  • Onion skin
<template>
<div class="psd-item">
<div class="title flex">
{{item.materialName}}
{{ item.materialName }}
<template v-if="!hidePYQ">
<div
class="sprite-icon icon-PYQ"
@click="onEmit('share',item)"
></div>
<div class="sprite-icon icon-PYQ" @click="onEmit('share', item)"></div>
</template>
</div>
<div class="content">
<template v-if="item.materialType == 1">
<div class="sprite-icon icon-pdf"></div>
</template>
<template v-else-if="item.materialType == 2">链接</template>
<!-- <template v-else-if="item.materialType == 2">链接</template> -->
<template v-else>
<div
v-html="decodeURIComponent(item.materialUrl)"
class="hide"
></div>
<div @click="goDetailPage(item)" class="gr-ctx">
<div class="sprite-icon icon-grctx"></div>
查看图文
</div>
</template>
<!-- <template v-else>
<div v-html="decodeURIComponent(item.materialUrl)" class="hide"></div>
</template> -->
</div>
<div class="bottom flex">
<div class="num flex">
<div class="sprite-icon icon-send"></div>
{{item.sendNum}}
{{ item.sendNum }}
</div>
<div class="num flex">
<div class="sprite-icon icon-eye"></div>
{{item.readNum}}
{{ item.readNum }}
</div>
<van-button
block
round
color="#3975C6"
@click="onEmit('send',item)"
>
发送
</van-button>
<van-button block round color="#3975C6" @click="onEmit('send', item)">发送</van-button>
</div>
</div>
</template>
<script type='text/ecmascript-6'>
<script type="text/ecmascript-6">
export default {
name: 'Psd',
props: {
......@@ -58,12 +51,18 @@ export default {
methods: {
onEmit (name, item) {
this.$emit(name, item)
},
goDetailPage(i){
this.$router.push({
path: '/psd/detail',
query: {id:i.id,name:i.materialName}
})
}
}
}
</script>
<style scoped lang='scss'>
<style scoped lang="scss">
.psd-item {
background: #ffffff;
box-shadow: 0px 4px 8px 0px rgba(224, 224, 224, 0.5);
......@@ -87,6 +86,15 @@ export default {
padding: 10px 16px;
font-size: 12px;
color: #999999;
.gr-ctx {
display: flex;
align-items: center;
font-size: 28rpx;
color: #3975c6;
.icon-grctx {
margin-right: 5px;
}
}
.hide {
max-height: 150px;
overflow-y: scroll;
......@@ -116,4 +124,4 @@ export default {
}
}
}
</style>
\ No newline at end of file
</style>
......@@ -74,13 +74,15 @@ export default {
},
getList () {
let { materialName, businessType, groupId, sort } = this
marketingApi.getPsdList({ materialName, businessType, groupId }).then(data => {
console.log('素材列表', data)
if (sort != 0 && data && data.materialToCRpcResponses && data.materialToCRpcResponses.length) data.materialToCRpcResponses = this.sortList(data.materialToCRpcResponses, sort == 1 ? 'sendNum' : 'readNum')
this.list = data.materialToCRpcResponses || []
this.flag = true
this.hideLoading()
})
setTimeout(()=>{
marketingApi.getPsdList({ materialName, businessType, groupId }).then(data => {
console.log('素材列表', data)
if (sort != 0 && data && data.materialToCRpcResponses && data.materialToCRpcResponses.length) data.materialToCRpcResponses = this.sortList(data.materialToCRpcResponses, sort == 1 ? 'sendNum' : 'readNum')
this.list = data.materialToCRpcResponses || []
this.flag = true
this.hideLoading()
})
},500)
}
}
}
\ No newline at end of file
......@@ -22,69 +22,81 @@ export default {
shareToExternalMoments (i) {
this.sendMessage(i, true)
},
sendMessage (i, isPyq) {
async sendMessage (i, isPyq) {
const { shopmall_appid, envVersion } = window.$fetchConfig
const path = 'pages/psdView/psdView'
const { merchantId, uuid, sapCode } = this.getLocalStorage('dj_scrm_userInfo')
const { merchantId, uuid, sapCode, userName } = this.getLocalStorage('dj_scrm_userInfo')
const { entry } = this
const { materialName, id, titleUrl, materialTitle, description } = i
const { materialName, id, titleUrl, materialTitle, description, videoUrl, imageUrlList } = i
// let fisrtFrame = videoUrl && await this.getVideoFirstFrame(videoUrl)
const imgUrl = 'https://img01.glsx.com.cn/weapp/resource/scrm-mobile/test/test.jpg'
let frameUrl = (imageUrlList && imageUrlList.length) ? imageUrlList[0] : imgUrl
let query = `merchantId=${merchantId}&id=${id}&staffUuid=${uuid}&shareTime=${Date.now()}`
if (sapCode) query = `${query}&storeCode=${sapCode}`
wxConfig.createMiniprogramUrlLink({
path,
query,
appId: shopmall_appid,
envVersion
})
.then(link => {
this.showLoading()
if (isPyq) {
console.log('朋友圈')
wxConfig.shareToExternalMoments({
attachments: [
{
msgtype: 'link', // 消息类型,必填
link: {
title: materialTitle || materialName, // H5消息标题
imgUrl: titleUrl || imgUrl, // H5消息封面图片URL
url: link // H5消息页面url 必填
},
}
]
}).then(() => {
this.sendReadBuriedPoint({ id, merchantId, uuid })
this.hideLoading()
})
.catch(err => {
this.hideLoading()
})
} else {
if (isPyq) {
const data = {
path,
query: encodeURIComponent(query),
appId: shopmall_appid,
envVersion
}
let url = window.location.origin.replace('scrm', 'wechatlink')
wxConfig.shareToExternalMoments({
attachments: [
{
msgtype: 'link', // 消息类型,必填
link: {
title: materialTitle || `「${userName}」邀请您查看「${materialName}」`, // H5消息标题
imgUrl: titleUrl || frameUrl, // H5消息封面图片URL
url: `${url}?linkData=${encodeURIComponent(JSON.stringify(data))}` // H5消息页面url 必填
},
}
]
}).then(() => {
this.sendReadBuriedPoint({ id, merchantId, uuid })
this.hideLoading()
})
.catch(err => {
this.hideLoading()
})
} else {
wxConfig.createMiniprogramUrlLink({
path,
query,
appId: shopmall_appid,
envVersion
})
.then(link => {
// console.log('再次进来了吗')
// this.showLoading()
let params = {
link,
title: materialTitle || materialName,
title: materialTitle || `「${userName}」邀请您查看「${materialName}」`,
desc: description || '',
imgUrl: titleUrl || imgUrl
imgUrl: titleUrl || frameUrl
}
wxConfig.getContext().then((res) => {
if (res.entry != 'normal'){
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 })
}
})
}
})
// if (entry != 'normal') this.sendChatMessage(params, { id, merchantId, uuid })
// else this.shareAppMessage(params, { id, merchantId, uuid })
this.shareAppMessage(params, { id, merchantId, uuid })
// wxConfig.getContext().then((res) => {
// if (res.entry != 'normal'){
// 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 })
// }
// })
})
}
},
sendReadBuriedPoint ({ id, merchantId, uuid }) {
marketingApi.sendReadBuriedPoint({
......@@ -94,7 +106,7 @@ export default {
staffUuid: uuid
})
},
getParam(item,sendParams){
getParam (item, sendParams) {
let str = decodeURIComponent(item.materialUrl)
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
let arr = str.match(testReg)
......@@ -109,7 +121,7 @@ export default {
} 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;','<') : ''
return item.slice(1, -1) ? item.slice(1, -1).replaceAll('&amp;', '&').replaceAll('&gt;', '>').replaceAll('&lt;', '<') : ''
}
})
arr = arr.filter(item => item)
......@@ -119,56 +131,55 @@ export default {
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']
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
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.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)
}
})
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)=>{
getTextPromise (ele) {
return new Promise((resolve, reject) => {
resolve({
msgtype: 'text',
text: {content: ele},
text: { content: ele },
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){
uploadMaterial (param, type) {
return new Promise((resolve, reject) => {
marketingApi.uploadMaterial(param).then(res => {
if (res?.mediaId) {
if (type == 1) {
resolve({
msgtype: 'file',
file: {mediaid: res.mediaId},
file: { mediaid: res.mediaId },
enterChat: false
})
}else if(type==3){
} else if (type == 3) {
resolve({
msgtype: 'image',
image: {mediaid: res.mediaId},
image: { mediaid: res.mediaId },
enterChat: false
})
}else{
} else {
resolve({
msgtype: 'video',
video: {mediaid: res.mediaId},
video: { mediaid: res.mediaId },
enterChat: false
})
}
......@@ -177,18 +188,17 @@ export default {
})
},
sendChatMessage (params, sendParams) {
return new Promise((resolve,reject)=>{
return new Promise((resolve, reject) => {
this.showLoading()
wxConfig
.sendChatMessage(params)
.then(res => {
this.hideLoading()
this.sendReadBuriedPoint(sendParams)
resolve()
}).catch(err => {
console.log(err)
this.hideLoading()
})
.sendChatMessage(params)
.then(res => {
this.hideLoading()
this.sendReadBuriedPoint(sendParams)
resolve()
}).catch(err => {
this.hideLoading()
})
})
},
shareAppMessage (params, sendParams) {
......
......@@ -48,7 +48,9 @@ import {
ShareSheet,
Overlay,
loading,
SwipeCell
SwipeCell,
Swipe,
SwipeItem
} from 'vant'
export const components = [
Button,
......@@ -91,5 +93,7 @@ export const components = [
ShareSheet,
Overlay,
loading,
SwipeCell
]
\ No newline at end of file
SwipeCell,
Swipe,
SwipeItem
]
......@@ -3,6 +3,8 @@ const pages = {
name: 'index'
}, {
name: 'list'
}, {
name: 'detail'
}
],
openEnterpriseChat: [
......
......@@ -165,7 +165,43 @@ const watchPageBack = () => {
const centsToyuan = price => {
return decimal(price / 100, 2).toFixed(2)
}
const getVideoFirstFrame = (url)=> {
return new Promise(function (resolve) {
let dataURL = ''
let video = document.createElement("video")
video.setAttribute('crossOrigin', 'anonymous')//处理跨域
video.setAttribute('src', url)
video.setAttribute('autoplay', 'autoplay')
video.addEventListener('canplaythrough', function () {
video.setAttribute('width', video.videoWidth)
video.setAttribute('height', video.videoHeight)
let canvas = document.createElement("canvas"),
width = video.width, //canvas的尺寸和图片一样
height = video.height
canvas.width = width
canvas.height = height
canvas.getContext("2d").drawImage(video, 0, 0, width, height) //绘制canvas
dataURL = canvas.toDataURL('image/jpeg') //转换为base64
//转换成file
const arr = dataURL.split(",")
const mime = arr[0].match(/:(.*?);/)[1]
const bstr = window.atob(arr[1])
let n = bstr.length
const u8arr = new Uint8Array(n)
while (n--) {
u8arr[n] = bstr.charCodeAt(n)
}
const FILE = new File([u8arr], 'cover'+Date.now()+'.jpeg', { type: mime })
resolve({
dataURL, //预览路径
file:FILE, //上传的文件
})
})
})
}
const utils = {
getVideoFirstFrame,
removeLocalStorage,
setClipboardData,
jumpChildrenPage,
......
<template>
<div class="layout" v-if="loaded">
<div>
<template v-if="(info.imageUrlList && info.imageUrlList.length) || info.videoUrl">
<van-swipe @change="changeSwiper" height="210" show-indicators>
<van-swipe-item v-if="info.videoUrl">
<video id="swiper_video" :autoplay="autoplay" controls controlslist="nodownload" disablepictureinpicture playsinline="true" :src="info.videoUrl"></video>
</van-swipe-item>
<van-swipe-item v-for="(item, index) in info.imageUrlList" :key="index">
<van-image width="100%" height="100%" fit="contain" :src="item" />
</van-swipe-item>
<template #indicator>
<div class="custom-indicator">{{ curIdx + 1 }}/{{ fileNum }}</div>
</template>
</van-swipe>
</template>
<div class="rich-text">
<div v-html="decodeURIComponent(info.materialUrl)" class="hide"></div>
</div>
</div>
<div class="bottom-send flex">
<div class="num flex">
<div class="sprite-icon icon-send"></div>
{{ info.sendNum }}
</div>
<div class="num flex">
<div class="sprite-icon icon-eye"></div>
{{ info.readNum }}
</div>
<van-button block round @click="shareToExternalMoments(info)">分享朋友圈</van-button>
<van-button block round color="#3975C6" @click="sendMessage(info)">转发</van-button>
</div>
</div>
</template>
<script type="text/ecmascript-6">
import { marketingApi } from '@/api'
import { shareMixin } from '@/mixins'
export default {
mixins: [shareMixin],
name: 'detail',
data() {
return {
curIdx: 0,
fileList: [],
autoplay: 3000,
materialUrl: '',
info: {},
fileNum: 0,
loaded: false,
poster: ''
}
},
beforeRouteEnter (to, from, next) {
let {query} = to
document.title = query.name || '详情'
next()
},
created() {
const { id } = this.getQuery()
// let id = 148
this.getDetail(id)
},
mounted() {
},
methods: {
changeSwiper(idx) {
this.curIdx = idx
},
getDetail(id) {
marketingApi.getTextDetail({ id, flag: 0 }).then(data => {
if(data){
// const fileList = []
// if (data.videoUrl) {
// fileList.push({ type: 'video', url: data.videoUrl })
// }
// if (data.imageUrlList && data.imageUrlList.length) {
// data.imageUrlList.forEach(item => {
// fileList.push({ type: 'image', url: item })
// })
// }
// this.fileList = fileList
this.fileNum = data.imageUrlList && data.imageUrlList.length ? data.imageUrlList.length: 0
if(data.videoUrl) this.fileNum = this.fileNum + 1
this.info = data
this.loaded = true
if(!data.videoUrl) return;
// this.getVideoFirstFrame(data.videoUrl).then(res => {
// this.poster = res.dataURL
// })
this.$nextTick(()=>{
const video = document.getElementById('swiper_video')
video.addEventListener('play', ()=> {
this.autoplay = 0
})
video.addEventListener('pause', ()=> {
this.autoplay = 3000
})
video.addEventListener('ended', ()=> {
this.autoplay = 3000
}, false)
})
}
})
}
}
}
</script>
<style lang="scss">
.layout {
background-color: #fff;
}
.van-swipe {
background-color: #f8f8f8;
padding-bottom: 20px;
}
.van-swipe-item {
height: 210px;
}
#swiper_video {
width: 100%;
height: 100%;
}
.custom-indicator {
display: inline-block;
text-align: center;
position: absolute;
top: 10px;
right: 10px;
width: 38px;
font-size: 11px;
color: #ffffff;
height: 24px;
line-height: 24px;
background: #666666;
border-radius: 12px;
}
.rich-text {
padding-bottom: 120px;
}
.hide img {
width: 100%;
height: unset;
}
.bottom-send {
padding: 0 16px 34px;
height: 82px;
background: #f8f8f8;
border-radius: 0px 0px 4px 4px;
position: fixed;
bottom: 0;
width: 100%;
box-sizing: border-box;
box-shadow: 0 0 0 0 #e9e9e9;
border-top: 1px solid #dcdee0;
.num {
font-size: 12px;
color: #999999;
margin-right: 10px;
.sprite-icon {
margin-right: 4px;
}
}
.van-button {
min-width: 100px;
height: 36px;
font-size: 12px;
margin-left: 10px;
}
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!