visitor.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <view class="container">
  3. <template v-if="!isLogin">
  4. <!-- 未登录状态 -->
  5. <view class="no-login">
  6. <image src="/static/images/no-login.png" mode="aspectFit" class="no-login-image"></image>
  7. <text class="no-login-text">登录后查看更多内容</text>
  8. <button class="login-btn" @click="goToLogin">去登录</button>
  9. </view>
  10. </template>
  11. <template v-else>
  12. <!-- Visit list -->
  13. <scroll-view scroll-y class="visit-list" @scrolltolower="onReachBottom">
  14. <template v-if="visitList.length > 0">
  15. <view class="visit-item" v-for="(item, index) in visitList" :key="index" @click="goToDetail(item)">
  16. <view class="visit-date">
  17. <text class="date-num">{{item.date}}</text>
  18. <text class="date-month">{{item.year}}</text>
  19. </view>
  20. <view class="visit-content">
  21. <view class="visit-header">
  22. <view class="visitor-info">
  23. <text class="visitor-label">对接人 </text>
  24. <text class="visitor-name">{{item.employeeName}}</text>
  25. </view>
  26. <text class="visit-status" :class="getStatusClass(item.status)">{{item.status}}</text>
  27. </view>
  28. <view class="visit-desc">{{item.visitReason}}</view>
  29. <view class="visit-time">
  30. <u-icon name="clock" size="12" color="#999"></u-icon>
  31. <text>{{item.time}}</text>
  32. </view>
  33. </view>
  34. </view>
  35. <!-- Loading more -->
  36. <u-loadmore :status="loadMoreStatus" />
  37. </template>
  38. <template v-else>
  39. <!-- 暂无数据 -->
  40. <view class="flex-items-plus">
  41. <image src="../../static/images/empty.png" class="empty "></image>
  42. </view>
  43. <view class="font28 font-gray flex-items-plus">
  44. 数据为空
  45. </view>
  46. <no-data text="暂无访问记录" mode="list"></no-data>
  47. </template>
  48. </scroll-view>
  49. </template>
  50. </view>
  51. </template>
  52. <script>
  53. import {
  54. mapGetters
  55. } from 'vuex';
  56. export default {
  57. data() {
  58. return {
  59. visitList: [],
  60. loadMoreStatus: 'loadmore', // loadmore, loading, nomore
  61. params: {
  62. current: 1,
  63. size: 10,
  64. },
  65. hasMore: true
  66. };
  67. },
  68. computed: {
  69. ...mapGetters(['isLogin'])
  70. },
  71. onLoad() {
  72. this.getList();
  73. },
  74. onShow() {
  75. },
  76. onPullDownRefresh() {
  77. this.refresh()
  78. uni.stopPullDownRefresh();
  79. },
  80. methods: {
  81. // Refresh list
  82. refresh() {
  83. this.visitList = []
  84. this.params.current = 1
  85. this.hasMore = true
  86. this.loadMoreStatus = 'loadmore'
  87. this.getList()
  88. },
  89. // Handle reaching bottom of scroll
  90. onReachBottom() {
  91. if (!this.hasMore || this.loadMoreStatus === 'loading') return
  92. this.params.current++
  93. this.getList(true)
  94. },
  95. // Get status class for styling
  96. getStatusClass(status) {
  97. const statusMap = {
  98. '待访问': 'status-pending-visit',
  99. '待审核': 'status-pending-review',
  100. '已拒绝': 'status-rejected'
  101. }
  102. return statusMap[status] || 'status-default'
  103. },
  104. // Get visit list with mock data
  105. getList(loadMore = false) {
  106. if (!loadMore) {
  107. uni.showLoading({
  108. title: '加载中...'
  109. });
  110. }
  111. this.loadMoreStatus = 'loading'
  112. // 模拟接口延迟
  113. setTimeout(() => {
  114. // 模拟数据
  115. const mockData = Array(10).fill(0).map((_, index) => {
  116. const currentIndex = (this.params.current - 1) * 10 + index;
  117. const date = new Date();
  118. date.setDate(date.getDate() - currentIndex); // 每条数据日期递减
  119. const statusList = ['待访问', '待审核', '已拒绝'];
  120. const contactPersons = ['范海洋', '张河嘉', '李明', '王芳'];
  121. const descList = [
  122. '我是访问事由我是访问事由我是访问事由...',
  123. '需要进行业务对接商谈...',
  124. '产品展示与技术交流...',
  125. '项目合作洽谈...'
  126. ];
  127. return {
  128. id: currentIndex,
  129. contactPerson: contactPersons[Math.floor(Math.random() * contactPersons
  130. .length)],
  131. createTime: date,
  132. status: statusList[Math.floor(Math.random() * statusList.length)],
  133. visitReason: descList[Math.floor(Math.random() * descList.length)]
  134. };
  135. });
  136. const list = mockData.map(item => ({
  137. ...item,
  138. date: this.$u.timeFormat(item.createTime, 'DD'),
  139. year: this.$u.timeFormat(item.createTime, 'YYYY/MM'),
  140. time: this.$u.timeFormat(item.createTime, 'hh:mm')
  141. }));
  142. if (loadMore) {
  143. this.visitList = [...this.visitList, ...list];
  144. } else {
  145. this.visitList = list;
  146. }
  147. // 模拟总共有5页数据
  148. this.hasMore = this.params.current < 5;
  149. this.loadMoreStatus = this.hasMore ? 'loadmore' : 'nomore';
  150. if (!loadMore) {
  151. uni.hideLoading();
  152. }
  153. }, 500); // 增加500ms延迟模拟网络请求
  154. },
  155. // 跳转到详情页面
  156. goToDetail(item) {
  157. uni.navigateTo({
  158. url: `/pagesA/task/detail?id=${item.id}&status=${item.status}`
  159. });
  160. },
  161. // 跳转到登录页面
  162. goToLogin() {
  163. uni.navigateTo({
  164. url: '/pagesA/public/login'
  165. });
  166. },
  167. }
  168. };
  169. </script>
  170. <style lang="scss" scoped>
  171. .container {
  172. min-height: 100vh;
  173. background-color: #f5f5f5;
  174. .no-login {
  175. display: flex;
  176. flex-direction: column;
  177. align-items: center;
  178. justify-content: center;
  179. padding-top: 30vh;
  180. .no-login-image {
  181. width: 240rpx;
  182. height: 240rpx;
  183. margin-bottom: 40rpx;
  184. }
  185. .no-login-text {
  186. font-size: 32rpx;
  187. color: #999;
  188. margin-bottom: 60rpx;
  189. }
  190. .login-btn {
  191. width: 320rpx;
  192. height: 88rpx;
  193. background: #FF6B00;
  194. border-radius: 44rpx;
  195. color: #fff;
  196. font-size: 32rpx;
  197. font-weight: 500;
  198. display: flex;
  199. align-items: center;
  200. justify-content: center;
  201. }
  202. }
  203. }
  204. .visit-list {
  205. height: 100vh;
  206. }
  207. .visit-item {
  208. background-color: #fff;
  209. margin: 16rpx 20rpx;
  210. border-radius: 16rpx;
  211. padding: 24rpx;
  212. display: flex;
  213. align-items: flex-start;
  214. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  215. }
  216. .visit-date {
  217. display: flex;
  218. flex-direction: column;
  219. align-items: center;
  220. margin-right: 24rpx;
  221. min-width: 80rpx;
  222. .date-num {
  223. font-size: 48rpx;
  224. font-weight: bold;
  225. color: #333;
  226. line-height: 1;
  227. }
  228. .date-month {
  229. font-size: 24rpx;
  230. color: #999;
  231. margin-top: 4rpx;
  232. }
  233. }
  234. .visit-content {
  235. flex: 1;
  236. .visit-header {
  237. display: flex;
  238. justify-content: space-between;
  239. align-items: center;
  240. margin-bottom: 12rpx;
  241. .visitor-info {
  242. display: flex;
  243. align-items: center;
  244. .visitor-label {
  245. margin-right: 10rpx;
  246. font-size: 32rpx;
  247. color: #333;
  248. font-weight: normal;
  249. }
  250. .visitor-name {
  251. font-size: 36rpx;
  252. color: #333;
  253. font-weight: bold;
  254. }
  255. }
  256. .visit-status {
  257. font-size: 28rpx;
  258. padding: 4rpx 12rpx;
  259. border-radius: 12rpx;
  260. &.status-pending-visit {
  261. color: #4CAF50;
  262. background-color: rgba(76, 175, 80, 0.1);
  263. }
  264. &.status-pending-review {
  265. color: #2196F3;
  266. background-color: rgba(33, 150, 243, 0.1);
  267. }
  268. &.status-rejected {
  269. color: #F44336;
  270. background-color: rgba(244, 67, 54, 0.1);
  271. }
  272. }
  273. }
  274. .visit-desc {
  275. color: #666;
  276. font-size: 28rpx;
  277. line-height: 1.4;
  278. margin-bottom: 12rpx;
  279. }
  280. .visit-time {
  281. display: flex;
  282. align-items: center;
  283. gap: 8rpx;
  284. text {
  285. color: #999;
  286. font-size: 24rpx;
  287. }
  288. }
  289. }
  290. </style>