|
@@ -5,63 +5,66 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- export default {
|
|
|
- name: 'App',
|
|
|
- provide() { //父组件中通过provide来提供变量,在子组件中通过inject来注入变量。
|
|
|
- return {
|
|
|
- reload: this.reload
|
|
|
- }
|
|
|
- },
|
|
|
- data() {
|
|
|
- return {
|
|
|
- isRouterAlive: true //控制视图是否显示的变量
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- created () {
|
|
|
- window.localStorage.setItem('scanUrl',location.href.split('#')[0])
|
|
|
- this.$http.post(this.$store.state.host + "/weixin/getWxConfig", {
|
|
|
- url: window.location.href.split('#')[0]
|
|
|
- }, {
|
|
|
- emulateJSON: true
|
|
|
+import { getWxConfig } from './api/index'
|
|
|
+export default {
|
|
|
+ name: 'App',
|
|
|
+ provide() { //父组件中通过provide来提供变量,在子组件中通过inject来注入变量。
|
|
|
+ return {
|
|
|
+ reload: this.reload
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ isRouterAlive: true //控制视图是否显示的变量
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ async created() {
|
|
|
+ window.localStorage.setItem('scanUrl', location.href.split('#')[0])
|
|
|
+ // this.$http.post(this.$store.state.host + "/weixin/getWxConfig", {
|
|
|
+ // url: window.location.href.split('#')[0]
|
|
|
+ // }, {
|
|
|
+ // emulateJSON: true
|
|
|
+ // })
|
|
|
+
|
|
|
+ const res = await getWxConfig({ url: window.location.href.split('#')[0] })
|
|
|
+
|
|
|
+ //发送成功
|
|
|
+ var timestamp = res.wxConfig.timestamp;
|
|
|
+ var noncestr = res.wxConfig.nonceStr;
|
|
|
+ var signature = res.wxConfig.signature;
|
|
|
+ var appId = res.wxConfig.appId;
|
|
|
+ wx.config({
|
|
|
+ debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
|
|
+ // debug : true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
|
|
+ appId: appId, // 必填,公众号的唯一标识
|
|
|
+ timestamp: timestamp, // 必填,生成签名的时间戳
|
|
|
+ nonceStr: noncestr, // 必填,生成签名的随机串
|
|
|
+ signature: signature, // 必填,签名,见附录1
|
|
|
+ jsApiList: [
|
|
|
+ "scanQRCode",
|
|
|
+ ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
|
|
|
+ });
|
|
|
+ // res => {
|
|
|
+ // //发送失败
|
|
|
+ // Toast("网络错误!")
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ reload() {
|
|
|
+ this.isRouterAlive = false; //先关闭,
|
|
|
+ this.$nextTick(function () {
|
|
|
+ this.isRouterAlive = true; //再打开
|
|
|
})
|
|
|
- .then(res => {
|
|
|
- //发送成功
|
|
|
- var timestamp = res.body.wxConfig.timestamp;
|
|
|
- var noncestr = res.body.wxConfig.nonceStr;
|
|
|
- var signature = res.body.wxConfig.signature;
|
|
|
- var appId = res.body.wxConfig.appId;
|
|
|
- wx.config({
|
|
|
- debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
|
|
- // debug : true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
|
|
- appId: appId, // 必填,公众号的唯一标识
|
|
|
- timestamp: timestamp, // 必填,生成签名的时间戳
|
|
|
- nonceStr: noncestr, // 必填,生成签名的随机串
|
|
|
- signature: signature, // 必填,签名,见附录1
|
|
|
- jsApiList: [
|
|
|
- "scanQRCode",
|
|
|
- ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
|
|
|
- });
|
|
|
- }, res => {
|
|
|
- //发送失败
|
|
|
- Toast("网络错误!")
|
|
|
- })
|
|
|
- },
|
|
|
- methods: {
|
|
|
- reload() {
|
|
|
- this.isRouterAlive = false; //先关闭,
|
|
|
- this.$nextTick(function() {
|
|
|
- this.isRouterAlive = true; //再打开
|
|
|
- })
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
- #app {
|
|
|
- width: 100%;
|
|
|
- max-width: 7.5rem;
|
|
|
- margin: 0 auto;
|
|
|
- }
|
|
|
+#app {
|
|
|
+ width: 100%;
|
|
|
+ max-width: 7.5rem;
|
|
|
+ margin: 0 auto;
|
|
|
+}
|
|
|
</style>
|