diff --git a/.DS_Store b/.DS_Store
index 22856d2..cb93dc4 100644
Binary files a/.DS_Store and b/.DS_Store differ
diff --git a/app.js b/app.js
index c5e5921..7addc6d 100755
--- a/app.js
+++ b/app.js
@@ -177,6 +177,13 @@ App({
selectedIconPath: "/pages/images/icon/activity_icon.png",
selected: true
},
+ {
+ pagePath: "/pages/mood/mood",
+ text: "心情",
+ iconPath: "/pages/images/icon/mood_icon.png",
+ selectedIconPath: "/pages/images/icon/mood_icon.png",
+ selected: false
+ },
{
pagePath: "/pages/discover/discover",
text: "发现",
diff --git a/app.json b/app.json
index e3126b1..ab50c1b 100755
--- a/app.json
+++ b/app.json
@@ -1,44 +1,45 @@
-{
- "pages": [
- "pages/activity/activity",
- "pages/weather/weather",
- "pages/map/map",
- "pages/account/account",
- "pages/trace/trace",
- "pages/friends/friends",
- "pages/friends_showPeople/friends_showPeople",
- "pages/discover/discover",
- "pages/discoverPOI/discoverPOI",
- "pages/checkin/checkin",
- "pages/error/error",
- "pages/showpeople/showpeople",
- "pages/mood/mood",
- "pages/moodstatistics/moodstatistics",
- "pages/privacy/privacy",
- "pages/aboutus/aboutus",
- "pages/recordmood/recordmood",
- "pages/categorysta/categorysta",
- "pages/districtsta/districtsta",
- "pages/placesta/placesta",
- "pages/chooseArea/chooseArea",
- "pages/otherMood/otherMood",
- "pages/qrcode/qrcode",
- "pages/tabbar/tabbar",
- "pages/showtops/showtops"
- ],
- "window": {
- "window": {
- "navigationBarBackgroundColor": "#FFFFFF",
- "navigationBarTextStyle": "black",
- "navigationBarTitleText": "微信接口功能演示",
- "backgroundColor": "#ffffff",
- "backgroundTextStyle": "light"
- },
- "enablePullDownRefresh": true
- },
- "networkTimeout": {
- "request": 10000,
- "downloadFile": 10000
- },
- "debug": true
+{
+ "pages": [
+ "pages/activity/activity",
+ "pages/weather/weather",
+ "pages/map/map",
+ "pages/account/account",
+ "pages/trace/trace",
+ "pages/friends/friends",
+ "pages/friends_showPeople/friends_showPeople",
+ "pages/discover/discover",
+ "pages/discoverPOI/discoverPOI",
+ "pages/checkin/checkin",
+ "pages/error/error",
+ "pages/showpeople/showpeople",
+ "pages/mood/mood",
+ "pages/moodstatistics/moodstatistics",
+ "pages/privacy/privacy",
+ "pages/aboutus/aboutus",
+ "pages/recordmood/recordmood",
+ "pages/categorysta/categorysta",
+ "pages/districtsta/districtsta",
+ "pages/placesta/placesta",
+ "pages/chooseArea/chooseArea",
+ "pages/otherMood/otherMood",
+ "pages/qrcode/qrcode",
+ "pages/tabbar/tabbar",
+ "pages/showtops/showtops",
+ "pages/moodcalender/moodcalender"
+ ],
+ "window": {
+ "window": {
+ "navigationBarBackgroundColor": "#FFFFFF",
+ "navigationBarTextStyle": "black",
+ "navigationBarTitleText": "微信接口功能演示",
+ "backgroundColor": "#ffffff",
+ "backgroundTextStyle": "light"
+ },
+ "enablePullDownRefresh": true
+ },
+ "networkTimeout": {
+ "request": 10000,
+ "downloadFile": 10000
+ },
+ "debug": true
}
\ No newline at end of file
diff --git a/pages/mood/mood.js b/pages/mood/mood.js
index 030eb8f..ab0d1a1 100755
--- a/pages/mood/mood.js
+++ b/pages/mood/mood.js
@@ -55,6 +55,11 @@ Page({
url: '../moodstatistics/moodstatistics'
})
},
+ goToMoodCalender: function(){
+ wx.navigateTo({
+ url: '../moodcalender/moodcalender',
+ })
+ },
goToRecordMood_7: function(){
wx.navigateTo({
url: '../otherMood/otherMood?moodId=7'
@@ -95,31 +100,7 @@ Page({
url: '../recordmood/recordmood?moodId=6'
})
},
- classifyByDate: function () {
- var that = this;
- var tempClassifyByDate = [];
- var currentDate = '';
- var currentClass = {};
- for (var i = 0; i < this.data.history_mood.length; i++) {
- if (currentDate != this.data.history_mood[i].date){
- console.log(currentDate)
- console.log(this.data.history_mood[i].date)
- if (currentClass.date){
- tempClassifyByDate.push(currentClass);
- }
- currentClass = {};
- currentClass.date = this.data.history_mood[i].date;
- currentDate = this.data.history_mood[i].date;
-
- currentClass['moodList'] = [];
- }
- currentClass['moodList'].push(this.data.history_mood[i]);
- console.log(currentClass+'..')
- }
- tempClassifyByDate.push(currentClass);
- console.log(tempClassifyByDate)
- this.setData({classifiedMoods: tempClassifyByDate,});
- },
+
/**
* 生命周期函数--监听页面加载
*/
@@ -203,60 +184,6 @@ Page({
}
}
//获取历史数据
- var history_mood = wx.getStorageSync('history_mood');
- var that = this;
- var oldDatetmp = wx.getStorageSync('timestamp_mood');
- var oldDate = 0;
- var nowDate = (Date.parse(new Date()) / 1000);
- if (oldDatetmp == "") oldDate = 0;
- else oldDate = oldDatetmp;
-
- if (history_mood != "" && ((nowDate - oldDate) < 86400)) {
- this.setData({history_mood: history_mood});
- console.log('历史')
- console.log(history_mood)
- this.classifyByDate();
- }
- else{
- wx.request({
- url: 'https://40525433.fudan-mini-program.com/cgi-bin/MoodHistory',
- data:{
- openid: app.globalData.openid,
- sessionid: app.globalData.sessionid,
- },
- method: 'POST',
- success: function (res) {
- if(res.data.status == 'ERROR'){
- wx.showToast({
- title: '获取历史心情失败',
- icon:'loading'
- })
- }
- else{
- console.log(res)
- wx.setStorageSync('timestamp_mood', (Date.parse(new Date()) / 1000));
- var temp_history_mood = [];
- for (var i = 0; i < res.data.moods.length; i++){
-
- res.data.moods[i].date = res.data.moods[i]['datetime'].split(" ")[0];
- res.data.moods[i].time = res.data.moods[i]['datetime'].split(" ")[1];
- var temp_table = {}
- temp_table = res.data.moods[i];
- temp_table['simpletime'] = res.data.moods[i].datetime.substring(11, 19)
- temp_table['logoPath'] = '../images/mood/'+res.data.moods[i].mood_id+'.png';
- temp_history_mood.push(temp_table);
- }
- that.setData({
- history_mood: temp_history_mood,
- });
- wx.setStorageSync('history_mood', temp_history_mood);
- console.log(wx.getStorageSync('history_mood'))
- console.log(temp_history_mood)
- that.classifyByDate();
- }
- }
- })
- }
},
/**
* 生命周期函数--监听页面隐藏
diff --git a/pages/mood/mood.json b/pages/mood/mood.json
old mode 100755
new mode 100644
diff --git a/pages/mood/mood.wxml b/pages/mood/mood.wxml
index 04758cf..44009ee 100755
--- a/pages/mood/mood.wxml
+++ b/pages/mood/mood.wxml
@@ -102,7 +102,10 @@
-
+
+
+
+
@@ -111,39 +114,4 @@
{{award_text_1}}{{con_day}}{{award_text_2}}
-
-
- Timeline
-
-
-
-
-
-
- {{item.date}}
-
-
-
-
-
-
-
-
-
- {{item.mood_text}}
-
-
- 心情寄语:{{item.text}}
-
-
- {{item.time}}
-
-
-
-
-
-
-
-
-
diff --git a/pages/mood/mood.wxss b/pages/mood/mood.wxss
index 22f4514..3582486 100755
--- a/pages/mood/mood.wxss
+++ b/pages/mood/mood.wxss
@@ -39,6 +39,9 @@
.two_button_left{
margin-right: 20rpx;
}
+.two_button_right{
+ margin-right: 20rpx;
+}
.button_my{
color: black;
border: 1px solid #D1D1D1;
diff --git a/pages/moodcalender/moodcalender.js b/pages/moodcalender/moodcalender.js
new file mode 100644
index 0000000..4604952
--- /dev/null
+++ b/pages/moodcalender/moodcalender.js
@@ -0,0 +1,262 @@
+
+let chooseYear = null;
+let chooseMonth = null;
+var app = getApp();
+const conf = {
+ data: {
+ hasEmptyGrid: false,
+ showPicker: false,
+ classifiedMoods: {},
+ mood_logo_dic: {
+
+ 0: 'orange-bg', //橙色
+ 1: 'pink-bg', //粉红色
+ 2: 'green-bg', //绿色
+ 3: 'blue-bg', //平静
+ 4: 'grey-bg',// 灰色
+ 5: 'brown-bg',//棕色
+ 6: 'red-bg', //生气
+ 100: ''//无色
+ }
+
+ },
+ onLoad() {
+ },
+ onShow(){
+ const date = new Date();
+ const curYear = date.getFullYear();
+ const curMonth = date.getMonth() + 1;
+ const weeksCh = ['日', '一', '二', '三', '四', '五', '六'];
+ this.fetchHistory();
+ this.calculateEmptyGrids(curYear, curMonth);
+ this.calculateDays(curYear, curMonth);
+ this.setData({
+ curYear,
+ curMonth,
+ weeksCh
+ });
+ },
+ fetchHistory(){
+ var history_mood = wx.getStorageSync('history_mood');
+ var that = this;
+ var oldDatetmp = wx.getStorageSync('timestamp_mood');
+ var oldDate = 0;
+ var nowDate = (Date.parse(new Date()) / 1000);
+ if (oldDatetmp == "") oldDate = 0;
+ else oldDate = oldDatetmp;
+
+ if (history_mood != "" && ((nowDate - oldDate) < 86400)) {
+ this.setData({ history_mood: history_mood });
+ console.log('历史')
+ console.log(history_mood)
+ this.classifyByDate();
+ }
+ else {
+ wx.request({
+ url: 'https://40525433.fudan-mini-program.com/cgi-bin/MoodHistory',
+ data: {
+ openid: app.globalData.openid,
+ sessionid: app.globalData.sessionid,
+ },
+ method: 'POST',
+ success: function (res) {
+ if (res.data.status == 'ERROR') {
+ wx.showToast({
+ title: '获取历史心情失败',
+ icon: 'loading'
+ })
+ }
+ else {
+ console.log(res)
+ wx.setStorageSync('timestamp_mood', (Date.parse(new Date()) / 1000));
+ var temp_history_mood = [];
+ for (var i = 0; i < res.data.moods.length; i++) {
+
+ res.data.moods[i].date = res.data.moods[i]['datetime'].split(" ")[0];
+ res.data.moods[i].time = res.data.moods[i]['datetime'].split(" ")[1];
+ var temp_table = {}
+ temp_table = res.data.moods[i];
+ temp_table['simpletime'] = res.data.moods[i].datetime.substring(11, 19)
+ temp_table['logoPath'] = '../images/mood/' + res.data.moods[i].mood_id + '.png';
+ temp_history_mood.push(temp_table);
+ }
+ that.setData({
+ history_mood: temp_history_mood,
+ });
+ wx.setStorageSync('history_mood', temp_history_mood);
+ console.log(wx.getStorageSync('history_mood'))
+ console.log(temp_history_mood)
+ that.classifyByDate();
+ }
+ }
+ })
+ }
+ },
+
+ getThisMonthDays(year, month) {
+ return new Date(year, month, 0).getDate();
+ },
+ getFirstDayOfWeek(year, month) {
+ return new Date(Date.UTC(year, month - 1, 1)).getDay();
+ },
+ calculateEmptyGrids(year, month) {
+ const firstDayOfWeek = this.getFirstDayOfWeek(year, month);
+ let empytGrids = [];
+ if (firstDayOfWeek > 0) {
+ for (let i = 0; i < firstDayOfWeek; i++) {
+ empytGrids.push(i);
+ }
+ this.setData({
+ hasEmptyGrid: true,
+ empytGrids
+ });
+ } else {
+ this.setData({
+ hasEmptyGrid: false,
+ empytGrids: []
+ });
+ }
+ },
+
+ getMoodByDate(year, month, date){
+ month = (month < 10 ? '0':'') + month.toString();
+ date = (date < 10 ? '0':'') + date.toString();
+ var full_date = year + '-' + month + '-' + date;
+ console.log(this.data.classifiedMoods);
+ var mood = this.data.classifiedMoods[full_date];
+ if (!mood)
+ return 100;
+ console.log(full_date);
+ console.log(mood.moodList[0].mood_id);
+ return mood.moodList[0].mood_id;
+ },
+
+ calculateDays(year, month) {
+ let days = [];
+
+ const thisMonthDays = this.getThisMonthDays(year, month);
+
+ for (let i = 1; i <= thisMonthDays; i++) {
+ var current_mood = this.getMoodByDate(year, month, i);
+ days.push({
+ day: i,
+ choosed: current_mood
+ });
+ }
+
+ this.setData({
+ days
+ });
+ },
+
+ handleCalendar(e) {
+ const handle = e.currentTarget.dataset.handle;
+ const curYear = this.data.curYear;
+ const curMonth = this.data.curMonth;
+ if (handle === 'prev') {
+ let newMonth = curMonth - 1;
+ let newYear = curYear;
+ if (newMonth < 1) {
+ newYear = curYear - 1;
+ newMonth = 12;
+ }
+
+ this.calculateDays(newYear, newMonth);
+ this.calculateEmptyGrids(newYear, newMonth);
+
+ this.setData({
+ curYear: newYear,
+ curMonth: newMonth
+ });
+ } else {
+ let newMonth = curMonth + 1;
+ let newYear = curYear;
+ if (newMonth > 12) {
+ newYear = curYear + 1;
+ newMonth = 1;
+ }
+
+ this.calculateDays(newYear, newMonth);
+ this.calculateEmptyGrids(newYear, newMonth);
+
+ this.setData({
+ curYear: newYear,
+ curMonth: newMonth
+ });
+ }
+ },
+
+ classifyByDate: function () {
+ var that = this;
+ var tempClassifyByDate = {};
+ var currentDate = '';
+ var currentClass = {};
+ for (var i = 0; i < this.data.history_mood.length; i++) {
+ if (currentDate != this.data.history_mood[i].date) {
+ console.log(currentDate)
+ console.log(this.data.history_mood[i].date)
+ if (currentClass.date) {
+ tempClassifyByDate[currentDate] = currentClass;
+ }
+ currentClass = {};
+ currentClass.date = this.data.history_mood[i].date;
+ currentDate = this.data.history_mood[i].date;
+
+ currentClass['moodList'] = [];
+ }
+ currentClass['moodList'].push(this.data.history_mood[i]);
+ console.log(currentClass + '..')
+ }
+ tempClassifyByDate[currentDate] = currentClass;
+ console.log(tempClassifyByDate)
+ this.setData({ classifiedMoods: tempClassifyByDate, });
+ },
+ chooseYearAndMonth() {
+ const curYear = this.data.curYear;
+ const curMonth = this.data.curMonth;
+ let pickerYear = [];
+ let pickerMonth = [];
+ for (let i = 2000; i <= 2100; i++) {
+ pickerYear.push(i);
+ }
+ for (let i = 1; i <= 12; i++) {
+ pickerMonth.push(i);
+ }
+ const idxYear = pickerYear.indexOf(curYear);
+ const idxMonth = pickerMonth.indexOf(curMonth);
+ this.setData({
+ pickerValue: [idxYear, idxMonth],
+ pickerYear,
+ pickerMonth,
+ showPicker: true,
+ });
+ },
+ pickerChange(e) {
+ const val = e.detail.value;
+ chooseYear = this.data.pickerYear[val[0]];
+ chooseMonth = this.data.pickerMonth[val[1]];
+ },
+ tapPickerBtn(e) {
+ const type = e.currentTarget.dataset.type;
+ const o = {
+ showPicker: false,
+ };
+ if (type === 'confirm') {
+ o.curYear = chooseYear;
+ o.curMonth = chooseMonth;
+ this.calculateEmptyGrids(chooseYear, chooseMonth);
+ this.calculateDays(chooseYear, chooseMonth);
+ }
+
+ this.setData(o);
+ },
+ onShareAppMessage() {
+ return {
+ title: '小程序日历',
+ desc: '还是新鲜的日历哟',
+ path: 'pages/index/index'
+ };
+ }
+};
+
+Page(conf);
diff --git a/pages/moodcalender/moodcalender.json b/pages/moodcalender/moodcalender.json
new file mode 100644
index 0000000..a09708c
--- /dev/null
+++ b/pages/moodcalender/moodcalender.json
@@ -0,0 +1,3 @@
+{
+ "navigationBarTitleText": "心情日历"
+}
\ No newline at end of file
diff --git a/pages/moodcalender/moodcalender.wxml b/pages/moodcalender/moodcalender.wxml
new file mode 100644
index 0000000..9f94598
--- /dev/null
+++ b/pages/moodcalender/moodcalender.wxml
@@ -0,0 +1,55 @@
+
+
+
+
+ 《
+
+ {{curYear || "--"}} 年 {{curMonth || "--"}} 月
+
+
+ 》
+
+
+
+ {{item}}
+
+
+
+
+
+ {{item.day}}
+
+
+
+
+
+ 生气
+ 开心
+ 放松
+ 焦虑
+ 狂喜
+ 平静
+ 低落
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+ 确定
+
+
+
+ {{item}}年
+
+
+ {{item}}月
+
+
+
\ No newline at end of file
diff --git a/pages/moodcalender/moodcalender.wxss b/pages/moodcalender/moodcalender.wxss
new file mode 100644
index 0000000..914def4
--- /dev/null
+++ b/pages/moodcalender/moodcalender.wxss
@@ -0,0 +1,328 @@
+page {
+ background-color: #fff;
+ display: flex;
+ flex-direction: column;
+ width: 100%;
+ height: 100%;
+}
+
+.box {
+ display: flex;
+}
+
+.box-lr {
+ flex-direction: row;
+}
+
+.box-rl {
+ flex-direction: row-reverse;
+}
+
+.box-tb {
+ flex-direction: column;
+}
+
+.box-bt {
+ flex-direction: column-reverse;
+}
+
+.box-pack-center {
+ justify-content: center;
+}
+
+.box-pack-start {
+ justify-content: flex-start;
+}
+
+.box-pack-end {
+ justify-content: flex-end;
+}
+
+.box-pack-between {
+ justify-content: space-between;
+}
+
+.box-pack-around {
+ justify-content: space-around;
+}
+
+.box-align-center {
+ align-items: center;
+}
+
+.box-align-start {
+ align-items: flex-start;
+}
+
+.box-align-end {
+ align-items: flex-end;
+}
+
+.self-align-center {
+ align-self: center;
+ margin: 0 auto;
+}
+
+.self-align-start {
+ align-self: flex-start;
+}
+
+.self-align-end {
+ align-self: flex-end;
+}
+
+.self-align-stretch {
+ align-self: stretch;
+}
+
+.box-wrap {
+ flex-wrap: wrap;
+}
+
+.box-nowrap {
+ flex-wrap: nowrap;
+}
+
+.flex {
+ flex-grow: 1;
+}
+
+.shrink {
+ flex-shrink: 1;
+}
+
+.bg {
+ background-image: linear-gradient(to bottom, #faefe7, #ffcbd7);
+ overflow: hidden;
+}
+
+.brown-color {
+ color: #784344;
+}
+
+.pink-color {
+ color: #ff629a;
+}
+
+.white-color {
+ color: #fff;
+}
+
+.fs24 {
+ font-size: 24rpx;
+}
+
+.fs28 {
+ font-size: 28rpx;
+}
+
+.fs32 {
+ font-size: 32rpx;
+}
+
+.fs36 {
+ font-size: 36rpx;
+}
+
+.top-handle {
+ height: 150rpx;
+}
+
+.prev {
+ text-align: right;
+ height: 80rpx;
+}
+
+.next {
+ height: 80rpx;
+}
+
+.prev-handle {
+ width: 80rpx;
+ height: 100%;
+}
+
+.next-handle {
+ width: 80rpx;
+ height: 100%;
+}
+
+.date-area {
+ width: 50%;
+ height: 80rpx;
+ text-align: center;
+}
+
+.weeks {
+ height: 50rpx;
+ line-height: 50rpx;
+ opacity: 0.5;
+}
+
+.week {
+ font-size: 20px;
+ text-align: center;
+}
+
+.days {
+ height: 500rpx;
+}
+
+.grid {
+ width: 107.1428571429rpx;
+}
+
+.day {
+ width: 60rpx;
+ height: 60rpx;
+ color: black;
+ font-size: 26rpx;
+ font-weight: 200;
+}
+
+.mark {
+ width: 120rpx;
+ height: 80rpx;
+ font-size: 30rpx;
+}
+
+.border-radius {
+ border-radius: 50%;
+ position: relative;
+ left: 0;
+ top: 0;
+ color: #fff;
+}
+
+.pink-bg {
+ background-color: #ff629a;
+}
+
+.purple-bg {
+ background-color: #b8b8f1;
+}
+
+.green-bg {
+ background-color: #88d2ac;
+}
+
+.brown-bg {
+ background-color: #784344;
+}
+
+.orange-bg {
+ background-color: #D2691E;
+}
+
+.red-bg {
+ background-color: #DC143C;
+}
+
+.grey-bg {
+ background-color: #CDC9C9;
+}
+
+.blue-bg {
+ background-color: #5CACEE;
+}
+
+.right-triangle::after {
+ content: "";
+ display: block;
+ width: 0;
+ height: 0;
+ border: 15rpx solid transparent;
+ border-left-color: #ff629a;
+ position: absolute;
+ right: -22rpx;
+ top: 18rpx;
+}
+
+.left-triangle::before {
+ content: "";
+ display: block;
+ width: 0;
+ height: 0;
+ border: 15rpx solid transparent;
+ border-right-color: #ff629a;
+ position: absolute;
+ left: -22rpx;
+ top: 18rpx;
+}
+
+.tips {
+ text-align: center;
+ margin-top: 20rpx;
+ margin-bottom: 20rpx;
+}
+
+.types {
+ background-color: #ffedf4;
+ height: 50rpx;
+}
+
+.types-desc {
+ padding: 0 20rpx;
+}
+
+.type-name {
+ margin-top: 50rpx;
+ margin-bottom: 30rpx;
+}
+
+.type-desc {
+ padding: 0 35rpx;
+ line-height: 38rpx;
+}
+
+.explain {
+ border-top: 1px solid #eee;
+ width: 90%;
+ margin: 20rpx 5% 20rpx 5%;
+ padding: 20rpx 0;
+}
+
+.explain-title {
+ font-weight: bold;
+ margin-bottom: 15rpx;
+}
+
+.explain-item {
+ padding: 8rpx 20rpx;
+ color: #fff;
+}
+
+.left-border-radius {
+ border-top-left-radius: 20rpx;
+ border-bottom-left-radius: 20rpx;
+}
+
+.right-border-radius {
+ border-top-right-radius: 20rpx;
+ border-bottom-right-radius: 20rpx;
+}
+
+.picker-btns {
+ height: 120rpx;
+ line-height: 120rpx;
+ border-bottom: 1rpx solid #ff7ca0;
+}
+
+.picker-confirm {
+ margin-right: 50rpx;
+}
+
+.picker-cancel {
+ margin-left: 50rpx;
+}
+
+.picker-view {
+ color: #ff7ca0;
+ text-align: center;
+}
+.button_my{
+ color: black;
+ border: 1px solid #D1D1D1;
+ height: 40px;
+ font-size: 15px;
+}
\ No newline at end of file