提交 db8c814e 编写于 作者: I inspurer

新增签到

上级 c399e7ce
......@@ -9,13 +9,18 @@
"pages/index1/index1",
"pages/write/write",
"pages/newList/newList",
"pages/about/about"
"pages/about/about",
"pages/main/main",
"pages/punch/punch",
"pages/sport/sport",
"pages/walk/walk",
"pages/run/run"
],
"window": {
"backgroundTextStyle": "dark",
"navigationBarBackgroundColor": "#FEFEFE",
"navigationBarTextStyle": "black",
"navigationBarTitleText": "校园动态",
"navigationBarTitleText": "铁道小e",
"enablePullDownRefresh": true
},
"tabBar": {
......@@ -24,11 +29,11 @@
"color": "#b2b2b2",
"selectedColor": "#1e1e1e",
"list": [
{
"pagePath": "pages/school/school",
"selectedIconPath": "static/images/school1.png",
"iconPath": "static/images/school.png",
"text": "校园动态"
{
"pagePath": "pages/school/school",
"selectedIconPath": "static/images/school1.png",
"iconPath": "static/images/school.png",
"text": "校园动态"
},
{
"pagePath": "pages/send/send",
......@@ -36,7 +41,6 @@
"iconPath": "static/images/send.png",
"text": "发布"
},
{
"pagePath": "pages/mine/mine",
"selectedIconPath": "static/images/mine1.png",
......
......@@ -33,8 +33,8 @@ Page({
var value = wx.getStorageSync('user_openid')
if (value) {
console.log("value不为空")
wx.switchTab({
url: '../school/school',
wx.navigateTo({
url: '../main/main',
});
} else {
console.log("value为空")
......@@ -58,8 +58,8 @@ Page({
} catch (e) {
}
console.log("登录成功y");
wx.switchTab({
url: '../school/school',
wx.navigateTo({
url: '../main/main',
});
},
error: function (user, error) {
......@@ -83,8 +83,8 @@ Page({
)
console.log("注册成功!");
wx.switchTab({
url: '../school/school',
wx.navigateTo({
url: '../main/main',
});
} catch (e) {
}
......
/* pages/loginer/loginer.wxss */
button{
margin-top: 300px;
width: 40%;
background-color: rgb(9, 233, 28);
}
\ No newline at end of file
// pages/mainui/main.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
school:function(e){
wx.switchTab({
url: '../school/school',
})
},
punch:function(e){
wx.navigateTo({
url: '../punch/punch',
})
},
sport:function(e){
wx.navigateTo({
url: '../sport/sport',
})
}
})
\ No newline at end of file
{}
\ No newline at end of file
<!--pages/mainui/main.wxml-->
<button class='btn_school' bindtap='school' >校园空间</button>
<button class='btn_sport' bindtap='sport' >开始运动</button>
<button class='btn_punch' bindtap='punch' >开始打卡</button>
\ No newline at end of file
/* pages/mainui/main.wxss */
.btn_school{
width: 80%;
margin-top: 150px;
background-color: rgb(9, 233, 28);
}
.btn_sport{
width: 80%;
margin-top: 60px;
margin-bottom: 60px;
background-color: rgb(9, 233, 28);
}
.btn_punch{
width: 80%;
margin-bottom: 150px;
background-color: rgb(9, 233, 28);
}
\ No newline at end of file
{
"navigationBarTitleText": "我"
}
\ No newline at end of file
{}
\ No newline at end of file
var app = getApp();
var calendarSignData;
var date;
var calendarSignDay;
var is_qd;
var Bmob = require('../../utils/bmob.js');
Page({
/**
* 页面的初始数据
*/
data: {
qdView: false,
calendarSignData: "",
calendarSignDay: "",
is_qd: false,
},
quxiaoQd: function (e) {
var that = this;
that.setData({
qdView: false,
is_qd: true
})
},
//事件处理函数
calendarSign: function (e) {
var that = this;
that.setData({
qdView: true
})
calendarSignData[date] = date;
console.log(calendarSignData);
calendarSignDay = calendarSignDay + 1;
var today = new Date().getDate()
wx.setStorageSync("calendarSignData", calendarSignData);
wx.setStorageSync("calendarSignDay", calendarSignDay);
this.setData({
calendarSignData: calendarSignData,
calendarSignDay: calendarSignDay
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function () {
var that = this;
var mydate = new Date();
var year = mydate.getFullYear();
var month = mydate.getMonth() + 1;
date = mydate.getDate();
console.log("date" + date)
var day = mydate.getDay();
console.log(day)
var nbsp = 7 - ((date - day) % 7);
console.log("nbsp" + nbsp);
var monthDaySize;
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
monthDaySize = 31;
} else if (month == 4 || month == 6 || month == 9 || month == 11) {
monthDaySize = 30;
} else if (month == 2) {
// 计算是否是闰年,如果是二月份则是29天
if ((year - 2000) % 4 == 0) {
monthDaySize = 29;
} else {
monthDaySize = 28;
}
};
wx.getStorage({
key: 'user_id',
success: function (res) {
console.log('1',111);
var user_id = new Bmob.User();
user_id.id = res.data;
wx.getStorage({
key: 'my_nick',
success: function (ress) {
console.log('2',222)
var Punch = Bmob.Object.extend("punch");
var punch = new Punch();
var me = ress.data;
var Diary = Bmob.Object.extend("punch");
var query = new Bmob.Query(Diary);
query.equalTo("nickname", me);
// 查询所有数据
query.find({
success: function (results) {
console.log("共查询到 " + results.length + " 条记录");
},
error: function (error) {
console.log("查询失败: " + error.code + " " + error.message);
punch.set('nickname', me);
punch.set('user_id', user_id);
console.log(me,user_id);
punch.save(null, {
success: function (result) {
console.log('success');
},
error: function(result,error){
console.log(result,error,"failure")
}
})
}
});
}
})
},
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
wx.removeStorageSync("calendarSignData")
wx.removeStorageSync("calendarSignDay")
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{}
\ No newline at end of file
<!--index.wxml-->
<view class="calendar">
<view class='bcfff'>
<view class="weekName">
<view class="monday">一</view>
<view class="tuesday">二</view>
<view class="wednesday">三</view>
<view class="thursday">四</view>
<view class="friday">五</view>
<view class="saturday">六</view>
<view class="sunday">日</view>
</view>
<view class="week">
<!--填补空格-->
<view wx:for="{{nbsp}}">\n</view>
<!--循环日期-->
<!-- 当天以前 -->
<view wx:for="{{date-1}}" style="color:gainsboro;">
<text wx:if="{{item+1==calendarSignData[item+1]}}" style="color: #2ccecb;">{{item+1}}</text>
<text wx:else="">{{item+1}}</text>
</view>
<!-- 当天 -->
<view style="">
<text wx:if="{{is_qd}}" style="color: #2ccecb;">{{date}}</text>
<text wx:else="" style="">{{date}}</text>
</view>
<!-- 以后 -->
<view wx:for="{{monthDaySize-date}}">{{item+date+1}}</view>
</view>
</view>
<view class="calendarSign">
<image bindtap="calendarSign" class='btnimg'></image>
<!-- wx:if="{{date!=calendarSignData[date]}}" -->
</view>
</view>
<!-- 签到成功 -->
<view class='zhegai hide {{qdView?"block":""}}' bindtap='quxiaoQd'></view>
<view class='successqd hide {{qdView?"block":""}}'>
<view class='qdtitle'>签到成功</view>
<view class='qdcontent' wx:if="{{is_qd}}">今天已经签过了~</view>
<view class='qdcontent' wx:else>签到成功,获得{{integral}}积分,您已连续签到{{rule}}天!</view>
<view class='queding' bindtap='quxiaoQd'>确定</view>
</view>
\ No newline at end of file
page {
background-color: rgb(9, 233, 28);
}
.t_red {
color: red;
}
.t_blue {
color: royalblue;
}
.calendar {
width: 500rpx;
margin: 200rpx 125rpx;
/* height: 600rpx; *//* background-color: #ffffff; */
border-radius: 4rpx;
}
.time {
padding: 16rpx 20rpx;
background-color: wheat;
display: flex;
}
.time view {
flex: 1;
font-size: 30rpx;
}
.time view text {
font-size: 38rpx;
}
.weekName {
background-color: #54ff9c;
width: 100%;
display: flex;
padding: 30rpx 0;
font-size: 40rpx;
color: #fff;
}
.weekName view {
flex: 1;
text-align: center;
}
.week {
width: 100%;
}
.week view {
width: 14.2%;
height: 50rpx;
line-height: 50rpx;
display: inline-block;
margin: 10rpx 0;
text-align: center;
font-size: 30rpx;
color: #747474;
}
.week view text {
width: 100%;
height: 100%;
display: inline-block;
}
.calendarSign {
margin-top: -75rpx;
text-align: center;
}
.btnimg {
width: 150rpx;
height: 150rpx;
border-radius: 50%;
}
.bcfff {
background-color: white;
padding-bottom: 100rpx;
}
.zhegai {
position: fixed;
top: 0;
left: 0;
bottom: 0;
width: 100%;
height: 100%;
background-color: black;
opacity: 0.4;
}
.successqd {
position: fixed;
top: 50%;
left: 50%;
width: 550rpx;
margin-left: -275rpx;
margin-top: -200rpx;
background-color:white;
border-radius: 6rpx;
border: 2rpx solid #54ff9c;
text-align: center;
}
.qdtitle{
font-size: 32rpx;
font-weight: bold;
color: #232323;
padding: 20rpx;
}
.qdcontent{
font-size: 30rpx;
color: #232323;
padding: 20rpx 10rpx;
}
.queding{
font-size: 30rpx;
color: #232323;
border-top: 1rpx solid #cccccc;
padding: 20rpx;
}
\ No newline at end of file
function formatLocation(longitude, latitude) {
longitude = longitude.toFixed(2)
latitude = latitude.toFixed(2)
return {
longitude: longitude.toString().split('.'),
latitude: latitude.toString().split('.')
}
}
module.exports = formatLocation
var countTooGetLocation = 0;
var total_micro_second = 0;
var starRun = 0;
var totalSecond = 0;
var oriMeters = 0.0;
/* 毫秒级倒计时 */
function count_down(that) {
if (starRun == 0) {
return;
}
if (countTooGetLocation >= 100) {
var time = date_format(total_micro_second);
that.updateTime(time);
}
if (countTooGetLocation >= 5000) { //1000为1s
that.getLocation();
countTooGetLocation = 0;
}
setTimeout
setTimeout(function(){
countTooGetLocation += 10;
total_micro_second += 10;
count_down(that);
}
,10
)
}
// 时间格式化输出,如03:25:19 86。每10ms都会调用一次
function date_format(micro_second) {
// 秒数
var second = Math.floor(micro_second / 1000);
// 小时位
var hr = Math.floor(second / 3600);
// 分钟位
var min = fill_zero_prefix(Math.floor((second - hr * 3600) / 60));
// 秒位
var sec = fill_zero_prefix((second - hr * 3600 - min * 60));// equal to => var sec = second % 60;
return hr + ":" + min + ":" + sec + " ";
}
function getDistance(lat1, lng1, lat2, lng2) {
var dis = 0;
var radLat1 = toRadians(lat1);
var radLat2 = toRadians(lat2);
var deltaLat = radLat1 - radLat2;
var deltaLng = toRadians(lng1) - toRadians(lng2);
var dis = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(deltaLat / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(deltaLng / 2), 2)));
return dis * 6378137;
function toRadians(d) { return d * Math.PI / 180;}
}
function fill_zero_prefix(num) {
return num < 10 ? "0" + num : num
}
//****************************************************************************************
//****************************************************************************************
Page({
data: {
clock: '',
isLocation:false,
latitude: 0,
longitude: 0,
markers: [],
covers: [],
meters: 0.00,
time: "0:00:00"
},
//****************************
onLoad:function(options){
// 页面初始化 options为页面跳转所带来的参数
this.getLocation()
console.log("onLoad")