Fix(入驻):[#2105]经纬度要求保留6位小数,实际只有前两位小数保留,后四位全部被置为0导致定位有偏差

This commit is contained in:
lifizer
2024-07-30 11:49:24 +08:00
parent f9be8af78f
commit 01eaea0cdc
2 changed files with 21 additions and 19 deletions
+19 -17
View File
@@ -46,31 +46,33 @@ Vue.prototype.$validator = function (rule) {
// cookie.clearAll();
// cookie.set(CACHE_KEY, 1);
// }
//强制转为几位小数,不足的补0
var forceToDecimal = function changeToDecimal(x, len, ignore = false) {
var f_x = parseFloat(x);
// 强制转为几位小数,不足的补0
const forceToDecimal = function changeToDecimal(value, len = 1) {
const f_x = parseFloat(value)
if (isNaN(f_x)) {
return 0;
return 0
}
var f = Math.round(f_x * 100) / 100;
if (ignore) {
f = Math.floor(f_x * 100) / 100;
}
var s = f.toString();
var rs = s.indexOf('.');
let s = f_x.toString()
let rs = s.indexOf('.')
if (rs < 0) {
rs = s.length;
s += '.';
rs = s.length
s += '.'
}
while (s.length <= rs + len) {
s += '0';
s += '0'
}
return s;
const tempArr = s.split('.')
const decimalArr = tempArr[1].split('')
let res = tempArr[0] + '.'
for (let i = 0; i < len; i++) {
res += decimalArr[i]
}
return res
}
//强制转为2位小数,不足的补0
var force2Decimal = function change2Decimal(x, ignore = false) {
return forceToDecimal(x, 2, false);
// 强制转为2位小数,不足的补0
const force2Decimal = function change2Decimal(value) {
return forceToDecimal(value, 2)
}
Vue.prototype.$force2Decimal = force2Decimal
+2 -2
View File
@@ -757,8 +757,8 @@ export default {
_this.isLike = data.zanVo !== null
_this.isFavorite = data.hasFavorite
_this.favoriteCount = data.favoriteCount
_this.inn.latitude = _this.inn.latitude ? parseFloat(_this.inn.latitude) : 24.993587
_this.inn.longitude = _this.inn.longitude ? parseFloat(_this.inn.longitude) : 102.779656
_this.inn.latitude = _this.inn.latitude > 0 ? _this.inn.latitude : 24.993587
_this.inn.longitude = _this.inn.longitude > 0 ? _this.inn.longitude : 102.779656
// fix bug#1107
if (!_this.isLoad) {
// 该店铺无商品则不显示“精选商品”