withdraw.vue 6.8 KB

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