Commit 8186527092be3714fe52a965b571d379e6d9a857
1 parent
df34ee8a
Exists in
master
1.扫校验码自动跳转调整。
2.校验图片存OSS调整为不存OSS直接存ECS。
Showing
7 changed files
with
32 additions
and
29 deletions
Show diff stats
app-wx/controllers/BaseController.php
... | ... | @@ -177,6 +177,7 @@ class BaseController extends AppController |
177 | 177 | if ($appUser->isGuest){ |
178 | 178 | $this->handleOAuthRedirect(); |
179 | 179 | } else { |
180 | + AppLog::DEBUG("BaseController::handleMallAccessCtrl() --> 当前访问路径=" . $this->site->url); | |
180 | 181 | $path = $this->request->get('jumppath'); |
181 | 182 | $model= $this->request->get('jumpmodel'); |
182 | 183 | $paramOne= $this->request->get('paramOne'); |
... | ... | @@ -187,6 +188,11 @@ class BaseController extends AppController |
187 | 188 | } |
188 | 189 | header("Location: $locationUrl");exit; |
189 | 190 | } |
191 | + $jumpDestUrl = $this->site->url; | |
192 | + if (strpos($jumpDestUrl, '/?uuid=')) { | |
193 | + $jumpDestUrl = str_replace('/?uuid=', '/qrcode/index?uuid=', $jumpDestUrl); | |
194 | + header("Location: $jumpDestUrl");exit; | |
195 | + } | |
190 | 196 | } |
191 | 197 | |
192 | 198 | } | ... | ... |
app-wx/controllers/QrcodeController.php
... | ... | @@ -53,18 +53,18 @@ class QrcodeController extends BaseController |
53 | 53 | if ($result["code"] == 2) { |
54 | 54 | $hasRecord = SellerInputRecordRepository::findOne(["uuid" => $uuid]); |
55 | 55 | if (empty($hasRecord)) { |
56 | + Log::DEBUG("执行跳转code={2},未存记录"); | |
56 | 57 | $this->jumpActive($uuid); |
57 | 58 | } else { |
59 | + Log::DEBUG("执行跳转code={2},已存记录"); | |
58 | 60 | // 记录扫码次数 |
59 | 61 | $scanCount = ScanRecords::updateCount($uuid); |
60 | 62 | $scanCount = $scanCount ? $scanCount : 1; |
61 | 63 | $this->jumpScanCount($uuid, $scanCount); |
62 | 64 | } |
63 | 65 | } else if ($result["code"] == 0) { |
64 | - // 记录扫码次数 | |
65 | - $scanCount = ScanRecords::updateCount($uuid); | |
66 | - $scanCount = $scanCount ? $scanCount : 1; | |
67 | - $this->jumpScanCount($uuid, $scanCount); | |
66 | + Log::DEBUG("执行跳转code={0},跳转到激活页"); | |
67 | + $this->jumpActive($uuid); | |
68 | 68 | } else { |
69 | 69 | $this->jumpError(); |
70 | 70 | } | ... | ... |
app-wx/controllers/WechatController.php
... | ... | @@ -279,6 +279,9 @@ class WechatController extends BaseController |
279 | 279 | header("Location: $locationUrl");exit; |
280 | 280 | } |
281 | 281 | } |
282 | + if (strpos($jumpDestUrl, '/?uuid=')) { | |
283 | + $jumpDestUrl = str_replace('/?uuid=', '/qrcode/index?uuid=', $jumpDestUrl); | |
284 | + } | |
282 | 285 | AppLog::DEBUG("processWechatLogin登录成功: 目标跳转=" . $jumpDestUrl); |
283 | 286 | return $this->redirect($jumpDestUrl); |
284 | 287 | } | ... | ... |
app-wx/modules/check/controllers/DefaultController.php
... | ... | @@ -94,8 +94,6 @@ class DefaultController extends BaseController |
94 | 94 | return $this->renderJson($e); |
95 | 95 | } |
96 | 96 | $filename = basename($uploadFile); |
97 | - // 获取图片路径 | |
98 | - $uploadFile = ImageManager::getUrl($uploadFile); | |
99 | 97 | |
100 | 98 | // @todo 校验UUID是否有效 2 无效 0 有效未激活 1 有效已激活 |
101 | 99 | $startTime = microtime(true); |
... | ... | @@ -151,7 +149,7 @@ class DefaultController extends BaseController |
151 | 149 | $e->message = '保存失败!'; |
152 | 150 | return $this->renderJson($e); |
153 | 151 | } |
154 | - $e->show_path = ImageManager::getUrl($filename, ImageManager::$STYLE_180); | |
152 | + $e->show_path = $filename; | |
155 | 153 | $e->img_path = $filename; |
156 | 154 | $e->success = true; |
157 | 155 | $e->message = '上传成功'; |
... | ... | @@ -176,15 +174,17 @@ class DefaultController extends BaseController |
176 | 174 | return false; |
177 | 175 | } |
178 | 176 | $filename_root = $_SERVER['DOCUMENT_ROOT']; |
179 | - $path = $filename_root . '/tmp'; | |
177 | + $baseUrl = Yii::$app->params['baseUrl']; | |
178 | + $path = $filename_root . '/tmp/'. date("Ymd") . '/'; | |
180 | 179 | |
181 | 180 | if (!is_dir($path)) { |
182 | 181 | @mkdir($path, 0777); |
183 | 182 | } |
184 | 183 | $dir = $path; |
185 | 184 | $tt = time(); |
186 | - $filename = 'smart_'.$tt.md5($tr).'.jpg'; | |
185 | + $filename = "IMG_" . $uuid . "_" . time() . '.jpg'; | |
187 | 186 | $saveFilePath = $dir.'/'.$filename; |
187 | + $showPath = $baseUrl . '/tmp/'. date("Ymd") . '/' .$filename; | |
188 | 188 | |
189 | 189 | $local_file = fopen($saveFilePath, 'w'); |
190 | 190 | if (false !== $local_file) { |
... | ... | @@ -193,12 +193,7 @@ class DefaultController extends BaseController |
193 | 193 | } |
194 | 194 | } |
195 | 195 | $user_id = $userId = $this->getUserId(); |
196 | - $stat_path = ImageManager::getSmartCheckImgPath($user_id, $uuid); | |
197 | - ImageManager::add($saveFilePath, $stat_path); | |
198 | - // 删除服务器文件 | |
199 | - @unlink($saveFilePath); | |
200 | - | |
201 | - return $stat_path; | |
196 | + return $showPath; | |
202 | 197 | } |
203 | 198 | |
204 | 199 | /** | ... | ... |
app-wx/web/dist/js/check-app.js
1 | -define("check-app",["mk7/app"],function(t){var n=Dom7,e=function(){var t=n(".ui-loading-block");0==t.length&&(n(".view-main").html('<div class="ui-loading-block" id="ui-loading"><div class="ui-loading-cnt"><div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div><div id="loader-inner"><p></p></div> </div> </div>'),window.waitingTime=1e4,window.loaderTimer&&clearTimeout(window.loaderTimer),window.loaderTimer=setTimeout(function(){var t=document.getElementById("loader-inner"),n=document.createElement("p");n.className="notice",t&&(n.innerHTML='加载速度太慢?试试<a class="link" href="#" onclick="javascript:location.reload();return false;">重新加载</a>',t.appendChild(n))},window.waitingTime))},o=!0;return t.name="check",t.routes={index:function(){return o=!1,e(),t.runController("index")},"*":function(){return o=!1,e(),t.runController("index")},"scan-count/:uuid/:scancount":function(n,i){return o=!1,e(),t.runController("scan-count",{uuid:n,scancount:i})},"warning/:uuid":function(n){return o=!1,e(),t.runController("warning",{uuid:n})},"submit/:uuid":function(n){return o=!1,e(),t.runController("submit",{uuid:n})},"error/:uuid":function(n){return o=!1,e(),t.runController("error",{uuid:n})},"success/:uuid":function(n){return o=!1,e(),t.runController("success",{uuid:n})},"info/:uuid/:number_code":function(n,i){return o=!1,e(),t.runController("info",{uuid:n,number_code:i})}},t}),define("check/error-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(t,n,e,o,i){var t=new t,c=Dom7;Template7;return t.run=function(){var t=this;t.setPageTitle("验证结果"),t.render()},t.bindEvents=function(){c(".back-button").click(function(){window.history.go(-1)})},t}),define("check/index-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(t,n,e,o,i){var t=new t,c=Dom7,a=(Template7,1),r=0,s=2,u=0;return t.run=function(){var t=this;t.setPageTitle("验证标签"),i.config({debug:!1,appId:window.$site.appid,timestamp:window.$site.timestamp,nonceStr:window.$site.noncestr,signature:window.$site.signature,jsApiList:["openLocation","getLocation","scanQRCode"]}),t.scanQrcode(),t.render(),c(".scan-button").attr("disabled","disabled"),c(".scan-button").text("正在调起扫码……")},t.bindEvents=function(){var t=this;c(".scan-button").click(function(){t.scanQrcode()})},t.scanQrcode=function(){var t=this;i.ready(function(){i.scanQRCode({needResult:1,desc:"scanQRCode desc",success:function(o){var i=o.resultStr;if(""==i||void 0==i||i.indexOf("http://smart.zhoundlee.com")<0)return e.toast({content:"该智能防伪二维码无效"}),!1;var d=c.parseUrlQuery(i);if(null!=d&&void 0!==d&&null!=d.uuid&&void 0!==d.uuid){if(d.uuid.indexOf("@")==-1)return e.toast({content:"该智能防伪二维码无效"}),!1;var d=d.uuid.split("@"),l=n.to("check#warning/"+d[0]),m=n.to("check#scan-count/"+d[0]+"/"+u);c.ajax({method:"POST",url:n.to("check/default/check-active"),data:{uuid:d[0]},dataType:"json",beforeSend:function(){t.showIndicator()},success:function(t){u=t.scan_count,m=n.to("check#scan-count/"+d[0]+"/"+u),t.success==a?window.location.href=m:t.success==r?window.location.href=l:t.success==s?e.toast({content:"该智能防伪二维码无效"}):e.toast({content:"该智能防伪二维码无效"})},error:function(t){},complete:function(n){t.hideIndicator()}})}else e.toast({content:"请扫描智能防伪二维码"})}}),setTimeout(function(){c(".scan-button").removeAttr("disabled"),c(".scan-button").text("点击扫描标签")},1e3)})},t}),define("check/info-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(t,n,e,o,i){var t=new t,c=Dom7;Template7;return i.config({debug:!1,appId:window.$site.appid,timestamp:window.$site.timestamp,nonceStr:window.$site.noncestr,signature:window.$site.signature,jsApiList:["previewImage"]}),t.run=function(){var t=this;t.setPageTitle("隐私信息"),t.loadData(t.params.uuid,t.params.number_code),t.popstate()},t.bindEvents=function(){c(".back-button").click(function(){window.history.go(-1)}),c(".image_button").click(function(){var t=c(this).attr("data-url");return e.isEmpty(t)?(e.toast({content:"该图片不存在",closeDelay:3e3}),!1):(c(".scan-image-div").html('<img src="'+t+'" class="scan-image"/>'),void c(".scan-image").click(function(){var t=[],n=c("#info").find(".image_button");c.each(n,function(n,e){var o=c(e).attr("data-url");t.push(o)});var e=c(this).attr("src");i.previewImage({current:e,urls:t})}))}),c(".scan-image").click(function(){var t=[],n=c("#info").find(".image_button");c.each(n,function(n,e){var o=c(e).attr("data-url");t.push(o)});var e=c(this).attr("src");i.previewImage({current:e,urls:t})}),c(".vedio_button").click(function(){var t=c(this).attr("data-url");if(e.isEmpty(t))return e.toast({content:"该视频不存在",closeDelay:3e3}),!1;var n="<video class='scan-image' style='border: 1px solid #cce1f1;object-fit: fill;height:15rem;' alt='商品视频' ";n+="controls='controls'> <source src='"+t+"' type='video/mp4'>您的浏览器不支持 video 标签。</video>",c(".scan-image-div").html(n)})},t.loadData=function(t,o){var i=this;c.ajax({method:"POST",url:n.to("check/default/get-info"),data:{uuid:t,number_code:o},dataType:"json",beforeSend:function(){i.showIndicator()},success:function(t){try{t.success?i.render(t.data):e.toast({content:t.message,closeDelay:3e3})}catch(n){e.toast({content:"出错",closeDelay:3e3})}},error:function(t){e.toast({content:"提交出错,请联系系统管理员"})},complete:function(t){i.hideIndicator()}})},t.popstate=function(){window.addEventListener("popstate",function(t){window.location.href=n.to("check#index")},!1)},t}),define("check/scan-count-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(t,n,e,o,i){var t=new t,c=Dom7,a=(Template7,0),r="";return t.run=function(){var t=this;a=parseInt(t.params.scancount),r=t.params.uuid,t.setPageTitle("验证标签"),t.render(),c(".count-num").html(a)},t.bindEvents=function(){c(".scan-button").click(function(){""!=r&&void 0!=r?window.location.href=n.to("check#submit/"+r):window.location.href=n.to("check#index")})},t}),define("check/submit-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(t,n,e,o,i){var t=new t,c=Dom7,a=(Template7,"");return t.run=function(){var t=this;a=t.params.uuid,t.setPageTitle("验证标签"),i.config({debug:!1,appId:window.$site.appid,timestamp:window.$site.timestamp,nonceStr:window.$site.noncestr,signature:window.$site.signature,jsApiList:["chooseImage","previewImage","uploadImage","getLocalImgData"]}),t.render()},t.bindEvents=function(){var t=this;c(".scan-image").click(function(){t.uploadImg(c(this))}),c(".scan-button").click(function(){var o=c(".scan-image").attr("data");return e.isEmpty(o)?(e.toast({content:"请拍照文件上传后再试!"}),!1):void c.ajax({method:"POST",url:n.to("check/default/check-actived"),data:{upload_file:o,uuid:a},dataType:"json",beforeSend:function(){t.showIndicator()},success:function(t){try{t.success?1==t.code?window.location.href=n.to("check#success/"+a):e.toast({content:t.message,closeDelay:3e3}):window.location.href=n.to("check#error/"+a)}catch(o){e.toast({content:"出错",closeDelay:3e3})}},error:function(t){e.toast({content:"提交出错,请联系系统管理员"})},complete:function(n){t.hideIndicator()}})})},t.uploadImg=function(t){var n=this;i.ready(function(){i.chooseImage({count:1,sizeType:["compressed"],sourceType:["album","camera"],success:function(e){e.localIds.length>0&&n.upload(e.localIds,t)}})})},t.upload=function(t,o){var r=this;return void 0==t[0]?"":void i.uploadImage({localId:t[0],isShowProgressTips:1,success:function(t){c.ajax({method:"POST",url:n.to("check/default/update-serviceid"),data:{service_id:t.serverId,uuid:a},dataType:"json",beforeSend:function(){r.showIndicator()},success:function(t){try{if(t.success){var n=t.img_path;o.attr("data",n),o.attr("src",t.show_path)}else e.toast({content:t.message,closeDelay:3e3})}catch(i){e.toast({content:"校验失败,请换个图片再试!",closeDelay:3e3})}},error:function(t){e.toast({content:"校验失败,请换个图片再试!"})},complete:function(t){r.hideIndicator()}})},fail:function(t){r.app.alert(JSON.stringify(t))}})},t}),define("check/success-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(t,n,e,o,i){var t=new t,c=Dom7,a=(Template7,"");return t.run=function(){var t=this;a=t.params.uuid,t.setPageTitle("验证结果"),t.render()},t.bindEvents=function(){var t=this;c(".btn-submit").click(function(){var o=c(".input-num").val();return e.isEmpty(o)?(e.toast({content:"请填写提取码"}),c(".input-num").focus(),!1):e.isEmpty(a)?(e.toast({content:"缺少必要参数请退出重试"}),!1):void c.ajax({method:"POST",url:n.to("check/default/get-info"),data:{uuid:a,number_code:o},dataType:"json",beforeSend:function(){t.showIndicator()},success:function(t){try{t.success?window.location.href=n.to("check#info/"+a+"/"+o):e.toast({content:t.message,closeDelay:3e3})}catch(i){e.toast({content:"出错",closeDelay:3e3})}},error:function(t){e.toast({content:"提交出错,请联系系统管理员"})},complete:function(n){t.hideIndicator()}})})},t}),define("check/warning-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(t,n,e,o,i){var t=new t,c=Dom7,a=(Template7,"");return t.run=function(){var t=this;a=t.params.uuid,t.setPageTitle("验证标签"),t.render()},t.bindEvents=function(){c(".scan-jump-button").click(function(){""!=a&&void 0!=a?window.location.href=n.to("smart#enter/"+a):window.location.href=n.to("check#index")})},t}); | |
2 | 1 | \ No newline at end of file |
2 | +define("check-app",["mk7/app"],function(t){var n=Dom7,e=function(){var t=n(".ui-loading-block");0==t.length&&(n(".view-main").html('<div class="ui-loading-block" id="ui-loading"><div class="ui-loading-cnt"><div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div><div id="loader-inner"><p></p></div> </div> </div>'),window.waitingTime=1e4,window.loaderTimer&&clearTimeout(window.loaderTimer),window.loaderTimer=setTimeout(function(){var t=document.getElementById("loader-inner"),n=document.createElement("p");n.className="notice",t&&(n.innerHTML='加载速度太慢?试试<a class="link" href="#" onclick="javascript:location.reload();return false;">重新加载</a>',t.appendChild(n))},window.waitingTime))},o=!0;return t.name="check",t.routes={index:function(){return o=!1,e(),t.runController("index")},"*":function(){return o=!1,e(),t.runController("index")},"scan-count/:uuid/:scancount":function(n,i){return o=!1,e(),t.runController("scan-count",{uuid:n,scancount:i})},"warning/:uuid":function(n){return o=!1,e(),t.runController("warning",{uuid:n})},"submit/:uuid":function(n){return o=!1,e(),t.runController("submit",{uuid:n})},"error/:uuid":function(n){return o=!1,e(),t.runController("error",{uuid:n})},"success/:uuid":function(n){return o=!1,e(),t.runController("success",{uuid:n})},"info/:uuid/:number_code":function(n,i){return o=!1,e(),t.runController("info",{uuid:n,number_code:i})}},t}),define("check/error-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(t,n,e,o,i){var t=new t,c=Dom7;Template7;return t.run=function(){var t=this;t.setPageTitle("验证结果"),t.render()},t.bindEvents=function(){c(".back-button").click(function(){window.history.go(-1)})},t}),define("check/index-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(t,n,e,o,i){var t=new t,c=Dom7,a=(Template7,1),r=0,s=2,u=0;return t.run=function(){var t=this;t.setPageTitle("验证标签"),i.config({debug:!1,appId:window.$site.appid,timestamp:window.$site.timestamp,nonceStr:window.$site.noncestr,signature:window.$site.signature,jsApiList:["openLocation","getLocation","scanQRCode"]}),t.scanQrcode(),t.render(),c(".scan-button").attr("disabled","disabled"),c(".scan-button").text("正在调起扫码……")},t.bindEvents=function(){var t=this;c(".scan-button").click(function(){t.scanQrcode()})},t.scanQrcode=function(){var t=this;i.ready(function(){i.scanQRCode({needResult:1,desc:"scanQRCode desc",success:function(o){var i=o.resultStr;if(""==i||void 0==i||i.indexOf("http://smart.zhoundlee.com")<0)return e.toast({content:"该智能防伪二维码无效"}),!1;var d=c.parseUrlQuery(i);if(null!=d&&void 0!==d&&null!=d.uuid&&void 0!==d.uuid){if(d.uuid.indexOf("@")==-1)return e.toast({content:"该智能防伪二维码无效"}),!1;var d=d.uuid.split("@"),l=n.to("check#warning/"+d[0]),m=n.to("check#scan-count/"+d[0]+"/"+u);c.ajax({method:"POST",url:n.to("check/default/check-active"),data:{uuid:d[0]},dataType:"json",beforeSend:function(){t.showIndicator()},success:function(t){u=t.scan_count,m=n.to("check#scan-count/"+d[0]+"/"+u),t.success==a?window.location.href=m:t.success==r?window.location.href=l:t.success==s?e.toast({content:"该智能防伪二维码无效"}):e.toast({content:"该智能防伪二维码无效"})},error:function(t){},complete:function(n){t.hideIndicator()}})}else e.toast({content:"请扫描智能防伪二维码"})}}),setTimeout(function(){c(".scan-button").removeAttr("disabled"),c(".scan-button").text("点击扫描标签")},1e3)})},t}),define("check/info-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(t,n,e,o,i){var t=new t,c=Dom7;Template7;return i.config({debug:!1,appId:window.$site.appid,timestamp:window.$site.timestamp,nonceStr:window.$site.noncestr,signature:window.$site.signature,jsApiList:["previewImage"]}),t.run=function(){var t=this;t.setPageTitle("隐私信息"),t.loadData(t.params.uuid,t.params.number_code),t.popstate()},t.bindEvents=function(){c(".back-button").click(function(){window.history.go(-1)}),c(".image_button").click(function(){var t=c(this).attr("data-url");return e.isEmpty(t)?(e.toast({content:"该图片不存在",closeDelay:3e3}),!1):(c(".scan-image-div").html('<img src="'+t+'" class="scan-image"/>'),void c(".scan-image").click(function(){var t=[],n=c("#info").find(".image_button");c.each(n,function(n,e){var o=c(e).attr("data-url");t.push(o)});var e=c(this).attr("src");i.previewImage({current:e,urls:t})}))}),c(".scan-image").click(function(){var t=[],n=c("#info").find(".image_button");c.each(n,function(n,e){var o=c(e).attr("data-url");t.push(o)});var e=c(this).attr("src");i.previewImage({current:e,urls:t})}),c(".vedio_button").click(function(){var t=c(this).attr("data-url");if(e.isEmpty(t))return e.toast({content:"该视频不存在",closeDelay:3e3}),!1;var n="<video class='scan-image' style='border: 1px solid #cce1f1;object-fit: fill;height:15rem;' alt='商品视频' ";n+="controls='controls'> <source src='"+t+"' type='video/mp4'>您的浏览器不支持 video 标签。</video>",c(".scan-image-div").html(n)})},t.loadData=function(t,o){var i=this;c.ajax({method:"POST",url:n.to("check/default/get-info"),data:{uuid:t,number_code:o},dataType:"json",beforeSend:function(){i.showIndicator()},success:function(t){try{t.success?i.render(t.data):e.toast({content:t.message,closeDelay:3e3})}catch(n){e.toast({content:"出错",closeDelay:3e3})}},error:function(t){e.toast({content:"提交出错,请联系系统管理员"})},complete:function(t){i.hideIndicator()}})},t.popstate=function(){window.addEventListener("popstate",function(t){window.location.href=n.to("check#index")},!1)},t}),define("check/scan-count-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(t,n,e,o,i){var t=new t,c=Dom7,a=(Template7,0),r="";return t.run=function(){var t=this;a=parseInt(t.params.scancount),r=t.params.uuid,t.setPageTitle("验证标签"),t.render(),c(".count-num").html(a)},t.bindEvents=function(){c(".scan-button").click(function(){""!=r&&void 0!=r?window.location.href=n.to("check#submit/"+r):window.location.href=n.to("check#index")})},t}),define("check/submit-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(t,n,e,o,i){var t=new t,c=Dom7,a=(Template7,"");return t.run=function(){var t=this;a=t.params.uuid,t.setPageTitle("验证标签"),i.config({debug:!1,appId:window.$site.appid,timestamp:window.$site.timestamp,nonceStr:window.$site.noncestr,signature:window.$site.signature,jsApiList:["chooseImage","previewImage","uploadImage","getLocalImgData"]}),t.render()},t.bindEvents=function(){var t=this;c(".scan-image").click(function(){t.uploadImg(c(this))}),c(".scan-button").click(function(){var o=c(".scan-image").attr("data");if(e.isEmpty(o))return e.toast({content:"请拍照文件上传后再试!"}),!1;var i=c(this);c.ajax({method:"POST",url:n.to("check/default/check-actived"),data:{upload_file:o,uuid:a},dataType:"json",beforeSend:function(){t.showIndicator(),i.html("验证中…")},success:function(t){try{t.success?1==t.code?window.location.href=n.to("check#success/"+a):e.toast({content:t.message,closeDelay:3e3}):window.location.href=n.to("check#error/"+a)}catch(o){e.toast({content:"校验失败,请重拍图片再试!",closeDelay:3e3})}},error:function(t){e.toast({content:"校验失败,请重拍图片再试!"}),i.html("提交验证")},complete:function(n){t.hideIndicator(),i.html("提交验证")}})})},t.uploadImg=function(t){var n=this;i.ready(function(){i.chooseImage({count:1,sizeType:["compressed"],sourceType:["album","camera"],success:function(e){e.localIds.length>0&&n.upload(e.localIds,t)}})})},t.upload=function(t,o){var r=this;return void 0==t[0]?"":void i.uploadImage({localId:t[0],isShowProgressTips:1,success:function(t){c.ajax({method:"POST",url:n.to("check/default/update-serviceid"),data:{service_id:t.serverId,uuid:a},dataType:"json",beforeSend:function(){r.showIndicator()},success:function(t){try{if(t.success){var n=t.img_path;o.attr("data",n),o.attr("src",t.show_path)}else e.toast({content:t.message,closeDelay:3e3})}catch(i){e.toast({content:"图片上传失败!",closeDelay:3e3}),r.hideIndicator()}},error:function(t){e.toast({content:"图片上传失败!"}),r.hideIndicator()},complete:function(t){r.hideIndicator()}})},fail:function(t){r.app.alert(JSON.stringify(t))}})},t}),define("check/success-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(t,n,e,o,i){var t=new t,c=Dom7,a=(Template7,"");return t.run=function(){var t=this;a=t.params.uuid,t.setPageTitle("验证结果"),t.render()},t.bindEvents=function(){var t=this;c(".btn-submit").click(function(){var o=c(".input-num").val();return e.isEmpty(o)?(e.toast({content:"请填写提取码"}),c(".input-num").focus(),!1):e.isEmpty(a)?(e.toast({content:"缺少必要参数请退出重试"}),!1):void c.ajax({method:"POST",url:n.to("check/default/get-info"),data:{uuid:a,number_code:o},dataType:"json",beforeSend:function(){t.showIndicator()},success:function(t){try{t.success?window.location.href=n.to("check#info/"+a+"/"+o):e.toast({content:t.message,closeDelay:3e3})}catch(i){e.toast({content:"出错",closeDelay:3e3})}},error:function(t){e.toast({content:"提交出错,请联系系统管理员"})},complete:function(n){t.hideIndicator()}})})},t}),define("check/warning-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(t,n,e,o,i){var t=new t,c=Dom7,a=(Template7,"");return t.run=function(){var t=this;a=t.params.uuid,t.setPageTitle("验证标签"),t.render()},t.bindEvents=function(){c(".scan-jump-button").click(function(){""!=a&&void 0!=a?window.location.href=n.to("smart#enter/"+a):window.location.href=n.to("check#index")})},t}); | |
3 | 3 | \ No newline at end of file | ... | ... |
app-wx/web/src/js/check/submit-controller.js
... | ... | @@ -42,6 +42,7 @@ define( |
42 | 42 | utils.toast({content:"请拍照文件上传后再试!"}); |
43 | 43 | return false; |
44 | 44 | } |
45 | + var thiz = $$(this); | |
45 | 46 | $$.ajax({ |
46 | 47 | method : "POST", |
47 | 48 | url: url.to('check/default/check-actived'), |
... | ... | @@ -49,6 +50,7 @@ define( |
49 | 50 | dataType : "json", |
50 | 51 | beforeSend : function(){ |
51 | 52 | me.showIndicator(); |
53 | + thiz.html("验证中…"); | |
52 | 54 | }, |
53 | 55 | success : function(res){ |
54 | 56 | try { |
... | ... | @@ -62,14 +64,16 @@ define( |
62 | 64 | window.location.href = url.to('check#error/' + uuid); |
63 | 65 | } |
64 | 66 | } catch(ex) { |
65 | - utils.toast({content:'出错', closeDelay:3000}); | |
67 | + utils.toast({content:'校验失败,请重拍图片再试!', closeDelay:3000}); | |
66 | 68 | } |
67 | 69 | }, |
68 | 70 | error : function(res){ |
69 | - utils.toast({content:"提交出错,请联系系统管理员"}); | |
71 | + utils.toast({content:"校验失败,请重拍图片再试!"}); | |
72 | + thiz.html("提交验证"); | |
70 | 73 | }, |
71 | 74 | complete : function(res){ |
72 | 75 | me.hideIndicator(); |
76 | + thiz.html("提交验证"); | |
73 | 77 | }, |
74 | 78 | }); |
75 | 79 | }); |
... | ... | @@ -119,11 +123,13 @@ define( |
119 | 123 | utils.toast({content:res.message, closeDelay:3000}); |
120 | 124 | } |
121 | 125 | } catch(ex) { |
122 | - utils.toast({content:'校验失败,请换个图片再试!', closeDelay:3000}); | |
126 | + utils.toast({content:'图片上传失败!', closeDelay:3000}); | |
127 | + me.hideIndicator(); | |
123 | 128 | } |
124 | 129 | }, |
125 | 130 | error : function(res){ |
126 | - utils.toast({content:"校验失败,请换个图片再试!"}); | |
131 | + utils.toast({content:"图片上传失败!"}); | |
132 | + me.hideIndicator(); | |
127 | 133 | }, |
128 | 134 | complete : function(res){ |
129 | 135 | me.hideIndicator(); | ... | ... |
common/helpers/CheckActiveHelper.php
... | ... | @@ -40,20 +40,14 @@ class CheckActiveHelper |
40 | 40 | $curl = curl_init(); |
41 | 41 | curl_setopt($curl, CURLOPT_URL, self::CHECK_URL); |
42 | 42 | // 获取图片内容 |
43 | - $fp = file_get_contents($imageFullPath); // 获取图片的二进制数据 | |
44 | 43 | $filename_root = $_SERVER['DOCUMENT_ROOT']; |
45 | - $path = $filename_root. '/tmp'; | |
46 | - if (!is_dir($path)) { | |
47 | - @mkdir($path, 0777); | |
48 | - } | |
44 | + $path = $filename_root. '/tmp/'. date("Ymd"); | |
49 | 45 | $saveFilePath = $path.'/'.$fileName; |
50 | - file_put_contents($saveFilePath,$fp); | |
51 | 46 | // 设置post数据 |
52 | 47 | $post_data = array( |
53 | 48 | 'fileName' => $fileName, |
54 | 49 | 'token' => $token |
55 | 50 | ); |
56 | - //$image = "data:image/png;base64," . base64_encode($fp); //图片二进制数据base64编码 | |
57 | 51 | if (class_exists('\CURLFile')) { |
58 | 52 | curl_setopt($curl, CURLOPT_SAFE_UPLOAD, true); |
59 | 53 | $post_data['img'] = new \CURLFile(realpath($saveFilePath), '', $fileName);//>=5.5 |
... | ... | @@ -63,8 +57,6 @@ class CheckActiveHelper |
63 | 57 | } |
64 | 58 | $post_data['img'] = '@' . realpath($saveFilePath);//<=5.5 |
65 | 59 | } |
66 | - ob_clean(); | |
67 | - flush(); | |
68 | 60 | curl_setopt($curl, CURLOPT_HEADER, 0); |
69 | 61 | // 如果是https协议 |
70 | 62 | if (stripos(self::CHECK_URL, "https://") !== FALSE) { |
... | ... | @@ -90,6 +82,7 @@ class CheckActiveHelper |
90 | 82 | return ""; |
91 | 83 | // 关闭,释放资源 |
92 | 84 | curl_close($curl); |
85 | + @unlink($saveFilePath); | |
93 | 86 | //返回内容JSON_DECODE |
94 | 87 | return json_decode($callbcak, true); |
95 | 88 | } catch (Exception $e) { | ... | ... |