Commit 2e20f97a authored by Zhang Xiaojie's avatar Zhang Xiaojie

Merge branch 'dev' of gitlab.33.cn:chenqikuai/fns_front_2 into dev

parents 26ddc3c5 1c1b79fb
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
>{{ displayName }}</div> >{{ displayName }}</div>
<div <div
class="txt whitespace-nowrap overflow-hidden overflow-ellipsis flex-shrink-0" class="txt whitespace-nowrap overflow-hidden overflow-ellipsis flex-shrink-0"
>{{ latest_msg_timeStamp && timestampFormat(latest_msg_timeStamp) }}</div> >{{ datetime && timestampFormat2(datetime) }}</div>
</div> </div>
<div class="flex justify-between mb-5 mt-1"> <div class="flex justify-between mb-5 mt-1">
<div <div
...@@ -25,21 +25,20 @@ ...@@ -25,21 +25,20 @@
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { timestampFormat } from "@/utils/time"; import { timestampFormat2 } from "@/utils/time";
const props = defineProps({ const props = defineProps({
avatar_url: { type: String, default: '--' }, avatar_url: { type: String, default: '--' },
id: { type: String, default: '--' }, id: { type: String, default: '--' },
latest_msg_timeStamp: {
type: Number,
default: new Date().getTime() - 1000 * 60,
},
latest_msg_content: { type: String, default: '--' }, latest_msg_content: { type: String, default: '--' },
unReadMsgNum: { unReadMsgNum: {
type: Number, type: Number,
default: 10 default: 10
}, },
displayName: String, displayName: String,
datetime: {
type: Number,
}
}) })
</script> </script>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
name="icon-kefu" name="icon-kefu"
class="absolute left-11" class="absolute left-11"
size="18" size="18"
@click="$router.push({name:'Chat'})" @click="$emit('clickSecondIcon')"
:color="iconColor" :color="iconColor"
/> />
<icon <icon
...@@ -41,6 +41,7 @@ import { defineComponent } from "vue"; ...@@ -41,6 +41,7 @@ import { defineComponent } from "vue";
import Icon from "../common/Icon.vue"; import Icon from "../common/Icon.vue";
export default defineComponent({ export default defineComponent({
inheritAttrs: false, inheritAttrs: false,
emits: ['clickSecondIcon'],
components: { Icon }, components: { Icon },
props: { props: {
title: { title: {
......
...@@ -35,6 +35,7 @@ export default class ChatListCardDB extends MyAppDatabase { ...@@ -35,6 +35,7 @@ export default class ChatListCardDB extends MyAppDatabase {
targetId: string, targetId: string,
count: number, count: number,
content: string, content: string,
datetime: number
) { ) {
this.chatListCard this.chatListCard
.filter((item) => { .filter((item) => {
...@@ -43,6 +44,7 @@ export default class ChatListCardDB extends MyAppDatabase { ...@@ -43,6 +44,7 @@ export default class ChatListCardDB extends MyAppDatabase {
.modify((item) => { .modify((item) => {
item.unreadMsgCount = count item.unreadMsgCount = count
item.content = content item.content = content
item.datetime = datetime
}) })
} }
...@@ -89,11 +91,15 @@ export default class ChatListCardDB extends MyAppDatabase { ...@@ -89,11 +91,15 @@ export default class ChatListCardDB extends MyAppDatabase {
const unreadMsgCount = cardItem?.unreadMsgCount || 0 const unreadMsgCount = cardItem?.unreadMsgCount || 0
console.log(data.msg, 'show msg when update newest card');
this.updateCard( this.updateCard(
masterId, masterId,
targetId, targetId,
isChattingWithTargetId ? 0 : unreadMsgCount + 1, isChattingWithTargetId ? 0 : unreadMsgCount + 1,
content, content,
data.msg.datetime
) )
} }
...@@ -112,6 +118,7 @@ export default class ChatListCardDB extends MyAppDatabase { ...@@ -112,6 +118,7 @@ export default class ChatListCardDB extends MyAppDatabase {
unreadMsgCount: data.isChattingWithTargetId ? 0 : 1, unreadMsgCount: data.isChattingWithTargetId ? 0 : 1,
content, content,
inChat: false, inChat: false,
datetime: data.msg.datetime
}) })
} }
......
...@@ -30,7 +30,7 @@ export default class ChatMessageDB extends MyAppDatabase { ...@@ -30,7 +30,7 @@ export default class ChatMessageDB extends MyAppDatabase {
} }
async deleteMsg({ uuid, logid }: { uuid?: string; logid?: string }) { async deleteMsg({ uuid, logid }: { uuid?: string; logid?: string }) {
const updateChatList = async (masterId: string, target: string) => { const updateChatList = async (masterId: string, target: string, deletedMsgDatetime: number) => {
const latestedMsg = await this.getLatestedMessage(masterId, target) const latestedMsg = await this.getLatestedMessage(masterId, target)
if (latestedMsg) { if (latestedMsg) {
...@@ -38,23 +38,29 @@ export default class ChatMessageDB extends MyAppDatabase { ...@@ -38,23 +38,29 @@ export default class ChatMessageDB extends MyAppDatabase {
// latestedMsg.content.content // latestedMsg.content.content
this.chatListCard this.chatListCard
.filter((i) => i.masterId === masterId && i.targetId === target) .filter((i) => i.masterId === masterId && i.targetId === target)
.modify((i) => (i.content = latestedMsg.content.content as string)) .modify((i) => {
i.content = latestedMsg.content.content as string;
i.datetime = latestedMsg.datetime;
})
} else { } else {
/* 如果和target没有聊天消息 */ /* 如果和target没有聊天消息 */
this.chatListCard this.chatListCard
.filter((i) => i.masterId === masterId && i.targetId === target) .filter((i) => i.masterId === masterId && i.targetId === target)
.modify((i) => (i.content = '')) .modify((i) => {
i.content = ''
i.datetime = deletedMsgDatetime
})
} }
} }
if (uuid) { if (uuid) {
const item = await this.chatMessage.where('uuid').equals(uuid).first() const item = await this.chatMessage.where('uuid').equals(uuid).first()
await this.chatMessage.where('uuid').equals(uuid).delete() await this.chatMessage.where('uuid').equals(uuid).delete()
item && updateChatList(item?.masterId, getTargetIdFromDisplayMsg(item)) item && updateChatList(item?.masterId, getTargetIdFromDisplayMsg(item), item?.datetime)
} else if (logid) { } else if (logid) {
const item = await this.chatMessage.where('logid').equals(logid).first() const item = await this.chatMessage.where('logid').equals(logid).first()
await this.chatMessage.where('logid').equals(logid).delete() await this.chatMessage.where('logid').equals(logid).delete()
item && updateChatList(item?.masterId, getTargetIdFromDisplayMsg(item)) item && updateChatList(item?.masterId, getTargetIdFromDisplayMsg(item), item?.datetime)
} else { } else {
throw new Error('没有uuid或者logid') throw new Error('没有uuid或者logid')
} }
......
...@@ -11,6 +11,7 @@ export interface iChatListCard { ...@@ -11,6 +11,7 @@ export interface iChatListCard {
targetId: string targetId: string
unreadMsgCount: number unreadMsgCount: number
content: string content: string
datetime: number
inChat: boolean // 会话状态,会话中? inChat: boolean // 会话状态,会话中?
} }
...@@ -23,7 +24,7 @@ export class MyAppDatabase extends Dexie { ...@@ -23,7 +24,7 @@ export class MyAppDatabase extends Dexie {
constructor() { constructor() {
super('MyAppDatabase') super('MyAppDatabase')
this.version(1.2).stores({ this.version(1.3).stores({
chatMessage: chatMessage:
'++id, content, from, uuid, state, uploadProgress, type, datetime, hideDatetime, logid, masterId, readed', '++id, content, from, uuid, state, uploadProgress, type, datetime, hideDatetime, logid, masterId, readed',
chatListCard: '++id, masterId, targetId, unreadMsgCount, content, inChat', chatListCard: '++id, masterId, targetId, unreadMsgCount, content, inChat',
......
...@@ -63,6 +63,63 @@ export function timestampFormat(timestamp: number) { ...@@ -63,6 +63,63 @@ export function timestampFormat(timestamp: number) {
} }
} }
/* timestampFormat版本2,参照微信设计的最新消息时间显示, HH:mm 昨天 MM/dd */
export function timestampFormat2(timestamp: number) {
if (String(timestamp).length === new Date().getTime().toString().length) {
timestamp /= 1000
}
function zeroize(num: number) {
return (String(num).length == 1 ? '0' : '') + num
}
var curTimestamp = new Date().getTime() / 1000 //当前时间戳
var timestampDiff = curTimestamp - timestamp // 参数时间戳与当前时间戳相差秒数
var curDate = new Date(curTimestamp * 1000) // 当前时间日期对象
var tmDate = new Date(timestamp * 1000) // 参数时间戳转换成的日期对象
var Y = tmDate.getFullYear(),
m = tmDate.getMonth() + 1,
d = tmDate.getDate()
var H = tmDate.getHours(),
i = tmDate.getMinutes(),
s = tmDate.getSeconds()
if (
curDate.getFullYear() == Y &&
curDate.getMonth() + 1 == m &&
curDate.getDate() == d
) {
return zeroize(H) + ':' + zeroize(i)
} else {
var newDate = new Date((curTimestamp - 86400) * 1000) // 参数中的时间戳加一天转换成的日期对象
if (
newDate.getFullYear() == Y &&
newDate.getMonth() + 1 == m &&
newDate.getDate() == d
) {
return '昨天' + zeroize(H) + ':' + zeroize(i)
} else if (curDate.getFullYear() == Y) {
return (
zeroize(m) + '月' + zeroize(d) + '日 ' + zeroize(H) + ':' + zeroize(i)
)
} else {
return (
Y +
'年' +
zeroize(m) +
'月' +
zeroize(d) +
'日 ' +
zeroize(H) +
':' +
zeroize(i)
)
}
}
}
export function format(timestamp: string, format: string) { export function format(timestamp: string, format: string) {
return dayjs(timestamp).format(format) return dayjs(timestamp).format(format)
} }
...@@ -56,6 +56,8 @@ import { textInputStore } from "@/store/textInputStore"; ...@@ -56,6 +56,8 @@ import { textInputStore } from "@/store/textInputStore";
import { v4 as uuidv4 } from 'uuid' import { v4 as uuidv4 } from 'uuid'
import Icon from "@/components/common/Icon.vue"; import Icon from "@/components/common/Icon.vue";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import { getUserMsg } from "@/utils/userMsg";
import { eRole } from "@/types/roleType";
export default defineComponent({ export default defineComponent({
props: { props: {
...@@ -113,8 +115,11 @@ export default defineComponent({ ...@@ -113,8 +115,11 @@ export default defineComponent({
const handleSend = () => { const handleSend = () => {
console.log('handle send'); console.log('handle send');
const isStaff = getUserMsg()?.role === eRole.staff;
if (props.serviceShowValue === "人工服务") { const isUser = getUserMsg()?.role === eRole.user;
console.log(isStaff, 'isStaff');
if (isUser && props.serviceShowValue === "人工服务") {
messageStore.displayNewMessage({ messageStore.displayNewMessage({
content: { content: {
content: inputText.value content: inputText.value
......
...@@ -14,6 +14,8 @@ import { filterGuaranteeType } from "@/utils/guarantee-type" ...@@ -14,6 +14,8 @@ import { filterGuaranteeType } from "@/utils/guarantee-type"
import { Skeleton } from "vant" import { Skeleton } from "vant"
import { iNearbyOutLet } from "@/service/AddressService/types" import { iNearbyOutLet } from "@/service/AddressService/types"
import AddressService from "@/service/AddressService" import AddressService from "@/service/AddressService"
import router from "@/router";
import UserService from "@/service/UserService";
function isInViewPort(element: HTMLElement, barHeight: number) { function isInViewPort(element: HTMLElement, barHeight: number) {
const viewWidth = window.innerWidth || document.documentElement.clientWidth; const viewWidth = window.innerWidth || document.documentElement.clientWidth;
...@@ -109,6 +111,34 @@ export default defineComponent({ ...@@ -109,6 +111,34 @@ export default defineComponent({
window.onscroll = null; window.onscroll = null;
}); });
const handleClickApply = async () => {
getOutletAndNavigateToChat();
}
const clickChatIcon = async () => {
getOutletAndNavigateToChat()
}
const getOutletAndNavigateToChat = async () => {
const ret = await AddressService.getInstance().getNearby({
bank_code: Number(process.env.VUE_APP_BANK_CODE),
number: 1,
})
if (ret.code === 200) {
const ret2 = await UserService.getInstance().contact_custom_service({
outLetID: ret.data[0].outlet_id as number
})
if (ret2.code == 200) {
router.push({
name: 'Chat',
query: {
target: ret2.data.addr
}
})
}
}
}
return () => ( return () => (
<> <>
<div class="page flex-col"> <div class="page flex-col">
...@@ -118,6 +148,7 @@ export default defineComponent({ ...@@ -118,6 +148,7 @@ export default defineComponent({
iconColor={canSeeApplyBtn.value ? "white" : 'black'} iconColor={canSeeApplyBtn.value ? "white" : 'black'}
style={{ 'background': canSeeApplyBtn.value ? '#2C3C92 !important' : 'white !important', 'color': canSeeApplyBtn.value ? 'white' : 'black' }} style={{ 'background': canSeeApplyBtn.value ? '#2C3C92 !important' : 'white !important', 'color': canSeeApplyBtn.value ? 'white' : 'black' }}
showSecondIcon={true} showSecondIcon={true}
onClickSecondIcon={clickChatIcon}
occupyPosition={false} occupyPosition={false}
/> />
<div class="block1 flex-col"> <div class="block1 flex-col">
...@@ -254,6 +285,7 @@ export default defineComponent({ ...@@ -254,6 +285,7 @@ export default defineComponent({
<div <div
class=" fixed left-0 right-0 bottom-0 h-12 bg-app-blue apply-btn flex items-center justify-center" class=" fixed left-0 right-0 bottom-0 h-12 bg-app-blue apply-btn flex items-center justify-center"
style={{ zIndex: 300 }} style={{ zIndex: 300 }}
onClick={handleClickApply}
> >
立即申请 立即申请
</div> </div>
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
:id="item.targetId" :id="item.targetId"
:displayName="item.displayName" :displayName="item.displayName"
:latest_msg_content="item.content" :latest_msg_content="item.content"
:datetime="item.datetime"
></ChatListItem> ></ChatListItem>
</template> </template>
</van-popover> </van-popover>
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
> >
<TabItem <TabItem
:tabName="item.name" :tabName="item.name"
:iconName="item.icon" :iconName="activeTabRouteName === item.routeName ? item.icon : item.icon1"
:active="activeTabRouteName === item.routeName" :active="activeTabRouteName === item.routeName"
/> />
</div> </div>
......
...@@ -29,11 +29,6 @@ ...@@ -29,11 +29,6 @@
/> />
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div @click="clickLogout" class="logout-btn flex items-center justify-center fixed">退出登录</div> <div @click="clickLogout" class="logout-btn flex items-center justify-center fixed">退出登录</div>
......
...@@ -5,12 +5,15 @@ export default [ ...@@ -5,12 +5,15 @@ export default [
name: '首页', name: '首页',
routeName: 'Home', routeName: 'Home',
icon: 'icon-shouye-tab-xuanze1', icon: 'icon-shouye-tab-xuanze1',
icon1: 'icon-shouye-tab',
roles: [eRole.user, eRole.staff], roles: [eRole.user, eRole.staff],
showNotLogin: true, showNotLogin: true,
}, },
{ {
name: '聊天', name: '聊天',
routeName: 'ChatList', routeName: 'ChatList',
icon1: 'icon-liaotian',
icon: 'icon-liaotian-dianji', icon: 'icon-liaotian-dianji',
roles: [eRole.staff, eRole.user], roles: [eRole.staff, eRole.user],
showNotLogin: true, showNotLogin: true,
...@@ -19,6 +22,7 @@ export default [ ...@@ -19,6 +22,7 @@ export default [
name: '贷款', name: '贷款',
routeName: 'Loan', routeName: 'Loan',
icon: 'icon-daikuan-tab-xuanze', icon: 'icon-daikuan-tab-xuanze',
icon1: 'icon-daikuan-tab',
roles: [eRole.user, eRole.staff], roles: [eRole.user, eRole.staff],
showNotLogin: true, showNotLogin: true,
}, },
...@@ -26,6 +30,7 @@ export default [ ...@@ -26,6 +30,7 @@ export default [
name: '我的', name: '我的',
routeName: 'Mine', routeName: 'Mine',
icon: 'icon-wode-tabdianji', icon: 'icon-wode-tabdianji',
icon1: 'icon-wode-tab',
roles: [eRole.user, eRole.staff], roles: [eRole.user, eRole.staff],
showNotLogin: true, showNotLogin: true,
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment