UserCash.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <template>
  2. <view class="cash-withdrawal">
  3. <!-- 头部背景 -->
  4. <view class="promoterHeader">
  5. <view class="headerCon acea-row row-between-wrapper">
  6. <view>
  7. <view class="name">提现申请</view>
  8. <view class="money">
  9. <text class="num">可提现: ¥{{ commissionCount || '0' }}</text>
  10. </view>
  11. </view>
  12. </view>
  13. </view>
  14. <!-- 内容区域 -->
  15. <view class="sign-record">
  16. <div class="pos-order-list">
  17. <view class="nav acea-row row-around row-middle">
  18. <view v-for="(item, navListIndex) in navList" class="item" :class="currentTab === navListIndex ? 'on' : ''"
  19. @click="swichNav(navListIndex, item)" :key="navListIndex">{{item.name}}</view>
  20. </view>
  21. </div>
  22. <view class="wrapper">
  23. <view :hidden="currentTab !== 0" class="list">
  24. <view class="item acea-row row-between-wrapper">
  25. <view class="name">微信号</view>
  26. <view class="input">
  27. <input placeholder="请输入微信号" v-model="post.weixin" />
  28. </view>
  29. </view>
  30. <view class="item acea-row row-between-wrapper">
  31. <view class="name">提现金额</view>
  32. <view class="input">
  33. <input :placeholder="'最低提现金额' + minPrice" v-model="post.money" />
  34. </view>
  35. </view>
  36. <view class="bnt bg-color-red" @click="submitted">提现</view>
  37. </view>
  38. <view :hidden="currentTab !== 1" class="list">
  39. <view class="item acea-row row-between-wrapper">
  40. <view class="name">用户名</view>
  41. <view class="input">
  42. <input placeholder="请填写您的支付宝用户名" v-model="post.name" />
  43. </view>
  44. </view>
  45. <view class="item acea-row row-between-wrapper">
  46. <view class="name">账号</view>
  47. <view class="input">
  48. <input placeholder="请填写您的支付宝账号" v-model="post.alipay_code" />
  49. </view>
  50. </view>
  51. <view class="item acea-row row-between-wrapper">
  52. <view class="name">提现金额</view>
  53. <view class="input">
  54. <input :placeholder="'最低提现金额' + minPrice" v-model="post.money" />
  55. </view>
  56. </view>
  57. <view class="bnt bg-color-red" @click="submitted">提现</view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. export default {
  65. name: "UserCash",
  66. data: function() {
  67. return {
  68. navList: [
  69. {
  70. name: "微信",
  71. type: "weixin",
  72. icon: "icon-weixin2"
  73. },
  74. {
  75. name: "支付宝",
  76. type: "alipay",
  77. icon: "icon-icon34"
  78. }
  79. ],
  80. post: {
  81. extract_type: "weixin",
  82. alipay_code: "",
  83. money: "",
  84. name: "",
  85. bankname: "",
  86. cardnum: "",
  87. weixin: ""
  88. },
  89. currentTab: 0,
  90. minPrice: 0,
  91. banks: [],
  92. commissionCount: 0,
  93. loading: false,
  94. loaded: false
  95. };
  96. },
  97. mounted: function() {
  98. this.getBank();
  99. },
  100. methods: {
  101. swichNav: function(index, item) {
  102. this.currentTab = index;
  103. this.post.extract_type = item.type;
  104. },
  105. getBank: function() {
  106. let that = this;
  107. if (that.loading) return;
  108. that.loading = true;
  109. uni.showLoading({
  110. title: '加载中...'
  111. });
  112. this.$api.request('get', 'user/app/extract/bank', {}).then(
  113. res => {
  114. uni.hideLoading();
  115. that.loading = false;
  116. that.banks = res.data.extractBank;
  117. that.minPrice = res.data.minPrice;
  118. that.commissionCount = res.data.commissionCount;
  119. },
  120. err => {
  121. uni.hideLoading();
  122. uni.showToast({
  123. title: err.msg || err.response.data.msg || err.response.data.message,
  124. icon: "none",
  125. duration: 2000
  126. });
  127. }
  128. );
  129. },
  130. async submitted() {
  131. let bankname = this.post.bankname,
  132. alipay_code = this.post.alipay_code,
  133. money = this.post.money,
  134. name = this.post.name,
  135. cardnum = this.post.cardnum,
  136. weixin = this.post.weixin,
  137. that = this;
  138. if (parseFloat(money) > parseFloat(that.commissionCount) || parseFloat(that.commissionCount) == 0) {
  139. uni.showToast({
  140. title: "余额不足",
  141. icon: "none",
  142. duration: 2000
  143. });
  144. return;
  145. }
  146. if (parseFloat(money) < parseFloat(that.minPrice)) {
  147. uni.showToast({
  148. title: "最低提现金额" + that.minPrice,
  149. icon: "none",
  150. duration: 2000
  151. });
  152. return;
  153. }
  154. if (that.loading) return;
  155. that.loading = true;
  156. uni.showLoading({
  157. title: '提交中...'
  158. });
  159. try {
  160. let params = {};
  161. if (that.post.extract_type === "alipay") {
  162. if (!name) {
  163. uni.showToast({
  164. title: "请输入支付宝用户名",
  165. icon: "none",
  166. duration: 2000
  167. });
  168. return;
  169. }
  170. if (!alipay_code) {
  171. uni.showToast({
  172. title: "请输入支付宝账号",
  173. icon: "none",
  174. duration: 2000
  175. });
  176. return;
  177. }
  178. params = {
  179. extractType: that.post.extract_type,
  180. alipayCode: alipay_code,
  181. name: name,
  182. money: money
  183. };
  184. } else {
  185. if (!weixin) {
  186. uni.showToast({
  187. title: "请输入提现微信号",
  188. icon: "none",
  189. duration: 2000
  190. });
  191. return;
  192. }
  193. params = {
  194. extractType: that.post.extract_type,
  195. weixin: weixin,
  196. money: money
  197. };
  198. }
  199. this.$api.request('post', 'user/app/extract/cash', params).then(
  200. res => {
  201. uni.hideLoading();
  202. that.loading = false;
  203. uni.showToast({
  204. title: res.msg,
  205. icon: "none",
  206. duration: 2000
  207. });
  208. // 5 秒后返回上一页
  209. setTimeout(() => {
  210. uni.navigateBack();
  211. }, 2000); // 5000 毫秒 = 5 秒
  212. },
  213. err => {
  214. uni.hideLoading();
  215. that.loading = false;
  216. uni.showToast({
  217. title: err.msg || err.response.data.msg || err.response.data.message,
  218. icon: "none",
  219. duration: 2000
  220. });
  221. }
  222. );
  223. } catch (e) {
  224. uni.hideLoading();
  225. that.loading = false;
  226. uni.showToast({
  227. title: e.message || "提交失败",
  228. icon: "none",
  229. duration: 2000
  230. });
  231. }
  232. }
  233. }
  234. };
  235. </script>
  236. <style lang="less">
  237. .cash-withdrawal {
  238. .promoterHeader {
  239. background-image: url('https://kxmalls.oss-cn-hangzhou.aliyuncs.com/bg/bg.png');
  240. background-repeat: no-repeat;
  241. background-size: 100% 100%;
  242. width: 100%;
  243. height: 300rpx;
  244. padding: 0 50rpx;
  245. box-sizing: border-box;
  246. color: #fff;
  247. .headerCon {
  248. padding: 50rpx 0;
  249. .name {
  250. font-size: 28rpx;
  251. opacity: 0.9;
  252. margin-bottom: 10rpx;
  253. }
  254. .money {
  255. font-size: 36rpx;
  256. font-weight: bold;
  257. line-height: 1.2;
  258. font-family: 'Arial Rounded MT Bold', 'Helvetica Rounded', sans-serif;
  259. text-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.1);
  260. .num {
  261. font-size: 48rpx;
  262. font-family: 'GuildfordProBook 5';
  263. }
  264. }
  265. }
  266. }
  267. .sign-record {
  268. background-color: #fff;
  269. border-radius: 16rpx 16rpx 0 0;
  270. margin-top: -20rpx;
  271. padding: 0 30rpx;
  272. .pos-order-list {
  273. .nav {
  274. padding: 30rpx 0;
  275. .item {
  276. font-size: 28rpx;
  277. color: #666;
  278. padding: 10rpx 0;
  279. position: relative;
  280. &.on {
  281. color: #eb3729;
  282. font-weight: bold;
  283. &:after {
  284. content: '';
  285. position: absolute;
  286. bottom: 0;
  287. left: 50%;
  288. transform: translateX(-50%);
  289. width: 60rpx;
  290. height: 4rpx;
  291. background-color: #eb3729;
  292. border-radius: 2rpx;
  293. }
  294. }
  295. }
  296. }
  297. }
  298. .wrapper {
  299. .list {
  300. .item {
  301. padding: 30rpx 0;
  302. border-bottom: 1rpx solid #f5f5f5;
  303. .name {
  304. font-size: 28rpx;
  305. color: #333;
  306. width: 150rpx;
  307. }
  308. .input {
  309. flex: 1;
  310. input {
  311. text-align: right;
  312. font-size: 28rpx;
  313. color: #666;
  314. }
  315. }
  316. }
  317. .bnt {
  318. margin: 50rpx auto;
  319. width: 90%;
  320. height: 80rpx;
  321. border-radius: 40rpx;
  322. text-align: center;
  323. line-height: 80rpx;
  324. color: #fff;
  325. font-size: 30rpx;
  326. font-weight: bold;
  327. }
  328. }
  329. }
  330. }
  331. }
  332. .acea-row {
  333. display: flex;
  334. flex-wrap: wrap;
  335. }
  336. .row-between-wrapper {
  337. justify-content: space-between;
  338. align-items: center;
  339. }
  340. .row-around {
  341. justify-content: space-around;
  342. }
  343. .row-middle {
  344. align-items: center;
  345. }
  346. .font-color-red {
  347. color: #2AAC34;
  348. }
  349. .bg-color-red {
  350. background-color: #2AAC34;
  351. }
  352. </style>