Bladeren bron

upload

newCard
HolyKnightIX 2 jaren geleden
bovenliggende
commit
7af73df804
2 gewijzigde bestanden met toevoegingen van 41 en 10 verwijderingen
  1. +39
    -8
      pages/specialcourtesy/specialcourtesy.js
  2. +2
    -2
      pages/specialcourtesy/specialcourtesy.wxml

+ 39
- 8
pages/specialcourtesy/specialcourtesy.js Bestand weergeven

@@ -17,7 +17,7 @@ Page({
goHomeUrl: "",
showCode: true,
showTimeLine: true,
expiredSeconds: 30
expiredSeconds: 0
},
phone: function (e) {
console.log(e)
@@ -44,26 +44,36 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {

this.ifPhoneInfo()
let that = this;
that.ifPhoneInfo()
that.setData({
goHomeUrl: app.globalData.goHomeUrl,
})
console.log("渲染开始")
that.getDiscountInfo()
},

refreshCode() {
this.setData({
showCode: true
})
this.getDiscountInfo()
},

getDiscountInfo() {
let that = this;
Http.get({
url: config.api.getDiscountInfo,
data: {}
})
.then(res => {
that.setData({
level: res.data.level ? res.data.level : ''
})
that.qrcode(res.data.id);
that.qrcode(res.data.dynamicId);
that.setData({
memberId: res.data.id
memberId: res.data.id,
expiredSeconds: res.data.expiredSeconds,
})
console.log(res.data.levelMerchantList)
let discountMerchantList = [];
res.data.levelMerchantList.map(file => {
if (file.discount != 100) {
@@ -73,6 +83,27 @@ Page({
that.setData({
discountMerchantList: discountMerchantList,
})
if (that.data.expiredSeconds * 1) {
const timer = setInterval(() => {
const expiredSeconds = that.data.expiredSeconds
if (expiredSeconds) {
that.setData({
expiredSeconds: expiredSeconds - 1,
})
} else {
clearInterval(timer)
that.setData({
showCode: false,
})
}

}, 1000);
}
}).catch(err => {
console.log(err, 'err');
wx.showToast({
title: err.message,
})
})
},

@@ -85,7 +116,7 @@ Page({
/**
* 二维码
*/
qrcode: function (memberId) {
qrcode(memberId) {
let that = this;
var size = that.setCanvasSize();
let url = JSON.stringify({


+ 2
- 2
pages/specialcourtesy/specialcourtesy.wxml Bestand weergeven

@@ -11,7 +11,7 @@
<image src="{{tempFilePath}}" mode="aspectFit" />
</view>

<view wx:else class="negatived">
<view wx:else class="negatived" bindtap="refreshCode">
<view class="canWrap">
<canvas canvas-id="mycanvas2" style="width: 1200rpx; height: 800rpx;" />
</view>
@@ -19,7 +19,7 @@
<image src="../../assets/images/negatived.png" mode="aspectFit" />
</view>

<view class="coedTiem" wx:if="{{showTimeLine}}">二维码将在
<view class="coedTiem" wx:if="{{showCode}}">二维码将在
<text style="color:red">{{expiredSeconds}}s</text>
后失效
</view>


Laden…
Annuleren
Opslaan