zhaoxiaohai 2 years ago
parent
commit
673f26cb40

+ 122 - 4
packageA/clockIn/index.js

@@ -1,8 +1,126 @@
+const _Http = getApp().globalData.http,
+	getHeight = require("../../utils/getRheRemainingHeight");
+
+
 Page({
-    data: {
+	data: {
+		list: [],
+	},
+	onLoad(options) {},
+	/* 日历加载完成 */
+	handleCalendarLoad({
+		detail
+	}) {
+		console.log("日历加载完成", detail)
+		/* let {
+			year,
+			month,
+			day
+		} = detail.date;
+		month = month < 10 ? "0" + month : month;
+		day = day < 10 ? "0" + day : day;
+		this.querySignIn(year + '-' + month + '-' + day) */
+	},
+	/* 日期发生变化 */
+	handleCalendarDateChange({
+		detail
+	}) {
+		console.log("日期发生变化", detail)
+		this.setData({
+			list: []
+		})
+		if (detail.date.marker) {
+			let {
+				year,
+				month,
+				day
+			} = detail.date;
+			month = month < 10 ? "0" + month : month;
+			day = day < 10 ? "0" + day : day;
+			this.querySignIn(year + '-' + month + '-' + day)
+		}
+	},
+	/* 查询签到日 */
+	checkIn(content) {
+		_Http.basic({
+			"accesstoken": "3614131fa126be7f41ea07d99b5d9fe6",
+			"id": 20221229150001,
+			content
+		}).then(res => {
+			console.log("查询签到日", content, res)
+			if (res.data.length) {
+				this.selectComponent("#calendar").setMarkers(res.data.map(v => {
+					let date = v.split("-");
+					return {
+						year: date[0],
+						month: date[1],
+						day: date[2],
+						type: "schedule",
+						mark: '签到',
+						color: '#2a97ff',
+						bgColor: '#cce6ff'
+					}
+				}))
+			}
+		})
+	},
+	/* 查询签到记录 */
+	querySignIn(signindate) {
+		_Http.basic({
+			"id": 20221229150101,
+			"content": {
+				signindate,
+				pageSize: 999
+			}
+		}).then(res => {
+			console.log('查询签到记录', res)
+			this.setData({
+				list: res.data
+			})
+		})
+	},
+	/* 日期范围发生变化 */
+	handleCalendarRangeChange({
+		detail
+	}) {
+		console.log("日期范围变化", detail)
+		let {
+			year,
+			month,
+			day
+		} = detail.curr;
+
+		this.checkIn({
+			year,
+			month
+		});
 
-    },
-    onLoad(options) {
+		this.setData({
+			list: []
+		})
 
-    },
+		month = month < 10 ? "0" + month : month;
+		day = day < 10 ? "0" + day : day;
+		this.querySignIn(year + '-' + month + '-' + day)
+	},
+	/* 更新日期数据 */
+	toDate(date) {
+		this.selectComponent("#calendar").toDate(date)
+	},
+	toSignIn() {
+		wx.navigateTo({
+			url: '/packageA/clockIn/signIn',
+		})
+	},
+	onReady() {
+		this.setListHeight();
+	},
+	setListHeight() {
+		getHeight.getHeight('.head', this).then(res => {
+			if (this.data.listHeight != res)
+				this.setData({
+					listHeight: res
+				})
+		});
+	},
 })

+ 4 - 1
packageA/clockIn/index.json

@@ -1,3 +1,6 @@
 {
-    "usingComponents": {}
+	"usingComponents": {
+		"calendar": "/components/wx-calendar/index"
+	},
+	"navigationBarTitleText": "签到"
 }

+ 54 - 1
packageA/clockIn/index.scss

@@ -1 +1,54 @@
-/* packageA/clockIn/index.wxss */
+page {
+	height: 100vh;
+	overflow: hidden;
+}
+
+.float-but {
+	display: flex;
+	align-items: center;
+	justify-content: center;
+	width: 120rpx;
+	height: 120rpx;
+	background-color: var(--assist);
+	border-radius: 50%;
+	color: #ffffff;
+	transform: translate(-50%, -50%);
+}
+
+.history {
+	background-color: #F4F5F7;
+
+	.item {
+		width: 100vw;
+		padding: 20rpx 30rpx;
+		box-sizing: border-box;
+		background-color: #ffffff;
+		margin: 10rpx 0;
+
+		.time {
+			height: 40rpx;
+			line-height: 40rpx;
+			font-size: 28rpx;
+			color: #333333;
+		}
+
+		.location {
+			margin-top: 10rpx;
+
+			.iconfont {
+				margin-right: 4rpx;
+			}
+
+			line-height: 34rpx;
+			font-size: 24rpx;
+			color: #666666;
+		}
+
+		.exp {
+			line-height: 34rpx;
+			font-size: 24rpx;
+			color: #999999;
+			margin-top: 10rpx;
+		}
+	}
+}

+ 23 - 1
packageA/clockIn/index.wxml

@@ -1 +1,23 @@
-<navigator url="/packageA/clockIn/signIn">签到</navigator>
+<view class="head" />
+<My_listBox id='ListBox' pullDown='{{false}}' height="{{listHeight}}">
+	<view class="container">
+		<calendar id="calendar" bindload="handleCalendarLoad" binddatechange="handleCalendarDateChange" bindrangechange="handleCalendarRangeChange" bindviewchange="handleCalendarPanelViewChange" _position="absolute" _top="0">
+			<view class="history">
+				<view class="item" wx:for="{{list}}" wx:key="item.rowindex">
+					<view class="time">{{item.signintime}}</view>
+					<view class="location">
+						<text class="iconfont icon-a-wodemendianxinxidizhi" />{{item.address}}
+					</view>
+					<view class="exp">说明:{{item.remarks|| ' --'}}</view>
+				</view>
+				<view style="height: 40rpx;" />
+			</view>
+		</calendar>
+	</view>
+</My_listBox>
+
+<Yl_FloatingButton useSlot zIndex='99999999999' bindtap="toSignIn">
+	<view class="float-but">
+		签到
+	</view>
+</Yl_FloatingButton>

+ 1 - 0
packageA/clockIn/signIn.js

@@ -63,6 +63,7 @@ Page({
 				icon: "none"
 			})
 			if (res.msg == '成功') setTimeout(() => {
+				getCurrentPages()[getCurrentPages().length - 2].toDate(this.data.time.split(" ")[0]);
 				wx.navigateBack();
 			}, 500)
 		})

+ 1 - 1
pages/tabbar/home/index.js

@@ -292,7 +292,7 @@ Page({
             gridList.push({
                 name: "签到",
                 path: "/packageA/clockIn/index",
-                icon: "icon-xiaochengxu_xiaoshouyuce",
+                icon: "icon-a-wodemendianxinxidizhi",
                 apps: {}
             })
             /* 首页小组件查询 */