GivenSir 4 år sedan
förälder
incheckning
12d0ca8f8e
9 ändrade filer med 161 tillägg och 114 borttagningar
  1. 3 2
      .env
  2. 1 1
      .env.development
  3. 14 3
      README.zh-CN.md
  4. BIN
      dist.zip
  5. 54 36
      mock/common.js
  6. 2 0
      package.json
  7. 3 3
      src/utils/request.js
  8. 77 62
      src/views/recharge/index.vue
  9. 7 7
      vue.config.js

+ 3 - 2
.env

@@ -2,6 +2,7 @@
 ENV = 'development'
 
 # base api
-VUE_APP_BASE_API = 'http://devapi.youxi9.com/'
-# VUE_APP_BASE_URL = 'http://devapi.youxi9.com/'
+VUE_APP_BASE_API = ''
+# VUE_APP_BASE_URL = 'https://api.youxi9.com/'
+VUE_APP_BASE_URL = 'http://devapi.youxi9.com/'
 VUE_APP_IMG_URL = 'https://cdn.youxi9.com/'

+ 1 - 1
.env.development

@@ -2,6 +2,6 @@
 ENV = 'development'
 
 # base api
-VUE_APP_BASE_API = 'http://devapi.youxi9.com/'
+VUE_APP_BASE_API = ''
 # VUE_APP_BASE_URL = 'http://devapi.youxi9.com/'
 VUE_APP_IMG_URL = 'https://cdn.youxi9.com/'

+ 14 - 3
README.zh-CN.md

