Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
center-shop-show-h5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
center-shop-show-h5
Commits
bc503d12
提交
bc503d12
authored
6月 02, 2021
作者:
pengxiaohui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加微信网页支付
上级
3f513e55
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
147 行增加
和
18 行删除
+147
-18
project.config.json
project.config.json
+63
-0
account.js
src/api/account.js
+12
-0
PhoneCodeLoginPopup.vue
src/components/PhoneCodeLoginPopup.vue
+9
-0
BuyPopup.vue
src/pages/buy/components/BuyPopup.vue
+1
-1
index.vue
src/pages/buy/index.vue
+59
-15
getters.js
src/store/getters.js
+2
-1
user.js
src/store/modules/user.js
+1
-1
没有找到文件。
project.config.json
0 → 100644
浏览文件 @
bc503d12
{
"description"
:
"项目配置文件"
,
"packOptions"
:
{
"ignore"
:
[]
},
"setting"
:
{
"urlCheck"
:
true
,
"scopeDataCheck"
:
false
,
"coverView"
:
true
,
"es6"
:
true
,
"postcss"
:
true
,
"compileHotReLoad"
:
false
,
"preloadBackgroundData"
:
false
,
"minified"
:
true
,
"autoAudits"
:
false
,
"newFeature"
:
false
,
"uglifyFileName"
:
false
,
"uploadWithSourceMap"
:
true
,
"useIsolateContext"
:
true
,
"nodeModules"
:
false
,
"enhance"
:
false
,
"useCompilerModule"
:
false
,
"userConfirmedUseCompilerModuleSwitch"
:
false
,
"showShadowRootInWxmlPanel"
:
true
},
"compileType"
:
"miniprogram"
,
"libVersion"
:
"2.17.0"
,
"appid"
:
"touristappid"
,
"projectname"
:
"shop-h5"
,
"debugOptions"
:
{
"hidedInDevtools"
:
[]
},
"scripts"
:
{},
"simulatorType"
:
"wechat"
,
"simulatorPluginLibVersion"
:
{},
"condition"
:
{
"search"
:
{
"current"
:
-1
,
"list"
:
[]
},
"conversation"
:
{
"current"
:
-1
,
"list"
:
[]
},
"game"
:
{
"current"
:
-1
,
"list"
:
[]
},
"plugin"
:
{
"current"
:
-1
,
"list"
:
[]
},
"gamePlugin"
:
{
"current"
:
-1
,
"list"
:
[]
},
"miniprogram"
:
{
"current"
:
-1
,
"list"
:
[]
}
}
}
\ No newline at end of file
src/api/account.js
浏览文件 @
bc503d12
...
@@ -25,4 +25,15 @@ export function phoneCodeLogin(data) {
...
@@ -25,4 +25,15 @@ export function phoneCodeLogin(data) {
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
},
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
},
data
data
})
})
}
/**
* 修改用户信息
*/
export
function
getOpenId
(
data
)
{
return
httpRequest
({
url
:
'/api/usercenter/v1/wechat/get-openid'
,
method
:
'post'
,
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
},
data
})
}
}
\ No newline at end of file
src/components/PhoneCodeLoginPopup.vue
浏览文件 @
bc503d12
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
</
template
>
</
template
>
</van-field>
</van-field>
<div
style=
"margin: 16px;"
>
<div
style=
"margin: 16px;"
>
<p
class=
"account-login"
@
click=
"goLogin"
>
账号密码登录
</p>
<van-button
type=
"primary"
round
block
color=
"#C01540"
size=
"small"
:disabled=
"payBtnDisabled"
>
登录
</van-button>
<van-button
type=
"primary"
round
block
color=
"#C01540"
size=
"small"
:disabled=
"payBtnDisabled"
>
登录
</van-button>
</div>
</div>
</van-form>
</van-form>
...
@@ -50,6 +51,9 @@ export default {
...
@@ -50,6 +51,9 @@ export default {
}
}
},
},
methods
:
{
methods
:
{
goLogin
()
{
window
.
location
.
href
=
`
${
webConf
.
others
.
loginUrl
}
?rd=
${
encodeURIComponent
(
window
.
location
.
href
)}
`
},
handleSuccess
(
val
)
{
handleSuccess
(
val
)
{
this
.
fetchPhoneCodeLogin
()
this
.
fetchPhoneCodeLogin
()
},
},
...
@@ -125,6 +129,11 @@ h5{
...
@@ -125,6 +129,11 @@ h5{
line-height
:
33px
;
line-height
:
33px
;
}
}
}
}
.account-login
{
color
:
#C01540
;
font-size
:
12px
;
margin-bottom
:
15px
;
}
.code-btn
{
.code-btn
{
.van-button__text
{
.van-button__text
{
color
:
#C01540
;
color
:
#C01540
;
...
...
src/pages/buy/components/BuyPopup.vue
浏览文件 @
bc503d12
...
@@ -132,7 +132,7 @@ export default {
...
@@ -132,7 +132,7 @@ export default {
spu_id
:
this
.
spu_id
,
spu_id
:
this
.
spu_id
,
sku_id
:
this
.
spec
,
sku_id
:
this
.
spec
,
buy_count
:
this
.
form
.
count
,
buy_count
:
this
.
form
.
count
,
p
ayment_method
:
'4'
,
p
roduct_price
:
this
.
price
,
app_button_text
:
JSON
.
stringify
(
fields
)
app_button_text
:
JSON
.
stringify
(
fields
)
}
}
this
.
$emit
(
'placeOrder'
,
params
)
this
.
$emit
(
'placeOrder'
,
params
)
...
...
src/pages/buy/index.vue
浏览文件 @
bc503d12
...
@@ -39,7 +39,7 @@
...
@@ -39,7 +39,7 @@
</van-cell>
</van-cell>
</div>
</div>
<div
class=
"bottom-bar"
>
<div
class=
"bottom-bar"
>
<van-button
type=
"primary"
round
block
color=
"#C01540"
size=
"small"
@
click=
"
popupVisiable = true
"
>
立即购买
</van-button>
<van-button
type=
"primary"
round
block
color=
"#C01540"
size=
"small"
@
click=
"
handleBuy
"
>
立即购买
</van-button>
</div>
</div>
<buy-popup
v-model=
"popupVisiable"
:options=
"popupOptions"
@
placeOrder=
"handlePlaceOrder"
/>
<buy-popup
v-model=
"popupVisiable"
:options=
"popupOptions"
@
placeOrder=
"handlePlaceOrder"
/>
<phone-code-login-popup
v-model=
"loginPopupVisiable"
@
loginSuccess=
"handleHasLogin"
/>
<phone-code-login-popup
v-model=
"loginPopupVisiable"
@
loginSuccess=
"handleHasLogin"
/>
...
@@ -49,9 +49,10 @@
...
@@ -49,9 +49,10 @@
import
BuyPopup
from
'./components/BuyPopup.vue'
import
BuyPopup
from
'./components/BuyPopup.vue'
import
PhoneCodeLoginPopup
from
'@/components/PhoneCodeLoginPopup.vue'
import
PhoneCodeLoginPopup
from
'@/components/PhoneCodeLoginPopup.vue'
import
{
getGoodsList
,
getShopList
,
createOrder
,
checkPayStatus
}
from
'@/api/common.js'
import
{
getGoodsList
,
getShopList
,
createOrder
,
checkPayStatus
}
from
'@/api/common.js'
import
{
getOpenId
}
from
'@/api/account.js'
import
store
from
'@/store'
import
store
from
'@/store'
import
{
mapGetters
}
from
'vuex'
import
{
mapGetters
}
from
'vuex'
import
{
Dialog
}
from
'vant'
import
{
Dialog
,
Toast
}
from
'vant'
export
default
{
export
default
{
components
:
{
BuyPopup
,
PhoneCodeLoginPopup
},
components
:
{
BuyPopup
,
PhoneCodeLoginPopup
},
data
()
{
data
()
{
...
@@ -63,12 +64,14 @@ export default {
...
@@ -63,12 +64,14 @@ export default {
imgList
:
[],
imgList
:
[],
shopInfo
:
{},
shopInfo
:
{},
popupOptions
:
{},
popupOptions
:
{},
orderInfo
:
{},
payment_order_id
:
''
,
payment_order_id
:
''
payment_method
:
'4'
,
order_params
:
''
,
openId
:
''
}
}
},
},
computed
:
{
computed
:
{
...
mapGetters
([
'user'
]),
...
mapGetters
([
'user'
,
'isWxBrowser'
]),
query
()
{
query
()
{
return
this
.
$route
.
query
return
this
.
$route
.
query
},
},
...
@@ -85,7 +88,7 @@ export default {
...
@@ -85,7 +88,7 @@ export default {
beforeMount
()
{
beforeMount
()
{
this
.
fetchGoodsDetails
()
this
.
fetchGoodsDetails
()
this
.
fetchShopDetails
()
this
.
fetchShopDetails
()
if
(
this
.
isBackFormWxPay
)
{
if
(
this
.
isBackFormWx
H5
Pay
)
{
Dialog
.
alert
({
Dialog
.
alert
({
title
:
'支付确认'
,
title
:
'支付确认'
,
message
:
'确认已经完成微信支付'
,
message
:
'确认已经完成微信支付'
,
...
@@ -93,7 +96,11 @@ export default {
...
@@ -93,7 +96,11 @@ export default {
}).
then
(()
=>
{
}).
then
(()
=>
{
this
.
fetchCheckPayStatus
()
this
.
fetchCheckPayStatus
()
})
})
window
.
sessionStorage
.
removeItem
(
'isBackFormWxPay'
)
window
.
sessionStorage
.
removeItem
(
'isBackFormWxH5Pay'
)
}
if
(
!
this
.
openId
)
{
const
{
code
}
=
this
.
$route
.
query
if
(
code
)
this
.
fetchOpenId
(
code
)
}
}
},
},
methods
:
{
methods
:
{
...
@@ -109,9 +116,7 @@ export default {
...
@@ -109,9 +116,7 @@ export default {
navShop
(
id
)
{
navShop
(
id
)
{
this
.
$router
.
push
({
path
:
'/shop'
,
query
:
{
shop_id
:
id
}
})
this
.
$router
.
push
({
path
:
'/shop'
,
query
:
{
shop_id
:
id
}
})
},
},
async
handlePlaceOrder
(
val
)
{
async
handleBuy
()
{
this
.
orderInfo
=
val
this
.
popupVisiable
=
false
const
isLogin
=
store
.
state
.
isLogin
||
(
await
store
.
dispatch
(
'checkLogin'
))
const
isLogin
=
store
.
state
.
isLogin
||
(
await
store
.
dispatch
(
'checkLogin'
))
if
(
isLogin
)
{
if
(
isLogin
)
{
this
.
handleHasLogin
()
this
.
handleHasLogin
()
...
@@ -119,14 +124,44 @@ export default {
...
@@ -119,14 +124,44 @@ export default {
this
.
loginPopupVisiable
=
true
this
.
loginPopupVisiable
=
true
}
}
},
},
handleHasLogin
()
{
handlePlaceOrder
(
val
)
{
const
params
=
Object
.
assign
({},
this
.
orderInfo
)
this
.
popupVisiable
=
false
const
params
=
Object
.
assign
({},
val
)
params
.
customer_id
=
this
.
user
.
id
params
.
customer_id
=
this
.
user
.
id
params
.
customer_phone
=
this
.
user
.
phone
||
''
params
.
customer_phone
=
this
.
user
.
phone
||
''
params
.
buy_count
=
(
params
.
buy_count
).
toString
()
params
.
buy_count
=
(
params
.
buy_count
).
toString
()
console
.
log
(
params
)
params
.
payment_method
=
this
.
payment_method
if
(
this
.
payment_method
===
'3'
)
{
params
.
open_id
=
this
.
openId
}
this
.
fetchPlaceOrder
(
params
)
this
.
fetchPlaceOrder
(
params
)
},
},
handleHasLogin
()
{
console
.
log
(
navigator
.
userAgent
)
if
(
this
.
isWxBrowser
)
{
this
.
payment_method
=
'3'
this
.
getCode
()
}
else
{
this
.
payment_method
=
'4'
this
.
popupVisiable
=
true
// this.fetchPlaceOrder(params)
}
},
getCode
()
{
const
redirectURI
=
window
.
location
.
href
window
.
location
.
href
=
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx451c01d40d090d7a&redirect_uri=
${
redirectURI
}
&response_type=code&scope=snsapi_base#wechat_redirect`
},
// 获取微信openid
fetchOpenId
(
code
)
{
getOpenId
({
code
,
identity
:
'ezijing'
}).
then
(
response
=>
{
if
(
response
.
code
===
0
)
{
this
.
openId
=
response
.
openid
window
.
localStorage
.
setItem
(
'open_id'
,
this
.
openId
)
}
else
{
this
.
getCode
()
}
})
},
fetchGoodsDetails
()
{
fetchGoodsDetails
()
{
const
params
=
{
const
params
=
{
shop_id
:
this
.
shop_id
,
shop_id
:
this
.
shop_id
,
...
@@ -159,12 +194,21 @@ export default {
...
@@ -159,12 +194,21 @@ export default {
}
}
})
})
},
},
placeOrderParams
()
{
const
params
=
Object
.
assign
({
payment_method
:
this
.
payment_method
},
this
.
order_params
)
if
(
this
.
payment_method
===
'3'
)
{
params
.
open_id
=
this
.
openId
}
return
params
},
fetchPlaceOrder
(
params
)
{
fetchPlaceOrder
(
params
)
{
createOrder
(
params
).
then
(
res
=>
{
createOrder
(
params
).
then
(
res
=>
{
if
(
res
.
code
===
0
&&
res
.
payment_url
)
{
if
(
res
.
code
===
0
&&
res
.
msg
===
'成功'
)
{
window
.
sessionStorage
.
setItem
(
'isBackFormWxPay'
,
1
)
window
.
sessionStorage
.
setItem
(
'isBackFormWx
H5
Pay'
,
1
)
window
.
sessionStorage
.
setItem
(
'payment_order_id'
,
res
.
payment_order_id
)
window
.
sessionStorage
.
setItem
(
'payment_order_id'
,
res
.
payment_order_id
)
window
.
location
.
href
=
res
.
payment_url
window
.
location
.
href
=
res
.
payment_url
}
else
{
Toast
.
fail
(
res
.
msg
||
'购买下单失败'
)
}
}
})
})
},
},
...
...
src/store/getters.js
浏览文件 @
bc503d12
const
getters
=
{
const
getters
=
{
user
:
state
=>
state
.
user
.
user
user
:
state
=>
state
.
user
.
user
,
isWxBrowser
:
state
=>
state
.
user
.
isWxBrowser
}
}
export
default
getters
export
default
getters
src/store/modules/user.js
浏览文件 @
bc503d12
...
@@ -3,7 +3,7 @@ const user = {
...
@@ -3,7 +3,7 @@ const user = {
state
:
{
state
:
{
user
:
{},
user
:
{},
isLogin
:
false
,
isLogin
:
false
,
isWxBrowser
:
/micromessenger/
.
test
(
navigator
.
userAgent
)
isWxBrowser
:
/micromessenger/
i
.
test
(
navigator
.
userAgent
)
&&
/android|iphone|ipad|ipod/i
.
test
(
navigator
.
userAgent
)
},
},
mutations
:
{
mutations
:
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论