tixian.vue 13 KB

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