|
|
@@ -5,6 +5,7 @@ import { setupAssets, setupScrollbarStyle } from './plugins'
|
|
|
import { setupStore } from './store'
|
|
|
import { setupRouter } from './router'
|
|
|
import queryString from 'query-string'
|
|
|
+import { fetchOpenid, fetchJsapiSign, fetchPay } from '@/api'
|
|
|
|
|
|
const query = queryString.parse(location.search)
|
|
|
|
|
|
@@ -14,6 +15,29 @@ if (query.invitor) {
|
|
|
}
|
|
|
if (query.code) {
|
|
|
alert(query.code + ',' + query.state)
|
|
|
+ let openid: any = ''
|
|
|
+ fetchOpenid(query.code as string)
|
|
|
+ .then(res => {
|
|
|
+ openid = res
|
|
|
+ return fetchJsapiSign(location.href.split('#')[0])
|
|
|
+ })
|
|
|
+ .then((res: any) => {
|
|
|
+ wx.config({
|
|
|
+ ...res,
|
|
|
+ debug: true,
|
|
|
+ jsApiList: ['chooseWXPay', 'updateAppMessageShareData', 'updateTimelineShareData']
|
|
|
+ })
|
|
|
+ wx.ready(function () {
|
|
|
+ fetchPay(openid).then((params: any) => {
|
|
|
+ wx.chooseWXPay({
|
|
|
+ ...params,
|
|
|
+ success: function (res: any) {
|
|
|
+ console.log(res)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
async function bootstrap() {
|