Lydia's blog

Every day to be a little better


  • Home

  • Archives

  • Search

js-声明全局变量

Posted on 2018-05-15 14:30
1
2
3
4
var editor;
$(function(){
editor = ace.edit('editor');
});

这种参数必须在$(document) 里面调用不能直接调

微信小程序-获取授权 后台获取其他用户信息不行!

Posted on 2018-05-14 14:32

普通授权 用wx.authorize 就可以了有相关文档 可以直接用
https://developers.weixin.qq.com/miniprogram/dev/api/authorize.html
但是用户信息授权被坑爹的小程序改成了只能用button调起

1
<button open-type="getUserInfo" bindgetuserinfo="userInfoHandler"> Click me </button>

用以下代码去判断用户是否授权了

1
2
3
userInfoHandler: function (e) {
e.detail.userInfo; //要判断这个,有值表示用户点击允许,没有则表示用户点击的是拒绝。
}

后台只能获取到当前用户信息 并获取不到其他用户信息!!!!坑爹!!! 只能暂存

微信小程序-图片显示

Posted on 2018-05-13 17:32

https://developers.weixin.qq.com/miniprogram/dev/component/image.html

微信小程序-获取全局变量

Posted on 2018-05-10 16:12

getApp().globalData.xxx

html-普通标签模拟textarea

Posted on 2018-05-09 11:55

html5里面的contenteditable属性


css-美化checkbox 样式

Posted on 2018-05-07 16:55

1.css方法: 兼容性一般 不兼容safari

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
input[type=checkbox]
-webkit-appearance: checkbox !important
-moz-appearance: checkbox !important
-ms-appearance: checkbox !important
-o-appearance: checkbox !important
appearance: checkbox !important
display: none
input[type=checkbox]+label
height: 18px !important
width: 18px !important
background-color: #fff
border: 1px solid #dedfe1
padding: 9px
border-radius: 3px
display: inline-block
position: relative
margin-left: 7px
input[type=checkbox]:checked+label:after
content: '\2714'
font-size: 16px
position: absolute
top: 0px
left: 3px
color: #ff4f4c
line-height: 18px

html

1
2
3
<%= check_box_tag 'email[bcc_to_self]', true,
email.reply_to.present? && email.reply_to == email.bcc&.first, id: "bcc-to-self-checkbox"%>
<label for="bcc-to-self-checkbox"></label>

ios-tooltip需要点两次

Posted on 2018-05-02 17:48

//listen for the show event on any triggered elements
$(‘[data-toggle=”tooltip”]’).on(‘show.bs.tooltip’, function() {
$(this).click();
});

button 可以
a tag 不行
a tag 带data-confirm 可以

ios-版本更新提示

Posted on 2018-04-27 11:44

//判断是否需要提示更新App

  • (void)shareAppVersionAlert {
    if(![self judgeNeedVersionUpdate]) return ;
    //App内info.plist文件里面版本号
    NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
    NSString *appVersion = infoDict[@”CFBundleShortVersionString”];
    // NSString *bundleId = infoDict[@”CFBundleIdentifier”];
    NSString *urlString =[NSString stringWithFormat:@”https://itunes.apple.com/cn/lookup?id=%@", appId];;
    //两种请求appStore最新版本app信息 通过bundleId与appleId判断
    //[NSString stringWithFormat:@”https://itunes.apple.com/cn/lookup?bundleid=%@", bundleId]
    NSURL *urlStr = [NSURL URLWithString:urlString];
    //创建请求体
    NSURLRequest *urlRequest = [NSURLRequest requestWithURL:urlStr];
    [NSURLConnection sendAsynchronousRequest:urlRequest queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
    if (connectionError) {
        //            NSLog(@"connectionError->%@", connectionError.localizedDescription);
        return ;
    }
    NSError *error;
    NSDictionary *resultsDict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
    if (error) {
        //            NSLog(@"error->%@", error.localizedDescription);
        return;
    }
    NSArray *sourceArray = resultsDict[@"results"];
    if (sourceArray.count >= 1) {
        //AppStore内最新App的版本号
        NSDictionary *sourceDict = sourceArray[0];
        NSString *newVersion = sourceDict[@"version"];
        if ([self judgeNewVersion:newVersion withOldVersion:appVersion])
        {
            UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:@"提示:\n您的App不是最新版本,请问是否更新" message:@"" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"暂不更新" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                //                    [alertVc dismissViewControllerAnimated:YES completion:nil];
            }];
            [alertVc addAction:action1];
            UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"去更新" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
                //跳转到AppStore,该App下载界面
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:sourceDict[@"trackViewUrl"]]];
            }];
            [alertVc addAction:action2];
            [[UIApplication sharedApplication].delegate.window.rootViewController presentViewController:alertVc animated:YES completion:nil];
        }
    }
    }];
    }
    //每天进行一次版本判断
  • (BOOL)judgeNeedVersionUpdate {
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@”yyyy-MM-dd”];
    // 获取年-月-日
    NSString *dateString = [formatter stringFromDate:[NSDate date]];
    NSString *currentDate = [[NSUserDefaults standardUserDefaults] objectForKey:@”currentDate”];
    if ([currentDate isEqualToString:dateString]) {
    return NO;
    }
    [[NSUserDefaults standardUserDefaults] setObject:dateString forKey:@”currentDate”];
    return YES;
    }
    //判断当前app版本和AppStore最新app版本大小
  • (BOOL)judgeNewVersion:(NSString *)newVersion withOldVersion:(NSString *)oldVersion {
    NSArray *newArray = [newVersion componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@”.”]];
    NSArray *oldArray = [oldVersion componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@”.”]];
    for (NSInteger i = 0; i < newArray.count; i ++) {
    if ([newArray[i] integerValue] > [oldArray[i] integerValue]) {
        return YES;
    } else if ([newArray[i] integerValue] < [oldArray[i] integerValue]) {
        return NO;
    } else { }
    }
    return NO;
    }

在 didFinishLaunchingWithOptions方法中调用就可以了

js-ios alert confirm 不显示网址

Posted on 2018-04-26 17:17

window.alert = function(name){
var iframe = document.createElement(“IFRAME”);
iframe.style.display=”none”;
iframe.setAttribute(“src”, ‘data:text/plain,’);
document.documentElement.appendChild(iframe);
window.frames[0].window.alert(name);
iframe.parentNode.removeChild(iframe);
};

window.confirm = (message) ->
iframe = document.createElement(‘IFRAME’)
iframe.style.display = ‘none’
iframe.setAttribute ‘src’, ‘data:text/plain,’
document.documentElement.appendChild iframe
alertFrame = window.frames[0]
result = alertFrame.window.confirm(message)
iframe.parentNode.removeChild iframe
result

js-notify dismiss

Posted on 2018-04-26 16:27

$(‘.notifyjs-wrapper’).remove();

1…131415…28

Lydia

This is lydia's blog

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