authoriz.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view class="" >
  3. <view class="authorizBox" @click="authorizHide()" v-if="authorizShow">
  4. <view class="authorizCont" @click.stop="">
  5. <view class="authorizName">{{wxOpenData.miniAppName}}</view>
  6. <view class="authorizMs">您好,欢迎访问本店,授权手机号登录能获取我们最新的促销活动哦~</view>
  7. <button class="authorizContbutton" type="default" open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">授权</button>
  8. </view>
  9. <view style="text-align: center;padding-top: 56rpx;">
  10. <image src="../../static/timg/icon_guanbi@2x.png" mode="" class="authorizCloseImg"></image>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. wxOpenData: '',
  20. plateNumber:'',
  21. ext:'',
  22. userInfo: '',
  23. code:'',
  24. authorizShow:false
  25. }
  26. },
  27. onLoad(opt) {
  28. },
  29. onShow() {
  30. },
  31. methods: {
  32. init(){
  33. this.userInfo=this.$store.state.userInfo;
  34. this.ext=this.$common.getExtStoreId();
  35. if(this.userInfo){
  36. }else{
  37. this.$common.automaticlogin().then(val => {
  38. this.userInfo=this.$store.state.userInfo;
  39. this.wxOpenData=this.$store.state.wxOpenData;
  40. if(!this.userInfo){
  41. this.authorizShow=true
  42. }else{
  43. //this.authorizShow=false
  44. this.$emit('child-event');
  45. }
  46. })
  47. }
  48. },
  49. authorizHide(){
  50. this.authorizShow=false
  51. },
  52. decryptPhoneNumber: function(e) {
  53. console.log(e);
  54. this.code=e.detail.code
  55. this.wxPhoneLogin()
  56. this.authorizShow=false;
  57. },
  58. wxPhoneLogin(){
  59. var that=this;
  60. this.$http('miniApp2/sys/wxPhoneLogin', {
  61. appId:this.ext.appId,
  62. unionId:this.ext.unionId,
  63. code:this.code,
  64. openId:this.wxOpenData.openid
  65. },'POST').then(res => {
  66. var data = res.data;
  67. if(data.loginInfo){
  68. this.userInfo=data.loginInfo.openUser;
  69. this.wxOpenData=data.loginInfo;
  70. this.$store.commit('mutationswxOpenData', data)
  71. this.$store.commit('mutationsuserInfo', this.userInfo)
  72. /* this.myOrderCoupon()
  73. this.myPower()
  74. this.showPower()
  75. this.getplateNumber() */
  76. this.$emit('child-event');
  77. }
  78. })
  79. },
  80. }
  81. }
  82. </script>
  83. <style scoped>
  84. .authorizBox{
  85. width: 100vw;
  86. height: 100vh;
  87. background: rgba(0, 0, 0, 0.5);
  88. position: fixed;
  89. top: 0;
  90. left: 0;
  91. }
  92. .authorizCont{
  93. margin-top: 30vh;
  94. width: 564rpx;
  95. height: 408rpx;
  96. background: #FFFFFF;
  97. border-radius: 24rpx;
  98. margin-left: 93rpx;
  99. position: relative;
  100. }
  101. .authorizCloseImg{
  102. width: 62rpx;
  103. height: 62rpx;
  104. }
  105. .sqLogoBox{
  106. width: 180rpx;
  107. height: 180rpx;
  108. background: #FFFFFF;
  109. border-radius: 90rpx;
  110. text-align: center;
  111. position: absolute;
  112. top: -50rpx;
  113. left: 192rpx;
  114. }
  115. .authorizName{
  116. color: #333333;
  117. line-height: 42rpx;
  118. font-size: 30rpx;
  119. text-align: center;
  120. padding-top: 58rpx;
  121. }
  122. .authorizMs{
  123. color: #999999;
  124. line-height: 36rpx;
  125. font-size: 26rpx;
  126. width: 452rpx;
  127. padding-top: 24rpx;
  128. text-align: center;
  129. margin-left: 56rpx;
  130. }
  131. .authorizContbutton{
  132. width: 422rpx;
  133. height: 88rpx;
  134. background: #D53533;
  135. border-radius: 44rpx;
  136. line-height: 88rpx;
  137. text-align: center;
  138. font-size:30rpx;
  139. color: #FFFFFF;
  140. margin-top: 62rpx;
  141. margin-left:71rpx;
  142. }
  143. </style>