Selaa lähdekoodia

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

tags/富茂链客4.1.0
meo 6 vuotta sitten
vanhempi
commit
65441d8cbe
3 muutettua tiedostoa jossa 109 lisäystä ja 118 poistoa
  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 Näytä tiedosto

@@ -27,6 +27,9 @@ Page({
couponChannelId: null, couponChannelId: null,
orderId: "", orderId: "",
hour: null, hour: null,
day: null,
month: null,
year: null,
minute: "", minute: "",
tempFilePaths: null, tempFilePaths: null,
userInfo: {}, userInfo: {},
@@ -35,7 +38,7 @@ Page({
id: null, id: null,
result: [], result: [],
end_time: null, end_time: null,
checked:false,
checked: false,
clock: "已经截止", clock: "已经截止",
questionnaire: {}, questionnaire: {},
questionId: null, questionId: null,
@@ -51,17 +54,18 @@ Page({
zIndex: 11, zIndex: 11,
display: "none", display: "none",
showbutton: false, 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) { phone: function (e) {
let that = this; let that = this;
@@ -100,18 +104,18 @@ Page({
.then(res => { .then(res => {
console.log(res) console.log(res)
that.getQueryCardStatus() 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({ that.setData({
isSamePeople:false
isSamePeople: false
}) })
} }
}) })
}, },
//获取卡转赠状态 //获取卡转赠状态
getQueryCardStatus(){
getQueryCardStatus() {
let that = this; let that = this;
let param={
let param = {
id: this.data.cardData.couponOrderId, id: this.data.cardData.couponOrderId,
cUserId: this.data.cardData.cuserId, cUserId: this.data.cardData.cuserId,
updateDate: util.formatTime(Number(that.data.cardData.updateDate), "yyyy-MM-dd hh:mm:ss") updateDate: util.formatTime(Number(that.data.cardData.updateDate), "yyyy-MM-dd hh:mm:ss")
@@ -121,7 +125,7 @@ Page({
data: param data: param
}) })
.then(res => { .then(res => {
console.log(res,333333333333)
console.log(res, 333333333333)
}) })
.catch(err => { .catch(err => {
that.setData({ that.setData({
@@ -129,33 +133,32 @@ Page({
statusText: err.message statusText: err.message
}) })
}) })
}, },
receiveCard(){
let that=this;
receiveCard() {
let that = this;
let param = { let param = {
id: this.data.cardData.couponOrderId, id: this.data.cardData.couponOrderId,
cUserId: this.data.cardData.cuserId, cUserId: this.data.cardData.cuserId,
updateDate: util.formatTime(Number(this.data.cardData.updateDate), "yyyy-MM-dd hh:mm:ss") updateDate: util.formatTime(Number(this.data.cardData.updateDate), "yyyy-MM-dd hh:mm:ss")
} }
this.setData({ this.setData({
receivedDisabled:true
receivedDisabled: true
}) })
Http.post({ Http.post({
url: config.api.cardAccept, url: config.api.cardAccept,
data: param 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 => { .catch(err => {
wx.showToast({ wx.showToast({
title: err.message, title: err.message,
@@ -168,9 +171,9 @@ Page({
}) })
}) })
}, },
closeAlert(){
closeAlert() {
this.setData({ this.setData({
showCardOffer:false
showCardOffer: false
}) })
}, },
goback: function () { goback: function () {
@@ -193,19 +196,19 @@ Page({
} else { } else {
var answserIs = that.data.anwserId.join(","); var answserIs = that.data.anwserId.join(",");
} }
}
}
else if (e.currentTarget.dataset.flags == 'single') { else if (e.currentTarget.dataset.flags == 'single') {
var answserIs = e.detail.value; var answserIs = e.detail.value;
} }
console.log(answserIs) console.log(answserIs)
console.log(e.currentTarget.dataset.questionid) console.log(e.currentTarget.dataset.questionid)
Http.post({ 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 => { .then(res => {
that.closeQuestion(); that.closeQuestion();
}) })
@@ -250,11 +253,11 @@ Page({
showbutton: true showbutton: true
}) })
Http.get({ 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 => { .then(res => {
console.log(res); console.log(res);
if (res.data == undefined) { if (res.data == undefined) {
@@ -286,14 +289,14 @@ Page({
}); });
}) })
}, },

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

@@ -14,15 +14,21 @@
<view class='distance' wx:if="{{data.targetAd==2&&data.endTime!=undefined}}"> <view class='distance' wx:if="{{data.targetAd==2&&data.endTime!=undefined}}">
<view style='text-align:center;display:inline-block;'> <view style='text-align:center;display:inline-block;'>
<image class='clock' src='{{clockUrl}}' mode='widthFix'></image> <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>
<view wx:if="{{clock=='已经截止'||data.remainInventory==0||data.status==1}}" class='times'> <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>{{hour}}</text>:
<text>{{min}}</text>: <text>{{min}}</text>:
<text>{{sec}}</text> <text>{{sec}}</text>
</view> </view>
<view wx:if="{{clock!='已经截止'&&data.remainInventory!=0}}" class='times'> <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>{{hour}}</text>:
<text>{{min}}</text>: <text>{{min}}</text>:
<text>{{sec}}</text> <text>{{sec}}</text>


+ 1
- 1
utils/util.js Näytä tiedosto

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


Ladataan…
Peruuta
Tallenna