promotionExtract.vue 8.8 KB

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