From d5b71d4746e68ad571e0ce180bf41483da505766 Mon Sep 17 00:00:00 2001 From: 潘浩文 <phw@bronet.cn> Date: Mon, 22 Oct 2018 16:06:38 +0800 Subject: [PATCH] 1 --- app/portal/controller/PrizeController.php | 75 +++++++++++++++------------------------------------------------------------ public/themes/simpleboot3/portal/prize/getScore.html | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+), 60 deletions(-) create mode 100644 public/themes/simpleboot3/portal/prize/getScore.html diff --git a/app/portal/controller/PrizeController.php b/app/portal/controller/PrizeController.php index 7ad8c2a..cba7047 100644 --- a/app/portal/controller/PrizeController.php +++ b/app/portal/controller/PrizeController.php @@ -16,71 +16,17 @@ use think\Db; class PrizeController extends WeChatBaseController { + protected $options; public function _initialize() { parent::_initialize(); $this->checkWeChatUserLogin(); - - } - //活动首页 - public function active(){ - $this->checkUser(); - $banner=Db::name('active')->where('is_top',1)->field('thumbnail')->select(); - $this->assign('banner',$banner); - $data=Db::name('active')->where('status',1)->select(); - $this->assign('list',$data); - return $this->fetch(); - } - //活动首页ajax - public function activeAjax(){ - $this->checkUser(); - $status=$this->request->param('status'); - $data=Db::name('active')->where('status',$status)->select()->toArray(); - foreach ($data as $k => $v) { - $data[$k]['url']=url('portal/active/activeDetail',array('id'=>$data[$k]['id'])); - $data[$k]['image'] = cmf_get_image_preview_url($data[$k]['thumbnail']); - $data[$k]['active_time'] = date('Y-m-d',$data[$k]['active_time']); - $data[$k]['end_time'] = date('Y-m-d',$data[$k]['end_time']); - }; - return $data; - } - - //活动详情 - public function activeDetail() - { - $re=$this->checkUser(); - $id=$this->request->param('id'); - $data=Db::name('active') - ->where('id',$id) - ->find(); - $data['more']=json_decode($data['more'],true); - $data['content']=cmf_replace_content_file_url(htmlspecialchars_decode($data['content'])); - $like=Db::name('like')->where(['cid'=>$id,'users_id'=>$re['id'],'status'=>2])->find(); - if ($like){ - $like=1; - }else{ - $like=0; - } - $comment=Db::name('comment') - ->alias('c') - ->join('users u','c.users_id=u.id') - ->join('brand b','c.cid=b.id') - ->where(['b.id'=>$id,'c.status'=>2]) - ->field('c.*,u.*') - ->select(); - $this->assign('comment',$comment); - $this->assign('like',$like); - $this->assign('list',$data); - return $this->fetch('active_detail'); + $this->options = [ + 'app_id' => config('wechat_config.app_id'), + 'secret' => config('wechat_config.secret'), + 'payment' => config('wechat_config.payment'), + ]; } - - - - - - - - //兑奖首页 public function prize(){ $re=$this->checkUser(); @@ -189,6 +135,15 @@ class PrizeController extends WeChatBaseController Db::name('prize_order')->insert($data); return 1; } + + public function getScore(){ + $app = new Application($this->options); + $js = $app->js; + $this->assign('js',$js); + return $this->fetch('getScore'); + } + + //上传小票 public function upload(){ $options = [ diff --git a/public/themes/simpleboot3/portal/prize/getScore.html b/public/themes/simpleboot3/portal/prize/getScore.html new file mode 100644 index 0000000..cd2f1b8 --- /dev/null +++ b/public/themes/simpleboot3/portal/prize/getScore.html @@ -0,0 +1,134 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> + <link rel="stylesheet" href="__TMPL__/public/assets/css/base.css"> + <script type="text/javascript" src="__TMPL__/public/assets/js/base.js"></script> + <title>上传小票</title> + <style> + body,html{ + background: #fff; + } + .container{ + position:absolute; + top:50%; + left:50%; + transform: translate(-50%,-50%); + } + + #preview{ + width:2.59rem; + height:2.59rem; + font-size: 0; + + } + #preview img{ + width:100%; + height:100%; + } + .uploadword{ + width:2.59rem; + text-align: center; + color:#252729; + font-size: 0.32rem; + margin-top: 0.35rem; + } + .footer{ + width:6.86rem; + text-align: center; + height:0.88rem; + line-height: 0.88rem; + position:fixed; + bottom:0.55rem; + left:0; + right:0; + margin: 0 auto; + background:#CA277B ; + border-radius: 0.44rem; + color:#fff; + font-size:0.32rem ; + } + </style> +</head> +<body> + <div class="container"> + <!--<div class="upload">--> + <!--<img src="img/upload.png" alt="">--> + <!--</div>--> + <div id="preview"> + <img id="imghead" border="0" src="img/upload.png" style="width:100%;height:100%" onclick="$('#previewImg').click();"> + </div> + <!--<img src="../img/delet.png" alt="" style="position:absolute;bottom:92px;left:46px" class="deleteimg"/>--> + <input type="file" onchange="previewImage(this)" style="display: none;" id="previewImg"> + + <p class="uploadword">上传小票图片</p> + </div> +<div class="footer">确定</div> + <script type="text/javascript" src="js/jquery.min.js"></script> + <script> + function clacImgZoomParam(maxWidth, maxHeight, width, height) { + var param = { + top: 0, + left: 0, + width: width, + height: height + }; + if(width > maxWidth || height > maxHeight) { + rateWidth = width / maxWidth; + rateHeight = height / maxHeight; + + if(rateWidth > rateHeight) { + param.width = maxWidth; + param.height = Math.round(height / rateWidth); + } else { + param.width = Math.round(width / rateHeight); + param.height = maxHeight; + } + } + param.left = Math.round((maxWidth - param.width) / 2); + param.top = Math.round((maxHeight - param.height) / 2); + return param; + } + + function previewImage(file) { + var MAXWIDTH = 50; + var MAXHEIGHT = 50; + var div = document.getElementById('preview'); + if(file.files && file.files[0]) { + div.innerHTML = '<img id=imghead onclick=$("#previewImg").click()>'; + var img = document.getElementById('imghead'); + img.onload = function() { + var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight); + img.width = rect.width; + img.height = rect.height; + // img.style.marginLeft = rect.left+'px'; + img.style.marginTop = rect.top + 'px'; + } + var reader = new FileReader(); + reader.onload = function(evt) { + img.src = evt.target.result; + } + reader.readAsDataURL(file.files[0]); + } else //兼容IE + { + var sFilter = 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="'; + file.select(); + var src = document.selection.createRange().text; + div.innerHTML = '<img id=imghead>'; + var img = document.getElementById('imghead'); + img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src; + var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight); + status = ('rect:' + rect.top + ',' + rect.left + ',' + rect.width + ',' + rect.height); + div.innerHTML = "<div id=divhead style='width:" + rect.width + "px;height:" + rect.height + "px;margin-top:" + rect.top + "px;" + sFilter + src + "\"'></div>"; + } + + } + + //确定上传小票 + $(".footer").click(function(){ + window.location.href='successupload.html' + }) + </script> +</body> +</html> -- libgit2 0.24.0