增加抽奖功能
This commit is contained in:
parent
ae5fdf5204
commit
6eed411a99
@ -13,13 +13,13 @@ module.exports = {
|
||||
assetsPublicPath: '/',
|
||||
proxyTable: {
|
||||
'/lz_management': {
|
||||
target: 'http://192.168.43.94:8080',
|
||||
target: 'http://localhost:8080',
|
||||
changeOrigin: true
|
||||
}
|
||||
},
|
||||
|
||||
// Various Dev Server settings
|
||||
host: '192.168.43.94', // can be overwritten by process.env.HOST
|
||||
host: IP, // can be overwritten by process.env.HOST
|
||||
port: 8001, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
|
||||
autoOpenBrowser: true,
|
||||
errorOverlay: true,
|
||||
|
||||
@ -41,4 +41,14 @@ export const apiDingtalkLogin = data => {
|
||||
// 钉钉抽奖登记
|
||||
export const apiDingtalkLuck = data => {
|
||||
return http({ url: '/lz_management/dtlg/luck', method: 'post', data })
|
||||
}
|
||||
|
||||
// 钉钉抽奖详情
|
||||
export const apiGetLuck = params => {
|
||||
return http({ url: '/lz_management/luck/getLuckById', method: 'get', params })
|
||||
}
|
||||
|
||||
// 中将记录登记
|
||||
export const apiUpdateLuck = data => {
|
||||
return http({ url: '/lz_management/luck/updateLuck', method: 'post', data })
|
||||
}
|
||||
@ -9,8 +9,6 @@ import Router from 'vue-router'
|
||||
import { apiGetMenuNav } from '@/api/api_menu'
|
||||
import { isURL } from '@/utils/validate'
|
||||
import { clearLoginInfo } from '@/utils'
|
||||
import VConsole from 'vconsole'
|
||||
let vConsole = new VConsole()// eslint-disable-line no-unused-vars
|
||||
Vue.use(Router)
|
||||
|
||||
// 开发环境不使用懒加载, 因为懒加载页面太多的话会造成webpack热更新太慢, 所以只有生产环境使用懒加载
|
||||
@ -18,6 +16,7 @@ const _import = require('./import-' + process.env.NODE_ENV)
|
||||
|
||||
// 全局路由(无需嵌套上左右整体布局)
|
||||
const globalRoutes = [
|
||||
{ path: '/lzluck', component: _import('common/lzluck'), name: 'lzluck', meta: { title: '霖梓抽奖' } },
|
||||
{ path: '/dingtalkluck', component: _import('common/dingtalkluck'), name: 'dingtalkluck', meta: { title: '钉钉抽奖登记' } },
|
||||
{ path: '/404', component: _import('common/404'), name: '404', meta: { title: '404未找到' } },
|
||||
{ path: '/login', component: _import('common/login'), name: 'login', meta: { title: '登录' } }
|
||||
|
||||
@ -2,7 +2,8 @@
|
||||
<div>
|
||||
<div>
|
||||
<div>
|
||||
<div>
|
||||
<div
|
||||
v-loading='hasSendCode'>
|
||||
<h2 class="brand-info__text">{{dataForm.verify}}</h2>
|
||||
</div>
|
||||
|
||||
@ -14,7 +15,7 @@
|
||||
<script>
|
||||
import { apiDingtalkLuck } from '@/api/api_staff'
|
||||
import * as dd from 'dingtalk-jsapi'
|
||||
var dingCode
|
||||
var dingCode = null
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
@ -24,18 +25,12 @@ export default {
|
||||
password: '',
|
||||
uuid: '',
|
||||
// captcha: ''
|
||||
verify: '霖梓七夕抽奖登记中...'
|
||||
},
|
||||
dataRule: {
|
||||
userName: [{ required: true, message: '帐号不能为空', trigger: 'blur' }],
|
||||
password: [{ required: true, message: '密码不能为空', trigger: 'blur' }],
|
||||
// captcha: [{ required: true, message: '验证码不能为空', trigger: 'blur' }]
|
||||
verify: [{ required: true, message: '验证码不能为空', trigger: 'blur' }]
|
||||
verify: '霖梓2020七夕抽奖登记中...,请勿离开!'
|
||||
},
|
||||
// captchaPath: '' // 图像验证码请求地址
|
||||
time: 0,
|
||||
timer: true,
|
||||
hasSendCode: false
|
||||
hasSendCode: true
|
||||
}
|
||||
},
|
||||
created () {
|
||||
@ -43,14 +38,22 @@ export default {
|
||||
},
|
||||
mounted () {
|
||||
if(this.isDingtalk()){
|
||||
|
||||
console.log('走钉钉免登流程')
|
||||
this.dingtalkLogin()
|
||||
setTimeout(() =>{
|
||||
this.loginWtihCode(dingCode)
|
||||
}, 3000)
|
||||
this.checkDingTalkLogin()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
checkDingTalkLogin () {
|
||||
if(dingCode === null){
|
||||
setTimeout(() =>{
|
||||
this.checkDingTalkLogin()
|
||||
}, 300)
|
||||
} else {
|
||||
this.loginWtihCode(dingCode)
|
||||
}
|
||||
},
|
||||
isDingtalk () {
|
||||
if (/(DingTalk)/i.test(navigator.userAgent)) {
|
||||
return true
|
||||
@ -61,11 +64,16 @@ export default {
|
||||
dingtalkLogin () {
|
||||
dd.runtime.permission.requestAuthCode({
|
||||
corpId: 'ding02853c26606ba7d4a1320dcb25e91351',
|
||||
onSuccess: function (result) {
|
||||
onSuccess(result){
|
||||
|
||||
dingCode = result
|
||||
console.log(dingCode)
|
||||
|
||||
},
|
||||
onFail: function (err) {
|
||||
onFail(err) {
|
||||
|
||||
console.log(err)
|
||||
dingCode = err
|
||||
}
|
||||
})
|
||||
},
|
||||
@ -75,8 +83,10 @@ export default {
|
||||
apiDingtalkLuck(result).then(res => {
|
||||
console.log('获取登录结果')
|
||||
console.log(res)
|
||||
this.hasSendCode = false
|
||||
if (res && res.code === 0) {
|
||||
console.log('获取token')
|
||||
|
||||
this.dataForm.verify='已经登记,祝你好运!如若中将行政将会通知'
|
||||
|
||||
console.log('跳转')
|
||||
|
||||
189
src/views/common/lzluck.vue
Normal file
189
src/views/common/lzluck.vue
Normal file
@ -0,0 +1,189 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1 class="brand-info__text">{{dataForm.verify}}</h1>
|
||||
<h2 class="brand-info__text">{{dataForm.uuid}}</h2>
|
||||
|
||||
<el-table
|
||||
:data="data"
|
||||
style="width: 100%">
|
||||
<el-table-column
|
||||
prop="name"
|
||||
label="姓名"
|
||||
width="180">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="mobile"
|
||||
label="电话">
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-button type="primary" round @click="btnClick">{{dataForm.userName}}</el-button>
|
||||
<el-table
|
||||
:data="luckdata"
|
||||
style="width: 100%">
|
||||
<el-table-column
|
||||
prop="name"
|
||||
label="中将姓名"
|
||||
width="180">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="goodsName"
|
||||
label="获奖信息">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="mobile"
|
||||
label="电话">
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { apiGetLuck } from '@/api/api_staff'
|
||||
import { apiUpdateLuck } from '@/api/api_staff'
|
||||
var dingCode
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
isloading: false,
|
||||
dataForm: {
|
||||
userName: '开始',
|
||||
password: '',
|
||||
uuid: '',
|
||||
// captcha: ''
|
||||
verify: ''
|
||||
},
|
||||
// captchaPath: '' // 图像验证码请求地址
|
||||
time: -1,
|
||||
rand: 0,
|
||||
timer: false,
|
||||
hasSendCode: false,
|
||||
query: {
|
||||
luckId: 1
|
||||
},
|
||||
data: [],
|
||||
luckdata: [],
|
||||
requst: []
|
||||
}
|
||||
},
|
||||
created () {
|
||||
// this.handleGetImgCaptcha()
|
||||
},
|
||||
mounted () {
|
||||
if(this.getLucData()){
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
btnClick (btn) {
|
||||
if(this.requst.isFinish === 0){
|
||||
if(this.timer === false){
|
||||
this.time++
|
||||
this.timer = true
|
||||
this.dataTimeChange ();
|
||||
this.dataForm.userName = '停止'
|
||||
}else{
|
||||
this.timer = false
|
||||
this.dataForm.userName = '开始'
|
||||
for(let item of this.data) {
|
||||
item.goodsName = this.requst.luckGoodsReqs[this.time].name
|
||||
item.goodsId = this.requst.luckGoodsReqs[this.time].id
|
||||
item.luckId = this.requst.id
|
||||
item.isLuck = 1
|
||||
this.luckdata.unshift(item)
|
||||
}
|
||||
//这里更新中奖结果,并返回未中奖的数据
|
||||
apiUpdateLuck(this.luckdata).then(res => {
|
||||
console.log(res)
|
||||
if (res && res.code === 0) {
|
||||
console.log(res.luck.isFinish)
|
||||
this.requst = res.luck
|
||||
if(res.luck.isFinish === 1){
|
||||
this.dataForm.verify=res.luck.name + '——活动结束'
|
||||
}
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
getLucData () {
|
||||
apiGetLuck(this.query).then(res => {
|
||||
|
||||
console.log(res)
|
||||
if (res && res.code === 0) {
|
||||
console.log('获取token')
|
||||
if(res.luck.isFinish === 0){
|
||||
this.requst = res.luck
|
||||
this.dataForm.verify=res.luck.name
|
||||
}else{
|
||||
this.dataForm.verify=res.luck.name + '——活动已结束'
|
||||
this.luckdata = res.luck.luckRecordReqs
|
||||
}
|
||||
} else {
|
||||
this.dataForm.verify='无法登记。' + res.msg
|
||||
this.$message.error(res.msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
dataTimeChange () {
|
||||
if(this.time < this.requst.luckGoodsReqs.length){
|
||||
this.dataForm.uuid = this.requst.luckGoodsReqs[this.time].name
|
||||
setTimeout(() =>{
|
||||
this.randData(this.requst.luckGoodsReqs[this.time].counts)
|
||||
}, 100)
|
||||
}
|
||||
},
|
||||
randData (count) {
|
||||
if (this.timer === true) {
|
||||
var obj = []
|
||||
for(var i = 0; i < count; i++){
|
||||
|
||||
if(this.rand >= this.requst.luckRecordReqs.length){
|
||||
this.rand = 0;
|
||||
}
|
||||
obj.push(this.requst.luckRecordReqs[this.rand])
|
||||
this.rand++
|
||||
}
|
||||
this.data = obj
|
||||
setTimeout(() =>{
|
||||
this.randData(count)
|
||||
}, 100)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.el-row {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.el-col {
|
||||
border-radius: 4px;
|
||||
}
|
||||
.bg-purple-dark {
|
||||
background: #99a9bf;
|
||||
}
|
||||
.bg-purple {
|
||||
background: #d3dce6;
|
||||
}
|
||||
.bg-purple-light {
|
||||
background: #e5e9f2;
|
||||
}
|
||||
.grid-content {
|
||||
border-radius: 4px;
|
||||
min-height: 36px;
|
||||
}
|
||||
.row-bg {
|
||||
padding: 10px 0;
|
||||
background-color: #f9fafc;
|
||||
}
|
||||
</style>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user