Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
ui
mongo-ui
Commits
3d06e205
Commit
3d06e205
authored
Jul 29, 2020
by
郭志伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: pay联调
parent
e6840ba1
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
101 additions
and
145 deletions
+101
-145
App.vue
src/App.vue
+5
-1
LoginModal.vue
src/components/LoginModal.vue
+86
-9
prod.config.js
src/config/prod.config.js
+1
-2
main.js
src/main.js
+1
-1
http.js
src/service/http.js
+3
-3
utils.js
src/service/utils.js
+0
-123
index.vue
src/views/Goods/index.vue
+0
-1
paytest.vue
src/views/paytest.vue
+5
-5
No files found.
src/App.vue
View file @
3d06e205
...
@@ -4,11 +4,16 @@
...
@@ -4,11 +4,16 @@
<div
class=
"loading-container"
v-show=
"isLoading"
>
<div
class=
"loading-container"
v-show=
"isLoading"
>
<cr-loading
class=
"loading"
size=
"24px"
>
加载中...
</cr-loading>
<cr-loading
class=
"loading"
size=
"24px"
>
加载中...
</cr-loading>
</div>
</div>
<login-modal
/>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
{
mapState
,
mapActions
}
from
"
vuex
"
;
import
{
mapState
,
mapActions
}
from
"
vuex
"
;
import
LoginModal
from
"
@/components/LoginModal
"
;
export
default
{
export
default
{
components
:
{
LoginModal
},
computed
:
{
computed
:
{
...
mapState
([
"
isLoading
"
])
...
mapState
([
"
isLoading
"
])
},
},
...
@@ -22,7 +27,6 @@ export default {
...
@@ -22,7 +27,6 @@ export default {
</
script
>
</
script
>
<
style
lang=
"less"
scoped
>
<
style
lang=
"less"
scoped
>
@import "./style/index.less";
@import "./style/index.less";
.loading-container {
.loading-container {
position: fixed;
position: fixed;
left: 0;
left: 0;
...
...
src/components/LoginModal.vue
View file @
3d06e205
...
@@ -3,15 +3,45 @@
...
@@ -3,15 +3,45 @@
v-model=
"show"
v-model=
"show"
title=
"您好
<br
/>
欢迎来到芒果保险"
title=
"您好
<br
/>
欢迎来到芒果保险"
:closeable="true"
:closeable="true"
cancel-btn
=""
cancel-btn
confirm-btn="确定"
confirm-btn="确定"
@confirm="login"
>
>
<cr-form
class=
"login-form"
ref=
"loginForm"
validate-trigger=
"onBlur"
@
submit=
"onFormSubmit"
@
failed=
"onFormFailed"
>
<cr-field
v-model=
"formData.phoneNo"
name=
"phoneNo"
type=
"tel"
label=
"手机号"
placeholder=
"请填写您的手机号"
:rules=
"validOptions[0]"
/>
<cr-field
v-model=
"formData.verifyCode"
name=
"verifyCode"
type=
"tel"
label=
"验证码"
placeholder=
"请填写验证码"
:rules=
"validOptions[1]"
>
<template
v-slot:button
>
<a
href=
"javascript:;"
>
获取验证码
</a>
<span
class=
"login-form-remain"
>
59s
</span>
</
template
>
</cr-field>
</cr-form>
</modal>
</modal>
</template>
</template>
<
script
>
<
script
>
import
Modal
from
"
@/components/Modal
"
;
import
Modal
from
"
@/components/Modal
"
;
import
{
loginByPhone
}
from
"
@/api/user
"
;
import
{
isPhone
}
from
"
@/service/validation
"
;
export
default
{
export
default
{
name
:
"
LoginModal
"
,
name
:
"
LoginModal
"
,
components
:
{
components
:
{
...
@@ -19,18 +49,65 @@ export default {
...
@@ -19,18 +49,65 @@ export default {
},
},
data
()
{
data
()
{
return
{
return
{
show
:
false
show
:
false
,
formData
:
{
phoneNo
:
""
,
verifyCode
:
""
},
validOptions
:
[
[
{
require
:
true
,
message
:
"
请填写您的手机号
"
},
{
validator
:
isPhone
,
message
:
"
手机号格式错误
"
}
],
[{
require
:
true
,
message
:
"
请填写验证码
"
}]
]
};
};
},
},
watch
:
{
methods
:
{
value
(
val
)
{
onFormSubmit
()
{
this
.
show
=
val
;
this
.
login
();
}
},
},
methods
:
{}
onFormFailed
(
errorInfo
)
{
const
{
errors
}
=
errorInfo
;
this
.
$notify
({
type
:
"
warning
"
,
message
:
errors
[
0
].
message
});
},
async
login
()
{
this
.
formData
.
loginChannel
=
1
;
this
.
formData
.
openId
=
1
;
const
res
=
await
loginByPhone
(
this
.
formData
);
if
(
res
.
code
===
0
)
{
this
.
$notify
(
"
登录成功
"
);
}
}
}
};
};
</
script
>
</
script
>
<
style
lang=
"less"
scoped
>
<
style
lang=
"less"
scoped
>
@import "../../../../style/var.less";
@import "../style/var.less";
.login-form {
@{deep} .cr-field--error-message {
display: none;
}
@{deep} .cr-cell {
&-group {
&::after {
display: none;
}
}
background-color: @gray-1;
border-radius: @border-radius-md;
margin-bottom: 12px;
align-items: center;
padding: 9px 16px;
&::after {
display: none;
}
&__title {
color: #333333;
display: flex;
align-items: center;
}
}
}
</
style
>
</
style
>
src/config/prod.config.js
View file @
3d06e205
export
default
{
export
default
{
// basicHost: "https://hathaway-mg.liangkebang.net/",
basicHost
:
"
https://hathaway-mg.liangkebang.net/
"
,
basicHost
:
"
http://127.0.0.1:8964/
"
,
wxAppId
:
"
wx514de17b23d53a20
"
wxAppId
:
"
wx514de17b23d53a20
"
};
};
src/main.js
View file @
3d06e205
import
Vue
from
"
vue
"
;
import
Vue
from
"
vue
"
;
import
"
@/service/load
"
;
import
App
from
"
./App.vue
"
;
import
App
from
"
./App.vue
"
;
import
router
from
"
./router
"
;
import
router
from
"
./router
"
;
import
store
from
"
./store
"
;
import
store
from
"
./store
"
;
...
@@ -6,7 +7,6 @@ import "./style/index.less";
...
@@ -6,7 +7,6 @@ import "./style/index.less";
import
"
amfe-flexible
"
;
import
"
amfe-flexible
"
;
// import vConsole from "vconsole";
// import vConsole from "vconsole";
import
"
@/assets/icons/index
"
;
import
"
@/assets/icons/index
"
;
import
"
@/service/load
"
;
import
"
@/service/cherry-ui
"
;
import
"
@/service/cherry-ui
"
;
Vue
.
config
.
productionTip
=
false
;
Vue
.
config
.
productionTip
=
false
;
...
...
src/service/http.js
View file @
3d06e205
//引入axios
//引入axios
import
store
from
"
@/store
"
;
import
store
from
"
@/store
"
;
import
axios
from
"
axios
"
;
import
axios
from
"
axios
"
;
import
cherry
from
"
@qg/cherry-ui
"
;
import
{
Notify
}
from
"
@qg/cherry-ui
"
;
import
config
from
"
../config
"
;
import
config
from
"
../config
"
;
// import qs from "qs";
// import qs from "qs";
const
CancelToken
=
axios
.
CancelToken
;
const
CancelToken
=
axios
.
CancelToken
;
const
{
Notify
}
=
cherry
;
//
const { Notify } = cherry;
axios
.
defaults
.
baseURL
=
config
.
basicHost
;
axios
.
defaults
.
baseURL
=
config
.
basicHost
;
axios
.
defaults
.
timeout
=
30000
;
axios
.
defaults
.
timeout
=
30000
;
...
@@ -53,7 +53,7 @@ axios.interceptors.response.use(
...
@@ -53,7 +53,7 @@ axios.interceptors.response.use(
response
=>
{
response
=>
{
afterRequest
();
afterRequest
();
delete
pending
[
response
.
config
.
url
];
delete
pending
[
response
.
config
.
url
];
if
(
response
.
data
.
code
===
0
)
{
if
(
response
.
data
.
code
===
"
0
"
)
{
return
response
.
data
;
return
response
.
data
;
// return response.data.data;
// return response.data.data;
}
}
...
...
src/service/utils.js
View file @
3d06e205
/**
* 时间转换
* @param {String} time 需要转换的时间
* @param {String} cFormat 格式 {y}-{m}-{d} {h}:{i}:{s}
* @return: {String} timeStr 转换完成的时间
*/
export
function
parseTime
(
time
,
cFormat
)
{
if
(
arguments
.
length
===
0
)
{
return
"
-
"
;
}
if
(
time
==
null
)
{
return
"
-
"
;
}
const
format
=
cFormat
||
"
{y}-{m}-{d} {h}:{i}:{s}
"
;
let
date
;
if
(
time
==
""
)
{
date
=
new
Date
();
}
else
if
(
typeof
time
===
"
object
"
)
{
date
=
time
;
}
else
{
if
((
""
+
time
).
length
===
10
)
time
=
parseInt
(
time
)
*
1000
;
if
(
String
(
time
).
indexOf
(
"
T
"
)
>
-
1
)
{
time
=
time
.
replace
(
/T/g
,
"
"
).
replace
(
/
\.
.*/g
,
""
);
}
if
(
String
(
time
).
indexOf
(
"
-
"
)
>
-
1
&&
String
(
time
).
indexOf
(
"
T
"
)
==
-
1
)
{
time
=
time
.
replace
(
/-/g
,
"
/
"
);
}
date
=
new
Date
(
time
);
}
const
formatObj
=
{
y
:
date
.
getFullYear
(),
m
:
date
.
getMonth
()
+
1
,
d
:
date
.
getDate
(),
h
:
date
.
getHours
(),
i
:
date
.
getMinutes
(),
s
:
date
.
getSeconds
(),
a
:
date
.
getDay
()
};
const
timeStr
=
format
.
replace
(
/{
(
y|m|d|h|i|s|a
)
+}/g
,
(
result
,
key
)
=>
{
let
value
=
formatObj
[
key
];
if
(
key
===
"
a
"
)
{
return
[
"
日
"
,
"
一
"
,
"
二
"
,
"
三
"
,
"
四
"
,
"
五
"
,
"
六
"
][
value
];
}
if
(
result
.
length
>
0
&&
value
<
10
)
{
value
=
"
0
"
+
value
;
}
return
value
||
0
;
});
return
timeStr
;
}
/**
* 时间显示效果显示
* @param {String} time 需要转换的时间
* @param {String} option 格式 {y}-{m}-{d} {h}:{i}:{s}
* @return: {String} 转换完成的时间
*/
export
function
formatTime
(
time
,
option
)
{
time
=
+
time
*
1000
;
const
d
=
new
Date
(
time
);
const
now
=
Date
.
now
();
const
diff
=
(
now
-
d
)
/
1000
;
if
(
diff
<
30
)
{
return
"
刚刚
"
;
}
else
if
(
diff
<
3600
)
{
// less 1 hour
return
Math
.
ceil
(
diff
/
60
)
+
"
分钟前
"
;
}
else
if
(
diff
<
3600
*
24
)
{
return
Math
.
ceil
(
diff
/
3600
)
+
"
小时前
"
;
}
else
if
(
diff
<
3600
*
24
*
2
)
{
return
"
1天前
"
;
}
if
(
option
)
{
return
parseTime
(
time
,
option
);
}
else
{
return
(
d
.
getMonth
()
+
1
+
"
月
"
+
d
.
getDate
()
+
"
日
"
+
d
.
getHours
()
+
"
时
"
+
d
.
getMinutes
()
+
"
分
"
);
}
}
/**
* 延时函数
* @param {Function} func 方法
* @param {Number} wait 等待时间
* @param {Boolean} immediate 是否立即执行
* @return: {Function} result 方法执行
*/
export
function
debounce
(
func
,
wait
,
immediate
)
{
let
timeout
,
args
,
context
,
timestamp
,
result
;
const
later
=
function
()
{
// 据上一次触发时间间隔
const
last
=
+
new
Date
()
-
timestamp
;
// 上次被包装函数被调用时间间隔last小于设定时间间隔wait
if
(
last
<
wait
&&
last
>
0
)
{
timeout
=
setTimeout
(
later
,
wait
-
last
);
}
else
{
timeout
=
null
;
// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
if
(
!
immediate
)
{
result
=
func
.
apply
(
context
,
args
);
if
(
!
timeout
)
context
=
args
=
null
;
}
}
};
return
function
(...
args
)
{
context
=
this
;
timestamp
=
+
new
Date
();
const
callNow
=
immediate
&&
!
timeout
;
// 如果延时不存在,重新设定延时
if
(
!
timeout
)
timeout
=
setTimeout
(
later
,
wait
);
if
(
callNow
)
{
result
=
func
.
apply
(
context
,
args
);
context
=
args
=
null
;
}
return
result
;
};
}
/**
/**
* 替换邮箱字符
* 替换邮箱字符
* @param {String} email 输入字符串
* @param {String} email 输入字符串
...
...
src/views/Goods/index.vue
View file @
3d06e205
...
@@ -23,7 +23,6 @@ import GoodList from "@/components/GoodList/index";
...
@@ -23,7 +23,6 @@ import GoodList from "@/components/GoodList/index";
import
Tabbar
from
"
@/components/Tabbar
"
;
import
Tabbar
from
"
@/components/Tabbar
"
;
import
copyright
from
"
@/components/Copyright
"
;
import
copyright
from
"
@/components/Copyright
"
;
import
RecordLayer
from
"
@/components/RecordLayer
"
;
import
RecordLayer
from
"
@/components/RecordLayer
"
;
export
default
{
export
default
{
name
:
"
GoodsList
"
,
name
:
"
GoodsList
"
,
components
:
{
components
:
{
...
...
src/views/paytest.vue
View file @
3d06e205
...
@@ -128,7 +128,7 @@ export default {
...
@@ -128,7 +128,7 @@ export default {
methods
:
{
methods
:
{
async
login
()
{
async
login
()
{
const
res
=
await
loginByPhone
(
this
.
loginInfo
);
const
res
=
await
loginByPhone
(
this
.
loginInfo
);
if
(
res
.
code
===
0
)
{
if
(
res
.
code
===
"
0
"
)
{
this
.
mongoToken
=
res
.
data
.
token
;
this
.
mongoToken
=
res
.
data
.
token
;
localStorage
.
setItem
(
"
mongoToken
"
,
res
.
data
.
token
);
localStorage
.
setItem
(
"
mongoToken
"
,
res
.
data
.
token
);
}
}
...
@@ -148,7 +148,7 @@ export default {
...
@@ -148,7 +148,7 @@ export default {
if
(
this
.
openId
)
return
;
if
(
this
.
openId
)
return
;
const
code
=
this
.
$route
.
query
.
code
;
const
code
=
this
.
$route
.
query
.
code
;
const
res
=
await
getwxOpenId
({
code
,
appId
:
cfg
.
wxAppId
});
const
res
=
await
getwxOpenId
({
code
,
appId
:
cfg
.
wxAppId
});
if
(
res
.
code
===
0
)
{
if
(
res
.
code
===
"
0
"
)
{
this
.
openId
=
res
.
data
.
openId
;
this
.
openId
=
res
.
data
.
openId
;
localStorage
.
setItem
(
"
openId
"
,
res
.
data
.
openId
);
localStorage
.
setItem
(
"
openId
"
,
res
.
data
.
openId
);
}
}
...
@@ -168,7 +168,7 @@ export default {
...
@@ -168,7 +168,7 @@ export default {
}
}
this
.
tradeType
=
tradeType
;
this
.
tradeType
=
tradeType
;
const
res
=
await
placeOrder
.
create
(
this
.
insuredOrderInfo
);
const
res
=
await
placeOrder
.
create
(
this
.
insuredOrderInfo
);
if
(
res
.
code
===
0
)
{
if
(
res
.
code
===
"
0
"
)
{
this
.
orderInfo
=
res
.
data
;
this
.
orderInfo
=
res
.
data
;
}
}
},
},
...
@@ -180,7 +180,7 @@ export default {
...
@@ -180,7 +180,7 @@ export default {
return
;
return
;
}
}
const
res
=
await
placeOrder
.
pay
({
payOrderNo
,
payType
,
tradeType
});
const
res
=
await
placeOrder
.
pay
({
payOrderNo
,
payType
,
tradeType
});
if
(
res
.
code
===
0
)
{
if
(
res
.
code
===
"
0
"
)
{
let
payInfo
=
{
let
payInfo
=
{
url
:
res
.
data
.
payUrl
,
url
:
res
.
data
.
payUrl
,
params
:
{
params
:
{
...
@@ -202,7 +202,7 @@ export default {
...
@@ -202,7 +202,7 @@ export default {
pollTimer
=
setTimeout
(()
=>
{
pollTimer
=
setTimeout
(()
=>
{
const
{
payOrderNo
,
payType
}
=
this
.
orderInfo
;
const
{
payOrderNo
,
payType
}
=
this
.
orderInfo
;
placeOrder
.
polling
({
payOrderNo
,
payType
}).
then
(
res
=>
{
placeOrder
.
polling
({
payOrderNo
,
payType
}).
then
(
res
=>
{
if
(
res
.
code
===
0
)
{
if
(
res
.
code
===
"
0
"
)
{
const
{
result
,
payState
}
=
res
.
data
;
const
{
result
,
payState
}
=
res
.
data
;
if
(
result
)
{
if
(
result
)
{
this
.
$toast
(
"
支付成功
"
);
this
.
$toast
(
"
支付成功
"
);
...
...
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