sign.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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/images/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. state.isSign = 1;
  122. common_vendor.index.setStorageSync("isSign", true);
  123. }
  124. }
  125. common_vendor.watch(() => state.showModel, (newValue) => {
  126. if (newValue) {
  127. setTimeout(onConfirm, 3e3);
  128. }
  129. });
  130. function onConfirm() {
  131. state.showModel = false;
  132. getData({
  133. month: formatDate(/* @__PURE__ */ new Date()).substring(0, 7)
  134. });
  135. }
  136. function formatDate(t) {
  137. let date = new Date(t);
  138. let year = date.getFullYear();
  139. let month = String(date.getMonth() + 1).padStart(2, "0");
  140. let day = String(date.getDate()).padStart(2, "0");
  141. let dateString = `${year}-${month}-${day}`;
  142. return dateString;
  143. }
  144. async function getData(mouth) {
  145. const {
  146. code,
  147. data
  148. } = await sheep_api_member_signin.SignInApi.getOwnSignInMoon(mouth);
  149. if (code === 0) {
  150. data.days.forEach((i, index) => {
  151. if (i.week == "SUNDAY") {
  152. i.week = 0;
  153. } else if (i.week == "MONDAY") {
  154. i.week = 1;
  155. } else if (i.week == "TUESDAY") {
  156. i.week = 2;
  157. } else if (i.week == "WEDNESDAY") {
  158. i.week = 3;
  159. } else if (i.week == "THURSDAY") {
  160. i.week = 4;
  161. } else if (i.week == "FRIDAY") {
  162. i.week = 5;
  163. } else if (i.week == "SATURDAY") {
  164. i.week = 6;
  165. }
  166. i.date = formatDate(i.date);
  167. });
  168. state.data = data;
  169. } else {
  170. state.data = null;
  171. }
  172. state.loading = false;
  173. if (state.data) {
  174. state.data.days.forEach((i, index) => {
  175. if (index < i.week) {
  176. index++;
  177. var obj = {
  178. day: null,
  179. isSign: false
  180. };
  181. state.data.days.unshift(obj);
  182. }
  183. if (index == 1) {
  184. let arr = i.date.split("-");
  185. state.cur_year = arr[0];
  186. state.cur_month = arr[1];
  187. }
  188. });
  189. if (state.data.days[0].day == null) {
  190. state.data.days.forEach((i, index) => {
  191. if (i.current == "today") {
  192. state.isSign = i.isSign;
  193. }
  194. });
  195. }
  196. state.continue_days = data.continueDays;
  197. }
  198. }
  199. common_vendor.onReady(() => {
  200. getData({
  201. month: formatDate(/* @__PURE__ */ new Date()).substring(0, 7)
  202. });
  203. });
  204. const handleCalendar = (type) => {
  205. const cur_year = parseInt(state.cur_year);
  206. const cur_month = parseInt(state.cur_month);
  207. console.log(cur_year, cur_month);
  208. var newMonth;
  209. var newYear = cur_year;
  210. if (type === 0) {
  211. newMonth = cur_month - 1;
  212. if (newMonth < 1) {
  213. newYear = cur_year - 1;
  214. newMonth = 12;
  215. } else if (newMonth < 10) {
  216. newMonth = "0" + newMonth;
  217. }
  218. } else {
  219. newMonth = cur_month + 1;
  220. if (newMonth > 12) {
  221. newYear = cur_year + 1;
  222. newMonth = "01";
  223. } else if (newMonth < 10) {
  224. newMonth = "0" + newMonth;
  225. }
  226. }
  227. console.log(newYear + "-" + newMonth);
  228. getData({
  229. month: newYear + "-" + newMonth
  230. });
  231. };
  232. return (_ctx, _cache) => {
  233. var _a, _b, _c;
  234. return common_vendor.e({
  235. a: state.loading
  236. }, state.loading ? {} : state.data && !state.loading ? common_vendor.e({
  237. c: common_vendor.t(state.continue_days),
  238. d: common_vendor.o(($event) => handleCalendar(0)),
  239. e: common_vendor.t(state.cur_year || "--"),
  240. f: common_vendor.t(state.cur_month || "--"),
  241. g: common_vendor.o(($event) => handleCalendar(1)),
  242. h: common_vendor.f(state.weeks_ch, (item, index, i0) => {
  243. return {
  244. a: common_vendor.t(item.title),
  245. b: index
  246. };
  247. }),
  248. i: common_vendor.f(state.data.days, (item, j, i0) => {
  249. return common_vendor.e({
  250. a: item.isSign
  251. }, item.isSign ? {
  252. b: common_vendor.t(item.day < 10 ? "0" + item.day : item.day),
  253. c: common_vendor.unref(sheep_index.sheep).$url.static("/static/images/correct.png")
  254. } : {}, {
  255. d: item.isReplenish == 1
  256. }, item.isReplenish == 1 ? {
  257. e: common_vendor.t(item.day < 10 ? "0" + item.day : item.day)
  258. } : {}, {
  259. f: item.isReplenish == 0 && !item.isSign
  260. }, item.isReplenish == 0 && !item.isSign ? {
  261. g: common_vendor.t(item.day < 10 ? "0" + item.day : item.day)
  262. } : {}, {
  263. h: j
  264. });
  265. }),
  266. j: state.isSign === 0
  267. }, state.isSign === 0 ? {
  268. k: common_vendor.o(onSign)
  269. } : {}, {
  270. l: state.isSign === 1
  271. }, state.isSign === 1 ? {} : {}, {
  272. m: common_vendor.t(state.data.signInSocialStatus),
  273. n: ((_a = state.data.rules.discounts) == null ? void 0 : _a.length) > 0
  274. }, ((_b = state.data.rules.discounts) == null ? void 0 : _b.length) > 0 ? {
  275. o: common_vendor.f(state.data.rules.discounts, (i, k0, i0) => {
  276. return {
  277. a: common_vendor.t(i.full),
  278. b: common_vendor.t(i.value),
  279. c: i
  280. };
  281. })
  282. } : {}, {
  283. p: state.data.rules.is_replenish == "1"
  284. }, state.data.rules.is_replenish == "1" ? {
  285. q: common_vendor.t(((_c = state.data.rules.discounts) == null ? void 0 : _c.length) > 0 ? "3" : "2"),
  286. r: common_vendor.t(state.data.rules.replenish_limit),
  287. s: common_vendor.t(state.data.rules.replenish_days),
  288. t: common_vendor.t(state.data.rules.replenish_num)
  289. } : {}) : !state.data && !state.loading ? {
  290. w: common_vendor.p({
  291. icon: "/static/data-empty.png",
  292. text: "签到活动还未开始"
  293. })
  294. } : {}, {
  295. b: state.data && !state.loading,
  296. v: !state.data && !state.loading,
  297. x: common_vendor.t(state.signin.social),
  298. y: state == null ? void 0 : state.upgradeOrNot
  299. }, (state == null ? void 0 : state.upgradeOrNot) ? {
  300. z: common_vendor.t(state == null ? void 0 : state.socialStatusName)
  301. } : {}, {
  302. A: common_vendor.o(($event) => onConfirm()),
  303. B: common_vendor.p({
  304. show: state.showModel,
  305. type: "center",
  306. round: "10",
  307. isMaskClick: false
  308. }),
  309. C: common_vendor.s(_ctx.__cssVars()),
  310. D: common_vendor.p({
  311. title: "签到有礼"
  312. })
  313. });
  314. };
  315. }
  316. };
  317. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-964858d2"], ["__file", "D:/zx/mall-front-app/pages/app/sign.vue"]]);
  318. wx.createPage(MiniProgramPage);