|
|
|
@@ -0,0 +1,180 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
import { reactive } from 'vue' |
|
|
|
import { View } from '@tarojs/components' |
|
|
|
|
|
|
|
import './index.scss' |
|
|
|
import {weappAuth} from "../../utils"; |
|
|
|
import { |
|
|
|
GroupedContactPassRecords, |
|
|
|
useContactPassRecordsStore |
|
|
|
} from "../../stores/contact-pass-records"; |
|
|
|
import {Router} from "tarojs-router-next"; |
|
|
|
import { BjxHelper } from "../../utils"; |
|
|
|
|
|
|
|
|
|
|
|
const contactData = Router.getData() |
|
|
|
console.log("contactData", contactData) |
|
|
|
|
|
|
|
const state = reactive<{ |
|
|
|
isPageDataLoading: boolean, |
|
|
|
isAuthError: boolean, |
|
|
|
groupedContactPassRecords: GroupedContactPassRecords[], |
|
|
|
}>({ |
|
|
|
isPageDataLoading: true, |
|
|
|
isAuthError: false, |
|
|
|
groupedContactPassRecords: [], |
|
|
|
}) |
|
|
|
const passRecords = useContactPassRecordsStore() |
|
|
|
|
|
|
|
|
|
|
|
init() |
|
|
|
|
|
|
|
function init() { |
|
|
|
state.isAuthError = false |
|
|
|
state.isPageDataLoading = true |
|
|
|
console.log("contactData", contactData) |
|
|
|
weappAuth().then(r => { |
|
|
|
console.log(r) |
|
|
|
passRecords.loadContactPassRecordsFromServer(contactData.id).then( groupedPassRecords => { |
|
|
|
state.isPageDataLoading = false |
|
|
|
state.groupedContactPassRecords = groupedPassRecords |
|
|
|
// console.log(state.groupedPassRecords) |
|
|
|
}) |
|
|
|
.catch(error => { |
|
|
|
console.log("error", error) |
|
|
|
state.isAuthError = true |
|
|
|
state.isPageDataLoading = false |
|
|
|
}) |
|
|
|
}).catch(e => { |
|
|
|
console.log("error", e) |
|
|
|
state.isAuthError = true |
|
|
|
state.isPageDataLoading = false |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
const onAuthErrorRefresh = () => { |
|
|
|
init() |
|
|
|
} |
|
|
|
// const onPullDownRefresh = () => { |
|
|
|
// console.log("onPullDownRefresh") |
|
|
|
// state.isRefresherTriggered = false |
|
|
|
// } |
|
|
|
function onPullDownRefresh (e) { |
|
|
|
console.log("onPullDownRefresh", e) |
|
|
|
// state.isRefresherTriggered = false |
|
|
|
} |
|
|
|
const goBack = () => { |
|
|
|
Router.back() |
|
|
|
} |
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<view class="h-100 d-flex flex-column"> |
|
|
|
<BackgroundBasic/> |
|
|
|
<NutNavbar title=""></NutNavbar> |
|
|
|
<view class="p-3 d-flex"> |
|
|
|
<view class="flex-grow-1"> |
|
|
|
<view class="h3"> |
|
|
|
<view class="fas fa-chevron-left text-primary" @tap="goBack()" hover-class="btn-hover-primary"/> |
|
|
|
到访记录 |
|
|
|
</view> |
|
|
|
<view class="text-black-50">此联系人的最近来访记录</view> |
|
|
|
</view> |
|
|
|
<view class="d-flex align-items-end"> |
|
|
|
<View></View> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<View v-if="state.isAuthError"> |
|
|
|
<nut-empty description="连接出现问题,请稍后重试"> |
|
|
|
<div style="margin-top: 10px"> |
|
|
|
<nut-button type="default" @tap="onAuthErrorRefresh">刷新</nut-button> |
|
|
|
</div> |
|
|
|
</nut-empty> |
|
|
|
</View> |
|
|
|
<View class="scroll 100vh" v-else> |
|
|
|
<view class="scroll 100vh" v-if="!state.isPageDataLoading"> |
|
|
|
<Scroll-View style="height: 100vh" :scrollY="true"> |
|
|
|
|
|
|
|
<View v-for="dateGroup in state.groupedContactPassRecords"> |
|
|
|
<View class="h4 pt-3 pl-3">{{dateGroup.date}}</View> |
|
|
|
<view v-for="item in dateGroup.passRecords" class="border m-3 p-3 bg-light"> |
|
|
|
<view class="d-flex flex-row"> |
|
|
|
<view class="flex-grow-1"> |
|
|
|
<NutAvatar size="large" color="white" :bg-color="BjxHelper.mbString2RgbHex(contactData.name)" class="overflow-hidden"> |
|
|
|
<img v-if="item.faceUrl" :src="item.faceUrl" /> |
|
|
|
<view v-else-if="BjxHelper.getBJXFirstChar(contactData.name)">{{BjxHelper.getBJXFirstChar(contactData.name)}}</view> |
|
|
|
<view v-else> |
|
|
|
<Text className='fas fa-user fa-lg'/> |
|
|
|
</view> |
|
|
|
</NutAvatar> |
|
|
|
</view> |
|
|
|
<view class="d-flex align-items-center text-black-50"> |
|
|
|
{{item.time}} |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
|
|
<view v-if="passRecords.passRecords.length >= 100" class="pl-5 pr-5 pt-5 pb-3 text-black-50"> |
|
|
|
<nut-divider> 仅显示最近 100 条记录 </nut-divider> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view v-else class="container pt-5 pb-3"> |
|
|
|
<view class="row"> |
|
|
|
<view class="col"/> |
|
|
|
<view class="col text-center text-black-50"> |
|
|
|
<nut-divider> 没有更多了 </nut-divider> |
|
|
|
</view> |
|
|
|
<view class="col"/> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</Scroll-View> |
|
|
|
</view> |
|
|
|
<View v-else class="skeleton"> |
|
|
|
<NutSkeleton v-for="_ in 10" class="pl-4 pt-4 pb-4 pr-5" height="20px" width="60vw" animated avatar avatar-size="50px" row="2"/> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- <view class="p-4">--> |
|
|
|
<!-- <button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">使用电话号码登录</button>--> |
|
|
|
<!-- </view>--> |
|
|
|
|
|
|
|
|
|
|
|
<!-- <Counter/>--> |
|
|
|
|
|
|
|
|
|
|
|
<!-- <nut-cell title="展示弹出层" is-link @click="show = true"></nut-cell>--> |
|
|
|
<!-- <nut-popup :style="{ padding: '30px 50px' }" v-model:visible="show">正文</nut-popup>--> |
|
|
|
<!-- <View><Text>{{state.msg}}</Text></View>--> |
|
|
|
<!-- <nut-button type="primary" @click="handleClick(state.msg2)">点我</nut-button>--> |
|
|
|
<!-- <Add color="red" />--> |
|
|
|
<!-- <div class="alert alert-primary" role="alert">--> |
|
|
|
<!-- A simple primary alert—check it out!--> |
|
|
|
<!-- </div>--> |
|
|
|
<!-- <h1>Example heading <span class="badge bg-secondary">New</span></h1>--> |
|
|
|
<!-- <button type="button" class="btn btn-primary">--> |
|
|
|
<!-- Notifications <span class="badge text-bg-secondary">4</span>--> |
|
|
|
<!-- </button>--> |
|
|
|
<!-- <button type="button" class="btn btn-primary position-relative">--> |
|
|
|
<!-- Inbox--> |
|
|
|
<!-- <span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger">--> |
|
|
|
<!-- 99+--> |
|
|
|
<!-- <span class="visually-hidden">unread messages</span>--> |
|
|
|
<!-- </span>--> |
|
|
|
<!-- </button>--> |
|
|
|
|
|
|
|
<!-- </view>--> |
|
|
|
</template> |
|
|
|
|
|
|
|
|