index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <view class="container">
  3. <navBar title="提现" :back="true" color="#333333" background="#FFFFFF" />
  4. <view class='box'>
  5. <view class='addpd'>
  6. <view class='top'>
  7. <view class='left'>
  8. 提现方式
  9. </view>
  10. <view class='right' @click="handleOpen">
  11. <image class='icon' mode=""
  12. :src="currWayIndex[0]==0?picBase+'wechat.png':currWayIndex[0]==1?picBase+'zhifubao.png':picBase+'yhk.png'" />
  13. {{currWay}}
  14. <image class='icon_arrR' mode="" :src="picBase+ 'c_arrR.png'" />
  15. </view>
  16. </view>
  17. <view class='money'>
  18. <view class='label'>
  19. 提现金额
  20. </view>
  21. <view class='bot'>
  22. <view class='left'>
  23. <view class='danwei'>
  24. </view>
  25. <input class="" placeholder="请输入提现金额" v-model="formData.money">
  26. </input>
  27. </view>
  28. <view class='tips'>
  29. 可提现余额¥{{availMoney}}
  30. </view>
  31. </view>
  32. </view>
  33. <view class='info'>
  34. <view class='item bb'>
  35. <view class='label'>
  36. 名字
  37. </view>
  38. <input class="" placeholder="名字" v-model="formData.name">
  39. </input>
  40. </view>
  41. <view class='item bb' v-if="currWay=='银行卡'">
  42. <view class='label'>
  43. 开户行
  44. </view>
  45. <input class="" placeholder="请输入开户行名称" v-model="formData.bankName">
  46. </input>
  47. </view>
  48. <view class='item'>
  49. <view class='label'>
  50. 账号
  51. </view>
  52. <input class="" placeholder="账号" v-model="formData.account">
  53. </input>
  54. </view>
  55. </view>
  56. <view class='botTxt'>
  57. <!-- <image class='icon' mode="" src="{{picBaseUrl+'winfo.png'}}"/> -->
  58. <image class='icon' mode="" :src="picBase+'info_b.png'" />
  59. <view class='right'>
  60. <view class='item' @click="toCashRecord">
  61. 提现记录
  62. </view>
  63. <view class='item' style="color:black;margin-top: 10rpx;">
  64. 单次最低提现金额为{{min}}元
  65. </view>
  66. <view class='item' style="color:black;">
  67. 收取提现金额的{{Ratio}}%手续费
  68. </view>
  69. <view class='item' style="color:black;">
  70. 如有疑问,请及时联系客服
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. <u-picker :show="showPopup" :columns="wayList" title="提现方式" aColor="#007AFF" :defaultIndex="currWayIndex"
  77. :closeOnClickOverlay="true" @confirm="handleConfirm" @cancel="showPopup=false"></u-picker>
  78. <view class="btnBox">
  79. <view class="btn" @click="post">
  80. 提交申请
  81. </view>
  82. </view>
  83. </view>
  84. </template>
  85. <script>
  86. // import navBar from '@/components/navBar/index.vue'
  87. import {
  88. userWithdraw,
  89. getYongjinList,
  90. getPosterBg
  91. } from '@/api/index/index.js'
  92. export default {
  93. // components: {
  94. // navBar
  95. // },
  96. data() {
  97. return {
  98. picBase: this.$picBase2,
  99. wayList: [
  100. [
  101. '微信余额',
  102. '支付宝',
  103. '银行卡'
  104. ]
  105. ],
  106. currWay: '微信余额',
  107. currWayIndex: [0],
  108. availMoney: 0,
  109. formData: {
  110. money: '',
  111. name: '',
  112. account: '',
  113. bankName: ''
  114. },
  115. showPopup: false,
  116. Ratio: 0,
  117. min: 0
  118. }
  119. },
  120. onLoad(o) {
  121. // if (getApp().availMoney) {
  122. // this.availMoney = Number(o.availMoney || 0)
  123. // console.log('传递过来的可提现余额', o.availMoney)
  124. // }
  125. this.getCashTip()
  126. },
  127. onShow() {
  128. this.getYongjinList()
  129. },
  130. methods: {
  131. async getCashTip() {
  132. let res1 = await getPosterBg({
  133. key: 'withdraw'
  134. })
  135. console.log('提现提示返回值--------1', res1);
  136. if (res1.code == 0) {
  137. this.Ratio = res1.data.value
  138. } else {
  139. this.$toast(res1.message)
  140. }
  141. let res2 = await getPosterBg({
  142. key: 'withdraw_min'
  143. })
  144. console.log('提现提示返回值--------2', res2);
  145. if (res2.code == 0) {
  146. this.min = res2.data.value
  147. } else {
  148. this.$toast(res2.message)
  149. }
  150. },
  151. async getYongjinList() {
  152. let res1 = await getYongjinList()
  153. console.log('佣金明细返回值--------', res1);
  154. if (res1.code == 0) {
  155. this.availMoney = Number(res1.data.withdrawIncome || 0)
  156. console.log('可提现佣金--------', this.availMoney);
  157. } else {
  158. this.$toast(res1.message)
  159. }
  160. },
  161. async post() {
  162. if (Number(this.formData.money) > this.availMoney) {
  163. return wx.showToast({
  164. title: '可提现余额不足',
  165. icon: 'none'
  166. })
  167. } else
  168. if (!this.formData.money) {
  169. return wx.showToast({
  170. title: '请输入提现金额',
  171. icon: 'none'
  172. })
  173. } else if (Number(this.formData.money) < Number(this.min)) {
  174. return wx.showToast({
  175. title: '单次最低提现金额为' + this.min,
  176. icon: 'none'
  177. })
  178. } else if (!this.formData.name) {
  179. return wx.showToast({
  180. title: '请输入名字',
  181. icon: 'none'
  182. })
  183. } else if (!this.formData.bankName && this.currWay == '银行卡') {
  184. return wx.showToast({
  185. title: '请输入开户行名称',
  186. icon: 'none'
  187. })
  188. } else if (!this.formData.account) {
  189. return wx.showToast({
  190. title: '请输入账号',
  191. icon: 'none'
  192. })
  193. }
  194. let p = {}
  195. if (this.currWayIndex[0] == 0) {
  196. p = {
  197. type: this.currWayIndex[0] + 1,
  198. amount: this.formData.money,
  199. name: this.formData.name,
  200. number: this.formData.account,
  201. }
  202. } else if (this.currWayIndex[0] == 1) {
  203. p = {
  204. type: this.currWayIndex[0] + 1,
  205. amount: this.formData.money,
  206. name: this.formData.name,
  207. number: this.formData.account,
  208. }
  209. } else {
  210. p = {
  211. type: this.currWayIndex[0] + 1,
  212. amount: this.formData.money,
  213. name: this.formData.name,
  214. number: this.formData.account,
  215. bank_name: this.formData.bankName,
  216. }
  217. }
  218. console.log('提现参数', p, this.formData, this.currWayIndex[0]);
  219. // return
  220. let res1 = await userWithdraw(p)
  221. console.log('提现返回值--------', res1);
  222. if (res1.code == 0) {
  223. this.$toast('提交成功', 'success')
  224. setTimeout(() => {
  225. uni.redirectTo({
  226. url: '/pages/my/cashRecord/index'
  227. })
  228. }, 1500)
  229. } else {
  230. this.$toast(res1.message)
  231. }
  232. },
  233. handleConfirm(e) {
  234. console.log('e', e, );
  235. this.currWay = e.value[0]
  236. this.currWayIndex = e.indexs
  237. this.showPopup = false
  238. },
  239. handleOpen() {
  240. this.showPopup = true
  241. },
  242. // post() {
  243. // console.log('提现参数', this.formData, this.currWayIndex);
  244. // },
  245. toCashRecord() {
  246. uni.navigateTo({
  247. url: '/pages/my/cashRecord/index'
  248. })
  249. }
  250. }
  251. }
  252. </script>
  253. <style lang="scss" scoped>
  254. @import "./index.scss";
  255. </style>