提交 70bfdae0 authored 作者: lihuihui's avatar lihuihui
......@@ -27,7 +27,7 @@ export function sendResetPasswordCode(data) {
}
// 登出
export function logout() {
return httpRequest.post('https://learn-pbcsf.ezijing.com/api/clear/cookie')
return httpRequest.get('/passport/rest/logout')
}
// 获取用户信息
export function getUser() {
......
......@@ -79,7 +79,7 @@ export default {
_callback(_obj)
})
},
goToPay () {
async goToPay () {
const obj = { code: 0, msg: '', data: {} }
if (!this.requestParam.product_id) {
obj.code = 3001
......@@ -91,34 +91,47 @@ export default {
obj.msg = '没有小程序用户openid'
return obj
}
return Pay.getOrderId(this.requestParam).then(res => {
obj.data = res
this.wxWakeUpToPay()
// return
return await Pay.getOrderId(this.requestParam).then(res => {
if (res.code) {
// this.requestParam.product_id
// this.requestParam.open_id
this.requestParam.prepay_id = res.data.prepay_id
this.requestParam.app_id = res.data.options.appId
// this.requestParam.app_secret
this.requestParam.timeStamp = res.data.options.timeStamp
this.requestParam.nonceStr = res.data.options.nonceStr
this.requestParam.signType = res.data.options.signType
this.requestParam.paySign = res.data.options.paySign
this.wxWakeUpToPay(obj)
}
}).catch(e => {
obj.code = 5001
obj.msg = e.message
return obj
})
},
wxWakeUpToPay () {
async wxWakeUpToPay (obj) {
/* 直接调用微信支付 */
const timestamp = parseInt(new Date().getTime() / 1000)
const noncestr = parseInt(Math.random() * 10000000000000000)
// 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 + '', // 随机串
timeStamp: this.requestParam.timeStamp, // 时间戳,自1970年以来的秒数
nonceStr: this.requestParam.nonceStr, // 随机串
package: 'prepay_id=' + this.requestParam.prepay_id,
signType: 'MD5', // 微信签名方式:
paySign: '70EA570631E4BB79628FBCA90534C63FF7FADD89' // 微信签名
signType: this.requestParam.signType, // 微信签名方式:MD5
paySign: this.requestParam.paySign // 微信签名
},
function (res) {
if (res.err_msg === 'get_brand_wcpay_request:ok') {
// 使用以上方式判断前端返回,微信团队郑重提示:
// res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
}
obj.msg = res.err_msg
return obj
// if (res.err_msg === 'get_brand_wcpay_request:ok') {
// // 使用以上方式判断前端返回,微信团队郑重提示:
// // res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
// }
}
)
}
......
......@@ -10,7 +10,7 @@
<van-icon name="arrow" class="icon"/>
</li>
</ul>
<!-- <van-button type="default" @click="logout">退出登录</van-button> -->
<van-button type="default" @click="logout">退出登录</van-button>
</div>
</template>
......
......@@ -2,10 +2,9 @@ import Vue from 'vue'
import Vuex from 'vuex'
import { getUser } from '@/api/account'
Vue.use(Vuex)
export default new Vuex.Store({
state: {
isWeapp: false,
isWeapp: /miniProgram/.test(navigator.userAgent),
isLogin: false,
token: '',
user: {}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论