sign.js 11 KB

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