Commit df9c969e by 王玉曼

20210422

1 parent d8f61858
<script>
import { getAgentTicket, getAppTicket } from '@/api/common'
export default {
name: 'App',
data() {
return {
appId: '',
agentId: '1000005',
}
},
created() {},
watch: {
// 通过config接口注入权限验证配置
// 所有需要使用JS-SDK的页面必须先注入配置信息,否则将无法调用(同一个url仅需调用一次,对于变化url的SPA(single-page application)的web app可在每次url变化时进行调用)
// $route() {
// this.wxConfig()
// },
},
methods: {
wxConfig() {
getAgentTicket(window.location.href.split('#')[0]).then(({ data }) => {
let { timestamp, nonceStr, signature } = data
wx.agentConfig({
debug: true,
corpid: this.appId, // 必填,企业微信的corpid,必须与当前登录的企业一致
agentid: this.agentId, // 必填,企业微信的应用id (e.g. 1000247)
timestamp, // 必填,生成签名的时间戳
nonceStr, // 必填,生成签名的随机串
signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
jsApiList: ['sendChatMessage', 'getContext'], //必填
success: (res) => {
// 回调
// this.$toast('agentId成功:')
},
fail: (res) => {
this.$toast('agentId失败:' + JSON.stringify(res))
if (res.errMsg.indexOf('function not exist') > -1) {
alert('版本过低请升级')
}
},
})
})
},
// 丢弃
// _wxConfig() {
// // 获取企业的jsapi_ticket
// getAppTicket(window.location.href).then(({ data }) => {
// let { timestamp, nonceStr, signature } = data
// wx.config({
// beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
// debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
// appId: this.appId, // 必填,企业微信的corpID
// timestamp, // 必填,生成签名的时间戳
// nonceStr, // 必填,生成签名的随机串
// signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
// jsApiList: ['getContext', 'sendChatMessage'], // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
// })
// wx.ready(() => {
// // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
// getAgentTicket(window.location.href).then(({ data }) => {
// let { timestamp, nonceStr, signature } = data
// wx.agentConfig({
// corpid: this.appId, // 必填,企业微信的corpid,必须与当前登录的企业一致
// agentid: this.agentId, // 必填,企业微信的应用id (e.g. 1000247)
// timestamp, // 必填,生成签名的时间戳
// nonceStr, // 必填,生成签名的随机串
// signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
// jsApiList: ['sendChatMessage'], //必填
// success: (res) => {
// // 回调
// },
// fail: (res) => {
// if (res.errMsg.indexOf('function not exist') > -1) {
// alert('版本过低请升级')
// }
// },
// })
// })
// })
// wx.error(function(res) {
// console.error(res)
// // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
// })
// })
// },
},
}
</script>
<template>
<div id="app">
<router-view class="page" />
</div>
</template>
<style lang="less">
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #2c3e50;
}
</style>
<script>
import { getAgentTicket, getAppTicket } from '@/api/common'
export default {
name: 'App',
provide() {
return {
reload: this.reload
}
},
data() {
return {
appId: '',
agentId: '1000005',
isRouterAlive : true
}
},
created() {},
watch: {
// 通过config接口注入权限验证配置
// 所有需要使用JS-SDK的页面必须先注入配置信息,否则将无法调用(同一个url仅需调用一次,对于变化url的SPA(single-page application)的web app可在每次url变化时进行调用)
// $route() {
// this.wxConfig()
// },
},
methods: {
reload () {
this.isRouterAlive = false
this.$nextTick(function() {
this.isRouterAlive = true
})
},
wxConfig() {
getAgentTicket(window.location.href.split('#')[0]).then(({ data }) => {
let { timestamp, nonceStr, signature } = data
wx.agentConfig({
debug: true,
corpid: this.appId, // 必填,企业微信的corpid,必须与当前登录的企业一致
agentid: this.agentId, // 必填,企业微信的应用id (e.g. 1000247)
timestamp, // 必填,生成签名的时间戳
nonceStr, // 必填,生成签名的随机串
signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
jsApiList: ['sendChatMessage', 'getContext'], //必填
success: (res) => {
// 回调
// this.$toast('agentId成功:')
},
fail: (res) => {
this.$toast('agentId失败:' + JSON.stringify(res))
if (res.errMsg.indexOf('function not exist') > -1) {
alert('版本过低请升级')
}
},
})
})
},
// 丢弃
// _wxConfig() {
// // 获取企业的jsapi_ticket
// getAppTicket(window.location.href).then(({ data }) => {
// let { timestamp, nonceStr, signature } = data
// wx.config({
// beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
// debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
// appId: this.appId, // 必填,企业微信的corpID
// timestamp, // 必填,生成签名的时间戳
// nonceStr, // 必填,生成签名的随机串
// signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法
// jsApiList: ['getContext', 'sendChatMessage'], // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
// })
// wx.ready(() => {
// // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
// getAgentTicket(window.location.href).then(({ data }) => {
// let { timestamp, nonceStr, signature } = data
// wx.agentConfig({
// corpid: this.appId, // 必填,企业微信的corpid,必须与当前登录的企业一致
// agentid: this.agentId, // 必填,企业微信的应用id (e.g. 1000247)
// timestamp, // 必填,生成签名的时间戳
// nonceStr, // 必填,生成签名的随机串
// signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
// jsApiList: ['sendChatMessage'], //必填
// success: (res) => {
// // 回调
// },
// fail: (res) => {
// if (res.errMsg.indexOf('function not exist') > -1) {
// alert('版本过低请升级')
// }
// },
// })
// })
// })
// wx.error(function(res) {
// console.error(res)
// // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
// })
// })
// },
},
}
</script>
<template>
<div id="app">
<router-view class="page" v-if="isRouterAlive" />
</div>
</template>
<style lang="less">
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #2c3e50;
}
</style>
import request from "@/utils/request";
const wecom = window.CONFIG.services.wecom;
const service = wecom + "/portrait";
// 根据客户id和当前企业员工id获取客户详细信息
export function getCustomerInfo(params) {
return request({
url: service + "/findWeCustomerInfo",
params,
});
}
// 客户画像资料更新
export function getWeCustomerInfo(data) {
return request({
url: service + "/updateWeCustomerInfo",
method: 'post',
data:{
"externalUserid": data.externalUserid, // 客户Id
"userId": data.userId, // 员工Id
"remarkMobiles": data.remarkMobiles, // 手机号
"birthday": data.birthday, // 客户生日
"email": data.email, // 邮箱
"address": data.address, // 地址
"qq": data.qq, // qq
"position": data.position, // 职业
"remarkCorpName": data.remarkCorpName, // 公司
"description": data.description, // 其他描述
}
});
}
// 获取当前系统所有可用标签
export function getAllTags(params) {
return request({
url: service + "/findAllTags",
params,
});
}
import request from "@/utils/request";
const wecom = window.CONFIG.services.wecom;
const service = wecom + "/portrait";
// 根据客户id和当前企业员工id获取客户详细信息
export function getCustomerInfo(params) {
return request({
url: service + "/findWeCustomerInfo",
params,
});
}
// 客户画像资料更新
export function getWeCustomerInfo(data) {
return request({
url: service + "/updateWeCustomerInfo",
method: 'post',
data:{
"externalUserid": data.externalUserid, // 客户Id
"userId": data.userId, // 员工Id
"remarkMobiles": data.remarkMobiles, // 手机号
"birthday": data.birthday, // 客户生日
"email": data.email, // 邮箱
"address": data.address, // 地址
"qq": data.qq, // qq
"position": data.position, // 职业
"remarkCorpName": data.remarkCorpName, // 公司
"description": data.description, // 其他描述
}
});
}
// 获取当前系统所有可用标签
export function getAllTags(params) {
return request({
url: service + "/findAllTags",
params,
});
}
// 更新客户画像标签
export function updateWeCustomerPorTraitTag(data) {
return request({
url: service + "/updateWeCustomerPorTraitTag",
method: 'post',
data,
});
}
// 查看客户添加的员工
export function findAddaddEmployes(params) {
return request({
url: service + "/findAddaddEmployes/" + params,
});
}
// 获取用户添加的群
export function findAddGroupNum(params) {
return request({
url: service + "/findAddGroupNum",
params,
});
}
// 获取轨迹信息
export function findTrajectory(params) {
return request({
url: service + "/findTrajectory",
params,
});
}
// 添加或编辑轨迹
export function addOrEditWaitHandle(data) {
return request({
url: service + "/addOrEditWaitHandle",
method: 'post',
data,
});
}
// 删除轨迹
export function removeTrajectory(params) {
return request({
url: service + "/removeTrajectory/" + params,
method: 'delete',
});
}
// 完成待办
export function handleWait(params) {
return request({
url: service + "/handleWait/" + params,
method: 'delete',
});
}
\ No newline at end of file
<template>
<div>
<van-list
v-model="loading"
:finished="finished"
finished-text="没有更多了"
loading-text="上划加载更多"
>
<van-cell v-for="(item, index) in wList" :key="index">
<!-- {{item[0].createDate}} -->
<!-- 时间 -->
<p class="f12" style="position:relative; ">
{{ getTime1(item[0].createDate) }}
{{ getTime3(getTime1(item[0].createDate)) }}
<!-- {{item1.trajectoryType}} -->
</p>
<!-- <van-cell> -->
<van-steps
direction="vertical"
inactive-color="#2c8cf0"
:active="active"
v-for="(item1, index) in item"
:key="index"
>
<van-step class="msg">
<span class="f12 po">
{{ getTime2(getTime1(item1.createDate)) }}</span
>
<span class="fs14">{{ chargeType(item1.trajectoryType) }}</span>
<span
class="finish"
v-if="item1.trajectoryType == 4"
@click="finDynamic(item1.id)"
>完成</span
>
<span class="deldynamic" @click="delDynamic(item1.id)">删除</span>
<p class="fs14 con ">{{ item1.content }}</p>
</van-step>
<!-- <van-step>
<span class="f12 po"> 12:40</span>
<span class="fs14">社交动态</span>
<span class="deldynamic">删除</span>
<p class="fs14 con ">编辑编辑</p>
</van-step> -->
</van-steps>
</van-cell>
<van-divider />
</van-list>
</div>
</template>
<script>
import { removeTrajectory, handleWait } from "@/api/portrait";
export default {
props: ["stepList"],
inject:['reload'],
data() {
return {
// 步骤条
active: -1,
// 轨迹外层按时间
wlist: [],
// 轨迹内层
nlist: [],
oldele: [],
content: "",
type: 0,
wList: [],
finished: false,
loading: false,
};
},
watch: {
stepList(newVal, oldVal) {
// console.log(newVal, oldVal);
if (newVal != oldVal) {
// debugger
this.wlist = [];
this.wList = [];
this.oldele = [];
this.nlist = [];
}
newVal.forEach((ele) => {
this.oldele.push(parseInt(this.getTime(ele.createDate)));
// console.log(parseInt(this.getTime(ele.createDate)));
});
// console.log(this.oldele);
this.oldele = this.newArr(this.oldele).sort(this.f);
// console.log(this.oldele);
for (let i = 0; i < this.oldele.length; i++) {
for (let j = 0; j < newVal.length; j++) {
// console.log(newVal[j].createDate);
if (this.oldele[i] == this.getTime(newVal[j].createDate)) {
this.nlist.push(newVal[j]);
// console.log(this.nlist);
}
}
this.wlist.push(this.nlist);
this.nlist = [];
}
// console.log(this.wlist);
this.onLoad()
},
},
methods: {
onLoad() {
// 异步更新数据
// setTimeout 仅做示例,真实场景中一般为 ajax 请求
setTimeout(() => {
// debugger
let total = this.wlist.length > 10 ? 10 : this.wlist.length;
for (let i = 0; i < total; i++) {
this.wList.push(this.wlist[i]);
}
// 加载状态结束
this.loading = false;
// 数据全部加载完成
if (this.wList.length >= this.wlist.length) {
this.finished = true;
}
}, 1000);
},
// 根据数字判断类型
chargeType(num) {
if (num == 1) {
return (this.type = "信息动态");
} else if (num == 2) {
return (this.type = "社交动态");
} else if (num == 3) {
return (this.type = "活动规则");
} else if (num == 4) {
return (this.type = "待办动态");
}
},
// 数组去重
newArr(arr) {
return Array.from(new Set(arr));
},
// 数组由大到小排序
f(a, b) {
//排序函数
return -(a - b); //取反并返回比较参数
},
// 时间处理器
getTime(data) {
const date = new Date(data);
// console.log(timer.getFullYear());
var Y = date.getFullYear();
var M =
date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1;
var D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
return Y + M + D;
},
getTime1(data) {
const date = new Date(data);
// console.log(timer.getFullYear());
var Y = date.getFullYear() + "-";
var M =
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-";
var D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
return Y + M + D;
},
getTime2(data) {
const date = new Date(data);
// console.log(timer.getFullYear());
var h =
(date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
var m =
date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
return h + m;
},
// 处理星期几
getTime3(time) {
var dateArray = time.split("-");
var date = new Date(
dateArray[0],
parseInt(dateArray[1] - 1),
dateArray[2]
);
var week = "星期" + "日一二三四五六".charAt(date.getDay());
return week;
},
// 删除轨迹
delDynamic(id) {
removeTrajectory(id)
.then((data) => {
// console.log(data.code);
if (data.code == 200) {
// 提示删除成功
// this.msgSuccess("删除成功");
// debugger
// location.reload();
this.$toast.success('删除成功');
this.reload ()
// 重新获取全部数据
}
})
.catch((err) => {
console.log(err);
});
},
// 点击完成
finDynamic(id) {
handleWait(id)
.then((data) => {
if (data.code == 200) {
this.delDynamic(id);
this.reload();
}
})
.catch((err) => {
console.log(err);
});
},
},
};
</script>
<style lang="less" scoped>
.f12 {
color: #9c9c9c;
font-size: 12px;
font-weight: 600;
}
/deep/.msg {
&::after {
border: none;
}
.po {
position: relative;
}
}
.fs14 {
color: #333;
font-size: 14px;
position: relative;
left: 20px;
}
.deldynamic {
float: right;
color: #9c9c9c;
font-size: 12px;
font-weight: 600;
}
.con {
left: 51px;
margin-top: 20px;
}
.finish {
position: relative;
color: #2c8cf0;
font-size: 12px;
font-weight: 600;
right: -138px;
top: 0px;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!