diff --git a/app/portal/controller/PrizeController.php b/app/portal/controller/PrizeController.php index cba7047..fd36b77 100644 --- a/app/portal/controller/PrizeController.php +++ b/app/portal/controller/PrizeController.php @@ -139,7 +139,8 @@ class PrizeController extends WeChatBaseController public function getScore(){ $app = new Application($this->options); $js = $app->js; - $this->assign('js',$js); + $jss = $js->config(['chooseImage', 'uploadImage', 'previewImage'], $debug = false, $beta = false, $json = true); + $this->assign('js',$jss); return $this->fetch('getScore'); } diff --git a/public/themes/simpleboot3/portal/prize/getScore.html b/public/themes/simpleboot3/portal/prize/getScore.html index 37e66c6..f5c7a6c 100644 --- a/public/themes/simpleboot3/portal/prize/getScore.html +++ b/public/themes/simpleboot3/portal/prize/getScore.html @@ -66,67 +66,98 @@ </div> <div class="footer">确定</div> <script type="text/javascript" src="__TMPL__/public/assets/js/jquery.min.js"></script> - <!--<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>--> + <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.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; - } + wx.config( + {$jss} + ); +// 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>"; +// } +// +// } +wx.ready(function () { + $('#previewImg').click(function () { +// var id = $(this).attr('id'); +// if ($(this).find('img').length=="") { + wx.chooseImage({ + count: 1, // 默认9 + sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 + sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 + success: function (res) { + $('#previewImg').html('<img src="'+res.localIds+'" alt="" style="position:absolute;bottom:92px;left:46px" class="deleteimg"/>') + uploadImages(res.localIds, id) } - 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>"; - alert(src); + }); +// } + }); + function uploadImages(localIds,id) { +// var localId = localIds.pop(); + wx.uploadImage({ + localId: localIds, + isShowProgressTips: 1, + success: function (res) { + var serverId = res.serverId; // 返回图片的服务器端ID + serverIds += id+':'+serverId + ','; + }, + fail: function (res) { + $modal.toast(JSON.stringify(res)); } - - } - + }); + } +}); //确定上传小票 $(".footer").click(function(){ window.location.href='successupload.html'