| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- // pages/mycut/mycut.js
- var app = getApp();
- var wxh = require('../../utils/wxh.js');
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- url: app.globalData.urlImages,
- product:[],
- timeer:'',
- countDownDay:"00",
- countDownHour:"00",
- countDownMinute:"00",
- countDownSecond:"00"
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- app.setBarColor();
- var that = this;
- var timeStamp = "1912245455"
- wxh.time2(timeStamp, that);
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.getUserBargainAll();
- },
- getUserBargainAll:function(){
- var that = this;
- wx.request({
- url: app.globalData.url + '/routine/auth_api/get_user_bargain_all?uid=' + app.globalData.uid,
- method: 'GET',
- success: function (res) {
- console.log(res);
- if (res.data.code == 200){
- that.setData({
- product:res.data.data
- })
- that.setTime();
- }else{
- wx.showToast({
- title: res.data.msg,
- icon: 'none',
- duration: 2000
- })
- }
- }
- })
- },
- timeFormat(param) {//小于10的格式化函数
- return param < 10 ? '0' + param : param;
- },
- setTime: function () {//到期时间戳
- var that = this;
- var newTime = new Date().getTime() / 1000;
- var endTimeList = that.data.product;
- var countDownArr = [];
- for (var i in endTimeList) {
- var endTime = endTimeList[i].stop_time;
- var obj = [];
- if (endTime - newTime > 0) {
- var time = endTime - newTime;
- var day = parseInt(time / (60 * 60 * 24));
- var hou = parseInt(time % (60 * 60 * 24) / 3600);
- var min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
- var sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
- // hou = parseInt(hou) + parseInt(day * 24);
- obj = {
- day: that.timeFormat(day),
- hou: that.timeFormat(hou),
- min: that.timeFormat(min),
- sec: that.timeFormat(sec)
- }
- endTimeList[i].time = obj;
- that.setData({
- product: endTimeList
- })
- } else {
- obj = {
- day: '00',
- hou: '00',
- min: '00',
- sec: '00'
- }
- endTimeList[i].time = obj;
- if (endTimeList[i].status == 1) {
- that.setBargainStatusError(endTimeList, endTimeList[i].id);
- }
- }
- }
- // console.log(that.data.product);
- var timeer = setTimeout(that.setTime, 1000);
- that.setData({
- timeer: timeer
- })
- },
- goCut:function(e){
- var bargainId = e.target.dataset.id;
- wx.navigateTo({
- url: '/pages/cut-one/cut-one?id=' + bargainId,
- })
- },
- goCutList:function(){
- wx.navigateTo({
- url: '/pages/cut-list/cut-list'
- })
- },
- setBargainStatusError: function (endTimeList,bargainUserTableId){
- var that = this;
- wx.request({
- url: app.globalData.url + '/routine/auth_api/set_user_bargain_status?uid=' + app.globalData.uid,
- method: 'GET',
- data:{
- bargainUserTableId: bargainUserTableId
- },
- success: function (res) {
- if (res.data.code == 200) {
- endTimeList.forEach(function (value, index, endTimeList){
- if (endTimeList[index].id == bargainUserTableId){
- endTimeList[index].status = 2
- }
- })
- that.setData({
- product: endTimeList
- })
- } else {
-
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
- }
- })
|