Lydia's blog

Every day to be a little better


  • Home

  • Archives

  • Search

移动端-overflow hidden 失效

Posted on 2018-07-02 15:16

在body里面多加一层控制
$(‘.container’).css(‘overflow’, ‘hidden’)
$(‘.container’).css(‘position’, ‘fixed’)

ps:1. position 得是fixed

  1. overflow-x/overflow-y 不行

ios-延迟执行方法

Posted on 2018-06-16 02:08

[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(initData) userInfo:nil repeats:NO];

ps:如果想传参数给init data的话参数要从userInfo里面传
eg:

1
2
3
4
5
6
7
8
9
10
 NSTimer* timer = [NSTimer scheduledTimerWithTimeInterval:2.0 
target:self
selector:@selector(handleTimer:)
userInfo:@"someString" repeats:NO];

- (void)handleTimer:(NSTimer*)theTimer {

NSLog (@"Got the string: %@", (NSString*)[theTimer userInfo]);

}

安卓- android studio 配置真机调试

Posted on 2018-06-11 15:49

对于Android studio而言,默认的adb路径为:
~/Library/Android/sdk/platform-tools

vim /.bash_profile
export PATH=
/Library/Android/sdk/platform-tools/:$PATH

在终端输入
source .bash_profile
然后输入
adb
不提示“command not found”,而是出现一长串帮助说明,那就证明adb已经配置好了。

1、确保连接线没问题,连接好后。查看usb设备信息,终端输入命令

system_profiler SPUSBDataType

Vendor ID需要记下来一会用

2、终端输入以下命令,打开 adb_usb.ini 文件

vim ~/.android/adb_usb.ini
将vendor id 写进去

4、保存修改并退出。

5、重启adb,输入以下命令

adb kill-server
adb start-server

ios-修改userAgent

Posted on 2018-06-09 16:36

方案一,修改全局UserAgent值(这里是在原有基础上拼接自定义的字符串)

1
2
3
4
5
6
7
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
NSString *userAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
NSString *newUserAgent = [userAgent stringByAppendingString:@" native_iOS"];//自定义需要拼接的字符串
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:newUserAgent, @"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
}

方案二,自定义UserAgent值

1
2
3
4
5
6
7
8
9
WKWebView *wkWebView = [[WKWebView alloc] initWithFrame:self.view.bounds];
[self.view addSubview: wkWebView];
NSString *customUserAgent = @"native_iOS";
[[NSUserDefaults standardUserDefaults] registerDefaults:@{@"UserAgent":customUserAgent}];
NSURL *url = [NSURL URLWithString:self.strUrl];
NSURLRequest *request = [NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.f];
[self.wkWebView loadRequest:request];

方案三

1
2
3
4
5
6
7
8
9
10
11
12
self.wkWebView = [[WKWebView alloc] initWithFrame:self.view.bounds];
__weak typeof(self) weakSelf = self;
[self.wkWebView evaluateJavaScript:@"navigator.userAgent" completionHandler:^(id result, NSError *error) {
__strong typeof(weakSelf) strongSelf = weakSelf;
NSString *userAgent = result;
NSString *newUserAgent = [userAgent stringByAppendingString:@" native_iOS"];
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:newUserAgent, @"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
// needs retain because `evaluateJavaScript:` is asynchronous
strongSelf.wkWebView = [[WKWebView alloc] initWithFrame:strongSelf.view.bounds];
}];
[self.wkWebView loadRequest:request];

mac-安装安卓环境

Posted on 2018-06-07 15:03

