用了wxs后,苹果手机IOS8.3系统无法打开小程序
发布于 6 年前 作者 schen 6625 次浏览 来自 官方Issues

我把wxs注释掉后,用户就可以打开访问了。有好几个用户打不开。目前怀疑是wxs对IOS低版本不兼容导致的

3 回复

var common = require(’./common.wxs’);

/**

* 获取单个商品sku退款总数

* @param {object} goods

*/

function getGoodsRefundCount(goods = {}) {

var skus = goods.skus || [];

var count = 0;

count = skus

.reduce(function(sum, curr) {

var refund = curr.refund || 0;

if (refund > 0) {

sum += refund;

}

return sum;

}, count);

return count;

}

/**

* 获取订单所有商品总数

* @param {array} list

*/

function getOrderGoodsCount(list = []) {

return list

.reduce(function(count, curr) {

count += common.getGoodsCount(curr);

return count;

}, 0);

}

/**

* 获取单个商品sku折扣总价

* @param {object} goods

*/

function getGoodsDiscountPrice(goods = {}) {

var price = goods.price || 0;

var discountPrice = goods.discountPrice || 0;

price = discountPrice || price;

var count = common.getGoodsCount(goods);

var totalPrice = (price * count).toFixed(2) * 1;

return totalPrice;

}

/**

* @description 获取单个有skus的商品的sku折扣总价

* @param {object} goods

* @returns

*/

function getGoodsDiscountSkuPrice(goods = {}) {

var skus = goods.skus || [];

var totalPrice = 0;

totalPrice = skus.reduce(function(total, curr) {

var price = curr.price || 0;

var discountPrice = curr.discountPrice || 0;

var quantity = curr.quantity || 0;

price = discountPrice || price;

if (quantity > 0) {

total += price * 1 * quantity * 1;

}

return total;

}, totalPrice);

return totalPrice.toFixed(2) * 1;

}

/**

* 获取单个商品sku退款总金额

* @param {object} goods

*/

function getGoodsRefundPrice(goods = {}) {

var price = goods.price || 0;

var discountPrice = goods.discountPrice || 0;

price = discountPrice || price;

var count = getGoodsRefundCount(goods);

var totalPrice = (price * count).toFixed(2) * 1;

return totalPrice;

}

/**

* @description 获取单个有skus的商品的sku退款总金额

* @param {object} goods

* @returns

*/

function getGoodsRefundSkuPrice(goods = {}) {

var skus = goods.skus || [];

var totalPrice = 0;

totalPrice = skus.reduce(function(total, curr) {

var price = curr.price || 0;

var discountPrice = curr.discountPrice || 0;

var refund = curr.refund || 0;

price = discountPrice || price;

if (refund > 0) {

total += price * 1 * refund * 1;

}

return total;

}, totalPrice);

return totalPrice.toFixed(2) * 1;

}

/**

* 获取订单所有商品总价(原价)

* @param {array} list

*/

function getOrderPrice(list = []) {

return list

.reduce(function(sum, curr) {

var useSkusPrice = curr.useSkusPrice || true;

var skuPriceType = curr.skuPriceType;

skuPriceType = useSkusPrice ? skuPriceType : ‘’;

sum += !skuPriceType ? common.getGoodsPrice(curr) : common.getGoodsSkuPrice(curr);

return sum;

}, 0)

.toFixed(2) * 1;

}

/**

* 获取订单所有商品折扣总价

* @param {array} list

*/

function getOrderDiscountPrice(list = []) {

return list

.reduce(function(sum, curr) {

var useSkusPrice = curr.useSkusPrice || true;

var skuPriceType = curr.skuPriceType;

skuPriceType = useSkusPrice ? skuPriceType : ‘’;

sum += !skuPriceType ? getGoodsDiscountPrice(curr) : getGoodsDiscountSkuPrice(curr);

return sum;

}, 0)

.toFixed(2) * 1;

}

/**

* 获取订单所有商品退款总金额

* @param {array} list

*/

function getOrderRefundPrice(list = []) {

return list

.reduce(function(sum, curr) {

var useSkusPrice = curr.useSkusPrice || true;

var skuPriceType = curr.skuPriceType;

skuPriceType = useSkusPrice ? skuPriceType : ‘’;

sum += !skuPriceType ? getGoodsRefundPrice(curr) : getGoodsRefundSkuPrice(curr);

return sum;

}, 0)

.toFixed(2) * 1;

}

