index.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  1. <template>
  2. <div>
  3. <el-progress
  4. v-show="progressInfo.percentageNum > 0"
  5. :text-inside="true"
  6. :stroke-width="26"
  7. :percentage="progressInfo.percentageNum"
  8. style="margin: 10px;"
  9. />
  10. <!-- v-loading="loading"
  11. element-loading-text="Loading..."
  12. element-loading-svg-view-box="-10, -10, 50, 50"
  13. element-loading-background="rgba(0, 0, 0, 0.8)" -->
  14. <el-form
  15. ref="dataForm"
  16. v-loading="formLoading"
  17. :model="dataForm"
  18. :rules="ruleForm"
  19. class="login-container"
  20. element-loading-text="处理中..."
  21. element-loading-svg-view-box="-10, -10, 50, 50"
  22. element-loading-background="rgba(0, 0, 0, 0.2)"
  23. >
  24. <el-row :gutter="30">
  25. <el-col :span="4">
  26. <el-form-item label="游戏平台" prop="pid">
  27. <el-select v-model="dataForm.pid" placeholder="Select" class="filter-item">
  28. <el-option
  29. v-for="item in rechargePlatform"
  30. :key="item.pid"
  31. :label="item.platform"
  32. :value="item.pid"
  33. />
  34. </el-select>
  35. </el-form-item>
  36. <!-- <el-form-item label="渠道余额" style="width: 300px;">
  37. <el-input v-model="balanceMoney" type="number" class="inline-input filter-item" disabled style="width: 160px;" />&nbsp;元
  38. </el-form-item> -->
  39. <el-form-item label="渠道账号" prop="cid">
  40. <el-select v-model="dataForm.cid" placeholder="Select" class="filter-item">
  41. <el-option
  42. v-for="item in rechargeChannelPlatform"
  43. :key="item.cid"
  44. :label="item.account"
  45. :value="item.cid"
  46. />
  47. </el-select>
  48. </el-form-item>
  49. <el-form-item label="选择游戏" prop="gfid">
  50. <el-select v-model="dataForm.gfid" placeholder="Select" class="filter-item">
  51. <el-option
  52. v-for="item in rechargeGame"
  53. :key="item.id"
  54. :label="item.name"
  55. :value="item.id"
  56. />
  57. </el-select>
  58. </el-form-item>
  59. <el-form-item label="账户余额">
  60. <span>{{ user_money }}元</span>
  61. </el-form-item>
  62. <el-form-item label="当前渠道余额">
  63. <span>{{ balanceMoney }}元</span>
  64. </el-form-item>
  65. </el-col>
  66. <el-col :span="3">
  67. <el-form-item label="充值账户" prop="username" class="filter-item">
  68. <span style="font-size: 5px; color: #67C23A;">:{{ accountNum }}</span>
  69. <el-input
  70. v-model="dataForm.username"
  71. type="textarea"
  72. placeholder="请输入充值账户."
  73. :autosize="{ minRows: 15, maxRows: 60 }"
  74. @change="setAccountNum"
  75. />
  76. </el-form-item>
  77. </el-col>
  78. <el-col v-show="repeatNumList" :span="3">
  79. <el-form-item label="重复账号:" class="filter-item">
  80. <span style="font-size: 5px; color: #F56C6C;">:{{ repeatNumNum }}</span>
  81. <el-input
  82. v-model="repeatNumList"
  83. type="textarea"
  84. :autosize="{ minRows: 15, maxRows: 60 }"
  85. />
  86. </el-form-item>
  87. </el-col>
  88. <el-col :span="4">
  89. <el-form-item label="充值金额" prop="money">
  90. <el-input v-model="dataForm.money" type="number" min="0" :max="maxMoney" class="filter-item" />
  91. <span style="font-size: var(--el-font-size-extra-small); color: #909399;">最大充值金额:{{ maxMoney }}</span>
  92. </el-form-item>
  93. <!-- <el-form-item label="平台折扣">
  94. <span>9.8折</span>
  95. </el-form-item>
  96. <el-form-item label="游戏折扣">
  97. <span>9.8折</span>
  98. </el-form-item> -->
  99. <el-form-item label="支付方式">
  100. <el-radio-group v-model="dataForm.payway" prop="payway" class="filter-item">
  101. <el-radio :label="1">久币支付</el-radio>
  102. <!-- <el-radio :label="2">商务币支付</el-radio> -->
  103. </el-radio-group>
  104. </el-form-item>
  105. <el-form-item label="总支付金额">
  106. <span>{{ rechargeMoney }} 元</span>
  107. </el-form-item>
  108. <el-form-item label="账号检测">
  109. <el-radio-group v-model="onCheck" prop="payway" class="filter-item">
  110. <el-switch v-model="onCheck" />
  111. </el-radio-group>
  112. </el-form-item>
  113. <el-form-item label="是否充值">
  114. <el-radio-group v-model="onRecharge" prop="onRecharge" class="filter-item">
  115. <el-switch v-model="onRecharge" />
  116. </el-radio-group>
  117. </el-form-item>
  118. <el-form-item>
  119. <el-button type="primary" @click="onSubmit()">提交</el-button>
  120. </el-form-item>
  121. </el-col>
  122. <el-col :span="9">
  123. 处理时间:<span>{{ startTime }}</span> -- <span>{{ endTime }}</span>
  124. <el-row :gutter="10">
  125. <el-col :span="8">
  126. <span style="font-size: 5px; color: #67C23A;">成功账户:{{ thenAccountNum }}</span>
  127. <el-input
  128. v-model="thenAccount"
  129. type="textarea"
  130. :autosize="{ minRows: 15, maxRows: 60 }"
  131. disabled
  132. />
  133. </el-col>
  134. <el-col :span="8">
  135. <span style="font-size: 5px; color: #F56C6C;">失败账户:{{ catchAccountNum }}</span>
  136. <el-input
  137. v-model="catchAccount"
  138. type="textarea"
  139. :autosize="{ minRows: 15, maxRows: 60 }"
  140. disabled
  141. />
  142. </el-col>
  143. <el-col :span="8">
  144. <span style="font-size: 5px; color: #F56C6C;">账户不存在:{{ noExistenceNum }}</span>
  145. <el-input
  146. v-model="noExistence"
  147. type="textarea"
  148. :autosize="{ minRows: 15, maxRows: 60 }"
  149. disabled
  150. />
  151. </el-col>
  152. </el-row>
  153. </el-col>
  154. </el-row>
  155. </el-form>
  156. </div>
  157. </template>
  158. <script>
  159. var LodashArray = require('lodash/array')
  160. import { Message, MessageBox, Loading } from 'element-ui'
  161. import { rechargeChannelPlatformAccount } from '@/api/common'
  162. export default {
  163. name: 'Recharge',
  164. data() {
  165. return {
  166. formLoading: false, // 表单记载状态
  167. dataForm: {
  168. pid: 'd65aa6d7614589bffe62456b88e98811', // 游戏平台ID;默认魅族平台
  169. cid: '', // 渠道账号ID
  170. gfid: '', // 游戏ID
  171. paypwd: '', // 支付密码
  172. username: '', // 充值账户
  173. money: 1, // 充值金额(单位:元)
  174. recharge: 2, //
  175. payway: 1, // 充值方式
  176. type: 3 //
  177. },
  178. ruleForm: {
  179. pid: [{ required: true, message: '请选择平台.', trigger: 'change' }],
  180. cid: [{ required: true, message: '请选择渠道账号.', trigger: 'change' }],
  181. gfid: [{ required: true, message: '请选择游戏.', trigger: 'change' }],
  182. username: [{ required: true, message: '缺少充值账户.', trigger: 'blur' }],
  183. money: [{ required: true, message: '请输入充值金额,最低一元.', trigger: 'blur' }]
  184. },
  185. // 游戏平台列表
  186. rechargePlatform: [
  187. {
  188. 'pid': 'd65aa6d7614589bffe62456b88e98811',
  189. 'platform': 'MM',
  190. 'disRate': 9.8,
  191. 'rate': 9.7,
  192. 'type': 0,
  193. 'length': 2
  194. }
  195. ],
  196. balanceMoney: 0, // 渠道余额
  197. user_money: 0, // 账户余额
  198. maxMoney: 0, // 最大充值金额
  199. rechargeChannelPlatform: [], // 渠道账号
  200. rechargeGame: [], // 游戏列表
  201. accountNum: 0, // 总账户个数
  202. repeatNumList: '', // 重复账号列表
  203. repeatNumNum: 0, // 重复账号个数
  204. thenAccount: '', // 成功账户
  205. thenAccountNum: 0, // 成功个数
  206. catchAccount: '', // 失败账户
  207. catchAccountNum: 0, // 失败个数
  208. noExistence: '', // 不存在账户
  209. noExistenceNum: 0, // 不存在账户个数
  210. startTime: 0, // 开始时间
  211. endTime: 0, // 结束时间
  212. onCheck: false, // 是否需要检测账号
  213. onRecharge: true, // 是否充值
  214. rechargeMoney: 0, // 支付总金额
  215. progressInfo: {
  216. percentageNum: 0, // 进度条百分比
  217. num: 0 // 当前数
  218. }
  219. }
  220. },
  221. watch: {
  222. 'dataForm.money': {
  223. handler(val, oldVal) {
  224. this.checkMoney(val)
  225. }
  226. }
  227. },
  228. created() {
  229. this.getRechargePlatform(this.dataForm.pid)
  230. this.getRechargeGame(this.dataForm.pid)
  231. // this.updateUserMoney()
  232. this.updateMoney()
  233. this.$store.dispatch('user/getF5').then((res) => {
  234. if (!res) {
  235. this.$store.dispatch('user/setF5')
  236. location.reload()
  237. }
  238. })
  239. },
  240. methods: {
  241. // 判断充值金额
  242. checkMoney(money) {
  243. this.rechargeMoney = this.accountNum * money
  244. if ((this.balanceMoney - this.rechargeMoney) < 0) {
  245. // this.rechargeMoney = this.accountNum * oldVal
  246. return Message({
  247. type: 'warning',
  248. message: '渠道余额不足以充值!'
  249. })
  250. }
  251. },
  252. // 更新用户余额
  253. updateUserMoney() {
  254. this.$store.dispatch('user/getInfo').then((res) => {
  255. const { data } = res
  256. this.user_money = Math.floor(data.user_money)
  257. return Message({
  258. type: 'success',
  259. message: '账户余额已更新'
  260. })
  261. })
  262. },
  263. // 统计充值账户数量并处理行数是否账号
  264. setAccountNum() {
  265. if (!this.dataForm.username) {
  266. return false
  267. }
  268. this.accountNum = 0
  269. this.repeatNumList = []
  270. this.repeatNumNum = 0
  271. var newQuestion = this.dataForm.username.replace(/\n\n/, '\n')
  272. const list = newQuestion.split('\n')
  273. var newList = []
  274. for (var i = 0; i < list.length; i++) {
  275. if (list[i] === '') {
  276. continue
  277. }
  278. // 账户去重,并提示
  279. if (newList.indexOf(list[i]) === -1) {
  280. this.accountNum++
  281. newList.push(list[i])
  282. } else {
  283. if (this.repeatNumList.indexOf(list[i]) === -1) {
  284. this.repeatNumNum++
  285. this.repeatNumList.push(list[i])
  286. }
  287. }
  288. }
  289. this.repeatNumList = this.repeatNumList.join().replace(new RegExp(',', 'g'), '\n')
  290. this.dataForm.username = newList.join().replace(new RegExp(',', 'g'), '\n')
  291. this.rechargeMoney = this.accountNum * this.dataForm.money
  292. this.maxMoney = Math.floor(this.balanceMoney / this.accountNum)
  293. },
  294. /**
  295. * 发起提交 游戏账号检测/提交充值 数据
  296. */
  297. onSubmit() {
  298. this.startLoading()
  299. // this.formLoading = true
  300. // this.setAccountNum()
  301. this.thenAccount = '' // 渠道余额
  302. this.thenAccountNum = 0 // 成功个数
  303. this.catchAccount = '' // 失败账户
  304. this.catchAccountNum = 0 // 失败个数
  305. this.noExistence = '' // 不存在账户
  306. this.noExistenceNum = 0 // 不存在账户个数
  307. this.startTime = ''
  308. this.endTime = ''
  309. this.progressInfo.percentageNum = 0 // 进度条百分比
  310. this.progressInfo.num = 0 // 进度条百分比
  311. // TODO: 正式服务器未上线,暂时不需要
  312. // if ((this.balanceMoney - this.dataForm.money) < 0) {
  313. // return Message({
  314. // type: 'info',
  315. // message: '余额不足以充值.'
  316. // })
  317. // }
  318. if (this.onCheck === false && this.onRecharge === false) {
  319. return Message({
  320. type: 'warning',
  321. message: '请选择是否检测或充值!'
  322. })
  323. }
  324. this.operation('time_start')
  325. // 截取账号
  326. var accountLists = this.dataForm.username.split('\n')
  327. // 检测不充值
  328. if (this.onCheck === true && this.onRecharge === false) {
  329. // this.startLoading()
  330. // this.formLoading = true
  331. this.sublmeRecharge(accountLists, 1)
  332. return false
  333. }
  334. // 需要充值则检测余额
  335. if ((this.balanceMoney - this.rechargeMoney) < 0) {
  336. // this.formLoading = false
  337. this.cloneLoading()
  338. return Message({
  339. type: 'warning',
  340. message: '账户余额不足以充值!'
  341. })
  342. }
  343. this.$refs['dataForm'].validate((valid) => {
  344. if (valid) {
  345. MessageBox.prompt('输入支付密码', 'Tip', {
  346. confirmButtonText: '确认',
  347. cancelButtonText: '取消'
  348. }).then(({ value }) => {
  349. // this.startLoading()
  350. if (this.onRecharge === true && this.onCheck === false) { // 充值不检测
  351. this.sublmeRecharge(accountLists, 2, value)
  352. } else if (this.onRecharge === true && this.onCheck === true) { // 充值并检测
  353. this.sublmeRecharge(accountLists, 3, value)
  354. }
  355. }).catch(() => {
  356. this.cloneLoading()
  357. // this.formLoading = false
  358. return Message({
  359. message: '取消充值.'
  360. })
  361. })
  362. } else {
  363. this.cloneLoading()
  364. // this.formLoading = false
  365. return Message({
  366. type: 'error',
  367. message: '请完善提交内容.'
  368. })
  369. }
  370. })
  371. },
  372. // 提交检测和充值
  373. async sublmeRecharge(accountLists, operationType, paypwd = '') {
  374. // this.startTime = new Date().getHours() + ':' + new Date().getMinutes() + ':' + new Date().getSeconds()
  375. // 提取第一条账号数据,进行提交测试
  376. const oneAccount = accountLists[0]
  377. const loadingNum = accountLists.length - 2
  378. this.progressInfo.num++
  379. switch (operationType) {
  380. case 1: // 账号检测
  381. await this.$store.dispatch('common/rechargePlayerType', { pid: this.dataForm.pid, cid: this.dataForm.cid, gfid: this.dataForm.gfid, username: oneAccount }).then((res) => {
  382. const { code, status, message } = res
  383. if (code === 200 && status === true) {
  384. this.thenAccount = this.thenAccount + oneAccount + '\n'
  385. this.thenAccountNum++
  386. // Message({
  387. // type: 'success',
  388. // message: '检测成功 ' + oneAccount + ' : ' + message
  389. // })
  390. this.$notify({
  391. title: '检测成功',
  392. message: oneAccount + ' : ' + message,
  393. type: 'success'
  394. })
  395. // 成功后处理剩下账号数据
  396. accountLists = LodashArray.drop(accountLists) // 删除第一个账户
  397. if (accountLists.length <= 0) {
  398. this.cloneLoading()
  399. return false
  400. }
  401. accountLists.forEach(async(item, index) => {
  402. await this.rechargePlayer(
  403. { pid: this.dataForm.pid, cid: this.dataForm.cid, gfid: this.dataForm.gfid, paypwd: paypwd, username: item, money: this.dataForm.money, recharge: this.dataForm.recharge, type: this.dataForm.type },
  404. index, operationType, loadingNum
  405. )
  406. })
  407. } else {
  408. this.noExistence = this.noExistence + oneAccount + '\n'
  409. this.noExistenceNum++
  410. // this.cloneLoading(false)
  411. // this.formLoading = false
  412. this.cloneLoading()
  413. // return Message({
  414. // message: '检测 ' + oneAccount + ' : ' + message
  415. // })
  416. return this.$notify({
  417. title: '检测有误',
  418. message: oneAccount + ' : ' + message,
  419. type: 'info'
  420. })
  421. }
  422. }).catch((error) => {
  423. this.catchAccount = this.catchAccount + oneAccount + '\n'
  424. this.catchAccountNum++
  425. // this.cloneLoading(false)
  426. // this.formLoading = false
  427. this.cloneLoading()
  428. // return Message({
  429. // type: 'error',
  430. // message: '检测失败 ' + oneAccount + ' :' + error.message
  431. // })
  432. return this.$notify({
  433. title: '检测失败',
  434. message: oneAccount + ' : ' + error.message,
  435. type: 'error'
  436. })
  437. })
  438. break
  439. case 2: // 充值
  440. this.$store.dispatch('common/rechargePlayer', { pid: this.dataForm.pid, cid: this.dataForm.cid, gfid: this.dataForm.gfid, paypwd: paypwd, username: oneAccount, money: this.dataForm.money, recharge: this.dataForm.recharge, payway: this.dataForm.payway, type: this.dataForm.type }).then((res) => {
  441. const { code, status, message } = res
  442. if (code === 200 && status === true) {
  443. this.thenAccount = this.thenAccount + oneAccount + '\n'
  444. this.thenAccountNum++
  445. // Message({
  446. // type: 'success',
  447. // message: '充值成功 ' + oneAccount + ' : ' + message
  448. // })
  449. this.$notify({
  450. title: '充值成功',
  451. message: oneAccount + ' : ' + message,
  452. type: 'success'
  453. })
  454. // 成功后处理剩下账号数据
  455. accountLists = LodashArray.drop(accountLists) // 删除第一个账户
  456. console.log('# 充值 -- 账户列表:', accountLists)
  457. if (accountLists && accountLists.length > 0) {
  458. accountLists.forEach(async(item, index) => {
  459. await this.rechargePlayer(
  460. { pid: this.dataForm.pid, cid: this.dataForm.cid, gfid: this.dataForm.gfid, paypwd: paypwd, username: item, money: this.dataForm.money, recharge: this.dataForm.recharge, payway: this.dataForm.payway, type: this.dataForm.type },
  461. index, operationType, loadingNum
  462. )
  463. })
  464. } else {
  465. this.cloneLoading()
  466. this.operation('time_end')
  467. }
  468. } else {
  469. this.catchAccount = this.catchAccount + oneAccount + '\n'
  470. this.catchAccountNum++
  471. // this.formLoading = false
  472. this.cloneLoading()
  473. this.operation('time_end')
  474. // return Message({
  475. // message: '充值 ' + oneAccount + ' : ' + message
  476. // })
  477. return this.$notify({
  478. title: '充值有误',
  479. message: oneAccount + ' : ' + message,
  480. type: 'info'
  481. })
  482. }
  483. }).catch((error) => {
  484. this.catchAccount = this.catchAccount + oneAccount + '\n'
  485. this.catchAccountNum++
  486. // this.formLoading = false
  487. this.cloneLoading()
  488. this.operation('time_end')
  489. // return Message({
  490. // type: 'error',
  491. // message: '充值失败 ' + oneAccount + ' : ' + error.message
  492. // })
  493. return this.$notify({
  494. title: '充值失败',
  495. message: oneAccount + ' : ' + error.message,
  496. type: 'error'
  497. })
  498. })
  499. break
  500. case 3: // 充值并检测
  501. // 账号检测
  502. this.$store.dispatch('common/rechargePlayerType', { pid: this.dataForm.pid, cid: this.dataForm.cid, gfid: this.dataForm.gfid, username: oneAccount }).then((res) => {
  503. const { code, status, message } = res
  504. if (code === 200 && status === true) {
  505. // Message({
  506. // type: 'success',
  507. // message: '检测成功 ' + oneAccount + ' : ' + message
  508. // })
  509. this.$notify({
  510. title: '检测成功',
  511. message: oneAccount + ' : ' + message,
  512. type: 'success'
  513. })
  514. // 充值
  515. this.$store.dispatch('common/rechargePlayer', { pid: this.dataForm.pid, cid: this.dataForm.cid, gfid: this.dataForm.gfid, paypwd: paypwd, username: oneAccount, money: this.dataForm.money, recharge: this.dataForm.recharge, payway: this.dataForm.payway, type: this.dataForm.type }).then((res) => {
  516. const { code, status, message } = res
  517. if (code === 200 && status === true) {
  518. this.thenAccount = this.thenAccount + oneAccount + '\n'
  519. this.thenAccountNum++
  520. // Message({
  521. // type: 'success',
  522. // message: '充值成功 ' + oneAccount + ' : ' + message
  523. // })
  524. this.$notify({
  525. title: '充值成功',
  526. message: oneAccount + ' : ' + message,
  527. type: 'success'
  528. })
  529. // 成功后处理剩下账号数据
  530. accountLists = LodashArray.drop(accountLists) // 删除第一个账户
  531. if (accountLists && accountLists.length > 0) {
  532. accountLists.forEach(async(item, index) => {
  533. await this.rechargePlayer(
  534. { pid: this.dataForm.pid, cid: this.dataForm.cid, gfid: this.dataForm.gfid, paypwd: paypwd, username: item, money: this.dataForm.money, recharge: this.dataForm.recharge, payway: this.dataForm.payway, type: this.dataForm.type },
  535. index, operationType, loadingNum
  536. )
  537. })
  538. } else {
  539. this.cloneLoading()
  540. this.operation('time_end')
  541. }
  542. } else {
  543. this.catchAccount = this.catchAccount + oneAccount + '\n'
  544. this.catchAccountNum++
  545. // this.formLoading = false
  546. this.cloneLoading()
  547. this.operation('time_end')
  548. // return Message({
  549. // type: 'warning',
  550. // message: '充值 ' + oneAccount + ' : ' + message
  551. // })
  552. return this.$notify({
  553. title: '充值有误',
  554. message: oneAccount + ' : ' + message,
  555. type: 'info'
  556. })
  557. }
  558. }).catch((error) => {
  559. this.catchAccount = this.catchAccount + oneAccount + '\n'
  560. this.catchAccountNum++
  561. // this.formLoading = false
  562. this.cloneLoading()
  563. this.operation('time_end')
  564. // return Message({
  565. // type: 'error',
  566. // message: '充值失败 ' + oneAccount + ' : ' + error.message
  567. // })
  568. return this.$notify({
  569. title: '充值失败',
  570. message: oneAccount + ' : ' + error.message,
  571. type: 'error'
  572. })
  573. })
  574. } else {
  575. this.noExistence = this.noExistence + oneAccount + '\n'
  576. this.noExistenceNum++
  577. // this.formLoading = false
  578. this.cloneLoading()
  579. this.operation('time_end')
  580. // return Message({
  581. // message: '检测 ' + oneAccount + ' : ' + message
  582. // })
  583. return this.$notify({
  584. title: '检测失败',
  585. message: oneAccount + ' : ' + message,
  586. type: 'error'
  587. })
  588. }
  589. }).catch((error) => {
  590. this.catchAccount = this.catchAccount + oneAccount + '\n'
  591. this.catchAccountNum++
  592. // this.formLoading = false
  593. this.cloneLoading()
  594. this.operation('time_end')
  595. // return Message({
  596. // type: 'error',
  597. // message: '检测失败 ' + oneAccount + ' : ' + error.message
  598. // })
  599. return this.$notify({
  600. title: '检测失败',
  601. message: oneAccount + ' : ' + error.message,
  602. type: 'error'
  603. })
  604. })
  605. break
  606. default:
  607. this.$notify({
  608. title: '操作有误',
  609. message: '非法操作!',
  610. type: 'error'
  611. })
  612. this.cloneLoading()
  613. this.operation('time_end')
  614. break
  615. }
  616. // // ## 测试(去除第一个账户单独测试)
  617. // // 是否需要验证账户
  618. // const loadingNum = accountLists.length - 1
  619. // // 遮屏
  620. // this.loading = Loading.service({
  621. // lock: true,
  622. // text: '处理中, 请稍等...',
  623. // background: 'rgba(0, 0, 0, 0.7)'
  624. // })
  625. // // 成功后处理剩下账号数据
  626. // accountLists.forEach(async(item, index) => {
  627. // await this.rechargePlayer(
  628. // { pid: this.dataForm.pid, cid: this.dataForm.cid, gfid: this.dataForm.gfid, paypwd: paypwd, username: item, money: this.dataForm.money, recharge: this.dataForm.recharge, type: this.dataForm.type },
  629. // index,
  630. // this.onCheck,
  631. // loadingNum
  632. // )
  633. // })
  634. },
  635. // 启动遮屏
  636. startLoading() {
  637. this.loading = Loading.service({
  638. lock: true,
  639. text: '处理中, 请稍等...',
  640. background: 'rgba(0, 0, 0, 0.3)'
  641. })
  642. },
  643. // 关闭遮屏
  644. cloneLoading(onMoney = true) {
  645. this.loading.close()
  646. },
  647. // 更新账户余额和渠道余额
  648. updateMoney() {
  649. this.updateUserMoney()
  650. this.getBalanceMoney()
  651. },
  652. // 相关操作
  653. operation(type) {
  654. switch (type) {
  655. case 'loading_clone': // 关闭加载窗口
  656. this.formLoading = false
  657. break
  658. case 'time_start': // 开始时间
  659. this.startTime = new Date().getHours() + ':' + new Date().getMinutes() + ':' + new Date().getSeconds()
  660. break
  661. case 'time_end': // 结束时间
  662. this.endTime = new Date().getHours() + ':' + new Date().getMinutes() + ':' + new Date().getSeconds()
  663. break
  664. default:
  665. break
  666. }
  667. },
  668. // 异步进行账户检测与充值
  669. rechargePlayer(data, index, operationType, count) {
  670. const that = this
  671. // 延迟一秒处理
  672. setTimeout((data, new_index, new_operationType, new_count, that) => {
  673. return new Promise((resolve, reject) => {
  674. // 继续延迟
  675. setTimeout((_data, _index, _operationType, _count) => {
  676. that.progressInfo.num++
  677. that.progressCheck()
  678. switch (_operationType) {
  679. case 1: // 检测账户
  680. this.$store.dispatch('common/rechargePlayerType', { pid: _data.pid, cid: _data.cid, gfid: _data.gfid, username: _data.username }).then((res) => {
  681. const { code, status, message } = res
  682. if (code === 200 && status === true) {
  683. this.thenAccount = this.thenAccount + _data.username + '\n'
  684. this.thenAccountNum++
  685. // Message({
  686. // type: 'success',
  687. // message: '检测成功 ' + _data.username + ' :' + message
  688. // })
  689. this.$notify({
  690. title: '检测成功',
  691. message: _data.username + ' :' + message,
  692. type: 'success'
  693. })
  694. } else {
  695. if (code === 10001) {
  696. this.catchAccount = this.catchAccount + _data.username + '\n'
  697. this.catchAccountNum++
  698. } else {
  699. this.noExistence = this.noExistence + _data.username + '\n'
  700. this.noExistenceNum++
  701. }
  702. // Message({
  703. // message: '检测 ' + _data.username + ' :' + message
  704. // })
  705. this.$notify({
  706. title: '检测失败',
  707. message: _data.username + ' :' + message,
  708. type: 'info'
  709. })
  710. }
  711. }).catch((error) => {
  712. this.catchAccount = this.catchAccount + _data.username + '\n'
  713. this.catchAccountNum++
  714. // Message({
  715. // type: 'error',
  716. // message: '检测失败 ' + _data.username + ' :' + error.message
  717. // })
  718. this.$notify({
  719. title: '检测失败',
  720. message: _data.username + ' :' + error.message,
  721. type: 'error'
  722. })
  723. })
  724. break
  725. case 2: // 充值账户
  726. // 充值
  727. console.log('# 充值: ', _data)
  728. this.$store.dispatch('common/rechargePlayer', _data).then((res) => {
  729. const { code, status, message } = res
  730. if (code === 200 && status === true) {
  731. this.thenAccount = this.thenAccount + _data.username + '\n'
  732. this.thenAccountNum++
  733. // Message({
  734. // type: 'success',
  735. // message: '充值成功 ' + _data.username + ':' + message
  736. // })
  737. this.$notify({
  738. title: '充值成功',
  739. message: _data.username + ' :' + message,
  740. type: 'success'
  741. })
  742. } else {
  743. this.catchAccount = this.catchAccount + _data.username + '\n'
  744. this.catchAccountNum++
  745. // Message({
  746. // message: '充值 ' + _data.username + ':' + message
  747. // })
  748. this.$notify({
  749. title: '充值失败',
  750. message: _data.username + ':' + message,
  751. type: 'info'
  752. })
  753. }
  754. }).catch((error) => {
  755. this.catchAccount = this.catchAccount + _data.username + '\n'
  756. this.catchAccountNum++
  757. // Message({
  758. // type: 'error',
  759. // message: '充值失败 ' + _data.username + ':' + error.message
  760. // })
  761. this.$notify({
  762. title: '充值失败',
  763. message: _data.username + ':' + error.message,
  764. type: 'error'
  765. })
  766. })
  767. break
  768. case 3: // 检测并充值
  769. // 账号检测
  770. this.$store.dispatch('common/rechargePlayerType', { pid: _data.pid, cid: _data.cid, gfid: _data.gfid, username: _data.username }).then((res) => {
  771. const { code, status, message } = res
  772. if (code === 200 && status === true) {
  773. // Message({
  774. // type: 'success',
  775. // message: '检测成功 ' + _data.username + ':' + message
  776. // })
  777. this.$notify({
  778. title: '检测成功',
  779. message: _data.username + ':' + message,
  780. type: 'success'
  781. })
  782. // 充值
  783. this.$store.dispatch('common/rechargePlayer', _data).then((res) => {
  784. const { code, status, message } = res
  785. if (code === 200 && status === true) {
  786. this.thenAccount = this.thenAccount + _data.username + '\n'
  787. this.thenAccountNum++
  788. // Message({
  789. // type: 'success',
  790. // message: '充值成功 ' + _data.username + ':' + message
  791. // })
  792. this.$notify({
  793. title: '充值成功',
  794. message: _data.username + ' :' + message,
  795. type: 'success'
  796. })
  797. } else {
  798. this.catchAccount = this.catchAccount + _data.username + '\n'
  799. this.catchAccountNum++
  800. // Message({
  801. // message: '充值 ' + _data.username + ':' + message
  802. // })
  803. this.$notify({
  804. title: '充值有误',
  805. message: _data.username + ' :' + message,
  806. type: 'info'
  807. })
  808. }
  809. }).catch((error) => {
  810. this.catchAccount = this.catchAccount + _data.username + '\n'
  811. this.catchAccountNum++
  812. // Message({
  813. // type: 'error',
  814. // message: '充值失败 ' + _data.username + ':' + error.message
  815. // })
  816. this.$notify({
  817. title: '充值失败',
  818. message: _data.username + ' :' + error.message,
  819. type: 'error'
  820. })
  821. })
  822. } else {
  823. if (code === 10001) {
  824. this.catchAccount = this.catchAccount + _data.username + '\n'
  825. this.catchAccountNum++
  826. } else {
  827. this.noExistence = this.noExistence + _data.username + '\n'
  828. this.noExistenceNum++
  829. }
  830. // Message({
  831. // message: '检测 ' + _data.username + ':' + message
  832. // })
  833. this.$notify({
  834. title: '检测有误',
  835. message: _data.username + ' :' + message,
  836. type: 'info'
  837. })
  838. }
  839. }).catch((error) => {
  840. this.catchAccount = this.catchAccount + _data.username + '\n'
  841. this.catchAccountNum++
  842. // Message({
  843. // type: 'error',
  844. // message: '检测失败 ' + _data.username + ':' + error.message
  845. // })
  846. this.$notify({
  847. title: '检测失败',
  848. message: _data.username + ' :' + error.message,
  849. type: 'error'
  850. })
  851. })
  852. break
  853. default:
  854. break
  855. }
  856. if (_index !== null && _index === _count || _index > _count) {
  857. setTimeout(() => {
  858. // 检测不更新账户余额
  859. // var onMoney = true
  860. // this.formLoading = false
  861. this.cloneLoading()
  862. this.operation('time_end')
  863. if (new_operationType === 1) {
  864. // onMoney = false
  865. this.updateUserMoney()
  866. }
  867. // this.cloneLoading(onMoney)
  868. }, 1500)
  869. }
  870. resolve()
  871. }, 1800 * (index + 1), data, new_index, new_operationType, new_count)
  872. // }, (1600 + Math.round(Math.random() * 300)) * (index + 1), data, onCheck)
  873. // 1500 * (index + 1): +1的原因是,这里是从第二条数据开始处理的,异步处理之前单独处理了一个,所以时间久点。
  874. })
  875. }, 1000, data, index, operationType, count, that)
  876. },
  877. // 渠道账号列表
  878. getRechargePlatform(val) {
  879. rechargeChannelPlatformAccount(val).then(response => {
  880. // console.log('# getRechargePlatform:', response)
  881. this.rechargeChannelPlatform = response.data.data
  882. this.dataForm.cid = response.data.data[0]['cid']
  883. }).catch(res => {
  884. return Message({
  885. message: res,
  886. type: 'error',
  887. duration: 5 * 1000
  888. })
  889. })
  890. },
  891. // 游戏列表
  892. getRechargeGame(pid) {
  893. this.$store.dispatch('common/rechargeGame', pid).then((res) => {
  894. this.rechargeGame = res
  895. // 设置默认游戏
  896. if (res.find(item => item.id === 54252)) {
  897. this.dataForm.gfid = 54252
  898. }
  899. }).catch((res) => {
  900. return Message({
  901. message: res,
  902. type: 'error',
  903. duration: 5 * 1000
  904. })
  905. })
  906. },
  907. // 账户余额 -- 弃用
  908. getBalanceMoney() {
  909. this.$store.dispatch('common/getMainChannelMoney', this.dataForm.pid).then((res) => {
  910. this.balanceMoney = res
  911. if (this.accountNum > 0) {
  912. this.maxMoney = Math.floor(res / this.accountNum)
  913. } else {
  914. this.maxMoney = Math.floor(res)
  915. }
  916. return Message({
  917. type: 'success',
  918. message: '渠道余额已更新'
  919. })
  920. }).catch((res) => {
  921. return Message({
  922. message: res,
  923. type: 'error',
  924. duration: 5 * 1000
  925. })
  926. })
  927. },
  928. // 进度条统计
  929. progressCheck() {
  930. this.progressInfo.percentageNum = parseInt((this.progressInfo.num / this.accountNum) * 100)
  931. console.log('# progressCheck: ', this.progressInfo.num, this.accountNum, this.progressInfo.percentageNum)
  932. }
  933. }
  934. }
  935. </script>
  936. <style lang="scss">
  937. .login-container{
  938. margin: 20px;
  939. background-color: #FFFFFF;
  940. .el-bg-border{
  941. border: 2px dashed #909399;
  942. padding: 10px;
  943. }
  944. }
  945. </style>