customerDetail.vue 18 KB

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