Commit 6150880870e8f2b1506cfb70f17168356271da88
1 parent
39c1dee7
Exists in
master
1.添加提取码录入功能和校验成功失败页面。
Showing
18 changed files
with
625 additions
and
6 deletions
Show diff stats
app-wx/modules/check/controllers/DefaultController.php
... | ... | @@ -2,6 +2,8 @@ |
2 | 2 | |
3 | 3 | namespace app\wx\modules\check\controllers; |
4 | 4 | |
5 | +use common\helpers\ImageManager; | |
6 | +use common\helpers\WxHelper; | |
5 | 7 | use Yii; |
6 | 8 | use domain\smart\ScanRecords; |
7 | 9 | use domain\smart\SellerInputRecordRepository; |
... | ... | @@ -53,4 +55,134 @@ class DefaultController extends BaseController |
53 | 55 | return $this->renderJson($e); |
54 | 56 | |
55 | 57 | } |
58 | + | |
59 | + /** | |
60 | + * 检查是否激活 | |
61 | + * @return string | |
62 | + */ | |
63 | + public function actionCheckActived() | |
64 | + { | |
65 | + $e = new stdClass(); | |
66 | + $e->success = false; | |
67 | + $e->scan_count = 0; | |
68 | + $e->message = ""; | |
69 | + $uploadFile = Yii::$app->request->post("upload_file"); | |
70 | + if (empty($uploadFile)) { | |
71 | + $e->message = '缺少必要参数!'; | |
72 | + return $this->renderJson($e); | |
73 | + } | |
74 | + // 获取图片路径 | |
75 | + //$uploadFile = ImageManager::getUrl($uploadFile); | |
76 | + | |
77 | + // @todo 校验UUID是否有效 2 无效 0 有效未激活 1 有效已激活 | |
78 | + $hasRecord = true; | |
79 | + if (!$hasRecord) { | |
80 | + $e->success = false; | |
81 | + $e->message = '暂无激活!'; | |
82 | + return $this->renderJson($e); | |
83 | + } else { | |
84 | + $e->success = true; | |
85 | + $e->message = '已激活'; | |
86 | + } | |
87 | + return $this->renderJson($e); | |
88 | + | |
89 | + } | |
90 | + | |
91 | + /** | |
92 | + * 上传微信图片 | |
93 | + * @return string | |
94 | + */ | |
95 | + public function actionUpdateServiceid() | |
96 | + { | |
97 | + $e = new stdClass(); | |
98 | + $e->success = false; | |
99 | + $e->img_path = ""; | |
100 | + $e->show_path = ""; | |
101 | + $e->message = ''; | |
102 | + $wechat = WxHelper::getWxPHPSDK(); | |
103 | + $uploadFile = $this->request->post('service_id'); | |
104 | + if (empty($uploadFile)) { | |
105 | + $e->message = '请上传商品图片或视频!'; | |
106 | + return $this->renderJson($e); | |
107 | + } | |
108 | + $filename = $this->saveWxImgToRemoveServer($wechat, $uploadFile); | |
109 | + if (!$filename) { | |
110 | + $e->message = '保存失败!'; | |
111 | + return $this->renderJson($e); | |
112 | + } | |
113 | + $e->show_path = ImageManager::getUrl($filename, ImageManager::$STYLE_180); | |
114 | + $e->img_path = $filename; | |
115 | + $e->success = true; | |
116 | + $e->message = '上传成功'; | |
117 | + return $this->renderJson($e); | |
118 | + } | |
119 | + | |
120 | + /** | |
121 | + * @param $wechat 微信基础类 | |
122 | + * @param string $tr 微信公众号的 media_id | |
123 | + * @return bool|string 返回保存到数据库里面的文件名称是的带URL的,同时会把图片传到阿里云的图片服务器上面 | |
124 | + * $type 这个是类型,根据图片是头像还是身份证来存放,$stat_path 必须根据$type 而改变 | |
125 | + */ | |
126 | + private function saveWxImgToRemoveServer($wechat, $tr = '') | |
127 | + { | |
128 | + if (empty($tr)) { | |
129 | + return false; | |
130 | + } | |
131 | + | |
132 | + $qrcodeArr = $wechat->getMedia($tr, 1); | |
133 | + if (empty($qrcodeArr['body'])) { | |
134 | + return false; | |
135 | + } | |
136 | + $filename_root = $_SERVER['DOCUMENT_ROOT']; | |
137 | + $path = $filename_root . '/tmp'; | |
138 | + | |
139 | + if (!is_dir($path)) { | |
140 | + @mkdir($path, 0777); | |
141 | + } | |
142 | + $dir = $path; | |
143 | + $tt = time(); | |
144 | + $filename = 'smart_'.$tt.md5($tr).'.jpg'; | |
145 | + $saveFilePath = $dir.'/'.$filename; | |
146 | + | |
147 | + $local_file = fopen($saveFilePath, 'w'); | |
148 | + if (false !== $local_file) { | |
149 | + if (false !== fwrite($local_file, $qrcodeArr['body'])) { | |
150 | + fclose($local_file); | |
151 | + } | |
152 | + } | |
153 | + $user_id = $userId = $this->getUserId(); | |
154 | + $stat_path = ImageManager::getSmartCheckImgPath($user_id, 'smart_' . $tt . md5($tr)); | |
155 | + ImageManager::add($saveFilePath, $stat_path); | |
156 | + | |
157 | + return $stat_path; | |
158 | + } | |
159 | + | |
160 | + /** | |
161 | + * 获取消息 | |
162 | + * @return string | |
163 | + */ | |
164 | + public function actionGetInfo() | |
165 | + { | |
166 | + $e = new stdClass(); | |
167 | + $e->success = false; | |
168 | + $e->message = ''; | |
169 | + $numberCode = $this->request->post('number_code'); | |
170 | + $uuid = $this->request->post('uuid'); | |
171 | + if (empty($numberCode) || empty($uuid)) { | |
172 | + $e->message = '缺少必要参数!'; | |
173 | + return $this->renderJson($e); | |
174 | + } | |
175 | + $hasRecord = SellerInputRecordRepository::findOne(["uuid" => $uuid]); | |
176 | + if (empty($hasRecord)) { | |
177 | + $e->message = '该二维码暂未激活!'; | |
178 | + return $this->renderJson($e); | |
179 | + } | |
180 | + if ($hasRecord->extraction_code != $numberCode) { | |
181 | + $e->message = '提取码错误!'; | |
182 | + return $this->renderJson($e); | |
183 | + } | |
184 | + $e->success = true; | |
185 | + $e->message = '获取成功!'; | |
186 | + return $this->renderJson($e); | |
187 | + } | |
56 | 188 | } |
57 | 189 | \ No newline at end of file | ... | ... |
app-wx/modules/check/views/default/index.php
... | ... | @@ -24,6 +24,9 @@ $redirectInfo=$this->context->checkUserLevel('', true, "none"); |
24 | 24 | <?=$this->render('pages/index-template', ['asset' => $asset])?> |
25 | 25 | <?=$this->render('pages/scan-count-template', ['asset' => $asset])?> |
26 | 26 | <?=$this->render('pages/warning-template', ['asset' => $asset])?> |
27 | +<?=$this->render('pages/submit-template', ['asset' => $asset])?> | |
28 | +<?=$this->render('pages/error-template', ['asset' => $asset])?> | |
29 | +<?=$this->render('pages/success-template', ['asset' => $asset])?> | |
27 | 30 | |
28 | 31 | <script> |
29 | 32 | var redirect="<?=$redirectInfo['redirect_url']?>"; | ... | ... |
app-wx/modules/check/views/default/pages/error-template.php
0 → 100644
... | ... | @@ -0,0 +1,57 @@ |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Url; | |
4 | + | |
5 | +$baseUrl = Url::base(true); | |
6 | +?> | |
7 | +<style> | |
8 | + #error .page-content { | |
9 | + background-color: #fff; | |
10 | + } | |
11 | + #error .scan-image-div { | |
12 | + padding-top: 2.31rem; | |
13 | + text-align: center; | |
14 | + } | |
15 | + #error .scan-image { | |
16 | + width: 7.25rem; | |
17 | + height: 8.41rem; | |
18 | + margin: 0 auto; | |
19 | + } | |
20 | + #error .scan-button { | |
21 | + margin: 0 auto; | |
22 | + width: 15.75rem; | |
23 | + height: 2.81rem; | |
24 | + text-align: center; | |
25 | + line-height: 2.81rem; | |
26 | + font-size:1.19rem; | |
27 | + font-weight:400; | |
28 | + color:rgba(0,0,0,1); | |
29 | + } | |
30 | + #error .scan-tip { | |
31 | + margin: 0 auto; | |
32 | + width: 15.75rem; | |
33 | + height: 2.81rem; | |
34 | + text-align: center; | |
35 | + font-size:1rem; | |
36 | + font-weight:400; | |
37 | + color:rgba(106,106,106,1); | |
38 | + line-height:1.5rem; | |
39 | + } | |
40 | +</style> | |
41 | +<script id="error-template" type="text/template"> | |
42 | + <div class="pages" id="error"> | |
43 | + <div class="page"> | |
44 | + <div class="page-content"> | |
45 | + <div class="scan-image-div"> | |
46 | + <img src="<?=$baseUrl?>/i/check/error.png" class="scan-image"/> | |
47 | + </div> | |
48 | + <div class="scan-button"> | |
49 | + 防伪验证失败 | |
50 | + </div> | |
51 | + <div class="scan-tip"> | |
52 | + 风险提示:标签被篡改 | |
53 | + </div> | |
54 | + </div> | |
55 | + </div> | |
56 | + </div> | |
57 | +</script> | ... | ... |
app-wx/modules/check/views/default/pages/submit-template.php
0 → 100644
... | ... | @@ -0,0 +1,72 @@ |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Url; | |
4 | + | |
5 | +$baseUrl = Url::base(true); | |
6 | +?> | |
7 | +<style> | |
8 | + #submit .page-content { | |
9 | + background-color: #fff; | |
10 | + } | |
11 | + #submit .scan-image-div { | |
12 | + padding-top: 3.52rem; | |
13 | + text-align: center; | |
14 | + } | |
15 | + #submit .scan-image { | |
16 | + width: 7.78rem; | |
17 | + height: 7.78rem; | |
18 | + margin: 0 auto; | |
19 | + } | |
20 | + #submit .scan-button { | |
21 | + margin: 0 auto; | |
22 | + margin-top: 3rem; | |
23 | + width: 15.75rem; | |
24 | + height: 2.81rem; | |
25 | + background: url(<?=$baseUrl?>/i/check/submit_btn.png) center no-repeat #ffffff; | |
26 | + color: #FFF; | |
27 | + text-align: center; | |
28 | + line-height: 2.81rem; | |
29 | + font-size:1.06rem; | |
30 | + font-weight:400; | |
31 | + } | |
32 | + #submit .title-pic { | |
33 | + font-size:1.13rem; | |
34 | + font-weight:500; | |
35 | + color:rgba(0,0,0,1); | |
36 | + line-height:1.5rem; | |
37 | + } | |
38 | + #submit .div-tip { | |
39 | + width: 10rem; | |
40 | + height: 10rem; | |
41 | + margin: 0 auto; | |
42 | + margin-top: 2.5rem; | |
43 | + text-align: center; | |
44 | + } | |
45 | + #submit .tip-font { | |
46 | + font-size:0.88rem; | |
47 | + font-weight:400; | |
48 | + color:rgba(189,189,189,1); | |
49 | + line-height:1.5rem; | |
50 | + } | |
51 | +</style> | |
52 | +<script id="submit-template" type="text/template"> | |
53 | + <div class="pages" id="submit"> | |
54 | + <div class="page"> | |
55 | + <div class="page-content"> | |
56 | + <div class="scan-image-div"> | |
57 | + <img src="<?=$baseUrl?>/i/check/upload_phone.png" class="scan-image"/> | |
58 | + <div class="title-pic">点击拍照二维码</div> | |
59 | + </div> | |
60 | + <div class="div-tip"> | |
61 | + <span class="tip-font"> | |
62 | + 请移动手机靠近二维码<br> | |
63 | + 放大二维码区域并对焦 | |
64 | + </span> | |
65 | + </div> | |
66 | + <div class="scan-button"> | |
67 | + 提交验证 | |
68 | + </div> | |
69 | + </div> | |
70 | + </div> | |
71 | + </div> | |
72 | +</script> | ... | ... |
app-wx/modules/check/views/default/pages/success-template.php
0 → 100644
... | ... | @@ -0,0 +1,81 @@ |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Url; | |
4 | + | |
5 | +$baseUrl = Url::base(true); | |
6 | +?> | |
7 | +<style> | |
8 | + #success .scan-image-div { | |
9 | + padding-top: 2.31rem; | |
10 | + text-align: center; | |
11 | + } | |
12 | + #success .scan-image { | |
13 | + width: 7.25rem; | |
14 | + height: 8.41rem; | |
15 | + margin: 0 auto; | |
16 | + } | |
17 | + #success .scan-button { | |
18 | + margin: 0 auto; | |
19 | + width: 15.75rem; | |
20 | + height: 2.81rem; | |
21 | + text-align: center; | |
22 | + line-height: 2.81rem; | |
23 | + font-size:1.19rem; | |
24 | + font-weight:400; | |
25 | + color:rgba(0,0,0,1); | |
26 | + padding-bottom: 2rem; | |
27 | + } | |
28 | + #success .scan-tip { | |
29 | + margin: 0 auto; | |
30 | + width: 85%; | |
31 | + height: 2.81rem; | |
32 | + text-align: left; | |
33 | + font-size:1rem; | |
34 | + font-weight:400; | |
35 | + color:rgba(51,51,51,1); | |
36 | + line-height:1.44rem; | |
37 | + padding: 0.5rem 0; | |
38 | + } | |
39 | + #success .btn-submit{ | |
40 | + width:30%; | |
41 | + text-align:center; | |
42 | + height:2.81rem; | |
43 | + line-height:2.81rem; | |
44 | + background:rgba(0,188,112,1); | |
45 | + border-radius:0rem 0rem 0rem 0rem; | |
46 | + float: left; | |
47 | + font-size:1rem; | |
48 | + font-weight:400; | |
49 | + color:rgba(255,255,255,1); | |
50 | + } | |
51 | + #success .input-num { | |
52 | + line-height: 2rem;height: 2.41rem;width: 65%; background-color: #fff;float: left;padding-left: 0.5rem;font-size:1rem; | |
53 | + font-weight:400; | |
54 | + /*color:rgba(177,177,177,1);*/ | |
55 | + } | |
56 | +</style> | |
57 | +<script id="success-template" type="text/template"> | |
58 | + <div class="pages" id="success"> | |
59 | + <div class="page"> | |
60 | + <div class="page-content"> | |
61 | + <div style="background: #fff"> | |
62 | + <div class="scan-image-div"> | |
63 | + <img src="<?=$baseUrl?>/i/check/success.png" class="scan-image"/> | |
64 | + </div> | |
65 | + <div class="scan-button"> | |
66 | + 防伪验证通过 | |
67 | + </div> | |
68 | + </div> | |
69 | + <div style="background: #fff; margin-top:0.5rem"> | |
70 | + <div class="scan-tip" style="padding-top: 1rem"> | |
71 | + 您可以继续输入商品提取码,查看商家录入的隐私信息。 | |
72 | + </div> | |
73 | + <div class="scan-tip" style="padding-bottom: 1rem"> | |
74 | + <input class="input-num" placeholder="输入商品提取码"/> | |
75 | + <span class="btn-submit">点击查看</span> | |
76 | + </div> | |
77 | + </div> | |
78 | + </div> | |
79 | + </div> | |
80 | + </div> | |
81 | +</script> | ... | ... |
app-wx/web/dist/js/check-app.js
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,t){return o=!1,i(),n.runController("scan-count",{uuid:e,scancount:t})},"warning/:uuid":function(e){return o=!1,i(),n.runController("warning",{uuid:e})}},n}),define("check/index-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,e,i,o,t){var n=new n,c=Dom7,r=(Template7,1),a=0,u=2,d=0;return n.run=function(){var n=this;n.setPageTitle("验证标签"),t.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;c(".scan-button").click(function(){n.scanQrcode()})},n.scanQrcode=function(){var n=this;t.ready(function(){t.scanQRCode({needResult:1,desc:"scanQRCode desc",success:function(o){var t=o.resultStr,s=c.parseUrlQuery(t);if(null!=s&&void 0!==s&&null!=s.uuid&&void 0!==s.uuid){var s=s.uuid.split("@"),l=e.to("smart#enter/"+s[0]),m=e.to("check#scan-count/"+s[0]+"/"+d),w=e.to("check#warning/"+s[0]);c.ajax({method:"POST",url:e.to("check/default/check-active"),data:{uuid:s[0]},dataType:"json",beforeSend:function(){n.showIndicator()},success:function(n){d=n.scan_count,m=e.to("check#scan-count/"+s[0]+"/"+d),n.success==r?window.location.href=m:n.success==a?window.location.href=l:n.success==u?window.location.href=w:window.location.href=w},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,t){var n=new n,c=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(),c(".count-num").html(r)},n.bindEvents=function(){c(".scan-button").click(function(){})},n}),define("check/warning-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,e,i,o,t){var n=new n,c=Dom7,r=(Template7,"");return n.run=function(){var n=this;r=n.params.uuid,n.setPageTitle("验证标签"),n.render()},n.bindEvents=function(){c(".scan-jump-button").click(function(){""!=r&&void 0!=r?window.location.href=e.to("smart#enter/"+r):window.location.href=e.to("check#index")})},n}); | |
2 | 1 | \ No newline at end of file |
2 | +define("check-app",["mk7/app"],function(n){var e=Dom7,t=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,t(),n.runController("index")},"*":function(){return o=!1,t(),n.runController("index")},"scan-count/:uuid/:scancount":function(e,i){return o=!1,t(),n.runController("scan-count",{uuid:e,scancount:i})},"warning/:uuid":function(e){return o=!1,t(),n.runController("warning",{uuid:e})},"submit/:uuid":function(e){return o=!1,t(),n.runController("submit",{uuid:e})},"error/:uuid":function(e){return o=!1,t(),n.runController("error",{uuid:e})},"success/:uuid":function(e){return o=!1,t(),n.runController("success",{uuid:e})}},n}),define("check/error-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,e,t,o,i){var n=new n,c=Dom7;Template7;return n.run=function(){var n=this;n.setPageTitle("验证结果"),n.render()},n.bindEvents=function(){c(".back-button").click(function(){window.history.go(-1)})},n}),define("check/index-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,e,t,o,i){var n=new n,c=Dom7,r=(Template7,1),a=0,u=2,s=0;return n.run=function(){var n=this;n.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"]}),n.scanQrcode(),n.render()},n.bindEvents=function(){var n=this;c(".scan-button").click(function(){n.scanQrcode()})},n.scanQrcode=function(){var n=this;i.ready(function(){i.scanQRCode({needResult:1,desc:"scanQRCode desc",success:function(o){var i=o.resultStr,d=c.parseUrlQuery(i);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#warning/"+d[0]);c.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 t.toast({content:"请扫描智能防伪二维码"})}})})},n}),define("check/scan-count-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,e,t,o,i){var n=new n,c=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(),c(".count-num").html(r)},n.bindEvents=function(){c(".scan-button").click(function(){""!=a&&void 0!=a?window.location.href=e.to("check#submit/"+a):window.location.href=e.to("check#index")})},n}),define("check/submit-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,e,t,o,i){var n=new n,c=Dom7,r=(Template7,"");return n.run=function(){var n=this;r=n.params.uuid,n.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"]}),n.render()},n.bindEvents=function(){var n=this;c(".scan-image").click(function(){n.uploadImg(c(this))}),c(".scan-button").click(function(){var o=c(".scan-image").attr("data");return t.isEmpty(o)?(t.toast({content:"请拍照文件上传后再试!"}),!1):void c.ajax({method:"POST",url:e.to("check/default/check-actived"),data:{upload_file:o},dataType:"json",beforeSend:function(){n.showIndicator()},success:function(n){try{n.success?window.location.href=e.to("check#success/"+r):window.location.href=e.to("check#error/"+r)}catch(o){t.toast({content:"出错",closeDelay:3e3})}},error:function(n){t.toast({content:"提交出错,请联系系统管理员"})},complete:function(e){n.hideIndicator()}})})},n.uploadImg=function(n){var e=this;i.ready(function(){i.chooseImage({count:1,sizeType:["compressed"],sourceType:["album","camera"],success:function(t){t.localIds.length>0&&e.upload(t.localIds,n)}})})},n.upload=function(n,o){var r=this;return void 0==n[0]?"":void i.uploadImage({localId:n[0],isShowProgressTips:1,success:function(n){c.ajax({method:"POST",url:e.to("check/default/update-serviceid"),data:{service_id:n.serverId},dataType:"json",beforeSend:function(){r.showIndicator()},success:function(n){try{if(n.success){var e=n.img_path;o.attr("data",e),o.attr("src",n.show_path)}else t.toast({content:n.message,closeDelay:3e3})}catch(i){t.toast({content:"出错",closeDelay:3e3})}},error:function(n){t.toast({content:"提交出错,请联系系统管理员"})},complete:function(n){r.hideIndicator()}})},fail:function(n){r.app.alert(JSON.stringify(n))}})},n}),define("check/success-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,e,t,o,i){var n=new n,c=Dom7;Template7;return n.run=function(){var n=this;n.setPageTitle("验证结果"),n.render()},n.bindEvents=function(){c(".back-button").click(function(){window.history.go(-1)})},n}),define("check/warning-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,e,t,o,i){var n=new n,c=Dom7,r=(Template7,"");return n.run=function(){var n=this;r=n.params.uuid,n.setPageTitle("验证标签"),n.render()},n.bindEvents=function(){c(".scan-jump-button").click(function(){""!=r&&void 0!=r?window.location.href=e.to("smart#enter/"+r):window.location.href=e.to("check#index")})},n}); | |
3 | 3 | \ No newline at end of file | ... | ... |
app-wx/web/dist/js/smart-app.js
1 | -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}); | |
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()}else n.toast({content:e.message,closeDelay:3e3})}catch(r){n.toast({content:"出错",closeDelay:3e3})}},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 | ... | ... |
38.2 KB
6.57 KB
42.9 KB
53.2 KB
app-wx/web/src/js/check/app.js
... | ... | @@ -55,6 +55,21 @@ define( |
55 | 55 | _autoLoading(); |
56 | 56 | return app.runController('warning',{uuid: uuid}); |
57 | 57 | }, |
58 | + 'submit/:uuid': function (uuid) { | |
59 | + fromOutside = false; | |
60 | + _autoLoading(); | |
61 | + return app.runController('submit',{uuid: uuid}); | |
62 | + }, | |
63 | + 'error/:uuid': function (uuid) { | |
64 | + fromOutside = false; | |
65 | + _autoLoading(); | |
66 | + return app.runController('error',{uuid: uuid}); | |
67 | + }, | |
68 | + 'success/:uuid': function (uuid) { | |
69 | + fromOutside = false; | |
70 | + _autoLoading(); | |
71 | + return app.runController('success',{uuid: uuid}); | |
72 | + }, | |
58 | 73 | } |
59 | 74 | |
60 | 75 | return app; | ... | ... |
... | ... | @@ -0,0 +1,32 @@ |
1 | +/** | |
2 | + * 验证结果控制器 | |
3 | + */ | |
4 | +define( | |
5 | + "check/error-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/check/scan-count-controller.js
... | ... | @@ -29,6 +29,11 @@ define( |
29 | 29 | ctrl.bindEvents = function () { |
30 | 30 | var me = this; |
31 | 31 | $$(".scan-button").click(function () { |
32 | + if (uuid != "" && uuid != undefined) { | |
33 | + window.location.href = url.to('check#submit/' + uuid); | |
34 | + } else { | |
35 | + window.location.href = url.to('check#index'); | |
36 | + } | |
32 | 37 | }); |
33 | 38 | }; |
34 | 39 | ... | ... |
... | ... | @@ -0,0 +1,137 @@ |
1 | +/** | |
2 | + * 校验控制器 | |
3 | + */ | |
4 | +define( | |
5 | + "check/submit-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 | + var uuid = ""; | |
18 | + | |
19 | + ctrl.run = function () { | |
20 | + var me = this; | |
21 | + uuid = me.params.uuid; | |
22 | + me.setPageTitle("验证标签"); | |
23 | + jweixin.config({ | |
24 | + debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 | |
25 | + appId: window.$site.appid, // 必填,公众号的唯一标识 | |
26 | + timestamp: window.$site.timestamp, // 必填,生成签名的时间戳 | |
27 | + nonceStr: window.$site.noncestr, // 必填,生成签名的随机串 | |
28 | + signature: window.$site.signature,// 必填,签名,见附录1 | |
29 | + jsApiList: ['chooseImage','previewImage','uploadImage', 'getLocalImgData'] | |
30 | + }); | |
31 | + me.render(); | |
32 | + }; | |
33 | + | |
34 | + ctrl.bindEvents = function () { | |
35 | + var me = this; | |
36 | + $$(".scan-image").click(function () { | |
37 | + me.uploadImg($$(this)); | |
38 | + }); | |
39 | + $$(".scan-button").click(function () { | |
40 | + var uploadFile = $$(".scan-image").attr("data"); | |
41 | + if (utils.isEmpty(uploadFile)) { | |
42 | + utils.toast({content:"请拍照文件上传后再试!"}); | |
43 | + return false; | |
44 | + } | |
45 | + $$.ajax({ | |
46 | + method : "POST", | |
47 | + url: url.to('check/default/check-actived'), | |
48 | + data : {upload_file: uploadFile}, | |
49 | + dataType : "json", | |
50 | + beforeSend : function(){ | |
51 | + me.showIndicator(); | |
52 | + }, | |
53 | + success : function(res){ | |
54 | + try { | |
55 | + if(res.success) { | |
56 | + window.location.href = url.to('check#success/' + uuid); | |
57 | + } else { | |
58 | + window.location.href = url.to('check#error/' + uuid); | |
59 | + } | |
60 | + } catch(ex) { | |
61 | + utils.toast({content:'出错', closeDelay:3000}); | |
62 | + } | |
63 | + }, | |
64 | + error : function(res){ | |
65 | + utils.toast({content:"提交出错,请联系系统管理员"}); | |
66 | + }, | |
67 | + complete : function(res){ | |
68 | + me.hideIndicator(); | |
69 | + }, | |
70 | + }); | |
71 | + }); | |
72 | + }; | |
73 | + | |
74 | + ctrl.uploadImg=function(uploadParent) { | |
75 | + var me = this; | |
76 | + jweixin.ready(function () { | |
77 | + //每次只传一张图片 | |
78 | + jweixin.chooseImage({ | |
79 | + count: 1, | |
80 | + sizeType: ['compressed'],//'original', | |
81 | + sourceType: ['album', 'camera'], // 'album', 'camera' | |
82 | + success: function (res) { | |
83 | + if (res.localIds.length > 0) { | |
84 | + me.upload(res.localIds, uploadParent); | |
85 | + } | |
86 | + } | |
87 | + }); | |
88 | + }); | |
89 | + }; | |
90 | + | |
91 | + ctrl.upload = function (localIds, uploadParent) { | |
92 | + var me = this; | |
93 | + if (localIds[0] == undefined) { | |
94 | + return ''; | |
95 | + } | |
96 | + jweixin.uploadImage({ | |
97 | + localId: localIds[0], | |
98 | + isShowProgressTips: 1, // 默认为1,显示进度提示 | |
99 | + success: function (res) { | |
100 | + $$.ajax({ | |
101 | + method : "POST", | |
102 | + url: url.to('check/default/update-serviceid'), | |
103 | + data : {service_id:res.serverId}, | |
104 | + dataType : "json", | |
105 | + beforeSend : function(){ | |
106 | + me.showIndicator(); | |
107 | + }, | |
108 | + success : function(res){ | |
109 | + try { | |
110 | + if(res.success) { | |
111 | + var imgUrl = res.img_path; | |
112 | + uploadParent.attr("data", imgUrl); | |
113 | + uploadParent.attr("src", res.show_path); | |
114 | + } else { | |
115 | + utils.toast({content:res.message, closeDelay:3000}); | |
116 | + } | |
117 | + } catch(ex) { | |
118 | + utils.toast({content:'出错', closeDelay:3000}); | |
119 | + } | |
120 | + }, | |
121 | + error : function(res){ | |
122 | + utils.toast({content:"提交出错,请联系系统管理员"}); | |
123 | + }, | |
124 | + complete : function(res){ | |
125 | + me.hideIndicator(); | |
126 | + }, | |
127 | + }); | |
128 | + }, | |
129 | + fail: function (res) { | |
130 | + me.app.alert(JSON.stringify(res)); | |
131 | + } | |
132 | + }); | |
133 | + }; | |
134 | + | |
135 | + return ctrl; | |
136 | + } | |
137 | +); | |
0 | 138 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,69 @@ |
1 | +/** | |
2 | + * 验证结果控制器 | |
3 | + */ | |
4 | +define( | |
5 | + "check/success-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 | + var uuid = ""; | |
18 | + | |
19 | + ctrl.run = function () { | |
20 | + var me = this; | |
21 | + uuid = me.params.uuid; | |
22 | + me.setPageTitle("验证结果"); | |
23 | + me.render(); | |
24 | + }; | |
25 | + | |
26 | + ctrl.bindEvents = function () { | |
27 | + var me = this; | |
28 | + $$(".btn-submit").click(function () { | |
29 | + var numberCode = $$(".input-num").val(); | |
30 | + if (utils.isEmpty(numberCode)) { | |
31 | + utils.toast({content:"请填写提取码"}); | |
32 | + $$(".input-num").focus(); | |
33 | + return false; | |
34 | + } | |
35 | + if (utils.isEmpty(uuid)) { | |
36 | + utils.toast({content:"缺少必要参数请退出重试"}); | |
37 | + return false; | |
38 | + } | |
39 | + $$.ajax({ | |
40 | + method : "POST", | |
41 | + url: url.to('check/default/get-info'), | |
42 | + data : {uuid: uuid, number_code: numberCode}, | |
43 | + dataType : "json", | |
44 | + beforeSend : function(){ | |
45 | + me.showIndicator(); | |
46 | + }, | |
47 | + success : function(res){ | |
48 | + try { | |
49 | + if(res.success) { | |
50 | + window.location.href = url.to('check#info/' + uuid + "/" + numberCode); | |
51 | + } else { | |
52 | + utils.toast({content:res.message, closeDelay:3000}); | |
53 | + } | |
54 | + } catch(ex) { | |
55 | + utils.toast({content:'出错', closeDelay:3000}); | |
56 | + } | |
57 | + }, | |
58 | + error : function(res){ | |
59 | + utils.toast({content:"提交出错,请联系系统管理员"}); | |
60 | + }, | |
61 | + complete : function(res){ | |
62 | + me.hideIndicator(); | |
63 | + }, | |
64 | + }); | |
65 | + }); | |
66 | + }; | |
67 | + return ctrl; | |
68 | + } | |
69 | +); | |
0 | 70 | \ No newline at end of file | ... | ... |
app-wx/web/src/js/smart/enter-controller.js
... | ... | @@ -217,12 +217,12 @@ define( |
217 | 217 | if (imgLimit == $$('#image-list').find('.up-img').length) { |
218 | 218 | $$('.upload-btn-li').hide(); |
219 | 219 | } |
220 | - utils.toast({content:res.message, closeDelay:5000}); | |
220 | + //utils.toast({content:res.message, closeDelay:5000}); | |
221 | 221 | } else { |
222 | - utils.toast({content:res.message, closeDelay:5000}); | |
222 | + utils.toast({content:res.message, closeDelay:3000}); | |
223 | 223 | } |
224 | 224 | } catch(ex) { |
225 | - utils.toast({content:'出错', closeDelay:5000}); | |
225 | + utils.toast({content:'出错', closeDelay:3000}); | |
226 | 226 | } |
227 | 227 | }, |
228 | 228 | error : function(res){ | ... | ... |
common/helpers/ImageManager.php
... | ... | @@ -20,7 +20,8 @@ class ImageManager |
20 | 20 | /** |
21 | 21 | * 根据系统模块划分, 定义图片一级目录结构 |
22 | 22 | */ |
23 | - private static $SMART_ROOT_PATH = 'smart/'; // 设备库 | |
23 | + private static $SMART_ROOT_PATH = 'smart/'; // 激活库 | |
24 | + private static $CHECK_ROOT_PATH = 'check/'; // 校验库 | |
24 | 25 | |
25 | 26 | |
26 | 27 | /** |
... | ... | @@ -124,4 +125,19 @@ class ImageManager |
124 | 125 | $savePath = $basePath . '/' . $imageName; |
125 | 126 | return $savePath; |
126 | 127 | } |
128 | + | |
129 | + /** | |
130 | + * 商品图片存储路径: smart/20170509/[userid]/[16位md5加密串].jpg | |
131 | + * @param $userId | |
132 | + * @param $suffix 图片后缀, 如'.jpg' | |
133 | + * @param $fileName 图片另外的名称,商品图片存储路径 | |
134 | + * @return string | |
135 | + */ | |
136 | + public static function getSmartCheckImgPath($userId, $fileName = '', $suffix = 'jpg') | |
137 | + { | |
138 | + $imageName = md5(time() . $userId . $fileName . self::rand(5)) . '.' . $suffix; | |
139 | + $basePath = self::$CHECK_ROOT_PATH . date("Ymd") . '/' . $userId; | |
140 | + $savePath = $basePath . '/' . $imageName; | |
141 | + return $savePath; | |
142 | + } | |
127 | 143 | } |
128 | 144 | \ No newline at end of file | ... | ... |