小程序端工程代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

255 lines
7.8 KiB

  1. <template>
  2. <view class="cash-withdrawal">
  3. <!-- <view class="nav acea-row">
  4. <view v-for="(item, navListIndex) in navList" class="item font-color-red" @click="swichNav(navListIndex, item)"
  5. :key="navListIndex">
  6. <view class="line bg-color-red" :class="currentTab === navListIndex ? 'on' : ''"></view>
  7. <view class="iconfont" :class="item.icon + ' ' + (currentTab === navListIndex ? 'on' : '')"></view>
  8. <view>{{ item.name }}</view>
  9. </view>
  10. </view> -->
  11. <div class="pos-order-list">
  12. <view class="nav acea-row row-around row-middle">
  13. <view v-for="(item, navListIndex) in navList" class="item" :class="currentTab === navListIndex ? 'on' : ''"
  14. @click="swichNav(navListIndex, item)" :key="navListIndex">{{item.name}}</view>
  15. </view>
  16. </div>
  17. <view class="wrapper">
  18. <view :hidden="currentTab !== 0" class="list">
  19. <view class="item acea-row row-between-wrapper">
  20. <view class="name">微信号</view>
  21. <view class="input">
  22. <input placeholder="请输入微信号" v-model="post.weixin" />
  23. </view>
  24. </view>
  25. <view class="item acea-row row-between-wrapper">
  26. <view class="name">提现</view>
  27. <view class="input">
  28. <input :placeholder="'最低提现金额' + minPrice" v-model="post.money" />
  29. </view>
  30. </view>
  31. <view class="tip">当前可提现金额: {{ commissionCount }}</view>
  32. <view class="bnt bg-color-red" @click="submitted">提现</view>
  33. </view>
  34. <view :hidden="currentTab !== 1" class="list">
  35. <view class="item acea-row row-between-wrapper">
  36. <view class="name">用户名</view>
  37. <view class="input">
  38. <input placeholder="请填写您的支付宝用户名" v-model="post.name" />
  39. </view>
  40. </view>
  41. <view class="item acea-row row-between-wrapper">
  42. <view class="name">账号</view>
  43. <view class="input">
  44. <input placeholder="请填写您的支付宝账号" v-model="post.alipay_code" />
  45. </view>
  46. </view>
  47. <view class="item acea-row row-between-wrapper">
  48. <view class="name">提现</view>
  49. <view class="input">
  50. <input :placeholder="'最低提现金额' + minPrice" v-model="post.money" />
  51. </view>
  52. </view>
  53. <view class="tip">当前可提现金额: {{ commissionCount }}</view>
  54. <view class="bnt bg-color-red" @click="submitted">提现</view>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import {
  61. getBank,
  62. postCashInfo
  63. } from "@/api/user";
  64. import {
  65. required
  66. } from "@/utils/validate";
  67. import {
  68. validatorDefaultCatch
  69. } from "@/utils/dialog";
  70. export default {
  71. name: "UserCash",
  72. components: {},
  73. props: {},
  74. data: function () {
  75. return {
  76. navList: [{
  77. name: "微信",
  78. type: "weixin",
  79. icon: "icon-weixin2"
  80. },
  81. {
  82. name: "支付宝",
  83. type: "alipay",
  84. icon: "icon-icon34"
  85. }
  86. ],
  87. post: {
  88. extract_type: "weixin",
  89. alipay_code: "",
  90. money: "",
  91. name: "",
  92. bankname: "",
  93. cardnum: "",
  94. weixin: ""
  95. },
  96. currentTab: 0,
  97. minPrice: 0,
  98. banks: [],
  99. commissionCount: 0
  100. };
  101. },
  102. mounted: function () {
  103. this.getBank();
  104. },
  105. methods: {
  106. swichNav: function (index, item) {
  107. console.log(item);
  108. this.currentTab = index;
  109. this.post.extract_type = item.type;
  110. },
  111. getBank: function () {
  112. let that = this;
  113. getBank().then(
  114. res => {
  115. that.banks = res.data.extractBank;
  116. that.minPrice = res.data.minPrice;
  117. that.commissionCount = res.data.commissionCount;
  118. },
  119. function (err) {
  120. uni.showToast({
  121. title: err.msg || err.response.data.msg || err.response.data.message,
  122. icon: "none",
  123. duration: 2000
  124. });
  125. }
  126. );
  127. },
  128. async submitted() {
  129. let bankname = this.post.bankname,
  130. alipay_code = this.post.alipay_code,
  131. money = this.post.money,
  132. name = this.post.name,
  133. cardnum = this.post.cardnum,
  134. weixin = this.post.weixin,
  135. that = this;
  136. // console.log(parseFloat(money))
  137. if (
  138. parseFloat(money) > parseFloat(that.commissionCount) ||
  139. parseFloat(that.commissionCount) == 0
  140. ) {
  141. uni.showToast({
  142. title: "余额不足",
  143. icon: "none",
  144. duration: 2000
  145. });
  146. return
  147. }
  148. if (parseFloat(money) < parseFloat(that.minPrice)) {
  149. uni.showToast({
  150. title: "最低提现金额" + that.minPrice,
  151. icon: "none",
  152. duration: 2000
  153. });
  154. return
  155. }
  156. //console.log(that.post.extract_type)
  157. switch (that.post.extract_type) {
  158. case "alipay":
  159. // if (!name) {
  160. // uni.showToast({
  161. // title: "请输入支付宝用户名",
  162. // icon: "none",
  163. // duration: 2000
  164. // });
  165. // return;
  166. // }
  167. // if (!alipay_code) {
  168. // uni.showToast({
  169. // title: "请输入支付宝账号",
  170. // icon: "none",
  171. // duration: 2000
  172. // });
  173. // return;
  174. // }
  175. // if (!money) {
  176. // uni.showToast({
  177. // title: "请输入提现金额",
  178. // icon: "none",
  179. // duration: 2000
  180. // });
  181. // return;
  182. // }
  183. try {
  184. await this.$validator({
  185. name: [required(required.message("支付宝用户名"))],
  186. alipay_code: [required(required.message("支付宝账号"))],
  187. money: [required(required.message("提现金额"))]
  188. }).validate({
  189. name,
  190. alipay_code,
  191. money
  192. });
  193. let save = {
  194. extractType: that.post.extract_type,
  195. alipayCode: alipay_code,
  196. name: name,
  197. money: money
  198. };
  199. that.save(save);
  200. } catch (e) {
  201. return validatorDefaultCatch(e);
  202. }
  203. break;
  204. case "weixin":
  205. try {
  206. await this.$validator({
  207. weixin: [required(required.message("提现微信号"))],
  208. money: [required(required.message("提现金额"))]
  209. }).validate({
  210. weixin,
  211. money
  212. });
  213. let save = {
  214. extractType: that.post.extract_type,
  215. weixin: weixin,
  216. money: money
  217. };
  218. that.save(save);
  219. } catch (e) {
  220. return validatorDefaultCatch(e);
  221. }
  222. break;
  223. }
  224. },
  225. save: function (info) {
  226. postCashInfo(info).then(
  227. res => {
  228. uni.showToast({
  229. title: res.msg,
  230. icon: "none",
  231. duration: 2000
  232. });
  233. this.$yrouter.push({
  234. path: "/pages/user/promotion/CashAudit/index"
  235. });
  236. },
  237. err => {
  238. uni.showToast({
  239. title: err.msg || err.response.data.msg || err.response.data.message,
  240. icon: "none",
  241. duration: 2000
  242. });
  243. }
  244. );
  245. }
  246. }
  247. };
  248. </script>
  249. <style lang="less">
  250. .cash-withdrawal .pos-order-list .nav .item.on {
  251. color: #eb3729
  252. }
  253. </style>