Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mayi-mp-shop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
程默
mayi-mp-shop
Commits
22f7cc82
Commit
22f7cc82
authored
Nov 01, 2023
by
李嘉林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
index-params解析
parent
ee63910b
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
6 deletions
+61
-6
src/api/goods.js
+4
-0
src/pages/index/index.vue
+29
-4
src/utils/index.js
+1
-1
src/utils/request.js
+12
-0
src/utils/tool.js
+15
-1
No files found.
src/api/goods.js
View file @
22f7cc82
...
...
@@ -58,4 +58,8 @@ export default {
queryProductInformation
(
productId
)
{
return
requestGET
(
`
${
process
.
env
.
OLSHOP_URL
}
/product/queryProductInformation?productId=
${
productId
}
`
)
},
// 记录分销员分享商品信息
saveSpokesmanShareGoodsLog
(
data
)
{
return
requestGET
(
`
${
process
.
env
.
OLSHOP_URL
}
/product/saveSpokesmanShareGoodsLog`
,
data
)
},
};
src/pages/index/index.vue
View file @
22f7cc82
...
...
@@ -9,10 +9,12 @@ let forUrlAddKey = require("mayi-front-tools/forUrlAddKey").default;
let
getUrlKey
=
require
(
"mayi-front-tools/getUrlKey"
).
default
;
import
spokesman
from
"@/api/spokesman.js"
;
import
shop
from
"@/api/shop.js"
;
import
goods
from
"@/api/goods.js"
;
import
indexApi
from
"@/api/index.js"
;
import
{
serialize
,
getQueryVariable
,
DFSImg
,
parseQueryString
}
from
"@/utils/index"
;
import
login
from
"@/api/login"
;
import
{
getStoreInfo
,
setStoreInfo
}
from
"@/utils/mayi.js"
;
import
tool
from
'@/utils/tool.js'
const
app
=
getApp
();
const
{
log
}
=
app
;
export
default
{
...
...
@@ -152,11 +154,18 @@ export default {
wx
.
setStorageSync
(
this
.
$store
.
state
.
mixid
+
'storeId'
,
''
)
wx
.
setStorageSync
(
this
.
$store
.
state
.
mixid
+
'sellerId'
,
''
)
}
Object
.
assign
(
this
.
$data
,
this
.
$options
.
data
());
this
.
options
=
options
;
log
.
info
(
this
.
options
,
'----------------index-----options'
)
Object
.
assign
(
this
.
$data
,
this
.
$options
.
data
());
try
{
const
h5Params
=
options
&&
options
.
params
?
JSON
.
parse
(
decodeURIComponent
(
options
.
params
))
:
""
;
let
h5Params
=
{};
if
(
options
.
params
)
{
if
(
tool
.
isObjectString
(
options
.
params
))
{
h5Params
=
JSON
.
parse
(
decodeURIComponent
(
options
.
params
));
}
else
{
h5Params
=
parseQueryString
(
decodeURIComponent
(
options
.
params
));
}
}
console
.
log
(
"onLoad-h5Params"
,
h5Params
);
if
(
h5Params
&&
h5Params
.
offlineShopCode
)
{
// 存储h5url门店信息
setStoreInfo
({
...
...
@@ -164,7 +173,6 @@ export default {
offlineShopName
:
h5Params
.
offlineShopName
,
});
}
}
catch
(
e
)
{
console
.
log
(
e
)
}
if
(
wx
.
getStorageSync
(
"workBox"
)){
this
.
params
+=
`&workBox=
${
wx
.
getStorageSync
(
"workBox"
)}
`
}
...
...
@@ -211,6 +219,7 @@ export default {
this
.
link
=
decodeURIComponent
(
options
.
share
);
log
.
info
(
'options.share-link'
,
this
.
link
)
console
.
log
(
'options.share-link'
,
this
.
link
)
console
.
log
(
'options.share-options'
,
this
.
options
)
this
.
spokesmanGroupId
=
getQueryVariable
(
this
.
link
,
"spokesmanGroupId"
)
||
""
;
this
.
spokesmanShopId
=
...
...
@@ -236,6 +245,8 @@ export default {
}
this
.
page
=
""
;
this
.
params
=
""
;
// 记录分销员分享商品信息
// this.saveSpokesmanShareGoodsLog();
}
else
if
(
options
.
from
&&
options
.
from
==
"h5login"
)
{
let
params
=
JSON
.
parse
(
options
.
params
);
log
.
info
(
params
.
sessionid
,
'--------------h5login--params'
)
...
...
@@ -642,6 +653,20 @@ export default {
url
=
beforeUrl
+
nextUrl
;
return
url
;
},
saveSpokesmanShareGoodsLog
()
{
let
query
=
{
spokesmanGroupId
:
getQueryVariable
(
this
.
link
,
"spokesmanGroupId"
)
||
""
,
spokesmanRelId
:
getQueryVariable
(
this
.
link
,
"spokesmanRelId"
)
||
""
,
userId
:
getQueryVariable
(
this
.
link
,
"userId"
)
||
""
,
productId
:
getQueryVariable
(
this
.
link
,
"productId"
)
||
""
,
terminalProductId
:
getQueryVariable
(
this
.
link
,
"terminalProductId"
)
||
""
,
mixid
:
getQueryVariable
(
this
.
link
,
"mixid"
)
||
""
,
spokesmanShopId
:
getQueryVariable
(
this
.
link
,
"spokesmanShopId"
)
||
""
,
timeStamp
:
getQueryVariable
(
this
.
link
,
"timeStamp"
)
||
""
,
}
console
.
log
(
"saveSpokesmanShareGoodsLog"
,
query
)
goods
.
saveSpokesmanShareGoodsLog
(
query
);
}
},
onUnload
()
{
log
.
info
(
"卸载----------------"
,
this
.
options
);
...
...
src/utils/index.js
View file @
22f7cc82
...
...
@@ -68,7 +68,7 @@ export function getQueryVariable(query, variable) {
// url完整链接把参数转成对象
export
function
parseQueryString
(
url
)
{
let
str
=
url
.
split
(
"?"
)
[
1
]
,
let
str
=
url
.
split
(
"?"
)
.
length
>
1
?
url
.
split
(
"?"
)[
1
]
:
url
,
items
=
str
.
split
(
"&"
);
let
arr
,
name
,
value
;
let
obj
=
{}
...
...
src/utils/request.js
View file @
22f7cc82
...
...
@@ -23,6 +23,12 @@ export async function requestGET(url, options) {
resolve
(
res
)
},
fail
:
function
(
res
)
{
if
(
res
.
data
.
message
&&
res
.
data
.
message
==
"API rate limit exceeded"
)
{
wx
.
showToast
({
title
:
'您好,当前访问人数过多,请稍后再试试'
,
icon
:
'none'
,
});
}
reject
(
res
)
}
})
...
...
@@ -48,6 +54,12 @@ export async function requestPOST(url, options) {
resolve
(
res
)
},
fail
:
function
(
res
)
{
if
(
res
.
data
.
message
&&
res
.
data
.
message
==
"API rate limit exceeded"
)
{
wx
.
showToast
({
title
:
'您好,当前访问人数过多,请稍后再试试'
,
icon
:
'none'
,
});
}
reject
(
res
)
}
})
...
...
src/utils/tool.js
View file @
22f7cc82
...
...
@@ -45,9 +45,23 @@ function debounce(fn, interval) {
},
gapTime
);
};
}
/**
* 判断字符串对象
* @param {*} str 目标参数
* @returns
*/
function
isObjectString
(
str
)
{
try
{
JSON
.
parse
(
str
);
return
true
;
}
catch
(
e
)
{
return
false
;
}
}
export
default
{
throttle
,
debounce
,
appArea
appArea
,
isObjectString
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment