wallet.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. <!-- 我的-钱包 -->
  2. <!-- 注意,不要重排代码格式 -->
  3. <template>
  4. <view>
  5. <!-- 非商家钱包 -->
  6. <view v-if="sys_role==0">
  7. <view :style="'background-image:url( '+serverUrlImg+' )'" class="wal_bg">
  8. <view style="margin-left: 4%;" class="wal_bg_left">
  9. <view>账户余额(元)</view>
  10. <view style="font-size: 56upx;margin-top: 6upx;">{{finance_balance.toFixed(2)}}</view>
  11. </view>
  12. <view class="wal_bg_right" style="margin-right: 4%;">
  13. <view @click="open_modal('wxRecharge')" style="background-color: #ffefcb;color: #f96a3e;">充值</view>
  14. <view @click="open_modal('withdraw')"
  15. style="background-color: #d3fff2;color: #05a87d;margin-top: 20upx;">提现</view>
  16. </view>
  17. </view>
  18. </view>
  19. <!-- 商家钱包 -->
  20. <view v-else>
  21. <view :style="'background-image:url( '+serverUrlImgMer+' )'" class="wal_bg">
  22. <view style="display: flex;justify-content: space-between;width: 100%;height: 160upx;">
  23. <view style="margin-left: 4%;" class="wal_bg_left">
  24. <view>{{user_info.company_name}}</view>
  25. </view>
  26. <view class="wal_bg_right" style="margin-right: 4%;">
  27. <view @click="open_modal('withdraw')" style="background-color: #d3fff2;color: #05a87d;">提现
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="merch_money_box">
  33. <view style="width: 38%;border-right: 2upx solid #efefef;box-sizing: border-box;"
  34. class="merch_money_box_in">
  35. <view class="merch_money_box_in_1">{{finance_frozenBalance.toFixed(2)}}</view>
  36. <view class="merch_money_box_in_2">冻结金额(元)</view>
  37. </view>
  38. <view style="width: 38%;" class="merch_money_box_in">
  39. <view class="merch_money_box_in_1">{{finance_balance.toFixed(2)}}</view>
  40. <view class="merch_money_box_in_2">账户余额(元)</view>
  41. </view>
  42. <view @click="open_modal('wxRecharge')" style="background-color: #ffefcb;color: #ff6044;"
  43. class="merch_money_box_in_3">充值</view>
  44. </view>
  45. </view>
  46. <!-- 都显示 -->
  47. <view class="head">
  48. <view @click="change_type(0)" :class="type=='0'?'focus':''">收益</view>
  49. <view @click="change_type(1)" :class="type=='1'?'focus':''">支出</view>
  50. </view>
  51. <view style="background-color: #F4F4F4;height: 20upx;"></view>
  52. <view class="loading_text" v-if="loading">加载中...</view>
  53. <view v-else>
  54. <view :key="index" v-for="(item, index) in data" class="con box">
  55. <view style="display: flex;align-items: center;">
  56. <view style="">
  57. <view style="font-size: 32upx;font-weight: bold;display: flex;">
  58. <view :style="'color: '+(type==0?'#f53c41':'#00AB92')+';'">
  59. {{item.bizCatalogName||item.typeName}}
  60. </view>
  61. <view style="margin-left: 10upx;">
  62. {{item.biz_roletype==1?'现场经理-':''}}
  63. {{item.bt2_true_name||''}}
  64. </view>
  65. </view>
  66. <view style="width: 550upx;margin-top: 10upx;">{{item.remark}}</view>
  67. <view style="color: #8D8D8D;font-size: 28upx;margin-top: 10upx;">{{item.occurdatetime}}</view>
  68. </view>
  69. </view>
  70. <view :style="'color: '+(type==0?'#f53c41':'#00AB92')+';'">
  71. {{type==0?'+':'-'}}{{item.money}}
  72. </view>
  73. </view>
  74. </view>
  75. <view class="loading_text" v-if="data.length==0&&!loading">暂无数据</view>
  76. <!-- 遮罩内容 -->
  77. <uni-popup ref="popup" :mask-click="false">
  78. <view style="overflow: hidden;" class="modal_box">
  79. <view style="margin-top: 30upx;">
  80. <view style="text-align: center;color: #00ba98;font-size: 32upx;">
  81. {{todo_title}}
  82. </view>
  83. <view v-if="todo=='buyPrepay'" style="text-align: center;margin-top: 10upx;">
  84. {{'单价'+pricePer+'元/人'}}
  85. </view>
  86. <input :value="ipt_value" v-model="ipt_value" @input="ipt_change"
  87. :type="todo=='buyPrepay'?'number':'digit'" class="ipt" :placeholder="'请输入'+todo_title" />
  88. <input v-if="todo=='withdraw'" :value="trueName" v-model="trueName" @input="trueNameChange"
  89. :type="'text'" class="ipt" :placeholder="'请输入真实姓名'" />
  90. <view class="modal_btn">
  91. <view @click="close_modal()" class="modal_btn_cancel">取消</view>
  92. <view @click="process()" v-if="todo=='withdraw'" class="modal_btn_confirm">确认提现</view>
  93. <view v-else @click="process()" class="modal_btn_confirm">
  94. {{current_pay_loading?'计算中...':(current_pay+'元')}}
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </uni-popup>
  100. </view>
  101. </template>
  102. <script>
  103. import commonData from '../../commonData.js'
  104. import commonFun from '../../commonFun.js'
  105. export default {
  106. data() {
  107. return {
  108. serverUrlImg: this.serverUrl + 'wallet_bg.png',
  109. serverUrlImgMer: this.serverUrl + 'merchant/my_bg.png',
  110. type: 0, //tab栏status
  111. data: [], //主数据
  112. loading: true, //数据加载中...
  113. finance_balance: 0, //账户余额
  114. finance_frozenBalance:0,//冻结金额
  115. user_info: {}, //用户信息
  116. sys_role: commonData.sys_role, //角色
  117. todo_title: '', //操作todo标题
  118. rule: {}, //当前配置
  119. todo: '', //操作todo
  120. ipt_value: '', //输入框值
  121. current_pay: 0, //当前需要支付的实时金额
  122. current_pay_loading: false, //当前实时金额加载中...
  123. finance_numtotalbalance: 0, //剩余次数
  124. pricePer: 0,
  125. trueName: '',
  126. }
  127. },
  128. methods: {
  129. // 真实姓名输入
  130. trueNameChange(e) {
  131. this.trueName = e.target.value
  132. },
  133. // 输入框输入
  134. ipt_change(e) {
  135. if (e.target.value > 100000) {
  136. uni.showModal({
  137. content: '输入值应小于100000',
  138. showCancel: false
  139. })
  140. return
  141. }
  142. if (isNaN(Number(e.target.value))) {
  143. return
  144. }
  145. this.ipt_value = Number(e.target.value)
  146. // 充次数
  147. if (this.todo == 'buyPrepay') {
  148. this.fetchRecuritRule()
  149. }
  150. // 充值
  151. if (this.todo == 'wxRecharge' || this.todo == 'withdraw') {
  152. this.current_pay = this.ipt_value.toFixed(2)
  153. }
  154. },
  155. //拉取当前单价等配置
  156. fetchRecuritRule() {
  157. this.current_pay_loading = true
  158. commonFun.requestUrl('&WsAjaxBiz=Trader&WsAjaxAction=entityDataHandle', {
  159. handleMode: 'fetchRecuritRule',
  160. bizCatalog: 'PlatConfigEntity'
  161. }, res => {
  162. if (res.status) {
  163. this.rule = res.data.Result
  164. this.current_pay = (Number(this.ipt_value).toFixed(0) * Number(this.rule.pricePer))
  165. .toFixed(2)
  166. this.pricePer = this.rule.pricePer
  167. console.log('拉取当前配置')
  168. console.log(this.rule, this.current_pay)
  169. }
  170. this.current_pay_loading = false
  171. })
  172. },
  173. // 关闭遮罩
  174. close_modal() {
  175. this.$refs.popup.close('top')
  176. },
  177. // 打开遮罩
  178. open_modal(todo) {
  179. if (todo == 'withdraw') {
  180. if (this.finance_balance == 0) {
  181. return
  182. }
  183. if ((this.sys_role == 0 && !this.user_info.idcard ) || (this.sys_role == 1 && (!this
  184. .user_info.lawer_idcard || this.user_info.certif_confirmed == '0'))) {
  185. uni.showModal({
  186. title: '提现需要实名认证',
  187. success: (res) => {
  188. if (res.confirm) {
  189. uni.navigateTo({
  190. url: this.sys_role == 0 ? './authentication' :
  191. './authentication_merchant'
  192. })
  193. }
  194. }
  195. })
  196. return
  197. }
  198. }
  199. this.ipt_value = ''
  200. this.current_pay = 0.00
  201. this.todo = todo
  202. this.$refs.popup.open('top')
  203. this.todo_title = commonData.todo_wal_title_obj[todo]['title']
  204. },
  205. // 处理
  206. process() {
  207. // 判断输入
  208. if (isNaN(Number(this.ipt_value)) || Number(this.ipt_value) <= 0) {
  209. uni.showModal({
  210. title: '请输入正确的金额或人数!',
  211. showCancel: false
  212. })
  213. return
  214. }
  215. // 处理提现
  216. if (this.todo == 'withdraw' && ((Number(this.ipt_value) > this.finance_balance) || Number(this.ipt_value) <
  217. 1)) {
  218. uni.showModal({
  219. title: '提现金额应该小于账户余额,且不小于1元!',
  220. showCancel: false
  221. })
  222. return
  223. }
  224. if (this.todo == 'withdraw' && this.trueName == '') {
  225. uni.showModal({
  226. title: '请输入真实姓名!',
  227. showCancel: false
  228. })
  229. return
  230. }
  231. // 处理充值金额
  232. uni.showModal({
  233. content: '确认' + this.todo_title + this.current_pay + '元?',
  234. success: (res) => {
  235. if (res.confirm) {
  236. uni.login({
  237. success: res => {
  238. uni.showLoading({
  239. title: '加载中...',
  240. mask: true
  241. })
  242. let params = {
  243. bizCatalog: commonData.todo_wal_title_obj[this.todo][
  244. 'bizCatalog'
  245. ],
  246. handleMode: commonData.todo_wal_title_obj[this.todo][
  247. 'handleMode'
  248. ],
  249. todo: 'part',
  250. buyCount: Number(this.ipt_value).toFixed(0),
  251. money: Number(this.ipt_value).toFixed(2),
  252. minaCode: res.code,
  253. trueName: this.trueName,
  254. }
  255. console.log('处理请求参数')
  256. console.log(params)
  257. // return
  258. commonFun.requestUrl(
  259. '&WsAjaxBiz=Worker&WsAjaxAction=entityDataHandle',
  260. params,
  261. res => {
  262. console.log(res)
  263. if (res.status) {
  264. // 提现
  265. if (this.todo == 'withdraw') {
  266. uni.hideLoading()
  267. uni.showModal({
  268. title: '提现成功!',
  269. showCancel: false,
  270. success: () => {
  271. setTimeout(() => {
  272. this.get_data()
  273. this.close_modal()
  274. }, 300)
  275. }
  276. })
  277. return
  278. }
  279. // 充值预处理结果/购买次数预处理结果
  280. if (this.todo == 'wxRecharge' || this.todo ==
  281. 'buyPrepay') {
  282. let prePayInfo = this.todo ==
  283. 'wxRecharge' ? res.data.Result
  284. .prePayInfo : res.data.Result
  285. console.log('充值预处理结果')
  286. console.log(prePayInfo)
  287. if (this.todo == 'buyPrepay' && prePayInfo
  288. .payResult == true) {
  289. uni.hideLoading()
  290. uni.showModal({
  291. title: '充值成功',
  292. confirmText: '充值完成',
  293. cancelText: '返回上页',
  294. success: res => {
  295. if (res.confirm) {
  296. this.get_data()
  297. this.close_modal()
  298. } else {
  299. uni.navigateBack({
  300. delta: 1
  301. })
  302. }
  303. }
  304. })
  305. return
  306. }
  307. uni.requestPayment({
  308. ...prePayInfo,
  309. success: (res2) => {
  310. uni.showModal({
  311. title: '充值成功',
  312. confirmText: '充值完成',
  313. cancelText: '返回上页',
  314. success: res => {
  315. if (res
  316. .confirm
  317. ) {
  318. this.get_data()
  319. this.close_modal()
  320. } else {
  321. uni.navigateBack({
  322. delta: 1
  323. })
  324. }
  325. }
  326. })
  327. },
  328. fail: function(res2) {
  329. if (res2.errMsg
  330. .indexOf(
  331. 'cancel') == -1
  332. ) {
  333. uni.showModal({
  334. title: '充值失败',
  335. content: JSON
  336. .stringify(
  337. res2
  338. ),
  339. showCancel: false,
  340. })
  341. }
  342. }
  343. });
  344. }
  345. }
  346. uni.hideLoading()
  347. })
  348. }
  349. })
  350. }
  351. }
  352. })
  353. },
  354. // 获取用户信息
  355. get_info() {
  356. this.finance_balance = 0
  357. commonFun.get_user_info(res => {
  358. if (res.status) {
  359. uni.hideLoading()
  360. let user_info = res.data.Result
  361. this.user_info = user_info
  362. this.finance_balance = user_info.finance_balance
  363. this.finance_frozenBalance = user_info.finance_frozenBalance
  364. this.finance_numtotalbalance = this.user_info.finance_numFreeCount + this.user_info
  365. .finance_numtotalbalance
  366. console.log('钱包打印个人信息')
  367. console.log(this.user_info)
  368. }
  369. uni.stopPullDownRefresh()
  370. })
  371. },
  372. //切换tab
  373. change_type(type) {
  374. this.type = type
  375. this.get_data()
  376. },
  377. // 获取数据
  378. get_data() {
  379. if (this.sys_role == 1) {
  380. this.fetchRecuritRule()
  381. }
  382. this.get_info()
  383. if (this.isTrader2 == 1 || this.FOREND_TOKEN == '') {
  384. uni.stopPullDownRefresh()
  385. return
  386. }
  387. this.loading = true
  388. uni.showLoading({
  389. title: '加载中...',
  390. mask: true
  391. })
  392. let params = {
  393. bizCatalog: 'AccountEntity',
  394. handleMode: 'fetchall',
  395. pageIndex: 1,
  396. pageSize: 1000,
  397. orderby: 0,
  398. query: {
  399. type: this.type + 1,
  400. }
  401. }
  402. console.log('钱包列表请求参数')
  403. console.log(params)
  404. commonFun.requestUrl('&WsAjaxBiz=Worker&WsAjaxAction=fetchPageData', params, res => {
  405. if (res.status) {
  406. this.data = res.data.Result.pageData
  407. console.log('钱包获取数据')
  408. console.log(this.data)
  409. }
  410. this.loading = false
  411. uni.hideLoading()
  412. uni.stopPullDownRefresh()
  413. })
  414. },
  415. },
  416. components: {},
  417. onShow() {
  418. this.get_data()
  419. },
  420. onLoad(e) {
  421. // 如果携带需要充值的次数,则自动弹窗并携带次数
  422. if (e.dvalue) {
  423. this.open_modal('buyPrepay')
  424. setTimeout(() => {
  425. this.ipt_value = Number(e.dvalue)
  426. this.fetchRecuritRule()
  427. }, 300)
  428. }
  429. this.get_data()
  430. },
  431. onPullDownRefresh() {
  432. this.get_data();
  433. },
  434. };
  435. </script>
  436. <style>
  437. .ipt {
  438. background-color: #f4f4f4;
  439. width: 90%;
  440. margin-left: 5%;
  441. height: 90upx;
  442. text-align: center;
  443. margin-top: 20upx;
  444. }
  445. .wal_bg_right view {
  446. width: 150upx;
  447. height: 60upx;
  448. border-radius: 30upx;
  449. line-height: 60upx;
  450. text-align: center;
  451. }
  452. .wal_bg_left view {
  453. color: white !important;
  454. }
  455. .wal_bg {
  456. display: flex;
  457. justify-content: space-between;
  458. align-items: center;
  459. width: 100%;
  460. height: 300upx;
  461. background-size: 750upx 300upx;
  462. }
  463. .box {
  464. border-bottom: 4upx solid #ececec;
  465. display: flex;
  466. justify-content: space-between;
  467. align-items: center;
  468. width: 92% !important;
  469. margin-left: 4% !important;
  470. }
  471. .head view.focus {
  472. border-bottom: 6upx solid #00AB92;
  473. color: #00AB92;
  474. }
  475. .head view {
  476. height: 70upx;
  477. margin-top: 40upx;
  478. width: 150upx;
  479. text-align: center;
  480. }
  481. .head {
  482. display: flex;
  483. justify-content: space-around;
  484. overflow: hidden;
  485. }
  486. .con {
  487. width: 100%;
  488. /* height: 170upx; */
  489. background: #FFFFFF;
  490. padding: 30upx 0;
  491. }
  492. .wal {
  493. width: 100%;
  494. height: 254upx;
  495. background: linear-gradient(90deg, #0ABACC 0%, #00DC7C 100%);
  496. border-radius: 26upx;
  497. color: #ffffff;
  498. margin-top: 20upx;
  499. overflow: hidden;
  500. }
  501. .merch_money_box_in_3 {
  502. width: 120upx;
  503. height: 50upx;
  504. border-radius: 30upx;
  505. line-height: 50upx;
  506. text-align: center;
  507. margin-top: 20upx;
  508. }
  509. .merch_money_box_in_1 {
  510. color: #333333;
  511. font-size: 40upx;
  512. }
  513. .merch_money_box_in_2 {
  514. color: #999999;
  515. margin-top: 10upx;
  516. }
  517. .merch_money_box_in view {
  518. margin-left: 60upx;
  519. }
  520. .merch_money_box_in {
  521. height: 200upx;
  522. /* background-color: #006566; */
  523. display: flex;
  524. flex-direction: column;
  525. justify-content: center;
  526. }
  527. .merch_money_box {
  528. width: 92%;
  529. height: 220upx;
  530. margin-left: 4%;
  531. margin-top: -130upx;
  532. background: #FFFFFF;
  533. box-shadow: 0px 3px 9px 0px rgba(115, 115, 115, 0.09);
  534. border-radius: 16upx;
  535. display: flex;
  536. align-items: center;
  537. }
  538. .wal_bg_right view {
  539. width: 150upx;
  540. height: 60upx;
  541. border-radius: 30upx;
  542. line-height: 60upx;
  543. text-align: center;
  544. }
  545. .wal_bg_left view {
  546. color: white !important;
  547. font-size: 32upx;
  548. }
  549. .wal_bg {
  550. width: 100%;
  551. height: 370upx;
  552. background-size: 750upx 370upx;
  553. }
  554. .wal_bg_box {
  555. display: flex;
  556. justify-content: space-between;
  557. align-items: center;
  558. height: 240upx;
  559. }
  560. .box {
  561. border-bottom: 4upx solid #ececec;
  562. display: flex;
  563. justify-content: space-between;
  564. align-items: center;
  565. }
  566. .head view.focus {
  567. border-bottom: 6upx solid #00AB92;
  568. color: #00AB92;
  569. }
  570. .head view {
  571. height: 70upx;
  572. margin-top: 40upx;
  573. width: 150upx;
  574. text-align: center;
  575. }
  576. .head {
  577. display: flex;
  578. justify-content: space-around;
  579. overflow: hidden;
  580. }
  581. .con {
  582. width: 100%;
  583. /* height: 170upx; */
  584. background: #FFFFFF;
  585. padding: 30upx 0;
  586. }
  587. .wal {
  588. width: 100%;
  589. height: 254upx;
  590. background: linear-gradient(90deg, #0ABACC 0%, #00DC7C 100%);
  591. border-radius: 26upx;
  592. color: #ffffff;
  593. margin-top: 20upx;
  594. overflow: hidden;
  595. }
  596. </style>