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