Commit 56c61aa0697298791edf2452aef1127f98207895
1 parent
28f61820
购好物:
1、加入购物车H5不弹窗提示 2、搜索跳转原生
Showing
2 changed files
with
43 additions
and
14 deletions
src/pages/common/common.vue
| @@ -667,6 +667,26 @@ | @@ -667,6 +667,26 @@ | ||
| 667 | } | 667 | } |
| 668 | }, | 668 | }, |
| 669 | 669 | ||
| 670 | + /** | ||
| 671 | + * 跳转搜索页面(原生交互) | ||
| 672 | + */ | ||
| 673 | + jumpToShopSearch() { | ||
| 674 | + | ||
| 675 | + if (this.isCNLive.value) { | ||
| 676 | + | ||
| 677 | + // 请求App接口,跳转搜索页面 | ||
| 678 | + if(window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.jumpToShopSearch) { | ||
| 679 | + | ||
| 680 | + // 请求App接口,跳转搜索页面 | ||
| 681 | + window.webkit.messageHandlers.jumpToShopSearch.postMessage({body: {}}); | ||
| 682 | + } else if(window.obj && window.obj.jumpToShopSearch) { | ||
| 683 | + | ||
| 684 | + // 请求App接口,跳转搜索页面 | ||
| 685 | + window.obj.jumpToShopSearch(); | ||
| 686 | + } | ||
| 687 | + } | ||
| 688 | + }, | ||
| 689 | + | ||
| 670 | /* 获取并设置唤起App参数 开始 */ | 690 | /* 获取并设置唤起App参数 开始 */ |
| 671 | 691 | ||
| 672 | /** | 692 | /** |
src/pages/optimization2/optimization2.vue
| @@ -1083,9 +1083,6 @@ | @@ -1083,9 +1083,6 @@ | ||
| 1083 | 1083 | ||
| 1084 | // 加入购物车 | 1084 | // 加入购物车 |
| 1085 | this.$parent.addToShoppingCart(item); | 1085 | this.$parent.addToShoppingCart(item); |
| 1086 | - | ||
| 1087 | - // 提示加入购物车 | ||
| 1088 | - Toast('已加入购物车'); | ||
| 1089 | } | 1086 | } |
| 1090 | } else { | 1087 | } else { |
| 1091 | 1088 | ||
| @@ -1098,19 +1095,31 @@ | @@ -1098,19 +1095,31 @@ | ||
| 1098 | * 跳转搜索页面 | 1095 | * 跳转搜索页面 |
| 1099 | */ | 1096 | */ |
| 1100 | toSearch() { | 1097 | toSearch() { |
| 1101 | - | ||
| 1102 | - // 跳转搜索页面(跳转封装) | ||
| 1103 | - if (typeof this.$parent.gotoDetail === 'function') { | ||
| 1104 | 1098 | ||
| 1105 | - // 设置跳转参数 | ||
| 1106 | - let params = { | ||
| 1107 | - type: '5', | ||
| 1108 | - to: window.location.origin + window.location.pathname + '#/search', | ||
| 1109 | - shop_type: '' | ||
| 1110 | - }; | 1099 | + // 判断是否在App内 |
| 1100 | + if (this.isCNLive.value) { | ||
| 1111 | 1101 | ||
| 1112 | - // 页面跳转 | ||
| 1113 | - this.$parent.gotoDetail(params); | 1102 | + // 判断加入购物车函数是否存在 |
| 1103 | + if (typeof this.$parent.jumpToShopSearch === 'function') { | ||
| 1104 | + | ||
| 1105 | + // 跳转搜索页面(原生交互) | ||
| 1106 | + this.$parent.jumpToShopSearch(); | ||
| 1107 | + } | ||
| 1108 | + } else { | ||
| 1109 | + | ||
| 1110 | + // 跳转搜索页面(H5,跳转封装) | ||
| 1111 | + if (typeof this.$parent.gotoDetail === 'function') { | ||
| 1112 | + | ||
| 1113 | + // 设置跳转参数 | ||
| 1114 | + let params = { | ||
| 1115 | + type: '5', | ||
| 1116 | + to: window.location.origin + window.location.pathname + '#/search', | ||
| 1117 | + shop_type: '' | ||
| 1118 | + }; | ||
| 1119 | + | ||
| 1120 | + // 页面跳转 | ||
| 1121 | + this.$parent.gotoDetail(params); | ||
| 1122 | + } | ||
| 1114 | } | 1123 | } |
| 1115 | }, | 1124 | }, |
| 1116 | 1125 |