GivenSir пре 4 година
родитељ
комит
3926a4790e
6 измењених фајлова са 162 додато и 120 уклоњено
  1. 4 6
      README.zh-CN.md
  2. 41 41
      mock/common.js
  3. 3 5
      src/store/modules/user.js
  4. 12 21
      src/utils/request.js
  5. 24 7
      src/views/login/index.vue
  6. 78 40
      src/views/recharge/index.vue

+ 4 - 6
README.zh-CN.md

@@ -4,16 +4,13 @@
 ```bash
 # 启动服务
 npm run dev
+
+# 构建生产环境 -- 本地目录会生成 dist 打包文件
+npm run build:prod
 ```
 
 浏览器访问 http://localhost:9527
 
-## 发布
-
-```bash
-# 构建生产环境 -- 打包
-npm run build:prod
-```
 ## 本地部署相关介绍
 main.js 文件默认开启 mock ,请求数据为 mock;正式打包时可以注释。
 ![image.png](https://i.loli.net/2021/11/18/AIqoErjRHKgD1f2.png)
@@ -75,5 +72,6 @@ server
 3. [x] 登录时的验证码不显示浏览器输入记录。 
 4. [x] 修复首页首次进入加载样式异常问题。
 5. [x] 账户提交失败统计展示完善。 
+6. [x] 添加显示 处理开始和结束时间。
 
 

+ 41 - 41
mock/common.js

@@ -156,13 +156,13 @@ 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': []
+      }
 
       // return {
       //   code: 35203,
@@ -170,41 +170,41 @@ module.exports = [
       //   data: [],
       //   message: '您的支付密码有误'
       // }
-      const math = Math.round(Math.random() * 3)
-      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
-        case 3:
-          result = { 'status': false, 'code': 10007, 'time': 1637213822, 'message': '发放Flyme账户不存在,请确认', 'data': [] }
-          break
-      }
 
-      return result
+      // const math = Math.round(Math.random() * 3)
+      // 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
+      //   case 3:
+      //     result = { 'status': false, 'code': 10007, 'time': 1637213822, 'message': '发放Flyme账户不存在,请确认', 'data': [] }
+      //     break
+      // }
+      // return result
     }
   }
 ]

+ 3 - 5
src/store/modules/user.js

