wallet.js 10 KB

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