withdraw.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <view>
  3. <ujp-navbar title="提现"></ujp-navbar>
  4. <view class="withdraw">
  5. <view class="withdraw-head">
  6. <b>提现至</b><span>{{code}}</span>
  7. </view>
  8. <view class="withdraw-head">
  9. <b>选择提现站点</b>
  10. <span >
  11. <picker @change="bindPickerChange" range-key="name" :range="stationList">
  12. <view class="uni-input">{{stationObj.name?stationObj.name:'无站点'}}<text class="iconfont more">
  13. &#xe600;
  14. </text></view>
  15. </picker>
  16. </span>
  17. </view>
  18. <view class="withdraw-head">
  19. <b>上次提现时间</b><span>{{info.startTime}}</span>
  20. </view>
  21. <view class="withdraw-head">
  22. <b>本次提现时间</b>
  23. <u-picker mode="time" v-model="showEndTime" :default-time="endTime" :params="params" @confirm="bindDateChange0"></u-picker>
  24. <span @click="showEndTime=true">
  25. <view class="uni-input">{{info.endTime}} <text class="iconfont more">
  26. &#xe600;
  27. </text></view>
  28. </span>
  29. </view>
  30. <view class="withdraw-head">
  31. <b>此期间累计产生订单数</b><span>{{info.total}}笔</span>
  32. </view>
  33. <view class="withdraw-head">
  34. <b>此期间总分润金额</b><span class="whthdraw-price">{{info.amount?info.amount.toFixed(2):0}}元</span>
  35. </view>
  36. <view class="withdraw-head">
  37. <b>此期间累计产生折扣卡分润数</b><span>{{info.cardTotal}}笔</span>
  38. </view>
  39. <view class="withdraw-head">
  40. <b>此期间累计折扣卡分润金额</b><span class="whthdraw-price">{{info.cardAmount.toFixed(2)}}元</span>
  41. </view>
  42. <view class="withdraw-head">
  43. <b>分润提现明细表</b><span class="download" @click="ckdownload"><u-icon name="download"></u-icon> 下载</span>
  44. </view>
  45. <view class="withdraw-main" v-if="false">
  46. <p>申请提现金额(元)</p>
  47. <view class="withdraw-input">
  48. <span>¥</span>
  49. <u-input v-model="value" :type="type" placeholder-style="font-size:28px;height:40px;line-height:40px;color:#ccc;" />
  50. </view>
  51. </view>
  52. <view class="withdraw-head">
  53. <b>是否开票</b><span >
  54. <u-radio-group v-model="invoiceRequired" >
  55. <u-radio v-for="(item, index) in list2"
  56. :key="index+'a'" :name="item.value"
  57. :disabled="item.disabled" active-color="#00b962">
  58. {{item.name}}
  59. </u-radio>
  60. </u-radio-group>
  61. </span>
  62. </view>
  63. <view class="withdraw-head">
  64. <b>发票类型</b><span >
  65. <u-radio-group v-model="invoiceType" >
  66. <u-radio v-for="(item, index) in list1" :key="index+'a'" :name="item.value"
  67. :disabled="item.disabled" active-color="#00b962">
  68. {{item.name}}
  69. </u-radio>
  70. </u-radio-group>
  71. </span>
  72. </view>
  73. <view class="withdraw-head" v-if="!isPt" >
  74. <b>实际电量(度)<span style="color: red; float: none;">*</span></b>
  75. <span class="withdraw-input">
  76. <u-input
  77. height="20px"
  78. placeholder="请输入实际电量"
  79. input-align="right"
  80. type="digit"
  81. v-model="electricQuantity"
  82. ></u-input>
  83. </span>
  84. </view>
  85. <view class="withdraw-head" v-if="!isPt" >
  86. <b>成本电价(元/度)<span style="color: red; float: none;">*</span></b>
  87. <span class="withdraw-input">
  88. <u-input
  89. height="20px"
  90. placeholder="请输入成本电价"
  91. input-align="right"
  92. type="digit"
  93. v-model="electricityPrice"
  94. ></u-input>
  95. </span>
  96. </view>
  97. <view class="withdraw-head" >
  98. <b>开票税率(%)</b>
  99. <span class="withdraw-input">
  100. <u-input
  101. height="20px"
  102. placeholder="请输入开票税率"
  103. input-align="right"
  104. type="digit"
  105. v-model="taxRate"
  106. ></u-input>
  107. </span>
  108. </view>
  109. </view>
  110. <view class="applyBtn">
  111. <u-button :class="{
  112. 'applyBtn-btn':!info.amount&&!info.cardAmount
  113. }" @click="submit()" type="primary">申请提现,等待财务转账</u-button>
  114. </view>
  115. <view class="withdraw-tips">
  116. <h4>提现说明:</h4>
  117. <p>由于银行清算,提现申请将于次日内到账。如遇高峰期,可能延时到账,请耐心等待。</p>
  118. </view>
  119. </view>
  120. </template>
  121. <script>
  122. import * as API from '@/apis/finance.js'
  123. import {
  124. parseUnixTime,
  125. substrMb
  126. } from '@/utils'
  127. export default {
  128. data() {
  129. return {
  130. params: {
  131. year: true,
  132. month: true,
  133. day: true,
  134. hour: true,
  135. minute: true,
  136. second: true,
  137. timestamp: true,
  138. },
  139. isPt:false,
  140. info:{},
  141. electricityPrice:'',
  142. electricQuantity:'',
  143. code:"",
  144. showEndTime:false,
  145. value: '',
  146. type: 'number',
  147. nowTime:"",
  148. taxRate:"",
  149. invo:"",
  150. invoiceRequired:"1",
  151. invoiceType:"1",
  152. stationList:[],
  153. stationObj:{},
  154. list1: [{
  155. name: '普票',
  156. value:"1"
  157. }, {
  158. name: '专票',
  159. value:"2"
  160. }],
  161. list2: [{
  162. name: '是',
  163. value:"1"
  164. }, {
  165. name: '否 ',
  166. value:"0"
  167. }],
  168. home:{
  169. accountBalance:0
  170. },
  171. endTime:null
  172. }
  173. },
  174. onReady() {
  175. this.endTime=parseUnixTime(new Date(),"{y}-{m}-{d} 00:00:00")
  176. //this.getHomePage()
  177. },
  178. onShow(){
  179. this.nowTime=parseUnixTime(new Date())
  180. this.getHomePage()
  181. },
  182. methods: {
  183. bindDateChange0(e){
  184. console.log(e)
  185. var key=e.year+"/"+e.month+"/"+e.day+" "+e.hour+":"+e.minute+":"+e.second;
  186. var endTime=parseUnixTime(new Date(key))
  187. if(endTime<this.nowTime){
  188. this.endTime=parseUnixTime(new Date(key))
  189. this.info.endTime=this.endTime
  190. this.queryWithdrawInfo(this.stationObj.id)
  191. }else{
  192. uni.showToast({
  193. title:"结束时间不能大于当前时间"
  194. })
  195. }
  196. },
  197. ckdownload(){
  198. //this.value=this.info.amount
  199. if(!this.stationObj.id){
  200. uni.showToast({
  201. title: "请选择站点"
  202. })
  203. return
  204. }
  205. API.profitDetailsExcel({
  206. stationId:this.stationObj.id,
  207. startTime:this.info.startTime,
  208. endTime:this.info.endTime
  209. }).then((resDown) => {
  210. // uni.downloadFile({
  211. // url: resDown.data, //仅为示例,并非真实的资源
  212. // success: (res) => {
  213. // if (res.statusCode === 200) {
  214. // console.log('下载成功');
  215. // }
  216. // }
  217. // });
  218. if(resDown.data){
  219. window.location.href=resDown.data
  220. }else{
  221. uni.showToast({
  222. title:"无文件下载"
  223. })
  224. }
  225. }).catch(error => {
  226. uni.showToast({
  227. title:error
  228. })
  229. })
  230. },
  231. bindPickerChange(e){
  232. console.log(e)
  233. if(this.stationList[e.detail.value]){
  234. this.stationObj=this.stationList[e.detail.value];
  235. this.queryWithdrawInfo(this.stationObj.id)
  236. }
  237. },
  238. selectStation(){},
  239. submit(){
  240. //this.value=this.info.amount
  241. if(!this.stationObj.id){
  242. uni.showToast({
  243. title: "请选择站点"
  244. })
  245. return
  246. }
  247. if(!this.isPt){
  248. if(!this.electricQuantity){
  249. uni.showToast({
  250. title: "请输入实际电量"
  251. })
  252. return
  253. }
  254. if(!this.electricityPrice){
  255. uni.showToast({
  256. title: "请输入成本电价"
  257. })
  258. return
  259. }
  260. this.info.electricQuantity=this.electricQuantity
  261. this.info.electricityPrice=this.electricityPrice
  262. }
  263. var amount=0
  264. if(!this.info.amount&&!this.info.cardAmount){
  265. uni.showToast({
  266. title: "可提现金额为0"
  267. })
  268. return
  269. }
  270. amount=(this.info.amount*100+this.info.cardAmount*100)/100;
  271. uni.showLoading({
  272. title: "加载中",
  273. mask: true,
  274. })
  275. this.info.invoiceRequired=this.invoiceRequired
  276. this.info.invoiceType=this.invoiceType
  277. this.info.taxRate=this.taxRate
  278. this.info.stationId=this.stationObj.id;
  279. API.applyWithdraw(this.info).then((res) => {
  280. uni.redirectTo({
  281. url:"/pagesFinance/user/applyResult?value="+amount
  282. })
  283. }).catch(error => {
  284. uni.hideLoading()
  285. uni.showModal({
  286. title:"提示",
  287. content:error,
  288. showCancel:false
  289. })
  290. })
  291. },
  292. queryWithdrawInfo(id){
  293. uni.showLoading({
  294. title: "加载中",
  295. mask: true,
  296. })
  297. API.queryWithdrawInfo({
  298. stationId:id,
  299. endTime:this.endTime
  300. }).then((res) => {
  301. this.info=res.data;
  302. this.isPt=res.data.isPt;
  303. uni.hideLoading()
  304. }).catch(error => {
  305. uni.showToast({
  306. title: error
  307. })
  308. })
  309. },
  310. getStationList(){
  311. uni.showLoading({
  312. title: "加载中",
  313. mask: true,
  314. })
  315. API.stationList().then((res) => {
  316. this.stationList=res.data.stationList;
  317. if(this.stationList.length){
  318. this.stationObj=this.stationList[0];
  319. this.queryWithdrawInfo(this.stationList[0].id)
  320. }
  321. uni.hideLoading()
  322. }).catch(error => {
  323. uni.showToast({
  324. title: error
  325. })
  326. })
  327. },
  328. getHomePage(){
  329. uni.showLoading({
  330. title: "加载中",
  331. mask: true,
  332. })
  333. API.homePage().then((res) => {
  334. this.home = res.data
  335. var bankCard="";
  336. if(this.home.bankCard){
  337. bankCard=substrMb(this.home.bankCard,0,4)+"****"+substrMb(this.home.bankCard,this.home.bankCard.length-4,4)
  338. }
  339. this.code=this.home.bank+":"+bankCard;
  340. if(this.home.bank==null&&this.home.bankCard==null){
  341. this.code="未绑定"
  342. }
  343. uni.hideLoading()
  344. this.getStationList()
  345. }).catch(error => {
  346. uni.showToast({
  347. title: error
  348. })
  349. })
  350. }
  351. }
  352. }
  353. </script>
  354. <style>
  355. page{
  356. background-color: #F7F7F7;
  357. }
  358. </style>
  359. <style lang="scss" scoped>
  360. .download{
  361. color: #185AC6 ;
  362. }
  363. .withdraw-tips{
  364. margin:24px 16px;
  365. p{
  366. color:#999;
  367. margin-top: 4px;
  368. }
  369. }
  370. .withdraw{
  371. margin: 16px;
  372. background-color: #fff;
  373. padding: 16px 16px 0 16px;
  374. .withdraw-head{
  375. // margin: 16px 0;
  376. padding: 16px 0;
  377. border-bottom: 1px solid #f7f7f7;
  378. line-height: 20px;
  379. align-items: center;
  380. .whthdraw-price{
  381. font-size: 18px;
  382. color: #101010;
  383. font-weight: 600;
  384. }
  385. b{
  386. color:#999;
  387. }
  388. span{
  389. margin-left: 12px;
  390. float: right;
  391. }
  392. }
  393. .withdraw-main{
  394. border-top: 1px solid #f7f7f7;
  395. border-bottom: 1px solid #f7f7f7;
  396. margin: 16px 0;
  397. padding: 16px 0;
  398. .withdraw-input{
  399. margin-top: 32px;
  400. display: flex;
  401. align-items: center;
  402. font-size: 28px;
  403. /deep/.uni-input-input{
  404. font-size: 28px;
  405. }
  406. }
  407. }
  408. .withdraw-foot{
  409. display: flex;
  410. align-items: center;
  411. p{
  412. color:#999
  413. }
  414. span{
  415. color:#2979FF;
  416. margin-left: 16px;
  417. }
  418. }
  419. }
  420. .applyBtn{
  421. margin: 16px;
  422. }
  423. .applyBtn-btn{
  424. background-color: #185AC6;
  425. opacity: 0.5;
  426. border-color:#185AC6 ;
  427. border-radius: 8px;
  428. }
  429. </style>