wallet.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const sheep_index = require("../../sheep/index.js");
  4. const sheep_api_trade_brokerage = require("../../sheep/api/trade/brokerage.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/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/config/zIndex.js");
  38. if (!Array) {
  39. const _easycom_uni_datetime_picker2 = common_vendor.resolveComponent("uni-datetime-picker");
  40. const _easycom_su_tabs2 = common_vendor.resolveComponent("su-tabs");
  41. const _easycom_su_sticky2 = common_vendor.resolveComponent("su-sticky");
  42. const _easycom_s_empty2 = common_vendor.resolveComponent("s-empty");
  43. const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
  44. const _easycom_su_popup2 = common_vendor.resolveComponent("su-popup");
  45. const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
  46. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  47. (_easycom_uni_datetime_picker2 + _easycom_su_tabs2 + _easycom_su_sticky2 + _easycom_s_empty2 + _easycom_uni_easyinput2 + _easycom_su_popup2 + _easycom_uni_load_more2 + _easycom_s_layout2)();
  48. }
  49. const _easycom_uni_datetime_picker = () => "../../uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.js";
  50. const _easycom_su_tabs = () => "../../sheep/ui/su-tabs/su-tabs.js";
  51. const _easycom_su_sticky = () => "../../sheep/ui/su-sticky/su-sticky.js";
  52. const _easycom_s_empty = () => "../../sheep/components/s-empty/s-empty.js";
  53. const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
  54. const _easycom_su_popup = () => "../../sheep/ui/su-popup/su-popup.js";
  55. const _easycom_uni_load_more = () => "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
  56. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  57. if (!Math) {
  58. (_easycom_uni_datetime_picker + _easycom_su_tabs + _easycom_su_sticky + _easycom_s_empty + _easycom_uni_easyinput + _easycom_su_popup + _easycom_uni_load_more + _easycom_s_layout)();
  59. }
  60. const _sfc_main = {
  61. __name: "wallet",
  62. setup(__props) {
  63. common_vendor.useCssVars((_ctx) => ({
  64. "bce371da": common_vendor.unref(headerBg)
  65. }));
  66. const headerBg = sheep_index.sheep.$url.css("/static/img/shop/user/wallet_card_bg.png");
  67. const state = common_vendor.reactive({
  68. showMoney: false,
  69. summary: {},
  70. // 分销信息
  71. today: "",
  72. date: [],
  73. currentTab: 0,
  74. pagination: {
  75. list: [],
  76. total: 0,
  77. pageNo: 1,
  78. pageSize: 1
  79. },
  80. loadStatus: "",
  81. price: void 0,
  82. showModal: false
  83. });
  84. const tabMaps = [
  85. {
  86. name: "分佣",
  87. value: "1"
  88. // BrokerageRecordBizTypeEnum.ORDER
  89. },
  90. {
  91. name: "提现",
  92. value: "2"
  93. // BrokerageRecordBizTypeEnum.WITHDRAW
  94. }
  95. ];
  96. const dateFilterText = common_vendor.computed(() => {
  97. if (state.date[0] === state.date[1]) {
  98. return state.date[0];
  99. } else {
  100. return state.date.join("~");
  101. }
  102. });
  103. async function getLogList() {
  104. state.loadStatus = "loading";
  105. let { code, data } = await sheep_api_trade_brokerage.BrokerageApi.getBrokerageRecordPage({
  106. pageSize: state.pagination.pageSize,
  107. pageNo: state.pagination.pageNo,
  108. bizType: tabMaps[state.currentTab].value,
  109. "createTime[0]": state.date[0] + " 00:00:00",
  110. "createTime[1]": state.date[1] + " 23:59:59"
  111. });
  112. if (code !== 0) {
  113. return;
  114. }
  115. state.pagination.list = common_vendor._.concat(state.pagination.list, data.list);
  116. state.pagination.total = data.total;
  117. state.loadStatus = state.pagination.list.length < state.pagination.total ? "more" : "noMore";
  118. }
  119. function onChangeTab(e) {
  120. sheep_util_index.resetPagination(state.pagination);
  121. state.currentTab = e.index;
  122. getLogList();
  123. }
  124. function onChangeTime(e) {
  125. state.date[0] = e[0];
  126. state.date[1] = e[e.length - 1];
  127. sheep_util_index.resetPagination(state.pagination);
  128. getLogList();
  129. }
  130. async function onConfirm() {
  131. if (state.price <= 0) {
  132. sheep_index.sheep.$helper.toast("请输入正确的金额");
  133. return;
  134. }
  135. common_vendor.index.showModal({
  136. title: "提示",
  137. content: "确认把您的佣金转入到余额钱包中?",
  138. success: async function(res) {
  139. if (!res.confirm) {
  140. return;
  141. }
  142. const { code } = await sheep_api_trade_brokerage.BrokerageApi.createBrokerageWithdraw({
  143. type: 1,
  144. // 钱包
  145. price: state.price * 100
  146. });
  147. if (code === 0) {
  148. state.showModal = false;
  149. await getAgentInfo();
  150. onChangeTab({
  151. index: 1
  152. });
  153. }
  154. }
  155. });
  156. }
  157. async function getAgentInfo() {
  158. const { code, data } = await sheep_api_trade_brokerage.BrokerageApi.getBrokerageUserSummary();
  159. if (code !== 0) {
  160. return;
  161. }
  162. state.summary = data;
  163. }
  164. common_vendor.onLoad(async (options) => {
  165. state.today = common_vendor.dayjs().format("YYYY-MM-DD");
  166. state.date = [state.today, state.today];
  167. if (options.type === 2) {
  168. state.currentTab = 1;
  169. }
  170. getLogList();
  171. getAgentInfo();
  172. });
  173. common_vendor.onReachBottom(() => {
  174. if (state.loadStatus === "noMore") {
  175. return;
  176. }
  177. state.pagination.pageNo++;
  178. getLogList();
  179. });
  180. return (_ctx, _cache) => {
  181. return common_vendor.e({
  182. a: common_vendor.o(($event) => state.showMoney = !state.showMoney),
  183. b: common_vendor.n(state.showMoney ? "cicon-eye" : "cicon-eye-off"),
  184. c: common_vendor.t(state.showMoney ? common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.summary.withdrawPrice || 0) : "*****"),
  185. d: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/commission/withdraw")),
  186. e: common_vendor.o(($event) => state.showModal = true),
  187. f: common_vendor.t(state.showMoney ? common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.summary.frozenPrice || 0) : "*****"),
  188. g: common_vendor.t(state.showMoney ? common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.summary.brokeragePrice || 0) : "*****"),
  189. h: common_vendor.t(common_vendor.unref(dateFilterText)),
  190. i: common_vendor.o(onChangeTime),
  191. j: common_vendor.o(($event) => state.date = $event),
  192. k: common_vendor.p({
  193. type: "daterange",
  194. end: state.today,
  195. modelValue: state.date
  196. }),
  197. l: common_vendor.o(onChangeTab),
  198. m: common_vendor.p({
  199. list: tabMaps,
  200. scrollable: false,
  201. current: state.currentTab
  202. }),
  203. n: state.pagination.total === 0
  204. }, state.pagination.total === 0 ? {
  205. o: common_vendor.p({
  206. icon: "/static/data-empty.png",
  207. text: "暂无数据"
  208. })
  209. } : {}, {
  210. p: common_vendor.o(($event) => state.price = $event),
  211. q: common_vendor.p({
  212. inputBorder: false,
  213. type: "number",
  214. placeholder: "请输入金额",
  215. modelValue: state.price
  216. }),
  217. r: common_vendor.o(onConfirm),
  218. s: common_vendor.o(($event) => state.showModal = false),
  219. t: common_vendor.p({
  220. show: state.showModal,
  221. type: "bottom",
  222. round: "20",
  223. showClose: true
  224. }),
  225. v: state.pagination.total > 0
  226. }, state.pagination.total > 0 ? {
  227. w: common_vendor.f(state.pagination.list, (item, k0, i0) => {
  228. return common_vendor.e({
  229. a: common_vendor.t(item.title),
  230. b: item.price >= 0
  231. }, item.price >= 0 ? {
  232. c: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.price))
  233. } : {
  234. d: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.price))
  235. }, {
  236. e: common_vendor.t(common_vendor.unref(sheep_index.sheep).$helper.timeFormat(item.createTime, "yyyy-mm-dd hh:MM:ss")),
  237. f: item.id
  238. });
  239. })
  240. } : {}, {
  241. x: state.pagination.total > 0
  242. }, state.pagination.total > 0 ? {
  243. y: common_vendor.p({
  244. status: state.loadStatus,
  245. ["content-text"]: {
  246. contentdown: "上拉加载更多"
  247. }
  248. })
  249. } : {}, {
  250. z: common_vendor.s(_ctx.__cssVars()),
  251. A: common_vendor.p({
  252. title: "佣金"
  253. })
  254. });
  255. };
  256. }
  257. };
  258. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-52afd294"], ["__file", "/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-app/pages/commission/wallet.vue"]]);
  259. wx.createPage(MiniProgramPage);