"use strict"; const common_vendor = require("../../common/vendor.js"); const config_host = require("../../config/host.js"); const api_user = require("../../api/user.js"); require("../../utils/request.js"); require("../../utils/functions.js"); require("../../utils/log.js"); require("../../utils/qqmap-wx-jssdk.min.js"); require("../../api/other.js"); const HeaderNav = () => "../../components/HeaderNav/Index.js"; const FooterNav = () => "../../components/FooterNav/Index.js"; const RightNav = () => "../../components/RightNav/Index.js"; const MzButton = () => "../../components/MzButton/Index.js"; const _sfc_main = { components: { HeaderNav, FooterNav, RightNav, MzButton }, data() { return { title: "Hello", loading: true, staticImage: { screenActiveImg: config_host.imghost + "/static/image/order-screen-active.png", orderCardBackground: config_host.imghost + "/static/image/order-card-background.png", wallpaperBgImage: config_host.imghost + "/static/image/background.png", couponsBackground: config_host.imghost + "/static/image/coupons-bg.png", couponsGrayBackground: config_host.imghost + "/static/image/coupons-gray-bg.png", couponsGQ: config_host.imghost + "/static/image/coupons-gq.png", couponsUse: config_host.imghost + "/static/image/coupons-use.png" }, indexBanner: [{ image: config_host.imghost + "/static/image/banner.png", url: "" }], user: { avatar: config_host.imghost + "/static/image/banner.png", nickname: "清晨的风", coupons: 221, id: 88685 }, isTop: false, pagePadding: 100, petImage: config_host.imghost + "/static/image/pet_avatar1.jpeg", couponsList: [], type: "lists", couponType: 2, types: [ { title: "省点银子", value: 2 }, { title: "豪门大户卡", value: 1 } ], page: 1, status: "loadmore" }; }, onLoad(option) { this.type = option.type || "lists"; console.log(this.type); }, methods: { clickCoupons(item) { if (item.status === 0) { console.log("coupons", item); common_vendor.index.setStorageSync("userCoupons", item); common_vendor.index.navigateBack(); } }, navTo(url) { common_vendor.index.navigateTo({ url }); }, getCouponsList(page = 1) { if (this.status === "nomore") { return; } else { this.status = "loading"; } api_user.userCoupons({ page, limit: 10, is_buy: this.couponType }).then((res) => { let couponsList = res.data.map((row) => { return { id: row.id, price: parseFloat(row.deduction), title: row.title, time: "有效期至 " + row.end_time, cause: "满" + parseFloat(row.min_price) + "使用", status: row.status }; }); this.status = couponsList.length < 10 ? "nomore" : "loadmore"; if (page === 1) { this.couponsList = couponsList; return; } this.couponsList.push(...couponsList); }); }, couponTypeToggle(item) { this.couponType = item.value; this.page = 1; this.status = "loadmore"; this.getCouponsList(); } }, onPageScroll(res) { if (res.scrollTop <= 20) { common_vendor.index.$emit("isTop", true); } else { common_vendor.index.$emit("isTop", false); } }, onReachBottom() { this.getCouponsList(++this.page); }, created() { }, mounted() { this.getCouponsList(); } }; if (!Array) { const _component_HeaderNav = common_vendor.resolveComponent("HeaderNav"); const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon"); const _component_MzButton = common_vendor.resolveComponent("MzButton"); const _easycom_u_loadmore2 = common_vendor.resolveComponent("u-loadmore"); (_component_HeaderNav + _easycom_u_icon2 + _component_MzButton + _easycom_u_loadmore2)(); } const _easycom_u_icon = () => "../../uni_modules/uview-plus/components/u-icon/u-icon.js"; const _easycom_u_loadmore = () => "../../uni_modules/uview-plus/components/u-loadmore/u-loadmore.js"; if (!Math) { (_easycom_u_icon + _easycom_u_loadmore)(); } function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: common_vendor.p({ title: "优惠在这", ["is-back"]: true }), b: $data.type === "lists" }, $data.type === "lists" ? { c: common_vendor.f($data.types, (item, k0, i0) => { return { a: common_vendor.t(item.title), b: item.value === $data.couponType ? 1 : "", c: common_vendor.o(($event) => $options.couponTypeToggle(item)) }; }) } : {}, { d: common_vendor.f($data.couponsList, (item, k0, i0) => { return { a: common_vendor.t(item.price), b: common_vendor.t(item.cause), c: common_vendor.t(item.title), d: common_vendor.t(item.time), e: item.status === 2, f: item.status === 1, g: "e808cb4e-1-" + i0, h: common_vendor.o(($event) => $options.clickCoupons(item)), i: "e808cb4e-2-" + i0, j: common_vendor.p({ title: "立即使用", ["button-width"]: "145rpx", ["button-color"]: item.status > 0 ? "#CACACA" : "#4DC3B8", ["font-color"]: "#fff", ["font-size"]: "26rpx", ["is-background"]: false, ["padding-tb"]: "2rpx", ["btn-style"]: { boxShadow: item.status > 0 ? "2rpx -5rpx 0rpx 0rpx rgba(199,199,199,0.35)" : "2rpx -5rpx 0rpx 0rpx rgba(77,195,184,0.35)" } }), k: "url(" + (item.status > 0 ? $data.staticImage.couponsGrayBackground : $data.staticImage.couponsBackground) + ")" }; }), e: $data.staticImage.couponsGQ, f: $data.staticImage.couponsUse, g: common_vendor.p({ size: "24rpx", color: "#999999", name: "arrow-right" }), h: common_vendor.o(($event) => $options.getCouponsList(++this.page)), i: common_vendor.p({ status: $data.status, fontSize: "28", color: "#ACB4B6", line: true, ["line-color"]: "#ACB4B6", marginBottom: "30", marginTop: "30" }), j: "url(" + $data.staticImage.wallpaperBgImage + ")" }); } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "E:/Project/pet_uni/pages/UserCoupons/index.vue"]]); _sfc_main.__runtimeHooks = 1; wx.createPage(MiniProgramPage);