Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
P
pica-professional-exam
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
Close sidebar
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
com.pica.cloud.education.frontend
pica-professional-exam
提交
9255d87a
提交
9255d87a
编写于
9月 07, 2020
作者:
guofeng.chen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
测试微信登录
上级
d0919bec
变更
5
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
95 行增加
和
7 行删除
+95
-7
main.js
src/main.js
+6
-0
router.js
src/router/router.js
+1
-1
user.js
src/store/modules/user.js
+21
-1
index.js
src/utils/index.js
+10
-0
goods-detail.vue
src/views/goods-detail.vue
+57
-5
未找到文件。
src/main.js
浏览文件 @
9255d87a
...
...
@@ -68,6 +68,12 @@ function fliterRoute(query, path) {
delete
query
.
projectId
;
has
=
true
;
}
// 商品详情页去掉code
if
(
path
===
'/goods-detail'
&&
query
.
code
)
{
store
.
dispatch
(
'getWxUserInfo'
,
query
.
code
);
delete
query
.
code
;
has
=
true
;
}
return
[
query
,
has
];
}
...
...
src/router/router.js
浏览文件 @
9255d87a
...
...
@@ -7,7 +7,7 @@ const test = r => require.ensure([], () => r(require('../views/test-components')
const
courseDetail
=
r
=>
require
.
ensure
([],
()
=>
r
(
require
(
'../views/course-detail'
)),
'course-detail'
)
const
notFound
=
r
=>
require
.
ensure
([],
()
=>
r
(
require
(
'../views/not-found'
)),
'not-found'
)
const
goodsDetail
=
r
=>
require
.
ensure
([],
()
=>
r
(
require
(
'../views/goods-detail'
)),
'goods-detail'
)
const
purchaseRezult
=
r
=>
require
.
ensure
([],
()
=>
r
(
require
(
'../views/
purchase-rezult'
)),
'purchase-rezult'
)
const
purchaseRezult
=
r
=>
require
.
ensure
([],
()
=>
r
(
require
(
'../views/purchase-rezult'
)),
'purchase-rezult'
)
export
default
[{
path
:
'/'
,
...
...
src/store/modules/user.js
浏览文件 @
9255d87a
...
...
@@ -2,12 +2,16 @@ import { Toast } from 'vant';
import
fetch
from
'@/utils/fetch'
;
import
{
getBaseUrl
}
from
'@/utils/index'
import
{
setCookie
,
delCookie
}
from
'@/utils/index'
;
import
{
envConfig
}
from
'@/utils/env-config'
import
{
envConfig
}
from
'@/utils/env-config'
;
let
wxInfo
=
sessionStorage
.
getItem
(
'wxInfo'
);
wxInfo
=
wxInfo
?
JSON
.
parse
(
wxInfo
)
:
{};
const
user
=
{
state
:
{
token
:
localStorage
.
getItem
(
'token'
)
||
''
,
info
:
{},
// 用户信息
wxInfo
,
// 微信信息,openid等
},
mutations
:
{
SET_TOKEN
:
(
state
,
payload
)
=>
{
...
...
@@ -16,6 +20,9 @@ const user = {
SET_USER_INFO
:
(
state
,
payload
)
=>
{
state
.
info
=
payload
;
},
SET_WX_INFO
:
(
state
,
payload
)
=>
{
state
.
wxInfo
=
payload
;
},
},
actions
:
{
// 外部登陆返回设置token
...
...
@@ -69,6 +76,19 @@ const user = {
window
.
location
.
href
=
envConfig
[
process
.
env
.
BUILD_ENV
][
'webPageUrl'
]
+
"/pica_login?target_url="
+
encodeURIComponent
(
location
.
href
);
},
getWxUserInfo
({
state
,
commit
},
code
)
{
const
type
=
15
;
fetch
({
url
:
getBaseUrl
(
`wechats/users/info/
${
type
}
/
${
code
}
`
),
method
:
'get'
,
headers
:
{
token
:
state
.
token
}
}).
then
(
res
=>
{
console
.
log
(
'____wx res_____'
,
res
.
data
)
sessionStorage
.
setItem
(
'wxInfo'
,
JSON
.
stringify
(
res
.
data
));
commit
(
'SET_WX_INFO'
,
res
.
data
)
});
},
// 登出
logout
({
state
,
commit
})
{
commit
(
'SET_TOKEN'
,
''
);
...
...
src/utils/index.js
浏览文件 @
9255d87a
...
...
@@ -205,6 +205,16 @@ export function isWeiXin() {
}
}
//弹出微信授权
export
const
wxOauth
=
()
=>
{
let
url
=
location
.
href
,
redirectUrl
;
let
appId
=
getAPPID
();
url
=
url
.
split
(
'?'
)[
0
];
redirectUrl
=
encodeURIComponent
(
url
);
console
.
log
(
'wxOauth redirectUrl => '
,
redirectUrl
);
window
.
location
.
href
=
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=
${
appId
}
&redirect_uri=
${
redirectUrl
}
&response_type=code&scope=snsapi_userinfo&#wechat_redirect`
;
}
export
const
setCookie
=
(
name
,
value
,
time
)
=>
{
var
expires
=
30
*
24
*
60
*
60
*
1000
;
//一天
var
date
=
new
Date
(
+
new
Date
()
+
expires
);
...
...
src/views/goods-detail.vue
浏览文件 @
9255d87a
...
...
@@ -73,7 +73,8 @@
<
script
>
import
{
Swipe
,
SwipeItem
}
from
'vant'
;
import
{
debounce
}
from
'@/utils'
;
import
{
getAPPID
,
getWebPageUrl
,
isWeiXin
,
wxOauth
,
debounce
}
from
'@/utils'
;
const
isWechat
=
isWeiXin
();
export
default
{
components
:
{
...
...
@@ -98,6 +99,9 @@ export default {
logged
()
{
return
this
.
$store
.
getters
.
logged
;
},
wxInfo
()
{
return
this
.
$store
.
state
.
user
.
wxInfo
;
},
tabLeft
()
{
const
num
=
this
.
curtTabIdx
+
0.25
+
15
/
115
;
return
this
.
tabW
*
num
;
...
...
@@ -230,6 +234,11 @@ export default {
this
.
goLogin
();
return
;
}
// 微信内先去授权
if
(
isWechat
&&
!
this
.
wxInfo
.
openid
)
{
wxOauth
();
return
;
}
const
{
id
,
couponDTO
,
isSale
}
=
this
.
goods
;
const
{
preferentialPrice
,
costPrice
}
=
this
.
totalPrice
;
// if (!id || isSale !== 1) {
...
...
@@ -246,7 +255,11 @@ export default {
this
.
POST
(
'trade/center/order/createV2'
,
orderData
).
then
(
res
=>
{
if
(
res
.
code
==
"000000"
)
{
const
orderId
=
res
.
data
.
orderId
;
// if (isWechat) {
this
.
goWxPayInner
(
orderId
);
// } else {
// this.goWxPayOut(orderId);
// }
if
(
this
.
projectId
)
{
this
.
createRelation
(
this
.
projectId
,
orderId
);
}
...
...
@@ -255,9 +268,48 @@ export default {
}
})
},
// 支付
goPay
(
orderId
)
{
//
// 站外微信支付
goWxPayOut
(
orderId
)
{
const
data
=
{
orderId
,
payChannel
:
1
,
tradeType
:
3
,
}
this
.
POST
(
'trade/center/mweb_prepay'
,
data
).
then
(
res
=>
{
if
(
res
.
code
==
"000000"
)
{
let
redirectUrl
=
this
.
getRedirectUrl
(
orderId
);
let
jumpLink
=
res
.
data
+
'&redirect_url='
+
encodeURIComponent
(
redirectUrl
);
window
.
location
.
href
=
jumpLink
;
}
else
{
this
.
$toast
(
res
.
message
);
}
})
},
// 微信内支付
goWxPayInner
(
orderId
)
{
const
data
=
{
openId
:
getAPPID
(),
orderId
,
payChannel
:
1
,
tradeType
:
1
,
}
this
.
POST
(
'trade/center/jsapi_prepay'
,
data
).
then
(
res
=>
{
if
(
res
.
code
==
"000000"
)
{
}
else
{
this
.
$toast
(
res
.
message
);
}
})
},
getRedirectUrl
(
orderId
)
{
let
path
=
`profexam/#/prezult?orderId=
${
orderId
}
`
;
if
(
this
.
projectId
)
{
path
+=
`&projectId=
${
this
.
projectId
}
`
}
if
(
this
.
returnUrl
)
{
path
+=
`&returnUrl=
${
this
.
returnUrl
}
`
}
return
getWebPageUrl
(
path
);
},
// 绑定项目和订单的关系
createRelation
(
projectId
,
orderId
)
{
...
...
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录