Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mayi-mp-shop
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
程默
mayi-mp-shop
Commits
f74e40d8
Commit
f74e40d8
authored
Sep 18, 2019
by
程默
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步
parent
9b6b9567
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
236 additions
and
125 deletions
+236
-125
build/webpack.dev.conf.js
+3
-1
config/dev.env.js
+1
-1
project.config.json
+1
-0
src/api/wxPay.js
+3
-4
src/pages/index/index.vue
+54
-30
src/pages/login/index.vue
+93
-33
src/pages/wxPay/index.vue
+57
-53
src/utils/request.js
+24
-3
No files found.
build/webpack.dev.conf.js
View file @
f74e40d8
var
UglifyJsPlugin
=
require
(
'uglifyjs-webpack-plugin'
)
var
utils
=
require
(
'./utils'
)
var
utils
=
require
(
'./utils'
)
var
webpack
=
require
(
'webpack'
)
var
webpack
=
require
(
'webpack'
)
var
config
=
require
(
'../config'
)
var
config
=
require
(
'../config'
)
...
@@ -80,6 +81,7 @@ module.exports = merge(baseWebpackConfig, {
...
@@ -80,6 +81,7 @@ module.exports = merge(baseWebpackConfig, {
// template: 'index.html',
// template: 'index.html',
// inject: true
// inject: true
// }),
// }),
new
FriendlyErrorsPlugin
()
new
FriendlyErrorsPlugin
(),
new
UglifyJsPlugin
({
sourceMap
:
true
})
]
]
})
})
config/dev.env.js
View file @
f74e40d8
...
@@ -5,5 +5,5 @@ var prodEnv = require('./prod.env')
...
@@ -5,5 +5,5 @@ var prodEnv = require('./prod.env')
module
.
exports
=
merge
(
prodEnv
,
{
module
.
exports
=
merge
(
prodEnv
,
{
NODE_ENV
:
'"development"'
,
NODE_ENV
:
'"development"'
,
APPID
:
'"wx743dc2f4adb9cf01"'
,
APPID
:
'"wx743dc2f4adb9cf01"'
,
OLSHOP_URL
:
'"https://
dev
-m-shop.mayi888.cn/innerApi/shopApiService"'
OLSHOP_URL
:
'"https://
test
-m-shop.mayi888.cn/innerApi/shopApiService"'
})
})
project.config.json
View file @
f74e40d8
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
"minified"
:
true
,
"minified"
:
true
,
"newFeature"
:
true
,
"newFeature"
:
true
,
"coverView"
:
true
,
"coverView"
:
true
,
"nodeModules"
:
false
,
"autoAudits"
:
false
,
"autoAudits"
:
false
,
"checkInvalidKey"
:
true
,
"checkInvalidKey"
:
true
,
"checkSiteMap"
:
true
,
"checkSiteMap"
:
true
,
...
...
src/api/wxPay.js
View file @
f74e40d8
import
request
from
"@/utils/request.js"
;
import
{
requestPOST
,
requestPOST1
}
from
"@/utils/request.js"
;
const
baseApi
=
"http://test-m-shop.mayi888.cn/innerApi"
;
export
default
{
export
default
{
to_wx_pay
(
options
)
{
to_wx_pay
(
options
)
{
return
request
(
`
${
baseApi
}
/shopApiService
/pay/to_wx_pay`
,
options
)
return
request
POST1
(
`
${
process
.
env
.
OLSHOP_URL
}
/pay/to_wx_pay`
,
options
)
}
}
}
}
\ No newline at end of file
src/pages/index/index.vue
View file @
f74e40d8
...
@@ -40,46 +40,70 @@ export default {
...
@@ -40,46 +40,70 @@ export default {
return
{
return
{
options
:
{},
options
:
{},
session_key
:
""
,
session_key
:
""
,
link
:
"http://localhost:3000"
,
link
:
"http://test-m-shop.mayi888.cn"
,
page
:
""
,
// link: "http://localhost:3000",
page
:
"/"
,
params
:
"?mixid=dev001"
,
params
:
"?mixid=dev001"
,
motto
:
"Hello miniprograme"
,
motto
:
"Hello miniprograme"
,
userInfo
:
{
userInfo
:
{
nickName
:
"mpvue"
,
nickName
:
"mpvue"
,
avatarUrl
:
"http://mpvue.com/assets/logo.png"
avatarUrl
:
"http://mpvue.com/assets/logo.png"
}
},
shareUrl
:
""
};
};
},
},
onShareAppMessage
()
{
onShareAppMessage
(
res
)
{
console
.
log
(
"share"
,
res
,
this
.
page
);
//获取webview当前页面地址
this
.
shareUrl
=
res
.
webViewUrl
;
return
{
return
{
title
:
"微信小程序"
,
title
:
this
.
shareUrl
,
// 默认是小程序的名称
desc
:
"小程序开发!"
,
path
:
`/pages/index/main?share=
${
encodeURIComponent
(
this
.
shareUrl
)}
`
,
// 默认是当前页面
path
:
"/page/logs"
imageUrl
:
"http://test-bucket-ant.oss-cn-shanghai.aliyuncs.com/product/png/026da85e-d78d-4260-bbe1-4ca5e1fed10d.png"
,
//自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
success
:
function
(
res
)
{
// 转发成功之后的回调
if
(
res
.
errMsg
==
"shareAppMessage:ok"
)
{
}
},
fail
:
function
()
{
// 转发失败之后的回调
if
(
res
.
errMsg
==
"shareAppMessage:fail cancel"
)
{
// 用户取消转发
}
else
if
(
res
.
errMsg
==
"shareAppMessage:fail"
)
{
// 转发失败,其中 detail message 为详细失败信息
}
},
complete
:
function
()
{
// 转发结束之后的回调(转发成不成功都会执行)
}
};
};
},
},
onLoad
(
options
)
{
onLoad
(
options
)
{
Object
.
assign
(
this
.
$data
,
this
.
$options
.
data
());
Object
.
assign
(
this
.
$data
,
this
.
$options
.
data
());
console
.
log
(
options
,
"index"
);
console
.
log
(
options
,
"index"
);
this
.
options
=
options
;
this
.
options
=
options
;
if
(
options
.
from
==
"login"
)
{
if
(
options
.
share
)
{
//来自分享
this
.
link
=
options
.
share
;
this
.
page
=
""
;
this
.
params
=
""
;
}
else
if
(
options
.
from
&&
options
.
from
==
"login"
)
{
//来自登录页面
this
.
page
=
decodeURIComponent
(
options
.
backpath
);
this
.
page
=
decodeURIComponent
(
options
.
backpath
);
this
.
params
+=
"&"
+
decodeURIComponent
(
options
.
params
);
this
.
params
+=
"&"
+
decodeURIComponent
(
options
.
params
);
}
else
if
(
options
.
from
==
"wxPay"
)
{
}
else
if
(
options
.
from
==
"wxPay"
)
{
}
//来自支付页面
this
.
page
=
options
.
backpath
;
console
.
log
(
"url"
,
this
.
link
,
"-"
,
this
.
page
,
"-"
,
this
.
params
);
this
.
params
=
this
.
params
+
"&orderSn="
+
options
.
params
;
return
;
if
(
options
.
payCallback
&&
options
.
orderSn
)
{
//支付页面跳转过来
this
.
page
=
options
.
payCallback
;
this
.
params
=
this
.
params
+
"&orderSn="
+
options
.
orderSn
;
}
else
if
(
options
.
scene
)
{
}
else
if
(
options
.
scene
)
{
//扫码
//
来自
扫码
// options 中的scene需要使用decodeURIComponent才能获取到生成二维码时传入的scene
// options 中的scene需要使用decodeURIComponent才能获取到生成二维码时传入的scene
var
scene
=
decodeURIComponent
(
options
.
scene
);
//参数二维码传递过来的参数
var
scene
=
decodeURIComponent
(
options
.
scene
);
//参数二维码传递过来的参数
var
query
=
options
.
query
.
dentistId
;
// 参数二维码传递过来的场景参数
var
query
=
options
.
query
.
dentistId
;
// 参数二维码传递过来的场景参数
}
else
if
(
options
)
{
}
}
console
.
log
(
"url"
,
this
.
link
+
this
.
page
+
this
.
params
);
},
},
components
:
{
components
:
{
// card
// card
...
@@ -102,20 +126,20 @@ export default {
...
@@ -102,20 +126,20 @@ export default {
}
}
},
},
onUnload
()
{
onUnload
()
{
console
.
log
(
'卸载----------------'
)
console
.
log
(
"卸载----------------"
,
this
.
options
);
//控制返回按钮
//控制返回按钮
if
(
this
.
options
.
backpath
)
{
//
if (this.options.backpath) {
switch
(
this
.
options
.
backpath
)
{
//
switch (this.options.backpath) {
case
"/login/accountLogin"
:
//
case "/login/accountLogin":
wx
.
redirectTo
({
//
wx.redirectTo({
url
:
`../login/main`
//
url: `../login/main`
});
//
});
break
;
//
break;
default
:
//
default:
break
;
//
break;
}
//
}
}
//
}
}
}
};
};
</
script
>
</
script
>
...
...
src/pages/login/index.vue
View file @
f74e40d8
<
template
>
<
template
>
<div
class=
"domain"
>
<div
class=
"domain"
>
1234
<div
class=
"toCLogin"
>
<div
class=
"toCLogin"
v-if=
"!isShowPhone"
>
<p
class=
"shopName"
v-if=
"shopName"
>
{{
shopName
}}
</p>
<p
class=
"shopName"
v-if=
"shopName"
>
{{
shopName
}}
</p>
<div
class=
"btn_info"
>
<div
class=
"btn_info"
>
<button
class=
"btn"
open-type=
"getUserInfo"
@
getuserinfo=
"getUserInfo"
>
微信登录
</button>
<button
class=
"btn"
open-type=
"getUserInfo"
@
getuserinfo=
"getUserInfo"
>
微信登录
</button>
</div>
</div>
<div
class=
"enterpriseLogin"
@
click=
"eLogin"
>
企业员工登录
</div>
<div
class=
"enterpriseLogin"
@
click=
"eLogin"
>
企业员工登录
</div>
</div>
</div>
<div
class=
"toCLogin"
v-if=
"isShowPhone"
>
<div
class=
"toCLogin toCLogin1"
v-if=
"isShowPhone"
>
<div
class=
"btn_info"
>
<div
class=
"btn_info1"
>
<button
class=
"btn"
open-type=
"getPhoneNumber"
@
getphonenumber=
"getPhoneNumber"
>
绑定手机号
</button>
<h1>
绑定手机号
</h1>
<span
class=
"hint"
>
检测到您的账号还未绑定手机号,请绑定手机号
</span>
<button
class=
"btn"
open-type=
"getPhoneNumber"
@
getphonenumber=
"getPhoneNumber"
>
绑定手机号一键绑定
</button>
<div
class=
"btn2"
@
click=
"handbindHandle"
>
手动绑定手机号
</div>
</div>
</div>
<div
class=
"layer"
@
click=
"isShowPhone=false"
></div>
</div>
</div>
<!--
<div
v-else
>
<!--
<div
v-else
>
...
@@ -40,7 +43,7 @@ export default {
...
@@ -40,7 +43,7 @@ export default {
return
{
return
{
session_key
:
""
,
session_key
:
""
,
shopName
:
""
,
shopName
:
""
,
isShow
:
tru
e
,
isShow
:
fals
e
,
isShowPhone
:
false
,
isShowPhone
:
false
,
getPhone
:
false
,
getPhone
:
false
,
openid
:
""
,
openid
:
""
,
...
@@ -74,7 +77,6 @@ export default {
...
@@ -74,7 +77,6 @@ export default {
getshop
()
{
getshop
()
{
shop
.
getShopInfo
().
then
(
res
=>
{
shop
.
getShopInfo
().
then
(
res
=>
{
console
.
log
(
res
,
"shop"
);
console
.
log
(
res
,
"shop"
);
if
(
res
.
data
.
code
==
200
)
{
if
(
res
.
data
.
code
==
200
)
{
this
.
shopName
=
res
.
data
.
data
.
shopName
;
this
.
shopName
=
res
.
data
.
data
.
shopName
;
}
}
...
@@ -88,24 +90,29 @@ export default {
...
@@ -88,24 +90,29 @@ export default {
.
miniLogin
({
code
:
res
.
code
})
.
miniLogin
({
code
:
res
.
code
})
.
then
(
res
=>
{
.
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
)
{
if
(
res
.
data
.
code
==
200
)
{
wx
.
setStorage
({
key
:
"openid"
,
data
:
res
.
data
.
data
.
openid
});
this
.
isShow
=
true
;
if
(
res
.
data
.
data
.
isHaveUnion
==
"true"
)
{
if
(
res
.
data
.
data
.
isHaveUnion
==
"true"
)
{
this
.
session_key
=
res
.
data
.
data
.
session_key
;
this
.
session_key
=
res
.
data
.
data
.
session_key
;
this
.
isHaveUnion
=
true
;
this
.
isHaveUnion
=
true
;
this
.
backParams
+=
`&sessionid=
${
res
.
data
.
data
.
sessionId
}
`
;
this
.
backParams
+=
`&sessionid=
${
res
.
data
.
data
.
sessionId
}
`
;
console
.
log
(
this
.
backParams
,
"mini"
);
console
.
log
(
res
,
"mini"
);
wx
.
setStorage
({
key
:
"sessionid"
,
data
:
res
.
data
.
data
.
sessionId
});
process
.
env
.
sessionid
=
res
.
data
.
data
.
sessionId
;
//有账号
//有账号
// wx.setStorage({
// key: "sessionId",
// data: res.data.data.sessionId
// });
}
else
{
}
else
{
//需要绑定
//需要绑定
this
.
isHaveUnion
=
false
;
this
.
isHaveUnion
=
false
;
this
.
openid
=
res
.
data
.
data
.
openid
;
this
.
openid
=
res
.
data
.
data
.
openid
;
this
.
session_key
=
res
.
data
.
data
.
session_key
;
this
.
session_key
=
res
.
data
.
data
.
session_key
;
this
.
appid
=
res
.
data
.
data
.
appid
;
this
.
appid
=
res
.
data
.
data
.
appid
;
this
.
isShow
=
true
;
}
}
}
}
})
})
...
@@ -115,10 +122,10 @@ export default {
...
@@ -115,10 +122,10 @@ export default {
});
});
},
},
getUserInfo
:
function
(
e
)
{
getUserInfo
:
function
(
e
)
{
if
(
e
.
target
.
errMsg
==
"getUserInfo:ok"
)
{
if
(
e
.
target
.
errMsg
==
"getUserInfo:ok"
&&
this
.
isShow
)
{
if
(
this
.
isHaveUnion
)
{
if
(
this
.
isHaveUnion
)
{
//是会员 直接登录
//是会员 直接登录
wx
.
re
directTo
({
wx
.
re
Launch
({
url
:
`../index/main?from=login&backpath=
${
url
:
`../index/main?from=login&backpath=
${
this
.
backPath
this
.
backPath
}
¶ms=
${
encodeURIComponent
(
this
.
backParams
)}
`
}
¶ms=
${
encodeURIComponent
(
this
.
backParams
)}
`
...
@@ -132,7 +139,7 @@ export default {
...
@@ -132,7 +139,7 @@ export default {
e
.
mp
.
detail
.
encryptedData
,
e
.
mp
.
detail
.
encryptedData
,
e
.
mp
.
detail
.
iv
e
.
mp
.
detail
.
iv
);
);
this
.
unionId
=
data
.
unionId
;
this
.
unionId
=
data
.
unionId
|
""
;
this
.
userInfo
=
JSON
.
parse
(
e
.
target
.
rawData
);
this
.
userInfo
=
JSON
.
parse
(
e
.
target
.
rawData
);
console
.
log
(
"data"
,
data
,
this
.
unionId
);
console
.
log
(
"data"
,
data
,
this
.
unionId
);
}
}
...
@@ -143,6 +150,7 @@ export default {
...
@@ -143,6 +150,7 @@ export default {
success
:
()
=>
{
success
:
()
=>
{
//session_key 未过期,并且在本生命周期一直有效
//session_key 未过期,并且在本生命周期一直有效
if
(
e
.
target
.
errMsg
==
"getPhoneNumber:ok"
)
{
if
(
e
.
target
.
errMsg
==
"getPhoneNumber:ok"
)
{
console
.
log
(
"生命周期一直"
);
this
.
isShowPhone
=
false
;
this
.
isShowPhone
=
false
;
this
.
phoneNumber
=
wx_decode
(
this
.
phoneNumber
=
wx_decode
(
process
.
env
.
APPID
,
process
.
env
.
APPID
,
...
@@ -170,15 +178,16 @@ export default {
...
@@ -170,15 +178,16 @@ export default {
nickname
:
this
.
userInfo
.
nickName
nickname
:
this
.
userInfo
.
nickName
})
})
.
then
(
res
=>
{
.
then
(
res
=>
{
console
.
log
(
res
.
data
,
"=================-"
);
//绑定成功
//绑定成功
if
(
res
.
data
.
code
==
200
)
{
if
(
res
.
data
.
code
==
200
)
{
this
.
backParams
+=
`&sessionid=
${
res
.
data
.
data
.
sessionId
}
`
;
this
.
backParams
+=
`&sessionid=
${
res
.
data
.
data
.
sessionId
}
`
;
// console.log(this.backParams, "binduser");
wx
.
setStorage
({
// wx.setStorage({
key
:
"sessionid"
,
// key: "sessionId",
data
:
res
.
data
.
data
.
sessionId
// data: res.data.data
});
// })
;
process
.
env
.
sessionid
=
res
.
data
.
data
.
sessionId
;
wx
.
re
directTo
({
wx
.
re
Launch
({
url
:
`../index/main?from=login&backpath=
${
url
:
`../index/main?from=login&backpath=
${
this
.
backPath
this
.
backPath
}
¶ms=
${
encodeURIComponent
(
this
.
backParams
)}
`
}
¶ms=
${
encodeURIComponent
(
this
.
backParams
)}
`
...
@@ -190,16 +199,23 @@ export default {
...
@@ -190,16 +199,23 @@ export default {
});
});
},
},
backMainHandle
()
{
backMainHandle
()
{
wx
.
re
directTo
({
wx
.
re
Launch
({
url
:
`../index/main?from=login&backpath=
${
url
:
`../index/main?from=login&backpath=
${
this
.
backPath
this
.
backPath
}
¶ms=
${
encodeURIComponent
(
this
.
backParams
)}
`
}
¶ms=
${
encodeURIComponent
(
this
.
backParams
)}
`
});
});
},
},
eLogin
()
{
//企业员工登录
eLogin
()
{
//企业员工登录
wx
.
redirectTo
({
wx
.
redirectTo
({
url
:
`../index/main?from=login&backpath=/login/accountLogin`
url
:
`../index/main?from=login&backpath=/login/accountLogin`
});
});
},
handbindHandle
()
{
//绑定手机号
wx
.
navigateTo
({
url
:
`../index/main?from=login&backpath=/login/wxRegister`
});
}
}
}
}
};
};
...
@@ -207,6 +223,7 @@ export default {
...
@@ -207,6 +223,7 @@ export default {
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
.domain
{
.domain
{
//
position
:
relative
;
.toCLogin
{
.toCLogin
{
display
:
flex
;
display
:
flex
;
width
:
100%
;
width
:
100%
;
...
@@ -223,18 +240,64 @@ export default {
...
@@ -223,18 +240,64 @@ export default {
.btn_info
{
.btn_info
{
margin
:
0
auto
;
margin
:
0
auto
;
color
:
#
fff
;
color
:
#
000
;
align-items
:
center
;
align-items
:
center
;
justify-content
:
space-around
;
justify-content
:
space-around
;
.btn
{
.btn
{
margin-top
:
180px
;
margin-top
:
180px
;
background-color
:
#01d10c
;
background-color
:
#01d10c
;
color
:
#fff
;
color
:
#fff
;
height
:
45px
;
height
:
45px
;
width
:
200px
;
width
:
200px
;
border-radius
:
90
px
;
border-radius
:
5
px
;
}
}
}
}
.btn_info1
{
margin
:
80px
10px
;
color
:
#000
;
align-items
:
center
;
justify-content
:
space-around
;
border
:
0.5px
solid
#000
;
border-radius
:
5px
;
padding
:
15px
;
z-index
:
1
;
background-color
:
#fff
;
h1
{
text-align
:
center
;
font-size
:
22px
;
margin
:
10px
15px
;
font-weight
:
700
;
}
.btn
{
margin-top
:
10px
;
background-color
:
#01d10c
;
color
:
#fff
;
height
:
45px
;
//
width
:
90%
;
border-radius
:
5px
;
font-size
:
16px
;
}
.btn2
{
border
:
1px
solid
#000
;
height
:
45px
;
//
width
:
90%
;
border-radius
:
5px
;
margin
:
10px
auto
;
text-align
:
center
;
font-size
:
16px
;
line-height
:
45px
;
}
}
.layer
{
position
:
fixed
;
top
:
0
;
left
:
0
;
width
:
100%
;
height
:
100%
;
background
:
rgba
(
0
,
0
,
0
,
0.5
);
z-index
:
0
;
}
.enterpriseLogin
{
.enterpriseLogin
{
position
:
absolute
;
position
:
absolute
;
bottom
:
20px
;
bottom
:
20px
;
...
@@ -245,13 +308,10 @@ export default {
...
@@ -245,13 +308,10 @@ export default {
font-size
:
15px
;
font-size
:
15px
;
}
}
}
}
.bind
{
.toCLogin1
{
position
:
absolute
;
top
:
0
;
left
:
0
;
}
}
}
}
//
.login
{
//
background-color
:
green
;
//
margin
:
30px
;
//
color
:
#fff
;
//
}
</
style
>
</
style
>
src/pages/wxPay/index.vue
View file @
f74e40d8
<
template
>
<
template
>
<div>
正在支付中。。。
</div>
<div>
{{
message
}}
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
{
formatTime
}
from
"@/utils/index"
;
import
{
formatTime
}
from
"@/utils/index"
;
import
wxPay
from
"@/api/wxPay"
;
export
default
{
export
default
{
components
:
{
components
:
{
// card
// card
...
@@ -12,46 +12,38 @@ export default {
...
@@ -12,46 +12,38 @@ export default {
data
()
{
data
()
{
return
{
return
{
message
:
"正在支付中"
,
shopmixid
:
""
,
shopmixid
:
""
,
openId
:
""
,
options
:
{}
options
:
{}
};
};
},
},
onLoad
(
options
)
{
onLoad
(
options
)
{
console
.
log
(
"支付开始"
,
options
);
Object
.
assign
(
this
.
$data
,
this
.
$options
.
data
());
//mpvue 的混合周期 使用小程序生命周期数据未初始化
console
.
log
(
"onload//"
);
this
.
options
=
JSON
.
parse
(
options
.
ordercode
);
this
.
options
=
JSON
.
parse
(
options
.
ordercode
);
this
.
getTempcode
(
this
.
options
);
console
.
log
(
this
.
options
,
"pages/wxPay/main"
);
},
let
that
=
this
;
methods
:
{
wx
.
getStorage
({
getTempcode
(
options
)
{
key
:
"openid"
,
let
ths
=
this
;
success
(
res
)
{
wx
.
login
({
// this.openId=res;
success
:
res
=>
{
console
.
log
(
that
.
options
,
"++++"
);
// 发送 res.code 到后台换取 openId, sessionKey, unionId
console
.
log
(
res
,
"openid"
);
console
.
log
(
"支付code:"
,
res
);
that
.
options
.
openId
=
res
.
data
;
options
.
openId
=
"ohUOewfkbVbxHLLledEGGNUu1XgY"
;
that
.
options
.
tradeType
=
"Mini"
;
this
.
getPayinfo
(
options
);
console
.
log
(
"支付开始"
,
that
.
options
);
that
.
toPay
();
}
}
});
});
// this.options.openId = "ohUOewfkbVbxHLLledEGGNUu1XgY";
},
},
getPayinfo
(
options
)
{
methods
:
{
var
self
=
this
;
toPay
()
{
wx
.
request
({
wxPay
url
:
.
to_wx_pay
(
this
.
options
)
"http://test-m-shop.mayi888.cn/innerApi/shopApiService/pay/to_wx_pay"
,
//后台接口地址
.
then
(
res
=>
{
data
:
options
,
method
:
"POST"
,
header
:
{
"Content-Type"
:
"application/x-www-form-urlencoded"
,
"Shop-Mixid"
:
"dev001"
,
Authorization
:
"ce9d0ca7-ba9b-4951-9c42-47cd9b5e4f42"
},
success
:
function
(
res
)
{
console
.
log
(
res
,
"ressssssss"
);
let
payData
=
JSON
.
parse
(
res
.
data
.
data
);
let
payData
=
JSON
.
parse
(
res
.
data
.
data
);
payData
.
appId
=
'wxfe9889fb08e7f50b'
;
console
.
log
(
res
,
"ressssssss"
);
// {
// {
// timestamp: 0, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
// timestamp: 0, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
// nonceStr: '', // 支付签名随机串,不长于 32 位
// nonceStr: '', // 支付签名随机串,不长于 32 位
...
@@ -61,36 +53,48 @@ export default {
...
@@ -61,36 +53,48 @@ export default {
// success:
// success:
// }
// }
payData
.
success
=
res
=>
{
payData
.
success
=
res
=>
{
console
.
log
(
"支付成功"
,
res
);
console
.
log
(
"支付成功"
,
res
,
this
.
options
);
// wx.redirectTo({"url":`../index/main?payCallback=/pay/paySuccess&orderSn=${options.orderSn}`});
this
.
message
=
"支付成功"
;
// Toast("支付成功~");
let
that
=
this
;
// window.location.replace('/pay/paySuccess?orderSn='+this.$route.query.orderSn);
wx
.
redirectTo
({
// this.$router.replace(
url
:
`../index/main?from=wxPay&backpath=/pay/paySuccess¶ms=
${
// "/pay/paySuccess?orderSn=" + this.$route.query.orderSn
that
.
options
.
orderSn
// );
}
`
});
};
};
payData
.
fail
=
res
=>
{
payData
.
fail
=
res
=>
{
console
.
log
(
"支付失败"
,
res
);
console
.
log
(
"支付失败"
,
res
,
this
.
options
.
orderSn
);
this
.
message
=
"支付失败"
;
let
that
=
this
;
console
.
log
(
`../index/main?from=wxPay&backpath=/pay/paySuccess¶ms=
${
that
.
options
.
orderSn
}
`
)
wx
.
redirectTo
({
url
:
`../index/main?from=wxPay&backpath=/pay/paySuccess¶ms=
${
that
.
options
.
orderSn
}
`
});
// window.location.replace('/pay/paySuccess?orderSn='+this.$route.query.orderSn);
// this.$router.replace(
// "/pay/paySuccess?orderSn=" + this.$route.query.orderSn
// );
};
};
payData
.
complete
=
res
=>
{
payData
.
complete
=
res
=>
{
console
.
log
(
"支付取消"
,
res
,
options
);
wx
.
redirectTo
({
"url"
:
`../index/main?from=wxPay&backpath=/pay/paySuccess¶ms=
${
options
.
orderSn
}
`
});
if
(
res
.
errMsg
==
"chooseWXPay:cancel"
)
{
if
(
res
.
errMsg
==
"chooseWXPay:cancel"
)
{
console
.
log
(
"支付取消11"
);
console
.
log
(
"支付取消"
,
this
.
options
);
// payApi.cancelPayment(this.$route.query.orderSn);
this
.
message
=
"支付取消"
;
let
that
=
this
;
wx
.
redirectTo
({
url
:
`../index/main?from=wxPay&backpath=/pay/paySuccess¶ms=
${
that
.
options
.
orderSn
}
`
});
}
}
};
};
wx
.
requestPayment
(
payData
);
wx
.
requestPayment
(
payData
);
// wx.navigateTo({
})
// url: `/pages/lnyc2019/detail?ordercode=${self.data.ordercode}`
.
catch
(
err
=>
{});
// });
}
});
}
}
}
}
};
};
...
...
src/utils/request.js
View file @
f74e40d8
let
shopMixid
=
"dev001"
;
let
shopMixid
=
"dev001"
;
console
.
log
(
'----------------------------'
,
process
.
env
.
sessionid
)
export
function
requestGET
(
url
,
options
)
{
export
function
requestGET
(
url
,
options
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
request
({
wx
.
request
({
...
@@ -6,9 +7,8 @@ export function requestGET(url, options) {
...
@@ -6,9 +7,8 @@ export function requestGET(url, options) {
data
:
options
,
data
:
options
,
method
:
"GET"
,
method
:
"GET"
,
header
:
{
header
:
{
"Content-Type"
:
"application/x-www-form-urlencoded"
,
"Shop-Mixid"
:
shopMixid
,
"Shop-Mixid"
:
shopMixid
,
Authorization
:
"
ce9d0ca7-ba9b-4951-9c42-47cd9b5e4f42
"
Authorization
:
"
eedbbdaf-844c-4fcc-8970-1fb92346441c
"
},
},
success
:
function
(
res
)
{
success
:
function
(
res
)
{
resolve
(
res
)
resolve
(
res
)
...
@@ -28,7 +28,28 @@ export function requestPOST(url, options) {
...
@@ -28,7 +28,28 @@ export function requestPOST(url, options) {
method
:
"POST"
,
method
:
"POST"
,
header
:
{
header
:
{
"Shop-Mixid"
:
shopMixid
,
"Shop-Mixid"
:
shopMixid
,
Authorization
:
"ce9d0ca7-ba9b-4951-9c42-47cd9b5e4f42"
Authorization
:
"eedbbdaf-844c-4fcc-8970-1fb92346441c"
},
success
:
function
(
res
)
{
resolve
(
res
)
},
fail
:
function
(
res
)
{
reject
(
res
)
}
})
})
}
export
async
function
requestPOST1
(
url
,
options
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
request
({
url
:
url
,
data
:
options
,
method
:
"POST"
,
header
:
{
"Content-Type"
:
"application/x-www-form-urlencoded"
,
"Shop-Mixid"
:
shopMixid
,
Authorization
:
"eedbbdaf-844c-4fcc-8970-1fb92346441c"
},
},
success
:
function
(
res
)
{
success
:
function
(
res
)
{
resolve
(
res
)
resolve
(
res
)
...
...
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