| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <template>
- <view class="container">
- <img src="../../static/index/logo.png" />
- <view class="msg">靖安乡村民宿</view>
- <view class="btn" @click="handleLogin">授权登录</view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {}
- },
- methods: {
- // 授权登录按钮回调
- handleLogin() {
- // 获取code
- uni.login({
- //使用微信登录
- provider: 'weixin',
- success: (res) => {
- this.loginReq(res.code)
- }
- })
- },
- // 解密用户信息请求
- async loginReq(code) {
- const res = await this.$myRequest({
- url: '/mhotel/ampauthorizationUser.action',
- data: {
- code
- }
- })
- // console.log(res)
- if (res.code === 200) {
- uni.setStorageSync('openid', res.data.openid)
- uni.setStorageSync('userInfo', res.data)
- uni.setStorageSync('tokenId', res.data.token)
- uni.showToast({
- title: '授权成功',
- icon: 'success',
- mask: true
- })
- uni.$emit('changeFlag', {
- data: true
- })
- setTimeout(() => {
- uni.navigateBack(1)
- }, 1500)
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- display: flex;
- flex-direction: column;
- align-items: center;
- height: 100vh;
- background-color: #fff;
- img {
- margin-top: 116rpx;
- width: 138rpx;
- height: 138rpx;
- }
- .msg {
- margin-top: 32rpx;
- font-size: 32rpx;
- font-weight: bold;
- }
- .btn {
- position: absolute;
- // left: 20rpx;
- bottom: 74rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- width: 710rpx;
- height: 96rpx;
- color: #fff;
- font-size: 32rpx;
- border-radius: 64rpx;
- background-color: #096562;
- }
- }
- </style>
|