同步代码
This commit is contained in:
178
pageCoupon/components/select-goods.vue
Normal file
178
pageCoupon/components/select-goods.vue
Normal file
@@ -0,0 +1,178 @@
|
||||
<template>
|
||||
<up-popup :show="show" @close="close" round="20" mode="bottom">
|
||||
<view class="head">
|
||||
<text></text>
|
||||
<text class="title">请选择</text>
|
||||
<up-icon @tap="close" name="close-circle-fill" color="#333" size="20"></up-icon>
|
||||
</view>
|
||||
<view class="content">
|
||||
<view class="category">
|
||||
<view class="category_item" @tap="itemClick(item,index)" :class="{active:index===category.active}" v-for="(item,index) in category.list" :key="index">{{item.name}}</view>
|
||||
</view>
|
||||
<up-radio-group v-model="goodsValue" @change="groupChange" style="width: 100%;display: initial;">
|
||||
<view class="goodsList">
|
||||
<view class="goodsItem" @tap="goodsClick(item,index)" v-for="(item,index) in category.goodsList" :key="index">
|
||||
<view>{{item.name}}</view>
|
||||
<up-radio
|
||||
:key="item.id"
|
||||
:name="item.id"
|
||||
@change="groupChange"
|
||||
>
|
||||
</up-radio>
|
||||
</view>
|
||||
</view>
|
||||
</up-radio-group>
|
||||
</view>
|
||||
<view class="bomBtn">
|
||||
<view class="affirm" @tap="affirm">确定</view>
|
||||
</view>
|
||||
</up-popup>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive,ref,onMounted } from 'vue';
|
||||
import {
|
||||
$tbShopCategory,
|
||||
$tbProductV2
|
||||
} from "@/http/yskApi/goods.js"
|
||||
const props=defineProps({
|
||||
show:{
|
||||
type:Boolean,
|
||||
default:false
|
||||
}
|
||||
})
|
||||
const emits=defineEmits(['itemClick','close', "affirm"])
|
||||
const category=reactive({
|
||||
list:[],
|
||||
goodsList:[],
|
||||
active: 0,
|
||||
query: {
|
||||
page: 0,
|
||||
size: 999,
|
||||
categoryId: '',
|
||||
sort: "createdAt,desc",
|
||||
}
|
||||
})
|
||||
let goodsValue = ref('');
|
||||
let show=ref(false)
|
||||
|
||||
function itemClick(item,index){
|
||||
category.active = index;
|
||||
category.query.categoryId = item.id;
|
||||
getGoodsList()
|
||||
}
|
||||
function goodsClick (item,index) {
|
||||
goodsValue.value = item.id;
|
||||
}
|
||||
function groupChange ( n ) {
|
||||
// console.log(n)
|
||||
}
|
||||
function getCategoryList () {
|
||||
$tbShopCategory({
|
||||
page:0,size:200
|
||||
}).then(res=>{
|
||||
category.list = res.content;
|
||||
category.query.categoryId = res.content[0].id
|
||||
getGoodsList()
|
||||
})
|
||||
}
|
||||
function getGoodsList () {
|
||||
$tbProductV2(category.query).then(res => {
|
||||
category.goodsList = res.content.map(v => {
|
||||
return {
|
||||
...v,
|
||||
isSellNone: false,
|
||||
checked: false,
|
||||
showDetail: false
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
function open(){
|
||||
show.value = true;
|
||||
getCategoryList();
|
||||
}
|
||||
|
||||
function close(){
|
||||
show.value = false;
|
||||
category.active = 0;
|
||||
goodsValue.value = "";
|
||||
emits('close')
|
||||
}
|
||||
/**
|
||||
* 确认
|
||||
*/
|
||||
function affirm() {
|
||||
let item;
|
||||
category.goodsList.forEach((v,e)=>{
|
||||
if ( v.id == goodsValue.value) {
|
||||
item = v;
|
||||
}
|
||||
})
|
||||
emits('affirm',item)
|
||||
close();
|
||||
}
|
||||
defineExpose({
|
||||
open,close,affirm
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.head{
|
||||
display: flex;
|
||||
padding: 32rpx 28rpx;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
.title{
|
||||
font-weight: bold;
|
||||
font-size: 32rpx;
|
||||
color: #333333;
|
||||
}
|
||||
}
|
||||
.content{
|
||||
display: flex;
|
||||
height: 672rpx;
|
||||
.category{
|
||||
min-width: 316rpx;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
background: #F9F9F9;
|
||||
.category_item{
|
||||
padding: 22rpx 24rpx;
|
||||
border-left: 8rpx solid transparent;
|
||||
}
|
||||
.active{
|
||||
border-left: 8rpx solid #318AFE;
|
||||
background-color: #fff;
|
||||
}
|
||||
}
|
||||
.goodsList{
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.goodsItem{
|
||||
width: 100%;
|
||||
padding: 22rpx 24rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
}
|
||||
}
|
||||
.bomBtn{
|
||||
padding: 16rpx 38rpx 32rpx 38rpx;
|
||||
background-color: #fff;
|
||||
.affirm{
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
text-align: center;
|
||||
background: #318AFE;
|
||||
border-radius: 12rpx 12rpx 12rpx 12rpx;
|
||||
font-weight: 500;
|
||||
font-size: 32rpx;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
330
pageCoupon/discountCoupons.vue
Normal file
330
pageCoupon/discountCoupons.vue
Normal file
@@ -0,0 +1,330 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<view class="card">
|
||||
<view class="item">
|
||||
<view class="lable">优惠券名称</view>
|
||||
<view class="value">
|
||||
<up-input v-model="formData.title" placeholder="填写名称" border="none" clearable ></up-input>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<view class="lable">使用门槛2</view>
|
||||
<view class="value">
|
||||
<view>满</view><input v-model="formData.fullAmount" type="number" placeholder="填写金额" border="none"></input><view>元</view>,<view>减</view><input v-model="formData.discountAmount" type="number" placeholder="填写金额" border="none"></input><view>元</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="card">
|
||||
<view class="item">
|
||||
<view class="lable">有效期类型</view>
|
||||
<view class="value" style="display: flex;flex-direction: column;align-items: flex-start;">
|
||||
<view>
|
||||
<up-radio-group v-model="formData.validityType" @change="typeChange('validityType')">
|
||||
<up-radio name="fixed" label="领券后有效期内可用" style="margin-right: 30rpx;"></up-radio>
|
||||
<up-radio name="custom" label="固定有效期范围内可用"></up-radio>
|
||||
</up-radio-group>
|
||||
</view>
|
||||
<view class="date" v-if="formData.validityType=='custom'">
|
||||
<!-- {{formData.useStartTime +'—'+ formData.useEndTime}} -->
|
||||
<view @click="typeChange('validityType')">{{ formData.validStartTime || '开始时间'}}</view>--
|
||||
<view @click="typeChange('validityType')">{{ formData.validEndTime || '结束时间'}}</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<view class="lable">有效期(天)</view>
|
||||
<view class="value">
|
||||
<up-input v-model="formData.validDays" type="number" placeholder="填写天数" border="none"></up-input>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<view class="lable">隔天生效
|
||||
<!-- <up-icon @click="modalShow(1)" name="question-circle" color="#999" size="20" style="margin-left: 10rpx;"></up-icon> -->
|
||||
</view>
|
||||
<view class="value">
|
||||
<view>隔</view><input v-model="formData.daysToTakeEffect" type="number" placeholder="填写天数" border="none" ></input><view>天生效</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<view class="lable">可用日期</view>
|
||||
<view class="value">
|
||||
<up-checkbox-group v-model="formData.userDays" placement="row" @change="checkboxChange" >
|
||||
<up-checkbox
|
||||
:customStyle="{marginBottom: '8px',marginRight: '15px'}"
|
||||
v-for="(item, index) in pageData.value"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:name="item.name"
|
||||
>
|
||||
</up-checkbox>
|
||||
</up-checkbox-group>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<view class="lable">指定时间段可用</view>
|
||||
<view class="value" style="display: flex;flex-direction: column;align-items: flex-start;">
|
||||
<view>
|
||||
<up-radio-group v-model="formData.useTimeType" >
|
||||
<up-radio name="all" label="全时段可用" style="margin-right: 30rpx;"></up-radio>
|
||||
<up-radio name="custom" label="指定时段可用"></up-radio>
|
||||
</up-radio-group>
|
||||
</view>
|
||||
<view class="time" v-if="formData.useTimeType=='custom'">
|
||||
<!-- {{formData.useStartTime +'—'+ formData.useEndTime}} -->
|
||||
<view @click="useTimeChange('useStartTime')">{{ formData.useStartTime || '开始时间'}}</view>--
|
||||
<view @click="useTimeChange('useEndTime')">{{ formData.useEndTime || '结束时间'}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="card">
|
||||
<view class="item">
|
||||
<view class="lable">总发放数量
|
||||
<!-- <up-icon @click="modalShow(2)" name="question-circle" color="#999" size="20" style="margin-left: 10rpx;"></up-icon> -->
|
||||
</view>
|
||||
<view class="value">
|
||||
<up-input v-model="formData.number" placeholder="填写数量" border="none" clearable ></up-input>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="bottomPop">
|
||||
<button @click="save">保存</button>
|
||||
</view>
|
||||
<up-datetime-picker
|
||||
:show="pageData.useTimeShow"
|
||||
v-model="pageData.useTime"
|
||||
mode="time"
|
||||
@cancel="timeCancel"
|
||||
@confirm="timeConfirm"
|
||||
></up-datetime-picker>
|
||||
<my-date-pickerview @confirm="datePickerConfirm" :mode="pageData.mode" ref="datePicker"></my-date-pickerview>
|
||||
<up-modal :show="pageData.show" :title="pageData.title" @confirm="pageData.show = false" ></up-modal>
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import go from '@/commons/utils/go.js'
|
||||
import {
|
||||
reactive,
|
||||
ref
|
||||
} from 'vue';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import { getTbShopCouponInfo, addTbShopCoupon } from '@/http/yskApi/coupon.js'
|
||||
const pageData = reactive({
|
||||
value: [
|
||||
{ name: "周一", },
|
||||
{ name: "周二", },
|
||||
{ name: "周三", },
|
||||
{ name: "周四", },
|
||||
{ name: "周五", },
|
||||
{ name: "周六", },
|
||||
{ name: "周日", },
|
||||
],
|
||||
mode: "",
|
||||
title: "",
|
||||
show: false,
|
||||
useTimeShow: false,
|
||||
useTime: "",
|
||||
dateType: "",
|
||||
sueDateType: "",
|
||||
})
|
||||
const formData = reactive({
|
||||
type: '1',
|
||||
title: '',
|
||||
fullAmount: null,
|
||||
discountAmount: null,
|
||||
validityType: 'fixed',
|
||||
validStartTime: '',
|
||||
validEndTime: '',
|
||||
userDays: [],
|
||||
useTimeType: 'all',
|
||||
useStartTime: '',
|
||||
useEndTime: '',
|
||||
validDays: null,
|
||||
daysToTakeEffect: null,
|
||||
number: null,
|
||||
})
|
||||
onLoad((options) => {
|
||||
if ( options.type == 'info' ) {
|
||||
pageData.id = options.id;
|
||||
getConponInfo();
|
||||
}
|
||||
})
|
||||
let datePicker = ref(null)
|
||||
let refTime = ref(null)
|
||||
|
||||
/**
|
||||
* 查看生效时间/发放数量提示
|
||||
*/
|
||||
let modalShow = ( type ) => {
|
||||
if ( type == 1) {
|
||||
pageData.title = "领取后0天后的0点0分生效";
|
||||
} else {
|
||||
pageData.title = "限用户自行领取,(当库存为 0时,集草等活动仍会赠送)";
|
||||
}
|
||||
pageData.show = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取详情
|
||||
*/
|
||||
let getConponInfo = () => {
|
||||
getTbShopCouponInfo(pageData.id).then((res) => {
|
||||
// formData = res;
|
||||
for (let item in res) {
|
||||
formData[item] = res[item]
|
||||
}
|
||||
formData.userDays = formData.userDays.split(",");
|
||||
console.log(formData)
|
||||
})
|
||||
}
|
||||
|
||||
let typeChange = ( type ) =>{
|
||||
pageData.dateType = type;
|
||||
pageData.mode = 'date'
|
||||
|
||||
if ( formData.validityType == "custom") {
|
||||
datePicker.value.open()
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 指定时间段选择
|
||||
*/
|
||||
let useTimeChange = ( type ) => {
|
||||
console.log(type)
|
||||
pageData.sueDateType = type;
|
||||
pageData.mode = 'time';
|
||||
pageData.useTimeShow = true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭时间段弹窗
|
||||
*/
|
||||
let timeCancel = () => {
|
||||
pageData.useTimeShow = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认时间端选择
|
||||
*/
|
||||
let timeConfirm = () => {
|
||||
pageData.useTimeShow = false;
|
||||
console.log(pageData.useTime)
|
||||
if ( pageData.sueDateType == 'useStartTime') { formData.useStartTime = pageData.useTime}
|
||||
if ( pageData.sueDateType == 'useEndTime') { formData.useEndTime = pageData.useTime}
|
||||
}
|
||||
|
||||
/**
|
||||
* 有效期选择
|
||||
*/
|
||||
let datePickerConfirm = (data) => {
|
||||
console.log(pageData.dateType)
|
||||
if ( pageData.dateType == 'validityType') {
|
||||
// .substring(0,10)
|
||||
formData.validStartTime = data.start;
|
||||
formData.validEndTime = data.end;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
let save = () => {
|
||||
formData.userDays = formData.userDays.toString();
|
||||
let params = {
|
||||
...formData
|
||||
}
|
||||
console.log(params)
|
||||
addTbShopCoupon(params).then((res) => {
|
||||
// console.log(res)
|
||||
go.back(1)
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
.content {
|
||||
background: #F9F9F9;
|
||||
padding: 32rpx 28rpx 150rpx 28rpx;
|
||||
|
||||
.card{
|
||||
padding: 32rpx 24rpx;
|
||||
background-color: #fff;
|
||||
margin-bottom: 32rpx;
|
||||
.item{
|
||||
padding-bottom: 24rpx;
|
||||
border-bottom: 2rpx solid #E5E5E5;
|
||||
margin-bottom: 24rpx;
|
||||
.lable{
|
||||
font-weight: bold;
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
margin-bottom: 16rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.value{
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
input{
|
||||
width: 150rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.date,.time{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-weight: 400;
|
||||
font-size: 26rpx;
|
||||
color: #999999;
|
||||
margin-top: 10rpx;
|
||||
view{
|
||||
border: 1rpx solid #999;
|
||||
padding: 10rpx 20rpx;
|
||||
border-radius: 10rpx
|
||||
}
|
||||
view:nth-child(1){
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
view:nth-child(2){
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
}
|
||||
.time{
|
||||
view{
|
||||
padding: 10rpx 30rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.item:last-child{
|
||||
border-bottom: none;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
.bottomPop{
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
height: 150rpx;
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
z-index: 9;
|
||||
>button {
|
||||
width: 530rpx;
|
||||
margin: 30rpx 0;
|
||||
margin-left: 50%;
|
||||
transform: translateX(-50%);
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
color: #fff;
|
||||
background: #318AFE;
|
||||
border-radius: 56rpx 56rpx 56rpx 56rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
206
pageCoupon/editCertificate.vue
Normal file
206
pageCoupon/editCertificate.vue
Normal file
@@ -0,0 +1,206 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<view class="card">
|
||||
<view class="item">
|
||||
<view class="lable">商品兑换券名称</view>
|
||||
<view class="value">
|
||||
<up-input v-model="formData.title" placeholder="填写名称" border="none" clearable ></up-input>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<view class="lable">使用门槛</view>
|
||||
<view class="value">
|
||||
<view>满</view><input v-model="formData.fullAmount" type="number" placeholder="填写金额" border="none"></input><view>元,可用</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<view class="lable">总发放数量</view>
|
||||
<view class="value">
|
||||
<up-input v-model="formData.number" type="number" placeholder="填写数量" border="none" clearable ></up-input>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="card">
|
||||
|
||||
<view class="item">
|
||||
<view class="lable">指定抵扣商品</view>
|
||||
<view class="value">
|
||||
<view class="selectGoods" @tap="selectGoodsOpen">
|
||||
<view>
|
||||
<view class="title">选择商品</view>
|
||||
<view class="goodsName" v-if='formData.products.length <= 0'>选择指定商品</view>
|
||||
<view class="goodsName" v-else>
|
||||
<view class="goodsItem" v-for="(item,index) in formData.products" :key="index">
|
||||
<view class="productName">{{item.name}}</view><up-input @tap.stop="stop" style="border-bottom: 1rpx solid #666;" v-model="item.num" placeholder="填写数量" border="none" ></up-input>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<up-icon name="arrow-right" color="#9F9F9F" size="22"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
|
||||
<view class="bottomPop">
|
||||
<button @click="save">保存</button>
|
||||
</view>
|
||||
|
||||
<select-goods ref="goods" @affirm="affirm"></select-goods>
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import go from '@/commons/utils/go.js'
|
||||
import myActionSheet from '@/components/my-components/my-action-sheet';
|
||||
import selectGoods from './components/select-goods';
|
||||
import { getTbShopCouponInfo, addTbShopCoupon } from '@/http/yskApi/coupon.js'
|
||||
import { reactive, ref } from 'vue';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
const pageData = reactive({
|
||||
id: null,
|
||||
goodsData: null,
|
||||
title: "",
|
||||
show: false,
|
||||
})
|
||||
let formData = reactive({
|
||||
title: "",
|
||||
type: '2',
|
||||
fullAmount: null,
|
||||
number: null,
|
||||
products: []
|
||||
})
|
||||
|
||||
onLoad((options) => {
|
||||
if ( options.type == 'info' ) {
|
||||
pageData.id = options.id;
|
||||
getConponInfo();
|
||||
}
|
||||
})
|
||||
|
||||
let goods = ref(null)
|
||||
let selectGoodsOpen = () => {
|
||||
goods.value.open();
|
||||
}
|
||||
|
||||
let getConponInfo = () => {
|
||||
getTbShopCouponInfo(pageData.id).then((res) => {
|
||||
// formData = res;
|
||||
for (let item in res) {
|
||||
formData[item] = res[item]
|
||||
}
|
||||
console.log(formData)
|
||||
})
|
||||
}
|
||||
|
||||
let stop = () => { }
|
||||
|
||||
let affirm = (item) => {
|
||||
pageData.goodsData = item;
|
||||
formData.products = [];
|
||||
formData.products.push({
|
||||
productId: item.id,
|
||||
name: item.name,
|
||||
num: null
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
let save = () => {
|
||||
let params = {
|
||||
...formData
|
||||
}
|
||||
addTbShopCoupon(params).then((res) => {
|
||||
go.back(1)
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
.content {
|
||||
background: #F9F9F9;
|
||||
padding: 32rpx 28rpx 150rpx 28rpx;
|
||||
|
||||
.card{
|
||||
padding: 32rpx 24rpx;
|
||||
background-color: #fff;
|
||||
margin-bottom: 32rpx;
|
||||
.item{
|
||||
padding-bottom: 24rpx;
|
||||
border-bottom: 2rpx solid #E5E5E5;
|
||||
margin-bottom: 24rpx;
|
||||
.lable{
|
||||
font-weight: bold;
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
margin-bottom: 16rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.value{
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
input{
|
||||
width: 150rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.selectGoods{
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 32rpx 16rpx;
|
||||
background: #F9F9F9;
|
||||
border-radius: 12rpx 12rpx 12rpx 12rpx;
|
||||
.title{
|
||||
font-weight: bold;
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
.goodsName{
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
}
|
||||
.goodsItem{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.productName{
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.item:last-child{
|
||||
border-bottom: none;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
.bottomPop{
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
height: 150rpx;
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
>button {
|
||||
width: 530rpx;
|
||||
margin: 30rpx 0;
|
||||
margin-left: 50%;
|
||||
transform: translateX(-50%);
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
color: #fff;
|
||||
background: #318AFE;
|
||||
border-radius: 56rpx 56rpx 56rpx 56rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
408
pageCoupon/index.vue
Normal file
408
pageCoupon/index.vue
Normal file
@@ -0,0 +1,408 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 顶部菜单 -->
|
||||
<view class="tagClass">
|
||||
<view class="tag-item" @tap="tagClick(item)" :class="{active:item.type===pageData.query.type}"
|
||||
v-for="(item,index) in pageData.status.list" :key="index">
|
||||
{{item.name}}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 搜搜 -->
|
||||
<!-- <view class="search">
|
||||
<up-input
|
||||
placeholder="搜索优惠券名称"
|
||||
prefixIcon="search"
|
||||
shape="circle"
|
||||
border="none"
|
||||
fontSize="14px"
|
||||
prefixIconStyle="font-size: 28px;color: #999;"
|
||||
:customStyle="{backgroundColor:'#F9F9F9',padding: '10rpx 18rpx'}"
|
||||
></up-input>
|
||||
<view class="searchBtn">
|
||||
搜索
|
||||
</view>
|
||||
</view> -->
|
||||
<!-- 内容 -->
|
||||
<view class="couponContentList">
|
||||
<view class="couponContent" v-for="(item,index) in pageData.couponList" :key="index">
|
||||
|
||||
<view class="couponContentListTop">
|
||||
<view class="title"> {{ item.title }} </view>
|
||||
<view> ID:{{item.id}} </view>
|
||||
</view>
|
||||
<view class="couponContentListcontent">
|
||||
<view>
|
||||
<view> 使用门槛 </view>
|
||||
<view v-if="item.type == 1"> 满 {{ item.fullAmount }} 元减 {{ item.discountAmount }} 元 </view>
|
||||
<view v-if="item.type == 2"> 满 {{ item.fullAmount }} 元可用 </view>
|
||||
</view>
|
||||
<!-- <view>
|
||||
<view> 领取方式 </view>
|
||||
<view> 用户不可自行领取 </view>
|
||||
</view> -->
|
||||
<view v-if="item.type == 1">
|
||||
<view> 有效期 </view>
|
||||
<view> 领券后{{ item.validDays }}天过期 </view>
|
||||
</view>
|
||||
<view class="JQclass">
|
||||
<image :src="'/static/coupon/qrcode.svg'" mode="scaleToFill" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="couponContentListcontent2">
|
||||
<view class="">
|
||||
<view class="num"> {{ item.number }} </view>
|
||||
<view class="lable"> 发放数量 </view>
|
||||
</view>
|
||||
<view class="">
|
||||
<view class="num"> {{ item.number-item.leftNumber }} </view>
|
||||
<view class="lable"> 已领取 </view>
|
||||
</view>
|
||||
<view class="">
|
||||
<view class="num"> {{ item.leftNumber }} </view>
|
||||
<view class="lable"> 剩余 </view>
|
||||
</view>
|
||||
<view class="">
|
||||
<view class="num"> {{ item.useNumber }} </view>
|
||||
<view class="lable"> 已使用 </view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="couponContentListbottom">
|
||||
<button @tap="editCoupon(item)">编辑</button>
|
||||
<button @tap="delCoupon(item)">删除</button>
|
||||
</view>
|
||||
</view>
|
||||
<template v-if="pageData.couponList.length">
|
||||
<my-pagination :page="pageData.query.page" :totalElements="pageData.totalElements" :size="pageData.query.size"
|
||||
@change="pageChange"></my-pagination>
|
||||
</template>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="bottomPop">
|
||||
<button @click="addCoupon">+添加{{pageData.status.tagName}}</button>
|
||||
</view>
|
||||
<up-modal :show="pageData.delShow" title="确认是否删除当前优惠券" @confirm="delConfirm" @cancel="pageData.delShow=false" showCancelButton></up-modal>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import go from '@/commons/utils/go.js'
|
||||
import { getTbShopCoupon , delTbShopCoupon} from '@/http/yskApi/coupon.js'
|
||||
import {
|
||||
reactive,
|
||||
ref,
|
||||
onMounted
|
||||
} from 'vue';
|
||||
import { onLoad, onShow,onPageScroll,
|
||||
onPullDownRefresh,
|
||||
onReachBottom, } from '@dcloudio/uni-app';
|
||||
const pageData = reactive({
|
||||
delShow: false,
|
||||
delItem: null,
|
||||
status: {
|
||||
list: [
|
||||
{name: '优惠券', type: 1},
|
||||
{name: '商品兑换券', type: 2},
|
||||
],
|
||||
tagName: "优惠券",
|
||||
active: 0,
|
||||
},
|
||||
query: {
|
||||
type: 1,
|
||||
page: 1,
|
||||
size: 10,
|
||||
},
|
||||
couponList: [],
|
||||
totalElements: 0,
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
getCoupon();
|
||||
})
|
||||
|
||||
onReachBottom(() => {
|
||||
// pageData.query.page++
|
||||
// getCoupon()
|
||||
})
|
||||
|
||||
/**
|
||||
* tag切换
|
||||
*/
|
||||
let tagClick = ( item ) => {
|
||||
pageData.query.type = item.type;
|
||||
pageData.status.tagName = item.name;
|
||||
pageData.query.page = 1;
|
||||
getCoupon();
|
||||
}
|
||||
|
||||
// 获取优惠券列表
|
||||
let getCoupon = () => {
|
||||
let params = pageData.query;
|
||||
getTbShopCoupon(params).then((res) => {
|
||||
console.log(res)
|
||||
pageData.couponList = res.content;
|
||||
pageData.totalElements = res.totalElements;
|
||||
})
|
||||
}
|
||||
// 页数改变事件
|
||||
function pageChange(page) {
|
||||
console.log(page)
|
||||
pageData.query.page = page
|
||||
getCoupon()
|
||||
}
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
let addCoupon = ()=>{
|
||||
if ( pageData.query.type == 1 ) {
|
||||
go.to('PAGES_COUPON_DISCOUNTCOUPONS')
|
||||
} else {
|
||||
go.to('PAGES_COUPON_CERTIFICATE')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
let editCoupon = (item)=>{
|
||||
console.log(item.id)
|
||||
if ( item.type == 1 ) {
|
||||
go.to('PAGES_COUPON_DISCOUNTCOUPONS',{type: 'info', id: item.id})
|
||||
} else {
|
||||
go.to('PAGES_COUPON_CERTIFICATE',{type: 'info', id: item.id})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
let delCoupon = (item) => {
|
||||
pageData.delShow = true;
|
||||
pageData.delItem = item;
|
||||
}
|
||||
let delConfirm = () => {
|
||||
pageData.delShow = false;
|
||||
delTbShopCoupon([pageData.delItem.id]).then((res) => {
|
||||
getCoupon();
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang='scss'>
|
||||
body{
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
.container{
|
||||
position: relative;
|
||||
}
|
||||
.tagClass {
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
padding-top: 44rpx;
|
||||
padding: 32rpx 28rpx;
|
||||
background-color: #fff;
|
||||
position: fixed;
|
||||
top: 0rpx;
|
||||
z-index: 999;
|
||||
.tag-item {
|
||||
display: inline-block;
|
||||
padding: 10rpx 24rpx;
|
||||
margin-right: 32rpx;
|
||||
border-radius: 4rpx 4rpx 4rpx 4rpx;
|
||||
text-align: center;
|
||||
font-weight: 400;
|
||||
font-size: 28rpx;
|
||||
color: #666666;
|
||||
background: #F7F7FA;
|
||||
|
||||
&.active {
|
||||
background: #E6F0FF;
|
||||
color: #318AFE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tagClass::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.search {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 32rpx;
|
||||
background-color: #fff;
|
||||
margin-bottom: 32rpx;
|
||||
.inputsearch {
|
||||
color: #999999;
|
||||
width: 542rpx;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
background: #F9F9F9;
|
||||
border-radius: 32rpx 32rpx 32rpx 32rpx;
|
||||
}
|
||||
|
||||
.searchBtn {
|
||||
width: 120rpx;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
margin-left: 32rpx;
|
||||
text-align: center;
|
||||
color: #FFFFFF;
|
||||
background: #318AFE;
|
||||
border-radius: 32rpx 32rpx 32rpx 32rpx;
|
||||
}
|
||||
}
|
||||
.couponContentList {
|
||||
/* width: 694rpx; */
|
||||
/* height: 544rpx; */
|
||||
margin: 32rpx auto 0;
|
||||
margin-bottom: 32rpx;
|
||||
padding: 70rpx 28rpx 182rpx 28rpx;
|
||||
}
|
||||
.couponContent {
|
||||
/* background-color: #f9f9f9; */
|
||||
border-radius: 18rpx 18rpx 18rpx 18rpx;
|
||||
background: #FFFFFF;
|
||||
padding: 32rpx 24rpx;
|
||||
margin-bottom: 32rpx;
|
||||
.couponContentListTop {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.title{
|
||||
font-weight: bold;
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
>view:last-child {
|
||||
width: 98rpx;
|
||||
height: 36rpx;
|
||||
line-height: 36rpx;
|
||||
text-align: center;
|
||||
background: #F7F7FA;
|
||||
border-radius: 4rpx 4rpx 4rpx 4rpx;
|
||||
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: 500;
|
||||
font-size: 18rpx;
|
||||
color: #999999;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.couponContentListcontent {
|
||||
margin-top: 24rpx;
|
||||
padding-top: 1rpx;
|
||||
width: 646rpx;
|
||||
height: 228rpx;
|
||||
background: #F9F9F9;
|
||||
border-radius: 12rpx 12rpx 12rpx 12rpx;
|
||||
position: relative;
|
||||
|
||||
>view {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 12rpx;
|
||||
|
||||
>view:first-child {
|
||||
width: 180rpx;
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
>view:last-child {
|
||||
margin-left: 48rpx;
|
||||
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
color: #333333;
|
||||
line-height: 0rpx;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.JQclass {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
/* background-color: #318AFE; */
|
||||
position: absolute;
|
||||
right: 48rpx;
|
||||
top: 90rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.couponContentListcontent2 {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
text-align: center;
|
||||
padding-top: 24rpx;
|
||||
.num{
|
||||
font-weight: bold;
|
||||
font-size: 24rpx;
|
||||
color: #333333;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
.lable{
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
}
|
||||
}
|
||||
|
||||
.couponContentListbottom {
|
||||
margin-top: 24rpx;
|
||||
overflow: hidden;
|
||||
>button {
|
||||
float: right;
|
||||
width: 140rpx;
|
||||
height: 56rpx;
|
||||
margin-left: 22rpx;
|
||||
line-height: 56rpx;
|
||||
text-align: center;
|
||||
color: #999;
|
||||
background: #F7F7FA;
|
||||
border-radius: 28rpx 28rpx 28rpx 28rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
>button:first-child {
|
||||
background-color: #318afe;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
.couponContent:last-of-type{
|
||||
/* margin-bottom: 150rpx; */
|
||||
}
|
||||
|
||||
.bottomPop {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
height: 150rpx;
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
|
||||
>button {
|
||||
width: 530rpx;
|
||||
margin: 30rpx 0;
|
||||
margin-left: 50%;
|
||||
transform: translateX(-50%);
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
color: #fff;
|
||||
background: #318AFE;
|
||||
border-radius: 56rpx 56rpx 56rpx 56rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user