Commit 280cf851 by 高淑倩

add: 集点相关

parent 6068467c
...@@ -31,7 +31,9 @@ ...@@ -31,7 +31,9 @@
"pages/refund/refund", "pages/refund/refund",
"pages/orderDetail/orderDetail", "pages/orderDetail/orderDetail",
"pages/logistics/logistics", "pages/logistics/logistics",
"pages/extendProduct/extendProduct" "pages/extendProduct/extendProduct",
"pages/pointList/pointList",
"pages/pointDetail/pointDetail"
], ],
"subPackages": [ "subPackages": [
{ {
......
const app = getApp()
const wxService = require('../../utils/wxService')
const utils = require('../../utils/util')
const envInfo = require('../../config/index').envInfo
Component({
/**
* 组件的属性列表
*/
properties: {
isAuthorization: Boolean,
isAuthorizationActiveText: {
type: String,
value: ''
},
isAuthorizationType: {
type: Number,
value: 2
}
},
observers: {
},
/**
* 组件的初始数据
*/
data: {
couponNum: '2',
userInfo: {},
hasUserInfo: false,
env: envInfo.env,
checkAll: true
},
/**
* 组件的方法列表
*/
methods: {
checkAll() {
this.setData({
checkAll: !this.data.checkAll
})
},
handelToMemberRules() {
wxService.router(`/pages/memberRules/memberRules?type=${this.data.isAuthorizationType}`)
},
//再想想
close() {
this.setData({
isAuthorization: false
})
},
//立即兑换
query() {},
_getUserInfo(res = {}) {
this.setData({
isAuthorization: false
})
const userInfo = res.detail || {}
if (res.detail.userInfo) {
utils.getUserInfoByBtn(userInfo).then( (data = {} ) => {
const {token} = data
wx.setStorageSync('_accreditUserInfo', userInfo)
wx.hideNavigationBarLoading()
if (token) {
wx.setStorageSync('token', token)
} else {
wx.setStorageSync('token', '')
}
wx.setStorageSync('_baseUserInfo', data)
// 存储用户开卡状态
// wx.setStorageSync('memberActivateStatus', data.memberActivateStatus)
this.setUserInfo()
}).catch(err=> {
if (err) {
wx.showToast({
title: `会员系统异常请稍后重试!`,
icon: 'none'
})
}
})
} else {
this.setData({
isAuthorization: false
})
}
},
handleActiveAgree() {
// 子组件触发父组件 去开卡
wxService.nextTick(() => {
this.triggerEvent('activeTocard', true)
})
this.setData({
isAuthorization: false
})
},
setUserInfo () {
// 判断有无开卡
// const {memberActivateStatus} = wx.getStorageSync('_baseUserInfo')
const userInfo = wx.getStorageSync('_baseUserInfo')
// 新用户去激活领卡
if (userInfo && userInfo.member && !userInfo.member.mobile) {
wxService.openCard()
return false
}
// 没有开卡并且需要开卡
// if(!memberActivateStatus) {
// wxService.openCard()
// return false
// }
// 跳转
const urls = getCurrentPages()
setTimeout(() => {
const item = urls[0]
if (item.route) {
try {
const options = item.options
wxService.router(`/${item.route}`).search(options).replace()
} catch (e) {
wx.showToast({
title: `会员系统异常请稍后重试!`,
icon: 'none'
})
}
} else {
wx.showToast({
title: `会员系统异常请稍后重试!`,
icon: 'none'
})
}
}, 200)
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<view class="modal" wx:if='{{isAuthorization}}'>
<view class="modal-mask"></view>
<view class="modal-container" style="top:{{isAuthorizationActiveText ? '12%' : '26%' }};">
<view class='auth-avatar'>
<image class='auth-avatar-img' src='/assets/imgs/auth-avatar.png'></image>
</view>
<view class='auth-shop' wx:if="{{isAuthorizationActiveText}}">
<view class="auto-old"><span class="auto-old-num">1. </span>老会员无需领取新会员卡,即可在会员小程序享受全部会员权益。</view>
<view class="auto-old"><span class="auto-old-num">2. </span>若在领取新会员卡过程中输入新手机号,会造成原会员及积分信息的更替。</view>
<view class="auto-old"><span class="auto-old-num">3. </span>领取后的新会员卡,将存放在"微信-卡包"。</view>
</view>
<view class='auth-shop' wx:else>广东7-Eleven申请获取授权,用于会员服务</view>
<button type='primary' wx:if="{{!isAuthorizationActiveText}}" bindgetuserinfo="_getUserInfo" open-type='getUserInfo' class='agree' disabled='{{!checkAll}}'>同意</button>
<button type='primary' wx:else class='agree' disabled='{{!checkAll}}' bindtap="handleActiveAgree">同意并领取新会员卡</button>
<view class='rule-wrap'>
<view class='agree-rule'>
<view wx:if="{{!isAuthorizationActiveText}}" class="agree-icon"><icon size="18" type="{{checkAll ? 'success' : 'circle'}}" bindtap="checkAll"></icon></view>
<view wx:if="{{!isAuthorizationActiveText}}"><text>我已阅读并同意</text><text class='rule-text' bindtap="handelToMemberRules">《会员规则》</text></view>
<!-- <view wx:else><text>我已阅读并同意</text><text class='rule-text' bindtap="handelToMemberRules">《激活领卡规则》</text></view>-->
</view>
</view>
<view class='close' bindtap='close'>
<image class='close-img' src='/assets/imgs/close.png'></image>
</view>
</view>
</view>
\ No newline at end of file
/* component/authorization-modal/authorization-modal.wxss */
.modal {
position: absolute;
right: 0;
left: 0;
bottom: 0;
top: 0;
background-color: transparent;
}
.auto-old {
display: flex;
padding-bottom: 10rpx;
}
.auto-old-num {
display: inline-block;
width: 60rpx;
}
.modal-mask {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: rgba(0, 0, 0, 0.6);
opacity: 1;
z-index: 3;
}
.modal-container {
position: fixed;
left: 96rpx;
/* top: 262rpx; */
/* top: 18%; */
background-color: #fff;
width: 570rpx;
min-height: 450rpx;
z-index: 4;
border-radius: 20rpx;
}
.auth-avatar{
width: 126rpx;
height: 126rpx;
/* margin: 120rpx auto 92rpx; */
margin: 60rpx auto 60rpx;
}
.auth-avatar-img{
width: 126rpx;
height: 126rpx;
}
.auth-shop{
width: 400rpx;
margin: 0 auto;
font-size: 30rpx;
color: #333333;
}
.agree{
width: 416rpx;
height: 88rpx;
line-height: 88rpx;
font-size: 30rpx;
background-color: #05c35b !important;
margin: 50rpx auto 32rpx;
}
.agree-rule{
font-size: 22rpx;
color: #666666;
display: flex;
padding-bottom: 50rpx;
}
.agree-icon{
margin-right: 10rpx;
}
.rule-text{
color: #05c35b;
}
.rule-wrap{
margin-left: 76rpx;
}
.close-img{
width: 58rpx;
height: 58rpx;
position: absolute;
bottom: -120rpx;
left: 265rpx;
}
// component/progressImage/progressImage.js
const wxService = require('../../utils/wxService')
Component({
properties: {
goal: {
type: Number,
value: 0
},
showNum: {
type: Boolean,
value: false
},
AvailableNum: {
type: Number,
value: 0
},
showRemNum: {
type: Number,
value: 0
},
iconImage: {
type: String,
value: ''
},
iconImageFinsh: {
type: String,
value: ''
}
},
/**
* 页面的初始数据
*/
data: {
num: 5,
currentProgress: 0, // 当前已完成进度
},
attached() {},
observers: {
AvailableNum() {
wxService.nextTick(()=>{
const { AvailableNum, showRemNum,goal, showNum } = this.data
this.setData({
currentProgress: AvailableNum ? (showNum ? goal : showRemNum) : showRemNum
})
})
}
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {
}
}
\ No newline at end of file
<!--component/progressImage/progressImage.wxml-->
<view class="section clearfix">
<view class="{{goal >=7 ? '' : 'text-section'}}">
<!-- 当前已完成 -->
<block wx:for="{{currentProgress}}" wx:key="{{index}}">
<view class="text-item" style="width: {{100 / 8}}%;">
<!--<image class="item-img" style="" src="/assets/imgs/point/color.png" mode="widthFix" />-->
<image class="item-img" style="" src="{{iconImageFinsh}}" mode="widthFix" />
</view>
</block>
<!-- 当前目标进度 未完成 -->
<block wx:for="{{goal - currentProgress}}" wx:key="{{index}}">
<view class="text-item" style="width: {{100 / 8}}%;">
<image class="item-img" style="" src="{{iconImage}}" mode="widthFix" />
</view>
</block>
</view>
</view>
\ No newline at end of file
/* component/progressImage/progressImage.wxss */
.text-section {
text-align: center;
display: flex;
justify-content: center;
}
.text-item {
float: left;
height: 82rpx;
line-height: 82rpx;
margin:0 10rpx 10rpx 0;
box-sizing: content-box;
border-radius: 50%;
}
.item-img {
height: 82rpx;
width: 100%;
border-radius: 50%;
}
.clearfix::after {
content: '';
display: block;
clear: both; }
\ No newline at end of file
// component/progressPoint/progressPoint.js
const wxService = require('../../utils/wxService')
Component({
properties: {
percent: {
type: [Number, String],
value: 0
},
width: {
type: [Number, String],
value: 650
},
strokeWidth: {
type: [Number, String],
value: 10
},
activeColor: {
type: [String, Array],
value: '#949494'
},
backgroundColor: {
type: String,
value: '#e5e5e5'
},
radius: {
type: [Number, String],
value: 5
},
orientation: {
type: [Number, String],
value: 'landscape'
// slider方向 landscape横向 portrait纵向
},
portraitOrientation: {
type: [Number, String],
value: 'bottom'
// 纵向方向 top 从上到下 bottom 从下到上
}
},
attached: function () {
let activeColor = this.data.activeColor;
if (!!~activeColor.indexOf(',')) {
this.setData({
activeLineColor: activeColor.split(',')
})
}
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {
}
}
\ No newline at end of file
<!--component/progressPoint/progressPoint.wxml-->
<view class="progress progress__bg" style="width: {{orientation == 'landscape' ? width : strokeWidth}}rpx; border-radius:{{radius}}rpx; background-color: {{backgroundColor}}; height: {{orientation == 'landscape' ? strokeWidth : width}}rpx">
<view class="progress__line" style="width: {{orientation == 'landscape' ? percent / 100 * width : strokeWidth}}rpx; height: {{orientation == 'landscape' ? strokeWidth : percent / 100 * width}}rpx; top:{{ portraitOrientation == 'bottom' && orientation == 'portrait' ? (100 - percent) / 100 * width : 0 }}rpx; border-radius:{{radius}}rpx; {{ orientation == 'landscape' ?(activeLineColor[1] ? 'background-image: linear-gradient(to right, ' + activeLineColor[0] + ', ' + activeLineColor[1] + ');' : 'background-color:' + activeColor + ';') : (activeLineColor[1] ? 'background-image: linear-gradient(to top, ' + activeLineColor[0] + ', ' + activeLineColor[1] + ');' : 'background-color:' + activeColor + ';')}}" />
</view>
\ No newline at end of file
/* component/progressPoint/progressPoint.wxss */
/* .progress__line {
width: 100%!important;
} */
\ No newline at end of file
// component/statusPoint/statusPoint.js
const wxService = require('../../utils/wxService')
Component({
/**
* 组件的属性列表
*/
properties: {
img: {
type: String,
value: '',
},
imgHeight: {
type: Number,
value: 320
},
currentStatus: {
type: Number,
value: 2
},
currentTimeStatus: {
type: Number,
value: 1
},
},
attached() { },
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})
{
"component": true,
"usingComponents": {
}
}
\ No newline at end of file
<!--component/statusPoint/statusPoint.wxml-->
<!--#05C35B -->
<view class="status" style="height: {{imgHeight}}rpx" wx:if="{{img}}">
<view class="status-tips" style="background-color:rgba(5, 195, 91, 1);" wx:if="{{currentStatus == 2 && currentTimeStatus == 1}}">进行中 >></view>
<view class="status-tips" style="background-color:rgb(170, 170, 170);" wx:elif="{{currentStatus == 3}}"> 已失效 >></view>
<view class="status-tips" style="background-color:rgb(170, 170, 170);" wx:elif="{{currentTimeStatus == 2}}">已结束 >></view>
<view class="status-tips" style="background-color:rgb(170, 170, 170);" wx:elif="{{currentTimeStatus == 3}}">未开始 >></view>
<view class="status-tips" style="background-color:rgb(170, 170, 170);" wx:else>已结束 >></view>
<!--<image class='status-tips' src='/assets/imgs/point/status.png' mode="widthFix"/>-->
<image wx:if="{{img}}" class='status-img' src='{{img}}' />
</view>
/* component/statusPoint/statusPoint.wxss */
@import './../../base/base.wxss';
.status {
height: 320rpx;
border-radius: 8rpx;
position: relative;
overflow: hidden;
}
.status-tips {
width: 130rpx;
height: 58rpx;
margin-top: 12px;
box-sizing: border-box;
position: absolute;
color: #fff;
text-align: center;
line-height: 58rpx;
font-size: 24rpx;
border-radius: 10rpx 100rpx 100rpx 10rpx;
}
.status-img {
border-radius: 8rpx;
height: 100%;
width: 100%;
}
\ No newline at end of file
// pages/pointDetail/pointDetail.js
const app = getApp()
const wxService = require('../../utils/wxService')
const utils = require('../../utils/util')
wxService.page({
/**
* 页面的初始数据
*/
data: {
id: 0,
imgHeight: 450,
dialog: {
show: false,
image: '../../assets/imgs/point/bgc.png',
content: '优惠券和积分流水',
tip: '立即查看'
},
desc: [],
activityId: '',
type: 0, // 0 不显示 1 显示
popupType: 0, // 默认不跳转 1 优惠券 2 积分
goal: 0,
iconImage: '',
iconImageFinsh: '',
detailImage: '',
countObj: {
surplusPoints: 0,
exchangeCount: 0,
totalPoints: 0,
surplusExchangeCount: 0
},
currentPercent: 0, // 当前进度
isDisabled: false,
hideGetBtn: true, // 默认隐藏 可领取按钮
showGetBtn: true, // 默认展示 未达成按钮
currentStatus: 2, // 活动状态 1 未生效 2 生效中 3 已失效 0 已删除
currentTimeStatus: 1, // 1 进行中 2 已结束 3 未开始
isAuthorization: false,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
// 集点详情
getPointDetail(id) {
wx.showLoading({
title: '加载中'
})
wxService.get(`/sale/touchpoints/pointConsumptionActivity/findById/${id}`).then(res => {
if (res) {
const { result, data } = res.data
if (result == 0) {
wx.hideLoading()
let dialog = this.data.dialog
dialog.show = false
// 弹框背景
dialog.image = data.popupImage
// 是否在有效期
let timeFlag = 1
let endT = data.endTime
let startT = data.startTime
let currentEndTime = (new Date(endT.replace(/-/g, '/'))).getTime();
let currentstartTime = (new Date(startT.replace(/-/g, '/'))).getTime();
let currentTime = (new Date()).getTime();
// 开始时间 小于 现在 && 小于 结束时间 进行中
if (currentstartTime < currentTime && currentTime < currentEndTime) {
timeFlag = 1
} else if (currentEndTime < currentTime) {
// 结束时间 小于 现在时间 已结束
timeFlag = 2
} else if(currentTime < currentstartTime) {
// 未开始
timeFlag = 3
}
this.setData({
activityId: data.id,
type: data.showActivitys,
currentStatus: data.status,
popupType: data.popupType,
goal: data.goal,
iconImage: data.iconImage,
iconImageFinsh: data.iconImageFinsh,
desc: JSON.parse(data.content),
detailImage: data.detailImage,
dialog,
currentTimeStatus: timeFlag
}, () => {
// 1 进行中 2 已结束
if (timeFlag == 2) {
this.showTimeStatus('活动已经结束啦')
} else if (data.status == 3) {
// 活动状态 1 未生效 2 生效中 3 已失效 0 已删除
this.showTimeStatus('活动已经失效啦,看看其他的')
} else {
// 会员集点活动统计信息 进行中且有效
this.getPointConsumptionCount(id)
}
})
}
}
})
},
showTimeStatus(status) {
wx.showToast({
title: `${status}`,
icon: 'none'
})
},
// 会员集点活动统计信息
getPointConsumptionCount(activityId) {
const { memberId } = wx.getStorageSync('_baseUserInfo')
wx.showLoading({
title: '加载中'
})
wxService.post(`/sale/touchpoints/pointConsumptionCount/getPointConsumptionCount?activityId=${activityId}&memberId=${memberId}`).then(res => {
if (res) {
const { result, data } = res.data
// percent
let newPercent = 0
let hasNum = data.surplusExchangeCount
let totalPoints = data.totalPoints
let goal = this.data.goal
if (hasNum) {
if (parseInt(totalPoints % goal) == 0) {
newPercent = goal
} else {
if (totalPoints) {
newPercent = totalPoints % goal
} else {
newPercent = 0
}
}
} else {
if (totalPoints) {
newPercent = totalPoints % goal
} else {
newPercent = 0
}
}
if (result == 0) {
this.setData({
countObj: data,
currentPercent: 100 / (this.data.goal / newPercent),
surplusExchangeCount: data.surplusExchangeCount,
hideGetBtn: hasNum ? false : true,
showGetBtn: hasNum ? true : false,
}, () => {
wx.hideLoading()
})
}
}
})
},
handleCheckGoods() {
const { activityId } = this.data
wxService.router(`/subPackage/page/pages/pointGoodsList/pointGoodsList`).search({ activityId })
},
_closeDialog() {
const { id } = this.data
if (id) this.getPointDetail(id)
},
handleGo() {
// 跳转 popupType: 0 默认不跳转 1 优惠券 2 积分
const { popupType, id } = this.data
if (popupType == 1) {
wxService.router(`/pages/coupons/coupons`)
} else if (popupType == 2) {
wxService.router(`/pages/integralWater/integralWater`)
} else {
// 隐藏 dialog
this.isShowDialog(false)
// 获取最新数据
this.getPointDetail(id)
}
},
// 触点有礼-消费集点兑换
getPointExchange() {
const { activityId } = this.data
const { memberId } = wx.getStorageSync('_baseUserInfo')
wx.showLoading({
title: '加载中'
})
wxService.get(`/sale/touchpoints/pointConsumptionExchange/exchange?activityId=${activityId}&memberId=${memberId}`).then(res => {
if (res) {
const { result, data } = res.data
const { popupType, id } = this.data
if (result == 0) {
wx.hideLoading()
// 显示 dialog
this.isShowDialog(true)
// popupType == 0 3s 关闭
if (popupType == 0){
setTimeout(()=>{
this.isShowDialog(false)
this.getPointDetail(id)
},3000)
}
}
}
})
},
isShowDialog(flag) {
let dialog = this.data.dialog
dialog.show = flag
this.setData({
dialog
})
},
handleToGet() {
// 按钮防止短时间多次点击
const { countObj } = this.data
if (countObj.surplusExchangeCount) {
this.getPointExchange()
}
this.setData({
isDisabled: true
})
setTimeout(() => {
this.setData({
isDisabled: false
})
}, 3000)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
// 登录接口返回err
const reLoginErrFlag = wx.getStorageSync('reLoginErr')
const baseUserInfo = wx.getStorageSync('_baseUserInfo')
let id
if (baseUserInfo && !reLoginErrFlag){
this.setData({
isAuthorization: false
},()=>{
const option = this.options || {}
const { scene } = option
if (scene) {
let idParam = decodeURIComponent(scene).split('&')[0]
let shareId = idParam && idParam.split('=')[1] || 0
id = shareId
} else {
id = option.id
}
if (id) {
this.setData({
id
}, () => {
this.getPointDetail(id)
})
}
// 隐藏 dialog
this.isShowDialog(false)
})
}
else if(!baseUserInfo && reLoginErrFlag){
this.setData({
isAuthorization: true
})
}
else {
this.setData({
isAuthorization: true
})
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"navigationBarTitleText": "集点详情",
"usingComponents": {
"status-img": "/component/statusPoint/statusPoint",
"x-dialog":"/component/dialog/dialog",
"x-progress-point":"/component/progressPoint/progressPoint",
"x-progress-image":"/component/progressImage/progressImage",
"authorization-modal-point": "/component/authorization-modal-point/authorization-modal-point"
}
}
\ No newline at end of file
<!--pages/pointDetail/pointDetail.wxml-->
<wxs src="./tools.wxs" module="tools" />
<status-img imgHeight="{{imgHeight}}" img="{{detailImage}}" currentStatus="{{currentStatus}}" currentTimeStatus="{{currentTimeStatus}}"/>
<view class="detail-info border_box" wx:if="{{goal}}">
<view class="info-top weui-flex df-j--bt">
<view class="info-num">
进度:
<!--可领取次数_surplusExchangeCount 存在 3/3 不存在 0/3 -->
<span wx:if="{{countObj.surplusExchangeCount}}">
<!-- 被整除 是 显示目标集点 否 显示余数-->
<text class="point_color" wx:if="{{tools.parse(countObj.totalPoints % goal) == 0}}"> {{goal}}</text>
<text class="point_color" wx:else> {{countObj.totalPoints ? tools.parse(countObj.totalPoints % goal) : 0}}</text>
</span>
<text class="point_color" wx:else> {{countObj.totalPoints ? tools.parse(countObj.totalPoints % goal) : 0}}</text>
/ {{goal}}
</view>
<view class="info-ready-num">
<!-- 已达成次数 总集点数/目标节点 取整 -->
已达成 {{countObj.totalPoints ? tools.parse(countObj.totalPoints / goal) : 0}} 次
</view>
</view>
<view class="info-progress border_box">
<!-- <x-progress-point
active-color='#3EEB9A, #04C25C'
percent='{{currentPercent != null ? currentPercent : 0}}'
stroke-width='20'
radius='20'
/>-->
<x-progress-image goal="{{goal}}" iconImageFinsh="{{iconImageFinsh}}" iconImage="{{iconImage}}" AvailableNum="{{countObj.surplusExchangeCount}}" showRemNum="{{countObj.totalPoints ? tools.parse(countObj.totalPoints % goal) : 0}}" showNum="{{tools.parse(countObj.totalPoints % goal) == 0}}"/>
</view>
<!-- 活动剩余点数 >= 目标点数 wx:if="{{countObj.surplusPoints >= goal}}"-->
<button
hidden="{{hideGetBtn}}"
bindtap="handleToGet"
class="info-status-btn border_box available breathe-btn"
disabled="{{isDisabled}}"
>可领取奖励
<text class="total-points"> {{countObj.surplusExchangeCount}} </text>
</button>
<view hidden="{{showGetBtn}}" class="info-status-btn unacommpolished border_box">
还未达成,继续加油呀
</view>
</view>
<view class="detail-desc">
<view class="detail-active point_color" bindtap="handleCheckGoods" wx:if="{{type == 1}}">查看活动商品 ></view>
<view class='integral-list' wx:for="{{desc}}" wx:key="{{index}}">
<text class='integral-title'>{{item.title}}</text>
<text class='integral-desc wpl'>{{item.value}}</text>
</view>
</view>
<x-dialog
dialog="{{dialog}}"
bind:handleGo="handleGo"
bind:_closeDialog="_closeDialog"
show="{{dialog.show}}"
/>
<authorization-modal-point isAuthorization='{{isAuthorization}}'/>
/* pages/pointDetail/pointDetail.wxss */
@import './../../base/base.wxss';
.detail-info{
min-height: 350rpx;
background-color: #fff;
padding: 44rpx 51rpx;
}
.info-num {
height: 45rpx;
color: rgba(51, 51, 51, 1);
font-size: 32rpx;
text-align: left;
font-family: PingFangSC-Regular;
}
.info-ready-num {
left: 563rpx;
height: 40rpx;
color: rgba(117, 117, 117, 1);
font-size: 28rpx;
text-align: right;
font-family: PingFangSC-Regular;
}
.info-progress{
padding: 31rpx 0 56rpx 15rpx;
}
.info-status-btn {
margin: 0 50rpx;
text-align: center;
height: 88rpx;
line-height: 78rpx;
border-radius: 44rpx;
background-color: #FFFFFF;
font-size: 32rpx;
}
.available{
box-shadow: 0px 2rpx 14rpx -3rpx rgba(255, 51, 51, 1);
background:linear-gradient(to bottom, #FF3333,#F85B5B);/*设置按钮为渐变颜色*/
color: #fff;
}
.unacommpolished {
border: 1px solid rgba(204, 204, 204, 1);
color: rgba(204, 204, 204, 1);
font-size: 32rpx;
font-family: PingFangSC-Medium;
}
.detail-desc {
box-sizing: border-box;
padding: 20rpx 40rpx 0 40rpx;
}
.integral-list{
margin: 20rpx 0 60rpx 0;
font-size: 27rpx;
}
.integral-title,.integral-desc{
display: inline-block;
}
.integral-title{
color: #999999;
vertical-align: top;
margin-right: 50rpx;
text-align: right;
width: 120rpx;
}
.integral-desc{
width: 500rpx;
color: #666666;
}
.detail-active {
height: 33rpx;
font-size: 24rpx;
text-align: right;
font-family: PingFangSC-Regular;
}
.total-points {
font-size: 48rpx;
}
function parse (str) {
return parseInt(str);
};
function isNaN(str) {
return isNaN(str);
};
function isFinite(str) {
return isFinite(str)
}
module.exports = {
parse: parse,
isNaN: isNaN,
isFinite: isFinite
}
\ No newline at end of file
// pages/pointList/pointList.js
const app = getApp()
const wxService = require('../../utils/wxService')
const utils = require('../../utils/util')
wxService.page({
/**
* 页面的初始数据
*/
data: {
pointList: [],
currentStatus: 2, // 活动状态 1 未生效 2 生效中 3 已失效 0 已删除
currentTimeStatus: 1, // 1 进行中 2 已结束 3 未开始
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() { },
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.getPointList()
},
getPointList() {
wx.showLoading({
title: '加载中'
})
wxService.get(`/sale/touchpoints/pointConsumptionActivity/findAllValidActivityList`).then(res => {
if (res) {
const { result, data } = res.data
if (result == 0) {
data.forEach(item => {
// 是否在有效期
let timeFlag = 1
let endT = item.endTime
let startT = item.startTime
// ios 兼容
let currentEndTime = (new Date(endT.replace(/-/g, '/'))).getTime();
let currentstartTime = (new Date(startT.replace(/-/g, '/'))).getTime();
let currentTime = (new Date()).getTime();
// 开始时间 小于 现在 && 小于 结束时间 进行中
if (currentstartTime < currentTime && currentTime < currentEndTime) {
timeFlag = 1
} else if (currentEndTime < currentTime) {
// 结束时间 小于 现在时间 已结束
timeFlag = 2
} else if(currentTime < currentstartTime) {
// 未开始
timeFlag = 3
}
let distancetime = currentEndTime - currentTime
let result = {
day: '00',
hour: '00',
min: '00',
sec: '00',
ms: '00',
isOver: true,
};
if (distancetime > 0) {
//如果大于0.说明尚未到达截止时间
result.ms = Math.floor((distancetime % 1000) / 100);
result.sec = Math.floor((distancetime / 1000) % 60);
result.min = Math.floor((distancetime / 1000 / 60) % 60);
result.hour = Math.floor((distancetime / 1000 / 60 / 60) % 24);
result.day = Math.floor((distancetime / 1000 / 60 / 60) / 24);
result.isOver = false;
// if (result.ms < 10) result.ms = result.ms;
// if (result.sec < 10) result.sec = '0' + result.sec;
// if (result.min < 10) result.min = '0' + result.min;
// if (result.hour < 10) result.hour = '0' + result.hour;
// if (result.day < 10) result.day = '0' + result.day;
}
item.countdown = result
this.setData({
pointList: data,
currentStatus: item.status,
currentTimeStatus: timeFlag
}, () => {
wx.hideLoading()
this.getPointConsumptionCount(item.id)
})
})
}
}
})
},
getPointConsumptionCount(activityId) {
const { memberId } = wx.getStorageSync('_baseUserInfo')
// 会员集点活动统计信息
wxService.post(`/sale/touchpoints/pointConsumptionCount/getPointConsumptionCount?activityId=${activityId}&memberId=${memberId}`).then(res => {
if (res) {
const { result, data } = res.data
const { pointList } = this.data
if (result == 0) {
pointList.forEach(item => {
if (item.id == data.activityId) {
item.surplusPoints = data.surplusPoints
item.totalPoints = data.totalPoints
item.surplusExchangeCount = data.surplusExchangeCount
this.setData({
pointList
})
}
})
}
}
})
},
handleDetail(e) {
const { id } = e.currentTarget.dataset
wxService.router(`/pages/pointDetail/pointDetail`).search({ id })
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"navigationBarTitleText": "集点列表",
"usingComponents": {
"status-img": "/component/statusPoint/statusPoint"
}
}
\ No newline at end of file
<!--pages/pointList/pointList.wxml-->
<wxs src="./tools.wxs" module="tools" />
<view class="point--no-list border_box" wx:if="{{!pointList.length}}">
<text>您当前暂无集点活动</text>
</view>
<view class="point-list border_box" wx:if="{{pointList.length}}">
<block wx:for="{{pointList}}" wx:key="item">
<view class="point border_box" data-id="{{item.id}}" bindtap="handleDetail">
<status-img img="{{item.listImage}}" currentStatus="{{currentStatus}}" currentTimeStatus="{{currentTimeStatus}}"-/>
<view class="progress weui-flex df-j--bt">
<view class="rate">进度:
<span wx:if="{{item.surplusExchangeCount}}">
<text class="point_color" wx:if="{{tools.parse(item.totalPoints % item.goal) == 0}}"> {{item.goal}}</text>
<text class="point_color" wx:else> {{item.totalPoints && item.goal ? tools.parse(item.totalPoints % item.goal) : 0}}</text>
</span>
<text class="point_color" wx:else> {{item.totalPoints && item.goal ? item.totalPoints % item.goal : 0}}</text>
/ {{item.goal}}
</view>
<view class="time-out">距离结束时间:
<!-- 不满1小时,按1小时算-->
<!--<text class="time">{{item.countdown.day}}天{{item.countdown.hour}}小时</text>-->
<text class="time">{{item.countdown.day}}天{{item.countdown.min <= 59 ? item.countdown.hour + 1: item.countdown.hour}}小时</text>
</view>
</view>
</view>
</block>
</view>
/* pages/pointList/pointList.wxss */
@import './../../base/base.wxss';
page {
background-color: #fff;
}
.point-list {
padding-bottom: 30rpx;
}
.point {
padding: 30rpx 30rpx 0 30rpx;
}
.status-img {
height: 320rpx;
}
.progress {
height: 70rpx;
line-height: 70rpx;
border-bottom: 1px solid rgba(151, 151, 151, .3);
}
.rate {
/* width: 137rpx; */
height: 33rpx;
color: rgba(51, 51, 51, 1);
font-size: 24rpx;
text-align: left;
font-family: PingFangSC-Regular;
}
.time-out {
/* width: 279px; */
height: 33px;
color: rgba(120, 120, 120, 1);
font-size: 24rpx;
text-align: right;
font-family: PingFangSC-Regular;
}
.time {
color: #000;
}
.point--no-list {
display: flex;
align-items: center;
justify-content: center;
color: rgba(120, 120, 120, 1);
font-size: 24rpx;
padding-top: 200rpx;
}
\ No newline at end of file
var parse = function(str) {
return parseInt(str);
};
module.exports = {
parse: parse
}
\ No newline at end of file
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
"list": [] "list": []
}, },
"miniprogram": { "miniprogram": {
"current": 13, "current": 38,
"list": [ "list": [
{ {
"id": -1, "id": -1,
...@@ -293,6 +293,11 @@ ...@@ -293,6 +293,11 @@
"pathName": "subPackage/page/pages/plus/plus", "pathName": "subPackage/page/pages/plus/plus",
"query": "", "query": "",
"scene": null "scene": null
},
{
"id": -1,
"name": "集点列表",
"pathName": "pages/pointList/pointList"
} }
] ]
} }
......
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