猎豆优选小程序

alipayWithdraw.vue 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <view>
  3. <u-navbar class="navbar-wrap" :is-back="true" title="支付宝提现" :background="background" title-color="#ffffff" back-icon-color="#ffffff" />
  4. <!-- 支付宝账号信息 -->
  5. <!-- <view class="alipayInfo" @click="goBindAlipayPage()">
  6. <view class="info">
  7. <image class="alipayImg" src="https://ld.726p.com/ldyx_static/imgs/alipay_icon.png" mode="widthFix"></image>
  8. <view>
  9. <view class="alipayInfoItem">
  10. <view class="label">真实姓名</view>
  11. <view class="value">{{alipayGetMoney.real_name || '-'}}</view>
  12. </view>
  13. <view class="alipayInfoItem">
  14. <view class="label">支付宝账号</view>
  15. <view class="value">{{alipayGetMoney.alipay_account || '-'}}</view>
  16. </view>
  17. </view>
  18. </view>
  19. <image class="rightArrow" src="https://ld.726p.com/ldyx_static/imgs/rightArrow.png" mode="widthFix"></image>
  20. </view> -->
  21. <!-- 提现 -->
  22. <view class="alipayBlock">
  23. <view class="title">提现金额</view>
  24. <view class="alipayInput">
  25. <text>¥</text>
  26. <input class="input" v-model="money" type="digit" focus placeholder="请输入金额" placeholder-style="font-size:32rpx"/>
  27. </view>
  28. <view class="alipayOperation">
  29. <text class="balance">可提现余额:{{alipayGetMoney.can_use_money || '-'}}</text>
  30. <view class="allWithdrawButton" @click="onClickWithdraw()">全部提现</view>
  31. </view>
  32. </view>
  33. <view class="hint"><text>*48小时内办理入账</text><text>*用户提现个税自理</text></view>
  34. <button class="withdrawButton" type="default" @click="onClickWithdrawButton()">申请提现</button>
  35. <view class="txButton">每月25日可提现上个月已结算佣金</view>
  36. <!-- 服务商 -->
  37. <serviceProvider :show="showService" @close="showService=false" hint="关于支付宝问题,请联系服务商!"></serviceProvider>
  38. </view>
  39. </template>
  40. <script>
  41. const app = getApp()
  42. import serviceProvider from '@/components/serviceProvider.vue'
  43. export default {
  44. components:{
  45. serviceProvider
  46. },
  47. data() {
  48. return {
  49. background: app.globalData.navbarBackground,
  50. alipayGetMoney: {},
  51. money: '',
  52. showService: false
  53. }
  54. },
  55. onShow() {
  56. this.getAlipayGetMoney()
  57. },
  58. methods: {
  59. // 获取已绑定支付宝信息
  60. async getAlipayGetMoney(){
  61. try {
  62. const url = this.$api.users_alipayGetMoneyPage
  63. const params = {}
  64. uni.showLoading({ title: '加载中...', mask: true })
  65. const { data: res } = await this.$postJSON(url, params)
  66. if (res && res.errno == 0) {
  67. this.alipayGetMoney = res.rst.data
  68. this.alipayGetMoney.real_name = this.alipayGetMoney.real_name && this.formatName(this.alipayGetMoney.real_name)
  69. let alipay_account = this.alipayGetMoney.alipay_account;
  70. this.alipayGetMoney.alipay_account = alipay_account && alipay_account.replace(alipay_account.substring(3,7), "****");
  71. } else {
  72. uni.showToast({ title: res.err || '操作失败', icon: 'none' })
  73. }
  74. } catch (error) {
  75. uni.showToast({ title: '服务器错误', icon: 'none' })
  76. } finally {
  77. uni.hideLoading()
  78. }
  79. },
  80. // 点击全部提现
  81. onClickWithdraw(){
  82. this.money = this.alipayGetMoney.can_use_money;
  83. },
  84. // 点击申请提现
  85. async onClickWithdrawButton(){
  86. const _this = this;
  87. if(!this.alipayGetMoney.alipay_account || this.alipayGetMoney.alipay_account == ''){
  88. uni.showToast({ title: '您还未绑定支付宝', icon: 'none' })
  89. setTimeout(()=>{
  90. this.showService = true
  91. },1000)
  92. return
  93. }
  94. if(this.money <= 0 ){
  95. uni.showToast({ title: '请正确输入金额', icon: 'none' })
  96. return
  97. }
  98. uni.showModal({
  99. title: '提示',
  100. content:`请确认您的支付宝账号:${this.alipayGetMoney.alipay_account}`,
  101. cancelText: '修改账号',
  102. confirmText: '确认',
  103. success: function (res) {
  104. if (res.confirm) {
  105. _this.alipayGetMoneyEvent()
  106. } else if (res.cancel) {
  107. _this.showService = true
  108. }
  109. }
  110. });
  111. },
  112. // 提现接口
  113. async alipayGetMoneyEvent(){
  114. try {
  115. const url = this.$api.users_alipayGetMoney
  116. const params = {
  117. money: this.money
  118. }
  119. uni.showLoading({ title: '加载中...', mask: true })
  120. const { data: res } = await this.$postJSON(url, params)
  121. uni.hideLoading()
  122. if (res && res.errno == 0) {
  123. if(res.rst.flag == 1) {//提现成功
  124. this.money = ''
  125. this.getAlipayGetMoney()
  126. }
  127. uni.showToast({ title: res.rst.msg, icon: 'none' })
  128. } else {
  129. uni.showToast({ title: res.err || '操作失败', icon: 'none' })
  130. }
  131. } catch (error) {
  132. uni.showToast({ title: '服务器错误', icon: 'none' })
  133. }
  134. },
  135. // 去绑定支付宝账号页面
  136. goBindAlipayPage(){
  137. this.showService = true;
  138. },
  139. // 名字改为带*的
  140. formatName(name) {
  141. var newStr;
  142. if (name.length === 2) {
  143. newStr = name.substr(0, 1) + '*';
  144. } else if (name.length > 2) {
  145. var char = '';
  146. for (var i = 0, len = name.length - 2; i < len; i++) {
  147. char += '*';
  148. }
  149. newStr = name.substr(0, 1) + char + name.substr(-1, 1);
  150. } else {
  151. newStr = name;
  152. }
  153. return newStr;
  154. }
  155. }
  156. }
  157. </script>
  158. <style scoped lang="scss">
  159. .alipayInfo{
  160. display: flex;
  161. align-items: center;
  162. justify-content: space-between;
  163. background-color: #FFFFFF;
  164. padding: 20rpx;
  165. margin: 20rpx 0;
  166. .info{
  167. display: flex;
  168. align-items: center;
  169. .alipayImg{
  170. width: 100rpx;
  171. height: 100rpx;
  172. margin-right: 20rpx;
  173. }
  174. .alipayInfoItem{
  175. display: flex;
  176. align-items: center;
  177. font-size: 32rpx;
  178. line-height: 50rpx;
  179. .label{
  180. width: 180rpx;
  181. }
  182. }
  183. }
  184. .rightArrow{
  185. width: 30rpx;
  186. height: 30rpx;
  187. }
  188. }
  189. .alipayBlock{
  190. background-color: #FFFFFF;
  191. padding: 20rpx;
  192. margin-top: 20rpx;
  193. .title{
  194. color: #666;
  195. font-size: 32rpx;
  196. line-height: 40rpx;
  197. }
  198. .alipayInput{
  199. display: flex;
  200. align-items: center;
  201. font-size: 50rpx;
  202. line-height: 80rpx;
  203. border-bottom: 2rpx solid #f4f4f4;
  204. padding: 10rpx 0;
  205. margin-top: 10rpx;
  206. .input{
  207. padding-left: 8rpx;
  208. }
  209. }
  210. .alipayOperation{
  211. display: flex;
  212. align-items: center;
  213. justify-content: space-between;
  214. font-size: 30rpx;
  215. line-height: 50rpx;
  216. margin-top: 20rpx;
  217. .allWithdrawButton{
  218. color: #ef0f2a;
  219. }
  220. }
  221. }
  222. .hint{
  223. font-size: 22rpx;
  224. line-height: 40rpx;
  225. text-align: right;
  226. color: #888;
  227. padding: 10rpx 20rpx;
  228. text{
  229. margin-left: 40rpx;
  230. }
  231. }
  232. .withdrawButton{
  233. width: 550rpx;
  234. line-height: 70rpx;
  235. background-color: #F52B18;
  236. font-size: 32rpx;
  237. color: #FFFFFF;
  238. text-align: center;
  239. margin: auto;
  240. margin-top: 200rpx;
  241. border-radius: 6rpx;
  242. }
  243. .txButton{
  244. color: #888;
  245. font-size: 24rpx;
  246. text-align: center;
  247. line-height: 40rpx;
  248. margin-top: 10rpx;
  249. }
  250. </style>