withdraw.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <view class="page">
  3. <!-- #ifdef H5-->
  4. <uni-nav-bar v-if="!$isWxBrowser()" :fixed="true" background-color="#FFE05C" :border="false" :statusBar="false" left-icon="left" title="收益提现" @clickLeft="back" />
  5. <!-- #endif -->
  6. <view class="title flex-col">
  7. <!--#ifdef H5-->
  8. <view class="flex-row justify-center" v-if="$isWxBrowser()">
  9. <text class="title1">收益提现</text>
  10. </view>
  11. <!--#endif-->
  12. <!-- <text class="title2" @click="navigateTo('/pages/withdrawalRecord/withdrawalRecord')">提现记录</text>-->
  13. </view>
  14. <view class="flex-col justify-center" :style="{marginTop:'100rpx'}">
  15. <view class="flex-row justify-center">
  16. <text class="priceTitle">可提现金额</text>
  17. </view>
  18. <view class="flex-row justify-center marginTop">
  19. <text class="price">{{statistics.myEarning || '0.00'}}</text>
  20. </view>
  21. </view>
  22. <!-- 提现金额输入 -->
  23. <view class="amountSection">
  24. <view class="sectionTitle">提现金额</view>
  25. <view class="amountInputWrap">
  26. <text class="amountSymbol">¥</text>
  27. <input
  28. class="amountInput"
  29. v-model="form.amount"
  30. type="digit"
  31. placeholder="请输入提现金额"
  32. placeholder-class="placeholder"
  33. />
  34. </view>
  35. <view class="amountTip">
  36. <text>最小提现金额 1 元</text>
  37. <text class="allAmount" @click="form.amount = statistics.myEarning">全部提现</text>
  38. </view>
  39. </view>
  40. <!-- 提现方式选择 -->
  41. <view class="withdrawTypeSection">
  42. <view class="sectionTitle">选择提现方式</view>
  43. <view class="typeOptionList">
  44. <view
  45. class="typeOption"
  46. :class="{ active: form.channel === '4' }"
  47. @click="selectChannel('4')"
  48. >
  49. <text class="typeText">银行卡</text>
  50. </view>
  51. <view
  52. class="typeOption"
  53. :class="{ active: form.channel === '2' }"
  54. @click="selectChannel('2')"
  55. >
  56. <text class="typeText">微信</text>
  57. </view>
  58. </view>
  59. </view>
  60. <!-- 银行卡表单 -->
  61. <view v-if="form.channel === '4'" class="formSection">
  62. <view class="formItem">
  63. <text class="formLabel">姓名</text>
  64. <input
  65. class="formInput"
  66. v-model="form.realName"
  67. placeholder="请输入真实姓名"
  68. placeholder-class="placeholder"
  69. />
  70. </view>
  71. <view class="formItem">
  72. <text class="formLabel">身份证号</text>
  73. <input
  74. class="formInput"
  75. v-model="form.idCard"
  76. placeholder="请输入身份证号"
  77. placeholder-class="placeholder"
  78. maxlength="18"
  79. />
  80. </view>
  81. <view class="formItem">
  82. <text class="formLabel">银行卡号</text>
  83. <input
  84. class="formInput"
  85. v-model="form.bankCardNumber"
  86. placeholder="请输入银行卡号"
  87. placeholder-class="placeholder"
  88. type="number"
  89. />
  90. </view>
  91. </view>
  92. <!-- 微信收款码上传 -->
  93. <view v-if="form.channel === '2'" class="formSection">
  94. <view class="uploadSection">
  95. <text class="formLabel">微信收款码</text>
  96. <view class="uploadBox" @click="uploadWxQrCode">
  97. <image
  98. v-if="form.wxQrCode"
  99. class="uploadImage"
  100. :src="form.wxQrCode"
  101. mode="aspectFit"
  102. />
  103. <view v-else class="uploadPlaceholder">
  104. <text class="uploadIcon">+</text>
  105. <text class="uploadText">点击上传收款码</text>
  106. </view>
  107. </view>
  108. </view>
  109. </view>
  110. <view class="flex-row justify-start ":style="{marginTop:'40rpx'}">
  111. <checkbox-group @change="checkboxChange">
  112. <checkbox :checked="checked" color="#000000" :style="{'transform':'scale(0.7)'}"/>
  113. <text class="read">请阅读并同意</text>
  114. <text @click.stop="gotoTermOfService(8)" class="read">《娇骄儿拓客活动规则》</text>
  115. </checkbox-group>
  116. </view>
  117. <view class="flex-row justify-center marginTop">
  118. <view class="withdrawButton" @click="apply">
  119. <text>立即提现</text>
  120. </view>
  121. </view>
  122. <!--#ifdef H5-->
  123. <liu-drag-button v-if="$isWxBrowser()" @clickBtn="back">返回</liu-drag-button>
  124. <!--#endif-->
  125. </view>
  126. </template>
  127. <script>
  128. export default {
  129. data() {
  130. return {
  131. checked:false,
  132. statistics:{},
  133. form: {
  134. channel: '4',
  135. amount: '',
  136. realName: '',
  137. idCard: '',
  138. bankCardNumber: '',
  139. wxQrCode: '',
  140. }
  141. }
  142. },
  143. onShow() {
  144. this.exStatistics()
  145. },
  146. methods: {
  147. // 查看储值协议
  148. gotoTermOfService(type){
  149. uni.navigateTo({
  150. url: '/pages/agreement/agreement?name='+'娇骄儿拓客活动规则'+'&type=' + 10,
  151. })
  152. },
  153. selectChannel(channel) {
  154. this.form.channel = channel
  155. if (channel === '4') {
  156. this.form.wxQrCode = ''
  157. } else if (channel === '2') {
  158. this.form.realName = ''
  159. this.form.idCard = ''
  160. this.form.bankCardNumber = ''
  161. }
  162. },
  163. uploadWxQrCode() {
  164. let that = this
  165. uni.chooseImage({
  166. count: 1,
  167. sizeType: ['compressed'],
  168. sourceType: ['album', 'camera'],
  169. success: function (res) {
  170. let tempUrl = res.tempFiles[0].path
  171. uni.uploadFile({
  172. url: that.$baseUrl + '/resource/oss/upload',
  173. filePath: tempUrl,
  174. name: 'file',
  175. header: {
  176. 'Authorization': 'Bearer ' + uni.getStorageSync('accessToken'),
  177. },
  178. success: (uploadFileRes) => {
  179. let res = JSON.parse(uploadFileRes.data)
  180. that.form.wxQrCode = res.data.url.replace(/^http:/, "https:")
  181. },
  182. fail: (err) => {
  183. uni.showToast({
  184. icon: 'none',
  185. title: '上传失败,请重试'
  186. })
  187. }
  188. })
  189. }
  190. })
  191. },
  192. apply(){
  193. if (!this.checked){
  194. uni.showToast({
  195. icon: 'none',
  196. duration: 3000,
  197. title: '请同意《娇骄儿拓客活动规则》'
  198. });
  199. return
  200. }
  201. const amount = parseFloat(this.form.amount)
  202. if (!this.form.amount || isNaN(amount) || amount <= 0) {
  203. uni.showToast({ icon: 'none', title: '请输入有效的提现金额' })
  204. return
  205. }
  206. if (amount > parseFloat(this.statistics.myEarning || 0)) {
  207. uni.showToast({ icon: 'none', title: '提现金额不能超过可提现金额' })
  208. return
  209. }
  210. if (this.form.channel === '4') {
  211. if (!this.form.realName.trim()) {
  212. uni.showToast({ icon: 'none', title: '请输入姓名' })
  213. return
  214. }
  215. if (!this.form.idCard.trim()) {
  216. uni.showToast({ icon: 'none', title: '请输入身份证号' })
  217. return
  218. }
  219. if (!this.form.bankCardNumber.trim()) {
  220. uni.showToast({ icon: 'none', title: '请输入银行卡号' })
  221. return
  222. }
  223. } else if (this.form.channel === '2') {
  224. if (!this.form.wxQrCode) {
  225. uni.showToast({ icon: 'none', title: '请上传微信收款码' })
  226. return
  227. }
  228. }
  229. let params = {
  230. amount: amount,
  231. channel: this.form.channel,
  232. }
  233. if (this.form.channel === '4') {
  234. params.realName = this.form.realName.trim()
  235. params.idCard = this.form.idCard.trim()
  236. params.bankCardNumber = this.form.bankCardNumber.trim()
  237. } else if (this.form.channel === '2') {
  238. params.wxQrCode = this.form.wxQrCode
  239. }
  240. this.$api.service.apply(params).then(res=>{
  241. uni.showToast({
  242. icon: 'success',
  243. duration: 2000,
  244. title: '申请成功'
  245. });
  246. // 清空表单
  247. this.form.amount = ''
  248. this.form.realName = ''
  249. this.form.idCard = ''
  250. this.form.bankCardNumber = ''
  251. this.form.wxQrCode = ''
  252. setTimeout(() => {
  253. uni.navigateTo({
  254. url: '/pages/withdrawalRecord/withdrawalRecord'
  255. })
  256. }, 1500)
  257. })
  258. },
  259. exStatistics(){
  260. this.$api.service.exStatistics().then(res=>{
  261. this.statistics = res.data.data
  262. })
  263. },
  264. navigateTo(url) {
  265. uni.navigateTo({
  266. url: url
  267. })
  268. },
  269. back() {
  270. let pages = getCurrentPages()
  271. if (pages.length > 1){
  272. uni.navigateBack({
  273. delta: 1,
  274. fail:err=>{
  275. console.log(err)
  276. }
  277. })
  278. }else {
  279. uni.switchTab({
  280. url: '/pages/my/my'
  281. });
  282. }
  283. },
  284. checkboxChange(){
  285. this.checked = !this.checked
  286. },
  287. }
  288. }
  289. </script>
  290. <style lang="scss" scoped>
  291. @import './index.rpx.css';
  292. </style>