Commit 44ede266243ff397548783b252490be9b25813ad

Authored by 王强
1 parent 52a70004

优选库:

1、添加版本比较函数
2、优选库,优选首页,根据App版本判断是否显示“积分商城”模块
src/pages/common/common.vue
@@ -1012,6 +1012,51 @@ @@ -1012,6 +1012,51 @@
1012 } 1012 }
1013 }, 1013 },
1014 1014
  1015 + /**
  1016 + * 比较版本号大小(数字形式比较)
  1017 + * @author HONOR
  1018 + * @param {string} nowVersion [当前版本号]
  1019 + * @param {string} targetVersion [目标版本号]
  1020 + * @returns {boolean} [true: 大于等于目标版本,false: 小于目标版本]
  1021 + */
  1022 + compareVersion(nowVersion, targetVersion) {
  1023 +
  1024 + // 判断参数合法性,必须是字符串
  1025 + if (typeof nowVersion !== "string" || typeof targetVersion !== "string") {
  1026 + return false;
  1027 + }
  1028 +
  1029 + // 版本字符串转换数组
  1030 + var nowArr = nowVersion.split(".");
  1031 + var targetArr = targetVersion.split(".");
  1032 +
  1033 + // 判断两个数组长度相同
  1034 + if (nowArr.length !== targetArr.length) {
  1035 + return false;
  1036 + }
  1037 +
  1038 + // 遍历比较版本大小,有结果随时返回
  1039 + for (var i = 0; i < nowArr.length; i++) {
  1040 +
  1041 + // 判断版本号是否为数字
  1042 + if (isNaN(nowArr[i]) || isNaN(targetArr[i])) {
  1043 + return false;
  1044 + }
  1045 +
  1046 + // 比较版本大小
  1047 + if (parseInt(nowArr[i]) === targetArr[i]) {
  1048 + continue;
  1049 + } else if (parseInt(nowArr[i]) > targetArr[i]) {
  1050 + return true;
  1051 + } else if (parseInt(nowArr[i]) < targetArr[i]) {
  1052 + return false;
  1053 + }
  1054 + }
  1055 +
  1056 + // 返回,版本号相等
  1057 + return true;
  1058 + },
  1059 +
1015 /* 图片上传压缩/旋转优化 开始 */ 1060 /* 图片上传压缩/旋转优化 开始 */
1016 1061
1017 /** 1062 /**
src/pages/optimization2/optimization2.vue
@@ -92,7 +92,7 @@ @@ -92,7 +92,7 @@
92 </div> 92 </div>
93 93
94 <!-- 积分商城 --> 94 <!-- 积分商城 -->
95 - <div class="section shop-list" ref="integralMallBox" v-if="pointsLists && pointsLists.length"> 95 + <div class="section shop-list" ref="integralMallBox" v-if="showIntegral && pointsLists && pointsLists.length">
96 96
97 <!-- 标题 --> 97 <!-- 标题 -->
98 <text-bg-title-com 98 <text-bg-title-com
@@ -200,6 +200,7 @@ @@ -200,6 +200,7 @@
200 quality: null, // 品质优选 200 quality: null, // 品质优选
201 salesOptions: null, // 热销排行选项 201 salesOptions: null, // 热销排行选项
202 sales: null, // 热销排行数据 202 sales: null, // 热销排行数据
  203 + showIntegral: false, // 是否显示积分商城模块,默认不显示
203 points: null, // 用户积分 204 points: null, // 用户积分
204 pointsLists: null, // 积分商城数据 205 pointsLists: null, // 积分商城数据
205 likeLists: null, // 猜你喜欢列表 206 likeLists: null, // 猜你喜欢列表
@@ -417,6 +418,25 @@ @@ -417,6 +418,25 @@
417 // 判断是否有积分商城 418 // 判断是否有积分商城
418 if (datas.integral_goods && datas.integral_goods.length) { 419 if (datas.integral_goods && datas.integral_goods.length) {
419 420
  421 +
  422 + // 判断在App内
  423 + if (this.isCNLive.value) {
  424 +
  425 + // 判断App版本,判断是否显示积分商城模块
  426 + if (typeof this.$parent.compareVersion === 'function') {
  427 +
  428 + // 获取平台版本
  429 + let version = this.$route.query.version;
  430 +
  431 + // 根据平台,判断是否符合版本
  432 + if ((this.isiPhone.value && this.$parent.compareVersion(version, '1.9.1')) || (this.isAndroid.value && this.$parent.compareVersion(version, '1.7.3.3'))) {
  433 +
  434 + // 设置显示积分商城模块
  435 + this.$set(this, 'showIntegral', true);
  436 + }
  437 + }
  438 + }
  439 +
420 // 热销排行数据 440 // 热销排行数据
421 this.$set(this, 'pointsLists', datas.integral_goods); 441 this.$set(this, 'pointsLists', datas.integral_goods);
422 } else { 442 } else {