index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. <template>
  2. <view class="container">
  3. <!-- Visit list -->
  4. <scroll-view scroll-y class="visit-list" @scrolltolower="onReachBottom">
  5. <view class="visit-item" v-for="(item, index) in taskList" :key="index">
  6. <view class="visit-date">
  7. <text class="date-num">{{item.date}}</text>
  8. <text class="date-month">{{item.year}}</text>
  9. </view>
  10. <view class="visit-content">
  11. <view class="visit-header">
  12. <view class="visitor-info">
  13. <text class="visitor-label">对接人 </text>
  14. <text class="visitor-name">{{item.visitorName}}</text>
  15. </view>
  16. <text class="visit-status">{{item.status}}</text>
  17. </view>
  18. <view class="visit-desc">{{item.description}}</view>
  19. <view class="visit-time">
  20. <u-icon name="clock" size="12" color="#999"></u-icon>
  21. <text>{{item.time}}</text>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- Loading more -->
  26. <u-loadmore :status="loadMoreStatus" />
  27. </scroll-view>
  28. <!-- Floating button -->
  29. <view class="floating-button" @click="showApplyPopup">
  30. <text class="floating-text">申请<br>访问</text>
  31. </view>
  32. <!-- Application method popup -->
  33. <uni-popup ref="popup" type="center" border-radius="16rpx">
  34. <view class="popup-content">
  35. <view class="popup-title">
  36. 选择申请方式
  37. <text class="close-icon" @click="closePopup">×</text>
  38. </view>
  39. <view class="apply-methods">
  40. <view class="method-item" @click="handleApply('self')">
  41. <view class="method-icon green-bg">
  42. <image src="/static/images/apply.png" mode="aspectFit"></image>
  43. </view>
  44. <text class="font-bold">发起申请</text>
  45. </view>
  46. <view class="method-item" @click="handleApply('proxy')">
  47. <view class="method-icon orange-bg">
  48. <image src="/static/images/behalf.png" mode="aspectFit"></image>
  49. </view>
  50. <text class="font-bold">代客申请</text>
  51. </view>
  52. </view>
  53. </view>
  54. </uni-popup>
  55. </view>
  56. </template>
  57. <script>
  58. import {
  59. orderList,
  60. } from '@/config/api.js';
  61. import {
  62. mapGetters,
  63. mapActions
  64. } from 'vuex';
  65. import {
  66. shareImg
  67. } from '@/common/config.js'
  68. export default {
  69. data() {
  70. return {
  71. taskList: [],
  72. loadMoreStatus: 'loadmore', // loadmore, loading, nomore
  73. params: {
  74. current: 1,
  75. size: 10,
  76. },
  77. hasMore: true
  78. }
  79. },
  80. computed: {
  81. ...mapGetters(['isLogin'])
  82. },
  83. onLoad(options) {
  84. this.getList();
  85. },
  86. // 微信小程序分享配置
  87. onShareAppMessage() {
  88. return {
  89. title: `邀请您加入知己访客`,
  90. path: `/pages/index/index`,
  91. imageUrl: shareImg // 分享图片,需要添加
  92. }
  93. },
  94. onShareTimeline(res) {
  95. let that = this;
  96. let shareInfo = store.state.vuex_shareInfo;
  97. let query = shareInfo.query;
  98. //携带当前页面资源ID参数
  99. let currentPage = getCurrentPages()[getCurrentPages().length - 1];
  100. let options = currentPage.options;
  101. if (JSON.stringify(options) != '{}' && options.id) {
  102. query += `&id=${options.id}`;
  103. }
  104. return {
  105. title: shareInfo.title,
  106. query: query,
  107. imageUrl: shareImg,
  108. success(res) {
  109. uni.showToast({
  110. title: '分享成功'
  111. })
  112. },
  113. fail(res) {
  114. uni.showToast({
  115. title: '分享失败',
  116. icon: 'none'
  117. })
  118. },
  119. }
  120. },
  121. onShow() {
  122. // #ifdef H5
  123. this.login()
  124. // #endif
  125. },
  126. onPullDownRefresh() {
  127. this.refresh()
  128. uni.stopPullDownRefresh();
  129. },
  130. methods: {
  131. ...mapActions(['setToken', 'setUserInfo']),
  132. // Refresh list
  133. refresh() {
  134. this.taskList = []
  135. this.params.current = 1
  136. this.hasMore = true
  137. this.loadMoreStatus = 'loadmore'
  138. this.getList()
  139. },
  140. // Handle reaching bottom of scroll
  141. onReachBottom() {
  142. if (!this.hasMore || this.loadMoreStatus === 'loading') return
  143. this.params.current++
  144. this.getList(true)
  145. },
  146. // Show apply popup
  147. showApplyPopup() {
  148. console.log('显示申请弹窗');
  149. this.$refs.popup.open()
  150. },
  151. // Close popup
  152. closePopup() {
  153. this.$refs.popup.close()
  154. },
  155. // Handle apply method selection
  156. handleApply(type) {
  157. console.log('选择申请方式:', type);
  158. this.$refs.popup.close()
  159. if (type === 'self') {
  160. uni.showToast({
  161. title: '跳转到发起申请页面',
  162. icon: 'none'
  163. });
  164. // uni.navigateTo({
  165. // url: '/pagesA/public/visit-apply'
  166. // })
  167. } else {
  168. uni.showToast({
  169. title: '跳转到代客申请页面',
  170. icon: 'none'
  171. });
  172. // uni.navigateTo({
  173. // url: '/pagesA/public/proxy-visit-apply'
  174. // })
  175. }
  176. },
  177. // Login method
  178. login() {
  179. let params = {
  180. username: "USER082927",
  181. grant_type: "web",
  182. memberId: "1957060037088083973"
  183. }
  184. userLogin(params).then((loginData) => {
  185. uni.setStorageSync('access_token', loginData.access_token);
  186. uni.setStorageSync('refresh_token', loginData.refresh_token);
  187. uni.setStorageSync('user', loginData);
  188. this.$store.commit('isLogin', true);
  189. this.$store.commit('refresh_token', loginData.refresh_token);
  190. })
  191. },
  192. // Get visit list with mock data
  193. getList(loadMore = false) {
  194. if (!loadMore) {
  195. uni.showLoading({
  196. title: '加载中...'
  197. });
  198. }
  199. this.loadMoreStatus = 'loading'
  200. // 模拟接口延迟
  201. setTimeout(() => {
  202. // 模拟数据
  203. const mockData = Array(10).fill(0).map((_, index) => {
  204. const currentIndex = (this.params.current - 1) * 10 + index;
  205. const date = new Date();
  206. date.setDate(date.getDate() - currentIndex); // 每条数据日期递减
  207. const statusList = ['待审核', '已通过', '已拒绝'];
  208. const descList = [
  209. '我是访问事由我是访问事由我是访问事由...',
  210. '需要进行业务对接商谈...',
  211. '产品展示与技术交流...',
  212. '项目合作洽谈...'
  213. ];
  214. return {
  215. id: currentIndex,
  216. visitorName: `范海洋${currentIndex + 1}`,
  217. createTime: date,
  218. status: statusList[Math.floor(Math.random() * statusList.length)],
  219. description: descList[Math.floor(Math.random() * descList.length)]
  220. };
  221. });
  222. const list = mockData.map(item => ({
  223. ...item,
  224. date: this.$u.timeFormat(item.createTime, 'DD'),
  225. year: this.$u.timeFormat(item.createTime, 'YYYY/MM'),
  226. time: this.$u.timeFormat(item.createTime, 'hh:mm')
  227. }));
  228. if (loadMore) {
  229. this.taskList = [...this.taskList, ...list];
  230. } else {
  231. this.taskList = list;
  232. }
  233. // 模拟总共有5页数据
  234. this.hasMore = this.params.current < 5;
  235. this.loadMoreStatus = this.hasMore ? 'loadmore' : 'nomore';
  236. if (!loadMore) {
  237. uni.hideLoading();
  238. }
  239. }, 500); // 增加500ms延迟模拟网络请求
  240. },
  241. },
  242. }
  243. </script>
  244. <style lang="scss" scoped>
  245. .container {
  246. min-height: 100vh;
  247. background-color: #f5f5f5;
  248. }
  249. .visit-list {
  250. height: 100vh;
  251. }
  252. .visit-item {
  253. background-color: #fff;
  254. margin: 16rpx 20rpx;
  255. border-radius: 16rpx;
  256. padding: 24rpx;
  257. display: flex;
  258. align-items: flex-start;
  259. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  260. }
  261. .visit-date {
  262. display: flex;
  263. flex-direction: column;
  264. align-items: center;
  265. margin-right: 24rpx;
  266. min-width: 80rpx;
  267. .date-num {
  268. font-size: 48rpx;
  269. font-weight: bold;
  270. color: #333;
  271. line-height: 1;
  272. }
  273. .date-month {
  274. font-size: 24rpx;
  275. color: #999;
  276. margin-top: 4rpx;
  277. }
  278. }
  279. .visit-content {
  280. flex: 1;
  281. .visit-header {
  282. display: flex;
  283. justify-content: space-between;
  284. align-items: center;
  285. margin-bottom: 12rpx;
  286. .visitor-info {
  287. display: flex;
  288. align-items: center;
  289. .visitor-label {
  290. margin-right: 10rpx;
  291. font-size: 32rpx;
  292. color: #333;
  293. font-weight: normal;
  294. }
  295. .visitor-name {
  296. font-size: 36rpx;
  297. color: #333;
  298. font-weight: bold;
  299. }
  300. }
  301. .visit-status {
  302. font-size: 28rpx;
  303. color: #4CAF50;
  304. background-color: rgba(76, 175, 80, 0.1);
  305. padding: 4rpx 12rpx;
  306. border-radius: 12rpx;
  307. }
  308. }
  309. .visit-desc {
  310. color: #666;
  311. font-size: 28rpx;
  312. line-height: 1.4;
  313. margin-bottom: 12rpx;
  314. }
  315. .visit-time {
  316. display: flex;
  317. align-items: center;
  318. gap: 8rpx;
  319. text {
  320. color: #999;
  321. font-size: 24rpx;
  322. }
  323. }
  324. }
  325. .floating-button {
  326. position: fixed;
  327. bottom: 120rpx;
  328. right: 40rpx;
  329. width: 120rpx;
  330. height: 120rpx;
  331. background-color: #FF6B00;
  332. border-radius: 16rpx;
  333. display: flex;
  334. align-items: center;
  335. justify-content: center;
  336. box-shadow: 0 8rpx 20rpx rgba(255, 107, 0, 0.3);
  337. z-index: 999;
  338. .floating-text {
  339. color: #fff;
  340. font-size: 28rpx;
  341. text-align: center;
  342. line-height: 1.2;
  343. }
  344. }
  345. .popup-content {
  346. width: 600rpx;
  347. padding: 70rpx 40rpx;
  348. background-color: #fff;
  349. border-radius: 16rpx;
  350. .popup-title {
  351. font-size: 36rpx;
  352. color: #333;
  353. text-align: center;
  354. position: relative;
  355. margin-bottom: 60rpx;
  356. font-weight: 500;
  357. .close-icon {
  358. position: absolute;
  359. right: 0;
  360. top: 50%;
  361. transform: translateY(-50%);
  362. font-size: 50rpx;
  363. color: #999;
  364. width: 60rpx;
  365. height: 60rpx;
  366. display: flex;
  367. align-items: center;
  368. justify-content: center;
  369. }
  370. }
  371. .apply-methods {
  372. display: flex;
  373. justify-content: space-around;
  374. padding: 0 20rpx;
  375. .method-item {
  376. display: flex;
  377. flex-direction: column;
  378. align-items: center;
  379. gap: 30rpx;
  380. cursor: pointer;
  381. .method-icon {
  382. width: 120rpx;
  383. height: 120rpx;
  384. border-radius: 20rpx;
  385. display: flex;
  386. align-items: center;
  387. justify-content: center;
  388. image {
  389. width: 80rpx;
  390. height: 80rpx;
  391. }
  392. &.green-bg {
  393. background-color: #39833b;
  394. }
  395. &.orange-bg {
  396. background-color: #FF6B00;
  397. }
  398. }
  399. text {
  400. font-size: 32rpx;
  401. color: #333;
  402. font-weight: 500;
  403. }
  404. }
  405. }
  406. }
  407. </style>