Commit ef978c54ce7378845cc23e9f63ee521d30596f84

Authored by zhiyangdu
2 parents 41cb5e95 90502b38

Merge branch 'version_2.0.0_optimization_mall_update' of http://bj.gitlab.cnlive…

….com/w-front-end/select_good into version_2.0.0_optimization_mall_update
src/components/callAppBox/callAppBox.vue
... ... @@ -55,6 +55,13 @@ export default {
55 55 // 拼接参数字符串,根据分享参数拼接
56 56 let shareString = "shop_shop_type=" + this.callApps.funcs.callAppParams.shop_shop_type + "&shop_to=" + this.callApps.funcs.callAppParams.shop_to + "&shop_type=" + this.callApps.funcs.callAppParams.shop_type + "&share_mold=" + this.callApps.funcs.callAppParams.share_mold;
57 57  
  58 + // 判断是否有扩展参数,如果有,拼接扩展参数到原始字符串
  59 + if (this.callApps.funcs.callAppParams.shop_ext) {
  60 +
  61 + // 拼接扩展参数到原始字符串
  62 + shareString += "&shop_extra=" + this.callApps.funcs.callAppParams.shop_ext;
  63 + }
  64 +
58 65 // Base64位编码加密
59 66 const CryptoJS = require("crypto-js");
60 67 const wordArray = CryptoJS.enc.Utf8.parse(shareString);
... ...
src/components/goodsItem_10/goodsItem_10.vue
... ... @@ -14,12 +14,13 @@
14 14 <!-- <div class="prices" v-if="(pid == '1') && item.prices && parseFloat(item.prices) > 0 && parseFloat(item.prices) > parseFloat(item.price)">¥{{item.prices}}</div> -->
15 15 </div>
16 16  
17   - <div class="price-box" v-if="pid == '2' && item.price && parseFloat(item.price) > 0">
  17 + <!-- <div class="price-box" v-if="pid == '2' && item.price && parseFloat(item.price) > 0">
18 18 <div class="symbol">¥</div>
19 19 <div class="price">{{item.price}}</div>
20   - </div>
  20 + </div> -->
21 21  
22   - <div class="price-box" v-else-if="pid == '2'">
  22 + <!-- <div class="price-box" v-else-if="pid == '2'"> -->
  23 + <div class="price-box" v-if="pid == '2'">
23 24 <div class="price">{{item.num}}</div>
24 25 <div class="price-text">积分</div>
25 26 </div>
... ...
src/pages/common/common.vue
... ... @@ -639,6 +639,54 @@
639 639 }
640 640 },
641 641  
  642 + /**
  643 + * 加入购物车
  644 + * @param {Object} item [商品信息对象]
  645 + */
  646 + addToShoppingCart(item) {
  647 +
  648 + if (this.isCNLive.value) {
  649 +
  650 + // 获取商品id
  651 + let {id} = item;
  652 +
  653 + // 判断必要参数,是否有商品id
  654 + if (id) {
  655 +
  656 + // 请求App接口,加入购物车
  657 + if(window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.addToShoppingCart) {
  658 +
  659 + // 请求App接口,加入购物车
  660 + window.webkit.messageHandlers.addToShoppingCart.postMessage({body: {id: id}});
  661 + } else if(window.obj && window.obj.addToShoppingCart) {
  662 +
  663 + // 请求App接口,加入购物车
  664 + window.obj.addToShoppingCart(id);
  665 + }
  666 + }
  667 + }
  668 + },
  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 +
