money.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const sheep_index = require("../../../sheep/index.js");
  4. const sheep_api_pay_wallet = require("../../../sheep/api/pay/wallet.js");
  5. const sheep_hooks_useGoods = require("../../../sheep/hooks/useGoods.js");
  6. const sheep_util_index = require("../../../sheep/util/index.js");
  7. require("../../../sheep/url/index.js");
  8. require("../../../sheep/store/index.js");
  9. require("../../../sheep/store/app.js");
  10. require("../../../sheep/api/promotion/diy.js");
  11. require("../../../sheep/request/index.js");
  12. require("../../../sheep/config/index.js");
  13. require("../../../sheep/platform/index.js");
  14. require("../../../sheep/platform/provider/wechat/index.js");
  15. require("../../../sheep/platform/provider/wechat/miniProgram.js");
  16. require("../../../sheep/api/member/auth.js");
  17. require("../../../sheep/api/member/social.js");
  18. require("../../../sheep/api/member/user.js");
  19. require("../../../sheep/platform/provider/apple/index.js");
  20. require("../../../sheep/platform/share.js");
  21. require("../../../sheep/router/index.js");
  22. require("../../../sheep/hooks/useModal.js");
  23. require("../../../sheep/helper/index.js");
  24. require("../../../sheep/helper/test.js");
  25. require("../../../sheep/helper/digit.js");
  26. require("../../../sheep/helper/throttle.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/trade/order.js");
  33. require("../../../sheep/api/promotion/coupon.js");
  34. require("../../../sheep/store/sys.js");
  35. require("../../../sheep/store/modal.js");
  36. require("../../../sheep/config/zIndex.js");
  37. if (!Array) {
  38. const _easycom_uni_datetime_picker2 = common_vendor.resolveComponent("uni-datetime-picker");
  39. const _easycom_su_tabs2 = common_vendor.resolveComponent("su-tabs");
  40. const _easycom_su_sticky2 = common_vendor.resolveComponent("su-sticky");
  41. const _easycom_s_empty2 = common_vendor.resolveComponent("s-empty");
  42. const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
  43. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  44. (_easycom_uni_datetime_picker2 + _easycom_su_tabs2 + _easycom_su_sticky2 + _easycom_s_empty2 + _easycom_uni_load_more2 + _easycom_s_layout2)();
  45. }
  46. const _easycom_uni_datetime_picker = () => "../../../uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.js";
  47. const _easycom_su_tabs = () => "../../../sheep/ui/su-tabs/su-tabs.js";
  48. const _easycom_su_sticky = () => "../../../sheep/ui/su-sticky/su-sticky.js";
  49. const _easycom_s_empty = () => "../../../sheep/components/s-empty/s-empty.js";
  50. const _easycom_uni_load_more = () => "../../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
  51. const _easycom_s_layout = () => "../../../sheep/components/s-layout/s-layout.js";
  52. if (!Math) {
  53. (_easycom_uni_datetime_picker + _easycom_su_tabs + _easycom_su_sticky + _easycom_s_empty + _easycom_uni_load_more + _easycom_s_layout)();
  54. }
  55. const _sfc_main = {
  56. __name: "money",
  57. setup(__props) {
  58. common_vendor.useCssVars((_ctx) => ({
  59. "05bea019": common_vendor.unref(headerBg)
  60. }));
  61. const headerBg = sheep_index.sheep.$url.css("/static/img/shop/user/wallet_card_bg.png");
  62. const state = common_vendor.reactive({
  63. showMoney: false,
  64. date: [],
  65. // 筛选的时间段
  66. currentTab: 0,
  67. pagination: {
  68. list: [],
  69. total: 0,
  70. pageNo: 1,
  71. pageSize: 8
  72. },
  73. summary: {
  74. totalIncome: 0,
  75. totalExpense: 0
  76. },
  77. loadStatus: "",
  78. today: ""
  79. });
  80. const tabMaps = [
  81. {
  82. name: "全部",
  83. value: ""
  84. },
  85. {
  86. name: "收入",
  87. value: "1"
  88. },
  89. {
  90. name: "支出",
  91. value: "2"
  92. }
  93. ];
  94. const userWallet = common_vendor.computed(() => sheep_index.sheep.$store("user").userWallet);
  95. const dateFilterText = common_vendor.computed(() => {
  96. if (state.date[0] === state.date[1]) {
  97. return state.date[0];
  98. } else {
  99. return state.date.join("~");
  100. }
  101. });
  102. async function getLogList() {
  103. state.loadStatus = "loading";
  104. const { data, code } = await sheep_api_pay_wallet.PayWalletApi.getWalletTransactionPage({
  105. pageNo: state.pagination.pageNo,
  106. pageSize: state.pagination.pageSize,
  107. type: tabMaps[state.currentTab].value,
  108. "createTime[0]": state.date[0] + " 00:00:00",
  109. "createTime[1]": state.date[1] + " 23:59:59"
  110. });
  111. if (code !== 0) {
  112. return;
  113. }
  114. state.pagination.list = common_vendor._.concat(state.pagination.list, data.list);
  115. state.pagination.total = data.total;
  116. state.loadStatus = state.pagination.list.length < state.pagination.total ? "more" : "noMore";
  117. }
  118. async function getSummary() {
  119. const { data, code } = await sheep_api_pay_wallet.PayWalletApi.getWalletTransactionSummary({
  120. "createTime": [state.date[0] + " 00:00:00", state.date[1] + " 23:59:59"]
  121. });
  122. if (code !== 0) {
  123. return;
  124. }
  125. state.summary = data;
  126. }
  127. common_vendor.onLoad(() => {
  128. state.today = common_vendor.dayjs().format("YYYY-MM-DD");
  129. state.date = [state.today, state.today];
  130. getLogList();
  131. getSummary();
  132. sheep_index.sheep.$store("user").getWallet();
  133. });
  134. function onChange(e) {
  135. state.currentTab = e.index;
  136. sheep_util_index.resetPagination(state.pagination);
  137. getLogList();
  138. getSummary();
  139. }
  140. function onChangeTime(e) {
  141. state.date[0] = e[0];
  142. state.date[1] = e[e.length - 1];
  143. sheep_util_index.resetPagination(state.pagination);
  144. getLogList();
  145. getSummary();
  146. }
  147. common_vendor.onReachBottom(() => {
  148. if (state.loadStatus === "noMore") {
  149. return;
  150. }
  151. state.pagination.pageNo++;
  152. getLogList();
  153. });
  154. return (_ctx, _cache) => {
  155. return common_vendor.e({
  156. a: common_vendor.o(($event) => state.showMoney = !state.showMoney),
  157. b: common_vendor.n(state.showMoney ? "cicon-eye" : "cicon-eye-off"),
  158. c: common_vendor.t(state.showMoney ? common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(common_vendor.unref(userWallet).balance) : "*****"),
  159. d: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/pay/recharge")),
  160. e: common_vendor.t(common_vendor.unref(dateFilterText)),
  161. f: common_vendor.o(onChangeTime),
  162. g: common_vendor.o(($event) => state.data = $event),
  163. h: common_vendor.p({
  164. type: "daterange",
  165. end: state.today,
  166. modelValue: state.data
  167. }),
  168. i: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.summary.totalIncome)),
  169. j: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.summary.totalExpense)),
  170. k: common_vendor.o(onChange),
  171. l: common_vendor.p({
  172. list: tabMaps,
  173. scrollable: false,
  174. current: state.currentTab
  175. }),
  176. m: state.pagination.total === 0
  177. }, state.pagination.total === 0 ? {
  178. n: common_vendor.p({
  179. text: "暂无数据",
  180. icon: "/static/data-empty.png"
  181. })
  182. } : {}, {
  183. o: state.pagination.total > 0
  184. }, state.pagination.total > 0 ? {
  185. p: common_vendor.f(state.pagination.list, (item, k0, i0) => {
  186. return common_vendor.e({
  187. a: common_vendor.t(item.title),
  188. b: item.price >= 0
  189. }, item.price >= 0 ? {
  190. c: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.price))
  191. } : {
  192. d: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.price))
  193. }, {
  194. e: item.id
  195. });
  196. }),
  197. q: common_vendor.t(common_vendor.unref(sheep_index.sheep).$helper.timeFormat(state.createTime, "yyyy-mm-dd hh:MM:ss"))
  198. } : {}, {
  199. r: state.pagination.total > 0
  200. }, state.pagination.total > 0 ? {
  201. s: common_vendor.p({
  202. status: state.loadStatus,
  203. ["content-text"]: {
  204. contentdown: "上拉加载更多"
  205. }
  206. })
  207. } : {}, {
  208. t: common_vendor.s(_ctx.__cssVars()),
  209. v: common_vendor.p({
  210. title: "钱包"
  211. })
  212. });
  213. };
  214. }
  215. };
  216. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-69f29528"], ["__file", "/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-app/pages/user/wallet/money.vue"]]);
  217. wx.createPage(MiniProgramPage);