market_activity_1109

This commit is contained in:
dengbw
2022-11-09 18:49:13 +08:00
committed by lccsw
parent 2f6becc934
commit f4e464180d
6 changed files with 405 additions and 2 deletions
@@ -66,4 +66,33 @@ class Market_sylive_order_model extends HD_Model
}
}
/**
* Notes:中奖类型
* Created on: 2022/11/08 14:46
* Created by: dengbw
* @param int $activityId
* @param int $type
* @return array|mixed
*/
public function winTypeAry($activityId = 0, $type = 0)
{
$winType = [];
if ($activityId == 1) {
$winType = [6 => ['title' => '150元京东卡', 'tag' => '六等奖', 'img' => '', 'num' => 300, 'price' => 0.99]
, 5 => ['title' => '200元京东卡', 'tag' => '五等奖', 'img' => '', 'num' => 200, 'price' => 0.99]
, 4 => ['title' => '300元京东卡', 'tag' => '四等奖', 'img' => '', 'num' => 100, 'price' => 0.99]
, 3 => ['title' => '500元京东卡', 'tag' => '三等奖', 'img' => '', 'num' => 50, 'price' => 0.99]
, 2 => ['title' => 'iphone14', 'tag' => '二等奖', 'img' => '', 'num' => 5, 'price' => 199]
, 1 => ['title' => '半价购车权益', 'tag' => '一等奖', 'img' => '', 'num' => 1, 'price' => 199]
, 7 => ['title' => '200元京东卡', 'tag' => '199独享', 'img' => '', 'num' => 5, 'price' => 199]
, 8 => ['title' => '500元京东卡', 'tag' => '199独享', 'img' => '', 'num' => 2, 'price' => 199]
, 9 => ['title' => '1000元京东卡', 'tag' => '199独享', 'img' => '', 'num' => 1, 'price' => 199]
];
if ($type) {
$winType = $winType[$type];
}
}
return $winType;
}
}
+124
View File
@@ -0,0 +1,124 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:抽奖
* Created on: 2022/11/09 11:19
* Created by: dengbw
*/
class Draw extends CI_Controller
{
private $activityId = 1;
public function __construct()
{
parent::__construct();
$this->load->model('market/Market_sylive_order_model', 'mdSyliveOrder');
$this->load->model('market/Market_sylive_user_model', 'mdSyliveUser');
}
/**
* Notes:
* https://liche-dev.xiaoyu.com/h5/market/draw
* https://www.liche.cn/h5/market/draw
* Created on: 2022/11/09 11:19
* Created by: dengbw
*/
public function index()
{
$winNumAry = [['title' => '请选择...', 'value' => 0], ['title' => '1人', 'value' => 1], ['title' => '2人', 'value' => 2],
['title' => '5人', 'value' => 5], ['title' => '50人', 'value' => 50]];
$winTypeAry = [];
$winTypeAryGet = $this->mdSyliveOrder->winTypeAry($this->activityId);
foreach ($winTypeAryGet as $k => $v) {
$winTypeAry[] = ['title' => $v['tag'] . ' ' . $v['title'], 'value' => $k];
}
$data['info'] = ['winNumAry' => $winNumAry, 'winTypeAry' => $winTypeAry];
$data['title'] = '私域直播抽奖';
$this->load->view('/h5/market/draw/index', $data);
}
/**
* Notes:获取抽奖人
* Created on: 2022/11/9 17:21
* Created by: dengbw
*/
public function post_info()
{
$params = $this->input->post();
$winNum = intval($params['winNum']);
$winType = intval($params['winType']);
if (!$winType) {
$this->show_json(400, '请选择抽奖类型');
}
if (!$winNum) {
$this->show_json(400, '请选择中奖人数');
}
$winTypeAry = $this->mdSyliveOrder->winTypeAry($this->activityId);
$price = $winTypeAry[$winType]['price'];
$limit = $winNum >= 50 ? 100 : 50;
$where = ['activityId' => $this->activityId, 'win' => 0, 'status' => 1, 'totalPrice>=' => $price];
$res = $this->mdSyliveOrder->select($where, 'payTime desc,id asc', 1, $limit, 'id,userId,mobile,uname');
$list = $result = [];
foreach ($res as $v) {
if ($v['mobile']) {
$headimg = 'https://qs.haodian.cn/web/images/project/H5-ShiYu/default-head.png';
$name = $v['uname'] ? $v['uname'] : '***';
$re_user = $this->mdSyliveUser->get(['userId' => $v['userId']], 'nickname,headimg');
if ($re_user) {
$re_user['headimg'] && $headimg = $re_user['headimg'];
}
$list[] = ['id' => intval($v['id']), 'name' => $name, 'tel' => $v['mobile'], 'headimg' => $headimg];
}
}
shuffle($list);//随机数组
$data['list'] = $list;
//$winNumCount = $this->mdSyliveOrder->count(['activityId' => $this->activityId, 'win' => 1, 'status' => 1, 'winType' => $winType]);
//$num = $winTypeAry[$winType]['num'];
//$winNum = ($winNum + $winNumCount) > $num ? $num - $winNumCount : $winNum;
if ($winNum > 0) {
shuffle($list);
$result = array_slice($list, 0, $winNum);
}
$data['result'] = $result;
$data['type'] = $winType;
$this->show_json(200, '更新信息成功', $data);
}
/**
* Notes:更新中奖人
* Created on: 2022/11/9 17:22
* Created by: dengbw
*/
public function post_win()
{
$params = $this->input->post();
$result = $params['result'];
$winType = $params['type'];
if (!$result || !$winType) {
$this->show_json(400, '参数错误');
}
$resultSet = [];
foreach ($result as $v) {
$ret = $this->mdSyliveOrder->update(['win' => 1, 'winType' => $winType], ["id" => $v['id']]);
if ($ret) {
$resultSet = $v;
}
}
$winNumCount = $this->mdSyliveOrder->count(['activityId' => $this->activityId, 'win' => 1, 'status' => 1, 'winType' => $winType]);
$winTypeAry = $this->mdSyliveOrder->winTypeAry($this->activityId, $winType);
$winMsgTip = "已中奖{$winNumCount}人({$winTypeAry['tag']} {$winTypeAry['title']})";
$data['result'] = $resultSet;
$data['winMsgTip'] = $winMsgTip;
$this->show_json(200, '中奖成功', $data);
}
private function show_json($code, $msg, $info = [])
{
$data['code'] = $code;
$data['msg'] = $msg;
$data['data'] = $info;
die(json_encode($data, JSON_UNESCAPED_UNICODE));
}
}
+249
View File
@@ -0,0 +1,249 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title><?= $title ?></title>
<link rel="stylesheet" href="/css/h5/market/draw/pc.css?11091">
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/jquery.3.4.1.min.js"></script>
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/vue.2.6.10.min.js"></script>
</head>
<body class="bg-fff">
<div class="bg-fff" id="app" ref="app">
<div class="container">
<div class="absolute box-center mt50 box-1280-720 bg-no-repeat bg-size-fullwidth bg-pos-top"
style="background-image:url('https://qs.haodian.cn/web/images/project/H5-ShiYu-draw/bg.jpg?v=1109')">
<div class="absolute box-center pt10 font-50 text-bold color-fff text-italic ">
{{topTitle}}
</div>
<div class="maincontent ulib-r20 overflowhidden">
<div class="box-1200-585 relative overflowhidden">
<div class="fn-flex fn-flex-wrap roll-50-1" v-if="winNum==50">
<div class="wp20 relative" style="height:56px;" v-if="index<winNum"
v-for="(item,index) in list">
<img class="absolute box-middle left-0 ml50 imgsize-30X30 ulib-r750" :src="item.headimg"
alt="#"/>
<div class="absolute box-middle left-0 right-0 pl90">
<div class="text-nowrap font-14">{{item.name}}</div>
<div class="font-12 color-666">{{item.tel}}</div>
</div>
</div>
</div>
<div class="absolute box-center-middle" style="width:300px;" v-if="winNum==5">
<div class="relative" style="height:100px;" v-if="index<winNum" v-for="(item,index) in list">
<img class="absolute box-middle left-0 imgsize-50X50 ulib-r750" :src="item.headimg"
alt="#"/>
<div class="absolute box-middle left-0 right-0 pl70">
<div class="text-nowrap font-24">{{item.name}}</div>
<div class="font-16 color-666">{{item.tel}}</div>
</div>
</div>
</div>
<div class="absolute box-center-middle" style="width:400px;" v-if="winNum==2">
<div class="relative" style="height:150px;" v-if="index<winNum" v-for="(item,index) in list">
<img class="absolute box-middle left-0 imgsize-70X70 ulib-r750" :src="item.headimg"
alt="#"/>
<div class="absolute box-middle left-0 right-0 pl100">
<div class="text-nowrap font-40">{{item.name}}</div>
<div class="font-30 color-666">{{item.tel}}</div>
</div>
</div>
</div>
<div class="absolute box-center-middle" style="width:500px;" v-if="winNum==1">
<div class="relative" style="height:150px;" v-if="index<winNum" v-if="index<winNum"
v-for="(item,index) in list">
<img class="absolute box-middle left-0 imgsize-90X90 ulib-r750" :src="item.headimg"
alt="#"/>
<div class="absolute box-middle left-0 right-0 pl110">
<div class="text-nowrap font-60">{{item.name}}</div>
<div class="font-40 color-666">{{item.tel}}</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="fixed left-0 bottom-0 right-0 bg-1a1a1a pt40 pb40 text-center fn-clear">
<select id="win_type_id" class="fn-fl text-middle ml40 select-more pl20 pr20 ulib-r5 font-18"
style="height:50px;"
@change="changeTitle">
<option :value="item.value" v-for="(item,index) in info.winTypeAry">{{item.title}}</option>
</select>
<span v-if="!isStartAc">
<span class="text-middle font-18 color-fff">选择中奖人数:</span>
<select class="text-middle mr10 select-more pl20 pr20 ulib-r5 font-18" style="height:50px;"
@change="changeType">
<option :value="item.value" v-for="item in info.winNumAry">{{item.title}}</option>
</select>
<a class="text-middle inline-block bg-1282f4 ml10 mr10 pt10 pb10 pl20 pr20 text-center font-18 color-fff ulib-r5"
href="javascript:;" @click="getDraw">更新信息</a>
<a class="text-middle inline-block bg-1282f4 ml10 mr10 pt10 pb10 pl20 pr20 text-center font-18 color-fff ulib-r5"
v-if="list.length>0&&draw.list.length>0" href="javascript:;" @click="start">开始抽奖</a>
</span>
<a v-else
class="text-middle inline-block bg-1282f4 ml10 mr10 pt10 pb10 pl20 pr20 text-center font-18 color-fff ulib-r5"
href="javascript:;" @click="result">立即开奖</a>
<div class=" absolute left-0 right-0 top-0 pt10 font-14 color-eb5359 ">{{msgTip}} {{winMsgTip}}</div>
</div>
<!--隐藏加载数据-->
<div class="absolute left-0 bottom-0 op0 overflowhidden" style="width:50px;height:50px;">
<div v-for="item in draw.list">
<img style="width:1px;height:1px;" :src="item.headimg" alt="#"/>
</div>
</div>
</div>
</div>
<script>
let hostUrl = '';
var app = new Vue({
el: '#app',
data: {
submitFlag: false,
topTitle: '',
winNum: '0',
winType: 6,
info: {
winNumAry: [],
winTypeAry: [],
},
draw: {
list: [],
result: [],
type: 0,
},
list: [],
timer: null,
isStartAc: false,
isOpen: false,
msgTip: '',
winMsgTip: '',
},
mounted() {
this.getInfo()
},
beforeDestroy() {
this.list = [];
clearTimeout(this.timer);
},
methods: {
//基础信息
getInfo() {
this.info = {
winNumAry: <?=json_encode($info['winNumAry'], JSON_UNESCAPED_UNICODE)?>,
winTypeAry: <?=json_encode($info['winTypeAry'], JSON_UNESCAPED_UNICODE)?>,
}
},
//更新信息
getDraw() {
let that = this;
if (that.isSubmiting) return;
clearTimeout(that.timer);
that.msgTip = "";
that.winMsgTip = "";
if (!that.isOpen && that.winNum > 0) {
that.draw = {list: [], result: [], type: 0};
that.list = [];
$.ajax({
url: '/h5/market/draw/post_info',
type: 'post',
dataType: 'json',
data: {winNum: that.winNum, winType: that.winType},
beforeSend: function () {
that.submitFlag = true;
},
success: function (re) {
if (re.code == 200) {
if (re.data.list.length == 0) {
that.msgTip = '无抽奖人...';
} else if (re.data.list.result == 0) {
that.msgTip = '无中抽奖人...';
} else {
that.topTitle = $("#win_type_id").find("option:selected").text();
that.draw = {list: re.data.list, result: re.data.result, type: re.data.type};
let arr = that.draw.list.slice(0);
arr.sort(function () {
return Math.random() - 0.5;
});
that.list = arr;
}
} else {
that.msgTip = re.msg;
}
},
complete: function () {
that.submitFlag = false;
}
});
} else {
that.msgTip = "请选择中奖人数"
}
},
//选择中奖个数
changeType(e) {
this.isOpen = false;
if (this.winNum != e.target.value) {
this.winNum = e.target.value;
this.list = [];
this.msgTip = "";
this.winMsgTip = "";
}
},
//选择类型
changeTitle(e) {
if (this.winType != e.target.value) {
this.winType = e.target.value;
}
},
//开始抽奖
start() {
this.isStartAc = true
this.timer = setInterval(res1 => {
//随机排序
let arr = this.draw.list.slice(0)
arr.sort(function () {
return Math.random() - 0.5;
})
this.list = arr
}, 20)
},
//立即开奖
result() {
let that = this;
if (that.isSubmiting) return;
//提交中奖数据
$.ajax({
url: '/h5/market/draw/post_win',
type: 'post',
dataType: 'json',
data: {result: that.draw.result, type: that.draw.type},
beforeSend: function () {
that.submitFlag = true;
},
success: function (re) {
if (re.code == 200) {
that.msgTip = '';
that.winMsgTip = re.data.winMsgTip;
clearTimeout(that.timer);
that.list = re.data.result;
that.isStartAc = false;
that.isOpen = true;
that.draw = {list: [], result: [], type: 0};
} else {
that.msgTip = re.msg;
}
},
complete: function () {
that.submitFlag = false;
}
});
},
}
})
</script>
</body>
</html>
+1 -1
View File
@@ -130,7 +130,7 @@ class Activity extends BaseController
$teamIds[] = intval($v2['teamId2']);
}
}
$skey = $this->myencryption->base64url_encode("activityId=" . $activityId);
$skey = $this->myencryption->base64url_encode("a_id=" . $activityId);
$url = http_host_com('home') . "/h5/market/sylive?skey=" . $skey;//活动连接
$list[] = [
'activityId' => $activityId, 'title' => $v['title'], 'channelId' => $v['channelId'], 'bizIds' => $bizIds, 'teamIds' => $teamIds, 'pay' => $pay,
+1 -1
View File
@@ -48,7 +48,7 @@ class Goods extends BaseController
$list = [];
if ($count) {
$this->load->library('MyEncryption');
$skey = $this->myencryption->base64url_encode("activityId=" . $activityId);
$skey = $this->myencryption->base64url_encode("a_id=" . $activityId);
$res = $this->mdSyliveItems->select($where, $sort_order, $page, $limit);
foreach ($res as $v) {
$banner = [];
File diff suppressed because one or more lines are too long