绿满眶商城微信小程序-uniapp
xiangpei
2025-05-09 c3e6cdbb29580e77444541c7953aca33581a4267
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<template>
  <view class="container">
    <u-navbar :custom-back="back" title="公众网页登录"></u-navbar>
    <view class="wx-auth-container">
      <div class="box">
        <view class="logo-info">
          <text class="title">欢迎进入{{ projectName }}</text>
        </view>
        <view class="small-tips">
          <view>为您提供优质服务,{{ projectName }}需要获取以下信息</view>
          <view>您的公开信息(昵称、头像)</view>
        </view>
        <view class="btns">
          <button @click="getUserProfile()" class="btn-auth">使用微信授权</button>
          <div @click="backToHome" class="btn-callback">暂不登录</div>
        </view>
      </div>
    </view>
  </view>
</template>
 
<script>
import { whetherNavigate } from "@/utils/Foundation"; //登录跳转
import config from "@/config/config";
import api from "@/config/api.js";
export default {
  data() {
    return {
      // 授权信息展示,商城名称
      projectName: config.name,
    };
  },
 
  //微信小程序进入页面,先获取code,否则几率出现code和后续交互数据不对应情况
  mounted() {
    // 小程序默认分享
    uni.showShareMenu({ withShareTicket: true });
  },
  methods: {
    back() {
      whetherNavigate();
    },
    getUserProfile() {
      let code = "WECHAT";
      let buyer = api.buyer;
      window.open(buyer + `/passport/connect/connect/login/web/` + code, "_self");
    },
    backToHome() {
      uni.switchTab({
        url: `/pages/tabbar/home/index`,
      });
    },
  },
};
</script>
 
<style lang="scss" scoped>
.wx-auth-container {
  width: 100%;
 
  margin-top: 20%;
}
 
.logo-info {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  flex-direction: row;
  align-items: flex-start;
  padding: 20rpx;
  flex-direction: column;
  font-weight: bold;
}
 
image {
  width: 100px;
  height: 100px;
  text-align: center;
  -webkit-transform: scale(2.5);
  transform: scale(2.5);
}
 
text.title,
text.shop {
  display: inline-block;
  font-size: 60rpx;
  color: #333;
}
 
.box {
  margin: 0 32rpx;
}
 
/* 文字提示*/
.small-tips {
  width: 94%;
  padding: 20rpx;
  font-size: 24rpx;
  margin: 0 0 20rpx;
  color: #999;
}
 
.btn-auth {
  width: 92%;
  background: $light-color;
  color: #fff;
  margin: 0 auto 40rpx;
  border-radius: 100px;
  animation: mymove 5s infinite;
  -webkit-animation: mymove 5s infinite; /*Safari and Chrome*/
  animation-direction: alternate; /*轮流反向播放动画。*/
  animation-timing-function: ease-in-out; /*动画的速度曲线*/
  /* Safari 和 Chrome */
  -webkit-animation: mymove 5s infinite;
  -webkit-animation-direction: alternate; /*轮流反向播放动画。*/
  -webkit-animation-timing-function: ease-in-out; /*动画的速度曲线*/
}
.btn-callback {
  text-align: center;
  font-size: 30rpx;
  background: #ededed;
  height: 90rpx;
  line-height: 90rpx;
  border-radius: 100px;
  width: 92%;
  margin: 0 auto;
}
 
.btns {
  margin-top: 100rpx;
  display: flex;
  flex-direction: column;
  width: 100%;
  justify-content: center;
}
 
@keyframes mymove {
  0% {
    transform: scale(1); /*开始为原始大小*/
  }
  25% {
    transform: scale(1.1); /*放大1.1倍*/
  }
  50% {
    transform: scale(1);
  }
  75% {
    transform: scale(1.1);
  }
}
</style>