tixian.vue 13 KB

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