642 690 /* 获取并设置唤起App参数 开始 */
643 691  
644 692 /**
... ... @@ -650,6 +698,20 @@
650 698 // 判断非App内
651 699 if (!this.isCNLive.value) {
652 700  
  701 + // 判断是否有渠道参数,如果有,添加到ext参数中
  702 + if (this.$route.query && this.$route.query.cnlive_union_activity_id && (!params.ext || !params.ext.cnlive_union_activity_id)) {
  703 +
  704 + // 判断ext参数是否存在,如果不存在,初始化params.ext
  705 + if (!params.ext) {
  706 +
  707 + // 初始化params.ext
  708 + this.$set(params, 'ext', {});
  709 + }
  710 +
  711 + // 设置渠道参数到ext参数中
  712 + this.$set(params.ext, 'cnlive_union_activity_id', this.$route.query.cnlive_union_activity_id);
  713 + }
  714 +
653 715 // 处理扩展参数转为字符串传参
654 716 if (params.ext && typeof params.ext === "object") {
655 717 this.$set(params, "ext", JSON.stringify(params.ext));
... ... @@ -690,11 +752,31 @@
690 752 shop_shop_type: datas.inside_aes.shop_type
691 753 });
692 754  
  755 + // 判断是否有扩展参数,如果有,传递扩展参数
  756 + if (datas.inside_aes.ext) {
  757 +
  758 + // 添加扩展参数
  759 + Object.assign(this.schemeParams, {
  760 + shop_ext: datas.inside_aes.ext
  761 + });
  762 + }
  763 +
693 764 // 遍历对象,重新编码
694 765 for (let index in this.schemeParams) {
695 766 this.schemeParams[index] = encodeURIComponent(decodeURIComponent(this.schemeParams[index]));
696 767 }
697 768  
  769 + // 如果在iOS内,重新设置OpenInstall参数
  770 + if (this.isiPhone.value) {
  771 +
  772 + // 判断openInstallReady函数是否存在
  773 + if (typeof openInstallReady === 'function') {
  774 +
  775 + // 重新设置OpenInstall参数
  776 + openInstallReady(this.schemeParams);
  777 + }
  778 + }
  779 +
698 780 // 设置唤起App对象
699 781 this.$set(this, "callApps", {
700 782 funcs: {
... ...
src/pages/optimization2/optimization2.vue
... ... @@ -1075,27 +1075,51 @@
1075 1075 */
1076 1076 primary(item) {
1077 1077  
1078   - // 跳转详情页面
1079   - this.toDetail(item);
  1078 + // 判断是否在App内
  1079 + if (this.isCNLive.value) {
  1080 +
  1081 + // 判断加入购物车函数是否存在
  1082 + if (typeof this.$parent.addToShoppingCart === 'function') {
  1083 +
  1084 + // 加入购物车
  1085 + this.$parent.addToShoppingCart(item);
  1086 + }
  1087 + } else {
  1088 +
  1089 + // 跳转详情页面
  1090 + this.toDetail(item);
  1091 + }
1080 1092 },
1081 1093  
1082 1094 /**
1083 1095 * 跳转搜索页面
1084 1096 */
1085 1097 toSearch() {
1086   -
1087   - // 跳转搜索页面(跳转封装)
1088   - if (typeof this.$parent.gotoDetail === 'function') {
1089 1098  
1090   - // 设置跳转参数
1091   - let params = {
1092   - type: '5',
1093   - to: window.location.origin + window.location.pathname + '#/search',
1094   - shop_type: ''
1095   - };
  1099 + // 判断是否在App内
  1100 + if (this.isCNLive.value) {
1096 1101  
1097   - // 页面跳转
1098   - 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 + }
1099 1123 }
1100 1124 },
1101 1125  
... ...
static/js/cnLive_openinstall.js
... ... @@ -112,61 +112,77 @@ if (url.toLowerCase() === &quot;managemall.cnlive.com&quot; || url.toLowerCase() === &quot;mana
112 112 } else {
113 113 appKey = "gzqtwt"; //测试appKey
114 114 }
115   -//初始化openInstall方法
116   -function openInstallReady() {
117   - var timestamp = Date.parse(new Date());
118   - openInstallData = parseQueryString();
119   - openInstallData.channelCodeName = channelCodeName;
120   - openInstallData.timestamp = timestamp;
121   - openInstallData.changeSecDefChannel = true; //安卓默认定位二级频道
122   - openInstallData.type = type;
123   - // 处理礼物通过openinstall唤起APP
124   - let share_mold = encodeURIComponent(decodeURIComponent(openInstallData.share_mold));
125   - let shop_type = encodeURIComponent(decodeURIComponent(openInstallData.shop_type));
126   - let shop_to = encodeURIComponent(decodeURIComponent(openInstallData.shop_to));
127   - let shop_shop_type = encodeURIComponent(decodeURIComponent(openInstallData.shop_shop_type));
128   - // 把值链接的方式绑定到shopShoptype
129   - let shopCollection =
130   - "shop_shop_type=" +
131   - shop_shop_type +
132   - "&shop_to=" +
133   - shop_to +
134   - "&shop_type=" +
135   - shop_type +
136   - "&share_mold=" +
137   - share_mold;
138   - // Base64位编码加密
139   - // var CryptoJS = require('crypto-js')
140   - var wordArray = CryptoJS.enc.Utf8.parse(shopCollection);
141   - let shopData = encodeURIComponent(CryptoJS.enc.Base64.stringify(wordArray));
142   - openInstallData.shopData = shopData;
143   - mm = new OpenInstall(
144   - {
145   - /*appKey必选参数,openinstall平台为每个应用分配的ID*/
146   - appKey: appKey,
147   - /*可选参数,自定义android平台的apk下载文件名;个别andriod浏览器下载时,中文文件名显示乱码,请慎用中文文件名!*/
148   - //apkFileName : 'com.fm.openinstalldemo-v2.2.0.apk',
149   - /*可选参数,是否优先考虑拉起app,以牺牲下载体验为代价*/
150   - //preferWakeup:true,
151   - /*自定义遮罩的html*/
152   - //mask:function(){
153   - // return "<div id='openinstall_shadow' style='position:fixed;left:0;top:0;background:rgba(0,255,0,0.5);filter:alpha(opacity=50);width:100%;height:100%;z-index:10000;'></div>"
154   - //},
155   - /*openinstall初始化完成的回调函数,可选*/
156   - channelCode: channelName,
157   - onready: function() {
158   - /*在app已安装的情况尝试拉起app*/
159   - /*不管是iOS还是安卓必须在openInstall后台打开启用scheme按钮才能执行schemeWakeup方法*/
160   - /*在ios9.2以下schemeWakeup方法才能在openInstall初始化完毕之后执行拉起app操作,
161   - ios9.2以上必须通过点击触发wakeupOrInstall方法才能拉起app */
162   - /*在安卓里只要打开了启用scheme按钮,schemeWakeup方法就会执行*/
163   - /*隐藏以下代码是为了解决安卓网家家app内部打开h5会弹出跳转外部应用的bug*/
164   - //var m = this;
165   - //m.schemeWakeup();
166   - }
167   - },
168   - openInstallData
169   - );
  115 +/**
  116 + * 初始化openInstall方法
  117 + * @param {Object} schemeParams [从接口取到的schemeParams参数,对象形式的,未做任何处理]
  118 + */
  119 +function openInstallReady(schemeParams) {
  120 +
  121 + // 初始化数据
  122 + var timestamp = Date.parse(new Date());
  123 + openInstallData = parseQueryString();
  124 + openInstallData.channelCodeName = channelCodeName;
  125 + openInstallData.timestamp = timestamp;
  126 + openInstallData.changeSecDefChannel = true; //安卓默认定位二级频道
  127 + openInstallData.type = type;
  128 +
  129 + // 初始化通过openinstall唤起APP参数
  130 + let share_mold, shop_type, shop_to, shop_shop_type, shop_ext;
  131 +
  132 + // 判断如果传入了schemeParams的话,就不执行从地址栏取参数的操作,重新初始化一次OpenInstall
  133 + if (schemeParams && typeof schemeParams === 'object' && schemeParams.share_mold && schemeParams.shop_type && schemeParams.shop_to && schemeParams.shop_shop_type) {
  134 +
  135 + // 处理通过openinstall唤起APP参数
  136 + share_mold = schemeParams.share_mold;
  137 + shop_type = schemeParams.shop_type;
  138 + shop_to = schemeParams.shop_to;
  139 + shop_shop_type = schemeParams.shop_shop_type;
  140 + shop_ext = (schemeParams.shop_ext ? schemeParams.shop_ext : '');
  141 + } else {
  142 +
  143 + // 处理通过openinstall唤起APP参数
  144 + share_mold = encodeURIComponent(decodeURIComponent(openInstallData.share_mold));
  145 + shop_type = encodeURIComponent(decodeURIComponent(openInstallData.shop_type));
  146 + shop_to = encodeURIComponent(decodeURIComponent(openInstallData.shop_to));
  147 + shop_shop_type = encodeURIComponent(decodeURIComponent(openInstallData.shop_shop_type));
  148 + shop_ext = encodeURIComponent(decodeURIComponent(openInstallData.shop_ext));
  149 + }
  150 +
  151 + // 把值链接的方式绑定到shopShoptype
  152 + let shareString = "shop_shop_type=" + shop_shop_type + "&shop_to=" + shop_to + "&shop_type=" + shop_type + "&share_mold=" + share_mold + (shop_ext ? '&shop_extra=' + shop_ext : '');
  153 +
  154 + // Base64位编码加密
  155 + // var CryptoJS = require('crypto-js')
  156 + var wordArray = CryptoJS.enc.Utf8.parse(shareString);
  157 + let shopData = encodeURIComponent(CryptoJS.enc.Base64.stringify(wordArray));
  158 +
  159 + // 设置OpenInstall自定义参数
  160 + openInstallData.shopData = shopData;
  161 +
  162 + mm = new OpenInstall({
  163 + /*appKey必选参数,openinstall平台为每个应用分配的ID*/
  164 + appKey: appKey,
  165 + /*可选参数,自定义android平台的apk下载文件名;个别andriod浏览器下载时,中文文件名显示乱码,请慎用中文文件名!*/
  166 + //apkFileName : 'com.fm.openinstalldemo-v2.2.0.apk',
  167 + /*可选参数,是否优先考虑拉起app,以牺牲下载体验为代价*/
  168 + //preferWakeup:true,
  169 + /*自定义遮罩的html*/
  170 + //mask:function(){
  171 + // return "<div id='openinstall_shadow' style='position:fixed;left:0;top:0;background:rgba(0,255,0,0.5);filter:alpha(opacity=50);width:100%;height:100%;z-index:10000;'></div>"
  172 + //},
  173 + /*openinstall初始化完成的回调函数,可选*/
  174 + channelCode: channelName,
  175 + onready: function() {
  176 + /*在app已安装的情况尝试拉起app*/
  177 + /*不管是iOS还是安卓必须在openInstall后台打开启用scheme按钮才能执行schemeWakeup方法*/
  178 + /*在ios9.2以下schemeWakeup方法才能在openInstall初始化完毕之后执行拉起app操作,
  179 + ios9.2以上必须通过点击触发wakeupOrInstall方法才能拉起app */
  180 + /*在安卓里只要打开了启用scheme按钮,schemeWakeup方法就会执行*/
  181 + /*隐藏以下代码是为了解决安卓网家家app内部打开h5会弹出跳转外部应用的bug*/
  182 + //var m = this;
  183 + //m.schemeWakeup();
  184 + },
  185 + }, openInstallData);
170 186 }
171 187  
172 188 // $.ajax({
... ... @@ -198,4 +214,4 @@ function openInstallReady() {
198 214 // }
199 215 // });
200 216 // 本地测试
201 217 -openInstallReady();
  218 +openInstallReady();
202 219 \ No newline at end of file
... ...