Commit 6b97b3fa9cb3e07d9500d92134527dba5052a5b1
1 parent
05c36c1d
Exists in
master
1. 扫码次数页面显示功能完善
Showing
7 changed files
with
25 additions
and
8 deletions
Show diff stats
app-wx/modules/check/controllers/DefaultController.php
... | ... | @@ -28,6 +28,7 @@ class DefaultController extends BaseController |
28 | 28 | { |
29 | 29 | $e = new stdClass(); |
30 | 30 | $e->success = 2; |
31 | + $e->scan_count = 0; | |
31 | 32 | $e->message = ""; |
32 | 33 | $uuid = Yii::$app->request->post("uuid"); |
33 | 34 | if (empty($uuid)) { |
... | ... | @@ -37,7 +38,10 @@ class DefaultController extends BaseController |
37 | 38 | // @todo 校验UUID是否有效 2 无效 0 有效未激活 1 有效已激活 |
38 | 39 | $hasRecord = SellerInputRecordRepository::findOne(["uuid" => $uuid]); |
39 | 40 | // 记录扫码次数 |
40 | - ScanRecords::updateCount($uuid); | |
41 | + $scan_count = ScanRecords::updateCount($uuid); | |
42 | + if ($scan_count) { | |
43 | + $e->scan_count = (int) $scan_count; | |
44 | + } | |
41 | 45 | if (empty($hasRecord)) { |
42 | 46 | $e->success = 0; |
43 | 47 | $e->message = '暂无激活!'; | ... | ... |
... | ... | @@ -0,0 +1 @@ |
1 | +define("check-app",["mk7/app"],function(n){var e=Dom7,i=function(){var n=e(".ui-loading-block");0==n.length&&(e(".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 n=document.getElementById("loader-inner"),e=document.createElement("p");e.className="notice",n&&(e.innerHTML='加载速度太慢?试试<a class="link" href="#" onclick="javascript:location.reload();return false;">重新加载</a>',n.appendChild(e))},window.waitingTime))},o=!0;return n.name="check",n.routes={index:function(){return o=!1,i(),n.runController("index")},"*":function(){return o=!1,i(),n.runController("index")},"scan-count/:uuid/:scancount":function(e,c){return o=!1,i(),n.runController("scan-count",{uuid:e,scancount:c})}},n}),define("check/index-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,e,i,o,c){var n=new n,t=Dom7,r=(Template7,1),a=0,u=2,s=0;return n.run=function(){var n=this;n.setPageTitle("验证标签"),c.config({debug:!1,appId:window.$site.appid,timestamp:window.$site.timestamp,nonceStr:window.$site.noncestr,signature:window.$site.signature,jsApiList:["openLocation","getLocation","scanQRCode"]}),n.scanQrcode(),n.render()},n.bindEvents=function(){var n=this;t(".scan-button").click(function(){n.scanQrcode()})},n.scanQrcode=function(){var n=this;c.ready(function(){c.scanQRCode({needResult:1,desc:"scanQRCode desc",success:function(o){var c=o.resultStr,d=t.parseUrlQuery(c);if(null!=d&&void 0!==d&&null!=d.uuid&&void 0!==d.uuid){var d=d.uuid.split("@"),l=e.to("smart#enter/"+d[0]),m=e.to("check#scan-count/"+d[0]+"/"+s),f=e.to("check#error-url");t.ajax({method:"POST",url:e.to("check/default/check-active"),data:{uuid:d[0]},dataType:"json",beforeSend:function(){n.showIndicator()},success:function(n){s=n.scan_count,m=e.to("check#scan-count/"+d[0]+"/"+s),n.success==r?window.location.href=m:n.success==a?window.location.href=l:n.success==u?window.location.href=f:window.location.href=f},error:function(n){},complete:function(e){n.hideIndicator()}})}else i.toast({content:"请扫描智能防伪二维码"})}})})},n}),define("check/scan-count-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,e,i,o,c){var n=new n,t=Dom7,r=(Template7,0),a="";return n.run=function(){var n=this;r=parseInt(n.params.scancount),a=n.params.uuid,n.setPageTitle("验证标签"),n.render(),t(".count-num").html(r)},n.bindEvents=function(){t(".scan-button").click(function(){})},n}); | |
0 | 2 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1 @@ |
1 | +define("site-app",["mk7/app"],function(n){return n.name="site",n.routes={"*":function(){return n.runController("index")}},n}),define("site/index-controller",["mk7/controller"],function(n){var n=new n;Dom7;return n.run=function(){var n=this;n.render()},n.bindEvents=function(){console.log("bindEvents")},n}); | |
0 | 2 | \ No newline at end of file | ... | ... |
app-wx/web/src/js/check/app.js
... | ... | @@ -45,10 +45,10 @@ define( |
45 | 45 | _autoLoading(); |
46 | 46 | return app.runController('index'); |
47 | 47 | }, |
48 | - 'scan-count': function () { | |
48 | + 'scan-count/:uuid/:scancount': function (uuid, scancount) { | |
49 | 49 | fromOutside = false; |
50 | 50 | _autoLoading(); |
51 | - return app.runController('scan-count'); | |
51 | + return app.runController('scan-count',{uuid: uuid, scancount: scancount}); | |
52 | 52 | }, |
53 | 53 | } |
54 | 54 | ... | ... |
app-wx/web/src/js/check/index-controller.js
... | ... | @@ -17,6 +17,7 @@ define( |
17 | 17 | var HAS_ACTIVED = 1; |
18 | 18 | var NO_ACTIVED = 0; |
19 | 19 | var ERROR_URL = 2; |
20 | + var SCAN_COUNT = 0; | |
20 | 21 | |
21 | 22 | ctrl.run = function () { |
22 | 23 | var me = this; |
... | ... | @@ -55,7 +56,7 @@ define( |
55 | 56 | //可以用字符或字符串分割 |
56 | 57 | var resultArr=resultArr['uuid'].split('@'); |
57 | 58 | var redirectNoActivedUrl = url.to('smart#enter/'+resultArr[0]); |
58 | - var redirectHasActivedUrl = url.to('check#scan-count'); | |
59 | + var redirectHasActivedUrl = url.to('check#scan-count/' + resultArr[0] + '/' + SCAN_COUNT); | |
59 | 60 | var redirectErrorUrl = url.to('check#error-url'); |
60 | 61 | $$.ajax({ |
61 | 62 | method : "POST", |
... | ... | @@ -66,6 +67,8 @@ define( |
66 | 67 | me.showIndicator(); |
67 | 68 | }, |
68 | 69 | success : function(res){ |
70 | + SCAN_COUNT = res.scan_count; | |
71 | + redirectHasActivedUrl = url.to('check#scan-count/' + resultArr[0] + '/' + SCAN_COUNT); | |
69 | 72 | if (res.success == HAS_ACTIVED) { |
70 | 73 | window.location.href = redirectHasActivedUrl; |
71 | 74 | } else if (res.success == NO_ACTIVED) { | ... | ... |
app-wx/web/src/js/check/scan-count-controller.js
... | ... | @@ -14,11 +14,16 @@ define( |
14 | 14 | var ctrl = new ctrl(); |
15 | 15 | var $$ = Dom7; |
16 | 16 | var t7 = Template7; |
17 | + var scancount = 0; | |
18 | + var uuid = ""; | |
17 | 19 | |
18 | 20 | ctrl.run = function () { |
19 | 21 | var me = this; |
22 | + scancount = parseInt(me.params.scancount); | |
23 | + uuid = me.params.uuid; | |
20 | 24 | me.setPageTitle("验证标签"); |
21 | 25 | me.render(); |
26 | + $$(".count-num").html(scancount); | |
22 | 27 | }; |
23 | 28 | |
24 | 29 | ctrl.bindEvents = function () { | ... | ... |
domain/smart/ScanRecords.php
... | ... | @@ -21,11 +21,11 @@ class ScanRecords |
21 | 21 | try { |
22 | 22 | $canRecordsModel = Yii::createObject(ScanRecordsModel::className()); |
23 | 23 | $canRecordsModel->uuid = trim($uuid); |
24 | - $canRecordsModel->scan_count = 0; | |
24 | + $canRecordsModel->scan_count = 1; | |
25 | 25 | $result = $canRecordsModel->save(); |
26 | 26 | |
27 | 27 | if($result) { |
28 | - $result = $canRecordsModel->id; | |
28 | + $result = $canRecordsModel; | |
29 | 29 | } else { |
30 | 30 | $result = false; |
31 | 31 | } |
... | ... | @@ -45,12 +45,15 @@ class ScanRecords |
45 | 45 | $scanRecordsModel = ScanRecordsModel::findOne(["uuid" => $uuid]); |
46 | 46 | if (empty($scanRecordsModel)) { |
47 | 47 | $scanRecordsModel = self::create($uuid); |
48 | + if (!$scanRecordsModel) { | |
49 | + return false; | |
50 | + } | |
48 | 51 | } |
49 | - $scanRecordsModel->scan_count += $scanRecordsModel->scan_count; | |
52 | + $scanRecordsModel->scan_count = $scanRecordsModel->scan_count + 1; | |
50 | 53 | $result = $scanRecordsModel->save(); |
51 | 54 | |
52 | 55 | if($result) { |
53 | - $result = $scanRecordsModel->id; | |
56 | + $result = $scanRecordsModel->scan_count; | |
54 | 57 | } else { |
55 | 58 | $result = false; |
56 | 59 | } | ... | ... |