@@ -47,7 +47,10 @@ npm run lint -- --fix
 
 更多信息请参考 [使用文档](https://panjiachen.github.io/vue-element-admin-site/zh/)
 
-Nginx 部署时设置反向代理+跨域
+## 本地部署相关介绍
+main.js 文件开启 mock 相关,即可使用 mock。
+(不用改,指示说明)打包时使用 /src/utils/request.js 使用的 .env 的 VUE_APP_BASE_URL 地址,这个就是线上的。 
+### Nginx 部署时设置反向代理+跨域
 ```config
 server
 {
@@ -87,10 +90,18 @@ server
 ## 修改记录
 ### v1.5
 > 2021.11.16
-1. [ ] 账户余额显示(个人信息里有)
+1. [x] 账户余额显示(个人信息里有)
 2. [x] 字体颜色可以看清
 3. [x] 默认选中游戏 热血江湖
 4. [x] 清除默认充值显示的账号
 5. [x] 充值时添加充值状态和计数
 6. [x] 账号为空时不能充值
-7. [ ] 本地浏览器记录历史充值记录信息
+7. [ ] 本地浏览器记录历史充值记录信息
+8. [ ] 充值账户的 textarea 显示行号,并把状态显示到这里。(非必要)
+
+### v1.6
+> 2021.11.17
+1. [x] 充值账户不判断是否是手机号,有些手机号格式比较新奇,或许还不是手机号。
+2. [x] 账户支付密码错误,停止其他数据请求(如果有500条,会提示500次问题)。
+
+

BIN
dist.zip


+ 54 - 36
mock/common.js

@@ -111,6 +111,17 @@ module.exports = [
               'lastRate': 10,
               'toRate': '自然点位39',
               'from': 1
+            },
+            {
+              'id': 4044,
+              'gid': 8261,
+              'pid': 'd65aa6d7614589bffe62456b88e98812',
+              'name': '热血江湖',
+              'yxid': '3175432',
+              'firRate': 10,
+              'lastRate': 10,
+              'toRate': '自然点位39',
+              'from': 1
             }
           ]
         }
@@ -144,45 +155,52 @@ module.exports = [
     url: '/v1/recharge/player',
     type: 'post',
     response: config => {
+      return {
+        'status': true,
+        'code': 200,
+        'time': 1637055309,
+        'message': '成功',
+        'data': []
+      }
+
       // return {
-      //   'status': true,
-      //   'code': 200,
-      //   'time': 1637055309,
-      //   'message': '成功',
-      //   'data': []
+      //   code: 35203,
+      //   status: false,
+      //   data: [],
+      //   message: '您的支付密码有误'
+      // }
+      // const math = Math.round(Math.random() * 2)
+      // var result = []
+      // switch (math) {
+      //   case 0:
+      //     result = {
+      //       'status': true,
+      //       'code': 200,
+      //       'time': 1637055309,
+      //       'message': '成功',
+      //       'data': []
+      //     }
+      //     break
+      //   case 1:
+      //     result = {
+      //       'status': false,
+      //       'code': 35203,
+      //       'time': 1637032613,
+      //       'message': '您的支付密码有误',
+      //       'data': []
+      //     }
+      //     break
+      //   case 2:
+      //     result = {
+      //       code: 401,
+      //       status: false,
+      //       data: [],
+      //       message: '操作失败'
+      //     }
+      //     break
       // }
-      const math = Math.round(Math.random() * 2)
-      var result = []
-      switch (math) {
-        case 0:
-          result = {
-            'status': true,
-            'code': 200,
-            'time': 1637055309,
-            'message': '成功',
-            'data': []
-          }
-          break
-        case 1:
-          result = {
-            'status': false,
-            'code': 35203,
-            'time': 1637032613,
-            'message': '您的支付密码有误',
-            'data': []
-          }
-          break
-        case 2:
-          result = {
-            code: 401,
-            status: false,
-            data: [],
-            message: '操作失败'
-          }
-          break
-      }
 
-      return result
+      // return result
     }
   }
 ]

+ 2 - 0
package.json

@@ -28,7 +28,9 @@
     "js-cookie": "2.2.0",
     "jsonlint": "1.6.3",
     "jszip": "3.2.1",
+    "lodash": "^4.17.21",
     "normalize.css": "7.0.0",
+    "nprogress": "^0.2.0",
     "path-to-regexp": "2.4.0",
     "pinyin": "^2.10.2",
     "screenfull": "4.2.0",

+ 3 - 3
src/utils/request.js

@@ -3,11 +3,11 @@ import { MessageBox, Message } from 'element-ui'
 import store from '@/store'
 import { getToken } from '@/utils/auth'
 
-console.log('# process.env.ENV: ', process.env.NODE_ENV, process.env.NODE_ENV === 'development' ? undefined : process.env.VUE_APP_BASE_API)
+console.log('# process.env.ENV: ', process.env.NODE_ENV, process.env.NODE_ENV === 'development' ? undefined : process.env.VUE_APP_BASE_URL)
 // create an axios instance
 const service = axios.create({
   // baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
-  baseURL: process.env.NODE_ENV === 'development' ? undefined : process.env.VUE_APP_BASE_API,
+  baseURL: process.env.NODE_ENV === 'development' ? undefined : process.env.VUE_APP_BASE_URL,
   // withCredentials: true, // send cookies when cross-domain requests
   timeout: 5000 // request timeout
 })
@@ -46,7 +46,7 @@ service.interceptors.response.use(
    */
   response => {
     const res = response.data
-    console.log('# request@response:', res)
+    console.log('# request@url&response:' + response.config.url + ':', res)
 
     // if the custom code is not 20000, it is judged as an error.
     if (res.code !== 200) {

+ 77 - 62
src/views/recharge/index.vue

@@ -38,7 +38,7 @@
           </el-form-item>
         </el-col>
 
-        <el-col :span="3">
+        <el-col :span="4">
           <el-form-item label="充值账户" prop="username" class="filter-item">
             <span style="font-size: 5px; color: #67C23A;">:{{ accountNum }}</span>
             <el-input
@@ -49,29 +49,12 @@
               @change="setAccountNum"
             />
           </el-form-item>
-
-          <!-- <el-row class="row-bg" gutter="10">
-            <el-col :span="9">
-              <span style="font-size: 5px; color: #67C23A;">贴入充值账号,一行一个账号.</span>
-            </el-col>
-            <el-col :span="6" style="margin-top: 150px;">
-              <el-button type="success" @click="confirmAccount">确认账号</el-button>
-            </el-col>
-            <el-col :span="9">
-              <span style="font-size: 5px; color: #67C23A;">账号确认成功后会显示到这里.</span>
-              <el-input
-                v-model="accountHandleSuccess"
-                type="textarea"
-                placeholder="账号检测成功."
-                :autosize="{ minRows: 10, maxRows: 30 }"
-              />
-            </el-col>
-          </el-row> -->
+          <span v-show="repeatNumList">重复账号:{{ repeatNumList }}</span>
         </el-col>
 
-        <el-col :span="3">
+        <el-col :span="5">
           <el-form-item label="账户余额">
-            <span>0元</span>
+            <span>{{ user_money }}元</span>
           </el-form-item>
           <el-form-item label="充值金额" prop="money">
             <el-input v-model="dataForm.money" type="number" min="0" class="filter-item" />
@@ -121,21 +104,24 @@
 </template>
 
 <script>
+var LodashArray = require('lodash/array')
 import { Message, MessageBox, Loading } from 'element-ui'
 import { rechargeChannelPlatformAccount } from '@/api/common'
-import { validMobile } from '@/utils/validate'
+// import { validMobile } from '@/utils/validate'
 
 export default {
   name: 'Recharge',
   data() {
     return {
       // accountHandleSuccess: '', // 处理成功账号
+      repeatNumList: [], // 重复账号
       dataForm: {
         pid: 'd65aa6d7614589bffe62456b88e98811', // 游戏平台ID;默认魅族平台
         cid: '', // 渠道账号ID
         gfid: '', // 游戏ID
         paypwd: '', // 支付密码
-        username: '13121776520\n13121776521\n13121776522\n13121776523\n13121776524\n13121776525', // 充值账户
+        // username: '13121776520\n13121776521\n13121776522\n\n13121776523\n13121776524\n13121776525', // 充值账户
+        username: '', // 充值账户
         money: 1, // 充值金额(单位:元)
         recharge: 2, //
         payway: 1, // 充值方式
@@ -160,6 +146,7 @@ export default {
         }
       ],
       // balanceMoney: 0, // 渠道余额
+      user_money: 0, // 账户余额
       rechargeChannelPlatform: [], // 渠道账号
       rechargeGame: [], // 游戏列表
 
@@ -167,28 +154,52 @@ export default {
       thenAccount: '', // 成功账户
       thenAccountNum: 0, // 成功个数
       catchAccount: '', // 失败账户
-      catchAccountNum: 0, // 失败个数
-      loadingText: '处理中,请稍等。。。',
-      loadingTextNum: 0 // 操作百分比
+      catchAccountNum: 0 // 失败个数
+      // loadingText: '处理中,请稍等。。。',
+      // loadingTextNum: 0 // 操作百分比
     }
   },
   created() {
     // this.getBalanceMoney(this.dataForm.pid)
     this.getRechargePlatform(this.dataForm.pid)
     this.getRechargeGame(this.dataForm.pid)
+    this.updateUserMoney()
   },
   methods: {
+    // 更新用户余额
+    updateUserMoney() {
+      this.$store.dispatch('user/getInfo').then((res) => {
+        const { data } = res
+        this.user_money = data.user_money
+      })
+    },
+    // 统计充值账户数量并处理行数不是账号的
     setAccountNum() {
+      if (!this.dataForm.username) {
+        return false
+      }
       this.accountNum = 0
-      const list = this.dataForm.username.split('\n')
+      this.repeatNumList = []
+      var newQuestion = this.dataForm.username.replace(/\n\n/, '\n')
+      const list = newQuestion.split('\n')
+
+      var newList = [] // 处理重复数据
       for (var i = 0; i < list.length; i++) {
-        // console.log(list[i])
-        if (validMobile(list[i])) {
+        // 账户去重,并提示
+        if (newList.indexOf(list[i]) === -1) {
           this.accountNum++
+          newList.push(list[i])
+        } else {
+          if (this.repeatNumList.indexOf(list[i]) === -1) {
+            this.repeatNumList.push(list[i])
+          }
         }
       }
+      this.dataForm.username = newList.join().replace(new RegExp(',', 'g'), '\n')
     },
     async onSubmit() {
+      // this.setAccountNum()
+
       this.thenAccount = ''
       this.catchAccount = ''
 
@@ -200,47 +211,51 @@ export default {
       //   })
       // }
       this.$refs['dataForm'].validate((valid) => {
-        console.log('# form-validate:', valid)
         if (valid) {
           // 截取数据
           var userLists = this.dataForm.username.split('\n')
 
-          // TODO: 账号重复判断、账号为空判断
-
           MessageBox.prompt('输入支付密码', 'Tip', {
             confirmButtonText: '确认',
             cancelButtonText: '取消'
           }).then(({ value }) => {
-            var successList = [] // 成功数据
-            var failList = [] // 失败数据
-
-            const loading = Loading.service({
-              lock: true,
-              text: this.loadingText,
-              background: 'rgba(0, 0, 0, 0.7)'
-            })
+            // 提取第一条账号数据,针对接口提交判断数据是否有误
+            var oneData = { pid: this.dataForm.pid, cid: this.dataForm.cid, gfid: this.dataForm.gfid, paypwd: value, username: userLists[0], money: this.dataForm.money, recharge: this.dataForm.recharge, payway: this.dataForm.payway, type: this.dataForm.type }
+            this.$store.dispatch('common/rechargePlayer', oneData).then((res) => {
+              const { code, status } = res
+              if (code === 200 && status === true) {
+                this.thenAccount = this.thenAccount + oneData.username + '\n'
+                this.thenAccountNum++
 
-            // setTimeout(() => {
-            //   loading.close()
-            // }, 2000)
+                // 遮屏
+                const loading = Loading.service({
+                  lock: true,
+                  text: '处理中, 请稍等...',
+                  background: 'rgba(0, 0, 0, 0.7)'
+                })
 
-            const loadingNum = userLists.length - 1
-            // console.log('# loadingNum:', loadingNum)
-
-            userLists.forEach(async(item, index) => {
-              // console.log('# index:', index)
-              // this.loadingText = '处理中,当前' + index
-              if (validMobile(item)) {
-                var _data = { pid: this.dataForm.pid, cid: this.dataForm.cid, gfid: this.dataForm.gfid, paypwd: value, username: item, money: this.dataForm.money, recharge: this.dataForm.recharge, payway: this.dataForm.payway, type: this.dataForm.type }
-                await this.rechargePlayer({ successList, failList }, _data, index)
-              }
-              if (loadingNum === index) {
+                // 成功后处理剩下账号数据
+                // const loadingNum = userLists.length - 1
+                console.log('# AAA:', userLists)
+                userLists = LodashArray.drop(userLists)
+                console.log('# BBBB:', userLists)
                 loading.close()
+                // userLists.forEach(async(item, index) => {
+                //   var _data = { pid: this.dataForm.pid, cid: this.dataForm.cid, gfid: this.dataForm.gfid, paypwd: value, username: item, money: this.dataForm.money, recharge: this.dataForm.recharge, payway: this.dataForm.payway, type: this.dataForm.type }
+                //   await this.rechargePlayer(_data, index)
+                //   if (loadingNum === index) {
+                //     loading.close()
+                //     this.updateUserMoney()
+                //   }
+                // })
+              } else {
+                this.catchAccount = this.catchAccount + oneData.username + '\n'
+                this.catchAccountNum++
               }
+            }).catch((res) => {
+              this.catchAccount = this.catchAccount + oneData.username + '\n'
+              this.catchAccountNum++
             })
-
-            console.log('# 成功:', successList)
-            console.log('# 失败:', failList)
           }).catch(() => {
             return Message({
               type: 'info',
@@ -256,18 +271,16 @@ export default {
       })
     },
     // 异步进行账户充值
-    rechargePlayer(request, data, index) {
+    rechargePlayer(data, index) {
       return new Promise((resolve, reject) => {
-        setTimeout((_request, _data) => {
+        setTimeout((_data) => {
           this.$store.dispatch('common/rechargePlayer', _data).then((res) => {
             const { code, status } = res
             if (code === 200 && status === true) {
-              _request.successList.push(_data.username)
               this.thenAccount = this.thenAccount + _data.username + '\n'
               this.thenAccountNum++
               resolve()
             } else {
-              _request.failList.push(_data.username)
               this.catchAccount = this.catchAccount + _data.username + '\n'
               this.catchAccountNum++
               resolve()
@@ -277,7 +290,7 @@ export default {
             this.catchAccountNum++
             resolve()
           })
-        }, 2000 * index, request, data)
+        }, 2000 * index, data)
       })
     },
 
@@ -311,6 +324,8 @@ export default {
     getRechargeGame(pid) {
       this.$store.dispatch('common/rechargeGame', pid).then((res) => {
         this.rechargeGame = res
+
+        // TODO: 判断当前账户是否有默认选项,没有则选中第一条。
         this.dataForm.gfid = 42670
       }).catch((res) => {
         return Message({

+ 7 - 7
vue.config.js

@@ -35,17 +35,17 @@ module.exports = {
     overlay: {
       warnings: true,
       errors: true
-    },
-    before: require('./mock/mock-server.js')
+    }
+    // before: require('./mock/mock-server.js'),
 
     // proxy: {
     //   [process.env.VUE_APP_BASE_API]: { // 这里是公共部分,在调用接口时后面接不相同的部分,/api就相当于http://192.168.0.199:8926/api这一段
-    //     target: process.env.VUE_APP_BASE_API, // 这里写的是访问接口的域名和端口号
+    //     target: process.env.VUE_APP_BASE_URL, // 这里写的是访问接口的域名和端口号
     //     changeOrigin: true, // 必须加上这个才能跨域请求
-    //     logLevel: 'debug',
-    //     pathRewrite: { // 重命名
-    //       ['^/' + process.env.VUE_APP_BASE_API]: ''
-    //     }
+    //     logLevel: 'debug'
+    //     // pathRewrite: { // 重命名
+    //     //   ['^/' + process.env.VUE_APP_BASE_API]: ''
+    //     // }
     //   }
     // }
   },