promotionExtract.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  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; // 解决
  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 && this.cashState==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 && this.cashState==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 && this.cashState==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. clearTimeout(this.timer);
  221. }
  222. else{
  223. this.timer = setTimeout(this.checkOrderStatus, 2000);
  224. }
  225. })
  226. } catch (error) {
  227. console.error('查询订单状态失败:', error);
  228. // 出错时也继续轮询
  229. clearTimeout(this.timer);
  230. }
  231. },
  232. checkOrderStatusMounted() {
  233. this.checkOrderStatus(); // 立即执行第一次查询
  234. },
  235. beforeDestroy() {
  236. clearTimeout(this.timer);
  237. },
  238. getWechatMoney(){
  239. if (wx.canIUse('requestMerchantTransfer')) {
  240. wx.requestMerchantTransfer({
  241. mchId: this.mchId,
  242. appId: this.appId,
  243. package: this.packageInfo,
  244. success: (res) => {
  245. // res.err_msg将在页面展示成功后返回应用时返回ok,并不代表付款成功
  246. console.log(res);
  247. if (res.errMsg === 'requestMerchantTransfer:ok') {
  248. this.checkOrderStatusMounted();
  249. }
  250. },
  251. fail: (res) => {
  252. }
  253. });
  254. }
  255. }
  256. }
  257. }
  258. </script>
  259. <style>
  260. .box {
  261. min-height: 100vh;
  262. background: #F4F5F7;
  263. padding-top: 20rpx;
  264. }
  265. .tishiLine{
  266. display: flex;padding-top: 20rpx;
  267. color: #999999;
  268. }
  269. .tishiY{
  270. width: 10rpx;
  271. height: 10rpx;
  272. background: #DDDDDD;
  273. margin-top: 16rpx;
  274. border-radius: 50%;
  275. }
  276. .tishiTxt{
  277. padding-left: 18rpx;
  278. color: #999999;
  279. }
  280. .tixiancs{
  281. display: flex;
  282. justify-content: space-between;
  283. font-size: 24rpx;
  284. padding-left: 24rpx;
  285. padding-right: 24rpx;
  286. padding-bottom: 20rpx;
  287. }
  288. .tixiancsLeft{
  289. color: #999999;
  290. }
  291. .tixiancsRight{
  292. color:#596999;
  293. }
  294. .tishiTxtColor{
  295. color: #999999;
  296. }
  297. .header {
  298. background-color: #FFFFFF;
  299. margin: 0 24rpx;
  300. border-radius: 10rpx;
  301. padding: 30rpx 20rpx;
  302. }
  303. .title {
  304. font-size: 28rpx;
  305. color: #3C3C3C;
  306. }
  307. .moneyView {
  308. display: flex;
  309. justify-content: space-between;
  310. align-items: center;
  311. margin: 15rpx 0;
  312. }
  313. .icon {
  314. font-size: 50rpx;
  315. color: #222222;
  316. }
  317. .moneyInput {
  318. font-size: 70rpx;
  319. color: #222222;
  320. /* flex-grow: 1; */
  321. height: 98rpx;
  322. width: 100%;
  323. }
  324. .allBtn {
  325. font-size: 30rpx;
  326. color: #596999;
  327. width: 200rpx;
  328. height: 50rpx;
  329. line-height: 50rpx;
  330. margin-left: 10rpx;
  331. text-align: right;
  332. }
  333. .zongMoney {
  334. font-size: 25rpx;
  335. color: #999999;
  336. border-top: solid 3rpx #F4F4F4;
  337. padding-top: 25rpx;
  338. }
  339. .line {
  340. background-color: #EEEEEE;
  341. height: 1rpx;
  342. }
  343. .name {
  344. display: flex;
  345. justify-content: flex-start;
  346. padding: 28rpx 0;
  347. }
  348. .leftTitle {
  349. font-size: 30rpx;
  350. color: #3C3C3C;
  351. margin-right: 90rpx;
  352. }
  353. .Input {
  354. font-size: 30rpx;
  355. color: #333333;
  356. }
  357. .tishi {
  358. padding: 0 44rpx;
  359. font-size: 26rpx;
  360. color: #999999;
  361. line-height: 1.5;
  362. }
  363. .sureBtn {
  364. width: 690rpx;
  365. margin: 20rpx 30rpx;
  366. border-radius: 15rpx;
  367. height: 74rpx;
  368. background: #EB0F0A;
  369. color: #FFFFFF;
  370. font-size: 25rpx;
  371. text-align: center;
  372. line-height: 74rpx;
  373. }
  374. </style>