promotionExtract.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <template>
  2. <view class="box">
  3. <view class="tixiancs">
  4. <view class="tixiancsLeft"></view>
  5. <view class="tixiancsRight" @click="goRouter('../referral/extractList?type=2')">提现明细</view>
  6. </view>
  7. <view class="header">
  8. <view class="title">提现金额</view>
  9. <view class="moneyView">
  10. <text class="icon">¥</text>
  11. <input type="digit" class="moneyInput" placeholder-style="color:#999999; font-size:30rpx"
  12. v-model="money" @input="inputValue" />
  13. <view class="allBtn" @click="allBtn">全部提现</view>
  14. </view>
  15. <view class="zongMoney">可提现金额: <span style="padding: 0 10rpx;">{{canMoney.toFixed(2)}} 元 </span> </view>
  16. </view>
  17. <view class="sureBtn" @click="sure">申请提现</view>
  18. <view class="tishi" style="padding:20rpx 20rpx 100rpx 20rpx ; ">
  19. <view class="tishi-title" style="color: #999999;padding-left: 18rpx;">
  20. 提现说明:
  21. </view>
  22. <view class="tishiText">
  23. <rich-text :nodes="description"></rich-text>
  24. </view>
  25. <!-- <view class="tishiLine">
  26. <view class="tishiTxt">1.最小提现金额:<span class="tishiTxtColor">{{minCash}}</span>元</view>
  27. </view>
  28. <view class="tishiLine">
  29. <view class="tishiTxt">2.只允许一笔提现在途</view>
  30. </view> -->
  31. <!-- <view class="tishiLine">
  32. <view class="tishiTxt">1.提现冻结天数:<span class="tishiTxtColor">{{detail.explain&&detail.explain.freezeDay}}</span>天</view>
  33. </view>
  34. <view class="tishiLine">
  35. <view class="tishiTxt">2.最小提现金额:<span class="tishiTxtColor">{{detail.explain&&detail.explain.singleLow}}</span>元</view>
  36. </view>
  37. <view class="tishiLine">
  38. <view class="tishiTxt">3.每月可提现次数:<span class="tishiTxtColor">{{detail.explain&&detail.explain.monthlyMost}}</span>次</view>
  39. </view> -->
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. okMoney: '',
  48. money: 0,
  49. name: '',
  50. account: '',
  51. detail: {},
  52. alreadyMoney: 0,
  53. canMoney: 0,
  54. inMoney: 0,
  55. sumMoney: 0,
  56. minCash: 0.1,
  57. couContent: '', //提现规则
  58. cashState:null,
  59. timer :null,
  60. appId:'',
  61. mchId:'',
  62. outBatchNo:'',
  63. packageInfo:'',
  64. state:'',
  65. jkcashid:'',
  66. maxCash:0,
  67. description:'',
  68. }
  69. },
  70. onLoad() {
  71. this.getDetailData()
  72. },
  73. methods: {
  74. goRouter(url){
  75. uni.navigateTo({
  76. url:url
  77. })
  78. },
  79. getDetailData() {
  80. uni.showLoading({
  81. title: '加载中'
  82. })
  83. this.$http('jkCashout/getCashoutData', {}, 'GET').then(res => {
  84. uni.hideLoading();
  85. this.alreadyMoney = res.data.AlreadyMoney
  86. this.canMoney = res.data.CanMoney
  87. this.inMoney = res.data.InMoney
  88. this.sumMoney = res.data.SumMoney
  89. this.minCash = res.data.MinCash
  90. this.cashState = res.data.CashState
  91. this.maxCash = res.data.MaxCash
  92. this.description = res.data.description
  93. })
  94. },
  95. inputValue(event) {
  96. if (event.detail.value < 0) {
  97. setTimeout(() => {
  98. this.money = 0; // 解决
  99. }, 0)
  100. } else {
  101. this.money = event.detail.value;
  102. }
  103. },
  104. allBtn() {
  105. setTimeout(() => {
  106. this.money = this.canMoney.toFixed(2); // 解决
  107. }, 0)
  108. },
  109. sure() {
  110. if (this.money > this.canMoney) {
  111. uni.showToast({
  112. title: '提现金额不能大于可提现金额',
  113. icon: 'none',
  114. duration: 3000,
  115. });
  116. return;
  117. }
  118. if (this.money <= 0) {
  119. uni.showToast({
  120. title: '提现金额不能为0',
  121. icon: 'none',
  122. duration: 3000,
  123. });
  124. return;
  125. }
  126. if (this.money < this.minCash) {
  127. uni.showToast({
  128. title: '提现金额最低为'+this.minCash,
  129. icon: 'none',
  130. duration: 3000,
  131. });
  132. return;
  133. }
  134. if (this.money > this.maxCash) {
  135. uni.showToast({
  136. title: '提现金额最高为'+this.maxCash,
  137. icon: 'none',
  138. duration: 3000,
  139. });
  140. return;
  141. }
  142. this.postData();
  143. },
  144. postData() {
  145. uni.showLoading({
  146. title: '提现申请中..'
  147. })
  148. let url = 'jkCashout/applyJkCashout',
  149. params = {
  150. money: this.money,
  151. }
  152. this.$http(url, params, 'POST').then(res => {
  153. //uni.hideLoading();
  154. console.log(res)
  155. if(res.code ==0){
  156. this.canMoney = this.canMoney - this.money
  157. }
  158. //人工审核
  159. if(res.code==0 && res.data.cashType ==1){
  160. uni.showModal({
  161. title: '提交成功',
  162. content: '请耐心等待平台审核',
  163. showCancel:false,
  164. confirmText:'知道了',
  165. success: function(res) {
  166. uni.hideLoading();
  167. }
  168. });
  169. }else if(res.code==0 && res.data.cashType ==0){
  170. //自动审核
  171. //轮询查询状态
  172. uni.showToast({
  173. title: '审核成功请等待..',
  174. icon: 'success',
  175. duration: 3000,
  176. });
  177. this.appId = res.data.appId
  178. this.mchId = res.data.mchId
  179. this.outBatchNo = res.data.outBatchNo
  180. this.packageInfo = res.data.packageInfo
  181. this.state = res.data.state
  182. this.jkcashid = res.data.jkcashid
  183. if(res.data.state =='WAIT_USER_CONFIRM'){
  184. this.getWechatMoney()
  185. }else{
  186. this.checkOrderStatus()
  187. }
  188. }else if(res.code==0 && res.data.cashType ==2){
  189. //线下
  190. uni.showToast({
  191. title: '申请成功请等待平台审核',
  192. icon: 'success',
  193. duration: 3000,
  194. });
  195. }
  196. })
  197. },
  198. async checkOrderStatus() {
  199. try {
  200. this.$http('jkCashout/checkJkCashoutState', {
  201. outBatchNo:this.outBatchNo,
  202. jkcashid:this.jkcashid
  203. }, 'POST').then(res => {
  204. console.log(res);
  205. if(res.code == 0 && res.data.state =='WAIT_USER_CONFIRM'){
  206. uni.hideLoading();
  207. clearTimeout(this.timer);
  208. this.getWechatMoney();
  209. }
  210. else if(res.code == 0 && res.data.state =='SUCCESS'){
  211. //成功页面
  212. console.log("领取成功-跳转成功页面");
  213. clearTimeout(this.timer);
  214. this.goRouter('../subPack/extractSuccess?money='+this.money);
  215. }
  216. else if(res.code == 0 && res.data.state =='FAIL'){
  217. //失败页面
  218. console.log("领取失败-跳转失败页面");
  219. clearTimeout(this.timer);
  220. this.goRouter('../subPack/extractFail?money='+this.money)
  221. }else if(res.code == 1){
  222. uni.showToast({
  223. title: res.msg,
  224. icon: 'error',
  225. duration: 3000,
  226. });
  227. clearTimeout(this.timer);
  228. }
  229. else{
  230. console.log("else")
  231. this.timer = setTimeout(this.checkOrderStatus, 2000);
  232. }
  233. })
  234. } catch (error) {
  235. console.error('查询订单状态失败:', error);
  236. // 出错时也继续轮询
  237. clearTimeout(this.timer);
  238. }
  239. },
  240. checkOrderStatusMounted() {
  241. this.checkOrderStatus(); // 立即执行第一次查询
  242. },
  243. beforeDestroy() {
  244. clearTimeout(this.timer);
  245. },
  246. getWechatMoney(){
  247. if (wx.canIUse('requestMerchantTransfer')) {
  248. wx.requestMerchantTransfer({
  249. mchId: this.mchId,
  250. appId: this.appId,
  251. package: this.packageInfo,
  252. success: (res) => {
  253. // res.err_msg将在页面展示成功后返回应用时返回ok,并不代表付款成功
  254. console.log(res);
  255. if (res.errMsg === 'requestMerchantTransfer:ok') {
  256. //展示页面成功
  257. this.checkOrderStatusMounted();
  258. }
  259. if (res.errMsg === 'requestMerchantTransfer:fail') {
  260. //展示页面失败
  261. //this.checkOrderStatusMounted();
  262. }
  263. if (res.errMsg === 'requestMerchantTransfer:cancel') {
  264. //用户点击取消
  265. this.beforeDestroy();
  266. //this.userCancelMoney();
  267. this.goRouter('../referral/extractList?type=2');
  268. }
  269. },
  270. fail: (res) => {
  271. console.log(res);
  272. if (res.errMsg === 'requestMerchantTransfer:fail:internal error') {
  273. //用户点击取消
  274. this.beforeDestroy();
  275. //this.userCancelMoney();
  276. this.goRouter('../referral/extractList?type=2');
  277. }
  278. }
  279. });
  280. }
  281. },
  282. userCancelMoney(){
  283. //用户取消提现 outBatchNo:this.outBatchNo,
  284. this.$http('jkCashout/failJkCashout', {
  285. jkcashid:this.jkcashid
  286. }, 'POST').then(res => {
  287. })
  288. }
  289. }
  290. }
  291. </script>
  292. <style>
  293. .box {
  294. min-height: 100vh;
  295. background: #F4F5F7;
  296. padding-top: 20rpx;
  297. }
  298. .tishiLine{
  299. display: flex;padding-top: 20rpx;
  300. color: #999999;
  301. }
  302. .tishiY{
  303. width: 10rpx;
  304. height: 10rpx;
  305. background: #DDDDDD;
  306. margin-top: 16rpx;
  307. border-radius: 50%;
  308. }
  309. .tishiTxt{
  310. padding-left: 18rpx;
  311. color: #999999;
  312. }
  313. .tixiancs{
  314. display: flex;
  315. justify-content: space-between;
  316. font-size: 24rpx;
  317. padding-left: 24rpx;
  318. padding-right: 24rpx;
  319. padding-bottom: 10rpx;
  320. }
  321. .tixiancsLeft{
  322. color: #999999;
  323. }
  324. .tixiancsRight{
  325. color:#596999;
  326. }
  327. .tishiTxtColor{
  328. color: #999999;
  329. }
  330. .header {
  331. background-color: #FFFFFF;
  332. margin: 0 24rpx;
  333. border-radius: 10rpx;
  334. padding: 30rpx 20rpx;
  335. }
  336. .title {
  337. font-size: 28rpx;
  338. color: #3C3C3C;
  339. }
  340. .moneyView {
  341. display: flex;
  342. justify-content: space-between;
  343. align-items: center;
  344. margin: 15rpx 0;
  345. }
  346. .icon {
  347. font-size: 50rpx;
  348. color: #222222;
  349. }
  350. .moneyInput {
  351. font-size: 70rpx;
  352. color: #222222;
  353. /* flex-grow: 1; */
  354. height: 98rpx;
  355. width: 100%;
  356. }
  357. .allBtn {
  358. font-size: 30rpx;
  359. color: #596999;
  360. width: 200rpx;
  361. height: 50rpx;
  362. line-height: 50rpx;
  363. margin-left: 10rpx;
  364. text-align: right;
  365. position: absolute;
  366. right: 45rpx;
  367. top: 40px;
  368. }
  369. .zongMoney {
  370. font-size: 25rpx;
  371. color: #999999;
  372. border-top: solid 3rpx #F4F4F4;
  373. padding-top: 25rpx;
  374. }
  375. .line {
  376. background-color: #EEEEEE;
  377. height: 1rpx;
  378. }
  379. .name {
  380. display: flex;
  381. justify-content: flex-start;
  382. padding: 28rpx 0;
  383. }
  384. .leftTitle {
  385. font-size: 30rpx;
  386. color: #3C3C3C;
  387. margin-right: 90rpx;
  388. }
  389. .Input {
  390. font-size: 30rpx;
  391. color: #333333;
  392. }
  393. .tishi {
  394. padding: 0 44rpx;
  395. font-size: 26rpx;
  396. color: #999999;
  397. line-height: 1.5;
  398. }
  399. .tishi-title{
  400. padding-left: 18rpx;
  401. }
  402. .tishiText{
  403. padding-left: 18rpx;
  404. }
  405. .sureBtn {
  406. width: 690rpx;
  407. margin: 40rpx 30rpx;
  408. border-radius: 15rpx;
  409. height: 74rpx;
  410. background: #EB0F0A;
  411. color: #FFFFFF;
  412. font-size: 30rpx;
  413. text-align: center;
  414. line-height: 74rpx;
  415. }
  416. </style>