Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
mini-program
/
hmd
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 594b3100
authored
Jul 17, 2023
by
liimin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
结构调整
1 parent
34aee901
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
92 additions
and
89 deletions
api/env/index.js
api/module/index.js
api/module/system.js
api/request/http.js
api/request/sign.js
components/image/index.js
config.js
packageMine/pages/order/detail/detail.js
project.config.json
utils/constants.js
utils/util.js
api/env/index.js
View file @
594b310
...
...
@@ -111,10 +111,17 @@ const defaultMerchantId = {
uat
:
'44210895'
,
prod
:
'44189923'
}[
target
[
index
]]
const
CONFIG_ENV_MAP
=
{
'1'
:
'develope'
,
'2'
:
'test'
,
'3'
:
'production'
}
module
.
exports
=
{
index
,
domain
,
pathEnum
,
secretKey
,
defaultMerchantId
defaultMerchantId
,
env
:
CONFIG_ENV_MAP
[
index
]
}
api/module/index.js
View file @
594b310
...
...
@@ -5,6 +5,7 @@ import homeApi from './home'
import
discoveryApi
from
'./discovery'
import
shopmallApi
from
'./shopmall'
import
mineApi
from
'./mine'
import
systemApi
from
'./system'
module
.
exports
=
{
wechatApi
,
entmicroApi
,
...
...
@@ -12,5 +13,6 @@ module.exports = {
homeApi
,
discoveryApi
,
shopmallApi
,
mineApi
mineApi
,
systemApi
}
\ No newline at end of file
api/module/system.js
0 → 100644
View file @
594b310
import
http
from
"../request/http"
;
import
{
env
}
from
"../env/index"
;
const
serverConfig
=
{
mockRequestCount
:
null
,
mockTimer
:
{},
mockCache
:
null
,
};
const
configModule
=
'mini-hmd'
const
configUrl
=
`https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=
${
configModule
}
&env=
${
env
}
`
;
/**获取mock数据 */
const
getMockData
=
async
()
=>
{
const
MOCKDATA
=
wx
.
p
.
storage
.
get
(
"mock_data"
);
try
{
if
(
MOCKDATA
&&
Date
.
now
()
-
MOCKDATA
.
createTime
<
5
*
60
e3
)
{
return
Promise
.
resolve
(
MOCKDATA
);
}
else
{
if
(
!
serverConfig
.
mockRequestCount
)
{
serverConfig
.
mockCache
=
null
;
serverConfig
.
mockRequestCount
=
Date
.
now
();
const
data
=
await
http
.
wx_request
({
url
:
configUrl
});;
data
.
createTime
=
Date
.
now
();
serverConfig
.
mockCache
=
data
;
wx
.
p
.
storage
.
set
(
"mock_data"
,
data
);
return
Promise
.
resolve
(
data
);
}
else
{
const
key
=
Date
.
now
();
return
new
Promise
((
resolve
)
=>
{
serverConfig
.
mockTimer
[
key
]
=
setInterval
(()
=>
{
if
(
serverConfig
.
mockCache
)
{
clearInterval
(
serverConfig
.
mockTimer
[
key
]);
serverConfig
.
mockRequestCount
=
null
;
resolve
(
serverConfig
.
mockCache
);
}
},
1
e3
);
});
}
}
}
catch
(
error
)
{
if
(
serverConfig
.
mockTimer
[
key
])
clearInterval
(
serverConfig
.
mockTimer
[
key
]);
serverConfig
.
mockRequestCount
=
null
;
return
Promise
.
reject
(
error
);
}
};
// 图片版本号
const
getImageVersion
=
async
()
=>
{
const
accountInfo
=
await
getMockData
()
return
accountInfo
?.
version
||
Date
.
now
()
}
module
.
exports
=
{
getImageVersion
}
\ No newline at end of file
api/request/http.js
View file @
594b310
import
sign
from
'./sign.js'
import
{
defaultMerchantId
,
secretKey
,
pathEnum
,
domain
,
index
,
sign
}
from
'./sign.js'
}
from
'../env/index'
let
INTERRUPT
=
false
/**接口 */
class
Request
{
...
...
@@ -24,6 +23,21 @@ class Request {
returnAll
);
}
wx_request
({
url
,
method
=
'GET'
,
data
=
{},
header
=
{},
dataType
=
'json'
,
responseType
=
"text"
}){
return
new
Promise
((
resolve
)
=>
{
wx
.
request
({
url
,
data
,
method
,
header
,
dataType
,
responseType
,
success
(
response
)
{
resolve
(
response
.
data
)
}
})
})
}
reportTrack
(
params
)
{
return
this
.
request
(
'POST'
,
params
,
true
)
}
...
...
@@ -136,22 +150,5 @@ class Request {
const
projectName
=
method
.
split
(
'.'
)[
2
]
return
projectName
}
getMock
()
{
let
url
=
'https://oss-config.dev.glsx.com.cn/mock/6264ff4760f415276f6dfe62/aicard-config'
if
(
index
==
3
||
index
==
4
)
url
=
'https://oss-config.test.glsx.com.cn/mock/6274e3050da5034a58680aa6/aicard-config'
return
new
Promise
((
resolve
)
=>
{
wx
.
request
({
url
,
data
:
{},
method
:
'GET'
,
header
:
{},
dataType
:
'json'
,
responseType
:
'text'
,
success
(
response
)
{
resolve
(
response
.
data
)
}
})
})
}
}
export
default
new
Request
()
\ No newline at end of file
api/request/sign.js
View file @
594b310
import
{
sha1
,
qs
}
from
'../../lib/index'
import
environment
from
'../env/index.js'
const
sign
=
(
params
,
secret
,
noSignAttr
=
[])
=>
{
delete
params
.
sign
var
objStr
=
qs
.
stringify
(
params
,
{
...
...
@@ -32,8 +31,4 @@ const sign = (params, secret, noSignAttr = []) => {
realObj
.
sign
=
sha1
(
secret
+
str
.
join
(
''
)
+
secret
).
toUpperCase
()
return
realObj
}
module
.
exports
=
{
...
environment
,
sign
}
\ No newline at end of file
export
default
sign
\ No newline at end of file
components/image/index.js
View file @
594b310
// components/image/index.js
import
{
IMG_URL
,
IMG_VERSION
}
from
'~/utils/constants'
}
from
'~/config'
import
{
systemApi
}
from
'~/api/index'
Component
({
externalClasses
:
[
'custom-class'
,
'class'
],
/**
...
...
@@ -19,7 +21,7 @@ Component({
let
isFullAdd
=
checkList
.
map
(
item
=>
url
.
includes
(
item
)).
some
(
item
=>
item
)
this
.
setData
({
isWebp
,
imagePath
:
`
${
isFullAdd
?
''
:
IMG_URL
}${
url
}
?v=`
+
await
IMG_VERSION
()
imagePath
:
`
${
isFullAdd
?
''
:
IMG_URL
}${
url
}
?v=`
+
await
systemApi
.
getImageVersion
()
})
}
}
...
...
config.js
View file @
594b310
...
...
@@ -10,4 +10,4 @@ export const preReleaseAppId = 'wx6e40cfb83ce4ffb1'
export
const
dsnUrl
=
'https://44b18e4acc2e4ab18f12a69a561b55bc@sentry.glsx.com.cn/39'
// cdn图片地址
export
const
IMG_URL
=
'https://img02.glsx.com.cn/weapp/resource/miniprogram/hmd'
export
const
IMG_URL
=
'https://img02.glsx.com.cn/weapp/resource/miniprogram/hmd
/
'
packageMine/pages/order/detail/detail.js
View file @
594b310
// packageMine/pages/order/detail/detail.js
import
QR
from
'~/utils/lib/wxqrcode'
import
{
orderMixin
...
...
project.config.json
View file @
594b310
...
...
@@ -56,7 +56,7 @@
],
"include"
:
[]
},
"appid"
:
"wx
fe82b8d65d07808f
"
,
"appid"
:
"wx
6e40cfb83ce4ffb1
"
,
"projectname"
:
"hmd"
,
"libVersion"
:
"2.24.4"
}
\ No newline at end of file
utils/constants.js
View file @
594b310
import
getAppId
from
'~/utils/utils_wx'
// 图片cdn 加速使用地址
export
const
IMG_URL
=
'https://img02.glsx.com.cn/weapp/resource/miniprogram/hmd/'
// 缓存get方法为空的默认指定值
export
const
DEFAULT_GET_STORAGEKEY
=
[
'sessionId'
,
'merchantId'
,
'userInfo'
]
export
const
appId
=
getAppId
.
getAppId
()
// 缓存get方法key的对应才映射值
export
const
STORAGE_OBJECTkEY
=
{
system_info
:
'system_info'
,
...
...
@@ -17,15 +11,7 @@ export const STORAGE_OBJECTkEY = {
sessionId
:
'sessionId'
,
}
// 图片版本号
export
const
IMG_VERSION
=
async
()
=>
{
const
accountInfo
=
await
wx
.
p
.
util
.
getMockData
()
return
accountInfo
?.
version
||
Date
.
now
()
}
export
default
{
IMG_URL
,
DEFAULT_GET_STORAGEKEY
,
STORAGE_OBJECTkEY
,
IMG_VERSION
STORAGE_OBJECTkEY
}
\ No newline at end of file
utils/util.js
View file @
594b310
import
api
from
'~/api/request/http'
/**
* 日期格式化
* let time = new Date().format('yyyy-MM-dd hh:mm:ss') //log 2020-07-31 10:00:00
...
...
@@ -127,44 +126,6 @@ const parseString = str => {
return
obj
}
/**获取mock数据 */
let
mockRequestCount
=
null
,
mockTimer
=
{},
mockCache
=
null
const
getMockData
=
async
()
=>
{
const
MOCKDATA
=
wx
.
p
.
storage
.
get
(
'mock_data'
)
try
{
if
(
MOCKDATA
&&
Date
.
now
()
-
MOCKDATA
.
createTime
<
5
*
60
e3
)
{
return
Promise
.
resolve
(
MOCKDATA
)
}
else
{
if
(
!
mockRequestCount
)
{
mockCache
=
null
mockRequestCount
=
Date
.
now
()
const
data
=
await
api
.
getMock
()
data
.
createTime
=
Date
.
now
()
mockCache
=
data
wx
.
p
.
storage
.
set
(
'mock_data'
,
data
)
return
Promise
.
resolve
(
data
)
}
else
{
const
key
=
Date
.
now
()
return
new
Promise
((
resolve
)
=>
{
mockTimer
[
key
]
=
setInterval
(()
=>
{
if
(
mockCache
)
{
clearInterval
(
mockTimer
[
key
])
mockRequestCount
=
null
resolve
(
mockCache
)
}
},
1
e3
)
})
}
}
}
catch
(
error
)
{
if
(
mockTimer
[
key
])
clearInterval
(
mockTimer
[
key
])
mockRequestCount
=
null
return
Promise
.
reject
(
error
)
}
}
const
Util
=
{
onReachBottom
,
isFullSucreen
,
...
...
@@ -172,6 +133,5 @@ const Util = {
throttle
,
isEmptyObj
,
parseString
,
getMockData
}
export
default
Util
Write
Preview
Markdown
is supported
Attach a file
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 post a comment