Lydia's blog

Every day to be a little better


  • Home

  • Archives

  • Search

css-自己写的moal background

Posted on 2017-12-29 15:18
  .modal-background{
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.5);
overflow: hidden;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
//outline: 0;
z-index: 9;

}

如果不想让蒙版后面滑动 加上js
$(“body,html”).css({“overflow”:”hidden”});
取消不可滑动
$(“body,html”).css({“overflow”:”auto”});

h5-intercom 样式调整问题

Posted on 2017-12-28 14:35
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

<script>
function addNewStyle(newStyle) {
var styleElement = document.getElementById('styles_js');
if (!styleElement) {
styleElement = document.createElement('style');
styleElement.type = 'text/css';
styleElement.id = 'styles_js';
document.getElementsByTagName('head')[0].appendChild(styleElement);
}
styleElement.appendChild(document.createTextNode(newStyle));
}
addNewStyle('#intercom-container .intercom-messenger-frame>iframe{top:10% !important;}')
addNewStyle('#intercom-container .intercom-messenger-frame>iframe{position:absolute !important;}')
addNewStyle('#intercom-container .intercom-app div.intercom-messenger-frame iframe{height:90% !important;}')

</script>

其实很简单 就是找到合适的class 给他赋予样式
ps:一定要写在layout里面 才能全局通用

js 手机上键盘弹出挡住输入框

Posted on 2017-12-28 14:34
1
2
3
4
5
6
7
8
9
10
11
12
var viewTop = document.body.scrollTop,
viewBottom = viewTop + window.innerHeight;
$("#intercom-container .intercom-composer textarea").on("focus", function(){
window.setTimeout(function() {
window.scrollTo(0, viewBottom); // 调整value
},200);
})
$("#intercom-container .intercom-composer textarea").on("blur", function(){
window.setTimeout(function() {
window.scrollTo(0, viewTOP); // 调整value
},200);
})

ios-支付集成的巨坑

Posted on 2017-12-11 19:28

1、支付宝 url type 中的url scheme自定义
在alipaymanager 中调用自定义的url scheme 即可实现跳转

2.微信统一下单接口返回签名错误 如确定参数无误 重新设置商户key(一样的也可以)

3.app跟网站上的微信支付的账户不是一个 都要设置好才能用

ios11- wkweview获取的内容向下偏离

Posted on 2017-11-25 09:40
if (@available(iOS 11.0, *)) {
    _webview.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    _webview.scrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    _webview.scrollView.scrollIndicatorInsets = _webview.scrollView.contentInset;
}

也可以解决ipone x底部留白问题

ios-wkwebview cookie

Posted on 2017-11-23 17:47

1.存储
1)使用- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler{方法
2)

1
2
3
4
5
6
7
8
9
10
11
NSHTTPURLResponse *response = (NSHTTPURLResponse *)navigationResponse.response;
//读取wkwebview中的cookie 方法
NSArray *cookies =[NSHTTPCookie cookiesWithResponseHeaderFields:[response allHeaderFields] forURL:response.URL];
for (NSHTTPCookie *cookie in cookies) {
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie];
}
//看看存入到了NSHTTPCookieStorage了没有
NSHTTPCookieStorage *cookieJar2 = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (NSHTTPCookie *cookie in cookieJar2.cookies) {
NSLog(@"NSHTTPCookieStorage中的cookie%@", cookie);
}

2.读取

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// 在此处获取返回的cookie
NSMutableDictionary *cookieDic = [NSMutableDictionary dictionary];
NSMutableString *cookieValue = [NSMutableString stringWithFormat:@""];
NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (NSHTTPCookie *cookie in [cookieJar cookies]) {
[cookieDic setObject:cookie.value forKey:cookie.name];
NSLog(@"传递的cookie%@", cookieDic);
}
// cookie重复,先放到字典进行去重,再进行拼接
for (NSString *key in cookieDic) {
NSString *appendString = [NSString stringWithFormat:@"%@=%@;", key, [cookieDic valueForKey:key]];
[cookieValue appendString:appendString];
}
NSMutableURLRequest *requestCookie = [NSMutableURLRequest requestWithURL:url];
[requestCookie addValue:cookieValue forHTTPHeaderField:@"Cookie"];
NSLog(@"传递的最终cookie%@", requestCookie);

3.清除

1
2
3
4
5
NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];
NSArray *_tmpArray = [NSArray arrayWithArray:[cookieJar cookies]];
for (id obj in _tmpArray) {
[cookieJar deleteCookie:obj];
}

ps:如果想再次进入免登陆 需要在app端存储一下
app端手动存储Cookie

如果没设置Cookie失效时间expiresDate:(null),sessionOnly:true,kill掉后系统不会自动保存Cookie,如果想持久化Cookie 模仿浏览器存住Cookie,使用NSUserDefaults存下即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//合适的时机保存Cookie
- (void)saveCookies{
NSData *cookiesData = [NSKeyedArchiver archivedDataWithRootObject: [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject: cookiesData forKey: @"org.skyfox.cookie"];
[defaults synchronize];
}

//合适的时机加载Cookie 一般都是app刚刚启动的时候
- (void)loadCookies{
NSArray *cookies = [NSKeyedUnarchiver unarchiveObjectWithData: [[NSUserDefaults standardUserDefaults] objectForKey: @"org.skyfox.cookie"]];
NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (NSHTTPCookie *cookie in cookies){
[cookieStorage setCookie: cookie];
}
}

ios-oc和js的交互(数据传值)

Posted on 2017-11-22 14:10

https://github.com/marcuswestin/WebViewJavascriptBridge

ios-url中有中文

Posted on 2017-11-21 09:44

ios9之后才支持
NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]];

ios-字符串插入

Posted on 2017-11-21 09:26

NSString 声明的字符串不可变
所以想要改变这个字符串要用NSMutableString来声明

rails ajax获取的数据 分页

Posted on 2017-11-13 10:19

将will_paginate 写成一个partial 在ajax调用的时候 替换parcial
注意:1.页面上render的外面要套一层div
2.不需要传递参数 will_paginate 会自动去相对应的controller里面找
3.分页直接点击会显示html用一下方法可解决(让will_paginate 可调用ajax方法)

application_helper.rb
1
2
3
4
5
module ApplicationHelper
def paginate(collection, params= {})
will_paginate collection, params.merge(:renderer => RemoteLinkPaginationHelper::LinkRenderer)
end
end
index.html.erb
1
2
3
<div id="page_links">
<%= paginate @results %>
</div>
remote_link_pagination_helper.rb
1
2
3
4
5
6
7
8
module RemoteLinkPaginationHelper
class LinkRenderer < WillPaginate::ActionView::LinkRenderer
def link(text, target, attributes = {})
attributes['data-remote'] = true
super
end
end
end

Make will_paginate generate ajax links原文

1…171819…28

Lydia

This is lydia's blog

277 posts
1 categories
46 tags
© 2020 Lydia
Powered by Hexo
|
Theme — NexT.Muse v5.1.4