|
@@ -1,38 +1,51 @@
|
|
|
<template>
|
|
|
<div class="container">
|
|
|
- <button open-type="getUserInfo" @click="login">用户信息</button>
|
|
|
+ <button open-type="getUserInfo" @click="login">登录</button>
|
|
|
<div class="userinfo" >
|
|
|
<img :src="userInfo.avatarUrl" alt="">
|
|
|
<p>{{userInfo.nickName}}</p>
|
|
|
</div>
|
|
|
-
|
|
|
- <button class='btn'>添加图书</button>
|
|
|
+ <YearProgress></YearProgress>
|
|
|
+ <button @click="scanBook" class='btn'>添加图书</button>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-
|
|
|
+import {showSuccess} from '@/util'
|
|
|
import config from '@/config'
|
|
|
import qcloud from 'wafer2-client-sdk'
|
|
|
+import YearProgress from '@/components/YearProgress'
|
|
|
export default {
|
|
|
- data () {
|
|
|
+ components: {
|
|
|
+ YearProgress
|
|
|
+ },
|
|
|
+ data () {
|
|
|
return {
|
|
|
+ isLogin: false,
|
|
|
userInfo: { }
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
login () {
|
|
|
- qcloud.setLoginUrl(config.loginUrl);
|
|
|
+ qcloud.setLoginUrl(config.loginUrl)
|
|
|
qcloud.login({
|
|
|
- success: function (userInfo) {
|
|
|
- console.log('登录成功', userInfo);
|
|
|
- wx.setStorageSync('userInfo', userInfo)
|
|
|
- },
|
|
|
- fail: function (err) {
|
|
|
- console.log('登录失败', err);
|
|
|
- }
|
|
|
- });
|
|
|
+ success: function (userInfo) {
|
|
|
+ console.log('登录成功', userInfo)
|
|
|
+ showSuccess('登录成功')
|
|
|
+ wx.setStorageSync('userInfo', userInfo)
|
|
|
+ },
|
|
|
+ fail: function (err) {
|
|
|
+ console.log('登录失败', err)
|
|
|
+ }
|
|
|
+ })
|
|
|
this.userInfo = wx.getStorageSync('userInfo')
|
|
|
+ },
|
|
|
+ scanBook () {
|
|
|
+ wx.scanCode({
|
|
|
+ success (res) {
|
|
|
+ console.log(res)
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -63,7 +76,6 @@ export default {
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
-
|
|
|
</script>
|
|
|
|
|
|
|