"use strict"; const common_vendor = require("../../common/vendor.js"); const sheep_index = require("../../sheep/index.js"); const sheep_api_member_signin = require("../../sheep/api/member/signin.js"); require("../../sheep/url/index.js"); require("../../sheep/store/index.js"); require("../../sheep/store/app.js"); require("../../sheep/api/promotion/diy.js"); require("../../sheep/request/index.js"); require("../../sheep/config/index.js"); require("../../sheep/platform/index.js"); require("../../sheep/platform/provider/wechat/index.js"); require("../../sheep/platform/provider/wechat/miniProgram.js"); require("../../sheep/api/member/auth.js"); require("../../sheep/api/member/social.js"); require("../../sheep/api/member/user.js"); require("../../sheep/platform/provider/apple/index.js"); require("../../sheep/platform/share.js"); require("../../sheep/router/index.js"); require("../../sheep/hooks/useModal.js"); require("../../sheep/helper/index.js"); require("../../sheep/helper/test.js"); require("../../sheep/helper/digit.js"); require("../../sheep/helper/throttle.js"); require("../../sheep/platform/pay.js"); require("../../sheep/api/pay/order.js"); require("../../sheep/store/user.js"); require("../../sheep/store/cart.js"); require("../../sheep/api/trade/cart.js"); require("../../sheep/api/pay/wallet.js"); require("../../sheep/api/trade/order.js"); require("../../sheep/api/promotion/coupon.js"); require("../../sheep/store/sys.js"); require("../../sheep/store/modal.js"); require("../../sheep/config/zIndex.js"); if (!Array) { const _easycom_s_empty2 = common_vendor.resolveComponent("s-empty"); const _easycom_su_popup2 = common_vendor.resolveComponent("su-popup"); const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout"); (_easycom_s_empty2 + _easycom_su_popup2 + _easycom_s_layout2)(); } const _easycom_s_empty = () => "../../sheep/components/s-empty/s-empty.js"; const _easycom_su_popup = () => "../../sheep/ui/su-popup/su-popup.js"; const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js"; if (!Math) { (_easycom_s_empty + _easycom_su_popup + _easycom_s_layout)(); } const _sfc_main = { __name: "sign", setup(__props) { common_vendor.useCssVars((_ctx) => ({ "19707c8c": common_vendor.unref(headerBg) })); const headerBg = sheep_index.sheep.$url.css("/static/img/shop/app/sign.png"); const state = common_vendor.reactive({ data: { days: [], //日历 rules: {} //规则 }, cur_year: 0, //当前选的年 cur_month: 0, //当前选的月 cur_day: 0, //当前选择的天 weeks_ch: [ { title: "日", value: "0" }, { title: "一", value: "1" }, { title: "二", value: "2" }, { title: "三", value: "3" }, { title: "四", value: "4" }, { title: "五", value: "5" }, { title: "六", value: "6" } ], //星期 showModel: false, //签到弹框 continue_days: 0, //连续签到天数 signin: {}, // 签到 showRetroactive: false, //补签弹框 date: "", //补签选中日期 isSign: 0, //今天是否签到 loading: true }); async function onSign() { const { code, data } = await sheep_api_member_signin.SignInApi.createSignInRecord(); if (code === 0) { state.showModel = true; state.signin = data; } } function onConfirm() { state.showModel = false; getData(); } function formatDate(t) { let date = new Date(t); let year = date.getFullYear(); let month = String(date.getMonth() + 1).padStart(2, "0"); let day = String(date.getDate()).padStart(2, "0"); let dateString = `${year}-${month}-${day}`; return dateString; } async function getData(mouth) { const { code, data } = await sheep_api_member_signin.SignInApi.getOwnSignInMoon(mouth); if (code === 0) { data.days.forEach((i, index) => { if (i.week == "SUNDAY") { i.week = 0; } else if (i.week == "MONDAY") { i.week = 1; } else if (i.week == "TUESDAY") { i.week = 2; } else if (i.week == "WEDNESDAY") { i.week = 3; } else if (i.week == "THURSDAY") { i.week = 4; } else if (i.week == "FRIDAY") { i.week = 5; } else if (i.week == "SATURDAY") { i.week = 6; } i.date = formatDate(i.date); }); state.data = data; } else { state.data = null; } state.loading = false; if (state.data) { state.data.days.forEach((i, index) => { if (index < i.week) { index++; var obj = { day: null, isSign: false }; state.data.days.unshift(obj); } if (index == 1) { let arr = i.date.split("-"); state.cur_year = arr[0]; state.cur_month = arr[1]; } }); if (state.data.days[0].day == null) { state.data.days.forEach((i, index) => { if (i.current == "today") { state.isSign = i.isSign; } }); } state.continue_days = data.continueDays; } } common_vendor.onReady(() => { console.log(); getData({ month: formatDate(/* @__PURE__ */ new Date()).substring(0, 7) }); }); const handleCalendar = (type) => { const cur_year = parseInt(state.cur_year); const cur_month = parseInt(state.cur_month); var newMonth; var newYear = cur_year; if (type === 0) { newMonth = cur_month - 1; if (newMonth < 1) { newYear = cur_year - 1; newMonth = 12; } else if (newMonth < 10) { newMonth = "0" + newMonth; } } else { newMonth = cur_month + 1; if (newMonth > 12) { newYear = cur_year + 1; newMonth = 1; } else if (newMonth < 10) { newMonth = "0" + newMonth; } } console.log(newYear + "-" + newMonth); getData({ month: newYear + "-" + newMonth }); }; return (_ctx, _cache) => { var _a, _b, _c, _d; return common_vendor.e({ a: state.loading }, state.loading ? {} : state.data && !state.loading ? common_vendor.e({ c: common_vendor.t(state.continue_days), d: common_vendor.o(($event) => handleCalendar(0)), e: common_vendor.t(state.cur_year || "--"), f: common_vendor.t(state.cur_month || "--"), g: common_vendor.o(($event) => handleCalendar(1)), h: common_vendor.f(state.weeks_ch, (item, index, i0) => { return { a: common_vendor.t(item.title), b: index }; }), i: common_vendor.f(state.data.days, (item, j, i0) => { return common_vendor.e({ a: item.isSign }, item.isSign ? { b: common_vendor.t(item.day < 10 ? "0" + item.day : item.day), c: common_vendor.unref(sheep_index.sheep).$url.static("/static/img/shop/app/correct.png") } : {}, { d: item.isReplenish == 1 }, item.isReplenish == 1 ? { e: common_vendor.t(item.day < 10 ? "0" + item.day : item.day) } : {}, { f: item.isReplenish == 0 && !item.isSign }, item.isReplenish == 0 && !item.isSign ? { g: common_vendor.t(item.day < 10 ? "0" + item.day : item.day) } : {}, { h: j }); }), j: state.isSign === 0 }, state.isSign === 0 ? { k: common_vendor.o(onSign) } : {}, { l: state.isSign === 1 }, state.isSign === 1 ? {} : {}, { m: common_vendor.t(state.data.rules.everyday), n: state.data.rules.is_inc == "1" }, state.data.rules.is_inc == "1" ? { o: common_vendor.t(state.data.rules.inc_num), p: common_vendor.t(state.data.rules.until_day) } : {}, { q: ((_a = state.data.rules.discounts) == null ? void 0 : _a.length) > 0 }, ((_b = state.data.rules.discounts) == null ? void 0 : _b.length) > 0 ? { r: common_vendor.f(state.data.rules.discounts, (i, k0, i0) => { return { a: common_vendor.t(i.full), b: common_vendor.t(i.value), c: i }; }) } : {}, { s: state.data.rules.is_replenish == "1" }, state.data.rules.is_replenish == "1" ? { t: common_vendor.t(((_c = state.data.rules.discounts) == null ? void 0 : _c.length) > 0 ? "3" : "2"), v: common_vendor.t(state.data.rules.replenish_limit), w: common_vendor.t(state.data.rules.replenish_days), x: common_vendor.t(state.data.rules.replenish_num) } : {}) : !state.data && !state.loading ? { z: common_vendor.p({ icon: "/static/data-empty.png", text: "签到活动还未开始" }) } : {}, { b: state.data && !state.loading, y: !state.data && !state.loading, A: common_vendor.t(state.signin.score), B: common_vendor.t(state.continue_days), C: common_vendor.o(onConfirm), D: common_vendor.p({ show: state.showModel, type: "center", round: "10", isMaskClick: false }), E: common_vendor.t((_d = state.data) == null ? void 0 : _d.rules.replenish_num), F: common_vendor.t(state.continue_days), G: common_vendor.p({ show: state.showRetroactive, type: "center", round: "10", isMaskClick: false }), H: common_vendor.s(_ctx.__cssVars()), I: common_vendor.p({ title: "签到有礼" }) }); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-964858d2"], ["__file", "/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-app/pages/app/sign.vue"]]); wx.createPage(MiniProgramPage);