已支付订单列表:where.payStatus = 1;
This commit is contained in:
+238
@@ -0,0 +1,238 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const api_booking_coupon_index = require("../../api/booking/coupon/index.js");
|
||||
require("../../utils/request.js");
|
||||
const utils_common = require("../../utils/common.js");
|
||||
const api_booking_userCoupon_index = require("../../api/booking/userCoupon/index.js");
|
||||
const _sfc_main = {
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
isRefresh: false,
|
||||
isLogin: false,
|
||||
userId: 0,
|
||||
where: {
|
||||
page: 1,
|
||||
status: 0
|
||||
},
|
||||
canReset: false,
|
||||
loadMore: "more",
|
||||
logo: "",
|
||||
items: ["待使用(0)", "已使用(0)", "已失效(0)"],
|
||||
list: [],
|
||||
styles: [
|
||||
{
|
||||
value: "button",
|
||||
text: "按钮",
|
||||
checked: true
|
||||
},
|
||||
{
|
||||
value: "text",
|
||||
text: "文字"
|
||||
}
|
||||
],
|
||||
colors: ["#333333", "#4cd964", "#dd524d"],
|
||||
current: 0,
|
||||
colorIndex: 0,
|
||||
activeColor: "#108001",
|
||||
styleType: "text",
|
||||
getWeek: utils_common.getWeek,
|
||||
disabled: false
|
||||
};
|
||||
},
|
||||
onLoad(option) {
|
||||
this.openLogin();
|
||||
this.reload();
|
||||
},
|
||||
onShow(e) {
|
||||
this.openLogin();
|
||||
this.reload();
|
||||
},
|
||||
// 触底函数
|
||||
onReachBottom() {
|
||||
const app = this;
|
||||
const {
|
||||
where
|
||||
} = this;
|
||||
if (app.canReset) {
|
||||
app.where.page = ++where.page;
|
||||
app.reload();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async reload() {
|
||||
const app = this;
|
||||
const {
|
||||
where
|
||||
} = this;
|
||||
common_vendor.index.showLoading({
|
||||
title: "数据读取中."
|
||||
});
|
||||
app.loadMore = "loading";
|
||||
const userCouponIds = [];
|
||||
await app.getUserCoupon({
|
||||
userId: common_vendor.index.getStorageSync("user_id")
|
||||
}).then((list) => {
|
||||
list.map((d) => {
|
||||
userCouponIds.push(d.couponId);
|
||||
});
|
||||
});
|
||||
console.log("userCoupons: ", userCouponIds);
|
||||
api_booking_coupon_index.pageCoupon(where).then((res) => {
|
||||
const list = res.list.map((d) => {
|
||||
if (userCouponIds.indexOf(d.id) == 0) {
|
||||
d.disabled = true;
|
||||
}
|
||||
return d;
|
||||
});
|
||||
if (app.list.length < res.count) {
|
||||
app.list = app.list.concat(list);
|
||||
app.canReset = true;
|
||||
app.loadMore = "no-more";
|
||||
} else {
|
||||
app.canReset = false;
|
||||
app.loadMore = "no-more";
|
||||
}
|
||||
console.log("app.list: ", app.list);
|
||||
common_vendor.index.hideLoading();
|
||||
app.isRefresh = false;
|
||||
}).catch(() => {
|
||||
common_vendor.index.showToast({
|
||||
title: "请检查您的网络.",
|
||||
icon: "none"
|
||||
});
|
||||
common_vendor.index.hideLoading();
|
||||
app.isRefresh = false;
|
||||
});
|
||||
},
|
||||
getUserCoupon() {
|
||||
return new Promise((resolve, reject) => {
|
||||
api_booking_userCoupon_index.listUserCoupon({}).then((result) => {
|
||||
resolve(result);
|
||||
}).catch(reject);
|
||||
});
|
||||
},
|
||||
onClickItem(e) {
|
||||
const app = this;
|
||||
const {
|
||||
where,
|
||||
userId
|
||||
} = this;
|
||||
const index = e.currentIndex;
|
||||
if (this.current !== e.currentIndex) {
|
||||
this.current = e.currentIndex;
|
||||
}
|
||||
if (userId == 0) {
|
||||
app.openLogin();
|
||||
return;
|
||||
}
|
||||
app.where.status = index;
|
||||
this.where.page = 1;
|
||||
this.list = [];
|
||||
this.reload();
|
||||
},
|
||||
openUrl(url) {
|
||||
common_vendor.index.navigateTo({
|
||||
url
|
||||
});
|
||||
},
|
||||
toPay(orderId) {
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/package/booking/confirm?id=" + orderId
|
||||
});
|
||||
},
|
||||
closeOrder(item) {
|
||||
common_vendor.index.showModal({
|
||||
title: "确定取消此订单?",
|
||||
success(o) {
|
||||
if (o.confirm) {
|
||||
OrderApi.updateOrder({
|
||||
orderStatus: 2,
|
||||
orderId: item.orderId
|
||||
}).then((msg) => {
|
||||
common_vendor.index.showToast({
|
||||
title: msg,
|
||||
icon: "none"
|
||||
});
|
||||
item.orderStatus = 2;
|
||||
}).catch(() => {
|
||||
common_vendor.index.showToast({
|
||||
title: "请检查您的网络.",
|
||||
icon: "none"
|
||||
});
|
||||
common_vendor.index.hideLoading();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
// 弹出登录提示框
|
||||
async openLogin() {
|
||||
this.userId = common_vendor.index.getStorageSync("user_id");
|
||||
if (!this.userId) {
|
||||
this.$refs.login.open("bottom");
|
||||
return false;
|
||||
}
|
||||
},
|
||||
save(item, index) {
|
||||
const app = this;
|
||||
item.couponId = item.id;
|
||||
app.list[index].disabled = true;
|
||||
api_booking_userCoupon_index.addUserCoupon(item).then((msg) => {
|
||||
common_vendor.index.showToast({
|
||||
title: "领取成功",
|
||||
icon: "success"
|
||||
});
|
||||
setTimeout(() => {
|
||||
app.reload();
|
||||
}, 2e3);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!Array) {
|
||||
const _easycom_uv_button2 = common_vendor.resolveComponent("uv-button");
|
||||
const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
|
||||
const _easycom_ws_login2 = common_vendor.resolveComponent("ws-login");
|
||||
(_easycom_uv_button2 + _easycom_uni_load_more2 + _easycom_ws_login2)();
|
||||
}
|
||||
const _easycom_uv_button = () => "../../uni_modules/uv-button/components/uv-button/uv-button.js";
|
||||
const _easycom_uni_load_more = () => "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
|
||||
const _easycom_ws_login = () => "../../uni_modules/ws-login/components/ws-login/ws-login.js";
|
||||
if (!Math) {
|
||||
(_easycom_uv_button + _easycom_uni_load_more + _easycom_ws_login)();
|
||||
}
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return common_vendor.e({
|
||||
a: common_vendor.f($data.list, (item, index, i0) => {
|
||||
return {
|
||||
a: common_vendor.o(($event) => $options.save(item, index), index),
|
||||
b: "7c98fd37-0-" + i0,
|
||||
c: common_vendor.p({
|
||||
size: "mini",
|
||||
customStyle: {
|
||||
background: "linear-gradient(to right, #70b915, #008e04)",
|
||||
color: "#ffffff",
|
||||
border: "none"
|
||||
},
|
||||
text: item.disabled ? "已领取" : "领取",
|
||||
disabled: item.disabled
|
||||
}),
|
||||
d: index
|
||||
};
|
||||
}),
|
||||
b: $data.list.length > 0
|
||||
}, $data.list.length > 0 ? {
|
||||
c: common_vendor.p({
|
||||
status: $data.loadMore
|
||||
})
|
||||
} : {}, {
|
||||
d: common_vendor.sr("login", "7c98fd37-2"),
|
||||
e: common_vendor.o($options.reload),
|
||||
f: common_vendor.p({
|
||||
logo: $data.logo
|
||||
})
|
||||
});
|
||||
}
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/Users/gxwebsoft/APP/gxtyzx-uniapp-cli/src/package/coupon/index.vue"]]);
|
||||
wx.createPage(MiniProgramPage);
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"navigationBarTitleText": "领劵中心",
|
||||
"usingComponents": {
|
||||
"uv-button": "../../uni_modules/uv-button/components/uv-button/uv-button",
|
||||
"uni-load-more": "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more",
|
||||
"ws-login": "../../uni_modules/ws-login/components/ws-login/ws-login"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<view><view class="coupon"><block wx:for="{{a}}" wx:for-item="item" wx:key="d"><view class="coupon-item web-cell"><view class="coupon-bg"><view class="title"><label class="price">8</label><label class="unit">元</label></view><view class="desc">满减劵</view></view><view class="coupon-info web-cell web-cell-content"><view class="coupon-content"><view class="title">优惠券名称</view><view class="desc web-text-secondary">有效期至:2024-05-29</view></view><uv-button wx:if="{{item.c}}" class="save-btn" bindclick="{{item.a}}" u-i="{{item.b}}" bind:__l="__l" u-p="{{item.c}}"></uv-button></view></view></block><uni-load-more wx:if="{{b}}" u-i="7c98fd37-1" bind:__l="__l" u-p="{{c}}"></uni-load-more><ws-login wx:if="{{f}}" class="r" u-r="login" binddone="{{e}}" u-i="7c98fd37-2" bind:__l="__l" u-p="{{f}}"/></view></view>
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
.content {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 150px;
|
||||
text-align: center;
|
||||
}
|
||||
.segmented {
|
||||
padding: 0 12rpx;
|
||||
}
|
||||
.content-text {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
.color-tag {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
}
|
||||
.uni-list {
|
||||
flex: 1;
|
||||
}
|
||||
.coupon .coupon-item {
|
||||
width: 700rpx;
|
||||
margin: 20rpx auto;
|
||||
border-radius: 12rpx;
|
||||
border-bottom: 1px #eee solid;
|
||||
background: #fff;
|
||||
}
|
||||
.coupon .coupon-item .coupon-bg {
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 26rpx;
|
||||
color: #fff;
|
||||
border-radius: 12rpx 0 0 12rpx;
|
||||
background: linear-gradient(to right, #70b915, #008e04);
|
||||
}
|
||||
.coupon .coupon-item .coupon-bg .price {
|
||||
font-size: 50rpx;
|
||||
}
|
||||
.coupon .coupon-item .coupon-info {
|
||||
padding: 20rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.coupon .coupon-item .coupon-info .title {
|
||||
line-height: 2rem;
|
||||
}
|
||||
.coupon .coupon-item .merchant-avatar {
|
||||
margin-right: 12rpx;
|
||||
}
|
||||
.coupon .coupon-item .btn-status {
|
||||
font-size: 30rpx;
|
||||
display: flex;
|
||||
}
|
||||
.coupon .order-body {
|
||||
padding: 16px 0;
|
||||
}
|
||||
.ele-flex {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.card-actions {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
height: 45px;
|
||||
border-top: 1px #eee solid;
|
||||
}
|
||||
.card-actions-item {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
.card-actions-item-text {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
margin-left: 5px;
|
||||
}
|
||||
.close {
|
||||
top: 60rpx !important;
|
||||
}
|
||||
.total-price {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
font-size: 30rpx;
|
||||
align-items: flex-start;
|
||||
padding-left: 6rpx;
|
||||
margin-left: 450rpx;
|
||||
}
|
||||
.total-price .web-text-heading {
|
||||
font-size: 30rpx !important;
|
||||
}
|
||||
Reference in New Issue
Block a user