index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <!--promote/withdrawal/index/index.wxml-->
  3. <view>
  4. <view class=" mt20 r10">
  5. <block v-if="wechat == 0">
  6. <icon class="iconfont icon-tianjia"></icon>
  7. <view class="top">
  8. <view class="add ddflex" v-if="!settlementInfo" @click="toaddCard()">
  9. <icon class="icon iconfont icontianjia"></icon>
  10. <text>添加银行卡</text>
  11. </view>
  12. <view class="information" v-else>
  13. <view class="li ddflex">
  14. <image src="../../static/promote/images/txico1.png" class="txico"></image>
  15. <view class="fflex">
  16. <view class="t-name ddflex">
  17. <view class="fflex">{{ settlementInfo.legalCertName }}</view>
  18. <view class="t-sta ddflex">
  19. <!-- <image src="../../static/promote/images/txico3.png"></image> -->
  20. {{ getStateText(1) }}
  21. <image src="../../../static/pages/images/crico1.png" class="rico"></image>
  22. </view>
  23. </view>
  24. <view class="t-bri">{{ styleHintText(settlementInfo.legalCertId) }}</view>
  25. </view>
  26. </view>
  27. <view class="li ddflex" @click="toaddCard()">
  28. <image src="../../static/promote/images/txico2.png" class="txico"></image>
  29. <view class="fflex">
  30. <view class="t-name ddflex">
  31. <view class="fflex">{{ getBankName(settlementInfo.bankCode) }}</view>
  32. <view class="t-sta ddflex">
  33. <!-- <image src="../../static/promote/images/txico3.png"></image> -->
  34. {{ getStateText(2) }}
  35. <image src="../../../static/pages/images/crico1.png" class="rico"></image>
  36. </view>
  37. </view>
  38. <view class="t-bri" v-if="settlementInfo.cardNo">{{ '尾号' + getbankNo(settlementInfo.cardNo) }}</view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </block>
  44. <view class="pdlr20 pd50 bgfff cont">
  45. <view class="txje ddflex">
  46. <view class="fflex">提现金额</view>
  47. <navigator url="/promote/withdrawal/income/income" hover-class="none" class="ddflex">
  48. 收益账户明细
  49. <image src="../../../static/pages/images/crico1.png" class="rico"></image>
  50. </navigator>
  51. </view>
  52. <view class="dflex money pd50">
  53. <text>¥</text>
  54. <input adjust-position="false" placeholder="输入提现金额" placeholder-class="placeholder" type="number" :value="allmoney" @input="getwithdrawal" />
  55. </view>
  56. <view class="dflex tx mt20">
  57. <text class="mcolor">可提现金额 {{ countMoney.ktx }}元</text>
  58. <text @tap="allmoneyFun">全部提现</text>
  59. </view>
  60. <view class="btn mt50" @tap="withdrawmoney">提现</view>
  61. <view class="mt20">
  62. <text class="mcolor " v-if="minMoney > 0">最小提现金额 {{ minMoney }}元</text>
  63. </view>
  64. </view>
  65. </view>
  66. <navigator url="/promote/withdrawal/record/record" hover-class="none" class="jlbtn">历史提现记录</navigator>
  67. </view>
  68. </template>
  69. <script>
  70. // promote/withdrawal/index/index.js
  71. const app = getApp();
  72. const util = require('../../../utils/util.js');
  73. const { msg } = require('../../../utils/request.js');
  74. const req = require('../../../utils/request.js');
  75. const hfParams = require('../../../utils/hfParams.js');
  76. export default {
  77. data() {
  78. return {
  79. txmoney: 0,
  80. wechat: 0,
  81. minMoney: '',
  82. // card: '',
  83. // isShow: false,
  84. // Firstcard: '',
  85. // Lastcard: '',
  86. allmoney: '',
  87. countMoney: {},
  88. settlementInfo: '',
  89. bankList: []
  90. };
  91. },
  92. components: {},
  93. props: {},
  94. /**
  95. * 生命周期函数--监听页面加载
  96. */
  97. onLoad: function(options) {
  98. this.getminMoney();
  99. this.bankList = hfParams.bank();
  100. },
  101. /**
  102. * 生命周期函数--监听页面显示
  103. */
  104. onShow: function() {
  105. this.getMoney(); //分销统计
  106. // this.getCard();
  107. this.getProfit(); //用户收益统计
  108. this.getSettlementInfo();
  109. },
  110. methods: {
  111. getbankNo(bankNo) {
  112. if (bankNo) {
  113. return bankNo.substring(bankNo.length - 4, bankNo.length);
  114. }
  115. },
  116. getBankName(code) {
  117. if (code) {
  118. for (var i = 0; i < this.bankList.length; i++) {
  119. var bankObj = this.bankList[i];
  120. if (bankObj.code == code) {
  121. return bankObj.name;
  122. }
  123. }
  124. }
  125. },
  126. getStateText(type) {
  127. var text = '';
  128. if (this.settlementInfo && this.settlementInfo.channelList && this.settlementInfo.channelList.length > 0) {
  129. var obj = this.settlementInfo.channelList[0];
  130. if (type == 1) {
  131. //商户状态 -1 资料完善中 0、审核中 1、审核成功 2、审核失败
  132. if (obj.state == -1) {
  133. text = '资料完善中';
  134. } else if (obj.state == 0) {
  135. text = '审核中';
  136. } else if (obj.state == 1) {
  137. text = '已实名';
  138. } else if (obj.state == 2) {
  139. text = '审核失败';
  140. }
  141. }
  142. if (type == 2) {
  143. //结算账户状态 0、未创建 1、正常 2、已删除 3、删除失败 4、创建失败 ,
  144. if (obj.settlementState == 0) {
  145. if (obj.errMsg) {
  146. text = obj.errMsg;
  147. } else {
  148. text = '审核中';
  149. }
  150. } else if (obj.settlementState == 1) {
  151. text = '已绑定';
  152. } else if (obj.settlementState == 4) {
  153. text = obj.errMsg;
  154. }
  155. }
  156. }
  157. return text;
  158. },
  159. styleHintText(str) {
  160. return util.styleHintText(str);
  161. },
  162. //是否可提现
  163. isOkState() {
  164. var is = false;
  165. if (this.settlementInfo && this.settlementInfo.channelList && this.settlementInfo.channelList.length > 0) {
  166. var obj = this.settlementInfo.channelList[0];
  167. if (obj.state == 1 && obj.settlementState == 1) {
  168. is = true;
  169. }
  170. }
  171. return is;
  172. },
  173. getProfit() {
  174. req.getRequest('/api/rrLogs/profit', {}, res => {
  175. this.countMoney = res;
  176. });
  177. },
  178. getminMoney() {
  179. req.g('/api/config', res => {
  180. req.setStorage('configRes', JSON.stringify(res)); // 获取最小金额
  181. if (res.CONFIG_WITHDRAW_Min && res.CONFIG_WITHDRAW_Min >= 1) {
  182. this.setData({
  183. minMoney: res.CONFIG_WITHDRAW_Min
  184. });
  185. } else {
  186. this.setData({
  187. minMoney: 1
  188. });
  189. } //获取是否开通提现到微信零钱
  190. if (res.withdraw_wechat_small) {
  191. this.wechat = res.withdraw_wechat_small;
  192. }
  193. });
  194. },
  195. getSettlementInfo() {
  196. req.getRequest('/api/v3/settlement/info', '', data => {
  197. this.settlementInfo = data;
  198. });
  199. },
  200. // // 获取用户银行卡信息
  201. // getCard() {
  202. // req.getRequest('/api/bank', '', data => {
  203. // console.log(data);
  204. // if (data) {
  205. // let Firstcard = data.card.substring(0, 4);
  206. // let Lastcard = data.card.substring(data.card.length - 4, data.card.length);
  207. // console.log(Firstcard, Lastcard);
  208. // this.setData({
  209. // card: data,
  210. // isShow: false,
  211. // Firstcard: Firstcard,
  212. // Lastcard: Lastcard
  213. // });
  214. // } else {
  215. // this.setData({
  216. // isShow: true
  217. // });
  218. // }
  219. // });
  220. // },
  221. // 获取用户金额
  222. getMoney() {
  223. req.getRequest('/api/distribution/info', {}, data => {
  224. this.setData(data);
  225. // console.log(this);
  226. });
  227. },
  228. // 提现
  229. withdrawmoney() {
  230. if (this.wechat == 0) {
  231. if (!this.isOkState()) {
  232. return req.msg('请先添加正确的银行卡信息');
  233. }
  234. }
  235. if (this.txmoney == 0) {
  236. return req.msg('请输入提现金额');
  237. } else if (this.txmoney > this.countMoney.ktx) {
  238. return req.msg('提现金额不能大于可提金额');
  239. } else if (this.txmoney < this.minMoney) {
  240. return req.msg('提现金额不能低于最小提现金额');
  241. } else if (this.txmoney > 0 && this.txmoney <= this.countMoney.ktx && +this.txmoney >= +this.minMoney) {
  242. req.postRequest(
  243. '/api/withdraw',
  244. {
  245. money: this.txmoney
  246. },
  247. res => {
  248. console.log(res);
  249. req.msg('您的提现申请已受理,请等待平台打款', success => {
  250. setTimeout(function() {
  251. uni.navigateBack();
  252. }, 1500);
  253. });
  254. }
  255. );
  256. }
  257. },
  258. //全部提现
  259. allmoneyFun() {
  260. this.setData({
  261. allmoney: this.countMoney.ktx,
  262. txmoney: this.countMoney.ktx
  263. });
  264. },
  265. // 获取提现金额
  266. getwithdrawal(e) {
  267. this.setData({
  268. txmoney: e.detail.value
  269. });
  270. },
  271. toaddCard() {
  272. var url = '/promote/withdrawal/bindCard/bindCard';
  273. if (this.settlementInfo) {
  274. if (this.isOkState()) {
  275. url = '/promote/withdrawal/bindCardCheck/bindCardCheck';
  276. } else {
  277. url = url + '?isEnd=true';
  278. }
  279. }
  280. uni.navigateTo({
  281. url: url
  282. });
  283. }
  284. }
  285. };
  286. </script>
  287. <style>
  288. @import './index.css';
  289. </style>