wallet.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. <template>
  2. <view v-if="xcxSelect!='否'">
  3. <view class="padding">
  4. <view class="bg radius padding">
  5. <view class="text-lg">可提金额</view>
  6. <view class="flex margin-top-sm">
  7. <view class="text-xxl">{{money}}元</view>
  8. </view>
  9. </view>
  10. <view class="bg radius padding margin-top">
  11. <view class="text-lg margin-bottom">提现金额</view>
  12. <input type="number" placeholder="请输入提现金额" v-model="moneyNum">
  13. <view class="margin-tb-xs" style="width: 100%;height: 1rpx;background: #F5F5F5;"></view>
  14. <view class=" text-grey ">{{placeholder}}</view>
  15. </view>
  16. <view class="part_three">
  17. <view class="three_name">提现方式</view>
  18. <view class="btn">
  19. <view class="btn_right" v-if="zhifub=='是'" :class="current==1?'btna':''" @click="bindToindex(1)">
  20. <image src="../static/zhifubao.png"></image>
  21. <text>支付宝</text>
  22. </view>
  23. <view v-if="isWxAway == '是'" class="btn_left" :class="current==2?'btna':''" @click="bindToindex(2)">
  24. <image src="../static/weixin.png"></image>
  25. <text>微信</text>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="btn1" @click="cashMoney">立即提现</view>
  30. </view>
  31. <view class="flex justify-around margin-top">
  32. <view @click="goNav('/my/wallet/zhifubao')">提现账号</view>
  33. <view v-if="values==2 && isWxAway == '是'" class="box_right" @click="isShow">
  34. 微信收款码
  35. </view>
  36. <view @click="goNav('/my/team/moneydetail')">收益明细</view>
  37. <view @click="goNav('/my/team/cashList')">提现记录</view>
  38. </view>
  39. <!-- 微信收款码弹框 -->
  40. <u-popup v-model="show" mode="center" border-radius="14">
  41. <view class="padding">
  42. <view class="text-center text-lg text-bold flex justify-between">
  43. <view></view>
  44. <view>添加微信收款码</view>
  45. <view @click="show=false">X</view>
  46. </view>
  47. <view style="width: 80%;margin: 0 auto;">
  48. <view class="margin-top" @click.stop="weixin"
  49. style="border: 4rpx solid #010101;border-radius: 16rpx;overflow: hidden;">
  50. <image v-if="!wximg" src="../static/erweima.png" mode="aspectFill"></image>
  51. <image v-else :src="wximg" mode="aspectFill"></image>
  52. </view>
  53. </view>
  54. </view>
  55. </u-popup>
  56. </view>
  57. </template>
  58. <script>
  59. export default {
  60. data() {
  61. return {
  62. title_color: 1,
  63. money: 0,
  64. avatar: '',
  65. Profit: 0,
  66. moneyNum: null,
  67. thisSelect: {
  68. id: 1,
  69. num: '50',
  70. price: '50',
  71. isSelect: true
  72. },
  73. charge: 0, //提现手续费
  74. maxMoney: 0, //最高提现额度
  75. minMoney: 0, //最低提现额度
  76. placeholder: '',
  77. sp: 0,
  78. current: '1',
  79. values: '',
  80. show: false,
  81. wximg: '',
  82. zhifubaoName: '',
  83. zhifubao: '',
  84. zhifub: '是',
  85. xcxSelect: '是',
  86. isWxAway: '是',
  87. }
  88. },
  89. onLoad() {
  90. this.xcxSelect = uni.getStorageSync('xcxSelect')
  91. if (this.xcxSelect != '否') {
  92. uni.setNavigationBarTitle({
  93. title: '提现'
  94. })
  95. } else {
  96. uni.setNavigationBarTitle({
  97. title: '用户协议'
  98. })
  99. }
  100. this.avatar = uni.getStorageSync('avatar')
  101. //是否开启微信提现
  102. this.$Request.getT('/app/common/type/355').then(res => {
  103. if (res.code == 0) {
  104. if (res.data && res.data.value) {
  105. this.isWxAway = res.data.value
  106. }
  107. }
  108. })
  109. //判断微信提现方式
  110. this.$Request.getT('/app/common/type/280').then(res => {
  111. if (res.code == 0) {
  112. if (res.data && res.data.value) {
  113. this.values = res.data.value
  114. }
  115. }
  116. })
  117. this.$Request.getT('/app/common/type/356').then(res => {
  118. if (res.code == 0) {
  119. if (res.data && res.data.value) {
  120. this.zhifub = res.data.value
  121. }
  122. }
  123. })
  124. },
  125. onShow() {
  126. this.xcxSelect = uni.getStorageSync('xcxSelect')
  127. this.getCharge()
  128. this.getMinMoney()
  129. this.getMaxMoney()
  130. this.getUserInfo()
  131. this.selectMyMoney()
  132. },
  133. methods: {
  134. //获取提现余额
  135. selectMyMoney() {
  136. this.$Request.getT('/app/userMoney/selectMyMoney').then(res => {
  137. if (res.code == 0) {
  138. if (res.data.inviteMoney > 0) {
  139. this.money = res.data.inviteMoney
  140. }
  141. }
  142. })
  143. },
  144. isShow() {
  145. this.getUserInfo()
  146. this.show = true
  147. },
  148. bindToindex(e) {
  149. this.current = e
  150. // console.log(e, this.current)
  151. },
  152. getUserInfo() {
  153. this.$Request.getT("/app/user/selectUserById").then(res => {
  154. if (res.code == 0) {
  155. this.zhifubaoName = res.data.zhiFuBaoName
  156. this.zhifubao = res.data.zhiFuBao
  157. this.wximg = res.data.cashQrCode
  158. uni.setStorageSync('zhiFuBao', res.data.zhiFuBao)
  159. uni.setStorageSync('zhiFuBaoName', res.data.zhiFuBaoName)
  160. }
  161. });
  162. },
  163. // 提现手续费
  164. getCharge() {
  165. this.$Request.get("/app/common/type/114").then(res => {
  166. if (res.code == 0) {
  167. this.charge = res.data.value
  168. this.placeholder = '服务费:' + this.charge * 100 + '%' + ',最低提现:' +
  169. this.minMoney * 1 + ',最高提现:' + this.maxMoney * 1
  170. }
  171. });
  172. },
  173. // 最低提现额度
  174. getMinMoney() {
  175. this.$Request.get("/app/common/type/87").then(res => {
  176. if (res.code == 0) {
  177. this.minMoney = res.data.value
  178. this.placeholder = '服务费:' + this.charge * 100 + '%' + ',最低提现:' +
  179. this.minMoney * 1 + ',最高提现:' + this.maxMoney * 1
  180. }
  181. });
  182. },
  183. // 最高提现额度
  184. getMaxMoney() {
  185. this.$Request.get("/app/common/type/11").then(res => {
  186. if (res.code == 0) {
  187. this.maxMoney = res.data.value
  188. this.placeholder = '服务费:' + this.charge * 100 + '%' + ',最低提现:' +
  189. this.minMoney * 1 + ',最高提现:' + this.maxMoney * 1
  190. }
  191. });
  192. },
  193. cut(e) {
  194. this.title_color = e
  195. },
  196. goNav(url) {
  197. uni.navigateTo({
  198. url
  199. })
  200. },
  201. active(e) {
  202. this.wallet.forEach(res => {
  203. if (res.id == e.id) {
  204. res.isSelect = true
  205. this.thisSelect = e
  206. } else {
  207. res.isSelect = false
  208. }
  209. })
  210. },
  211. selectWay: function(item) {
  212. this.openWay = item.id;
  213. },
  214. // 提现
  215. // 提现
  216. cashMoney() {
  217. if (this.current == 1) {
  218. if (!/^\d+$/.test(this.moneyNum)) {
  219. uni.showToast({
  220. icon: 'none',
  221. title: '请输入正确金额,不能包含中文,英文,特殊字符和小数'
  222. });
  223. return;
  224. }
  225. // if (!this.zhifubao) {
  226. // uni.navigateTo({
  227. // url: '/pageA/wallet/zhifubao'
  228. // });
  229. // return
  230. // }
  231. if (Number(this.money) < Number(this.moneyNum)) {
  232. uni.showToast({
  233. icon: 'none',
  234. title: '可提现金额不足'
  235. });
  236. return;
  237. }
  238. if (Number(this.moneyNum) < Number(this.minMoney)) {
  239. uni.showToast({
  240. icon: 'none',
  241. title: '提现金额不能小于' + this.minMoney + '元'
  242. });
  243. return;
  244. }
  245. if (Number(this.moneyNum) > Number(this.maxMoney)) {
  246. uni.showToast({
  247. icon: 'none',
  248. title: '提现金额不能大于' + this.maxMoney + '元'
  249. });
  250. return;
  251. }
  252. let zhiFuBao = uni.getStorageSync('zhiFuBao')
  253. let zhiFuBaoName = uni.getStorageSync('zhiFuBaoName')
  254. if (!zhiFuBao && !zhiFuBaoName) {
  255. uni.showModal({
  256. title: '提示',
  257. content: '请先绑定提现账号',
  258. confirmText: '去添加',
  259. complete(res) {
  260. if (res.confirm) {
  261. uni.navigateTo({
  262. url: '/my/wallet/zhifubao'
  263. })
  264. }
  265. }
  266. })
  267. return
  268. }
  269. let that = this
  270. that.sp = (that.moneyNum * this.charge).toFixed(2)
  271. uni.showModal({
  272. title: '提示',
  273. content: '本次提现' + that.moneyNum + '元,服务费' + this.sp + '元,是否确认提现?',
  274. success: function(res) {
  275. if (res.confirm) {
  276. that.$Request.getT("/app/cash/cashMoney", {
  277. money: that.moneyNum,
  278. classify: 1,
  279. userType: 1,
  280. }).then(res => {
  281. if (res.code == 0) {
  282. uni.showToast({
  283. icon: 'none',
  284. title: res.msg
  285. })
  286. that.moneyNum = null
  287. } else {
  288. uni.showToast({
  289. icon: 'none',
  290. title: res.msg
  291. })
  292. }
  293. that.getUserInfo()
  294. });
  295. } else if (res.cancel) {
  296. console.log('用户点击取消');
  297. }
  298. }
  299. });
  300. } else {
  301. if (!/^\d+$/.test(this.moneyNum)) {
  302. uni.showToast({
  303. icon: 'none',
  304. title: '请输入正确金额,不能包含中文,英文,特殊字符和小数'
  305. });
  306. return;
  307. }
  308. // if (!this.zhifubao) {
  309. // uni.navigateTo({
  310. // url: '/pageA/wallet/zhifubao'
  311. // });
  312. // return
  313. // }
  314. if (Number(this.money) < Number(this.moneyNum)) {
  315. uni.showToast({
  316. icon: 'none',
  317. title: '可提现金额不足'
  318. });
  319. return;
  320. }
  321. if (Number(this.moneyNum) < Number(this.minMoney)) {
  322. uni.showToast({
  323. icon: 'none',
  324. title: '提现金额不能小于' + this.minMoney + '元'
  325. });
  326. return;
  327. }
  328. if (Number(this.moneyNum) > Number(this.maxMoney)) {
  329. uni.showToast({
  330. icon: 'none',
  331. title: '提现金额不能大于' + this.maxMoney + '元'
  332. });
  333. return;
  334. }
  335. // if (this.moneyNum*1+this.charge*this.moneyNum > this.money*1) {
  336. // uni.showToast({
  337. // icon: 'none',
  338. // title: '您的手续费不足'
  339. // })
  340. // return
  341. // }
  342. let that = this
  343. if (this.values == 2) { //手动提现
  344. if (!that.wximg) {
  345. uni.showModal({
  346. title: '提现提示',
  347. content: '请上传微信收款码',
  348. showCancel: true,
  349. cancelText: '取消',
  350. confirmText: '上传',
  351. success: res => {
  352. if (res.confirm) {
  353. that.show = true;
  354. }
  355. },
  356. fail: () => {},
  357. complete: () => {}
  358. });
  359. return;
  360. }
  361. }
  362. that.sp = (that.moneyNum * this.charge).toFixed(2)
  363. uni.showModal({
  364. title: '提示',
  365. content: '本次提现' + that.moneyNum + '元,服务费' + this.sp + '元,是否确认提现?',
  366. success: function(res) {
  367. if (res.confirm) {
  368. that.$Request.getT("/app/cash/cashMoney", {
  369. money: that.moneyNum,
  370. classify: 2,
  371. userType: 1,
  372. }).then(res => {
  373. if (res.code == 0) {
  374. uni.showToast({
  375. icon: 'none',
  376. title: res.msg
  377. })
  378. that.moneyNum = null
  379. } else {
  380. uni.showToast({
  381. icon: 'none',
  382. title: res.msg
  383. })
  384. }
  385. that.getUserInfo()
  386. });
  387. } else if (res.cancel) {
  388. console.log('用户点击取消');
  389. }
  390. }
  391. });
  392. }
  393. },
  394. weixin() {
  395. let that = this
  396. uni.chooseImage({
  397. count: 1, //默认9
  398. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  399. sourceType: ['album', 'camera'], //从相册选择
  400. success: (res) => {
  401. console.log('`````````````', res.tempFilePaths[0])
  402. that.$queue.showLoading("上传中...");
  403. for (let i = 0; i < 1; i++) {
  404. uni.uploadFile({ // 上传接口
  405. url: that.config("APIHOST") + '/alioss/upload',
  406. filePath: res.tempFilePaths[i],
  407. name: 'file',
  408. success: (uploadFileRes) => {
  409. let img = JSON.parse(uploadFileRes.data).data
  410. // this.img.push()
  411. console.log(img)
  412. that.show = false
  413. let userId = that.$queue.getData('userId');
  414. let data = {
  415. cashQrCode: img
  416. }
  417. that.$Request.postJson('/app/user/updateUser',
  418. data).then(
  419. res => {
  420. uni.hideLoading();
  421. that.$queue.showToast('上传成功,请重新操作提现')
  422. that.getUserInfo()
  423. });
  424. }
  425. });
  426. }
  427. }
  428. });
  429. },
  430. config: function(name) {
  431. var info = null;
  432. if (name) {
  433. var name2 = name.split("."); //字符分割
  434. if (name2.length > 1) {
  435. info = configdata[name2[0]][name2[1]] || null;
  436. } else {
  437. info = configdata[name] || null;
  438. }
  439. if (info == null) {
  440. let web_config = cache.get("web_config");
  441. if (web_config) {
  442. if (name2.length > 1) {
  443. info = web_config[name2[0]][name2[1]] || null;
  444. } else {
  445. info = web_config[name] || null;
  446. }
  447. }
  448. }
  449. }
  450. return info;
  451. }
  452. }
  453. }
  454. </script>
  455. <style>
  456. page {
  457. background-color: #F7F7F7;
  458. }
  459. .bgCol2 {
  460. color: #557EFD;
  461. }
  462. .bg {
  463. background-color: #FFFFFF;
  464. }
  465. .active {
  466. border: 1px solid #557EFD !important;
  467. color: #557EFD !important;
  468. }
  469. .title_btn {
  470. height: 78upx;
  471. line-height: 78upx;
  472. /* background: #f7f7f7; */
  473. }
  474. .btn1 {
  475. width: 100%;
  476. height: 88upx;
  477. background: #5074FF;
  478. border-radius: 44upx;
  479. text-align: center;
  480. line-height: 88upx;
  481. margin-top: 40upx;
  482. font-size: 28upx;
  483. color: #FFF;
  484. }
  485. .part_three {
  486. margin: 0 auto;
  487. background: #FFFFFF;
  488. margin-top: 20rpx;
  489. border-radius: 20rpx;
  490. }
  491. .three_name {
  492. width: 90%;
  493. margin: 0 auto;
  494. font-size: 33rpx;
  495. color: black;
  496. line-height: 80rpx;
  497. }
  498. .btn {
  499. width: 96%;
  500. margin: 0 auto;
  501. display: flex;
  502. justify-content: space-between;
  503. padding-bottom: 30rpx;
  504. }
  505. .btn_left {
  506. flex: 1;
  507. /* width: 240rpx; */
  508. height: 90rpx;
  509. border: 1rpx solid #ccc;
  510. border-radius: 20rpx;
  511. margin-right: 10rpx;
  512. display: flex;
  513. justify-content: center;
  514. align-items: center;
  515. margin-right: 20rpx;
  516. }
  517. .btn_right {
  518. flex: 1;
  519. /* width: 240rpx; */
  520. height: 90rpx;
  521. border: 1rpx solid #ccc;
  522. border-radius: 20rpx;
  523. margin-left: 10rpx;
  524. display: flex;
  525. justify-content: center;
  526. align-items: center;
  527. margin-right: 20rpx;
  528. }
  529. .beizhu {
  530. line-height: 55rpx;
  531. color: red;
  532. letter-spacing: 1rpx;
  533. }
  534. .btna {
  535. border: 1rpx solid #2B80FF !important;
  536. }
  537. .btn_left image {
  538. width: 50rpx;
  539. height: 50rpx;
  540. margin-right: 12rpx;
  541. }
  542. .btn_right image {
  543. width: 50rpx;
  544. height: 50rpx;
  545. margin-right: 12rpx;
  546. }
  547. </style>