withdraw.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <view class="withdraw">
  3. <view class="overage">
  4. 账户剩余金额:<text class="number">{{ userInfo.income }}元</text>
  5. </view>
  6. <view class="input-box main-left cross-center">
  7. <view class="left">¥</view>
  8. <view class="center">
  9. <input v-model="price" type="text" placeholder="请输入提现金额">
  10. </view>
  11. <view class="right" @click="handleAll">全部</view>
  12. </view>
  13. <view class="tips">
  14. <view>提现金额不能小于{{ setting.withdraw_min }}元</view>
  15. <view>提现需要加收{{ setting.withdraw_discount }}%手续费</view>
  16. </view>
  17. <view class="type-box main-between cross-center" @click="show = true">
  18. <view>提现方式</view>
  19. <view class="main-left cross-center">
  20. <text>{{ selectType.name }}</text>
  21. <u-icon name="arrow-right" :color="$colors.infoColor" bold top="1" />
  22. </view>
  23. </view>
  24. <template v-if="Object.keys(selectType).length">
  25. <view class="input-box main-left cross-center">
  26. <view class="left">姓名</view>
  27. <view class="center">
  28. <input v-model="name" type="text" placeholder="请输入姓名">
  29. </view>
  30. </view>
  31. <view class="input-box main-left cross-center">
  32. <view class="left">手机号</view>
  33. <view class="center">
  34. <input v-model="phone_num" type="number" placeholder="请输入手机号">
  35. </view>
  36. </view>
  37. <template v-if="selectType.value === 3">
  38. <view class="input-box main-left cross-center">
  39. <view class="left">提现银行</view>
  40. <view class="center">
  41. <input v-model="bank_name" type="text" placeholder="请输入提现银行">
  42. </view>
  43. </view>
  44. </template>
  45. <view class="input-box main-left cross-center">
  46. <view class="left">提现账号</view>
  47. <view class="center">
  48. <input v-model="account" type="text" placeholder="请输入提现账号">
  49. </view>
  50. </view>
  51. </template>
  52. <view class="btn" @click="handleConfirm">提交申请</view>
  53. <!-- 选择提现方式 -->
  54. <u-popup
  55. :show="show"
  56. :round="20"
  57. closeable
  58. @close="handleClose"
  59. >
  60. <view class="popup-content">
  61. <view
  62. v-for="(type, index) in types"
  63. :key="index"
  64. class="type-item main-between cross-center"
  65. @click="handleSelect(type, index)"
  66. >
  67. <view class="left-box dir-left-nowrap cross-center">
  68. <view class="icon" :class="{bank: index === 2}">
  69. <image :src="type.icon" />
  70. </view>
  71. <text>{{ type.name }}</text>
  72. </view>
  73. <u-icon v-if="selectIndex === index" name="checkmark" color="#68EBE9" size="24" />
  74. </view>
  75. </view>
  76. </u-popup>
  77. </view>
  78. </template>
  79. <script>
  80. import { mapState } from 'vuex'
  81. export default {
  82. name: 'Withdraw',
  83. data() {
  84. return {
  85. price: '',
  86. account: '',
  87. name: '',
  88. phone_num: '',
  89. bank_name: '',
  90. setting: { withdraw_min: 0, withdraw_discount: 0 },
  91. show: false,
  92. types: [
  93. { icon: '/static/image/share/wechat.png', value: 1, name: '微信线下打款' },
  94. { icon: '/static/image/share/alipay.png', value: 2, name: '支付宝线下打款' },
  95. { icon: '/static/image/share/bank.png', value: 3, name: '银联线下打款' }
  96. ],
  97. selectIndex: 0,
  98. selectType: {}
  99. }
  100. },
  101. computed: {
  102. ...mapState({
  103. userInfo: seate => seate.user.info
  104. })
  105. },
  106. methods: {
  107. handleConfirm() {
  108. if (!this.price) {
  109. this.$u.toast(`请输入提现金额`)
  110. return
  111. }
  112. if (Object.keys(this.selectType).length === 0) {
  113. this.$u.toast(`请选择提现方式`)
  114. return
  115. }
  116. if (parseFloat(this.price) < parseFloat(this.setting.withdraw_min)) {
  117. this.$u.toast(`提现金额不能小于${this.setting.withdraw_min}元`)
  118. return
  119. }
  120. if (!this.name) {
  121. this.$u.toast(`请输入姓名`)
  122. return
  123. }
  124. if (!this.phone_num) {
  125. this.$u.toast(`请输入手机号`)
  126. return
  127. }
  128. if (!this.account) {
  129. this.$u.toast(`请输入账号`)
  130. return
  131. }
  132. if (parseFloat(this.price) > this.userInfo.income) {
  133. this.$u.toast(`提现金额不能大于可提现余额`)
  134. return
  135. }
  136. if (Object.keys(this.selectType).length === 0) {
  137. this.$u.toast(`请选择提现方式`)
  138. return
  139. }
  140. if (this.selectType.value === 3 && !this.bank_name) {
  141. this.$u.toast(`请输入提现银行`)
  142. return
  143. }
  144. const params = {
  145. price: this.price,
  146. type: this.selectType.value,
  147. account: this.account,
  148. name: this.name,
  149. phone_num: this.phone_num,
  150. bank_name: this.bank_name
  151. }
  152. this.$loading()
  153. this.$api.share.withdraw.create(params).then(res => {
  154. this.$hideLoading()
  155. this.$u.toast(`提交成功`)
  156. this.$api.user.info().then(res => {
  157. this.$store.dispatch('user/info', res.data)
  158. setTimeout(() => {
  159. this.$u.route({ type: 'redirect', url: '/pages/share/withdrawDetail?active=1' })
  160. }, 500)
  161. })
  162. }).catch(() => {
  163. this.$hideLoading()
  164. })
  165. },
  166. handleAll() {
  167. this.price = this.userInfo.income
  168. },
  169. handleSelect(item, index) {
  170. this.selectIndex = index
  171. this.selectType = item
  172. this.handleClose()
  173. },
  174. handleClose() {
  175. this.show = false
  176. },
  177. getSetting() {
  178. this.$loading()
  179. this.$api.share.setting().then(res => {
  180. this.$hideLoading()
  181. this.setting = res.data
  182. })
  183. }
  184. },
  185. onLoad() {
  186. this.getSetting()
  187. }
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. .withdraw {
  192. padding: 30rpx 30rpx 80rpx;
  193. color: #FFFFFF;
  194. font-size: 38rpx;
  195. .overage{
  196. font-weight: bold;
  197. padding-bottom: 30rpx;
  198. border-bottom: 1rpx solid #232849;
  199. .number{
  200. color: #6eebe8;
  201. }
  202. }
  203. .input-box{
  204. padding: 30rpx 0;
  205. border-bottom: 1rpx solid #232849;
  206. .left{
  207. width: 180rpx;
  208. }
  209. .center{
  210. flex: 1;
  211. margin-left: 10rpx;
  212. }
  213. .right{
  214. font-size: 28rpx;
  215. color: #6eebe8;
  216. }
  217. }
  218. .tips{
  219. background: #1c203b;
  220. border-radius: 20rpx;
  221. padding: 30rpx 20rpx;
  222. color: #ccc;
  223. margin: 30rpx 0;
  224. font-size: 24rpx;
  225. }
  226. .type-box{
  227. border-bottom: 1rpx solid #232849;
  228. padding: 30rpx 0;
  229. text{
  230. margin-right: 10rpx;
  231. font-size: 32rpx;
  232. }
  233. }
  234. .btn{
  235. background: linear-gradient(270deg, #6EEBE8 0%, #FF74B9 100%);
  236. text-align: center;
  237. padding: 26rpx 0;
  238. width: 90%;
  239. margin: 60rpx auto;
  240. border-radius: 50rpx;
  241. font-size: 32rpx;
  242. }
  243. .popup-content{
  244. padding: 120rpx 0 40rpx;
  245. .type-item{
  246. padding: 20rpx 40rpx;
  247. background: transparent;
  248. border: none;
  249. text-align: unset;
  250. width: 100%;
  251. line-height: initial;
  252. font-size: initial;
  253. justify-content: space-between;
  254. border-top: 1rpx solid #CECFD1;
  255. border-radius: 0;
  256. &:first-child{
  257. }
  258. .left-box{
  259. flex: 1;
  260. .icon{
  261. width: 60rpx;
  262. height: 48rpx;
  263. transform: translateY(4rpx);
  264. image{
  265. width: 48rpx;
  266. height: 48rpx;
  267. }
  268. &.bank{
  269. image{
  270. width: 56rpx;
  271. height: 38rpx;
  272. }
  273. }
  274. }
  275. text{
  276. color: #777777;
  277. margin-left: 10rpx;
  278. }
  279. }
  280. }
  281. }
  282. }
  283. </style>