promotionExtract.vue 10 KB

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