123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <template>
- <view class="container" >
- <view v-if="!wxOpendata&&isload">
- <view class="logoBox">
- <image src="../../static/img/euro.png" mode="" class="euroImg"></image>
- </view>
- <view class="title1">请完成微信授权以继续使用</view>
- <button class="wxlogin" @click="wxgologin">授权微信用户信息</button>
- <view class="title2" @click="goIndex">取消授权</view>
- </view>
-
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
-
- wxdata:'',
- wxCode:'',
- openID:'',
- session_key:'',
- wxPhoneData:'',
- type:'',
- wxOpendata:'',
- isload:false,
- }
- },
- onLoad(opt) {
- this.type=opt.type;
- this.wxOpendata=uni.getStorageSync("wxOpendata");
-
- if( this.wxOpendata){
- uni.switchTab({
- url:'../index/index'
- })
- }else{
- this.isload=true;
- }
- },
- methods: {
- goIndex(){
- uni.switchTab({
- url:'../index/index'
- })
- },
-
- //api uni.getUserProfile
- wxgologin(){
- var that=this;
- uni.getUserProfile({
- lang:'zh_CN',
- desc:'登录',
- success:(res)=>{
- console.log(res);
- that.wxdata=res;
- uni.setStorage({
- key: 'wxdata',
- data: res,
- success: function () {
- that.ipLogin()
-
- }
- });
- },
- fail:(res)=>{
- console.log(res)
- }
- });
- },
- //api uni.login
- ipLogin(){
- var that=this;
- uni.showLoading({ });
- uni.login({
- provider: 'weixin',
- success: function (loginRes) {
- // console.log(loginRes)
- that.wxCode=loginRes.code
- that.getWxOpenID()
-
- }
- });
-
- },
-
- getWxOpenID(){
- var that=this;
- this.$http('worldKeepCar/sys/getWxOpenID', {
- code:this.wxCode,
- },'GET').then(res => {
- // console.log(res)
- this.openID=res.data.openid;
- this.session_key=res.data.session_key;
- // console.log(this.openID)
- uni.setStorage({
- key: 'wxOpendata',
- data: res.data,
- success: function () {
- // that.ipLogin()
- uni.hideLoading();
- if(!that.type){
- uni.switchTab({
- url:'../index/index'
- })
- }else{
- uni.redirectTo({
- url:'login'
- })
- }
- }
- });
-
- })
- },
-
- }
- }
- </script>
- <style scoped>
- .euroImg{
- width: 290rpx;
- height: 266rpx;
- }
- .logoBox{
- text-align: center;
- padding-top: 160rpx;
- }
- .title1{
- font-size: 26rpx;
- text-align: center;
- color: #576B95;
- padding-top: 150rpx;
- }
- .wxlogin{
- width: 658rpx;
- height: 88rpx;
- background: linear-gradient(113deg, #FF630F 0%, #FF450F 100%);
- border-radius: 10rpx;
- line-height: 88rpx;
- text-align: center;
- color: #FFFFFF;
- font-size: 30rpx;
- margin-top: 20rpx;
- }
- .title2{
- width: 100vw;
- position: fixed;
- left: 0;
- bottom: 50rpx;
- font-size: 26rpx;
- text-align: center;
- color: #576B95;
- }
- </style>
|