Commit 73d5dea87b88790647b2af62f80df4e388681fa1
1 parent
7eb4383e
Exists in
master
1.激活结果页实现。
Showing
12 changed files
with
225 additions
and
22 deletions
Show diff stats
app-wx/modules/smart/controllers/DefaultController.php
... | ... | @@ -2,13 +2,14 @@ |
2 | 2 | |
3 | 3 | namespace app\wx\modules\smart\controllers; |
4 | 4 | |
5 | +use Yii; | |
5 | 6 | use common\helpers\ImageManager; |
7 | +use common\helpers\ImageUtils; | |
6 | 8 | use common\helpers\WxHelper; |
7 | 9 | use domain\user\SellerInputRecord; |
10 | +use domain\user\SellerInputRecordRepository; | |
8 | 11 | use domain\user\UserAddressRepository; |
9 | -use Yii; | |
10 | 12 | use yii\base\Exception; |
11 | -use common\helpers\ImageUtils; | |
12 | 13 | use stdClass; |
13 | 14 | |
14 | 15 | /** |
... | ... | @@ -242,6 +243,34 @@ class DefaultController extends BaseController |
242 | 243 | } |
243 | 244 | |
244 | 245 | /** |
246 | + * 查询是否激活 | |
247 | + * @return string | |
248 | + */ | |
249 | + public function actionCheckActive() | |
250 | + { | |
251 | + $e = new stdClass(); | |
252 | + $e->success = 2; | |
253 | + $e->message = ""; | |
254 | + $uuid = Yii::$app->request->post("uuid"); | |
255 | + if (empty($uuid)) { | |
256 | + $e->message = '缺少必要参数!'; | |
257 | + return $this->renderJson($e); | |
258 | + } | |
259 | + // @todo 校验UUID是否有效 2 无效 0 有效未激活 1 有效已激活 | |
260 | + $hasRecord = SellerInputRecordRepository::findOne(["uuid" => $uuid]); | |
261 | + if (empty($hasRecord)) { | |
262 | + $e->success = 0; | |
263 | + $e->message = '暂无激活!'; | |
264 | + return $this->renderJson($e); | |
265 | + } else { | |
266 | + $e->success = 1; | |
267 | + $e->message = '已激活'; | |
268 | + } | |
269 | + return $this->renderJson($e); | |
270 | + | |
271 | + } | |
272 | + | |
273 | + /** | |
245 | 274 | * @param $imgPath |
246 | 275 | * @return null|resource |
247 | 276 | */ | ... | ... |
app-wx/modules/smart/views/default/index.php
... | ... | @@ -23,6 +23,8 @@ $redirectInfo=$this->context->checkUserLevel('', true, "none"); |
23 | 23 | |
24 | 24 | <?=$this->render('pages/index-template', ['asset' => $asset])?> |
25 | 25 | <?=$this->render('pages/enter-template', ['asset' => $asset])?> |
26 | +<?=$this->render('pages/actived-template', ['asset' => $asset])?> | |
27 | +<?=$this->render('pages/error-url-template', ['asset' => $asset])?> | |
26 | 28 | |
27 | 29 | <script> |
28 | 30 | var redirect="<?=$redirectInfo['redirect_url']?>"; | ... | ... |
app-wx/modules/smart/views/default/pages/actived-template.php
0 → 100644
... | ... | @@ -0,0 +1,53 @@ |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Url; | |
4 | + | |
5 | +$baseUrl = Url::base(true); | |
6 | +?> | |
7 | +<style> | |
8 | + #actived .page-content { | |
9 | + background-color: #fff; | |
10 | + } | |
11 | + #actived .scan-image-div { | |
12 | + padding-top: 6.69rem; | |
13 | + text-align: center; | |
14 | + } | |
15 | + #actived .scan-image { | |
16 | + width: 7.78rem; | |
17 | + height: 7.78rem; | |
18 | + margin: 0 auto; | |
19 | + } | |
20 | + #actived .ok-image { | |
21 | + width: 2.78rem; | |
22 | + height: 2.78rem; | |
23 | + position: relative; | |
24 | + margin-left: -1.9rem; | |
25 | + margin-bottom: -0.9rem; | |
26 | + } | |
27 | + #actived .scan-button { | |
28 | + margin: 0 auto; | |
29 | + margin-top: 3rem; | |
30 | + width: 15.75rem; | |
31 | + height: 2.81rem; | |
32 | + text-align: center; | |
33 | + line-height: 2.81rem; | |
34 | + font-size:1.19rem; | |
35 | + font-weight:400; | |
36 | + color:rgba(0,0,0,1); | |
37 | + } | |
38 | +</style> | |
39 | +<script id="actived-template" type="text/template"> | |
40 | + <div class="pages" id="actived"> | |
41 | + <div class="page"> | |
42 | + <div class="page-content"> | |
43 | + <div class="scan-image-div"> | |
44 | + <img src="<?=$baseUrl?>/i/enter/demo_qrcode.png" class="scan-image"/> | |
45 | + <img src="<?=$baseUrl?>/i/enter/circle-yes.png" class="ok-image"/> | |
46 | + </div> | |
47 | + <div class="scan-button"> | |
48 | + 该标签已经激活过了 | |
49 | + </div> | |
50 | + </div> | |
51 | + </div> | |
52 | + </div> | |
53 | +</script> | ... | ... |
app-wx/modules/smart/views/default/pages/error-url-template.php
0 → 100644
... | ... | @@ -0,0 +1,45 @@ |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Url; | |
4 | + | |
5 | +$baseUrl = Url::base(true); | |
6 | +?> | |
7 | +<style> | |
8 | + #error-url .page-content { | |
9 | + background-color: #fff; | |
10 | + } | |
11 | + #error-url .scan-image-div { | |
12 | + padding-top: 6.69rem; | |
13 | + text-align: center; | |
14 | + } | |
15 | + #error-url .scan-image { | |
16 | + width: 7.25rem; | |
17 | + height: 8.21rem; | |
18 | + margin: 0 auto; | |
19 | + } | |
20 | + #error-url .scan-button { | |
21 | + margin: 0 auto; | |
22 | + margin-top: 3rem; | |
23 | + width: 15.75rem; | |
24 | + height: 2.81rem; | |
25 | + text-align: center; | |
26 | + line-height: 2.81rem; | |
27 | + font-size:1.19rem; | |
28 | + font-weight:400; | |
29 | + color:rgba(0,0,0,1); | |
30 | + } | |
31 | +</style> | |
32 | +<script id="error-url-template" type="text/template"> | |
33 | + <div class="pages" id="error-url"> | |
34 | + <div class="page"> | |
35 | + <div class="page-content"> | |
36 | + <div class="scan-image-div"> | |
37 | + <img src="<?=$baseUrl?>/i/enter/error_scan.png" class="scan-image"/> | |
38 | + </div> | |
39 | + <div class="scan-button"> | |
40 | + 链接无效 | |
41 | + </div> | |
42 | + </div> | |
43 | + </div> | |
44 | + </div> | |
45 | +</script> | ... | ... |
app-wx/web/dist/js/smart-app.js
1 | -define("smart-app",["mk7/app"],function(e){var t=Dom7,n=function(){var e=t(".ui-loading-block");0==e.length&&(t(".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 e=document.getElementById("loader-inner"),t=document.createElement("p");t.className="notice",e&&(t.innerHTML='加载速度太慢?试试<a class="link" href="#" onclick="javascript:location.reload();return false;">重新加载</a>',e.appendChild(t))},window.waitingTime))},i=!0;return e.name="smart",e.routes={index:function(){return i=!1,n(),e.runController("index")},"enter/:uuid":function(t){i=!1,n();var o={uuid:t};return e.runController("enter",o)},"*":function(){return i=!1,n(),e.runController("index")}},e}),define("smart/enter-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin","mk7/uploadjs"],function(e,t,n,i,o,s){var e=new e,a=Dom7,r=(Template7,"smart/default/submit"),d=1,c="",l=!1;return e.run=function(){var e=this;e.setPageTitle("防伪信息录入"),o.config({debug:!1,appId:window.$site.appid,timestamp:window.$site.timestamp,nonceStr:window.$site.noncestr,signature:window.$site.signature,jsApiList:["chooseImage","previewImage","uploadImage","getLocalImgData"]}),c=e.params.uuid,e.hideAllNonBaseMenuItem(window.$site),e.render(),e.loadAddress()},e.bindEvents=function(){var e=this;a("#enter").on("click",".upload-btn-cls",function(){var t=a(this).parents("li");e.uploadImg(t)}),a("#enter").on("click",".del-img",function(e){a(this).parent().remove(),d>=a("#image-list").find(".up-img").length&&a(".upload-btn-li").show()}),a("#enter").on("click",".up-img .upload-item",function(e){var t=a(this).attr("data-url");a("#img-mask").remove();var n='<div id="img-mask" style="z-index:2;background:#000;justify-content:center;position: absolute;bottom:0;top:0;width:100%;display:flex;flex-direction: column;align-items: center"><div style="width:100%;"> <img width="100%" src="'+t+'" /></div><div id="set-convert-btn" style="position: absolute;bottom: 0;width: 100%;color: #000;text-align: center;padding: 1rem 0;z-index: 2;background: rgba(255,255,255,0.5)">设置为封面</div></div>';a("#publish").append(n)}),a("#enter").on("click","#dropdown-address",function(e){a(".address-input").val(a(this).html())}),a("#enter").on("click","#set-convert-btn",function(e){var t=a(this).parent().find("img").attr("src");a("#publish .convert-img").remove(),a('div[data-url="'+t+'"]').append('<div class="convert-img">封面</div>'),a("#img-mask").remove()}),a("#enter").on("click","#img-mask, #img-mask img",function(e){a("#img-mask").remove()}),a("#enter").on("click",".submit-btn",function(){if(n.isEmpty(c))return n.toast({content:"进入方式不对,请从新扫码激活",closeDelay:3e3}),!1;var i=a(".upload-item").attr("data"),o=a(".address-input").val(),s=a(".content-cls").val(),d=a(".phone-number").val();return n.isEmpty(i)?(n.toast({content:"请选择商品图片或视频",closeDelay:3e3}),!1):n.isEmpty(o)?(n.toast({content:"请填写发货地址",closeDelay:3e3}),a(".address-input").focus(),!1):n.isEmpty(s)?(n.toast({content:"请填写商家留言",closeDelay:3e3}),a(".content-cls").focus(),!1):n.isMobile(d)?(a(".submit-btn").attr("disabled","disabled"),void a.ajax({method:"POST",url:r,data:{file_data:i,address:o,content:s,phone:d,uuid:c},dataType:"json",beforeSend:function(){e.showIndicator()},success:function(e){e.success?(a(".submit-btn").removeAttr("disabled"),n.toast({content:e.msg}),setTimeout(function(){redirectUrl=t.to("smart#index"),window.location.href=redirectUrl},2e3)):n.toast({content:e.msg})},error:function(e){n.alert(e.responseText)},complete:function(t){a(".submit-btn").removeAttr("disabled"),e.hideIndicator()}})):(n.toast({content:"请填写手机号码",closeDelay:3e3}),a(".phone-number").focus(),!1)})},e.uploadImg=function(e){var t=this;o.ready(function(){o.chooseImage({count:1,sizeType:["compressed"],sourceType:["album","camera"],success:function(n){n.localIds.length>0&&t.upload(n.localIds,e)}})})},e.upload=function(e,i){var s=this;return void 0==e[0]?"":void o.uploadImage({localId:e[0],isShowProgressTips:1,success:function(e){a.ajax({method:"POST",url:t.to("smart/default/update-serviceid"),data:{service_id:e.serverId},dataType:"json",beforeSend:function(){s.showIndicator()},success:function(e){try{if(e.success){var t=e.img_path,o="";0==a("#image-list").find(".convert-img").length&&(o='<div class="convert-img">封面</div>'),a('<li class="upload-li up-img"><div data="'+e.img_path+'" data-url="'+t+'" class="upload-item" style="background-image:url('+e.show_path+')">'+o+'</div><span class="del-img"></span></li>').insertBefore(i),d==a("#image-list").find(".up-img").length&&a(".upload-btn-li").hide(),n.toast({content:e.message,closeDelay:5e3})}else n.toast({content:e.message,closeDelay:5e3})}catch(s){n.toast({content:"出错",closeDelay:5e3})}},error:function(e){n.toast({content:"提交出错,请联系系统管理员"})},complete:function(e){s.hideIndicator()}})},fail:function(e){s.app.alert(JSON.stringify(e))}})},e.loadAddress=function(){var e=this;a.ajax({method:"POST",url:t.to("smart/default/select-address"),data:{},dataType:"json",beforeSend:function(){e.showIndicator()},success:function(e){try{e.success&&""!=e.address&&(l=!0,a("#dropdown-address").html(e.address),a(".address-input").focus(function(e){l&&a("#dropdown-address").show()}),a(".address-input").blur(function(e){l&&a("#dropdown-address").hide()}))}catch(t){}},error:function(e){},complete:function(t){e.hideIndicator()}})},e}),define("smart/index-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(e,t,n,i,o){var e=new e,s=Dom7;Template7;return e.run=function(){var e=this;e.setPageTitle("智能防伪扫码"),o.config({debug:!1,appId:window.$site.appid,timestamp:window.$site.timestamp,nonceStr:window.$site.noncestr,signature:window.$site.signature,jsApiList:["openLocation","getLocation","scanQRCode"]}),e.scanQrcode(),e.render()},e.bindEvents=function(){var e=this;s(".scan-button").click(function(){e.scanQrcode()})},e.scanQrcode=function(){o.ready(function(){o.scanQRCode({needResult:1,desc:"scanQRCode desc",success:function(e){var i=e.resultStr,o=s.parseUrlQuery(i);if(null!=o&&void 0!==o&&null!=o.uuid&&void 0!==o.uuid){var o=o.uuid.split("@");redirectUrl=t.to("smart#enter/"+o[0]),window.location.href=redirectUrl}else n.toast({content:"请扫描智能防伪二维码"})}})})},e}); | |
2 | 1 | \ No newline at end of file |
2 | +define("smart/actived-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(e,t,n,i,o){var e=new e,r=Dom7;Template7;return e.run=function(){var e=this;e.setPageTitle("激活标签"),e.render()},e.bindEvents=function(){r(".back-button").click(function(){window.history.go(-1)})},e}),define("smart-app",["mk7/app"],function(e){var t=Dom7,n=function(){var e=t(".ui-loading-block");0==e.length&&(t(".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 e=document.getElementById("loader-inner"),t=document.createElement("p");t.className="notice",e&&(t.innerHTML='加载速度太慢?试试<a class="link" href="#" onclick="javascript:location.reload();return false;">重新加载</a>',e.appendChild(t))},window.waitingTime))},i=!0;return e.name="smart",e.routes={index:function(){return i=!1,n(),e.runController("index")},"enter/:uuid":function(t){i=!1,n();var o={uuid:t};return e.runController("enter",o)},"*":function(){return i=!1,n(),e.runController("index")},actived:function(){return i=!1,n(),e.runController("actived")},"error-url":function(){return i=!1,n(),e.runController("error-url")}},e}),define("smart/enter-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin","mk7/uploadjs"],function(e,t,n,i,o,r){var e=new e,s=Dom7,a=(Template7,"smart/default/submit"),d=1,c="",l=!1;return e.run=function(){var e=this;e.setPageTitle("防伪信息录入"),o.config({debug:!1,appId:window.$site.appid,timestamp:window.$site.timestamp,nonceStr:window.$site.noncestr,signature:window.$site.signature,jsApiList:["chooseImage","previewImage","uploadImage","getLocalImgData"]}),c=e.params.uuid,e.hideAllNonBaseMenuItem(window.$site),e.render(),e.loadAddress()},e.bindEvents=function(){var e=this;s("#enter").on("click",".upload-btn-cls",function(){var t=s(this).parents("li");e.uploadImg(t)}),s("#enter").on("click",".del-img",function(e){s(this).parent().remove(),d>=s("#image-list").find(".up-img").length&&s(".upload-btn-li").show()}),s("#enter").on("click",".up-img .upload-item",function(e){var t=s(this).attr("data-url");s("#img-mask").remove();var n='<div id="img-mask" style="z-index:2;background:#000;justify-content:center;position: absolute;bottom:0;top:0;width:100%;display:flex;flex-direction: column;align-items: center"><div style="width:100%;"> <img width="100%" src="'+t+'" /></div><div id="set-convert-btn" style="position: absolute;bottom: 0;width: 100%;color: #000;text-align: center;padding: 1rem 0;z-index: 2;background: rgba(255,255,255,0.5)">设置为封面</div></div>';s("#publish").append(n)}),s("#enter").on("click","#dropdown-address",function(e){s(".address-input").val(s(this).html())}),s("#enter").on("click","#set-convert-btn",function(e){var t=s(this).parent().find("img").attr("src");s("#publish .convert-img").remove(),s('div[data-url="'+t+'"]').append('<div class="convert-img">封面</div>'),s("#img-mask").remove()}),s("#enter").on("click","#img-mask, #img-mask img",function(e){s("#img-mask").remove()}),s("#enter").on("click",".submit-btn",function(){if(n.isEmpty(c))return n.toast({content:"进入方式不对,请从新扫码激活",closeDelay:3e3}),!1;var i=s(".upload-item").attr("data"),o=s(".address-input").val(),r=s(".content-cls").val(),d=s(".phone-number").val();return n.isEmpty(i)?(n.toast({content:"请选择商品图片或视频",closeDelay:3e3}),!1):n.isEmpty(o)?(n.toast({content:"请填写发货地址",closeDelay:3e3}),s(".address-input").focus(),!1):n.isEmpty(r)?(n.toast({content:"请填写商家留言",closeDelay:3e3}),s(".content-cls").focus(),!1):n.isMobile(d)?(s(".submit-btn").attr("disabled","disabled"),void s.ajax({method:"POST",url:a,data:{file_data:i,address:o,content:r,phone:d,uuid:c},dataType:"json",beforeSend:function(){e.showIndicator()},success:function(e){e.success?(s(".submit-btn").removeAttr("disabled"),n.toast({content:e.msg}),setTimeout(function(){redirectUrl=t.to("smart#index"),window.location.href=redirectUrl},2e3)):n.toast({content:e.msg})},error:function(e){n.alert(e.responseText)},complete:function(t){s(".submit-btn").removeAttr("disabled"),e.hideIndicator()}})):(n.toast({content:"请填写手机号码",closeDelay:3e3}),s(".phone-number").focus(),!1)})},e.uploadImg=function(e){var t=this;o.ready(function(){o.chooseImage({count:1,sizeType:["compressed"],sourceType:["album","camera"],success:function(n){n.localIds.length>0&&t.upload(n.localIds,e)}})})},e.upload=function(e,i){var r=this;return void 0==e[0]?"":void o.uploadImage({localId:e[0],isShowProgressTips:1,success:function(e){s.ajax({method:"POST",url:t.to("smart/default/update-serviceid"),data:{service_id:e.serverId},dataType:"json",beforeSend:function(){r.showIndicator()},success:function(e){try{if(e.success){var t=e.img_path,o="";0==s("#image-list").find(".convert-img").length&&(o='<div class="convert-img">封面</div>'),s('<li class="upload-li up-img"><div data="'+e.img_path+'" data-url="'+t+'" class="upload-item" style="background-image:url('+e.show_path+')">'+o+'</div><span class="del-img"></span></li>').insertBefore(i),d==s("#image-list").find(".up-img").length&&s(".upload-btn-li").hide(),n.toast({content:e.message,closeDelay:5e3})}else n.toast({content:e.message,closeDelay:5e3})}catch(r){n.toast({content:"出错",closeDelay:5e3})}},error:function(e){n.toast({content:"提交出错,请联系系统管理员"})},complete:function(e){r.hideIndicator()}})},fail:function(e){r.app.alert(JSON.stringify(e))}})},e.loadAddress=function(){var e=this;s.ajax({method:"POST",url:t.to("smart/default/select-address"),data:{},dataType:"json",beforeSend:function(){e.showIndicator()},success:function(e){try{e.success&&""!=e.address&&(l=!0,s("#dropdown-address").html(e.address),s(".address-input").focus(function(e){l&&s("#dropdown-address").show()}),s(".address-input").blur(function(e){l&&s("#dropdown-address").hide()}))}catch(t){}},error:function(e){},complete:function(t){e.hideIndicator()}})},e}),define("smart/error-url-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(e,t,n,i,o){var e=new e,r=Dom7;Template7;return e.run=function(){var e=this;e.setPageTitle("链接无效"),e.render()},e.bindEvents=function(){r(".back-button").click(function(){window.history.go(-1)})},e}),define("smart/index-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(e,t,n,i,o){var e=new e,r=Dom7,s=(Template7,1),a=0,d=2;return e.run=function(){var e=this;e.setPageTitle("智能防伪扫码"),o.config({debug:!1,appId:window.$site.appid,timestamp:window.$site.timestamp,nonceStr:window.$site.noncestr,signature:window.$site.signature,jsApiList:["openLocation","getLocation","scanQRCode"]}),e.scanQrcode(),e.render()},e.bindEvents=function(){var e=this;r(".scan-button").click(function(){e.scanQrcode()})},e.scanQrcode=function(){var e=this;o.ready(function(){o.scanQRCode({needResult:1,desc:"scanQRCode desc",success:function(i){var o=i.resultStr,c=r.parseUrlQuery(o);if(null!=c&&void 0!==c&&null!=c.uuid&&void 0!==c.uuid){var c=c.uuid.split("@"),l=t.to("smart#enter/"+c[0]),u=t.to("smart#actived"),m=t.to("smart#error-url");r.ajax({method:"POST",url:t.to("smart/default/check-active"),data:{uuid:c[0]},dataType:"json",beforeSend:function(){e.showIndicator()},success:function(e){e.success==s?window.location.href=u:e.success==a?window.location.href=l:e.success==d?window.location.href=m:window.location.href=m},error:function(e){},complete:function(t){e.hideIndicator()}})}else n.toast({content:"请扫描智能防伪二维码"})}})})},e}); | |
3 | 3 | \ No newline at end of file | ... | ... |
4.66 KB
36 KB
38.2 KB
... | ... | @@ -0,0 +1,32 @@ |
1 | +/** | |
2 | + * 已激活控制器 | |
3 | + */ | |
4 | +define( | |
5 | + "smart/actived-controller", | |
6 | + [ | |
7 | + 'mk7/controller', | |
8 | + 'mk7/url', | |
9 | + 'mk7/utils', | |
10 | + 'mk7/modals', | |
11 | + 'mk7/jweixin' | |
12 | + ], | |
13 | + function (ctrl, url, utils, modals, jweixin) { | |
14 | + var ctrl = new ctrl(); | |
15 | + var $$ = Dom7; | |
16 | + var t7 = Template7; | |
17 | + | |
18 | + ctrl.run = function () { | |
19 | + var me = this; | |
20 | + me.setPageTitle("激活标签"); | |
21 | + me.render(); | |
22 | + }; | |
23 | + | |
24 | + ctrl.bindEvents = function () { | |
25 | + var me = this; | |
26 | + $$(".back-button").click(function () { | |
27 | + window.history.go(-1); | |
28 | + }); | |
29 | + }; | |
30 | + return ctrl; | |
31 | + } | |
32 | +); | |
0 | 33 | \ No newline at end of file | ... | ... |
app-wx/web/src/js/smart/app.js
... | ... | @@ -53,6 +53,16 @@ define( |
53 | 53 | _autoLoading(); |
54 | 54 | return app.runController('index'); |
55 | 55 | }, |
56 | + 'actived': function () { | |
57 | + fromOutside = false; | |
58 | + _autoLoading(); | |
59 | + return app.runController('actived'); | |
60 | + }, | |
61 | + 'error-url': function () { | |
62 | + fromOutside = false; | |
63 | + _autoLoading(); | |
64 | + return app.runController('error-url'); | |
65 | + }, | |
56 | 66 | } |
57 | 67 | |
58 | 68 | return app; | ... | ... |
... | ... | @@ -0,0 +1,32 @@ |
1 | +/** | |
2 | + * 已激活控制器 | |
3 | + */ | |
4 | +define( | |
5 | + "smart/error-url-controller", | |
6 | + [ | |
7 | + 'mk7/controller', | |
8 | + 'mk7/url', | |
9 | + 'mk7/utils', | |
10 | + 'mk7/modals', | |
11 | + 'mk7/jweixin' | |
12 | + ], | |
13 | + function (ctrl, url, utils, modals, jweixin) { | |
14 | + var ctrl = new ctrl(); | |
15 | + var $$ = Dom7; | |
16 | + var t7 = Template7; | |
17 | + | |
18 | + ctrl.run = function () { | |
19 | + var me = this; | |
20 | + me.setPageTitle("链接无效"); | |
21 | + me.render(); | |
22 | + }; | |
23 | + | |
24 | + ctrl.bindEvents = function () { | |
25 | + var me = this; | |
26 | + $$(".back-button").click(function () { | |
27 | + window.history.go(-1); | |
28 | + }); | |
29 | + }; | |
30 | + return ctrl; | |
31 | + } | |
32 | +); | |
0 | 33 | \ No newline at end of file | ... | ... |
app-wx/web/src/js/smart/index-controller.js
... | ... | @@ -14,6 +14,9 @@ define( |
14 | 14 | var ctrl = new ctrl(); |
15 | 15 | var $$ = Dom7; |
16 | 16 | var t7 = Template7; |
17 | + var HAS_ACTIVED = 1; | |
18 | + var NO_ACTIVED = 0; | |
19 | + var ERROR_URL = 2; | |
17 | 20 | |
18 | 21 | ctrl.run = function () { |
19 | 22 | var me = this; |
... | ... | @@ -39,6 +42,7 @@ define( |
39 | 42 | |
40 | 43 | // 调用扫码功能 |
41 | 44 | ctrl.scanQrcode = function () { |
45 | + var me = this; | |
42 | 46 | jweixin.ready(function(){ |
43 | 47 | jweixin.scanQRCode({ |
44 | 48 | needResult: 1, |
... | ... | @@ -50,37 +54,33 @@ define( |
50 | 54 | if(resultArr != null && resultArr!==undefined && resultArr['uuid']!=null && resultArr['uuid']!==undefined) { |
51 | 55 | //可以用字符或字符串分割 |
52 | 56 | var resultArr=resultArr['uuid'].split('@'); |
53 | - redirectUrl = url.to('smart#enter/'+resultArr[0]); | |
54 | - window.location.href = redirectUrl; | |
55 | - /* $$.ajax({ | |
57 | + var redirectNoActivedUrl = url.to('smart#enter/'+resultArr[0]); | |
58 | + var redirectHasActivedUrl = url.to('smart#actived'); | |
59 | + var redirectErrorUrl = url.to('smart#error-url'); | |
60 | + $$.ajax({ | |
56 | 61 | method : "POST", |
57 | - url: url.to('smart/default/check-uuid'), | |
58 | - data : {qrcode:resultArr['number']}, | |
62 | + url: url.to('smart/default/check-active'), | |
63 | + data : {uuid: resultArr[0]}, | |
59 | 64 | dataType : "json", |
60 | 65 | beforeSend : function(){ |
61 | 66 | me.showIndicator(); |
62 | 67 | }, |
63 | 68 | success : function(res){ |
64 | - | |
65 | - if(res.success){ | |
66 | - that.attr('data-qrcode', resultArr['number']); | |
67 | - $$("#redpack .scanbtn-box").addClass('qrcode-success'); | |
68 | - | |
69 | - $$('.qrcode-note').html('扫码成功'); | |
70 | - $$('.qrcode-note').css('color', '#00C800'); | |
71 | - me.checkBtnColor(); | |
72 | - }else{ | |
73 | - //resultDom='<div class="qrcode-fail">fail</div>'; | |
74 | - $$('.qrcode-note').html(res.msg) | |
75 | - //utils.toast({content:res.msg}); | |
69 | + if (res.success == HAS_ACTIVED) { | |
70 | + window.location.href = redirectHasActivedUrl; | |
71 | + } else if (res.success == NO_ACTIVED) { | |
72 | + window.location.href = redirectNoActivedUrl; | |
73 | + } else if (res.success == ERROR_URL) { | |
74 | + window.location.href = redirectErrorUrl; | |
75 | + } else { | |
76 | + window.location.href = redirectErrorUrl; | |
76 | 77 | } |
77 | - //that.append(resultDom); | |
78 | 78 | }, |
79 | 79 | error : function(e){}, |
80 | 80 | complete : function(e){ |
81 | 81 | me.hideIndicator(); |
82 | 82 | }, |
83 | - });*/ | |
83 | + }); | |
84 | 84 | |
85 | 85 | }else{ |
86 | 86 | utils.toast({content:'请扫描智能防伪二维码'}); | ... | ... |