/**

* 获取订单所有商品实付金额

* @param {array} list

* @param {number} postage

*/

function getOrderFinalPrice(list = [], postage = 0) {

var price = getOrderDiscountPrice(list) - getOrderRefundPrice(list) + postage * 1;

return price.toFixed(2) * 1;

}

// 获取订单价格明细

function getPriceDetail(props) {

var showRefundPriceOnly = props.showRefundPriceOnly; // 是否只显示退款金额

var showReductionPrice = typeof props.showReductionPrice === ‘undefined’

? true : props.showReductionPrice; // 显示优惠金额

var postage = props.postage || 0;

var goodsList = props.goodsList || [];

//商品总数

var orderCount = getOrderGoodsCount(goodsList);

// 原价

var orderPrice = getOrderPrice(goodsList);

// 折扣价

var orderDiscountPrice = getOrderDiscountPrice(goodsList);

// 优惠金额

var orderReductionPrice = (orderPrice - orderDiscountPrice).toFixed(2) * 1;

// 退款金额

var orderRefundPrice = getOrderRefundPrice(goodsList);

// 实付金额

var price = getOrderFinalPrice(goodsList, postage);

var show = !showRefundPriceOnly; // 显示其他价格

if (showRefundPriceOnly) {

orderRefundPrice = getOrderDiscountPrice(goodsList);

}

var list = [

{

show: show,

title: ‘商品数量’,

value: orderCount

},

{

show: show,

title: ‘商品总金额’,

value: '¥ ’ + orderPrice

},

{

show: show && showReductionPrice,

title: ‘优惠金额’,

class: ‘error-color’,

value: '- ¥ ’ + orderReductionPrice

},

{

show: show,

title: ‘邮费’,

value: '¥ ’ + postage

},

{

show: orderRefundPrice > 0,

title: ‘退款金额’,

value: showRefundPriceOnly ? '¥ ’ : '- ¥ ’ + orderRefundPrice

},

{

show: show,

title: ‘实付金额’,

class: ‘warn-color font_bold’,

value: '¥ ’ + price

}

];

return list;

}

// 获取采购商品总数

function getTotalCount(list = []) {

var totalCount = 0;

totalCount = list.reduce(function(count, curr) {

var goodsList = curr.goodsList || [];

count += getOrderGoodsCount(goodsList);

return count;

}, totalCount);

return totalCount;

}

/**

* @description 根据商品数量和邮费规则计算邮费

* @param {*} { postage = 0, num = 0, config }

* @returns

*/

function getPostage(props) {

var postage = props.postage || 0;

var num = props.num || 0;

var config = props.config;

if (num <= 0) return postage;

if (!config) return postage;

var startCount = config.startCount || ‘’;

var startAmt = config.startAmt || ‘’;

var everyIncreaseCount = config.everyIncreaseCount || ‘’;

var everyIncreaseAmt = config.everyIncreaseAmt || ‘’;

// 全空

if (!startCount && !startAmt) return postage;

// start_count件内start_amt元

postage = startAmt * 1;

if (num <= startCount) return postage;

if (!everyIncreaseCount || !everyIncreaseAmt) return postage;

// 每增加increase_count件,邮费增加increase_amt元

postage += Math.floor((num - startCount) / everyIncreaseCount) * everyIncreaseAmt;

return postage;

}

function getGoodsListPostage(props) {

var goodsList = props.goodsList || [];

var postageConfig = props.postageConfig;

var postageObj = {

num: getOrderGoodsCount(goodsList),

config: postageConfig,

};

var postage = getPostage(postageObj);

return postage;

}

// 获取采购商品总价格

function getTotalPrice(list = [], needPostage = true) {

var totalPrice = 0;

totalPrice = list.reduce(function(price, curr) {

var goodsList = curr.goodsList || [];

var postageConfig = curr.postageConfig;

var postage = needPostage ? getGoodsListPostage({goodsList, postageConfig}) : 0;

price += getOrderFinalPrice(goodsList, postage);

return price;

}, totalPrice);

return totalPrice.toFixed(2) * 1;

}

function isSamePrice(skus = []) {

return common.dedupArr(skus, ‘price’).length == 1;

}

module.exports = {

getPriceDetail: getPriceDetail,

getTotalCount: getTotalCount,

getGoodsListPostage: getGoodsListPostage,

getTotalPrice: getTotalPrice,

isSamePrice: isSamePrice,

};

贴一下wxs的内容

应该是低版本的兼容性问题…

回到顶部