withdraw.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const sheep_index = require("../../sheep/index.js");
  4. const sheep_hooks_useGoods = require("../../sheep/hooks/useGoods.js");
  5. const sheep_api_trade_config = require("../../sheep/api/trade/config.js");
  6. const sheep_api_trade_brokerage = require("../../sheep/api/trade/brokerage.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. require("../../sheep/util/index.js");
  40. if (!Array) {
  41. const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
  42. const _easycom_s_uploader2 = common_vendor.resolveComponent("s-uploader");
  43. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  44. (_easycom_uni_easyinput2 + _easycom_s_uploader2 + _easycom_s_layout2)();
  45. }
  46. const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
  47. const _easycom_s_uploader = () => "../../sheep/components/s-uploader/s-uploader.js";
  48. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  49. if (!Math) {
  50. (_easycom_uni_easyinput + _easycom_s_uploader + accountTypeSelect + _easycom_s_layout)();
  51. }
  52. const accountTypeSelect = () => "./components/account-type-select.js";
  53. const _sfc_main = {
  54. __name: "withdraw",
  55. setup(__props) {
  56. common_vendor.useCssVars((_ctx) => ({
  57. "11aa8d88": common_vendor.unref(headerBg)
  58. }));
  59. const headerBg = sheep_index.sheep.$url.css("/static/img/shop/user/withdraw_bg.png");
  60. const statusBarHeight = sheep_index.sheep.$platform.device.statusBarHeight * 2;
  61. const userStore = sheep_index.sheep.$store("user");
  62. common_vendor.computed(() => userStore.userInfo);
  63. const state = common_vendor.reactive({
  64. accountInfo: {
  65. // 提现表单
  66. type: void 0,
  67. accountNo: void 0,
  68. accountQrCodeUrl: void 0,
  69. name: void 0,
  70. bankName: void 0,
  71. bankAddress: void 0
  72. },
  73. accountSelect: false,
  74. brokerageInfo: {},
  75. // 分销信息
  76. frozenDays: 0,
  77. // 冻结天数
  78. minPrice: 0,
  79. // 最低提现金额
  80. withdrawTypes: []
  81. // 提现方式
  82. });
  83. const onAccountSelect = (e) => {
  84. state.accountSelect = e;
  85. };
  86. const onConfirm = async () => {
  87. debugger;
  88. if (!state.accountInfo.price || state.accountInfo.price > state.brokerageInfo.price || state.accountInfo.price <= 0) {
  89. sheep_index.sheep.$helper.toast("请输入正确的提现金额");
  90. return;
  91. }
  92. if (!state.accountInfo.type) {
  93. sheep_index.sheep.$helper.toast("请选择提现方式");
  94. return;
  95. }
  96. let { code } = await sheep_api_trade_brokerage.BrokerageApi.createBrokerageWithdraw({
  97. ...state.accountInfo,
  98. price: state.accountInfo.price * 100
  99. });
  100. if (code !== 0) {
  101. return;
  102. }
  103. common_vendor.index.showModal({
  104. title: "操作成功",
  105. content: "您的提现申请已成功提交",
  106. cancelText: "继续提现",
  107. confirmText: "查看记录",
  108. success: (res) => {
  109. if (res.confirm) {
  110. sheep_index.sheep.$router.go("/pages/commission/wallet", { type: 2 });
  111. return;
  112. }
  113. getBrokerageUser();
  114. state.accountInfo = {};
  115. }
  116. });
  117. };
  118. async function getWithdrawRules() {
  119. let { code, data } = await sheep_api_trade_config.TradeConfigApi.getTradeConfig();
  120. if (code !== 0) {
  121. return;
  122. }
  123. if (data) {
  124. state.minPrice = data.brokerageWithdrawMinPrice || 0;
  125. state.frozenDays = data.brokerageFrozenDays || 0;
  126. state.withdrawTypes = data.brokerageWithdrawTypes;
  127. }
  128. }
  129. async function getBrokerageUser() {
  130. const { data, code } = await sheep_api_trade_brokerage.BrokerageApi.getBrokerageUser();
  131. if (code === 0) {
  132. state.brokerageInfo = data;
  133. }
  134. }
  135. common_vendor.onBeforeMount(() => {
  136. getWithdrawRules();
  137. getBrokerageUser();
  138. });
  139. return (_ctx, _cache) => {
  140. return common_vendor.e({
  141. a: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.brokerageInfo.brokeragePrice)),
  142. b: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/commission/wallet", {
  143. type: 2
  144. })),
  145. c: common_vendor.s({
  146. marginTop: "-" + Number(statusBarHeight + 88) + "rpx",
  147. paddingTop: Number(statusBarHeight + 108) + "rpx"
  148. }),
  149. d: !state.accountInfo.type
  150. }, !state.accountInfo.type ? {} : {}, {
  151. e: state.accountInfo.type === "1"
  152. }, state.accountInfo.type === "1" ? {} : {}, {
  153. f: state.accountInfo.type === "2"
  154. }, state.accountInfo.type === "2" ? {} : {}, {
  155. g: state.accountInfo.type === "3"
  156. }, state.accountInfo.type === "3" ? {} : {}, {
  157. h: state.accountInfo.type === "4"
  158. }, state.accountInfo.type === "4" ? {} : {}, {
  159. i: common_vendor.o(($event) => onAccountSelect(true)),
  160. j: common_vendor.o(($event) => state.accountInfo.price = $event),
  161. k: common_vendor.p({
  162. inputBorder: false,
  163. type: "number",
  164. placeholder: "请输入提现金额",
  165. modelValue: state.accountInfo.price
  166. }),
  167. l: ["2", "3", "4"].includes(state.accountInfo.type),
  168. m: common_vendor.o(($event) => state.accountInfo.accountNo = $event),
  169. n: common_vendor.p({
  170. inputBorder: false,
  171. placeholder: "请输入提现账号",
  172. modelValue: state.accountInfo.accountNo
  173. }),
  174. o: ["2", "3", "4"].includes(state.accountInfo.type),
  175. p: ["2", "3"].includes(state.accountInfo.type),
  176. q: common_vendor.o(($event) => state.accountInfo.accountQrCodeUrl = $event),
  177. r: common_vendor.p({
  178. fileMediatype: "image",
  179. limit: "1",
  180. mode: "grid",
  181. imageStyles: {
  182. width: "168rpx",
  183. height: "168rpx"
  184. },
  185. url: state.accountInfo.accountQrCodeUrl
  186. }),
  187. s: ["2", "3"].includes(state.accountInfo.type),
  188. t: state.accountInfo.type === "4",
  189. v: common_vendor.o(($event) => state.accountInfo.name = $event),
  190. w: common_vendor.p({
  191. inputBorder: false,
  192. placeholder: "请输入持卡人姓名",
  193. modelValue: state.accountInfo.name
  194. }),
  195. x: state.accountInfo.type === "4",
  196. y: state.accountInfo.type === "4",
  197. z: common_vendor.o(($event) => state.accountInfo.bankName = $event),
  198. A: common_vendor.p({
  199. inputBorder: false,
  200. placeholder: "请输入提现银行",
  201. modelValue: state.accountInfo.bankName
  202. }),
  203. B: state.accountInfo.type === "4",
  204. C: state.accountInfo.type === "4",
  205. D: common_vendor.o(($event) => state.accountInfo.bankAddress = $event),
  206. E: common_vendor.p({
  207. inputBorder: false,
  208. placeholder: "请输入开户地址",
  209. modelValue: state.accountInfo.bankAddress
  210. }),
  211. F: state.accountInfo.type === "4",
  212. G: common_vendor.o(onConfirm),
  213. H: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.minPrice)),
  214. I: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.brokerageInfo.frozenPrice)),
  215. J: common_vendor.t(state.frozenDays),
  216. K: common_vendor.o(($event) => onAccountSelect(false)),
  217. L: common_vendor.o(($event) => state.accountInfo = $event),
  218. M: common_vendor.p({
  219. show: state.accountSelect,
  220. round: "10",
  221. methods: state.withdrawTypes,
  222. modelValue: state.accountInfo
  223. }),
  224. N: common_vendor.s(_ctx.__cssVars()),
  225. O: common_vendor.p({
  226. title: "申请提现",
  227. navbar: "inner"
  228. })
  229. });
  230. };
  231. }
  232. };
  233. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-cf14c8af"], ["__file", "D:/zx/mall-front-app/pages/commission/withdraw.vue"]]);
  234. wx.createPage(MiniProgramPage);