Commit 8aeef4e0 authored by gu-jinli1118's avatar gu-jinli1118
Browse files

20230831

parent 646116b0
Pipeline #31 failed with stages
in 0 seconds
/* big.js v5.2.2 https://github.com/MikeMcl/big.js/LICENCE */
!function (e) {
"use strict";
var r,
i = 20,
s = 1,
P = 1e6,
o = -7,
f = 21,
c = "[big.js] ",
u = c + "Invalid ",
b = u + "decimal places",
h = u + "rounding mode",
x = c + "Division by zero",
l = {},
D = void 0,
a = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
function R(e, r, t, n) {
var i = e.c,
s = e.e + r + 1;
if (s < i.length) {
if (1 === t) n = 5 <= i[s];else if (2 === t) n = 5 < i[s] || 5 == i[s] && (n || s < 0 || i[s + 1] !== D || 1 & i[s - 1]);else if (3 === t) n = n || !!i[0];else if (n = !1, 0 !== t) throw Error(h);
if (s < 1) i.length = 1, i[0] = n ? (e.e = -r, 1) : e.e = 0;else {
if (i.length = s--, n) for (; 9 < ++i[s];) i[s] = 0, s-- || (++e.e, i.unshift(1));
for (s = i.length; !i[--s];) i.pop();
}
} else if (t < 0 || 3 < t || t !== ~~t) throw Error(h);
return e;
}
function t(e, r, t, n) {
var i,
s,
o = e.constructor,
f = !e.c[0];
if (t !== D) {
if (t !== ~~t || t < (3 == r) || P < t) throw Error(3 == r ? u + "precision" : b);
for (t = n - (e = new o(e)).e, e.c.length > ++n && R(e, t, o.RM), 2 == r && (n = e.e + t + 1); e.c.length < n;) e.c.push(0);
}
if (i = e.e, t = (s = e.c.join("")).length, 2 != r && (1 == r || 3 == r && n <= i || i <= o.NE || i >= o.PE)) s = s.charAt(0) + (1 < t ? "." + s.slice(1) : "") + (i < 0 ? "e" : "e+") + i;else if (i < 0) {
for (; ++i;) s = "0" + s;
s = "0." + s;
} else if (0 < i) {
if (++i > t) for (i -= t; i--;) s += "0";else i < t && (s = s.slice(0, i) + "." + s.slice(i));
} else 1 < t && (s = s.charAt(0) + "." + s.slice(1));
return e.s < 0 && (!f || 4 == r) ? "-" + s : s;
}
l.abs = function () {
var e = new this.constructor(this);
return e.s = 1, e;
}, l.cmp = function (e) {
var r,
t = this,
n = t.c,
i = (e = new t.constructor(e)).c,
s = t.s,
o = e.s,
f = t.e,
c = e.e;
if (!n[0] || !i[0]) return n[0] ? s : i[0] ? -o : 0;
if (s != o) return s;
if (r = s < 0, f != c) return c < f ^ r ? 1 : -1;
for (o = (f = n.length) < (c = i.length) ? f : c, s = -1; ++s < o;) if (n[s] != i[s]) return n[s] > i[s] ^ r ? 1 : -1;
return f == c ? 0 : c < f ^ r ? 1 : -1;
}, l.div = function (e) {
var r = this,
t = r.constructor,
n = r.c,
i = (e = new t(e)).c,
s = r.s == e.s ? 1 : -1,
o = t.DP;
if (o !== ~~o || o < 0 || P < o) throw Error(b);
if (!i[0]) throw Error(x);
if (!n[0]) return new t(0 * s);
var f,
c,
u,
h,
l,
a = i.slice(),
g = f = i.length,
p = n.length,
w = n.slice(0, f),
d = w.length,
v = e,
m = v.c = [],
E = 0,
M = o + (v.e = r.e - e.e) + 1;
for (v.s = s, s = M < 0 ? 0 : M, a.unshift(0); d++ < f;) w.push(0);
do {
for (u = 0; u < 10; u++) {
if (f != (d = w.length)) h = d < f ? 1 : -1;else for (l = -1, h = 0; ++l < f;) if (i[l] != w[l]) {
h = i[l] > w[l] ? 1 : -1;
break;
}
if (!(h < 0)) break;
for (c = d == f ? i : a; d;) {
if (w[--d] < c[d]) {
for (l = d; l && !w[--l];) w[l] = 9;
--w[l], w[d] += 10;
}
w[d] -= c[d];
}
for (; !w[0];) w.shift();
}
m[E++] = h ? u : ++u, w[0] && h ? w[d] = n[g] || 0 : w = [n[g]];
} while ((g++ < p || w[0] !== D) && s--);
return m[0] || 1 == E || (m.shift(), v.e--), M < E && R(v, o, t.RM, w[0] !== D), v;
}, l.eq = function (e) {
return !this.cmp(e);
}, l.gt = function (e) {
return 0 < this.cmp(e);
}, l.gte = function (e) {
return -1 < this.cmp(e);
}, l.lt = function (e) {
return this.cmp(e) < 0;
}, l.lte = function (e) {
return this.cmp(e) < 1;
}, l.minus = l.sub = function (e) {
var r,
t,
n,
i,
s = this,
o = s.constructor,
f = s.s,
c = (e = new o(e)).s;
if (f != c) return e.s = -c, s.plus(e);
var u = s.c.slice(),
h = s.e,
l = e.c,
a = e.e;
if (!u[0] || !l[0]) return l[0] ? (e.s = -c, e) : new o(u[0] ? s : 0);
if (f = h - a) {
for ((n = (i = f < 0) ? (f = -f, u) : (a = h, l)).reverse(), c = f; c--;) n.push(0);
n.reverse();
} else for (t = ((i = u.length < l.length) ? u : l).length, f = c = 0; c < t; c++) if (u[c] != l[c]) {
i = u[c] < l[c];
break;
}
if (i && (n = u, u = l, l = n, e.s = -e.s), 0 < (c = (t = l.length) - (r = u.length))) for (; c--;) u[r++] = 0;
for (c = r; f < t;) {
if (u[--t] < l[t]) {
for (r = t; r && !u[--r];) u[r] = 9;
--u[r], u[t] += 10;
}
u[t] -= l[t];
}
for (; 0 === u[--c];) u.pop();
for (; 0 === u[0];) u.shift(), --a;
return u[0] || (e.s = 1, u = [a = 0]), e.c = u, e.e = a, e;
}, l.mod = function (e) {
var r,
t = this,
n = t.constructor,
i = t.s,
s = (e = new n(e)).s;
if (!e.c[0]) throw Error(x);
return t.s = e.s = 1, r = 1 == e.cmp(t), t.s = i, e.s = s, r ? new n(t) : (i = n.DP, s = n.RM, n.DP = n.RM = 0, t = t.div(e), n.DP = i, n.RM = s, this.minus(t.times(e)));
}, l.plus = l.add = function (e) {
var r,
t = this,
n = t.constructor,
i = t.s,
s = (e = new n(e)).s;
if (i != s) return e.s = -s, t.minus(e);
var o = t.e,
f = t.c,
c = e.e,
u = e.c;
if (!f[0] || !u[0]) return u[0] ? e : new n(f[0] ? t : 0 * i);
if (f = f.slice(), i = o - c) {
for ((r = 0 < i ? (c = o, u) : (i = -i, f)).reverse(); i--;) r.push(0);
r.reverse();
}
for (f.length - u.length < 0 && (r = u, u = f, f = r), i = u.length, s = 0; i; f[i] %= 10) s = (f[--i] = f[i] + u[i] + s) / 10 | 0;
for (s && (f.unshift(s), ++c), i = f.length; 0 === f[--i];) f.pop();
return e.c = f, e.e = c, e;
}, l.pow = function (e) {
var r = this,
t = new r.constructor(1),
n = t,
i = e < 0;
if (e !== ~~e || e < -1e6 || 1e6 < e) throw Error(u + "exponent");
for (i && (e = -e); 1 & e && (n = n.times(r)), e >>= 1;) r = r.times(r);
return i ? t.div(n) : n;
}, l.round = function (e, r) {
var t = this.constructor;
if (e === D) e = 0;else if (e !== ~~e || e < -P || P < e) throw Error(b);
return R(new t(this), e, r === D ? t.RM : r);
}, l.sqrt = function () {
var e,
r,
t,
n = this,
i = n.constructor,
s = n.s,
o = n.e,
f = new i(.5);
if (!n.c[0]) return new i(n);
if (s < 0) throw Error(c + "No square root");
for (o = (e = 0 === (s = Math.sqrt(n + "")) || s === 1 / 0 ? ((r = n.c.join("")).length + o & 1 || (r += "0"), o = ((o + 1) / 2 | 0) - (o < 0 || 1 & o), new i(((s = Math.sqrt(r)) == 1 / 0 ? "1e" : (s = s.toExponential()).slice(0, s.indexOf("e") + 1)) + o)) : new i(s)).e + (i.DP += 4); t = e, e = f.times(t.plus(n.div(t))), t.c.slice(0, o).join("") !== e.c.slice(0, o).join(""););
return R(e, i.DP -= 4, i.RM);
}, l.times = l.mul = function (e) {
var r,
t = this.constructor,
n = this.c,
i = (e = new t(e)).c,
s = n.length,
o = i.length,
f = this.e,
c = e.e;
if (e.s = this.s == e.s ? 1 : -1, !n[0] || !i[0]) return new t(0 * e.s);
for (e.e = f + c, s < o && (r = n, n = i, i = r, c = s, s = o, o = c), r = new Array(c = s + o); c--;) r[c] = 0;
for (f = o; f--;) {
for (o = 0, c = s + f; f < c;) o = r[c] + i[f] * n[c - f - 1] + o, r[c--] = o % 10, o = o / 10 | 0;
r[c] = (r[c] + o) % 10;
}
for (o ? ++e.e : r.shift(), f = r.length; !r[--f];) r.pop();
return e.c = r, e;
}, l.toExponential = function (e) {
return t(this, 1, e, e);
}, l.toFixed = function (e) {
return t(this, 2, e, this.e + e);
}, l.toPrecision = function (e) {
return t(this, 3, e, e - 1);
}, l.toString = function () {
return t(this);
}, l.valueOf = l.toJSON = function () {
return t(this, 4);
}, (r = function t() {
function n(e) {
var r = this;
if (!(r instanceof n)) return e === D ? t() : new n(e);
e instanceof n ? (r.s = e.s, r.e = e.e, r.c = e.c.slice()) : function (e, r) {
var t, n, i;
if (0 === r && 1 / r < 0) r = "-0";else if (!a.test(r += "")) throw Error(u + "number");
for (e.s = "-" == r.charAt(0) ? (r = r.slice(1), -1) : 1, -1 < (t = r.indexOf(".")) && (r = r.replace(".", "")), 0 < (n = r.search(/e/i)) ? (t < 0 && (t = n), t += +r.slice(n + 1), r = r.substring(0, n)) : t < 0 && (t = r.length), i = r.length, n = 0; n < i && "0" == r.charAt(n);) ++n;
if (n == i) e.c = [e.e = 0];else {
for (; 0 < i && "0" == r.charAt(--i););
for (e.e = t - n - 1, e.c = [], t = 0; n <= i;) e.c[t++] = +r.charAt(n++);
}
}(r, e), r.constructor = n;
}
return n.prototype = l, n.DP = i, n.RM = s, n.NE = o, n.PE = f, n.version = "5.2.2", n;
}()).default = r.Big = r, "function" == typeof define && define.amd ? define(function () {
return r;
}) : "undefined" != typeof module && module.exports ? module.exports = r : e.Big = r;
}(this);
\ No newline at end of file
// 公众号appid
var mpAppId = 'wx42bbe857570c5b40'
// 临时
var domain = "http://127.0.0.1:8086"; //统一接口域名,测试环境
exports.domain = domain;
exports.mpAppId = mpAppId;
const PayType = {
SCOREPAY: 0, // 积分支付
WECHATPAY: 1, // 小程序支付
ALIPAY: 2,// 支付宝支付
WECHATPAY_SWEEP_CODE: 3,//微信扫码支付
WECHATPAY_H5: 4, //微信H5支付
WECHATPAY_MP: 5, //微信公众号支付
ALIPAY_H5: 6, //支付宝H5支付
ALIPAY_APP: 7, // 支付宝APP支付
WECHATPAY_APP: 8, // 微信APP支付
BALANCEPAY: 9 // 余额支付
}
const AppType = {
MINI: 1, // 小程序
MP: 2,// 微信公众号
PC: 3,//pc
H5: 4, //h5
ANDROID: 5, //安卓
IOS: 6, //苹果
ALI: 7, //支付宝H5
ALIMINI: 8, //支付宝小程序
}
module.exports = {
PayType,
AppType
};
import CryptoJS from 'crypto-js'
// 加密
const keyStr = '-mall4j-password' // 解密用的key
export function encrypt (word) {
const time = Date.now()
const key = CryptoJS.enc.Utf8.parse(keyStr)
const srcs = CryptoJS.enc.Utf8.parse(time + word) // 加密方式: 时间戳 + 密文
const encrypted = CryptoJS.AES.encrypt(srcs, key, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7})
return encrypted.toString()
}
var config = require("./config.js"); //统一的网络请求方法
var util = require("./util.js")
import {
AppType
} from './constant.js'
function request(params, isGetTonken) {
// 全局变量
var globalData = getApp().globalData; // 如果正在进行登陆,就将非登陆请求放在队列中等待登陆完毕后进行调用
// if (!isGetTonken && globalData.isLanding) {
// globalData.requestQueue.push(params);
// return;
// }
if (Object.prototype.toString.call(params.data) == '[object Array]') {
params.data = JSON.stringify(params.data);
} else if (Object.prototype.toString.call(params.data) == '[object Number]') {
params.data = params.data + '';
}
var needToken = false
// if (params.url.indexOf("/p/") == 0 || params.url.indexOf("/user/registerOrBindUser") == 0) {
// needToken = true
// }
wx.request({
// url: config.domain + params.url,
url: (params.domain ? params.domain : config.domain) + params.url,
//接口请求地址
data: params.data,
header: {
// 'content-type': params.method == "GET" ? 'application/x-www-form-urlencoded' : 'application/json;charset=utf-8',
// 'Authorization': params.login ? undefined : uni.getStorageSync('token')
'Authorization': uni.getStorageSync('token') ,
},
method: params.method == undefined ? "POST" : params.method,
dataType: 'json',
responseType: params.responseType == undefined ? 'text' : params.responseType,
success: function (res) {
const responseData = res.data
// 00000 请求成功
if (responseData.code === '00000') {
if (params.callBack) {
params.callBack(responseData.data);
}
return
}
// A00004 未授权
if (responseData.code === 'A00004') {
uni.removeStorageSync('loginResult');
uni.removeStorageSync('token');
// #ifdef H5
const ua = navigator.userAgent.toLowerCase();
if (ua.search(/MicroMessenger/i) > -1) uni.setStorageSync('appType', AppType.MP)
// #endif
uni.hideLoading();
if (!params.dontTrunLogin) {
if (uni.getStorageSync('hadLogin')) {
uni.showModal({
title: "提示",
content: "登录已过期",
cancelText: "取消",
confirmText: "确定",
success: res => {
if (res.confirm) {
// 跳转登录页面
var url = ''
// #ifdef H5 || MP-WEIXIN
if (uni.getStorageSync('appType') == AppType.MP || uni.getStorageSync('appType') == AppType.MINI) {
url = '/pages/login/login'
} else {
url = '/pages/accountLogin/accountLogin'
}
// #endif
// #ifdef APP-PLUS
var url = '/pages/accountLogin/accountLogin'
// #endif
uni.navigateTo({
url: url
})
} else {
uni.switchTab({
url: '/pages/index/index'
})
}
}
})
} else {
uni.showModal({
title: "提示",
content: "登录已过期",
cancelText: "取消",
confirmText: "确定",
success: res => {
if (res.confirm) {
// 跳转登录页面
// #ifdef H5
uni.navigateTo({
url: uni.getStorageSync('appType') == AppType.MP ? '/pages/login/login' : '/pages/accountLogin/accountLogin'
})
// #endif
// #ifdef MP-WEIXIN
uni.navigateTo({
url: '/pages/login/login'
})
// #endif
} else {
uni.switchTab({
url: '/pages/index/index'
})
}
}
})
// // 跳转登录页面
// // #ifdef H5
// uni.navigateTo({
// url: uni.getStorageSync('appType') == AppType.MP ? '/pages/login/login' : '/pages/accountLogin/accountLogin'
// })
// // #endif
// // #ifdef MP-WEIXIN
// uni.navigateTo({
// url: '/pages/login/login'
// })
// // #endif
}
}
return
}
// A00005 服务器出了点小差
if (responseData.code === 'A00005') {
console.error('============== 请求异常 ==============')
console.log('接口: ', params.url)
console.log('异常信息: ', responseData)
console.error('============== 请求异常 ==============')
if (params.errCallBack) {
params.errCallBack(responseData)
return
}
uni.showToast({
title: '服务器出了点小差~',
icon: 'none'
})
}
// A00001 用于直接显示提示用户的错误,内容由输入内容决定
if (responseData.code === 'A00001') {
if (params.errCallBack) {
params.errCallBack(responseData)
return
}
uni.showToast({
title: responseData.msg || 'Error',
icon: 'none'
})
return
}
// 其他异常
if (responseData.code !== '00000') {
// console.log('params', params)
if (params.errCallBack) {
params.errCallBack(responseData)
} else {
console.log(`接口: ${params.url}`)
console.log(`返回信息: `, res)
}
}
if (!globalData.isLanding) {
wx.hideLoading();
}
},
fail: function (err) {
uni.hideLoading();
if (err.errMsg == 'request:fail abort') {
console.log('请求被取消啦~')
return
}
setTimeout(() => {
uni.showToast({
// zheli
title: "服务器出了点小差",
icon: "none"
});
}, 1);
}
});
} //通过code获取token,并保存到缓存
var getToken = function () {
// uni.login({
// success: res => {
// // 发送 res.code 到后台换取 openId, sessionKey, unionId
// request({
// login: true,
// url: '/login?grant_type=mini_app',
// data: {
// principal: res.code
// },
// callBack: result => {
// // 没有获取到用户昵称,说明服务器没有保存用户的昵称,也就是用户授权的信息并没有传到服务器
// if (!result.nickName) {
// updateUserInfo();
// }
// if (result.userStutas == 0) {
// uni.showModal({
// showCancel: false,
// title: '提示',
// content: '您已被禁用,不能购买,请联系客服'
// });
// uni.setStorageSync('token', '');
// } else {
// uni.setStorageSync('token', 'bearer' + result.access_token); //把token存入缓存,请求接口数据时要用
// }
// var globalData = getApp().globalData;
// globalData.isLanding = false;
// while (globalData.requestQueue.length) {
// request(globalData.requestQueue.pop());
// }
// }
// }, true);
// }
// });
}; // 更新用户头像昵称
/**
* 微信公众号登录
* @param {Object} fn 登录成功回调
* @param {String} code 微信授权返回的code, 用于登录
*/
var mpLogin = function (fn, code) {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
request({
login: true,
url: '/appLogin',
data: {
principal: code,
appType: AppType.MP, // 登录类型
},
callBack: result => {
loginSuccess(result, fn)
}
}, true);
};
var getToken = function (fn) {
};
/**
* 登录成功后执行
* @param {Object} result 登录成功返回的数据
* @param {Object} fn 登录成功后的回调
*/
function loginSuccess (result, fn) {
// if (!result.enabled) {
// uni.showModal({
// showCancel: false,
// title: "提示",
// content: "您已被禁用,不能购买,请联系客服",
// cancelText: "取消",
// confirmText: "确定",
// success: function (res) {
// if (res.confirm) {
// wx.switchTab({
// url: '/pages/index/index'
// });
// }
// }
// })
// wx.setStorageSync('token', '');
// return
// }
// 保存登陆信息
wx.setStorageSync('loginResult', result)
// 保存成功登录标识,token过期判断
wx.setStorageSync('hadLogin', true)
// 没有获取到用户昵称,说明服务器没有保存用户的昵称,也就是用户授权的信息并没有传到服务器
// if (!result.pic) {
// updateUserInfo();
// }
const expiresTimeStamp = result.expiresIn * 1000 / 2 + new Date().getTime()
// 缓存token的过期时间
uni.setStorageSync('expiresTimeStamp', expiresTimeStamp)
wx.setStorageSync('token', result.accessToken); //把token存入缓存,请求接口数据时要用
// const routeUrlAfterLogin = uni.getStorageSync('routeUrlAfterLogin')
// const pages = getCurrentPages()
// if (pages.length === 1) {
// uni.reLaunch({
// url: routeUrlAfterLogin
// })
// uni.removeStorageSync('routeUrlAfterLogin')
// return
// }
// const prevPage = pages[pages.length - 2]
// if (!prevPage) {
// wx.switchTab({
// url: '/pages/index/index'
// });
// return
// }
// // 判断上一页面是否为tabbar页面 (首页和分类页无需登录接口)
// const isTabbar = prevPage.route === 'pages/user/user' || prevPage.route === 'pages/basket/basket'
// if (isTabbar) {
// wx.switchTab({
// url: '/' + prevPage.route
// });
// } else {
// // 非tabbar页面
// let backDelata = 0
// pages.forEach((page, index) => {
// if (page.$page.fullPath === routeUrlAfterLogin) {
// backDelata = pages.length - index - 1
// }
// })
// if (backDelata) {
// uni.navigateBack({
// delta: backDelata
// })
// } else {
// wx.switchTab({
// url: '/pages/index/index'
// });
// }
// }
if (fn) {
fn()
}
};
function updateUserInfo() {
uni.getUserInfo({
success: res => {
var userInfo = JSON.parse(res.rawData);
request({
url: "/p/user/setUserInfo",
method: "PUT",
data: {
avatarUrl: userInfo.avatarUrl,
nickName: userInfo.nickName
}
});
}
});
}
function isUserAuthInfo () {
// 查看是否授权
wx.getSetting({
success (res) {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称
wx.getUserInfo({
success: function (res) {
console.log(res.userInfo);
}
});
}
}
});
}
function mpAuthLogin (page, needCode) {
// 在微信环境打开,请求公众号网页登陆
var redirectUrl = null;
if (!page) {
redirectUrl = window.location.href
} else {
var {
protocol,
host,
pathname,
hash
} = window.location
var redirectUrl = `${protocol}//${host}` + page
}
var scope = 'snsapi_userinfo'
window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + config.mpAppId +
'&redirect_uri=' +
encodeURIComponent(redirectUrl) + '&response_type=code&scope=' + scope + '&state=' + (needCode ? 'needCode' :
'unNeedCode') +
'#wechat_redirect'
}
/**
* 获取购物车商品数量
*/
function getCartCount () {
if (!uni.getStorageSync('token')) {
// wx.removeTabBarBadge({
// index: 2
// });
util.removeTabBadge()
return
}
var params = {
url: "/p/shopCart/prodCount",
method: "GET",
dontTrunLogin: true,
data: {},
callBack: function (res) {
if (res > 0) {
wx.setTabBarBadge({
index: 2,
text: res + ""
});
var app = getApp().globalData;
getApp().globalData.totalCartCount = res;
} else {
wx.removeTabBarBadge({
index: 2
});
var app = getApp().globalData;
getApp().globalData.totalCartCount = 0;
}
}
};
request(params);
}
exports.getToken = getToken;
exports.request = request;
exports.getCartCount = getCartCount;
exports.updateUserInfo = updateUserInfo;
exports.mpAuthLogin = mpAuthLogin;
exports.loginSuccess = loginSuccess;
exports.mpLogin = mpLogin;
const formatTime = date => {
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
const hour = date.getHours();
const minute = date.getMinutes();
const second = date.getSeconds();
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':');
};
const formatNumber = n => {
n = n.toString();
return n[1] ? n : '0' + n;
};
const formatHtml = content => {
content = content.replace(/\<img/gi, '<img style="width:100% !important;height:auto !important;margin:0;display:flex;" ');
content = content.replace(/\<td/gi, '<td cellspacing="0" cellpadding="0" border="0" style="display:block;vertical-align:top;margin: 0px; padding: 0px; border: 0px;outline-width:0px;" ');
content = content.replace(/width=/gi, 'sss=');
content = content.replace(/height=/gi, 'sss=');
content = content.replace(/ \/\>/gi, ' style="max-width:100% !important;height:auto !important;margin:0;display:block;" \/\>');
return content;
};
/**
* 获取链接上的参数
*/
const getUrlKey = (name) => {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || ['', ''])[1]
.replace(/\+/g, '%20')) || null
}
/**
* 移除购物车Tabbar的数字
*/
const removeTabBadge = () => {
let pl = ''
// #ifdef MP-WEIXIN
pl = 'mp'
// #endif
uni.removeTabBarBadge({
index: pl=='mp' ? 3 : 2
})
}
module.exports = {
formatTime: formatTime,
getUrlKey: getUrlKey,
formatHtml: formatHtml,
removeTabBadge: removeTabBadge
};
\ No newline at end of file
function toPrice(val) {
if (!val) {
val = 0;
}
return val.toFixed(2);
}
;
function parsePrice(val) {
if (!val) {
val = 0;
}
return val.toFixed(2).split(".");
}
function array_contain(array, obj) {
for (var i = 0; i < array.length; i++) {
if (array[i] == obj) //如果要求数据类型也一致,这里可使用恒等号===
return true;
}
return false;
} //判断当前的规格值 是否可以选,即其他
function props_contain(allProperties, selectedPropObj, key, item, propKeys) {
var properties = "";
selectedPropObj[key] = item;
for (var j = 0; j < propKeys.length; j++) {
properties += propKeys[j] + ":" + selectedPropObj[propKeys[j]] + ";";
}
properties = properties.substring(0, properties.length - 1);
var find = false;
for (var i = 0; i < allProperties.length; i++) {
if (properties == allProperties[i]) {
find = true;
break;
}
}
return find;
}
function parseDiscount(discountRule) {
if (discountRule == 0) {
return '满额减';
} else if (discountRule == 1) {
return '满件减';
} else if (discountRule == 2) {
return '满额折';
} else if (discountRule == 3) {
return '满件折';
} else {
return '';
}
}
function parseDiscountMsg(discountRule, needAmount, discount) {
if (discountRule == 0) {
return '购满' + needAmount + '元减' + discount + '元';
} else if (discountRule == 1) {
return '购满' + needAmount + '件减' + discount + '元';
} else if (discountRule == 2) {
return '购满' + needAmount + '元打' + discount + '折';
} else if (discountRule == 3) {
return '购满' + needAmount + '件打' + discount + '折';
} else {
return '';
}
}
module.exports = {
toPrice: toPrice,
parsePrice: parsePrice,
array_contain: array_contain,
props_contain: props_contain,
parseDiscount: parseDiscount,
parseDiscountMsg: parseDiscountMsg
};
\ No newline at end of file
# just a flag
ENV = 'development'
// api接口请求地址
VUE_APP_BASE_API = 'http://127.0.0.1:8085'
# 静态资源文件url
VUE_APP_RESOURCES_URL = 'https://img.mall4j.com/'
# just a flag
ENV = 'production'
// api接口请求地址
VUE_APP_BASE_API = 'https://mini-admin.mall4j.com/apis'
# 静态资源文件url
VUE_APP_RESOURCES_URL = 'https://img.mall4j.com/'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment