提交优惠券,积分修改(领券部分没做)
This commit is contained in:
@@ -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 */
|
Reference in New Issue
Block a user