最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序?qū)崿F(xiàn)簽到功能

 更新時(shí)間:2018年10月31日 11:55:46   作者:陣雨丶  
這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)簽到功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了微信小程序?qū)崿F(xiàn)簽到功能的具體代碼,供大家參考,具體內(nèi)容如下

效果圖:

今天是16號(hào),所以顯示已簽到,渲染頁(yè)面時(shí)請(qǐng)求后臺(tái)傳的參數(shù)為這月簽到的日期

如:["16", "14"]

點(diǎn)擊簽到執(zhí)行

calendarSign

sign.wxml

<!--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">
 
 <!--填補(bǔ)空格-->
 <view wx:for="{{nbsp}}">\n</view>
 
 <!--循環(huán)日期-->
 <!-- 當(dāng)天以前 -->
 <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>
 <!-- 當(dāng)天 -->
 <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' src='https://jpadmin.99dudesign.com/public/img/source/btn_icon_wodekaoqin1.png'></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}}">今天已經(jīng)簽過(guò)了~</view>
 <view class='qdcontent' wx:else>簽到成功,獲得{{integral}}積分,您已連續(xù)簽到{{rule}}天!</view>
 <view class='queding' bindtap='quxiaoQd'>確定</view>
</view>

sign.js

var app = getApp();
var calendarSignData;
var date;
var calendarSignDay;
var is_qd;
Page({
 
 /**
 * 頁(yè)面的初始數(shù)據(jù)
 */
 data: {
 qdView: false,
 calendarSignData: "",
 calendarSignDay: "",
 is_qd: false,
 },
 quxiaoQd: function (e) {
 var that = this;
 that.setData({
 qdView: false,
 is_qd: true
 })
 },
 //事件處理函數(shù)
 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.request({
 url: getApp().data.host + '后臺(tái)的接口',
 method: "POST",
 data: {
 "user_id": wx.getStorageSync('user_id'),
 "sign_num": today
 },
 header: {
 'content-type': 'application/x-www-form-urlencoded' //通過(guò)post傳值,所以要加header
 },
 success: function (res) {
 that.setData({
  rule: res.data.rule,
  integral: res.data.integral,
 })
 }
 })
 
 wx.setStorageSync("calendarSignData", calendarSignData);
 wx.setStorageSync("calendarSignDay", calendarSignDay);
 
 this.setData({
 calendarSignData: calendarSignData,
 calendarSignDay: calendarSignDay
 })
 },
 /**
 * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面加載
 */
 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) {
 // 計(jì)算是否是閏年,如果是二月份則是29天
 if ((year - 2000) % 4 == 0) {
 monthDaySize = 29;
 } else {
 monthDaySize = 28;
 }
 };
 // 傳ajax
 wx.request({
 url: getApp().data.host + 'index.php?g=api&m=output&a=sign_list',
 method: "POST",
 data: {
 "user_id": wx.getStorageSync('user_id')
 },
 header: {
 'content-type': 'application/x-www-form-urlencoded'
 },
 success: function (res) {
 // 判斷是否簽到過(guò) 
 if (res.data == null) {
  calendarSignData = new Array(monthDaySize)
  wx.setStorageSync("calendarSignData", calendarSignData);
 } else {
  var is_qd;
  for (var i in res.data) {
  parseInt(res.data[i])
  calendarSignData = new Array(monthDaySize)
  calendarSignData[parseInt(res.data[i])] = parseInt(res.data[i])
  wx.setStorageSync("calendarSignData", calendarSignData);
  console.log(date)
  console.log(parseInt(res.data[i]))
 
  if (parseInt(res.data[i]) == date) {
  console.log(1)
  wx.setStorageSync("calendarSignDay", 1);
  is_qd = true
  } else {
  wx.setStorageSync("calendarSignDay", 0);
  
  }
  }
 }
 console.log(is_qd)
 calendarSignData = wx.getStorageSync("calendarSignData")
 calendarSignDay = wx.getStorageSync("calendarSignDay")
 console.log(calendarSignData);
 console.log(calendarSignDay)
 that.setData({
  is_qd: is_qd,
  year: year,
  month: month,
  nbsp: nbsp,
  monthDaySize: monthDaySize,
  date: date,
  calendarSignData: calendarSignData,
  calendarSignDay: calendarSignDay
 })
 }
 })
 
 
 },
 
 /**
 * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面初次渲染完成
 */
 onReady: function () {
 
 },
 
 /**
 * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面顯示
 */
 onShow: function () {
 
 },
 
 /**
 * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面隱藏
 */
 onHide: function () {
 
 },
 
 /**
 * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面卸載
 */
 onUnload: function () {
 wx.removeStorageSync("calendarSignData")
 wx.removeStorageSync("calendarSignDay")
 },
 
 /**
 * 頁(yè)面相關(guān)事件處理函數(shù)--監(jiān)聽(tīng)用戶(hù)下拉動(dòng)作
 */
 onPullDownRefresh: function () {
 
 },
 
 /**
 * 頁(yè)面上拉觸底事件的處理函數(shù)
 */
 onReachBottom: function () {
 
 },
 
 /**
 * 用戶(hù)點(diǎn)擊右上角分享
 */
 onShareAppMessage: function () {
 
 }
})

sign.wxss

page {
 background-color: #2ccecb;
}
 