@@ -50,11 +50,9 @@ const actions = {
       // resolve()
 
       login({ tel: mobile, code: smsCode }).then(response => {
-        const { data } = response
-
-        commit('SET_TOKEN', data.data)
-        setToken(data.data)
-        resolve()
+        commit('SET_TOKEN', response.data.data)
+        setToken(response.data.data)
+        resolve(response)
       }).catch(error => {
         reject(error)
       })

+ 12 - 21
src/utils/request.js

@@ -48,35 +48,26 @@ service.interceptors.response.use(
     const res = response.data
     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) {
-      var type = 'type'
-      if (res.code > 10000) {
-        type = 'warning'
-      }
+    if (res.code === 11010) {
       Message({
         message: res.message || 'Error',
-        type: type,
+        type: 'error',
         duration: 5 * 1000
       })
 
-      // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired;
-      if (res.code === 11010) {
-        // to re-login
-        MessageBox.confirm('登录已失效.', 'Confirm logout', {
-          confirmButtonText: 'Re-Login',
-          cancelButtonText: 'Cancel',
-          type: 'warning'
-        }).then(() => {
-          store.dispatch('user/resetToken').then(() => {
-            location.reload()
-          })
+      // to re-login
+      MessageBox.confirm('登录已失效.', 'Confirm logout', {
+        confirmButtonText: 'Re-Login',
+        cancelButtonText: 'Cancel',
+        type: 'warning'
+      }).then(() => {
+        store.dispatch('user/resetToken').then(() => {
+          location.reload()
         })
-      }
+      })
       return Promise.reject(new Error(res.message || 'Error'))
-    } else {
-      return res
     }
+    return res
   },
   error => {
     console.log('err' + error) // for debug

+ 24 - 7
src/views/login/index.vue

@@ -137,23 +137,40 @@ export default {
             clearInterval(this.timer)
           }
         }, 1000)
-      }).catch(() => {})
+      }).catch((error) => {
+        return Message({
+          message: error.message,
+          type: 'error',
+          duration: 5 * 1000
+        })
+      })
     },
     // 登录
     handleLogin() {
       this.$refs.loginForm.validate((valid) => {
         if (valid) {
           this.loading = true
-          this.$store.dispatch('user/login', this.loginForm).then(() => {
-            // console.log('# then:')
-            this.$router.push({ path: this.redirect || '/', query: this.otherQuery })
+          this.$store.dispatch('user/login', this.loginForm).then((res) => {
+            const { code, message } = res
+            if (code === 200) {
+              this.$router.push({ path: this.redirect || '/', query: this.otherQuery })
+            } else {
+              Message({
+                message: message,
+                type: 'error',
+                duration: 5 * 1000
+              })
+            }
             this.loading = false
-          }).catch((res) => {
-            // console.log('# res:', res)
+          }).catch((error) => {
             this.loading = false
+            return Message({
+              message: error.message,
+              type: 'error',
+              duration: 5 * 1000
+            })
           })
         } else {
-          // console.log('# if-error:')
           return Message({
             message: '请完善登录信息.',
             type: 'error',

+ 78 - 40
src/views/recharge/index.vue

@@ -45,7 +45,7 @@
               v-model="dataForm.username"
               type="textarea"
               placeholder="请输入充值账户."
-              :autosize="{ minRows: 15, maxRows: 100 }"
+              :autosize="{ minRows: 15, maxRows: 60 }"
               @change="setAccountNum"
             />
           </el-form-item>
@@ -57,7 +57,7 @@
             <el-input
               v-model="repeatNumList"
               type="textarea"
-              :autosize="{ minRows: 15, maxRows: 100 }"
+              :autosize="{ minRows: 15, maxRows: 60 }"
             />
           </el-form-item>
         </el-col>
@@ -89,13 +89,14 @@
           </el-form-item>
         </el-col>
         <el-col :span="6">
+          处理时间:<span>{{ startTime }}</span>  -- <span>{{ endTime }}</span>
           <el-row :gutter="30">
             <el-col :span="12">
               <span style="font-size: 5px; color: #67C23A;">成功账户:{{ thenAccountNum }}</span>
               <el-input
                 v-model="thenAccount"
                 type="textarea"
-                :autosize="{ minRows: 15, maxRows: 100 }"
+                :autosize="{ minRows: 15, maxRows: 60 }"
               />
             </el-col>
             <el-col :span="12">
@@ -103,7 +104,7 @@
               <el-input
                 v-model="catchAccount"
                 type="textarea"
-                :autosize="{ minRows: 15, maxRows: 100 }"
+                :autosize="{ minRows: 15, maxRows: 60 }"
               />
             </el-col>
           </el-row>
@@ -117,19 +118,16 @@
 var LodashArray = require('lodash/array')
 import { Message, MessageBox, Loading } from 'element-ui'
 import { rechargeChannelPlatformAccount } from '@/api/common'
-// import { validMobile } from '@/utils/validate'
 
 export default {
   name: 'Recharge',
   data() {
     return {
-      // accountHandleSuccess: '', // 处理成功账号
       dataForm: {
         pid: 'd65aa6d7614589bffe62456b88e98811', // 游戏平台ID;默认魅族平台
         cid: '', // 渠道账号ID
         gfid: '', // 游戏ID
         paypwd: '', // 支付密码
-        // username: '13121776520\n13121776521\n13121776522\n\n13121776523\n13121776524\n13121776525', // 充值账户
         username: '', // 充值账户
         money: 1, // 充值金额(单位:元)
         recharge: 2, //
@@ -166,7 +164,10 @@ export default {
       thenAccount: '', // 成功账户
       thenAccountNum: 0, // 成功个数
       catchAccount: '', // 失败账户
-      catchAccountNum: 0 // 失败个数
+      catchAccountNum: 0, // 失败个数
+
+      startTime: 0, // 开始时间
+      endTime: 0 // 结束时间
 
     }
   },
@@ -177,7 +178,6 @@ export default {
     this.updateUserMoney()
 
     this.$store.dispatch('user/getF5').then((res) => {
-      console.log('# getF5: ', res)
       if (!res) {
         this.$store.dispatch('user/setF5')
         location.reload()
@@ -223,13 +223,15 @@ export default {
       this.repeatNumList = this.repeatNumList.join().replace(new RegExp(',', 'g'), '\n')
       this.dataForm.username = newList.join().replace(new RegExp(',', 'g'), '\n')
     },
-    async onSubmit() {
+    onSubmit() {
       // this.setAccountNum()
 
       this.thenAccount = ''
       this.catchAccount = ''
       this.thenAccountNum = 0
       this.catchAccountNum = 0
+      this.startTime = ''
+      this.endTime = ''
 
       // TODO: 正式服务器未上线,暂时不需要
       // if ((this.balanceMoney - this.dataForm.money) < 0) {
@@ -242,46 +244,78 @@ export default {
         if (valid) {
           // 截取数据
           var userLists = this.dataForm.username.split('\n')
+          // console.log('# userLists: ', userLists)
 
           MessageBox.prompt('输入支付密码', 'Tip', {
             confirmButtonText: '确认',
             cancelButtonText: '取消'
           }).then(({ value }) => {
+            this.startTime = new Date().getHours() + ':' + new Date().getMinutes() + ':' + new Date().getSeconds()
             // 提取第一条账号数据,针对接口提交判断数据是否有误
             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
+              const { code, status, message } = res
               if (code === 200 && status === true) {
                 this.thenAccount = this.thenAccount + oneData.username + '\n'
                 this.thenAccountNum++
 
-                // 遮屏
-                const loading = Loading.service({
-                  lock: true,
-                  text: '处理中, 请稍等...',
-                  background: 'rgba(0, 0, 0, 0.7)'
-                })
-
-                // 成功后处理剩下账号数据
                 const loadingNum = userLists.length - 2
-                userLists = LodashArray.drop(userLists)
-                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)
-                  // console.log('# forEach:', loadingNum, index)
-                  if (loadingNum === index) {
-                    loading.close()
-                    this.updateUserMoney()
-                  }
-                })
+                if (loadingNum > 1) {
+                  // 遮屏
+                  const loading = Loading.service({
+                    lock: true,
+                    text: '处理中, 请稍等...',
+                    background: 'rgba(0, 0, 0, 0.7)'
+                  })
+
+                  // 成功后处理剩下账号数据
+                  userLists = LodashArray.drop(userLists) // 删除第一个账户
+                  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()
+                      this.endTime = new Date().getHours() + ':' + new Date().getMinutes() + ':' + new Date().getSeconds()
+                    }
+                  })
+                }
               } else {
                 this.catchAccount = this.catchAccount + oneData.username + '\n'
                 this.catchAccountNum++
+
+                return Message({
+                  type: 'warning',
+                  message: message
+                })
               }
-            }).catch((res) => {
+            }).catch((error) => {
               this.catchAccount = this.catchAccount + oneData.username + '\n'
               this.catchAccountNum++
+              return Message({
+                type: 'error',
+                message: error.message
+              })
             })
+
+            // TODO: 跳过第一条数据判断,直接测试
+            // // 遮屏
+            // const loading = Loading.service({
+            //   lock: true,
+            //   text: '处理中, 请稍等...',
+            //   background: 'rgba(0, 0, 0, 0.7)'
+            // })
+            // // 成功后处理剩下账号数据
+            // const loadingNum = userLists.length - 1
+            // 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 || index > loadingNum) {
+            //     loading.close()
+            //     this.updateUserMoney()
+            //     this.endTime = new Date().getHours() + ':' + new Date().getMinutes() + ': ' + new Date().getSeconds()
+            //   }
+            // })
           }).catch(() => {
             return Message({
               type: 'info',
@@ -301,26 +335,30 @@ export default {
       return new Promise((resolve, reject) => {
         setTimeout((_data) => {
           this.$store.dispatch('common/rechargePlayer', _data).then((res) => {
-            console.log('# then:', data.username)
-            const { code, status } = res
+            const { code, status, message } = res
             if (code === 200 && status === true) {
               this.thenAccount = this.thenAccount + _data.username + '\n'
               this.thenAccountNum++
-              resolve()
             } else {
               this.catchAccount = this.catchAccount + _data.username + '\n'
               this.catchAccountNum++
-              resolve()
+              Message({
+                type: 'warning',
+                message: message
+              })
             }
-          }).catch((res) => {
-            console.log('# catch:', data.username)
-
+            // resolve()
+          }).catch((error) => {
             this.catchAccount = this.catchAccount + _data.username + '\n'
             this.catchAccountNum++
-            resolve()
+            Message({
+              type: 'error',
+              message: error.message
+            })
           })
-        }, 2000 * (index + 1), data)
-        // 2000 * (index + 1): +1的原因是,这里是从第二条数据开始处理的,异步处理之前单独处理了一个,所以时间久点。
+          resolve()
+        }, 1500 * (index + 1), data)
+        // 1500 * (index + 1): +1的原因是,这里是从第二条数据开始处理的,异步处理之前单独处理了一个,所以时间久点。
       })
     },