Commit 0adf31d4 by 谢中龙

修改字段

parent 55bca836
// component/adDialog/adDialog.js
var app = getApp()
const wxService = require('../../utils/wxService')
const utils = require('../../utils/util')
const envInfo = require('../../config/index').envInfo
const utilLink = require('../../utils/currentLinkRouter')
Component({
/**
* 组件的属性列表
*/
properties: {
showDialog : {
type:Boolean,
value: false
},
imageUrl : {
type : String,
default : ''
}
},
observers:{
},
/**
* 组件的初始数据
*/
data: {
},
lifetimes:{
attached(){
// console.log(this.data.pageInfo)
},
created(){
}
},
/**
* 组件的方法列表
*/
methods: {
//关闭
onTapClose(){
this.setData({
showDialog :false
});
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<!--component/adDialog/adDialog.wxml-->
<view class="ad-modal-bg" wx:if="{{showDialog}}">
<view class="ad-modal-body">
<view class="show-img">
<image mode="widthFix" src="{{imageUrl}}"></image>
</view>
<view class="close-dia">
<image src="/assets/imgs/close.png" mode="aspectFit" bindtap="onTapClose"></image>
</view>
</view>
</view>
/* component/adDialog/adDialog.wxss */
.ad-modal-bg{
position: fixed;
z-index: 9999;
width: 100vw;
height: 100vh;
background: rgba(0, 0, 0, 0.5);
left: 0;
top: 0;
display: flex;
justify-content: center;
align-items: center;
}
.ad-modal-bg .ad-modal-body{
width: 70vw;
height: auto;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.ad-modal-bg .ad-modal-body .show-img{
width: 100%;
height: auto;
}
.ad-modal-bg .ad-modal-body .show-img image{
width: 100%;
height: auto;
}
.ad-modal-bg .ad-modal-body .close-dia{
width: 100%;
height: auto;
padding-top: 10rpx;
display: flex;
align-items: center;
justify-content: center;
}
.ad-modal-bg .ad-modal-body .close-dia image{
width: 80rpx;
height: 80rpx;
}
.ad-modal-bg .ad-modal-body .close-dia image:active{
opacity: 0.7;
}
\ No newline at end of file
// pages/userCenter.js
const wxService = require('../../../../utils/wxService')
const util = require('../../../../utils/util')
wxService.page({
/**
......@@ -8,6 +10,9 @@ wxService.page({
data: {
query: '',
integralCouponList: [], // 积分兑换优惠券列表
showDialog : false,
dialogPicture : '',
},
/**
......@@ -26,10 +31,20 @@ wxService.page({
wxService.post(`/coupon/couponCenterActivity/buyer/getValidList`).then(res => {
if (res) {
const { result, data } = res.data
let { result, data } = res.data
if (result == 0) {
wx.hideLoading()
this.data.integralCouponList = data ? data : [];
wx.hideLoading();
data = data ? data : [];
data.forEach(item => {
//判断活动开始时间是不是已经开始了
item.isStart = true;
//判断是不是老活动
if(item.couponList){
item.isStart = util.compareCurrentDate(item.startTime);
}
});
this.data.integralCouponList = data;
this.setData({
integralCouponList: this.data.integralCouponList
});
......@@ -52,14 +67,43 @@ wxService.page({
wx.showLoading({
title: '领取中..',
});
let isStart = e.currentTarget.dataset.start;
const { id } = e.currentTarget.dataset;
let item = e.currentTarget.dataset.item;
//先判断是不是老的活动
if(!item.couponList){
this.getCoupon(id,item);
return ;
}
if(isStart){
this.getCoupon(id,item);
}
//预约
else{
this.orderCouponActivity(id,item);
}
},
//立即领取
getCoupon(id,item){
wxService.post(`/coupon/couponCenterActivity/buyer/coupon/draw?id=${id}`).then(res => {
wx.hideLoading();
if(res){
if(res.data.result == 0){
wx.showToast({
title: '领取成功',
});
//判断是不是老活动
if(item.couponList){
this.data.showDialog = true;
this.data.dialogPicture = item.dialogPicture;
this.setData({
showDialog : this.data.showDialog,
dialogPicture : this.data.dialogPicture
});
}
else{
wx.showToast({
title: '领取成功!',
});
}
}
else{
wx.showToast({
......@@ -70,6 +114,11 @@ wxService.page({
}
});
},
//立即预约
orderCouponActivity(id){
},
//跳转到详情
goCouponDetail(e) {
const { id } = e.currentTarget.dataset
......
......@@ -4,10 +4,8 @@
"enablePullDownRefresh": true,
"usingComponents": {
"no-more": "/component/noMore/noMore",
"exchange-coupon-modal": "/component/exchange-coupon-modal/exchange-coupon-modal",
"dialog-stock-empty": "/component/dialogStockEmpty/dialogStockEmpty",
"dialog-user-limit": "/component/dialogUserLimit/dialogUserLimit",
"go-home": "/component/goHome/goHome",
"go-guid": "/component/goGuid/goGuid"
"go-guid": "/component/goGuid/goGuid",
"image-dialog": "/component/imageDialog/imageDialog"
}
}
\ No newline at end of file
......@@ -17,6 +17,7 @@
<image wx:if="{{item.listPicture}}" src='{{item.listPicture}}' mode="aspectFit"/>
<image wx:else src='https://img3.bigaka.com/prd/3001/202003/20200331/3001649f2f08-3b4e-4b5b-97c1-30cdf646651c.png' />
</view>
<!-- <view class='ac-date'>{{item.startTime}}至{{item.endTime}}</view> -->
<view class='coupon-info'>
<view class='coupon-name fs-28'>{{item.activityName}}</view>
<view class='coupon-desc text-align-left fs-24'>查看详情</view>
......@@ -29,8 +30,9 @@
class="clear-btn positionAbs"></button>
<view class='coupon-btn-click theme-color'
data-id="{{item.acvivityId}}"
bindtap='exchange'>立即领取</view>
<!-- <view class='ac-date'>{{item.startTime}}至{{item.endTime}}</view> -->
data-start="{{item.isStart}}"
data-item="{{item}}"
bindtap='exchange'>{{item.isStart ? '立即领取': '立即预约'}}</view>
</view>
</view>
</view>
......@@ -48,7 +50,8 @@
<go-guid />
<go-home/>
<floatNav bind:getAuth="_getUserInfo" bind:updatePage="updatePage"/>
<!-- image-dialog -->
<image-dialog showDialog="{{showDialog}}" imageUrl="{{dialogPicture}}"></image-dialog>
// subPackage/page/pages/couponCenterInfo/couponCenterInfo.js
const wxService = require('../../../../utils/wxService')
const util = require('../../../../utils/util')
wxService.page({
/**
......@@ -7,7 +8,8 @@ wxService.page({
*/
data: {
activityId : null,
activityInfo : {}
activityInfo : {},
showDialog : false,
},
/**
......@@ -36,6 +38,14 @@ wxService.page({
obj.desc = arr.filter(item => item.type == 2);
obj.hasExpDate = arr.filter(item => item.type == 1).length > 0 ;
this.data.activityInfo = obj;
//判断老活动
if(this.data.activityInfo.couponList){
this.data.activityInfo.isStart = util.compareCurrentDate(obj.startTime);
}
else{
this.data.activityInfo.isStart = true;
}
this.setData({
activityInfo: this.data.activityInfo
});
......@@ -50,13 +60,41 @@ wxService.page({
title: '领取中..',
});
let id = this.data.activityId;
let isStart = this.data.activityInfo.isStart;
//判断是不是老活动
if(!this.data.activityInfo.couponList){
this.getCoupon(id);
return ;
}
if(isStart){
this.getCoupon(id);
}
else{
//立即预约
this.orderCouponNow(id);
}
},
//立即;领取
getCoupon(id){
wxService.post(`/coupon/couponCenterActivity/buyer/coupon/draw?id=${id}`).then(res => {
wx.hideLoading();
if (res) {
if (res.data.result == 0) {
wx.showToast({
title: '领取成功',
});
//判断是不是老数据
if(!this.data.activityInfo.couponList){
wx.showToast({
title: '领取成功',
});
}
else{
this.data.showDialog = true;
this.setData({
showDialog : true
});
}
}
else {
wx.showToast({
......@@ -67,6 +105,10 @@ wxService.page({
}
});
},
//立即预约
orderCouponNow(id){
},
/**
* 用户点击右上角分享
......
{
"navigationBarTitleText": "优惠券信息",
"usingComponents": {}
"usingComponents": {
"image-dialog": "/component/imageDialog/imageDialog"
}
}
\ No newline at end of file
<!--subPackage/page/pages/couponCenterInfo/couponCenterInfo.wxml-->
<view class="coupon-info-con">
<view class="coupon-info-bg" style="background-image:url('https://img3.bigaka.com/prd/3001/202003/20200331/3001df30305c-f4fe-4c35-bd73-5d87d4882f7a.png')">
<!-- 老数据活动 -->
<view class="coupon-info-bg" wx:if="{{!activityInfo.couponList}}" style="background-image:url('https://img3.bigaka.com/prd/3001/202003/20200331/3001df30305c-f4fe-4c35-bd73-5d87d4882f7a.png')">
<view class="lf-coupon-Bg">
<image wx:if="{{activityInfo.listPicture}}" mode="aspectFit" src="{{activityInfo.listPicture}}"></image>
<image wx:else src='https://img3.bigaka.com/prd/3001/202003/20200331/3001649f2f08-3b4e-4b5b-97c1-30cdf646651c.png' />
......@@ -13,6 +14,12 @@
</view>
</view>
</view>
<!-- 修改为新的布局 -->
<view class="coupon-package" wx:if="{{activityInfo.couponList}}">
<image src="{{activityInfo.detailPicture}}" mode="widthFix"></image>
</view>
<!-- 活动说明 -->
<view class='integral-detail' wx:if="{{activityInfo.hasExpDate}}">
<view class='integral-list'>
......@@ -32,8 +39,10 @@
<button wx:if="{{!currentHasUserInfo}}"
bindgetuserinfo="_getUserInfo"
open-type='getUserInfo'
class="clear-btn positionAbs">立即领取</button>
<view wx:else class="view-btn" bindtap="onTapGetCoupon">立即领取</view>
class="clear-btn positionAbs">{{activityInfo.isStart ? '立即领取' : '立即预约'}}</button>
<view wx:else class="view-btn" bindtap="onTapGetCoupon">{{activityInfo.isStart ? '立即领取' : '立即预约'}}</view>
</view>
</view>
<!-- image-dialog -->
<image-dialog showDialog="{{showDialog}}" imageUrl="{{activityInfo.dialogPicture}}"></image-dialog>
\ No newline at end of file
......@@ -33,6 +33,16 @@ view{
padding: 15rpx;
}
.coupon-package{
width: 100%;
height: auto;
}
.coupon-package image{
width: 100%;
}
.coupon-info-bg .lf-coupon-Bg image{
width: 100%;
height: 100%;
......
......@@ -190,9 +190,20 @@ function getDateDiff(d){
result.days = parseInt(dayC);
result.hours = parseInt(hourC);
result.minutes = parseInt(minC);
result.second = parseInt(result.minutes*60);
return result;
}
//判断时间与当前时间比
function compareCurrentDate(d){
var now = new Date().getTime();
var diffValue = now - Date.parse(d.replace(/-/g, '/').replace(/:/g, ":"));
if (diffValue < 0) {
return false
}
return true;
}
function getCurrentRouter() {
var pages = getCurrentPages() // 获取加载的页面
......@@ -467,6 +478,7 @@ module.exports = {
moment,
parseUrl,
getDateDiff,
compareCurrentDate,
_,
isVideo,
getFirstImgUrl,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment