sign.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const sheep_index = require("../../sheep/index.js");
  4. const sheep_api_member_signin = require("../../sheep/api/member/signin.js");
  5. require("../../sheep/url/index.js");
  6. require("../../sheep/store/index.js");
  7. require("../../sheep/store/app.js");
  8. require("../../sheep/api/promotion/diy.js");
  9. require("../../sheep/request/index.js");
  10. require("../../sheep/config/index.js");
  11. require("../../sheep/platform/index.js");
  12. require("../../sheep/platform/provider/wechat/index.js");
  13. require("../../sheep/platform/provider/wechat/miniProgram.js");
  14. require("../../sheep/api/member/auth.js");
  15. require("../../sheep/api/member/social.js");
  16. require("../../sheep/api/member/user.js");
  17. require("../../sheep/platform/provider/apple/index.js");
  18. require("../../sheep/platform/share.js");
  19. require("../../sheep/router/index.js");
  20. require("../../sheep/hooks/useModal.js");
  21. require("../../sheep/helper/index.js");
  22. require("../../sheep/helper/test.js");
  23. require("../../sheep/helper/digit.js");
  24. require("../../sheep/helper/throttle.js");
  25. require("../../sheep/platform/pay.js");
  26. require("../../sheep/api/pay/order.js");
  27. require("../../sheep/store/user.js");
  28. require("../../sheep/store/cart.js");
  29. require("../../sheep/api/trade/cart.js");
  30. require("../../sheep/api/pay/wallet.js");
  31. require("../../sheep/api/trade/order.js");
  32. require("../../sheep/api/promotion/coupon.js");
  33. require("../../sheep/store/sys.js");
  34. require("../../sheep/store/modal.js");
  35. require("../../sheep/config/zIndex.js");
  36. if (!Array) {
  37. const _easycom_s_empty2 = common_vendor.resolveComponent("s-empty");
  38. const _easycom_su_popup2 = common_vendor.resolveComponent("su-popup");
  39. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  40. (_easycom_s_empty2 + _easycom_su_popup2 + _easycom_s_layout2)();
  41. }
  42. const _easycom_s_empty = () => "../../sheep/components/s-empty/s-empty.js";
  43. const _easycom_su_popup = () => "../../sheep/ui/su-popup/su-popup.js";
  44. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  45. if (!Math) {
  46. (_easycom_s_empty + _easycom_su_popup + _easycom_s_layout)();
  47. }
  48. const _sfc_main = {
  49. __name: "sign",
  50. setup(__props) {
  51. common_vendor.useCssVars((_ctx) => ({
  52. "19707c8c": common_vendor.unref(headerBg)
  53. }));
  54. const headerBg = sheep_index.sheep.$url.css("/static/img/shop/app/sign.png");
  55. const state = common_vendor.reactive({
  56. data: {
  57. days: [],
  58. //日历
  59. rules: {}
  60. //规则
  61. },
  62. cur_year: 0,
  63. //当前选的年
  64. cur_month: 0,
  65. //当前选的月
  66. cur_day: 0,
  67. //当前选择的天
  68. weeks_ch: [
  69. {
  70. title: "日",
  71. value: "0"
  72. },
  73. {
  74. title: "一",
  75. value: "1"
  76. },
  77. {
  78. title: "二",
  79. value: "2"
  80. },
  81. {
  82. title: "三",
  83. value: "3"
  84. },
  85. {
  86. title: "四",
  87. value: "4"
  88. },
  89. {
  90. title: "五",
  91. value: "5"
  92. },
  93. {
  94. title: "六",
  95. value: "6"
  96. }
  97. ],
  98. //星期
  99. showModel: false,
  100. //签到弹框
  101. continue_days: 0,
  102. //连续签到天数
  103. signin: {},
  104. // 签到
  105. showRetroactive: false,
  106. //补签弹框
  107. date: "",
  108. //补签选中日期
  109. isSign: 0,
  110. //今天是否签到
  111. loading: true
  112. });
  113. async function onSign() {
  114. const {
  115. code,
  116. data
  117. } = await sheep_api_member_signin.SignInApi.createSignInRecord();
  118. if (code === 0) {
  119. state.showModel = true;
  120. state.signin = data;
  121. }
  122. }
  123. function onConfirm() {
  124. state.showModel = false;
  125. getData();
  126. }
  127. function formatDate(t) {
  128. let date = new Date(t);
  129. let year = date.getFullYear();
  130. let month = String(date.getMonth() + 1).padStart(2, "0");
  131. let day = String(date.getDate()).padStart(2, "0");
  132. let dateString = `${year}-${month}-${day}`;
  133. return dateString;
  134. }
  135. async function getData(mouth) {
  136. const {
  137. code,
  138. data
  139. } = await sheep_api_member_signin.SignInApi.getOwnSignInMoon(mouth);
  140. if (code === 0) {
  141. data.days.forEach((i, index) => {
  142. if (i.week == "SUNDAY") {
  143. i.week = 0;
  144. } else if (i.week == "MONDAY") {
  145. i.week = 1;
  146. } else if (i.week == "TUESDAY") {
  147. i.week = 2;
  148. } else if (i.week == "WEDNESDAY") {
  149. i.week = 3;
  150. } else if (i.week == "THURSDAY") {
  151. i.week = 4;
  152. } else if (i.week == "FRIDAY") {
  153. i.week = 5;
  154. } else if (i.week == "SATURDAY") {
  155. i.week = 6;
  156. }
  157. i.date = formatDate(i.date);
  158. });
  159. state.data = data;
  160. } else {
  161. state.data = null;
  162. }
  163. state.loading = false;
  164. if (state.data) {
  165. state.data.days.forEach((i, index) => {
  166. if (index < i.week) {
  167. index++;
  168. var obj = {
  169. day: null,
  170. isSign: false
  171. };
  172. state.data.days.unshift(obj);
  173. }
  174. if (index == 1) {
  175. let arr = i.date.split("-");
  176. state.cur_year = arr[0];
  177. state.cur_month = arr[1];
  178. }
  179. });
  180. if (state.data.days[0].day == null) {
  181. state.data.days.forEach((i, index) => {
  182. if (i.current == "today") {
  183. state.isSign = i.isSign;
  184. }
  185. });
  186. }
  187. state.continue_days = data.continueDays;
  188. }
  189. }
  190. common_vendor.onReady(() => {
  191. console.log();
  192. getData({
  193. month: formatDate(/* @__PURE__ */ new Date()).substring(0, 7)
  194. });
  195. });
  196. const handleCalendar = (type) => {
  197. const cur_year = parseInt(state.cur_year);
  198. const cur_month = parseInt(state.cur_month);
  199. var newMonth;
  200. var newYear = cur_year;
  201. if (type === 0) {
  202. newMonth = cur_month - 1;
  203. if (newMonth < 1) {
  204. newYear = cur_year - 1;
  205. newMonth = 12;
  206. } else if (newMonth < 10) {
  207. newMonth = "0" + newMonth;
  208. }
  209. } else {
  210. newMonth = cur_month + 1;
  211. if (newMonth > 12) {
  212. newYear = cur_year + 1;
  213. newMonth = 1;
  214. } else if (newMonth < 10) {
  215. newMonth = "0" + newMonth;
  216. }
  217. }
  218. console.log(newYear + "-" + newMonth);
  219. getData({
  220. month: newYear + "-" + newMonth
  221. });
  222. };
  223. return (_ctx, _cache) => {
  224. var _a, _b, _c, _d;
  225. return common_vendor.e({
  226. a: state.loading
  227. }, state.loading ? {} : state.data && !state.loading ? common_vendor.e({
  228. c: common_vendor.t(state.continue_days),
  229. d: common_vendor.o(($event) => handleCalendar(0)),
  230. e: common_vendor.t(state.cur_year || "--"),
  231. f: common_vendor.t(state.cur_month || "--"),
  232. g: common_vendor.o(($event) => handleCalendar(1)),
  233. h: common_vendor.f(state.weeks_ch, (item, index, i0) => {
  234. return {
  235. a: common_vendor.t(item.title),
  236. b: index
  237. };
  238. }),
  239. i: common_vendor.f(state.data.days, (item, j, i0) => {
  240. return common_vendor.e({
  241. a: item.isSign
  242. }, item.isSign ? {
  243. b: common_vendor.t(item.day < 10 ? "0" + item.day : item.day),
  244. c: common_vendor.unref(sheep_index.sheep).$url.static("/static/img/shop/app/correct.png")
  245. } : {}, {
  246. d: item.isReplenish == 1
  247. }, item.isReplenish == 1 ? {
  248. e: common_vendor.t(item.day < 10 ? "0" + item.day : item.day)
  249. } : {}, {
  250. f: item.isReplenish == 0 && !item.isSign
  251. }, item.isReplenish == 0 && !item.isSign ? {
  252. g: common_vendor.t(item.day < 10 ? "0" + item.day : item.day)
  253. } : {}, {
  254. h: j
  255. });
  256. }),
  257. j: state.isSign === 0
  258. }, state.isSign === 0 ? {
  259. k: common_vendor.o(onSign)
  260. } : {}, {
  261. l: state.isSign === 1
  262. }, state.isSign === 1 ? {} : {}, {
  263. m: common_vendor.t(state.data.rules.everyday),
  264. n: state.data.rules.is_inc == "1"
  265. }, state.data.rules.is_inc == "1" ? {
  266. o: common_vendor.t(state.data.rules.inc_num),
  267. p: common_vendor.t(state.data.rules.until_day)
  268. } : {}, {
  269. q: ((_a = state.data.rules.discounts) == null ? void 0 : _a.length) > 0
  270. }, ((_b = state.data.rules.discounts) == null ? void 0 : _b.length) > 0 ? {
  271. r: common_vendor.f(state.data.rules.discounts, (i, k0, i0) => {
  272. return {
  273. a: common_vendor.t(i.full),
  274. b: common_vendor.t(i.value),
  275. c: i
  276. };
  277. })
  278. } : {}, {
  279. s: state.data.rules.is_replenish == "1"
  280. }, state.data.rules.is_replenish == "1" ? {
  281. t: common_vendor.t(((_c = state.data.rules.discounts) == null ? void 0 : _c.length) > 0 ? "3" : "2"),
  282. v: common_vendor.t(state.data.rules.replenish_limit),
  283. w: common_vendor.t(state.data.rules.replenish_days),
  284. x: common_vendor.t(state.data.rules.replenish_num)
  285. } : {}) : !state.data && !state.loading ? {
  286. z: common_vendor.p({
  287. icon: "/static/data-empty.png",
  288. text: "签到活动还未开始"
  289. })
  290. } : {}, {
  291. b: state.data && !state.loading,
  292. y: !state.data && !state.loading,
  293. A: common_vendor.t(state.signin.score),
  294. B: common_vendor.t(state.continue_days),
  295. C: common_vendor.o(onConfirm),
  296. D: common_vendor.p({
  297. show: state.showModel,
  298. type: "center",
  299. round: "10",
  300. isMaskClick: false
  301. }),
  302. E: common_vendor.t((_d = state.data) == null ? void 0 : _d.rules.replenish_num),
  303. F: common_vendor.t(state.continue_days),
  304. G: common_vendor.p({
  305. show: state.showRetroactive,
  306. type: "center",
  307. round: "10",
  308. isMaskClick: false
  309. }),
  310. H: common_vendor.s(_ctx.__cssVars()),
  311. I: common_vendor.p({
  312. title: "签到有礼"
  313. })
  314. });
  315. };
  316. }
  317. };
  318. 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"]]);
  319. wx.createPage(MiniProgramPage);