.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;
}

為大家推薦現(xiàn)在關(guān)注度比較高的微信小程序教程一篇:《微信小程序開(kāi)發(fā)教程》小編為大家精心整理的,希望喜歡。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 關(guān)于HTTP傳輸中g(shù)zip壓縮的秘密探索分析

    關(guān)于HTTP傳輸中g(shù)zip壓縮的秘密探索分析

    Gzip是一種流行的文件壓縮算法,現(xiàn)在的應(yīng)用十分廣泛,尤其是在Linux平臺(tái)。下面這篇文章主要給大家介紹了關(guān)于HTTP傳輸中g(shù)zip壓縮的相關(guān)資料,文中介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。
    2018-01-01
  • 《JavaScript DOM 編程藝術(shù)》讀書(shū)筆記之DOM基礎(chǔ)

    《JavaScript DOM 編程藝術(shù)》讀書(shū)筆記之DOM基礎(chǔ)

    這篇文章主要介紹了《JavaScript DOM 編程藝術(shù)》讀書(shū)筆記之DOM基礎(chǔ),需要的朋友可以參考下
    2015-01-01
  • 淺析Javascript中bind()方法的使用與實(shí)現(xiàn)

    淺析Javascript中bind()方法的使用與實(shí)現(xiàn)

    下面小編就為大家?guī)?lái)一篇淺析Javascript中bind()方法的使用與實(shí)現(xiàn)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,一起跟隨小編過(guò)來(lái)看看吧
    2016-04-04
  • layui在form表單頁(yè)面通過(guò)Validform加入簡(jiǎn)單驗(yàn)證的方法

    layui在form表單頁(yè)面通過(guò)Validform加入簡(jiǎn)單驗(yàn)證的方法

    今天小編就為大家分享一篇layui在form表單頁(yè)面通過(guò)Validform加入簡(jiǎn)單驗(yàn)證的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2019-09-09
  • JavaScript一文帶你玩轉(zhuǎn)web表單網(wǎng)頁(yè)

    JavaScript一文帶你玩轉(zhuǎn)web表單網(wǎng)頁(yè)

    表單通常用來(lái)收集網(wǎng)頁(yè)訪問(wèn)者信息,常見(jiàn)的表單比如搜索引擎的搜索框、各網(wǎng)頁(yè)應(yīng)用的注冊(cè)或者登陸界面等,通讀本篇對(duì)大家的學(xué)習(xí)或工作具有一定的價(jià)值,需要的朋友可以參考下
    2021-10-10
  • 在微信小程序中使用iconfont的最新圖文教程

    在微信小程序中使用iconfont的最新圖文教程

    由于微信小程序線(xiàn)上的資源限制了各種接口安全域名,所以在小程序里如果想使用iconfont字體圖標(biāo)就會(huì)稍有不同,下面這篇文章主要給大家介紹了關(guān)于在微信小程序中使用iconfont的相關(guān)資料,需要的朋友可以參考下
    2022-08-08
  • JavaScript SHA1加密算法實(shí)現(xiàn)詳細(xì)代碼

    JavaScript SHA1加密算法實(shí)現(xiàn)詳細(xì)代碼

    這篇文章主要為大家詳細(xì)介紹了JavaScript SHA1加密算法實(shí)現(xiàn)代碼,具有一定的參考價(jià)值,感興趣的朋友可以參考一下
    2016-10-10
  • Javascript的表單與驗(yàn)證-非空驗(yàn)證

    Javascript的表單與驗(yàn)證-非空驗(yàn)證

    JavaScript 可用來(lái)在數(shù)據(jù)被送往服務(wù)器前對(duì) HTML 表單中的這些輸入數(shù)據(jù)進(jìn)行驗(yàn)證。本文給大家介紹javascript的表單與驗(yàn)證-非空驗(yàn)證,對(duì)javascript表單驗(yàn)證相關(guān)知識(shí)感興趣的朋友一起學(xué)習(xí)吧
    2016-03-03
  • javascript 實(shí)現(xiàn)map集合

    javascript 實(shí)現(xiàn)map集合

    本文給大家分享的是個(gè)人項(xiàng)目中需要的一個(gè)小功能,當(dāng)時(shí)經(jīng)過(guò)一番度娘才實(shí)現(xiàn),現(xiàn)在從項(xiàng)目中拿出來(lái),分享給大家,需要的小伙伴快來(lái)參考下吧。
    2015-04-04
  • js綁定事件和解綁事件

    js綁定事件和解綁事件

    本篇文章主要介紹了js綁定事件和解綁事件的相關(guān)知識(shí)。具有很好的參考價(jià)值。下面跟著小編一起來(lái)看下吧
    2017-04-04

最新評(píng)論

苍南县| 扎囊县| 德阳市| 利津县| 盐城市| 焦作市| 庆城县| 静海县| 凤山市| 东源县| 白水县| 梨树县| 天长市| 定安县| 吴忠市| 东辽县| 上饶县| 宜宾市| 炉霍县| 尼玛县| 泰宁县| 云龙县| 泽库县| 镶黄旗| 延庆县| 寻乌县| 双辽市| 靖远县| 新营市| 江达县| 安阳市| 诸城市| 永修县| 河间市| 香格里拉县| 临邑县| 遵义县| 岑巩县| 郧西县| 故城县| 河源市|