ソースを参照

[券包详情][修改]:[券包详情倒计时]

tags/富茂链客4.1.0
meo 6年前
コミット
65441d8cbe
3個のファイルの変更109行の追加118行の削除
  1. +100
    -115
      pages/coupon/detail/index.js
  2. +8
    -2
      pages/coupon/detail/index.wxml
  3. +1
    -1
      utils/util.js

+ 100
- 115
pages/coupon/detail/index.js ファイルの表示

@@ -27,6 +27,9 @@ Page({
couponChannelId: null,
orderId: "",
hour: null,
day: null,
month: null,
year: null,
minute: "",
tempFilePaths: null,
userInfo: {},
@@ -35,7 +38,7 @@ Page({
id: null,
result: [],
end_time: null,
checked:false,
checked: false,
clock: "已经截止",
questionnaire: {},
questionId: null,
@@ -51,17 +54,18 @@ Page({
zIndex: 11,
display: "none",
showbutton: false,
cardData:null,
showCardOffer:false,
isSamePeople:true,
statusText:'',
isReceived:false,
receivedDisabled:false,
clock02: "00",
day02: "00",
hour02: "00",
min02: "00",
sec02: "00",
cardData: null,
showCardOffer: false,
isSamePeople: true,
statusText: '',
isReceived: false,
receivedDisabled: false,
clock: "00",
day: "00",
hour: "00",
min: "00",
sec: "00",
countdown: ""
},
phone: function (e) {
let that = this;
@@ -100,18 +104,18 @@ Page({
.then(res => {
console.log(res)
that.getQueryCardStatus()
if (that.data.cardData.cuserId != res.data.id){
console.log(2222,6666)
if (that.data.cardData.cuserId != res.data.id) {
console.log(2222, 6666)
that.setData({
isSamePeople:false
isSamePeople: false
})
}
})
},
//获取卡转赠状态
getQueryCardStatus(){
getQueryCardStatus() {
let that = this;
let param={
let param = {
id: this.data.cardData.couponOrderId,
cUserId: this.data.cardData.cuserId,
updateDate: util.formatTime(Number(that.data.cardData.updateDate), "yyyy-MM-dd hh:mm:ss")
@@ -121,7 +125,7 @@ Page({
data: param
})
.then(res => {
console.log(res,333333333333)
console.log(res, 333333333333)
})
.catch(err => {
that.setData({
@@ -129,33 +133,32 @@ Page({
statusText: err.message
})
})
},
receiveCard(){
let that=this;
receiveCard() {
let that = this;
let param = {
id: this.data.cardData.couponOrderId,
cUserId: this.data.cardData.cuserId,
updateDate: util.formatTime(Number(this.data.cardData.updateDate), "yyyy-MM-dd hh:mm:ss")
}
this.setData({
receivedDisabled:true
receivedDisabled: true
})
Http.post({
url: config.api.cardAccept,
data: param
})
.then(res => {
wx.showToast({
title: '领取成功!',
icon: 'none',
duration: 2000,
mask: false
});
wx.reLaunch({
url: '/pages/complete/index?couponOrderId=' + this.data.cardData.couponOrderId,
.then(res => {
wx.showToast({
title: '领取成功!',
icon: 'none',
duration: 2000,
mask: false
});
wx.reLaunch({
url: '/pages/complete/index?couponOrderId=' + this.data.cardData.couponOrderId,
})
})
})
.catch(err => {
wx.showToast({
title: err.message,
@@ -168,9 +171,9 @@ Page({
})
})
},
closeAlert(){
closeAlert() {
this.setData({
showCardOffer:false
showCardOffer: false
})
},
goback: function () {
@@ -193,19 +196,19 @@ Page({
} else {
var answserIs = that.data.anwserId.join(",");
}
}
}
else if (e.currentTarget.dataset.flags == 'single') {
var answserIs = e.detail.value;
}
console.log(answserIs)
console.log(e.currentTarget.dataset.questionid)
Http.post({
url: config.api.answerQuestion,
data: {
answer: answserIs,
questionId: e.currentTarget.dataset.questionid
}
})
url: config.api.answerQuestion,
data: {
answer: answserIs,
questionId: e.currentTarget.dataset.questionid
}
})
.then(res => {
that.closeQuestion();
})
@@ -250,11 +253,11 @@ Page({
showbutton: true
})
Http.get({
url: config.api.getQuestion,
data: {
couponType: JSON.stringify(that.data.data.type)
}
})
url: config.api.getQuestion,
data: {
couponType: JSON.stringify(that.data.data.type)
}
})
.then(res => {
console.log(res);
if (res.data == undefined) {
@@ -286,14 +289,14 @@ Page({
});
})
},

countdown(end_time) {
setIntervalTime(end_time) {
let that = this;
var EndTime = end_time;
var NowTime = new Date().getTime();
var total_micro_second = EndTime - NowTime || [];
// 渲染倒计时时钟
let obj = that.dateformat(total_micro_second);
console.log(obj)
if (total_micro_second > 0) {
that.setData({
clock: obj,
@@ -311,39 +314,14 @@ Page({
sec: "00",
})
}
setTimeout(function () {
total_micro_second -= 1000;
that.countdown(end_time);
}, 1000)
total_micro_second -= 1000;
console.log(obj);
},
countdown02(end_time) {
countdown: function (end_time) {
let that = this;
var EndTime = end_time;
var NowTime = new Date().getTime();
var total_micro_second = EndTime - NowTime || [];
// 渲染倒计时时钟
let obj = that.dateformat(total_micro_second);
if (total_micro_second > 0) {
that.setData({
clock02: obj,
day02: obj.a1,
hour02: obj.b1,
min02: obj.c1,
sec02: obj.d1,
})
} else {
that.setData({
clock02: "00",
day02: "0",
hour02: "00",
min02: "00",
sec02: "00",
showbutton1: false
})
}
setTimeout(function () {
total_micro_second -= 1000;
that.countdown02(end_time);
that.setIntervalTime(end_time);
that.data.setInterval = setInterval(function () {
that.setIntervalTime(end_time);
}, 1000)
},
// 时间格式化输出,如11:03 25:19 每1s都会调用一次
@@ -378,10 +356,10 @@ Page({
/**
* 转赠判断
*/
if (options.cuserId){
if (options.cuserId) {
this.setData({
showCardOffer:true,
cardData:options
showCardOffer: true,
cardData: options
})
this.getUserInfo()
}
@@ -417,12 +395,12 @@ Page({
}
var EndTime = res.data.validStartDate;
var NowTime = new Date().getTime();
if (EndTime - NowTime>0){
if (EndTime - NowTime > 0) {
that.setData({
showbutton1:true
showbutton1: true
})
}
that.countdown02(res.data.validStartDate)
// that.countdown02(res.data.validStartDate)
if (res.data.endTime) {
that.countdown(res.data.endTime);
//当前时间与优惠券下架时间做计算
@@ -480,7 +458,7 @@ Page({
let that = this;
that.orderFunc("discount");
that.setData({
showbutton1:true
showbutton1: true
})
},
/**
@@ -490,14 +468,14 @@ Page({
let that = this;
// 支付成功
Http.post({
url: config.api.payOrderUpdate,
data: {
payOrderId: payOrderId,
orderId: orderId,
status: status,
reason: reason
}
})
url: config.api.payOrderUpdate,
data: {
payOrderId: payOrderId,
orderId: orderId,
status: status,
reason: reason
}
})
.then(res => {
wx.hideLoading()
// 有价券
@@ -524,9 +502,6 @@ Page({
}
})
},
/**
*
*/
checkPhoneStatus: function () {
let that = this;
Http.post({
@@ -534,7 +509,7 @@ Page({
data: {}
})
.then(res => {
console.log(666,'授权成功!')
console.log(666, '授权成功!')
that.receiveCard()
})
.catch(err => {
@@ -569,9 +544,9 @@ Page({
console.log(discount)
var that = this;
Http.post({
url: config.api.checkPhoneStatus,
data: {}
})
url: config.api.checkPhoneStatus,
data: {}
})
.then(res => {
if (discount == 'discount') {
var data = {
@@ -579,13 +554,13 @@ Page({
couponId: "" + that.data.couponId,
press: true
}
} else if (discount == 'discount1'){
} else if (discount == 'discount1') {
var data = {
couponChannelId: "" + that.data.couponChannelId,
couponId: "" + that.data.couponId,
press: false
}
}else if (that.data.couponChannelId == null) {
} else if (that.data.couponChannelId == null) {
var data = {
couponId: "" + that.data.couponId
};
@@ -607,7 +582,7 @@ Page({
console.log(err);
that.setData({
showbutton: false,
showbutton1:false
showbutton1: false
})
if (err.code == 2011) {
wx.showToast({
@@ -703,11 +678,11 @@ Page({
* 支付订单创建
*/
Http.post({
url: config.api.payOrderCreate,
data: {
orderId: orderId
}
})
url: config.api.payOrderCreate,
data: {
orderId: orderId
}
})
.then(res => {
var payOrderId = "" + res.data.payOrderId;
wx.hideLoading();
@@ -737,7 +712,7 @@ Page({
key: 'couponNum2',
data: "couponNum2"
})
} else if(that.data.data.type!=5){
} else if (that.data.data.type != 5) {
wx.setStorage({
key: 'couponNum',
data: "couponNum"
@@ -755,7 +730,7 @@ Page({
})
return;
},
complete: res => {}
complete: res => { }
});
/// End payment --------
})
@@ -776,7 +751,7 @@ Page({
key: 'couponNum2',
data: "couponNum2"
})
} else if (that.data.data.type != "5"){
} else if (that.data.data.type != "5") {
wx.setStorage({
key: 'couponNum',
data: "couponNum"
@@ -785,7 +760,7 @@ Page({
}
}
} else {
if(res){
if (res) {
wx.navigateTo({
url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${res.data.id}`,
})
@@ -805,10 +780,10 @@ Page({
title: that.data.data.title,
path: `/pages/index/index?couponChannelId=${that.data.couponChannelId}`,
success: function (res) {
if (res.errMsg == 'shareAppMessage:ok') {}
if (res.errMsg == 'shareAppMessage:ok') { }
},
fail: function (error) {
if (res.errMsg == 'shareAppMessage:fail cancel') {} else if (res.errMsg == 'shareAppMessage:fail') {}
if (res.errMsg == 'shareAppMessage:fail cancel') { } else if (res.errMsg == 'shareAppMessage:fail') { }
}
};
// 来自页面内的按钮的转发
@@ -819,4 +794,14 @@ Page({
// 返回shareObj
return shareObj;
},
onUnload: function () {
let that = this;
console.log("onUnload")
clearInterval(that.data.setInterval);
},
onHide: function () {
let that = this;
console.log("onHide");
clearInterval(that.data.setInterval);
}
});

+ 8
- 2
pages/coupon/detail/index.wxml ファイルの表示

@@ -14,15 +14,21 @@
<view class='distance' wx:if="{{data.targetAd==2&&data.endTime!=undefined}}">
<view style='text-align:center;display:inline-block;'>
<image class='clock' src='{{clockUrl}}' mode='widthFix'></image>
<text class="qiang" wx:if="{{data.activityStatus!=0}}">距结束还剩 :</text>
<text class="qiang" wx:if="{{data.activityStatus==0}}">距开始还有 :</text>
<text class="qiang" wx:if="{{data.activityStatus!=0}}">距结束 :</text>
<text class="qiang" wx:if="{{data.activityStatus==0}}">距开始 :</text>
</view>
<view wx:if="{{clock=='已经截止'||data.remainInventory==0||data.status==1}}" class='times'>
<view style="display:inline-block;" wx:if="{{day!=0}}">
<text>{{day}}</text>天:
</view>
<text>{{hour}}</text>:
<text>{{min}}</text>:
<text>{{sec}}</text>
</view>
<view wx:if="{{clock!='已经截止'&&data.remainInventory!=0}}" class='times'>
<view style="display:inline-block;" wx:if="{{day!=0}}">
<text>{{day}}</text>天:
</view>
<text>{{hour}}</text>:
<text>{{min}}</text>:
<text>{{sec}}</text>


+ 1
- 1
utils/util.js ファイルの表示

@@ -95,7 +95,7 @@ function timechuo(startTime) {
if (day && !year && !month){
return (day + '天' + hour + "小时" + minute + "分钟")
} else if (month && !year){
return (month+'月'+day + '天' + hour + "小时" + minute + "分钟")
return (month +'月'+day + '天' + hour + "小时" + minute + "分钟")
} else if (year) {
return (year + '年' + month+'个月'+ day + '天' + hour + "小时" + minute + "分钟")
}else{


読み込み中…
キャンセル
保存