Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
transport-show-h5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
transport-show-h5
Commits
b9f8a36a
提交
b9f8a36a
authored
7月 03, 2020
作者:
lihuihui
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://gitlab.ezijing.com/ezijing/transport-weapp-h5
上级
7fb88799
02cd9bd4
显示空白字符变更
内嵌
并排
正在显示
18 个修改的文件
包含
325 行增加
和
14 行删除
+325
-14
.config.dev.js
.config.dev.js
+6
-5
.config.pro.js
.config.pro.js
+3
-1
.config.test.js
.config.test.js
+3
-1
.eslintrc
.eslintrc
+2
-1
index.js
src/modules/index.js
+5
-2
PayAction.js
src/modules/pay-module/action/PayAction.js
+7
-0
index.js
src/modules/pay-module/action/index.js
+5
-0
index.js
src/modules/pay-module/api/index.js
+7
-0
pay_api.js
src/modules/pay-module/api/pay_api.js
+4
-0
en.json
src/modules/pay-module/assets/languages/en.json
+20
-0
index.js
src/modules/pay-module/assets/languages/index.js
+40
-0
language.js
src/modules/pay-module/assets/languages/language.js
+7
-0
zh-CN.json
src/modules/pay-module/assets/languages/zh-CN.json
+20
-0
index.js
src/modules/pay-module/index.js
+30
-0
index.scss
src/modules/pay-module/index.scss
+15
-0
PayH5.vue
src/modules/pay-module/src/PayH5.vue
+131
-0
login.vue
src/pages/login/login.vue
+3
-3
index.vue
src/pages/pay/index.vue
+17
-1
没有找到文件。
.config.dev.js
浏览文件 @
b9f8a36a
...
...
@@ -4,11 +4,12 @@ module.exports = {
// apiBaseURL: 'https://zy2.ezijing.com/',
webpack
:
{
externals
:
{
CKEDITOR
:
'window.CKEDITOR'
,
Base64
:
'window.Base64'
,
md5
:
'window.md5'
,
regeneratorRuntime
:
'window.regeneratorRuntime'
,
wx
:
'window.wx'
'CKEDITOR'
:
'window.CKEDITOR'
,
'Base64'
:
'window.Base64'
,
'md5'
:
'window.md5'
,
'regeneratorRuntime'
:
'window.regeneratorRuntime'
,
'wx'
:
'window.wx'
,
'WeixinJSBridge'
:
'window.WeixinJSBridge'
},
devServer
:
{
proxy
:
{
...
...
.config.pro.js
浏览文件 @
b9f8a36a
...
...
@@ -8,7 +8,9 @@ module.exports = {
'CKEDITOR'
:
'window.CKEDITOR'
,
'Base64'
:
'window.Base64'
,
'md5'
:
'window.md5'
,
'regeneratorRuntime'
:
'window.regeneratorRuntime'
'regeneratorRuntime'
:
'window.regeneratorRuntime'
,
'wx'
:
'window.wx'
,
'WeixinJSBridge'
:
'window.WeixinJSBridge'
}
},
ProvidePlugin
:
{
...
...
.config.test.js
浏览文件 @
b9f8a36a
...
...
@@ -8,7 +8,9 @@ module.exports = {
'CKEDITOR'
:
'window.CKEDITOR'
,
'Base64'
:
'window.Base64'
,
'md5'
:
'window.md5'
,
'regeneratorRuntime'
:
'window.regeneratorRuntime'
'regeneratorRuntime'
:
'window.regeneratorRuntime'
,
'wx'
:
'window.wx'
,
'WeixinJSBridge'
:
'window.WeixinJSBridge'
}
},
ProvidePlugin
:
{
...
...
.eslintrc
浏览文件 @
b9f8a36a
...
...
@@ -18,6 +18,7 @@
"$": false,
"window": false,
"webConf": false,
"wx": false
"wx": false,
"WeixinJSBridge": false
}
}
src/modules/index.js
浏览文件 @
b9f8a36a
...
...
@@ -2,9 +2,11 @@
/* 模块基于 element-ui,一定在 element-ui后加载 */
import
ExamModule
from
'./exam-module'
import
PayModule
from
'./pay-module'
const
components
=
[
ExamModule
ExamModule
,
PayModule
]
const
install
=
function
(
Vue
,
opts
=
{})
{
...
...
@@ -20,5 +22,6 @@ if (typeof window !== 'undefined' && window.Vue) {
export
default
{
install
,
ExamModule
ExamModule
,
PayModule
}
src/modules/pay-module/action/PayAction.js
0 → 100644
浏览文件 @
b9f8a36a
import
BaseACTION
from
'@/action/base_action'
import
{
Pay
}
from
'../api'
export
default
class
PayAction
extends
BaseACTION
{
getOrderId
(
obj
)
{
return
Pay
.
getOrderId
(
obj
).
then
(
res
=>
res
)
}
}
src/modules/pay-module/action/index.js
0 → 100644
浏览文件 @
b9f8a36a
import
PayAction
from
'./PayAction'
const
Pay
=
new
PayAction
()
export
default
Pay
src/modules/pay-module/api/index.js
0 → 100644
浏览文件 @
b9f8a36a
import
PayAPI
from
'./pay_api'
const
Pay
=
new
PayAPI
(
webConf
)
export
{
Pay
}
src/modules/pay-module/api/pay_api.js
0 → 100644
浏览文件 @
b9f8a36a
import
BaseAPI
from
'@/api/base_api'
export
default
class
Pay
extends
BaseAPI
{
getOrderId
=
(
obj
)
=>
this
.
post
(
'/v2/mall/order/pre'
,
obj
,
{
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
}
})
}
src/modules/pay-module/assets/languages/en.json
0 → 100644
浏览文件 @
b9f8a36a
{
"PayModule"
:
{
"DiscussList"
:
{
"answers"
:
"Answers"
,
"votes"
:
"Votes"
,
"noData"
:
"No discussion"
},
"DiscussDetail"
:
{
"title"
:
"Problem details"
,
"like"
:
"Like"
,
"discuss"
:
"Discuss"
,
"reply"
:
"Reply"
,
"delete"
:
"Delete"
,
"send"
:
"Send"
,
"noAnswer"
:
"No answer"
,
"deleteSuccess"
:
"Delete success"
,
"answering"
:
"Answer"
}
}
}
src/modules/pay-module/assets/languages/index.js
0 → 100644
浏览文件 @
b9f8a36a
import
Cookies
from
'js-cookie'
import
VueI18n
from
'vue-i18n'
import
language
from
'./language'
// import zhCNLocale from 'element-ui/lib/locale/lang/zh-CN'
// import enLocale from 'element-ui/lib/locale/lang/en'
export
default
()
=>
{
let
_locale
=
'zh-CN'
/* 国际化初始化 */
const
_defaultLocale
=
'zh-CN'
const
_lang
=
Cookies
.
get
(
'lang'
)
||
window
.
navigator
.
language
||
window
.
navigator
.
userLanguage
||
''
if
(
_lang
)
{
if
(
language
[
_lang
])
{
_locale
=
_lang
}
else
{
let
flag
=
true
/* 做一下 兼容性处理 */
for
(
const
k
in
language
)
{
const
reg
=
new
RegExp
(
k
,
'gi'
)
if
(
reg
.
test
(
_lang
))
{
_locale
=
k
flag
=
false
break
}
}
if
(
flag
)
{
/* 当前语言版本 - 不再我们的语言库中,那么默认 en */
_locale
=
_defaultLocale
Cookies
.
set
(
'lang'
,
_defaultLocale
,
{
expires
:
30
,
domain
:
'.ezijing.com'
})
}
}
}
return
new
VueI18n
({
locale
:
_locale
,
// 定义默认语言为中文
messages
:
{
'zh-CN'
:
Object
.
assign
(
require
(
'./zh-CN.json'
)),
en
:
Object
.
assign
(
require
(
'./en.json'
))
}
})
}
src/modules/pay-module/assets/languages/language.js
0 → 100644
浏览文件 @
b9f8a36a
/* 定义语言模型 - key 值定义 跟 languages i18n 中 保持一致 */
const
language
=
{
'zh-CN'
:
{
show
:
'语言'
,
arr
:
[{
'zh-CN'
:
'中文'
},
{
en
:
'English'
}]
},
en
:
{
show
:
'Language'
,
arr
:
[{
'zh-CN'
:
'中文'
},
{
en
:
'English'
}]
}
}
export
default
language
src/modules/pay-module/assets/languages/zh-CN.json
0 → 100644
浏览文件 @
b9f8a36a
{
"PayModule"
:
{
"DiscussList"
:
{
"answers"
:
"回答"
,
"votes"
:
"投票"
,
"noData"
:
"暂无相关评论"
},
"DiscussDetail"
:
{
"title"
:
"问题详情"
,
"like"
:
"点赞"
,
"discuss"
:
"讨论"
,
"reply"
:
"回复"
,
"delete"
:
"删除"
,
"send"
:
"发送"
,
"noAnswer"
:
"暂无回答"
,
"deleteSuccess"
:
"删除成功"
,
"answering"
:
"回答问题"
}
}
}
src/modules/pay-module/index.js
0 → 100644
浏览文件 @
b9f8a36a
import
'./index.scss'
import
PayH5
from
'./src/PayH5.vue'
const
components
=
[
PayH5
]
const
install
=
function
(
Vue
,
opts
=
{})
{
/* 存在国际化 */
if
(
opts
.
i18n
)
{
const
msgs
=
opts
.
i18n
.
messages
for
(
const
k
in
msgs
)
{
opts
.
i18n
.
setLocaleMessage
(
k
,
Object
.
assign
(
msgs
[
k
],
require
(
'./assets/languages/'
+
k
+
'.json'
)))
}
}
components
.
forEach
(
component
=>
{
Vue
.
component
(
component
.
name
,
component
)
})
}
/* istanbul ignore if */
if
(
typeof
window
!==
'undefined'
&&
window
.
Vue
)
{
install
(
window
.
Vue
)
}
export
default
{
install
,
PayH5
}
src/modules/pay-module/index.scss
0 → 100644
浏览文件 @
b9f8a36a
/* Extra small devices (portrait phones, less than 576px) */
@media
(
max-width
:
575px
)
{}
/* Small devices (landscape phones, 576px and up) */
@media
(
min-width
:
576px
)
and
(
max-width
:
767px
)
{}
/* Medium devices (tablets, 768px and up) */
@media
(
min-width
:
768px
)
and
(
max-width
:
991px
)
{}
/* Large devices (desktops, 992px and up) */
@media
(
min-width
:
992px
)
and
(
max-width
:
1199px
)
{}
/* Extra large devices (large desktops, 1200px and up) */
@media
(
min-width
:
1200px
)
{}
src/modules/pay-module/src/PayH5.vue
0 → 100644
浏览文件 @
b9f8a36a
<
template
>
<!-- 暂时无用 -->
<div
class=
"pay-box"
></div>
</
template
>
<
script
>
import
Pay
from
'../action'
export
default
{
name
:
'PayH5'
,
components
:
{},
data
()
{
const
_this
=
this
return
{
isCard
:
false
,
opaKey
:
[
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
,
'G'
],
remainingTime
:
'01:00:00'
,
currentNum
:
1
,
isAnalysis
:
false
,
swiperOptions
:
{
observer
:
true
,
on
:
{
slideChangeTransitionStart
:
function
()
{
document
.
getElementById
(
'bottom-view'
).
scrollTop
=
0
_this
.
isAnalysis
=
false
_this
.
currentNum
=
this
.
activeIndex
+
1
}
}
},
questionsData
:
{
questions
:
[]
},
requestData
:
{},
requestData2
:
{},
clockCount
:
null
,
isExamEnd
:
true
,
// examIsShow: false,
isExamSubPop
:
false
,
timePopIsShow
:
false
,
initTime
:
null
,
cache
:
null
}
},
props
:
{
requestParam
:
{
type
:
Object
,
required
:
false
,
default
()
{
return
{
product_id
:
''
,
// 提前设定
open_id
:
''
,
// 通过微信授权获取
prepay_id
:
''
,
// 通过调用接口获取
app_id
:
''
,
// 提前设定
app_secret
:
''
// 提前设定
}
}
}
},
beforeDestroy
()
{
},
mounted
()
{
/* 判别是否引入JSSDK */
// if (typeof WeixinJSBridge === 'undefined') {
// console.log('尚未引入微信JSSDK或JSSDK未执行')
// if (document.addEventListener) {
// document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady.bind(this), false)
// } else if (document.attachEvent) {
// document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady.bind(this))
// document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady.bind(this))
// }
// } else {
// this.onBridgeReady()
// }
this
.
onBridgeReady
()
},
methods
:
{
onBridgeReady
()
{
this
.
VueEvent
.
$off
(
'pay-wx-h5'
).
$on
(
'pay-wx-h5'
,
(
obj
)
=>
{
const
_callback
=
obj
.
callback
||
function
()
{}
const
_obj
=
this
.
goToPay
()
_callback
(
_obj
)
})
},
goToPay
()
{
const
obj
=
{
code
:
0
,
msg
:
''
,
data
:
{}
}
if
(
!
this
.
requestParam
.
product_id
)
{
obj
.
code
=
3001
obj
.
msg
=
'没有商品ID'
return
obj
}
if
(
!
this
.
requestParam
.
open_id
)
{
obj
.
code
=
3002
obj
.
msg
=
'没有小程序用户openid'
return
obj
}
return
Pay
.
getOrderId
(
this
.
requestParam
).
then
(
res
=>
{
obj
.
data
=
res
this
.
wxWakeUpToPay
()
// return
}).
catch
(
e
=>
{
obj
.
code
=
5001
obj
.
msg
=
e
.
message
return
obj
})
},
wxWakeUpToPay
()
{
/* 直接调用微信支付 */
const
timestamp
=
parseInt
(
new
Date
().
getTime
()
/
1000
)
const
noncestr
=
parseInt
(
Math
.
random
()
*
10000000000000000
)
WeixinJSBridge
.
invoke
(
'getBrandWCPayRequest'
,
{
appId
:
this
.
requestParam
.
app_id
,
// 公众号名称,由商户传入
timeStamp
:
timestamp
+
''
,
// 时间戳,自1970年以来的秒数
nonceStr
:
noncestr
+
''
,
// 随机串
package
:
'prepay_id='
+
this
.
requestParam
.
prepay_id
,
signType
:
'MD5'
,
// 微信签名方式:
paySign
:
'70EA570631E4BB79628FBCA90534C63FF7FADD89'
// 微信签名
},
function
(
res
)
{
if
(
res
.
err_msg
===
'get_brand_wcpay_request:ok'
)
{
// 使用以上方式判断前端返回,微信团队郑重提示:
// res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
}
}
)
}
}
}
</
script
>
<
style
lang=
"scss"
>
</
style
>
src/pages/login/login.vue
浏览文件 @
b9f8a36a
...
...
@@ -98,7 +98,7 @@ export default {
})
},
// 登录成功
loginSuccess
(
response
)
{
loginSuccess
(
response
,
delta
=
2
)
{
if
(
response
.
code
===
0
)
{
Cookies
.
remove
(
'wechat_login_error'
,
{
domain
:
'.ezijing.com'
})
Cookies
.
remove
(
'wechat_login_no_phone_error'
,
{
...
...
@@ -107,7 +107,7 @@ export default {
this
.
$store
.
commit
(
'setToken'
,
response
.
data
.
TGC
)
if
(
this
.
isWeapp
)
{
wx
.
miniProgram
.
postMessage
({
data
:
{
token
:
response
.
data
.
TGC
}
})
wx
.
miniProgram
.
navigateBack
({
delta
:
2
})
wx
.
miniProgram
.
navigateBack
({
delta
})
return
}
if
(
this
.
redirectURI
)
{
...
...
@@ -140,7 +140,7 @@ export default {
beforeMount
()
{
this
.
$store
.
dispatch
(
'checkLogin'
).
then
(
isLogin
=>
{
if
(
isLogin
)
{
this
.
loginSuccess
({
code
:
0
,
data
:
{
TGC
:
Cookies
.
get
(
'TGC'
)
}
})
this
.
loginSuccess
({
code
:
0
,
data
:
{
TGC
:
Cookies
.
get
(
'TGC'
)
}
}
,
1
)
}
else
{
if
(
this
.
isWechat
&&
!
this
.
checkWechatLogin
())
{
this
.
wechatLogin
()
...
...
src/pages/pay/index.vue
浏览文件 @
b9f8a36a
<
template
>
<div>
<van-button
type=
"primary"
>
默认按钮
</van-button>
<van-button
type=
"primary"
@
click=
"goPay"
>
默认按钮
</van-button>
<pay-h5
:requestParam=
"requestParam"
></pay-h5>
</div>
</
template
>
<
script
>
...
...
@@ -10,6 +11,13 @@ export default {
},
data
()
{
return
{
requestParam
:
{
product_id
:
''
,
// 提前设定
open_id
:
''
,
// 通过微信授权获取
prepay_id
:
''
,
// 通过调用接口获取
app_id
:
''
,
// 提前设定
app_secret
:
''
// 提前设定
}
}
},
mounted
()
{
...
...
@@ -27,6 +35,14 @@ export default {
// api.getGoodsDetails('6682927830365372416').then(res => {
// console.log(res)
// })
},
goPay
()
{
this
.
VueEvent
.
$emit
(
'pay-wx-h5'
,
{
data
:
{},
callback
:
function
(
obj
)
{
console
.
log
(
obj
)
}
})
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论