下载的文件包括Java、Android Studio。Java下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html,Android studio的下载可以到google官网下载,也可以到中文社区下载(http://www.android-studio.org/)

要先连vpn

小程序-this.setData undefined

Posted on 2018-06-06 18:06

这个是由于this的作用域问题 一般来说 确认存在的方法什么的掉不起来都是因为这个
var that=this;
用that来调就可以了
但是一定要记住!!!
这个变量声明一定要写在方法开始,写在任何一个回调里面都不生效

小程序-webview 支付

Posted on 2018-06-06 18:00

小程序在webview里面只能调起网页支付 但是小程序又不允许这种支付方式 所以就坑爹了
我们只能用点击webview里面按钮跳转到原生小程序页面调起支付
小程序js

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Page({
data: {
openid: '',
order_id: ''
},
onLoad: function (options) {
console.log('pay')
this.setData({
order_id: options.order_id
})
this.getOpenId()
},
getOpenId: function () {
var that = this;
wx.login({
success: function (res) {
if (res.code) {
//发起网络请求
wx.request({
url: 'https://www.wondercv.com/zh-CN/interface/pages/get_wx_mini_open_id',
// url: 'http://localhost:3000/zh-CN/interface/pages/get_wx_mini_open_id',
method: 'GET',
data: {
code: res.code
},
success: function (response) {
console.log('get open id =====================' + response.data.open_id)
that.setData({
openid: response.data.open_id
});
that.getPaymentParams();
},
})
} else {
console.log('获取用户登录态失败!' + res.errMsg)
}
}
});
},
getPaymentParams: function(openId){
wx.request({
url: 'https://www.wondercv.com/zh-CN/interface/pages/wechat_mini_information',
// url: 'http://localhost:3000/zh-CN/interface/pages/wechat_mini_information',
method: 'GET',
data: {
open_id: this.data.openid,
order_id: this.data.order_id
},
success: function (response) {
console.log('get payment params=========================')
console.log(response)
wx.requestPayment({
//相关支付参数
'timeStamp': response.data.timeStamp,
'nonceStr': response.data.nonceStr,
'package': response.data.pre_package,
'signType': response.data.signType,
'paySign': response.data.sign,
//小程序微信支付成功的回调通知
'success': function (res) {
console.log("支付成功");
},
//小程序支付失败的回调通知
'fail': function (res) {
console.log("支付失败");
console.log(res);
}
})
},
})
},

})

获取小程序openid

1
2
3
4
5
6
7
8
9
res = RestClient.get 'https://api.weixin.qq.com/sns/jscode2session?appid=' +
ENV['WECHAT_MINIPROGRAM_APP_ID'] + '&secret=' + ENV['WECHAT_MINIPROGRAM_APP_SECRECT'] + '&js_code=' + params[:code] +
'&grant_type=authorization_code'
Rails.logger.info("code=======================#{params[:code]}")
open_id = JSON.parse(res.body)['openid']
Rails.logger.info("=======================#{JSON.parse(res.body)}")
render json: {
open_id: open_id
}

获取小程序需要的支付参数 用wx_pay 就可以,使用方式JSAPI
signType: MD5
注意:第二次签名的方法选择的方式不一样 方法也就不一样
r = WxPay::Service.generate_js_pay_req params_for_program

js-touchmove之后不触发touchend

Posted on 2018-06-01 11:32

var UL = document.getElementById(‘Ul’);
var moves = true;
function Alert(ev){
if(moves)
alert(ev.target.innerHTML)
}
UL.addEventListener(‘touchmove’,function(){
moves = false;
UL.addEventListener(‘touchend’,function(){
moves = true;
})
})
UL.addEventListener(‘touchend’, Alert)

原理:

  1. 设置一个变量moved来标识是否有移动过,初始值为false;
  2. 绑定touchend事件,将moved置为true;
  3. 绑定touchmove事件,将moved置为false;
  4. 在touchmove事件函数中继续绑定touchend事件,再将moved置为true

html-关闭弹窗

Posted on 2018-06-01 10:40

data-dismiss= ‘-modal’

小程序-安卓机不显示图片

Posted on 2018-05-31 10:34

从img文件夹中引用的图片必须没有空格 不可以用中文 否则安卓机不会显示

1…111213…28

Lydia

This is lydia's blog

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