Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wechat_lung
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hanpeng
wechat_lung
Commits
5d540859
Commit
5d540859
authored
Aug 20, 2019
by
hanpeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
-mark- 肺癌靶向家园公众号通用方法
parents
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
128 additions
and
0 deletions
+128
-0
medtap_core_wx.js
medtap_core_wx.js
+128
-0
No files found.
medtap_core_wx.js
0 → 100644
View file @
5d540859
define
([
'zepto'
,
'md5'
],
function
(
$
,
md5
)
{
/*
*微信服务号通用方法
*/
//设置请求头
var
setHeader
=
function
()
{
var
headers
=
{};
headers
[
'apptype'
]
=
'wechat_lung'
;
headers
[
'user-os'
]
=
'wechat'
;
return
headers
;
}
//获取url上的参数
var
getRequest
=
function
(
strParame
)
{
var
args
=
new
Object
();
var
query
=
window
.
location
.
search
.
substring
(
1
);
var
pairs
=
query
.
split
(
"&"
);
for
(
var
i
=
0
;
i
<
pairs
.
length
;
i
++
)
{
var
pos
=
pairs
[
i
].
indexOf
(
'='
);
if
(
pos
==
-
1
)
continue
;
var
argname
=
pairs
[
i
].
substring
(
0
,
pos
);
var
value
=
pairs
[
i
].
substring
(
pos
+
1
);
value
=
decodeURIComponent
(
value
);
args
[
argname
]
=
value
;
}
args
[
strParame
]
=
args
[
strParame
]
||
""
;
return
args
[
strParame
];
}
//页面跳转
var
pushWindow
=
function
(
urlParame
)
{
var
ts
=
new
Date
().
getTime
();
//时间戳
if
(
urlParame
.
indexOf
(
'?'
)
==
-
1
)
{
window
.
location
.
href
=
urlParame
+
'?ts='
+
ts
;
}
else
{
window
.
location
.
href
=
urlParame
+
'&ts='
+
ts
;
}
}
//loading效果
var
loading
=
function
(
isOpen
)
{
var
html
=
'<div class="mod"><div class="cssload-spin-box"></div></div>'
;
$
(
'body'
).
append
(
html
);
if
(
isOpen
==
1
)
{
$
(
'.mod'
).
show
();
}
else
{
setTimeout
(
function
()
{
$
(
'.mod'
).
hide
();
},
1000
)
}
}
//toast 提示
var
toast
=
function
(
msgParame
)
{
//设置消息框提示时间
var
time
=
msgParame
.
time
;
if
(
time
==
undefined
||
time
==
''
)
{
time
=
2000
;
}
//初始化消息框元素
var
el
=
document
.
createElement
(
"div"
);
el
.
setAttribute
(
"class"
,
"web-toast"
);
el
.
innerHTML
=
msgParame
.
message
;
document
.
body
.
appendChild
(
el
);
el
.
classList
.
add
(
"fadeIn"
);
setTimeout
(
function
()
{
el
.
classList
.
remove
(
"fadeIn"
);
el
.
classList
.
add
(
"fadeOut"
);
/* 监听动画结束,移除提示信息元素 */
el
.
addEventListener
(
"animationend"
,
function
()
{
document
.
body
.
removeChild
(
el
);
});
el
.
addEventListener
(
"webkitAnimationEnd"
,
function
()
{
document
.
body
.
removeChild
(
el
);
});
},
time
);
}
//请求函数
var
submitAjax
=
function
(
opts
)
{
//请求参数
var
ajaxParame
=
opts
.
data
||
''
;
var
params
=
{};
if
(
ajaxParame
!=
""
)
{
for
(
var
i
in
ajaxParame
)
{
params
[
i
]
=
ajaxParame
[
i
];
}
}
//是否异步请求
var
async
=
true
;
if
(
opts
.
async
!=
undefined
)
{
async
=
opts
.
async
;
}
//设置contentType
var
type
=
"application/x-www-form-urlencoded"
;
if
(
opts
.
contentType
==
"application/json"
)
{
type
=
"application/json"
;
params
=
JSON
.
stringify
(
params
);
}
$
.
ajax
({
url
:
opts
.
url
,
type
:
opts
.
type
,
headers
:
setHeader
(),
async
:
opts
.
async
,
contentType
:
type
,
data
:
params
,
success
:
function
(
res
)
{
opts
.
success
(
res
);
},
error
:
function
(
res
)
{
opts
.
error
(
res
);
}
})
}
//模块暴露
return
{
setHeader
:
setHeader
,
getRequest
:
getRequest
,
pushWindow
:
pushWindow
,
loading
:
loading
,
toast
:
toast
,
submitAjax
:
submitAjax
}
})
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