groupSopTip.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>客户群SOP</title>
  8. <!--引入 element-ui 的样式,-->
  9. <link rel="stylesheet"
  10. href="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742018383195/element-ui.css">
  11. <!-- 必须先引入vue, 后使用element-ui -->
  12. <script
  13. src="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742017957144/vue.js"></script>
  14. <!-- 引入element 的组件库-->
  15. <script
  16. src="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742017747738/element-ui.js"></script>
  17. <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
  18. <script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"></script>
  19. <!-- <script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script>
  20. <script>
  21. var vConsole = new window.VConsole();
  22. </script> -->
  23. </head>
  24. <style>
  25. body {
  26. margin: 0;
  27. padding: 0;
  28. }
  29. .box {
  30. width: 100vw;
  31. height: 100vh;
  32. box-sizing: border-box;
  33. background: #FAFAFA;
  34. }
  35. .page4 {
  36. width: 100vw;
  37. height: 100vh;
  38. box-sizing: border-box;
  39. }
  40. .top_tip {
  41. background: #afdefd;
  42. display: flex;
  43. justify-content: center;
  44. color: #FFF;
  45. font-size: 14px;
  46. padding: 6px 0;
  47. }
  48. .logo {
  49. width: 20px;
  50. height: 20px;
  51. margin-right: 10px;
  52. }
  53. .content {
  54. padding: 20px;
  55. margin-bottom: 10px;
  56. background: #FFF;
  57. }
  58. .icon_logo {
  59. width: 20px;
  60. vertical-align: bottom;
  61. }
  62. .sop_content {
  63. background: #f1f9ff;
  64. padding: 10px 20px;
  65. border-radius: 10px;
  66. font-size: 14px;
  67. }
  68. .font {
  69. color: #1890ff;
  70. }
  71. .send_title {
  72. padding: 20px;
  73. background: #FFF;
  74. border-bottom: 1px solid #d2d3d4;
  75. }
  76. .send_content {
  77. padding: 20px;
  78. background: #FFF;
  79. margin-bottom: 10px;
  80. }
  81. .send_item {
  82. background: #F8F8F8;
  83. padding: 20px;
  84. margin-bottom: 10px;
  85. border-radius: 10px;
  86. font-size: 14px;
  87. }
  88. .send_logo {
  89. width: 60px;
  90. height: 60px;
  91. margin-right: 10px;
  92. border-radius: 10px;
  93. }
  94. .follow_client {
  95. display: flex;
  96. align-items: center;
  97. justify-content: space-between;
  98. padding: 20px;
  99. font-size: 14px;
  100. background: #FFF;
  101. }
  102. .client_msg {
  103. display: flex;
  104. flex-direction: column;
  105. }
  106. .avatar {
  107. width: 60px;
  108. height: 60px;
  109. border-radius: 10px;
  110. }
  111. .follow_btn {
  112. background: #f1f9ff;
  113. color: #1890ff;
  114. padding: 5px;
  115. border-radius: 4px;
  116. font-size: 12px;
  117. }
  118. </style>
  119. <body>
  120. <div id="box" class="box">
  121. <!-- 数据查看 -->
  122. <div class="page4">
  123. <div class="top_tip">
  124. <img class="logo" src="./img/wefan.png"></img>
  125. 微分机器人提供技术支持
  126. </div>
  127. <div class="content">
  128. <div class="sop_content">
  129. <img class="icon_logo" :src="executeData.clientAvatar || './img/avatar.png'"></img>
  130. <span>「{{executeData.clientName}}」在「{{timeFormat(executeData.triggerTime, 'yyyy/MM/dd hh:mm:ss')}}」</span>
  131. <span class="font" v-if="executeData.triggerType">添加好友后触发客户SOP任务,</span>
  132. <span class="font" v-else>打上标签后触发客户SOP任务,</span>
  133. <span>快去跟进吧</span>
  134. </div>
  135. </div>
  136. <div class="send_title">推送内容</div>
  137. <div class="send_content">
  138. <div class="send_item" v-for="(item, index) in executeData.ctOthers" :key="index">
  139. <img v-if="item.imgUrl" class="send_logo" :src="item.imgUrl"></img>
  140. <span>{{item.matterText}}</span>
  141. </div>
  142. </div>
  143. <div class="send_title">跟进客户</div>
  144. <div class="follow_client">
  145. <img class="avatar" :src="executeData.clientAvatar || './img/avatar.png'"></img>
  146. <div class="client_msg">
  147. <span class="font">{{executeData.clientName}}</span>
  148. <span>添加时间:{{timeFormat(executeData.addTime, 'yyyy/MM/dd hh:mm:ss')}}</span>
  149. </div>
  150. <div class="follow_btn" @click="toFollow">去跟进</div>
  151. </div>
  152. </div>
  153. </div>
  154. </body>
  155. <script>
  156. new Vue({
  157. el: '#box',
  158. data () {
  159. return {
  160. httpUrl: '',
  161. bId: null,
  162. env: '',
  163. activeName: 'playing',
  164. executeData: {
  165. clientName: '',
  166. addTime: '',
  167. triggerTime: '',
  168. triggerType: '',
  169. ctOthers: [],
  170. chatId: '',
  171. clientAvatar: '',
  172. },
  173. }
  174. },
  175. created () {
  176. this.bId = this.getQueryParam('bId')
  177. this.env = this.getQueryParam('env')
  178. if (!this.env || this.env === 'prod') {
  179. this.httpUrl = 'https://wlapi.wefanbot.com'
  180. } else {
  181. this.httpUrl = 'http://test.wefanbot.com:18993'
  182. }
  183. this.executeDetail()
  184. this.getQyWxSign()
  185. },
  186. methods: {
  187. executeDetail () {
  188. fetch(this.httpUrl + `/scrm/v1/wxcp-group-sop/p/executeDetail?id=${this.bId}`)
  189. .then(res => {
  190. return res.json()
  191. }).then(result => {
  192. let { data, code, msg } = result
  193. if (code === 1) {
  194. this.executeData = data
  195. } else {
  196. this.$message({
  197. message: msg,
  198. type: 'warning'
  199. })
  200. }
  201. })
  202. },
  203. getQyWxSign () {
  204. fetch(this.httpUrl + '/scrm/v1/wxcp-corp/p/getAgentConfig', {
  205. method: 'post',
  206. body: JSON.stringify({
  207. bId: this.bId,
  208. url: window.location.href,
  209. }),
  210. headers: {
  211. 'Content-Type': 'application/json'
  212. }
  213. }).then(res => {
  214. return res.json()
  215. }).then(result => {
  216. let { data, code, msg } = result
  217. if (code === 1) {
  218. wx.config({
  219. beta: true,
  220. debug: false,
  221. appId: data.corpid, // 必填,企业号的唯一标识,此处填写企业号corpid
  222. timestamp: data.timestamp, // 必填,生成签名的时间戳
  223. nonceStr: data.nonceStr, // 必填,生成签名的随机串
  224. signature: data.agentSignature, // 必填,签名,见附录1
  225. jsApiList: ['checkJsApi', 'openEnterpriseChat'] // 必填,需要使用的JS接口列表
  226. })
  227. wx.agentConfig({
  228. corpid: data.corpid,
  229. agentid: data.agentId,
  230. timestamp: data.timestamp, // 必填,生成签名的时间戳
  231. nonceStr: data.nonceStr, // 必填,生成签名的随机串
  232. signature: data.agentSignature, // 必填,签名,见附录1
  233. jsApiList: ['openEnterpriseChat'], // 必填,需要使用的JS接口列表
  234. success: function(res) {
  235. // 回调
  236. console.log('agentConfig成功', res);
  237. },
  238. fail: function(res) {
  239. if (res.errMsg.indexOf('function not exist') > -1) {
  240. alert('版本过低请升级');
  241. }
  242. },
  243. complete: function(res) {
  244. // 回调
  245. console.log('complete', res);
  246. }
  247. });
  248. } else {
  249. this.$message({
  250. message: msg,
  251. type: 'warning'
  252. })
  253. }
  254. })
  255. },
  256. toFollow () {
  257. wx.openEnterpriseChat({
  258. groupName: "", // 会话名称。单聊时该参数传入空字符串""即可。
  259. chatId: this.executeData.chatId,
  260. success: function(res) {
  261. var chatId = res.chatId; //返回当前群聊ID,仅当使用agentConfig注入该接口权限时才返回chatId
  262. // 回调
  263. console.log('成功', res);
  264. },
  265. fail: function(res) {
  266. // 回调
  267. if (res.errMsg.indexOf('function not exist') > -1) {
  268. alert('版本过低请升级');
  269. }
  270. console.log('失败', res);
  271. },
  272. complete: function(res) {
  273. // 回调
  274. console.log('完成', res);
  275. }
  276. });
  277. },
  278. // 截取url中的数据
  279. getQueryParam (paramName) {
  280. // 获取当前URL的查询字符串部分
  281. const queryString = window.location.search;
  282. // 创建一个URLSearchParams对象
  283. const urlParams = new URLSearchParams(queryString);
  284. // 返回指定参数的值,如果不存在则返回null
  285. return urlParams.get(paramName);
  286. },
  287. timeFormat (time, format = 'yyyy-MM-dd hh:mm:ss') {
  288. if (time === undefined || time === '' || time === null) {
  289. return '/'
  290. } else {
  291. const date = new Date(time)
  292. const o = {
  293. 'M+': date.getMonth() + 1,
  294. 'd+': date.getDate(),
  295. 'h+': date.getHours(),
  296. 'm+': date.getMinutes(),
  297. 's+': date.getSeconds(),
  298. 'q+': Math.floor((date.getMonth() + 3) / 3),
  299. 'S': date.getMilliseconds()
  300. }
  301. if (/(y+)/.test(format)) {
  302. format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
  303. }
  304. for (let k in o) {
  305. if (new RegExp('(' + k + ')').test(format)) {
  306. format = format.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
  307. }
  308. }
  309. return format
  310. }
  311. },
  312. }
  313. })
  314. </script>
  315. </html>