customerDetail.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. <template>
  2. <view>
  3. <view class="bgf center ptb20">客户详情</view>
  4. <view class="topBgline plr20 column justify-center">
  5. <view class="justify-between align-center radius12">
  6. <view class="justify-start align-center">
  7. <u-avatar :src='user.avatar' size="60"></u-avatar>
  8. <view class="ml16 colorf">
  9. <view class="bold fs28 ">{{user.name?user.name:'用户信息加载中...'}}</view>
  10. <view class="fs24 mt20">备注:{{user.remark}}</view>
  11. </view>
  12. </view>
  13. <view class="ml90">
  14. <view @click="clearhuan()" class=" bgcolf fs24 w160 center radius40 colorf ptb10"
  15. >清除缓存</view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="justify-between align-center bgf newsbox plr20">
  20. <view class="fs28 pt20 fs32 bold" >看课记录</view>
  21. <view class="lh45 plr20 fs24 radius40 h50 justify-between align-center" style="color: #999;"
  22. @click="todetail">
  23. <view> {{typestate==0?'更多详情':'点击收起'}}</view>
  24. <image src="/static/arrow_up.png" class="w30 h30 ml10" v-if='typestate==1'></image>
  25. <image src="/static/arrow_down.png" class="w30 h30 ml10" v-else></image>
  26. </view>
  27. </view>
  28. <view class="bgf p20">
  29. <view class="justify-start ">
  30. <view v-for="(item,index) in titname" :key="index" class="justify-start align-center ml28">
  31. <view :style="{ backgroundColor: statusColors[index] || '#CCCCCC' }"
  32. class="w24 h24 radius4"></view>
  33. <view class="fs24 mr6 ml10">{{item}}</view>
  34. </view>
  35. </view>
  36. <view class="fs24 mt20 base-color-6" >近{{typestate==0?'7':'30'}}天看课记录</view>
  37. <view class="justify-between mt20">
  38. <view class="justify-start align-center mt12 " style="width: 100%;flex-wrap: wrap">
  39. <view class="w54 h54 mr20 radius4 mb12" v-for="(item,index) in answerlist" :key="index"
  40. >
  41. <view class="fs24 base-color-6">{{item.date.slice(-2)}}</view>
  42. <view :style="{ backgroundColor: statusColors[item.logType] || '#CCCCCC' }"
  43. class="w30 h30 radius4"></view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="bgf p20 mt20">
  49. <view class="justify-between align-center">
  50. <view class="bold fs32">用户信息</view>
  51. <view @click="changeuser()" class="plr20 ptb6 radius40 justify-between align-center editbox">
  52. <image src="/static/services_edit.png " class="w28 h28"></image>
  53. <view class="fs24 ml10">修改用户信息</view>
  54. </view>
  55. </view>
  56. <view class="justify-between align-center fs24 mt20 " >
  57. <view class="base-color-9 mr40">性别</view>
  58. <view>{{moreInfo.sex?moreInfo.sex:'未知'}}</view>
  59. </view>
  60. <view class="justify-between align-center fs24 mt28 " >
  61. <view class="base-color-9 mr40">年龄</view>
  62. <view>{{moreInfo.age?moreInfo.age:'未知'}}</view>
  63. </view>
  64. <view class="justify-between align-center fs24 mt28">
  65. <view class="base-color-9 mr40">行为习惯</view>
  66. <view>{{moreInfo.habits?moreInfo.habits:'无'}}</view>
  67. </view>
  68. <view class="justify-between align-center fs24 mt28">
  69. <view class="base-color-9 mr40">患病时间</view>
  70. <view>{{moreInfo.illnessTime?moreInfo.illnessTime:'无'}}</view>
  71. </view>
  72. <view class="justify-between align-center fs24 mt28" >
  73. <view class="base-color-9 mr40">疾病</view>
  74. <view>{{moreInfo.disease?moreInfo.disease:'无'}}</view>
  75. </view>
  76. <view class="justify-between align-center fs24 mt28" >
  77. <view class="base-color-9 mr40">家人的疾病</view>
  78. <view>{{moreInfo.familyDisease?moreInfo.familyDisease:'无'}}</view>
  79. </view>
  80. <view class="justify-between align-center fs24 mt28 ">
  81. <view class="base-color-9 mr40">是否线下就诊</view>
  82. <view>{{moreInfo.isLine?'已线下就诊':'无'}}</view>
  83. </view>
  84. <view class="justify-between align-center fs24 mt28 " >
  85. <view class="base-color-9 mr40 ">体质</view>
  86. <view>{{moreInfo.constitution?moreInfo.constitution:'无'}}</view>
  87. </view>
  88. <view class="justify-between align-center fs24 mt28" >
  89. <view class="base-color-9 mr40">使用药品</view>
  90. <view>{{moreInfo.medicine?moreInfo.medicine:'无'}}</view>
  91. </view>
  92. <view class="justify-between align-center fs24 mt28" >
  93. <view class="base-color-9 mr40">咨询产品</view>
  94. <view>{{moreInfo.consultProduct?moreInfo.consultProduct:'无'}}</view>
  95. </view>
  96. <view class="justify-between align-center fs24 mt28" >
  97. <view class="base-color-9 mr40">是否已经购买产品</view>
  98. <view class="prodcutbox ">{{moreInfo.isBuy?'已购买':'无'}}</view>
  99. </view>
  100. </view>
  101. <!-- <view>首次进入接口{{msg122}}</view>
  102. <view>验签接口{{msg123}}</view>
  103. <view>获取详情接口{{msg124}}</view>
  104. <view>获取用户信息接口{{msg125}}</view> -->
  105. <view class="pt120"></view>
  106. <view class="justify-around botfun bgf">
  107. <view class="justify-start align-center bottom-btns"
  108. style="background: linear-gradient( 90deg, #348ff0 0%, #267EF0 100%);"
  109. @click="navTo('/pages/user/courseManage?userId='+userId)" >
  110. <view class="colorf ml12">课程管理</view>
  111. </view>
  112. <view class="justify-start align-center bottom-btns"
  113. style="background: linear-gradient( 90deg, #FE8227 0%, #FE4E12 100%);"
  114. @click="navTo('/pages/user/UrgeClasses?userId='+userId+'&corpId='+corpId)">
  115. <view class="colorf ml12" >催课管理</view>
  116. </view>
  117. <u-loading-page :loading='loadingimg' bg-color="rgba(0,0,0,0.6)" loading-mode="semicircle"></u-loading-page>
  118. </view>
  119. </view>
  120. </template>
  121. <script>
  122. import {
  123. getcustomerlist,
  124. getcustomer
  125. } from "@/api/user.js";
  126. import { getConfigSignature,getQwExternalContactDetails } from '@/api/common.js'
  127. export default {
  128. data() {
  129. return {
  130. typeOption: [{
  131. label: '全部',
  132. value: 0
  133. }, {
  134. label: '今天',
  135. value: 1
  136. }, {
  137. label: '昨天',
  138. value: 2
  139. }, {
  140. label: '前天',
  141. value: 3
  142. }, {
  143. label: '近七天',
  144. value: 4
  145. }],
  146. tabindex: 0,
  147. detailUser: [],
  148. user: [],
  149. answerlist:[],
  150. answerText:'禁用',
  151. id:'',
  152. dateTag:'',
  153. qwUserId:'',
  154. startTime:"",
  155. endTime:'',
  156. todayday: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd'),
  157. moreInfo:{},
  158. statusColors: {
  159. 0: '#909399',
  160. 1: '#0bc6ff',
  161. 2: '#67c23a',
  162. 3: '#f55a4f',
  163. 4: '#ffd700',
  164. },
  165. titname:['未看课','看课中','完课','待看课','看课中断',],
  166. statelist:[
  167. { status: 4 },
  168. { status: 1 },
  169. { status: 2 },
  170. { status: 5 },
  171. { status: 3 },
  172. { status: 5 },
  173. { status: 3 },
  174. ],
  175. typestate:0,
  176. externalUserId:'',
  177. userId:null,
  178. qwUserExternalId:'',
  179. loadingimg:true,
  180. msg122:'',
  181. msg123:'',
  182. msg124:'',
  183. msg125:'',
  184. timer: null, // 定时器ID
  185. }
  186. },
  187. onShow() {
  188. // this.getuser()
  189. // this.detailUser =uni.getStorageSync('detailUser')
  190. // if(this.detailUser.status==0){
  191. // this.answerText='取消禁用'
  192. // }
  193. this.qwUserId=uni.getStorageSync('qwUserId')
  194. if(this.qwUserExternalId){
  195. this.getuser()
  196. this.getAnswerlists()
  197. }
  198. // this.$nextTick(()=>{
  199. // setTimeout(()=>{
  200. // console.log(12121212121)
  201. // })
  202. // },100)
  203. },
  204. mounted() {
  205. },
  206. beforeDestroy() {
  207. // 组件销毁时清除定时器
  208. clearTimeout(this.timer);
  209. },
  210. onLoad(options) {
  211. // 启动超时计时器(10秒)
  212. this.timer = setTimeout(() => {
  213. if (!this.requestCompleted) {
  214. this.loadingimg = false;
  215. uni.showToast({
  216. title: '请求超时,请清除缓存!',
  217. icon: 'none'
  218. });
  219. }
  220. }, 10000);
  221. // this.id=option.id
  222. this.url=window.location.href;
  223. this.code=options.code;
  224. this.corpId=options.corpId;
  225. uni.setStorageSync("corpId",this.corpId);
  226. this.externalUserId=uni.getStorageSync("externalUserId");
  227. // var userId=uni.getStorageSync("qwUserId");
  228. // if(userId!=null&&userId!=undefined&&userId!=""){
  229. // this.userId=userId;
  230. // }
  231. // if(uni.getStorageSync("qwUserId")){
  232. // this.userId=uni.getStorageSync("qwUserId");
  233. // }
  234. this.msg122=uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM:ss')
  235. this.getConfigSignature()
  236. uni.$on('urgeUser', (data) => {
  237. console.log(data)
  238. this.urgetoUser(data);
  239. });
  240. // uni.$on('urgeUser', this.urgetoUser(data));
  241. uni.$on('course', (data) => {
  242. this.sendInput(data);
  243. });
  244. // uni.$on('course', this.sendInput(data));
  245. // if(this.externalUserId!=null&&this.externalUserId!=undefined&&this.userId!=null&&this.userId!=undefined){
  246. // this.getQwExternalContactDetails()
  247. // }
  248. },
  249. onUnload() {
  250. // 移除事件监听(避免内存泄漏)
  251. uni.$off('course', this.sendInput());
  252. uni.$off('urgeUser', this.urgetoUser());
  253. },
  254. methods: {
  255. clearhuan(){
  256. uni.removeStorageSync('qwarrid')
  257. uni.removeStorageSync('fsUserId')
  258. uni.removeStorageSync('externalUserId')
  259. uni.removeStorageSync('corpId')
  260. uni.showToast({
  261. title: "请退出页面后重新进入",
  262. icon: 'none',
  263. });
  264. },
  265. urgetoUser(data){
  266. setTimeout(function(){
  267. uni.navigateTo({
  268. url:data.pageurl
  269. })
  270. console.log(data)
  271. },200);
  272. this.loadingimg=false
  273. clearTimeout(this.timer);
  274. jWeixin.openEnterpriseChat({
  275. // 注意:userIds和externalUserIds至少选填一个。内部群最多2000人;外部群最多500人;如果有微信联系人,最多40人
  276. externalUserIds: data.nextExternalUserIds, // 参与会话的外部联系人列表,格式为userId1;userId2;…,用分号隔开。
  277. groupName: '', // 会话名称。单聊时该参数传入空字符串""即可。
  278. chatId: "", // 若要打开已有会话,需指定此参数。如果是新建会话,chatId必须为空串
  279. success: function(res) {
  280. console.log(res);
  281. console.log("切换成功")
  282. uni.showToast({
  283. title: "切换成功",
  284. icon: 'none',
  285. });
  286. var data={cmd:"switchPage"};
  287. uni.$emit('sendMsg',data);
  288. },
  289. fail: function(res) {
  290. console.log(res);
  291. console.log("切换失败")
  292. uni.showToast({
  293. title: "切换失败",
  294. icon: 'none',
  295. });
  296. var data={cmd:"switchPage"};
  297. uni.$emit('sendMsg',data);
  298. }
  299. });
  300. },
  301. sendInput(data){
  302. this.loadingimg=false
  303. clearTimeout(this.timer);
  304. jWeixin.invoke('sendChatMessage', {
  305. msgtype:"news", //消息类型,必填
  306. enterChat: true,
  307. news:
  308. {
  309. desc: data.linkDescribe,
  310. title: data.linkTitle,
  311. imgUrl: data.linkImageUrl,
  312. link: data.linkUrl
  313. }
  314. }, function(res) {
  315. console.log("发送成功")
  316. console.log(res)
  317. uni.showToast({
  318. title: "发送成功",
  319. });
  320. jWeixin.invoke('closeWindow',{
  321. },function(res){
  322. // alert('关闭窗口')
  323. })
  324. })
  325. },
  326. changeuser(){
  327. if(!this.qwUserExternalId){
  328. uni.showToast({
  329. icon: 'none',
  330. title: '用户信息加载中...'
  331. })
  332. return
  333. }
  334. uni.navigateTo({
  335. url:'/pages/user/editUser?externalUserId='+this.qwUserExternalId
  336. })
  337. },
  338. getQwExternalContactDetails(){
  339. uni.showLoading({
  340. title: "加载中..."
  341. })
  342. var that=this
  343. var data = {
  344. corpId: this.corpId,
  345. userId:this.userId,
  346. externalUserId:this.externalUserId,
  347. };
  348. getQwExternalContactDetails(data).then(res => {
  349. if(res.code==200){
  350. uni.hideLoading()
  351. this.user=res.data;
  352. this.qwUserExternalId=res.data.id
  353. uni.setStorageSync('qwarrid',res.data.id)
  354. uni.setStorageSync('fsUserId',res.data.fsUserId)
  355. console.log("获取外部联系人详情接口",res)
  356. this.msg124=uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM:ss')
  357. this.getuser()
  358. this.getAnswerlists()
  359. }else{
  360. }
  361. });
  362. },
  363. getConfigSignature(){
  364. uni.showLoading({
  365. title: "加载中..."
  366. })
  367. var data = {
  368. corpId: this.corpId,
  369. url: this.url,
  370. code: this.code
  371. };
  372. // if(this.userId==null || this.userId==""){
  373. data.isGetUserId=1;
  374. // }
  375. // else{
  376. // data.isGetUserId=0;
  377. // }
  378. getConfigSignature(data).then(
  379. res => {
  380. if(res.code==200){
  381. this.isConfig=true;
  382. const agentConfigSignature = res.config.agentConfigSignature;
  383. const configSignature = res.config.configSignature;
  384. const corpId = res.config.corpId;
  385. const nonceStr = res.config.nonceStr;
  386. const timestamp = res.config.timestamp;
  387. const agentId = res.config.agentId;
  388. if(res.config.userid!=null || res.config.userid!=''){
  389. this.userId = res.config.userid;//当前员工ID
  390. uni.setStorageSync("qwUserId",this.userId);
  391. // console.log("获取到USERID")
  392. }
  393. else{
  394. // console.log("不需要获取USERID")
  395. }
  396. // console.log(this.userId)
  397. var that=this;
  398. jWeixin.config({
  399. beta: true,
  400. debug: false,
  401. appId: corpId,
  402. timestamp: timestamp,
  403. nonceStr: nonceStr,
  404. signature: configSignature,
  405. jsApiList: ['getCurExternalContact','sendChatMessage','openEnterpriseChat','shareToExternalContact','closeWindow']
  406. });
  407. jWeixin.ready(() => {
  408. jWeixin.agentConfig({
  409. corpid: corpId,
  410. agentid: agentId,
  411. timestamp: timestamp,
  412. nonceStr: nonceStr,
  413. signature: agentConfigSignature,
  414. jsApiList: ['getCurExternalContact','sendChatMessage','openEnterpriseChat','shareToExternalContact','closeWindow'],
  415. success: (res) => {
  416. jWeixin.invoke('getCurExternalContact', {}, async (res) => {
  417. if (res.err_msg === "getCurExternalContact:ok") {
  418. this.msg123=uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM:ss')
  419. uni.hideLoading()
  420. that.externalUserId = res.userId;
  421. uni.setStorageSync("externalUserId",res.userId)
  422. that.getQwExternalContactDetails()
  423. } else {
  424. // 错误处理
  425. }
  426. });
  427. },
  428. fail: (res) => {
  429. console.error('agentConfig fail:', res);
  430. },
  431. });
  432. });
  433. jWeixin.error((res) => {
  434. console.error('wx.error:', res);
  435. });
  436. }
  437. else{
  438. // uni.setStorageSync("qwUserId",null);
  439. // console.log("获取USERID失败")
  440. // setTimeout(function(){
  441. // window.location.reload();
  442. // },5000);
  443. }
  444. },
  445. rej => {
  446. setTimeout(function(){
  447. window.location.reload();
  448. },500);
  449. }
  450. );
  451. },
  452. todetail(){
  453. if(this.typestate==0){
  454. this.typestate=1
  455. }else{
  456. this.typestate=0
  457. }
  458. this.getAnswerlists()
  459. },
  460. getuser(){
  461. uni.showLoading({
  462. title: "加载中..."
  463. })
  464. const data={
  465. qwExternalContactId:this.qwUserExternalId
  466. }
  467. getcustomer(data).then(res=>{
  468. console.log('获取客户详情记录接口',res)
  469. if (res.code == 200) {
  470. uni.hideLoading()
  471. this.msg125=uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM:ss')
  472. console.log('用户详情',this.detailUser)
  473. this.moreInfo=res.moreInfo
  474. console.log('用户的ai信息详情',this.moreInfo)
  475. } else {
  476. uni.showToast({
  477. icon: 'none',
  478. title: res.msg
  479. })
  480. }
  481. })
  482. },
  483. getAnswerlists() {
  484. if(!this.qwUserExternalId){
  485. uni.showToast({
  486. icon: 'none',
  487. title: '用户信息加载中...'
  488. })
  489. return
  490. }
  491. uni.showLoading({
  492. title: "加载中..."
  493. })
  494. const params = {
  495. type:this.typestate,
  496. qwExternalContactId:this.qwUserExternalId
  497. }
  498. getcustomerlist(params).then(res => {
  499. uni.hideLoading()
  500. if (res.code == 200) {
  501. clearTimeout(this.timer);
  502. this.loadingimg=false
  503. this.answerlist=res.data.data
  504. console.log('看课记录内容',this.answerlist)
  505. } else {
  506. uni.showToast({
  507. icon: 'none',
  508. title: res.msg
  509. })
  510. }
  511. })
  512. },
  513. navTo(url){
  514. uni.navigateTo({
  515. url
  516. })
  517. },
  518. }
  519. }
  520. </script>
  521. <style lang="scss" scoped>
  522. page{
  523. background-color: #F5F7FA;
  524. }
  525. .prodcutbox{
  526. max-width: 60%;
  527. word-wrap: break-word;
  528. }
  529. .editbox{
  530. border: 2rpx #ECECEC solid;
  531. color: #757575;
  532. }
  533. .topBgline {
  534. background:#3975C6;
  535. // padding-top: 40rpx;
  536. height: 220rpx;
  537. }
  538. .newsbox{
  539. margin-top: -20rpx;
  540. border-radius: 24rpx 24rpx 0 0;
  541. }
  542. .bgcolf {
  543. background: rgba(255, 255, 255, 0.3);
  544. }
  545. .actsel {
  546. background-color: #1773ff;
  547. color: #fff;
  548. transition: background-color 0.4s ease-in-out;
  549. }
  550. .notact {
  551. background-color: #f8f8f8;
  552. }
  553. .livebox {
  554. width: calc(50% - 10rpx);
  555. background-color: #f8f8f8;
  556. padding: 20rpx 10rpx;
  557. border-radius: 12rpx;
  558. }
  559. .liveboxs {
  560. width: calc(33% - 10rpx);
  561. background-color: #f8f8f8;
  562. padding: 20rpx 10rpx;
  563. border-radius: 12rpx;
  564. }
  565. .bottom-btns {
  566. padding: 16rpx 80rpx;
  567. border-radius: 50rpx;
  568. }
  569. .botfun {
  570. position: fixed;
  571. width: 100%;
  572. bottom: 0rpx;
  573. padding: 20rpx 0;
  574. }
  575. </style>