提交优惠券,积分修改(领券部分没做)
This commit is contained in:
parent
34c2cb76e7
commit
9bc3cb5584
1
app.json
1
app.json
@ -28,7 +28,6 @@
|
||||
"pages/aid/law/index",
|
||||
"pages/aid/detail/index",
|
||||
"pages/aid/consult/index",
|
||||
"pages/ticket/index",
|
||||
"pages/integral/index",
|
||||
"pages/discountCoupon/index",
|
||||
"pages/integralRecord/index"
|
||||
|
@ -1,3 +1,8 @@
|
||||
import { alertInfo, alertSuccess, loadingFunc } from "../../utils/index"
|
||||
import { redeemCoupons } from "../../service/system";
|
||||
import request from "../../utils/request"
|
||||
const { OK } = request;
|
||||
|
||||
// components/discountCoupon/index.js
|
||||
Component({
|
||||
|
||||
@ -5,7 +10,8 @@ Component({
|
||||
* 组件的属性列表
|
||||
*/
|
||||
properties: {
|
||||
|
||||
type: Number,
|
||||
data: Object
|
||||
},
|
||||
|
||||
/**
|
||||
@ -20,7 +26,22 @@ Component({
|
||||
*/
|
||||
methods: {
|
||||
handleUse() {
|
||||
|
||||
alertInfo("敬请期待")
|
||||
},
|
||||
handleChange() {
|
||||
const { data } = this.data;
|
||||
const that = this;
|
||||
loadingFunc(async () => {
|
||||
console.log("--------------========", data)
|
||||
const { code, message } = await redeemCoupons({ id: data.id, type: 2 })
|
||||
console.log("code", code, 'message', message)
|
||||
if (code !== OK) {
|
||||
alertInfo(message)
|
||||
return
|
||||
}
|
||||
alertSuccess("兑换成功")
|
||||
this.triggerEvent("change", { id, type: 2 })
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
@ -5,28 +5,33 @@
|
||||
<view class="top">
|
||||
<view class="left">
|
||||
<view class="typeText">
|
||||
通用优惠券
|
||||
<text wx:if="{{data.type === 0}}"> 通用优惠券 </text>
|
||||
<text wx:if="{{data.type === 1}}"> 无门槛优惠券 </text>
|
||||
<text wx:if="{{data.type === 2}}"> 满减券 </text>
|
||||
</view>
|
||||
<view class="time">
|
||||
有效期至2024.12.01
|
||||
有效期至 {{ data.endTime }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="right">
|
||||
<view class="price">
|
||||
<text style="font-size: 26rpx;line-height: 26rpx;"> ¥ </text>
|
||||
<view class="number"> 30 </view>
|
||||
<view class="number" wx:if="{{data.discount > 0}}"> {{ data.discount }} 折 </view>
|
||||
<view class="number" wx:elif="{{data.discountMoney > 0}}"> {{ data.discountMoney }} 元 </view>
|
||||
<view wx:else> - </view>
|
||||
</view>
|
||||
<view class="limit">
|
||||
满30可用
|
||||
满 {{ data.useMin }} 可用
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="bottom">
|
||||
<view class="left">
|
||||
仅限商城使用
|
||||
|
||||
</view>
|
||||
<view class="right">
|
||||
<van-button type="info" size="small" bind:tap="handleUse">去使用</van-button>
|
||||
<van-button wx:if="{{type === 1}}" type="info" size="small" bind:tap="handleUse">去领取</van-button>
|
||||
<van-button wx:if="{{type === 2}}" type="info" size="small" bind:tap="handleChange">去兑换</van-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
@ -1,11 +1,18 @@
|
||||
// pages/discountCoupon/index.js
|
||||
|
||||
import request from "../../utils/request"
|
||||
import { getCurrentCoupons, getCurrentIntegral, getRedeemableCoupons } from "../../service/system";
|
||||
import { alertInfo, loadingFunc } from "../../utils/index";
|
||||
const { OK } = request;
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
currentList: [],
|
||||
canGetList: [],
|
||||
},
|
||||
|
||||
/**
|
||||
@ -28,7 +35,32 @@ Page({
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
async getCurrent() {
|
||||
const that = this;
|
||||
loadingFunc(async() => {
|
||||
const { code, message, data = [], } = await getCurrentCoupons();
|
||||
if (code !== OK) {
|
||||
alertInfo(message)
|
||||
return
|
||||
}
|
||||
that.setData({
|
||||
currentList: data
|
||||
})
|
||||
})
|
||||
},
|
||||
getCanGet() {
|
||||
const that = this;
|
||||
loadingFunc(async() => {
|
||||
const { code, message, data = [], } = await getRedeemableCoupons({ type: 1 });
|
||||
if (code !== OK) {
|
||||
alertInfo(message)
|
||||
return
|
||||
}
|
||||
that.setData({
|
||||
currentList: data
|
||||
})
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
|
@ -1,6 +1,8 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigator": "/components/navigator/index"
|
||||
"navigator": "/components/navigator/index",
|
||||
"van-tab": "@vant/weapp/tab/index",
|
||||
"van-tabs": "@vant/weapp/tabs/index"
|
||||
},
|
||||
"navigationStyle": "custom"
|
||||
}
|
@ -1,2 +1,16 @@
|
||||
<!--pages/discountCoupon/index.wxml-->
|
||||
<navigator title="我的优惠券" canBack="{{true}}" />
|
||||
<navigator title="我的优惠券" canBack="{{true}}" />
|
||||
<van-tabs active="{{ active }}" bind:change="onChange">
|
||||
<van-tab title="我的优惠券">
|
||||
<view wx:if="{{currentList.length}}">
|
||||
|
||||
</view>
|
||||
<empty bind:refresh="getCurrent" />
|
||||
</van-tab>
|
||||
<van-tab title="领券中心">
|
||||
<view wx:if="{{canGetList.length}}">
|
||||
|
||||
</view>
|
||||
<empty bind:refresh="getCanGet" />
|
||||
</van-tab>
|
||||
</van-tabs>
|
@ -1,6 +1,7 @@
|
||||
// pages/integral/index.js
|
||||
import request from "../../utils/request"
|
||||
import { getCurrentIntegral } from "../../service/system";
|
||||
import { getCurrentIntegral, getRedeemableCoupons } from "../../service/system";
|
||||
import { alertInfo, loadingFunc } from "../../utils/index";
|
||||
const { OK } = request;
|
||||
|
||||
Page({
|
||||
@ -10,6 +11,10 @@ Page({
|
||||
*/
|
||||
data: {
|
||||
integral: 0,
|
||||
page: 1,
|
||||
size: 20,
|
||||
list: [],
|
||||
totalPage: 0,
|
||||
},
|
||||
|
||||
/**
|
||||
@ -31,6 +36,28 @@ Page({
|
||||
*/
|
||||
onShow() {
|
||||
this.getIntegral();
|
||||
this.getCoupons();
|
||||
},
|
||||
async getCoupons() {
|
||||
const { page, size } = this.data
|
||||
const { code, message, data, total } = await getRedeemableCoupons({ page, size, type: 2 })
|
||||
if (code !== OK) {
|
||||
alertInfo(message)
|
||||
return;
|
||||
}
|
||||
this.setData({
|
||||
list: data,
|
||||
totalPage: Math.ceil(total / size),
|
||||
})
|
||||
},
|
||||
refresh() {
|
||||
const that = this;
|
||||
that.setData({
|
||||
page: 1,
|
||||
size: 20
|
||||
}, () => {
|
||||
that.getCoupons()
|
||||
})
|
||||
},
|
||||
jumpToRecord() {
|
||||
wx.navigateTo({
|
||||
@ -47,6 +74,7 @@ Page({
|
||||
integral: data?.balance || 0
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
|
@ -1,7 +1,8 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigator": "/components/navigator/index",
|
||||
"discount-coupon": "/components/discountCoupon/index"
|
||||
"discount-coupon": "/components/discountCoupon/index",
|
||||
"empty": "/components/empty/index"
|
||||
},
|
||||
"navigationStyle": "custom"
|
||||
}
|
@ -5,7 +5,10 @@
|
||||
<view class="number"> 当前积分: {{ integral }} </view>
|
||||
<view class="primaryTextBtn" bind:tap="jumpToRecord"> 查看积分明细 </view>
|
||||
</view>
|
||||
<view class="ticketList">
|
||||
<discount-coupon />
|
||||
<view class="ticketList" wx:if="{{list.length}}">
|
||||
<view wx:for="{{list}}" wx:key="id">
|
||||
<discount-coupon data="{{item}}" type="{{2}}" />
|
||||
</view>
|
||||
</view>
|
||||
<empty bind:refresh="refresh" text="暂无可兑换的优惠券" />
|
||||
</view>
|
@ -1,7 +1,7 @@
|
||||
// pages/integralRecord/index.js
|
||||
import request from "../../utils/request"
|
||||
import { getIntegralRecord } from "../../service/system";
|
||||
import { alertInfo, loadingFunc } from "../../utils";
|
||||
import { alertInfo, loadingFunc } from "../../utils/index";
|
||||
const { OK } = request;
|
||||
Page({
|
||||
|
||||
@ -30,11 +30,27 @@ Page({
|
||||
return;
|
||||
}
|
||||
this.setData({
|
||||
list: data || [],
|
||||
list: data?.map(item => {
|
||||
item.type = ['充值增加', '系统增加', '系统减少', '冲正减少', '退费减少', '兑换优惠券', '积分清零'][item.type]
|
||||
item.nowBalance = Number(item.nowBalance || 0)
|
||||
item.lastBalance = Number(item.lastBalance || 0)
|
||||
item.value = item.nowBalance - item.lastBalance;
|
||||
item.value = item.value > 0 ? `+${item.value}` : item.value
|
||||
return item
|
||||
}) || [],
|
||||
total,
|
||||
totalPage: Math.ceil(total / size),
|
||||
})
|
||||
},
|
||||
refresh() {
|
||||
const that = this;
|
||||
this.setData({
|
||||
page: 1,
|
||||
size: 20,
|
||||
}, () => {
|
||||
that.init();
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
@ -51,7 +67,15 @@ Page({
|
||||
await that.init();
|
||||
})
|
||||
},
|
||||
|
||||
async onChangePage(e) {
|
||||
const page = e.detail.currentIndex;
|
||||
const that = this;
|
||||
this.setData({
|
||||
page
|
||||
}, () => {
|
||||
that.init();
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
|
@ -1,6 +1,10 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigator": "/components/navigator/index"
|
||||
"navigator": "/components/navigator/index",
|
||||
"van-cell": "@vant/weapp/cell/index",
|
||||
"van-cell-group": "@vant/weapp/cell-group/index",
|
||||
"empty": "/components/empty/index",
|
||||
"pagination": "/components/pagination/index"
|
||||
},
|
||||
"navigationStyle": "custom"
|
||||
}
|
@ -1,2 +1,24 @@
|
||||
<!--pages/integralRecord/index.wxml-->
|
||||
<navigator title="积分明细" canBack="{{true}}" />
|
||||
|
||||
<view wx:if="{{list.length}}">
|
||||
<van-cell-group>
|
||||
<van-cell
|
||||
wx:for="{{list}}"
|
||||
wx:key="id"
|
||||
title="{{item.type}}"
|
||||
value="{{item.value}}"
|
||||
label="{{item.createdAt}}"
|
||||
border="{{ false }}"
|
||||
/>
|
||||
</van-cell-group>
|
||||
<pagination
|
||||
currentIndex="{{page}}"
|
||||
totalPage="{{totalPage}}"
|
||||
bind:pagingChange="onChangePage"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view wx:else>
|
||||
<empty bind:refresh="refresh" />
|
||||
</view>
|
@ -66,7 +66,7 @@ Page({
|
||||
}
|
||||
this.init()
|
||||
this.getUnReadNumber()
|
||||
// this.getIntegral()
|
||||
this.getIntegral()
|
||||
const tenement = wx.getStorageSync('tenement')
|
||||
this.setData({ tenement })
|
||||
},
|
||||
|
@ -8,7 +8,7 @@
|
||||
<view class="info">
|
||||
<view class="nickName"> {{ user.nickName }} </view>
|
||||
<view class="tenement"> {{ tenement.name }} </view>
|
||||
<view class="integration"> 积分: - </view>
|
||||
<view class="integration"> 积分: {{ integral }} </view>
|
||||
</view>
|
||||
</view>
|
||||
<view style="margin-bottom: 20rpx;border-radius: 16rpx; overflow: hidden;">
|
||||
@ -51,7 +51,7 @@
|
||||
</van-grid-item>
|
||||
</van-grid>
|
||||
</view>
|
||||
<!-- <view style="margin-bottom: 20rpx;border-radius: 16rpx; overflow: hidden;">
|
||||
<view style="margin-bottom: 20rpx;border-radius: 16rpx; overflow: hidden;">
|
||||
<van-cell
|
||||
title="积分兑换"
|
||||
value=""
|
||||
@ -66,7 +66,7 @@
|
||||
bind:tap="jumpToDiscountCoupon"
|
||||
icon="label-o"
|
||||
/>
|
||||
</view> -->
|
||||
</view>
|
||||
<view style="border-radius: 16rpx; overflow: hidden;">
|
||||
<van-cell title="联系客服" value="" is-link bind:tap="connect" icon="service-o" />
|
||||
<van-cell icon="qr" wx:if="{{!!user.isAdmin}}" title="二维码" value="" is-link bind:click="jumpToQrCode" />
|
||||
|
@ -1,66 +0,0 @@
|
||||
// pages/ticket/index.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
@ -1,7 +0,0 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigator": "/components/navigator/index",
|
||||
"discount-coupon": "/components/discountCoupon/index"
|
||||
},
|
||||
"navigationStyle": "custom"
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
<!--pages/ticket/index.wxml-->
|
||||
<navigator title="我的优惠券" />
|
||||
<discount-coupon />
|
@ -1 +0,0 @@
|
||||
/* pages/ticket/index.wxss */
|
@ -79,4 +79,19 @@ export const getCurrentIntegral = async function() {
|
||||
// 获取积分明细
|
||||
export const getIntegralRecord = async function({ page, size }) {
|
||||
return await GET(`/integral/getWxIntegralList/detail?page=${page}&size=${size}`);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取优惠券列表
|
||||
export const getRedeemableCoupons = async function({ page, size, type }) {
|
||||
return await GET(`/wx/getRedeemableCoupons?page=${page}&size=${size}&type=${type}`);
|
||||
}
|
||||
|
||||
// 获取优惠券列表
|
||||
export const redeemCoupons = async function({ id, type }) {
|
||||
return await POST(`/wx/redeemCoupons`, { id, type });
|
||||
}
|
||||
|
||||
// 获取当前拥有的优惠券列表
|
||||
export const getCurrentCoupons = async function() {
|
||||
return await GET(`/wx/getCurrentCoupons`);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ const parseResponse = function (response, url) {
|
||||
alertError("服务异常")
|
||||
return
|
||||
}
|
||||
console.log('url', url,'statusCode', statusCode, 'response.data', response)
|
||||
console.log('url', url,'statusCode', statusCode, 'response.data', response?.data)
|
||||
if (code === 401) {
|
||||
const currentUrl = getPageUrl()
|
||||
|
||||
@ -107,7 +107,7 @@ const parseResponse = function (response, url) {
|
||||
url: '/pages/login/index',
|
||||
})
|
||||
wx.clearStorageSync()
|
||||
return { code: 404, message: "服务故障" }
|
||||
return { code: 404, message: "服务不存在" }
|
||||
}
|
||||
if (500 <= code && code < 600) {
|
||||
return { code: 500, message: "服务错误" }
|
||||
|
Loading…
x
Reference in New Issue
Block a user