Feat(时令尝鲜):接口对接

This commit is contained in:
lifizer
2023-09-23 18:13:26 +08:00
parent c9ceac9f37
commit 2d73c2fe46
35 changed files with 2834 additions and 1547 deletions
+4 -4
View File
@@ -590,7 +590,8 @@ export async function routerPermissions(url, type) {
if (!path) {
path = '/' + getCurrentPageUrlWithArgs()
}
if (Vue.prototype.$deviceType == 'routine') {
if (Vue.prototype.$deviceType === 'routine') {
// 如果是微信小程序,跳转到授权页
// 先校验用户是否授权,如果授权了,进行自动登录
//authorize('userInfo')因为小程序登录和授权接口的修改基本废了
@@ -601,7 +602,6 @@ export async function routerPermissions(url, type) {
//检查授权信息
let authUserInfo = await checkAuth().catch(err => {
});
if (authUserInfo) {
var loginInfo = {
userInfo: authUserInfo,
@@ -646,7 +646,8 @@ export async function routerPermissions(url, type) {
})
} else {
// 跳转到登录页面或者授权页面
if (path == '/pages/shop/ShoppingCart/index' || path == '/pages/user/User/index') {
// path == '/pages/shop/ShoppingCart/index' ||
if ( path == '/pages/user/User/index') {
switchTab({
path,
})
@@ -893,7 +894,6 @@ export const handleLoginFailure = () => {
let path = '/' + getCurrentPageUrlWithArgs()
let qrCode = handleQrCode()
if (qrCode) {
// 当前是通过海报扫描进入的
+24
View File
@@ -0,0 +1,24 @@
// 日期格式化
export function formatterDate(date, flag = '-', mode = 'date') {
const year = new Date(date).getFullYear()
const month = new Date(date).getMonth() + 1
const day = new Date(date).getDate()
return `${year}${flag}${month > 9 ? month : '0' + month}${flag}${day > 9 ? day : '0' + day}`
}
export function formatContent(html) {
// 去掉img标签里的style、width、height属性
let contentData = html.replace(/<img[^>]*>/gi, function(match, capture) {
match = match.replace(`style=""`, '')
match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '')
match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '')
match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '')
return match
}) // 修改所有style里的width属性为max-width:100%
contentData = contentData.replace(/style="[^"]+"/gi, function(match, capture) {
match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi, 'max-width:100%;'); return match
}) // 去掉<br/>标签
contentData = contentData.replace(/<br[^>]*\/>/gi, '') // img标签添加style属性:max-width:100%;height:auto
contentData = contentData.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;margin:0 auto;"')
return contentData
}