im.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <view>
  3. <web-view :src="src" type="im"></web-view>
  4. </view>
  5. </template>
  6. <script>
  7. var api = require('@/config/api.js');
  8. // d:\Jz\Code\Mall20220601\douyin\pages\chat\im\im.js
  9. export default {
  10. data() {
  11. return {
  12. // #ifdef MP-TOUTIAO
  13. src: 'https://im6a9eefe.7x24cc.com/phone_webChat.html?accountId=N000000023246&chatId=f7659f6c-52bd-4ee2-9162-46425604af70',
  14. nickName: '抖音用户',
  15. // #endif
  16. // #ifdef MP-ALIPAY
  17. src: 'https://im6a9eefe.7x24cc.com/phone_webChat.html?accountId=N000000023246&chatId=6e10867f-ab6d-446e-81f6-018eab9eb0bb',
  18. nickName: '支付宝用户',
  19. // #endif
  20. userId: '',
  21. };
  22. },
  23. onLoad: function (options) {
  24. let yunjia= api.checkYunJia();
  25. if(yunjia){
  26. console.log('云嘉客服');
  27. uni.showModal({
  28. title: '提示',
  29. content: '是否拨打客服热线:4009218987',
  30. success: function (res) {
  31. if (res.confirm) {
  32. uni.makePhoneCall({
  33. phoneNumber: '4009218987'
  34. })
  35. } else if (res.cancel) {
  36. console.log('用户点击取消');
  37. }
  38. }
  39. });
  40. this.src="https://imxcx2.7x24cc.com/phone_webChat.html?accountId=N000000023246&chatId=13a693f5-031c-49e5-b94a-1b63d41fdd21";
  41. }
  42. let userInfo = uni.getStorageSync('userInfo');
  43. console.info(userInfo);
  44. //读取缓存中的昵称
  45. let nickName = uni.getStorageSync('nickName');
  46. //随机数
  47. let md = Math.random() * 10000 + 10000;
  48. if (userInfo) {
  49. this.setData({
  50. nickName: userInfo.nickName,
  51. userId: userInfo.id
  52. });
  53. } else {
  54. if (!nickName) {
  55. // #ifdef MP-TOUTIAO
  56. nickName = '抖音用户' + md.toFixed(0);
  57. // #endif
  58. // #ifdef MP-ALIPAY
  59. nickName = '支付宝用户' + md.toFixed(0);
  60. // #endif
  61. }
  62. this.setData({
  63. nickName: nickName,
  64. userId: userInfo.id
  65. });
  66. uni.setStorageSync('nickName', nickName);
  67. }
  68. this.setData({
  69. src: this.src + '&nickName=' + encodeURI(this.nickName)
  70. });
  71. },
  72. methods: {}
  73. };
  74. </script>
  75. <style>
  76. /* d:\Jz\Code\Mall20220601\douyin\pages\chat\im\im.ttss */
  77. </style>