diff --git a/packageA/pages/checkin/checkin.js b/packageA/pages/checkin/checkin.js new file mode 100644 index 0000000..10ea4fa --- /dev/null +++ b/packageA/pages/checkin/checkin.js @@ -0,0 +1,291 @@ +// packageA//pages/checkin/checkin.js +const app = getApp(); + +Page({ + + /** + * 页面的初始数据 + */ + data: { + year: '', + month: '', + day: '', + weekArr: ['日', '一', '二', '三', '四', '五', '六'], + dateArr: [], + firstDay: '', + lastDay: '', + param: null, + clockNum: 3, + + res: null, + isShowRules: false, + isCheckIn: false, + checkInDays: 0, //连续签到天数 + integral: 0, //积分 + checkInNums: 0, //补签次数 + isCheckInDay: '', + + + flag: true, + }, + + loadQd(callback) { + let self = this; + app.request.get('/api/weshop/qdrecord/getUser/'+ app.globalData.setting.stoid + '/' + app.globalData.user_id, { + success: function (res) { + if(callback) callback(); + self.setData({ + res: res.data.data + }); + self.loadCheckedRecord(); + }, + }); + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function(options) { + let self = this; + this.getDate(); + this.setDate(); + var res = wx.getSystemInfoSync(); + this.setData({ + param: res.windowHeight / 12, + }) + + this.loadQd(); + + }, + + + // 点击"我的积分"和"去购物"进行跳转 + goto(e) { + let url = e.target.dataset.url; + app.goto(url); + }, + + + // 点击显示签到规则 + showRules() { + if(this.data.isShowRules) { + this.setData({ + isShowRules: false + }); + } else { + this.setData({ + isShowRules: true + }); + } + }, + + + // 加载签到记录 + loadCheckedRecord() { + let newDateArr = this.data.dateArr; + let list; + let bqlist; + if(this.data.res.qddaylist) { + list = this.data.res.qddaylist.split(','); + for(let item of list) { + newDateArr[item-1].isCheckIn = true; + }; + } + if(this.data.res.curbqdaynum) { + bqlist = this.data.res.curbqdaynum.split(','); + for(let item of bqlist) { + var date = new Date(item); + newDateArr[date.getDate()-1].isBq = true; + } + } + this.setData({ + dateArr: newDateArr + }); + }, + + // 点击签到 + checkInToday() { + const self = this; + // 获取今天的签到状态 + let isCheckInToday = this.data.dateArr[this.data.day-1].isCheckIn; + // 如果还没签到, 可以点击签到 + if(!isCheckInToday) { + app.request.promisePost('/api/weshop/qdrecord/saveQd', { + data: { + store_id: app.globalData.setting.stoid, + user_id: app.globalData.user_id, + } + }).then(res => { + // 改变签到状态,由false置为true + // let newDateArr = self.data.dateArr; + // newDateArr[self.data.day-1].isCheckIn = true; + + self.loadQd(function() { + wx.showToast({ + title: self.data.res.qdintro, + icon: 'none', + duration: 1500, + success: function() { + + } + }); + }); + + }) + } + }, + + + // 补签 + reCheckIn() { + var self = this; + // var i = 0; + console.log('补签~'); + if(this.data.flag) { + this.data.flag = false; + app.request.promisePost('/api/weshop/qdrecord/saveBQd', { + data: { + store_id: app.globalData.setting.stoid, + user_id: app.globalData.user_id, + daynum: self.data.res.getBQIntegral, + bqnum: self.data.res.getbqnum2, + bqintegral: self.data.res.getBQIntegral1, + } + }).then(res => { + // 改变签到状态,由false置为true + // let newDateArr = self.data.dateArr; + // newDateArr[self.data.day-1].isCheckIn = true; + var bqlist = self.data.res.curbqdaynum.split(',').sort(); + var list = []; + for(let item of bqlist) { + var date = new Date(item); + list.push(date.getDate()); + } + + self.data.dateArr[list[0]-1].isBq = false; + self.setData({ + dateArr: self.data.dateArr + }); + + self.loadQd(function() { + self.data.flag = true; + wx.showToast({ + title: '补签成功', + icon: 'success', + duration: 1500, + success: function() { + + } + }); + }); + }) + } + }, + + + + + + getDate: function() { //获取当月日期 + var mydate = new Date(); + var year = mydate.getFullYear(); + var month = mydate.getMonth(); //0~11: 一月至十二月 + var months = month + 1; //1~12:一月至十二月 + this.data.year = year; + this.data.month = months; + this.data.day = mydate.getDate(); //获取当月日期: 1~31 + var fist = new Date(year, month, 1); + this.data.firstDay = fist.getDay(); //获取当月第一天 + var last = new Date(year, months, 0); //0表示当月最后一天 + this.data.lastDay = last.getDate(); //获取当月最后一天 + + this.setData({ + year: this.data.year, + month: this.data.month, + day: this.data.day, + firstDay: this.data.firstDay, + lastDay: this.data.lastDay + }) + console.log("今天:" + this.data.day); + }, + + setDate: function() { + var day; + for (var i = 1; i < this.data.lastDay + 1; i++) { + day = { + num: i, + }; + this.data.dateArr.push(day); + } + this.setData({ + dateArr: this.data.dateArr, + // firstDay: this.data.firstDay + }); + }, + + // prevMonth: function() { //上一月 + // var months = ""; + // var years = ""; + // if (this.data.month == 1) { + // years = this.data.year - 1 + // this.data.month = 12; + // months = this.data.month; + // } else { + // years = this.data.year; + // months = this.data.month - 1; + // } + + // var first = new Date(years, months - 1, 1); + // this.data.firstDay = first.getDay(); + // var last = new Date(years, months, 0); + // this.data.lastDay = last.getDate(); + + // this.setData({ + // month: months, + // year: years, + // firstDay: this.data.firstDay, + // lastDay: this.data.lastDay + // }) + + // this.data.dateArr = []; + // for (var i = 1; i < this.data.lastDay + 1; i++) { + // this.data.dateArr.push(i); + // } + // this.setData({ + // dateArr: this.data.dateArr + // }) + // }, + + // nextMonth: function() { //下一月 + // var months = ""; + // var years = ""; + // if (this.data.month == 12) { + // this.data.month = 0; + // months = this.data.month; + // years = this.data.year + 1; + // } else { + // months = this.data.month + 1; + // years = this.data.year; + // } + // var months = this.data.month + 1; + // var first = new Date(years, months - 1, 1); + // this.data.firstDay = first.getDay(); + // var last = new Date(years, months, 0); + // this.data.lastDay = last.getDate(); + // this.setData({ + // month: months, + // year: years, + // firstDay: this.data.firstDay, + // lastDay: this.data.lastDay + // }) + + // this.data.dateArr = []; + // for (var i = 1; i < this.data.lastDay + 1; i++) { + // this.data.dateArr.push(i); + // } + // this.setData({ + // dateArr: this.data.dateArr + // }) + // }, + +}) diff --git a/packageA/pages/checkin/checkin.json b/packageA/pages/checkin/checkin.json new file mode 100644 index 0000000..c387c73 --- /dev/null +++ b/packageA/pages/checkin/checkin.json @@ -0,0 +1,5 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "签到领积分", + "enablePullDownRefresh": false +} \ No newline at end of file diff --git a/packageA/pages/checkin/checkin.wxml b/packageA/pages/checkin/checkin.wxml new file mode 100644 index 0000000..a155ed9 --- /dev/null +++ b/packageA/pages/checkin/checkin.wxml @@ -0,0 +1,114 @@ + + + + + 我的积分 + 规则 + + + + + +{{res.cday1}} + {{myUtil.setDate(year, res.sday2, 0)}}日 + + + +{{res.daynum}} + {{myUtil.setDate(year, res.sday2, 1)}}日 + + + +{{res.tdayc1}} + {{myUtil.setDate(year, res.sday2, 2)}}日 + + + +{{res.tdayc2}} + {{myUtil.setDate(year, res.sday2, 3)}}日 + + + +{{res.tdayc3}} + {{myUtil.setDate(year, res.sday2, 4)}}日 + + + +{{res.tdayc4}} + {{myUtil.setDate(year, res.sday2, 5)}}日 + + + +{{res.tdayc5}} + {{myUtil.setDate(year, res.sday2, 6)}}日 + + + + + + {{!dateArr[day-1].isCheckIn ? '立即签到':'今日已签到'}} + + 补签(-10分) + + + + + + + + + + + {{year}}年{{month}}月 + 补签卡:{{res.getkbqnum}} + + + + + + + + + {{item}} + + + + + + + {{item.num}} + + + + + + + + + + + + + + + 小积分大作为 + 积分抵用现金,积少成多 + + + 去购物 Go! + + + + + + + + + 签到规则 + 1.每日签到领积分 + + + X + + + + + diff --git a/packageA/pages/checkin/checkin.wxs b/packageA/pages/checkin/checkin.wxs new file mode 100644 index 0000000..540a1ed --- /dev/null +++ b/packageA/pages/checkin/checkin.wxs @@ -0,0 +1,20 @@ +var myUtil = { + setDate: function(year, startDate, num) { + var date = getDate(year + '-' + startDate); + date.setDate(date.getDate() + num); + date = getDate(date).getDate(); + return date; + }, + + // dateDiff: function(firstDate,secondDate) { + // var firstDate = new Date(firstDate); + // var secondDate = new Date(secondDate); + // var diff = Math.abs(firstDate.getTime() - secondDate.getTime()); + // var result = parseInt(diff / (1000 * 60 * 60 * 24)); + // return result; + // }, +}; + +module.exports = { + setDate: myUtil.setDate, +}; \ No newline at end of file diff --git a/packageA/pages/checkin/checkin.wxss b/packageA/pages/checkin/checkin.wxss new file mode 100644 index 0000000..2cddae1 --- /dev/null +++ b/packageA/pages/checkin/checkin.wxss @@ -0,0 +1,356 @@ +/* packageA//pages/checkin/checkin.wxss */ +@charset "utf-8"; +page, +.checkin-container { + /* height: 100%; + overflow: hidden; */ +} + +.checkin-container { + background: linear-gradient(#FF7A07, #FF980F, white 95%); + background-repeat: no-repeat; +} + +.checkin-container { + /* background-color: #3F7EFF; */ +} + +.rule-container { + padding-top: 40rpx; + align-items: center; + justify-content: space-between; + position: relative; +} +.points { + background-color: #FFBC47; + color: #333; + font-size: 26rpx; + border-top-right-radius: 25rpx; + border-bottom-right-radius: 25rpx; + display: flex; + align-items: center; + padding-right: 20rpx; + line-height: 50rpx; +} +.rule { + padding: 10rpx 20rpx; + color: #FFBC47; + font-size: 26rpx; +} + +.coin { + width: 30rpx; + height: 25rpx; + padding-left: 10rpx; + padding-right: 6rpx; +} + +.current { + display: flex; + justify-content: space-between; + padding: 60rpx 30rpx 30rpx; + color: white; + font-size: 28rpx; +} + +.days { + font-weight: bold; + color: #FFE749; +} + +.f-vc { + display: flex; + align-items: center; +} + +.btn-container { + display: flex; + justify-content: space-around; + margin-bottom: 80rpx; +} + +.icon-rili, +.icon-buqian { + margin-right: 10rpx; + font-size: 40rpx; + font-weight: normal; +} + + +.btn { + width: 260rpx; + line-height: 76rpx; + padding-left: 30rpx; + padding-right: 30rpx; + background-color: #FFBC47; + border-radius: 38rpx; + color: white; + text-align: center; + box-shadow: 0 7px 0 #FF9A45, 0 8px 3px rgba(0, 0, 0, 0.3); + margin: 0 auto; + display: flex; + align-items: center; + justify-content: center; + font-weight: bold; +} + +.list { + margin: 80rpx 20rpx 60rpx; + color: rgba(255,255,255,.3); + align-items: center; + position: relative; +} +.list::after { + content: ''; + position: absolute; + left: 0; + right: 0; + top: 30rpx; + margin: 0 auto; + width: 94%; + height: 10rpx; + background-color: rgba(255,255,255,.3); +} +.list-item { + width: calc(100% / 7); + text-align: center; +} +.circle { + width: 68rpx; + height: 68rpx; + line-height: 68rpx; + font-size: 26rpx; + color: white; + background-color: #FF9A45; + margin: 0 auto 10rpx auto; + position: relative; + z-index: 3; +} +.list-item.active { + color: white; + /* font-weight: bold; */ +} +.list-item.active .circle { + box-sizing: border-box; + background-color: #FFBC47; + /* color: white; */ + border: 4rpx solid white; + line-height: 64rpx; + /* box-shadow: 2rpx 2rpx 16rpx #ddd; */ +} + +.calendar-container { + position: relative; + padding: 0 60rpx; +} +.calendar-container::before { + content: ''; + position: absolute; + left: 0; + right: 0; + top: 0; + margin: 0 auto; + width: 680rpx; + height: 24rpx; + border-radius: 12rpx; + /* background-color: #8AAFFC; */ + background: linear-gradient(#CBDAFC, #6E9CFD); + box-shadow: 0 2rpx 10rpx #6C98F4; +} +.calendar-wrapper { + background: linear-gradient(#BAD4FD, white 6rpx); + position: relative; + z-index: 2; + width: 100%; + top: 12rpx; + left: 0; + border-bottom-left-radius: 16rpx; + border-bottom-right-radius: 16rpx; + box-shadow: 0 2rpx 16rpx #999; +} +.calendar-title { + text-align: center; + line-height: 86rpx; + border-bottom: 2rpx solid #E0E6EE; + display: flex; + align-items: center; + padding: 0 20rpx; + justify-content: space-between; +} + +.calendar { + /* height: 400rpx; */ + font-size: 26rpx; + color: #838E9C; + padding-bottom: 20rpx; +} +.week { + display: flex; + flex-wrap: wrap; + text-align: center; +} + + +.jfbuy-container { + padding: 60rpx 40rpx 40rpx; +} +.jfbuy { + /* border: 2rpx solid black; */ + border-radius: 16rpx; + padding: 40rpx 30rpx; + background-color: #FF980F; + box-shadow: 0 2rpx 16rpx #FF7A07; + /* position: fixed; + width: 100%; + bottom: 0; */ + /* padding: 40rpx 20rpx; */ +} + +.jfbuy-img { + width: 260rpx; + height: 180rpx; + padding-right: 40rpx; +} +.t1 { + font-weight: bolder; + color: white; +} +.t2 { + color: white; + font-size: 24rpx; + padding-top: 10rpx; +} +.right { + display: flex; + flex-direction: column; + justify-content: space-between; + flex: 1; +} +.btn-buy { + /* padding: 20rpx 10rpx; */ + border: 2rpx solid white; + color: white; + line-height: 60rpx; + border-radius: 30rpx; +} + +.today .day { + /* background-color: skyblue; + border-radius: 50%; */ + /* color: white; */ + /* width: 44rpx; + height: 44rpx; + line-height: 44rpx; */ + /* border-radius: 50%; */ + /* background-color: rgba(255,188,71,.6); */ + /* box-shadow: 0 2rpx 12rpx #FFBC47; */ +} + +.active .day, +.bq .day { + position: relative; +} + +.active .day::after { + content: ''; + position: absolute; + width: 10rpx; + height: 10rpx; + border-radius: 50%; + background-color: #FFBC47; + left: 0; + right: 0; + bottom: 12rpx; + margin: auto; + box-shadow: 0 2rpx 12rpx #FFBC47; +} + +.bq .day { + background-color: #eee; +} + +.bq .day::before { + position: absolute; + top: 4rpx; + right: 0; + content: '补'; + color: white; + font-size: 16rpx; + line-height: 16rpx; + z-index: 5; +} +.bq .day::after { + position: absolute; + top: 0; + right: 0; + content: ''; + width: 0; + border-top: 34rpx solid #ccc; + border-left: 34rpx solid transparent; + +} + + +.popup-container { + position: fixed; + top: 0; + bottom: 0; + left: 0; + right: 0; + z-index: 99; + background-color: rgba(0,0,0,.5); +} + +.popup-wrapper { + position: absolute; + width: 80%; + max-height: 880rpx; + top: 0; + bottom: 0; + left: 0; + right: 0; + margin: auto; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +} + +.popup { + padding: 30rpx; + background-color: white; + border-radius: 20rpx; + max-height: 800rpx; + overflow: auto; +} + +.popup-title { + font-weight: 28rpx; + font-weight: bold; + padding-bottom: 20rpx; +} + +.popup-content { + text-align: justify; +} + +.popup-close { + color: white; + text-align: center; + padding-top: 20rpx; +} +.btn-close { + display: inline-block; + width: 50rpx; + height: 50rpx; + line-height: 50rpx; + border-radius: 50%; + border: 4rpx solid white; +} + +.date { + width: 100%; + display: flex; + flex-wrap: wrap; + text-align:center; +}