这里会显示出您选择的修订版和当前版本之间的差别。
Both sides previous revision 前一修订版 后一修订版 | 前一修订版 | ||
app_bridge_item [2014/08/13 18:10] 106.2.171.114 |
app_bridge_item [2022/04/19 10:57] (当前版本) 5.188.211.16 http://imrdsoacha.gov.co/silvitra-120mg-qrms |
||
---|---|---|---|
行 1: | 行 1: | ||
- | + | http://imrdsoacha.gov.co/silvitra-120mg-qrms | |
- | ===== 商品详情页通讯接口 ===== | + | |
- | + | ||
- | 在iOS、Android应用中打开的webview,可以通过JS函数和协议进行通讯。 | + | |
- | + | ||
- | 以iOS为例,可以在网页加载完成后,通过访问网页中的JS函数app_bridge_thumb()获取到函数return返回的缩略图url地址: | + | |
- | + | ||
- | \-(void)webViewDidFinishLoad:(UIWebView *)webView { | + | |
- | NSString *pic_thumb_url = [_webView stringByEvaluatingJavaScriptFromString:@"app_bridge_thumb()"]; | + | |
- | } | + | |
- | + | ||
- | 注意:_webView 改成你自己的名称。 | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | ==== 1、APP主动调用网页中JavaScript函数的接口列表: ==== | + | |
- | + | ||
- | * 1.1、商品详情页:APP原生应用获取商品主图缩略图URL地址 | + | |
- | + | ||
- | app_bridge_thumb() | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | * 1.2、商品详情页:获取点击APP原生“立即购买”按钮需要进入的购物车网址 | + | |
- | + | ||
- | app_bridge_submit_rp_shopping_cart() | + | |
- | + | ||
- | 返回JSON数据示例: | + | |
- | + | ||
- | {"opt":"cart","url":"https://m.repai.com/item/cart_islogin/?rp_iid=1100041405765641&rp_quantity=1&rp_sku1=%E9%BB%91%E8%89%B2&rp_sku2="} | + | |
- | + | ||
- | 说明:opt的值为cart时,表示此商品无型号选择或已经在详情页展开过型号选择,可以直接进入购物车。url表示购物车的网址。Webview打开购物车网址之前,APP需要先通过 [[user_info_api|APP客户端用户登陆状态判断及用户详情接口]] 查询当前的rp_access_token是否有效,如果失效请先登录,登录完成后,将 &access_token=xxxxx 作为参数追加在原网址参数后,在webview打开拼接后的网址,例如: | + | |
- | + | ||
- | https://m.repai.com/item/cart_islogin/?rp_iid=1100041405765641&rp_quantity=1&rp_sku1=%E9%BB%91%E8%89%B2&rp_sku2=&access_token=xxxxxxxxxxxxxxxx | + | |
- | + | ||
- | 或 | + | |
- | + | ||
- | {"opt":"type","url":"http://m.repai.com/item/sku/id/1100041405765641/"} | + | |
- | + | ||
- | 说明:opt的值为type时,表示从下方弹出一个半高度尺寸的webview,url表示在这个webview中打开的型号/数量选择页面。此页面无需传递rp_access_token | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | * 1.3、商品型号选择页:获取点击APP原生“确认购买”按钮需要进入的购物车网址 | + | |
- | + | ||
- | app_bridge_type_rp_shopping_cart() | + | |
- | + | ||
- | 返回文本数据示例: | + | |
- | + | ||
- | https://m.repai.com/item/cart_islogin/?rp_iid=1100041405765641&rp_quantity=1&rp_sku1=%E9%BB%91%E8%89%B2&rp_sku2= | + | |
- | + | ||
- | 说明:直接返回需要进入的购物车网址。Webview打开购物车网址之前,APP需要先通过 [[user_info_api|APP客户端用户登陆状态判断及用户详情接口]] 查询当前的rp_access_token是否有效,如果失效请先登录,登录完成后,将 &access_token=xxxxx 作为参数追加在原网址参数后,在webview打开拼接后的网址,例如: | + | |
- | + | ||
- | https://m.repai.com/item/cart_islogin/?rp_iid=1100041405765641&rp_quantity=1&rp_sku1=%E9%BB%91%E8%89%B2&rp_sku2=&access_token=xxxxxxxxxxxxxxxx | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | * 1.4、商品详情页:获取分享信息,标题、图片地址、价格、库存、详情页网址 | + | |
- | + | ||
- | app_bridge_item_info() | + | |
- | + | ||
- | 返回JSON数据示例: | + | |
- | + | ||
- | { | + | |
- | "rp_iid": "1100949812302780", | + | |
- | "rp_item_url": "http://m.repai.com/item/view/id/1100949812302780/", | + | |
- | "rp_pic_url": "http://img04.taobaocdn.com/imgextra/i4/2056453475/TB2Mwl8aXXXXXavXpXXXXXXXXXX_!!2056453475.jpg_320x320q90.jpg", | + | |
- | "rp_price": "14.5", | + | |
- | "rp_quantity": "50", | + | |
- | "rp_title": "拍下14.5牛皮女款皮带细腰带镶水钻" | + | |
- | } | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | * 1.5、商品详情页:获取点击APP原生“添加购物车”按钮需要获取的添加商品到购物车接口网址 | + | |
- | + | ||
- | app_bridge_shopping_cart_add() | + | |
- | + | ||
- | 返回JSON数据示例: | + | |
- | + | ||
- | {"opt":"cartapi","url":"https://m.repai.com/item/cart_add_api/?rp_iid=1100041405765641&rp_quantity=1&rp_sku1=%E9%BB%91%E8%89%B2&rp_sku2="} | + | |
- | + | ||
- | 说明:opt的值为cartapi时,表示此商品无型号选择或已经在详情页展开过型号选择,可以直接添加到购物车。url表示添加商品到购物车的接口。调用接口之前,APP需要先通过 [[user_info_api|APP客户端用户登陆状态判断及用户详情接口]] 查询当前的rp_access_token是否有效,如果失效请先登录,登录完成后,将 &access_token=xxxxx 作为参数追加在原网址参数后,作为接口调用地址,例如: | + | |
- | + | ||
- | https://m.repai.com/item/cart_add_api/?rp_iid=1100041405765641&rp_quantity=1&rp_sku1=%E9%BB%91%E8%89%B2&rp_sku2=&access_token=xxxxxxxxxxxxxxxx | + | |
- | + | ||
- | 或 | + | |
- | + | ||
- | {"opt":"type","url":"http://m.repai.com/item/sku/id/1100041405765641/"} | + | |
- | + | ||
- | 说明:opt的值为type时,表示从下方弹出一个半高度尺寸的webview,url表示在这个webview中打开的型号/数量选择页面。此页面无需传递rp_access_token | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | * 1.6、商品型号选择页:获取点击APP原生“添加购物车”按钮后进入型号选择页面点“确认”,需要调用的接口网址(非Webview调用) | + | |
- | + | ||
- | app_bridge_add_rp_shopping_cart() | + | |
- | + | ||
- | 返回文本数据示例: | + | |
- | + | ||
- | https://m.repai.com/item/cart_add_api/?rp_iid=1100041405765641&rp_quantity=1&rp_sku1=%E9%BB%91%E8%89%B2&rp_sku2= | + | |
- | + | ||
- | 说明:添加购物车调用的接口网址。调用接口之前,APP需要先通过 [[user_info_api|APP客户端用户登陆状态判断及用户详情接口]] 查询当前的rp_access_token是否有效,如果失效请先登录,登录完成后,将 &access_token=xxxxx 作为参数追加在原网址参数后,后台请求拼接后的网址,例如: | + | |
- | + | ||
- | https://m.repai.com/item/cart_add_api/?rp_iid=1100041405765641&rp_quantity=1&rp_sku1=%E9%BB%91%E8%89%B2&rp_sku2=&access_token=xxxxxxxxxxxxxxxx | + | |
- | + | ||
- | 调用接口后返回以下信息: | + | |
- | + | ||
- | 成功时: | + | |
- | + | ||
- | {"status":true,"reason":"成功添加宝贝到购物车!"} | + | |
- | + | ||
- | 失败时: | + | |
- | + | ||
- | {"status":false,"reason":"请先登录!"} | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | * 1.7、商品详情页:获取点击APP原生“购物车”按钮需要进入的购物车网址 | + | |
- | + | ||
- | app_bridge_shopping_cart_open() | + | |
- | + | ||
- | 返回文本数据示例: | + | |
- | + | ||
- | https://m.repai.com/item/cart_islogin/ | + | |
- | + | ||
- | 说明:直接返回需要进入的购物车网址。Webview打开购物车网址之前,APP需要先通过 [[user_info_api|APP客户端用户登陆状态判断及用户详情接口]] 查询当前的rp_access_token是否有效,如果失效请先登录,登录完成后,将 ?access_token=xxxxx 作为参数追加在原网址参数后,在webview打开拼接后的网址,例如: | + | |
- | + | ||
- | https://m.repai.com/item/cart_islogin/?access_token=xxxxxxxxxxxxxxxx | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | * 1.8、所有页面:获取“返回”按钮访问的网址 | + | |
- | + | ||
- | app_bridge_back_button() | + | |
- | + | ||
- | 返回文本数据示例: | + | |
- | + | ||
- | http://m.repai.com/item/cart/ | + | |
- | + | ||
- | 如果内容为空,则默认后退到上一页。 | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | ==== 2、网页调用APP接口: ==== | + | |
- | + | ||
- | * 2.1、准备打开的网址判断 | + | |
- | + | ||
- | 在 iOS 中,webview中的网页,如果准备访问另外的网址,可以通过协议与APP通讯,示例如下: | + | |
- | + | ||
- | \- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType: (UIWebViewNavigationType)navigationType { | + | |
- | if(navigationType == UIWebViewNavigationTypeLinkClicked || navigationType == UIWebViewNavigationTypeOther) | + | |
- | { | + | |
- | NSURL *URL = [request URL]; | + | |
- | NSString* rurl=[[request URL] absoluteString]; | + | |
- | //NSLog (@"url is :%@", URL); | + | |
- | if ([rurl rangeOfString:@"target=present"].location != NSNotFound) { | + | |
- | + | ||
- | 当网页视图被指示载入内容而得到通知。应当返回YES,这样会进行加载。通过导航类型参数可以得到请求发起的原因,可以是以下任意值: | + | |
- | + | ||
- | * UIWebViewNavigationTypeLinkClicked | + | |
- | * UIWebViewNavigationTypeFormSubmitted | + | |
- | * UIWebViewNavigationTypeBackForward | + | |
- | * UIWebViewNavigationTypeReload | + | |
- | * UIWebViewNavigationTypeFormResubmitted | + | |
- | * UIWebViewNavigationTypeOther | + | |
- | + | ||
- | 在热拍APP的webview中,需要做以下判断: | + | |
- | + | ||
- | * target=present 【以present从下方向上弹出的窗口打开新网址】 | + | |
- | * target=push 【以push方式打开新网址】 | + | |
- | * target=safari 【以[UIApplication sharedApplication]方式外部打开网址】 | + | |
- | * target=rpitem 【以热拍详情页的定制webview(带有立即购买、添加购物车按钮)打开网址】 | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | * 2.2 支付宝网页支付完成后一键关闭接口 | + | |
- | + | ||
- | repai://app_bridge_closewebview | + | |
- | + | ||
- | [[start|返回首页]] | + |