withdraw.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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="selectType.value === 3 ?'number':'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. input{
  196. color: #fff;
  197. font-size: 38rpx;
  198. }
  199. .overage{
  200. font-weight: bold;
  201. padding-bottom: 30rpx;
  202. border-bottom: 1rpx solid $border-op-color;
  203. .number{
  204. color: #6eebe8;
  205. }
  206. }
  207. .input-box{
  208. padding: 30rpx 0;
  209. border-bottom: 1rpx solid $border-op-color;
  210. .left{
  211. width: 180rpx;
  212. }
  213. .center{
  214. flex: 1;
  215. margin-left: 10rpx;
  216. }
  217. .right{
  218. font-size: 28rpx;
  219. color: #6eebe8;
  220. }
  221. }
  222. .tips{
  223. background: $bg-op-color;
  224. border-radius: 20rpx;
  225. padding: 30rpx 20rpx;
  226. color: #ccc;
  227. margin: 30rpx 0;
  228. font-size: 24rpx;
  229. }
  230. .type-box{
  231. border-bottom: 1rpx solid $border-op-color;
  232. padding: 30rpx 0;
  233. text{
  234. margin-right: 10rpx;
  235. font-size: 32rpx;
  236. }
  237. }
  238. .btn{
  239. background: linear-gradient(270deg, #6EEBE8 0%, #FF74B9 100%);
  240. text-align: center;
  241. padding: 26rpx 0;
  242. width: 90%;
  243. margin: 60rpx auto;
  244. border-radius: 50rpx;
  245. font-size: 32rpx;
  246. }
  247. .popup-content{
  248. padding: 120rpx 0 40rpx;
  249. .type-item{
  250. padding: 20rpx 40rpx;
  251. background: transparent;
  252. border: none;
  253. text-align: unset;
  254. width: 100%;
  255. line-height: initial;
  256. font-size: initial;
  257. justify-content: space-between;
  258. border-top: 1rpx solid #CECFD1;
  259. border-radius: 0;
  260. &:first-child{
  261. }
  262. .left-box{
  263. flex: 1;
  264. .icon{
  265. width: 60rpx;
  266. height: 48rpx;
  267. transform: translateY(4rpx);
  268. image{
  269. width: 48rpx;
  270. height: 48rpx;
  271. }
  272. &.bank{
  273. image{
  274. width: 56rpx;
  275. height: 38rpx;
  276. }
  277. }
  278. }
  279. text{
  280. color: #777777;
  281. margin-left: 10rpx;
  282. }
  283. }
  284. }
  285. }
  286. }
  287. </style>