init
This commit is contained in:
481
fuintUniapp/pages/coupon/detail.vue
Normal file
481
fuintUniapp/pages/coupon/detail.vue
Normal file
@@ -0,0 +1,481 @@
|
||||
<template>
|
||||
<view v-if="!isLoading" class="container b-f p-b">
|
||||
<view class="base">
|
||||
<view class="coupon-main">
|
||||
<view class="left">
|
||||
<image class="image" :src="detail.image"></image>
|
||||
</view>
|
||||
<view class="right">
|
||||
<view class="item">
|
||||
<view class="name">{{ detail.name ? detail.name : '' }}</view>
|
||||
</view>
|
||||
<view v-if="detail.amount > 0" class="item">
|
||||
<view class="amount">¥<text class="num">{{ detail.amount }}</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="detail.point > 0" class="item">
|
||||
<view class="label">兑换积分:</view>
|
||||
<view class="amount">{{ detail.point }}</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<view class="label">有效期至:</view>
|
||||
<view class="time">{{ detail.effectiveDate }}</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<view class="label">适用门店:</view>
|
||||
<view>{{ detail.storeNames ? detail.storeNames : '全部'}}</view>
|
||||
</view>
|
||||
<view v-if="detail.code && detail.status == 'A' && detail.isGive" class="gift" @click="give()"><text>转赠好友</text></view>
|
||||
</view>
|
||||
<view class="coupon-qr" v-if="detail.code">
|
||||
<view>
|
||||
<image class="image" :src="detail.qrCode"></image>
|
||||
</view>
|
||||
<view class="qr-code">
|
||||
<p class="code">核销码:{{ detail.code }}</p>
|
||||
<p class="tips">请出示以上券码给核销人员</p>
|
||||
</view>
|
||||
</view>
|
||||
<view class="coupon-content m-top20">
|
||||
<view class="title">使用须知</view>
|
||||
<view class="content"><jyf-parser :html="detail.description ? detail.description : '暂无...'"></jyf-parser></view>
|
||||
</view>
|
||||
<!-- 快捷导航 -->
|
||||
<shortcut/>
|
||||
<view class="give-popup" v-if="detail.qrCode">
|
||||
<uni-popup ref="givePopup" type="dialog">
|
||||
<uni-popup-dialog mode="input" focus="false" title="转赠给好友" type="info" placeholder="输入好友手机号码" :before-close="true" @close="cancelGive" @confirm="doGive"></uni-popup-dialog>
|
||||
</uni-popup>
|
||||
</view>
|
||||
<!-- 底部选项卡 -->
|
||||
<view v-if="!detail.code && !detail.isReceive" class="footer-fixed">
|
||||
<view class="footer-container">
|
||||
<!-- 操作按钮 -->
|
||||
<view class="foo-item-btn">
|
||||
<view class="btn-wrapper">
|
||||
<view class="btn-item btn-item-main" @click="receive(detail.id)">
|
||||
<text v-if="!detail.point || detail.point < 1">立即领取</text>
|
||||
<text v-if="detail.point && detail.point > 0">立即兑换</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="footer-fixed" v-if="userCouponId || detail.isReceive">
|
||||
<view class="footer-container">
|
||||
<!-- 操作按钮 -->
|
||||
<view class="foo-item-btn">
|
||||
<view class="btn-wrapper">
|
||||
<view v-if="detail.isReceive" class="btn-item btn-item-main state">
|
||||
<text v-if="!detail.point || detail.point < 1">您已领取</text>
|
||||
<text v-if="detail.point && detail.point > 0">您已兑换</text>
|
||||
</view>
|
||||
<view v-if="userCouponId && detail.status != 'D'" class="btn-item btn-item-main" @click="remove(userCouponId)">
|
||||
<text>删除卡券</text>
|
||||
</view>
|
||||
<view v-else class="btn-item btn-item-main state">
|
||||
<text>已删除</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!--领取码 start-->
|
||||
<view class="receive-pop">
|
||||
<uni-popup ref="receiveCodePopup" type="dialog">
|
||||
<uni-popup-dialog mode="input" v-model="receiveCode" focus="false" title="领取码" type="info" placeholder="请输入领取码" :before-close="true" @close="cancelReceive" @confirm="doReceive"></uni-popup-dialog>
|
||||
</uni-popup>
|
||||
</view>
|
||||
<!--领取码 end-->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import jyfParser from '@/components/jyf-parser/jyf-parser'
|
||||
import Shortcut from '@/components/shortcut'
|
||||
import * as myCouponApi from '@/api/myCoupon'
|
||||
import * as giveApi from '@/api/give'
|
||||
import * as couponApi from '@/api/coupon'
|
||||
import * as MessageApi from '@/api/message'
|
||||
import config from '@/config'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Shortcut
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 当前会员卡券ID
|
||||
userCouponId: 0,
|
||||
// 卡券ID
|
||||
couponId: 0,
|
||||
// 加载中
|
||||
isLoading: true,
|
||||
// 当前卡券详情
|
||||
detail: null,
|
||||
qrCode: '',
|
||||
receiveCode: '' // 领取码
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
this.userCouponId = options.userCouponId ? options.userCouponId : 0;
|
||||
this.couponId = options.couponId ? options.couponId : 0;
|
||||
this.getCouponDetail();
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 获取卡券详情
|
||||
getCouponDetail() {
|
||||
const app = this
|
||||
myCouponApi.detail(app.couponId, app.userCouponId, "")
|
||||
.then(result => {
|
||||
app.detail = result.data;
|
||||
if (!app.couponId || app.couponId < 1) {
|
||||
app.couponId = app.detail.couponId;
|
||||
}
|
||||
})
|
||||
.finally(() => app.isLoading = false)
|
||||
},
|
||||
// 转赠
|
||||
give() {
|
||||
this.$refs.givePopup.open('top');
|
||||
},
|
||||
cancelGive() {
|
||||
this.$refs.givePopup.close();
|
||||
},
|
||||
doGive(friendMobile) {
|
||||
const app = this
|
||||
if (friendMobile.length < 11) {
|
||||
app.$error("请先输入好友手机号码!")
|
||||
return false
|
||||
} else {
|
||||
app.$refs.givePopup.close()
|
||||
const param = {'mobile': friendMobile, 'couponId': this.userCouponId, 'message': '转赠一张优惠券给你'}
|
||||
giveApi.doGive(param)
|
||||
.then(result => {
|
||||
if (result.code == '200') {
|
||||
uni.showModal({
|
||||
title: '提示信息',
|
||||
content: '恭喜,转增成功!',
|
||||
showCancel: false,
|
||||
success(o) {
|
||||
if (o.confirm) {
|
||||
uni.navigateBack()
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
app.$error(result.message)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
// 取消领取码
|
||||
cancelReceive() {
|
||||
this.receiveCode = '';
|
||||
this.$refs.receiveCodePopup.close();
|
||||
},
|
||||
// 确认领取码
|
||||
doReceive(vCode) {
|
||||
if (!vCode || vCode.length < 1) {
|
||||
this.$error("请先输入领取码!");
|
||||
return false;
|
||||
}
|
||||
this.receiveCode = vCode;
|
||||
this.$refs.receiveCodePopup.close();
|
||||
this.receive(this.couponId);
|
||||
},
|
||||
// 领取卡券
|
||||
receive(couponId) {
|
||||
const app = this
|
||||
if (app.detail.needReceiveCode && !app.receiveCode) {
|
||||
app.$refs.receiveCodePopup.open('top');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (app.detail.point) {
|
||||
uni.showModal({
|
||||
title: "提示信息",
|
||||
content: "需要"+app.detail.point+"积分兑换,您确定兑换吗?",
|
||||
success({ confirm }) {
|
||||
if (confirm) {
|
||||
couponApi.receive({ 'couponId': couponId, 'receiveCode': app.receiveCode })
|
||||
.then(result => {
|
||||
app.receiveCode = '';
|
||||
// 显示提示
|
||||
if (parseInt(result.code) === 200) {
|
||||
app.detail.isReceive = true
|
||||
app.$success("兑换成功!")
|
||||
// #ifdef MP-WEIXIN
|
||||
MessageApi.getSubTemplate({keys: "couponArrival,couponConfirm"}).then(result => {
|
||||
const templateIds = result.data
|
||||
wx.requestSubscribeMessage({tmplIds: templateIds,
|
||||
success(res) {
|
||||
console.log("调用成功!")
|
||||
}, fail(res) {
|
||||
console.log("调用失败:", res)
|
||||
}, complete() {
|
||||
// empty
|
||||
}
|
||||
})
|
||||
})
|
||||
// #endif
|
||||
} else {
|
||||
app.$error(result.message)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
couponApi.receive({ 'couponId': couponId, 'receiveCode': app.receiveCode })
|
||||
.then(result => {
|
||||
app.receiveCode = '';
|
||||
// 显示提示
|
||||
if (parseInt(result.code) === 200) {
|
||||
app.detail.isReceive = true
|
||||
app.$success("领取成功!")
|
||||
// #ifdef MP-WEIXIN
|
||||
MessageApi.getSubTemplate({keys: "couponArrival,couponConfirm"}).then(result => {
|
||||
const templateIds = result.data
|
||||
wx.requestSubscribeMessage({tmplIds: templateIds,
|
||||
success(res) {
|
||||
console.log("调用成功!")
|
||||
}, fail(res) {
|
||||
console.log("调用失败:", res)
|
||||
}, complete() {
|
||||
// empty
|
||||
}
|
||||
})
|
||||
})
|
||||
// #endif
|
||||
} else {
|
||||
app.$error(result.message)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
// 删除卡券
|
||||
remove() {
|
||||
const app = this;
|
||||
if (app.isLoading == true) {
|
||||
return false;
|
||||
}
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "您确定要删除吗?",
|
||||
success({ confirm }) {
|
||||
if (confirm) {
|
||||
app.isLoading = true;
|
||||
myCouponApi.remove(app.userCouponId)
|
||||
.then(result => {
|
||||
app.getCouponDetail();
|
||||
app.isLoading = false;
|
||||
})
|
||||
.finally(() => app.isLoading = false)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 分享当前页面
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
const app = this
|
||||
return {
|
||||
title: config.name + "卡券分享",
|
||||
path: "/pages/coupon/detail?couponId=" + app.couponId + "&" + app.$getShareUrlParams()
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 分享到朋友圈
|
||||
* 本接口为 Beta 版本,暂只在 Android 平台支持,详见分享到朋友圈 (Beta)
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share-timeline.html
|
||||
*/
|
||||
onShareTimeline() {
|
||||
const app = this
|
||||
const { page } = app
|
||||
return {
|
||||
title: config.name + "卡券分享",
|
||||
path: "/pages/coupon/detail?couponId=" + app.couponId + "&" + app.$getShareUrlParams()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.container {
|
||||
min-height: 100vh;
|
||||
padding: 20rpx;
|
||||
background: #fff;
|
||||
color:#666666;
|
||||
}
|
||||
.base {
|
||||
border: #cccccc solid 1rpx;
|
||||
padding: 30rpx;
|
||||
border-radius: 10rpx;
|
||||
margin: 20rpx;
|
||||
display: block;
|
||||
height: auto;
|
||||
min-height: 420rpx;
|
||||
.coupon-main {
|
||||
clear: both;
|
||||
min-height: 164rpx;
|
||||
background: #f5f5f5;
|
||||
border-radius: 5rpx;
|
||||
margin-bottom: 20rpx;
|
||||
.left {
|
||||
width: 215rpx;
|
||||
float: left;
|
||||
.image {
|
||||
width: 210rpx;
|
||||
height: 160rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
}
|
||||
.right {
|
||||
width: 380rpx;
|
||||
float: left;
|
||||
overflow: hidden;
|
||||
.name {
|
||||
font-size: 38rpx;
|
||||
}
|
||||
.num {
|
||||
font-size: 58rpx;
|
||||
color: red;
|
||||
}
|
||||
}
|
||||
}
|
||||
.item {
|
||||
clear: both;
|
||||
margin-bottom: 10rpx;
|
||||
font-size: 30rpx;
|
||||
color: #666666;
|
||||
.label {
|
||||
float: left;
|
||||
}
|
||||
.amount {
|
||||
font-weight: bold;
|
||||
}
|
||||
.name {
|
||||
font-weight: bold;
|
||||
margin-left: 6rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
.coupon-qr {
|
||||
border: #cccccc solid 1rpx;
|
||||
border-radius: 10rpx;
|
||||
margin: 20rpx;
|
||||
text-align: center;
|
||||
padding-top: 30rpx;
|
||||
padding-bottom: 30rpx;
|
||||
.image{
|
||||
width: 360rpx;
|
||||
height: 360rpx;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.qr-code{
|
||||
.code{
|
||||
font-weight: bold;
|
||||
font-size: 30rpx;
|
||||
line-height: 50rpx;
|
||||
}
|
||||
.tips{
|
||||
font-size: 25rpx;
|
||||
color:#C0C4CC;
|
||||
}
|
||||
}
|
||||
}
|
||||
.coupon-content {
|
||||
padding: 30rpx;
|
||||
border: #cccccc solid 1rpx;
|
||||
border-radius: 10rpx;
|
||||
margin: 20rpx 20rpx 200rpx 20rpx;
|
||||
min-height: 400rpx;
|
||||
.title {
|
||||
margin-bottom: 15rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
.content {
|
||||
color: #666666;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
}
|
||||
.gift {
|
||||
height: 50rpx;
|
||||
width: 120rpx;
|
||||
margin-top: 20rpx;
|
||||
line-height: 50rpx;
|
||||
text-align: center;
|
||||
border: 1px solid #f8df00;
|
||||
border-radius: 6rpx;
|
||||
color: #f86d48;
|
||||
background: #f8df98;
|
||||
font-size: 22rpx;
|
||||
float: right;
|
||||
&.state {
|
||||
border: none;
|
||||
color: #F5F5F5;
|
||||
background: #888888;
|
||||
}
|
||||
}
|
||||
|
||||
/* 底部操作栏 */
|
||||
.footer-fixed {
|
||||
position: fixed;
|
||||
bottom: var(--window-bottom);
|
||||
left: 0;
|
||||
right: 0;
|
||||
display: flex;
|
||||
height: 180rpx;
|
||||
z-index: 11;
|
||||
box-shadow: 0 -4rpx 40rpx 0 rgba(144, 52, 52, 0.1);
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.footer-container {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
// 操作按钮
|
||||
.foo-item-btn {
|
||||
flex: 1;
|
||||
.btn-wrapper {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.btn-item {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
margin-right: 16rpx;
|
||||
margin-left: 16rpx;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
border-radius: 40rpx;
|
||||
}
|
||||
// 立即领取按钮
|
||||
.btn-item-main {
|
||||
background: linear-gradient(to right, #f9211c, #ff6335);
|
||||
&.state {
|
||||
border: none;
|
||||
color: #cccccc;
|
||||
background: #F5F5F5;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
517
fuintUniapp/pages/coupon/list.vue
Normal file
517
fuintUniapp/pages/coupon/list.vue
Normal file
@@ -0,0 +1,517 @@
|
||||
<template>
|
||||
<mescroll-body ref="mescrollRef" :sticky="true" @init="mescrollInit" :down="{ native: true }" @down="downCallback"
|
||||
:up="upOption" @up="upCallback">
|
||||
<!-- 页面头部 -->
|
||||
<view class="header">
|
||||
<search class="search" :tips="options.search ? options.search : '搜索卡券'" @event="handleSearch" />
|
||||
</view>
|
||||
|
||||
<!-- 排序标签 -->
|
||||
<view class="store-sort">
|
||||
<view class="sort-item" :class="{ active: sortType === 'all' }" @click="handleSortType('all')">
|
||||
<text>综合</text>
|
||||
</view>
|
||||
<view class="sort-item" :class="{ active: sortType === 'sales' }" @click="handleSortType('sales')">
|
||||
<text>领取数</text>
|
||||
</view>
|
||||
<view class="sort-item sort-item-price" :class="{ active: sortType === 'price' }" @click="handleSortType('price')">
|
||||
<text>面额</text>
|
||||
<view class="price-arrow">
|
||||
<view class="icon up" :class="{ active: sortType === 'price' && !sortPrice }">
|
||||
<text class="iconfont icon-arrow-up"></text>
|
||||
</view>
|
||||
<view class="icon down" :class="{ active: sortType === 'price' && sortPrice }">
|
||||
<text class="iconfont icon-arrow-down"></text> </view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 卡券列表 -->
|
||||
<view class="goods-list clearfix" :class="['column-1']">
|
||||
<view class="goods-item" v-for="(item, index) in list.content" :key="index" @click="onTargetDetail(item.id, item.type, item.userCouponId)">
|
||||
<view class="dis-flex">
|
||||
<!-- 卡券图片 -->
|
||||
<view class="goods-item_left">
|
||||
<image class="image" :src="item.image"></image>
|
||||
</view>
|
||||
<view class="goods-item_right">
|
||||
<!-- 卡券名称 -->
|
||||
<view class="goods-name twolist-hidden">
|
||||
<text>{{ item.name }}</text>
|
||||
</view>
|
||||
<view class="goods-item_desc">
|
||||
<!-- 卡券卖点 -->
|
||||
<view class="desc-selling_point dis-flex">
|
||||
<text class="onelist-hidden">{{ item.sellingPoint }}</text>
|
||||
</view>
|
||||
<view class="coupon-attr">
|
||||
<view class="attr-l">
|
||||
<!-- 卡券销量 -->
|
||||
<view class="desc-goods_sales dis-flex">
|
||||
<text v-if="item.type === 'C'">已领取{{ item.gotNum }},剩余{{ item.leftNum }}</text>
|
||||
<text v-if="item.type === 'P'">已有{{ item.gotNum }}人预存</text>
|
||||
<text v-if="item.type === 'T'">已领取{{ item.gotNum }},剩余{{ item.leftNum }}</text>
|
||||
</view>
|
||||
<!-- 面额 -->
|
||||
<view v-if="item.amount > 0 && item.type === 'C'" class="desc_footer">
|
||||
<text class="price_x">¥{{ item.amount }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="attr-r">
|
||||
<!--领券按钮-->
|
||||
<view class="receive" v-if="item.type === 'C' && item.isReceive === false">
|
||||
<text v-if="!item.point || item.point < 1">立即领取</text>
|
||||
<text v-if="item.point && item.point > 0">立即兑换</text>
|
||||
</view>
|
||||
<view class="receive state" v-if="item.type === 'C' && item.isReceive === true">
|
||||
<text>已领取</text>
|
||||
</view>
|
||||
<view class="receive" v-if="item.type === 'P' && item.isReceive === false">
|
||||
<text>立即预存</text>
|
||||
</view>
|
||||
<view v-if="item.type === 'T' && item.isReceive === false" class="receive">
|
||||
<text>领取次卡</text>
|
||||
</view>
|
||||
<view v-if="item.type === 'T' && item.isReceive === true" class="receive state">
|
||||
<text>已领取</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</mescroll-body>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MescrollBody from '@/components/mescroll-uni/mescroll-body.vue'
|
||||
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins'
|
||||
import * as couponApi from '@/api/coupon'
|
||||
import { getEmptyPaginateObj, getMoreListData } from '@/utils/app'
|
||||
import Search from '@/components/search'
|
||||
import { CouponTypeEnum } from '@/common/enum/coupon'
|
||||
|
||||
const pageSize = 15
|
||||
const showViewKey = 'CouponList-ShowView';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
MescrollBody,
|
||||
Search
|
||||
},
|
||||
|
||||
mixins: [MescrollMixin],
|
||||
|
||||
data() {
|
||||
return {
|
||||
// 枚举类
|
||||
CouponTypeEnum,
|
||||
sortType: 'all', // 排序类型
|
||||
sortPrice: false, // 价格排序 (true高到低 false低到高)
|
||||
options: {}, // 当前页面参数
|
||||
list: getEmptyPaginateObj(), // 卡券列表数据
|
||||
// 正在加载
|
||||
isLoading: false,
|
||||
// 上拉加载配置
|
||||
upOption: {
|
||||
// 首次自动执行
|
||||
auto: true,
|
||||
// 每页数据的数量; 默认10
|
||||
page: { size: pageSize },
|
||||
// 数量要大于4条才显示无更多数据
|
||||
noMoreSize: 4,
|
||||
}
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
this.getCouponList(1)
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
// 记录options
|
||||
this.options = options
|
||||
// 设置默认列表显示方式
|
||||
this.setShowView()
|
||||
// 设置标题
|
||||
let type = options.type
|
||||
uni.setNavigationBarTitle({
|
||||
title: CouponTypeEnum[type].name + "中心"
|
||||
})
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* 上拉加载的回调 (页面初始化时也会执行一次)
|
||||
* 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10
|
||||
* @param {Object} page
|
||||
*/
|
||||
upCallback(page) {
|
||||
const app = this
|
||||
// 设置列表数据
|
||||
app.getCouponList(page.num)
|
||||
.then(list => {
|
||||
const curPageLen = list.content.length
|
||||
const totalSize = list.totalElements
|
||||
app.mescroll.endBySize(curPageLen, totalSize)
|
||||
})
|
||||
.catch(() => app.mescroll.endErr())
|
||||
},
|
||||
|
||||
// 设置默认列表显示方式
|
||||
setShowView() {
|
||||
this.showView = uni.getStorageSync(showViewKey) || true
|
||||
},
|
||||
|
||||
// 点击跳转到首页
|
||||
onTargetIndex() {
|
||||
this.$navTo('pages/index/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取卡券列表
|
||||
* @param {number} pageNo 页码
|
||||
*/
|
||||
getCouponList(pageNo = 1) {
|
||||
const app = this
|
||||
console.log(app.options)
|
||||
const param = {
|
||||
sortType: app.sortType,
|
||||
sortPrice: Number(app.sortPrice),
|
||||
type: app.options.type || "C",
|
||||
needPoint: app.options.needPoint || '0',
|
||||
name: app.options.search || '',
|
||||
pageNumber: pageNo
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
couponApi.list(param)
|
||||
.then(result => {
|
||||
const newList = result.data.coupon
|
||||
app.list.content = getMoreListData(newList, app.list, pageNo)
|
||||
resolve(newList)
|
||||
})
|
||||
.catch(reject)
|
||||
})
|
||||
},
|
||||
|
||||
// 切换排序方式
|
||||
handleSortType(newSortType) {
|
||||
const app = this
|
||||
const newSortPrice = newSortType === 'price' ? !app.sortPrice : true
|
||||
app.sortType = newSortType
|
||||
app.sortPrice = newSortPrice
|
||||
// 刷新列表数据
|
||||
app.list = getEmptyPaginateObj()
|
||||
app.mescroll.resetUpScroll()
|
||||
},
|
||||
|
||||
// 切换列表显示方式
|
||||
handleShowView() {
|
||||
const app = this
|
||||
app.showView = !app.showView
|
||||
uni.setStorageSync(showViewKey, app.showView)
|
||||
},
|
||||
|
||||
// 跳转详情页
|
||||
onTargetDetail(couponId, type, userCouponId) {
|
||||
if (type === 'P') {
|
||||
this.$navTo(`pages/prestore/buy`, { couponId })
|
||||
} else {
|
||||
if (type === 'C') {
|
||||
this.$navTo(`pages/coupon/detail`, { couponId: couponId, userCouponId: userCouponId })
|
||||
} else if(type === 'T'){
|
||||
this.$navTo(`pages/timer/detail`, { couponId: couponId, userCouponId: userCouponId })
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
//卡券搜索
|
||||
handleSearch() {
|
||||
const searchPageUrl = 'pages/search/index'
|
||||
// 判断来源页面
|
||||
let pages = getCurrentPages()
|
||||
if (pages.length > 1 &&
|
||||
pages[pages.length - 2].route === searchPageUrl) {
|
||||
uni.navigateBack()
|
||||
return
|
||||
}
|
||||
// 跳转到卡券搜索页
|
||||
this.$navTo(searchPageUrl)
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 设置分享内容
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
// 构建分享参数
|
||||
return {
|
||||
title: "全部卡券",
|
||||
path: "/pages/coupon/list?" + this.$getShareUrlParams()
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 分享到朋友圈
|
||||
* 本接口为 Beta 版本,暂只在 Android 平台支持,详见分享到朋友圈 (Beta)
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share-timeline.html
|
||||
*/
|
||||
onShareTimeline() {
|
||||
// 构建分享参数
|
||||
return {
|
||||
title: "全部卡券",
|
||||
path: "/pages/coupon/list?" + this.$getShareUrlParams()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
// 页面头部
|
||||
.header {
|
||||
display: block;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
height: 103rpx;
|
||||
background: #fff;
|
||||
|
||||
// 搜索框
|
||||
.search {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
// 切换显示方式
|
||||
.show-view {
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
font-size: 36rpx;
|
||||
color: #505050;
|
||||
}
|
||||
}
|
||||
|
||||
// 排序组件
|
||||
.store-sort {
|
||||
position: sticky;
|
||||
top: var(--window-top);
|
||||
display: flex;
|
||||
padding: 20rpx 0;
|
||||
font-size: 28rpx;
|
||||
background: #fff;
|
||||
color: #000;
|
||||
z-index: 99;
|
||||
|
||||
.sort-item {
|
||||
flex-basis: 33.3333%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 50rpx;
|
||||
|
||||
&.active {
|
||||
color: #e49a3d;
|
||||
}
|
||||
}
|
||||
|
||||
.sort-item-price .price-arrow {
|
||||
margin-left: 20rpx;
|
||||
font-size: 24rpx;
|
||||
color: #000;
|
||||
|
||||
.icon {
|
||||
&.active {
|
||||
color: #e49a3d;
|
||||
}
|
||||
|
||||
&.up {
|
||||
margin-bottom: -16rpx;
|
||||
}
|
||||
|
||||
&.down {
|
||||
margin-top: -16rpx;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 卡券列表
|
||||
.goods-list {
|
||||
padding: 4rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
// 空数据按钮
|
||||
.empty-ipt {
|
||||
width: 220rpx;
|
||||
margin: 10rpx auto;
|
||||
font-size: 28rpx;
|
||||
height: 64rpx;
|
||||
line-height: 64rpx;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
border-radius: 5rpx;
|
||||
background: linear-gradient(to right, $fuint-theme, $fuint-theme);
|
||||
}
|
||||
|
||||
// 单列显示
|
||||
.goods-list.column-1 {
|
||||
.goods-item {
|
||||
width: 100%;
|
||||
height: 260rpx;
|
||||
margin-bottom: 12rpx;
|
||||
padding: 20rpx;
|
||||
box-sizing: border-box;
|
||||
background: #fff;
|
||||
line-height: 1.6;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.goods-item_left {
|
||||
display: flex;
|
||||
width: 35%;
|
||||
background: #fff;
|
||||
align-items: center;
|
||||
|
||||
.image {
|
||||
display: block;
|
||||
width: 200rpx;
|
||||
height: 157rpx;
|
||||
margin-top: 20rpx;
|
||||
border-radius: 6rpx;
|
||||
border: solid 1rpx #cccccc;
|
||||
}
|
||||
}
|
||||
|
||||
.goods-item_right {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
|
||||
.goods-name {
|
||||
margin-top: 30rpx;
|
||||
height: 44rpx;
|
||||
line-height: 1.3;
|
||||
white-space: normal;
|
||||
color: #484848;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.goods-item_desc {
|
||||
margin-top: 0rpx;
|
||||
.coupon-attr {
|
||||
.attr-l {
|
||||
float: left;
|
||||
width: 70%;
|
||||
}
|
||||
.attr-r {
|
||||
margin-top: 0rpx;
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
}
|
||||
.desc-selling_point {
|
||||
width: 400rpx;
|
||||
font-size: 24rpx;
|
||||
color: #e49a3d;
|
||||
}
|
||||
.receive {
|
||||
height: 46rpx;
|
||||
width: 128rpx;
|
||||
line-height: 46rpx;
|
||||
text-align: center;
|
||||
border: 1px solid #f8df00;
|
||||
border-radius: 5rpx;
|
||||
color: #f86d48;
|
||||
background: #f8df98;
|
||||
font-size: 22rpx;
|
||||
&.state {
|
||||
border: none;
|
||||
color: #cccccc;
|
||||
background: #F5F5F5;
|
||||
}
|
||||
}
|
||||
|
||||
.desc-goods_sales {
|
||||
color: #999;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.desc_footer {
|
||||
font-size: 24rpx;
|
||||
|
||||
.price_x {
|
||||
margin-right: 16rpx;
|
||||
color: #f03c3c;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.price_y {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.goods-item {
|
||||
float: left;
|
||||
box-sizing: border-box;
|
||||
padding: 6rpx;
|
||||
|
||||
.goods-image {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 0;
|
||||
padding-bottom: 100%;
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
|
||||
&:after {
|
||||
content: '';
|
||||
display: block;
|
||||
margin-top: 100%;
|
||||
}
|
||||
|
||||
.image {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
-o-object-fit: cover;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
||||
.detail {
|
||||
padding: 8rpx;
|
||||
background: #fff;
|
||||
|
||||
.goods-name {
|
||||
height: 64rpx;
|
||||
line-height: 32rpx;
|
||||
white-space: normal;
|
||||
color: #484848;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.detail-price {
|
||||
.goods-price {
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
|
||||
.line-price {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
158
fuintUniapp/pages/coupon/receive.vue
Normal file
158
fuintUniapp/pages/coupon/receive.vue
Normal file
@@ -0,0 +1,158 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="search-wrapper">
|
||||
<view class="search-input">
|
||||
<view class="search-input-wrapper">
|
||||
<view class="right">
|
||||
<input v-model="code" class="input" placeholder="请输入卡券核销码" type="text"></input>
|
||||
</view>
|
||||
<view class="scan u-icon-wrap">
|
||||
<view class="icon" @click="doScan">
|
||||
<u-icon name="scan"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="main-form">
|
||||
<view class="footer">
|
||||
<view class="btn-wrapper">
|
||||
<view class="btn-item btn-item-main" :class="{ disabled }" @click="doSubmit()">确定兑换</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as couponApi from '@/api/coupon'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
code: '',
|
||||
// 按钮禁用
|
||||
disabled: false
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
this.code = options.code ? options.code : '';
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
/**
|
||||
* 扫码
|
||||
*/
|
||||
doScan() {
|
||||
const app = this;
|
||||
uni.scanCode({
|
||||
success: function(res) {
|
||||
app.code = res.result;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 提交兑换
|
||||
*/
|
||||
doSubmit() {
|
||||
const app = this;
|
||||
app.disabled = true;
|
||||
couponApi.receive({ 'couponId': 0, 'receiveCode': app.code })
|
||||
.then(result => {
|
||||
app.code = '';
|
||||
app.disabled = false;
|
||||
// 显示提示
|
||||
if (parseInt(result.code) === 200) {
|
||||
app.$success("兑换成功!");
|
||||
} else {
|
||||
app.$error(result.message);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.container {
|
||||
padding: 20rpx;
|
||||
min-height: 100vh;
|
||||
background: #f7f7f7;
|
||||
}
|
||||
|
||||
.search-wrapper {
|
||||
display: flex;
|
||||
height: 100rpx;
|
||||
margin-top: 80rpx;
|
||||
padding: 0 5rpx;
|
||||
}
|
||||
|
||||
// 搜索输入框
|
||||
.search-input {
|
||||
width: 100%;
|
||||
background: #fff;
|
||||
border-radius: 10rpx 0 0 10rpx;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
.search-input-wrapper {
|
||||
display: flex;
|
||||
.right {
|
||||
flex: 1;
|
||||
input {
|
||||
font-size: 30rpx;
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
padding-left: 30rpx;
|
||||
.input-placeholder {
|
||||
color: #aba9a9;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.scan {
|
||||
display: flex;
|
||||
width: 60rpx;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
.icon {
|
||||
display: block;
|
||||
color: #b4b4b4;
|
||||
font-size: 48rpx;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
/* 底部操作栏 */
|
||||
.footer {
|
||||
margin-top: 100rpx;
|
||||
.btn-wrapper {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 5rpx;
|
||||
}
|
||||
.btn-item {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
border-radius: 40rpx;
|
||||
}
|
||||
|
||||
.btn-item-main {
|
||||
background: linear-gradient(to right, #f9211c, #ff6335);
|
||||
// 禁用按钮
|
||||
&.disabled {
|
||||
background: #ff9779;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user