index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <page-meta :page-font-size="fontValue+'px'" :root-font-size="fontValue+'px'"></page-meta>
  3. <view class="allViewBG">
  4. <cu-custom bgImage="/static/barBG.png" :isBack="false">
  5. <template v-slot:content>
  6. <text style="letter-spacing: 4rpx;font-style: italic;color:black;font-weight: bold;">AI IM</text>
  7. </template>
  8. </cu-custom>
  9. <view class="cu-list menu-avatar tab-bar-mar">
  10. <view class="cu-item bg-cyan" :class="modalName==='move-box-'+ index?'move-cur':''" :style="chat.top?'background-color:#f8f8f8':''"
  11. v-for="(chat, index) in chatStore.chats" :key="chat.id" @touchstart="handleListTouchStart" @tap="handleSend(chat.id)"
  12. @touchmove="handleListTouchMove" @touchend="handleListTouchEnd" :data-target="'move-box-' + index">
  13. <vim-avatar :img="chat.avatar" :name="chat.name" :is-group="chat.type === ChatType.GROUP"/>
  14. <view class="content">
  15. <view class="text-black text-jiachu" style="">{{ chat.name }}</view>
  16. <view class="text-black text-sm text-cut">
  17. {{ contentdecrypt(chatLastMessage[chat.id])}}
  18. </view>
  19. </view>
  20. <view class="chat-right">
  21. <view class="text-center">
  22. <view class="cu-tag round bg-orange sm" v-if="chat.unreadCount>0">{{ chat.unreadCount }}</view>
  23. <view class="cu-tag bg-gray radius sm" v-if="chatLastTime[chat.id]">
  24. {{formatDistanceToNow(chatLastTime[chat.id], {
  25. locale: zhCN,
  26. addSuffix: false,
  27. })}}
  28. </view>
  29. </view>
  30. <view class="text-center" v-if="immunityList.includes(chat.id)">
  31. <view class="cuIcon-notice_forbid_fill text-gray"></view>
  32. </view>
  33. </view>
  34. <view class="move">
  35. <view class="bg-red" @tap.stop="chatStore.delChat(chat.id)">删除</view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script setup lang="ts">
  42. import {useChatStore} from "@/store/chatStore";
  43. import {useImmunityStore} from "@/store/immunityStore";
  44. import CuCustom from '@/colorui/components/cu-custom.vue'
  45. import {handleListTouchEnd, handleListTouchMove, handleListTouchStart, modalName} from "@/hooks/useMoveMenu";
  46. import {onMounted} from "vue";
  47. import VimAvatar from "@/components/VimAvatar.vue";
  48. import {formatDistanceToNow} from "date-fns";
  49. import {zhCN} from "date-fns/locale";
  50. import {storeToRefs} from "pinia";
  51. import ChatType from "@/utils/ChatType";
  52. import {decryptLong2 } from '@/store/cryptoAES';
  53. import Auth from "@/api/Auth";
  54. const chatStore = useChatStore();
  55. const immunityStore = useImmunityStore();
  56. const {chatLastMessage,chatLastTime,chatUnreadId} = storeToRefs(chatStore)
  57. const {immunityList} = storeToRefs(immunityStore)
  58. const fontValue=Auth.getfontSize();
  59. //发送消息
  60. const handleSend = (id: string) => {
  61. uni.navigateTo({
  62. url: '/pages/chat/chat?id=' + id
  63. })
  64. }
  65. onMounted(() => {
  66. chatStore.setOpenChatId(null);
  67. console.log(uni.getSystemInfoSync().appVersionCode);
  68. //gengxinApp('');
  69. })
  70. const contentdecrypt=(ct:string)=>{
  71. //console.log(ct)
  72. var rct = decryptLong2(ct);
  73. if(rct){
  74. return rct;
  75. }
  76. return ct;
  77. }
  78. // const gengxinApp = (url:string) => {
  79. // console.log(url);
  80. // var that = this;
  81. // var dtask = plus.downloader.createDownload(
  82. // url,
  83. // {
  84. // method: "GET"
  85. // }, (d, status) => {
  86. // console.log(status,d);
  87. // if (status == 200) {
  88. // plus.runtime.install(d.filename)
  89. // } else {
  90. // plus.nativeUI.alert('安装失败,请稍候重试!' + status)
  91. // }
  92. // });
  93. // dtask.start();
  94. // var prg = 0;//进度数字化
  95. // var show= plus.nativeUI.showWaiting("Loading...");
  96. // var percentVal;
  97. // dtask.addEventListener('statechanged',function(task,status){
  98. // //console.log(task);
  99. // switch(task.state){//根据下载状态调整其显示内容
  100. // case 1:
  101. // percentVal = "Loading……";
  102. // show.setTitle("正在下载");
  103. // break;
  104. // case 2:
  105. // percentVal = "Connected";
  106. // show.setTitle("连接到服务器");
  107. // break;
  108. // case 3:
  109. // percentVal = parseInt((parseFloat(task.downloadedSize) / parseFloat(task.totalSize)) * 100);
  110. // show.setTitle("正在下载:" + percentVal + "%");
  111. // break;
  112. // case 4:
  113. // plus.nativeUI.closeWaiting();
  114. // break;
  115. // }
  116. // });
  117. // }
  118. </script>
  119. <style scoped>
  120. .cu-item:active{
  121. background-color: #aaaaaa;
  122. }
  123. .chat-right{
  124. width: 140upx
  125. }
  126. </style>