@@ -184,17 +184,19 @@ protected function html5DevideCheckAndRedirect($store_code, $store)
184
184
$ condition = isset ($ store ['mobile ' ]['condition ' ]) ? $ store ['mobile ' ]['condition ' ] : false ;
185
185
$ redirectDomain = isset ($ store ['mobile ' ]['redirectDomain ' ]) ? $ store ['mobile ' ]['redirectDomain ' ] : false ;
186
186
if (is_array ($ condition ) && !empty ($ condition ) && !empty ($ redirectDomain )) {
187
+
188
+ $ mobile_https = (isset ($ store ['mobile ' ]['https ' ]) && $ store ['mobile ' ]['https ' ]) ? true : false ;
187
189
if (in_array ('phone ' , $ condition ) && in_array ('tablet ' , $ condition )) {
188
190
if ($ mobileDetect ->isMobile ()) {
189
- $ this ->redirectMobile ($ store_code , $ redirectDomain );
191
+ $ this ->redirectMobile ($ store_code , $ redirectDomain, $ mobile_https );
190
192
}
191
193
} elseif (in_array ('phone ' , $ condition )) {
192
194
if ($ mobileDetect ->isMobile () && !$ mobileDetect ->isTablet ()) {
193
- $ this ->redirectMobile ($ store_code , $ redirectDomain );
195
+ $ this ->redirectMobile ($ store_code , $ redirectDomain, $ mobile_https );
194
196
}
195
197
} elseif (in_array ('tablet ' , $ condition )) {
196
198
if ($ mobileDetect ->isTablet ()) {
197
- $ this ->redirectMobile ($ store_code , $ redirectDomain );
199
+ $ this ->redirectMobile ($ store_code , $ redirectDomain, $ mobile_https );
198
200
}
199
201
}
200
202
}
@@ -205,10 +207,24 @@ protected function html5DevideCheckAndRedirect($store_code, $store)
205
207
* @property $redirectDomain | String
206
208
* 设备满足什么条件的时候进行跳转。
207
209
*/
208
- protected function redirectMobile ($ store_code , $ redirectDomain )
210
+ protected function redirectMobile ($ store_code , $ redirectDomain, $ mobile_https )
209
211
{
210
212
$ currentUrl = Yii::$ service ->url ->getCurrentUrl ();
211
213
$ redirectUrl = str_replace ($ store_code , $ redirectDomain , $ currentUrl );
214
+ // pc端跳转到html5,可能一个是https,一个是http,因此需要下面的代码进行转换。
215
+ if ($ mobile_https ) {
216
+ if (strstr ($ redirectUrl ,'https:// ' ) || strstr ($ redirectUrl ,'http:// ' )) {
217
+ $ redirectUrl = str_replace ('http:// ' ,'https:// ' ,$ redirectUrl );
218
+ } else {
219
+ $ redirectUrl = 'https: ' .$ redirectUrl ;
220
+ }
221
+ } else {
222
+ if (strstr ($ redirectUrl ,'https:// ' ) || strstr ($ redirectUrl ,'http:// ' )) {
223
+ $ redirectUrl = str_replace ('https:// ' ,'http:// ' ,$ redirectUrl );
224
+ } else {
225
+ $ redirectUrl = 'http: ' .$ redirectUrl ;
226
+ }
227
+ }
212
228
header ('Location: ' .$ redirectUrl );
213
229
}
214
230
0 commit comments