use-login.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <view class="use-login wh-full">
  3. <!-- 弹出框 -->
  4. <view v-if="is_show" class="l-mask"></view>
  5. <view v-if="is_show" class="box-container">
  6. <view class="title fs-lg"><text>{{title}}</text></view>
  7. <view class="dflex dflex-flow-c margin-top">
  8. <image class="image-sm" mode="aspectFill" src="../../static/images/user/default.png"></image>
  9. <text class="">微信授权</text>
  10. </view>
  11. <view class="btn-contaer margin-top-lg">
  12. <button class="no-border" @click="cancel">取消</button>
  13. <button class="no-border" :open-type="type" :lang="lang" @getuserinfo="getUserInfo" @getphonenumber="getPhoneNumber" :withCredentials="withCredentials">确定</button>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. props: {
  21. // getUserInfo getPhoneNumber
  22. type: {
  23. type: String,
  24. default: 'getUserInfo'
  25. },
  26. lang: {
  27. type: String,
  28. default: 'zh_CN'
  29. },
  30. withCredentials: {
  31. type: Boolean,
  32. default: true
  33. },
  34. title: {
  35. type: String,
  36. default: '获取授权信息'
  37. },
  38. show: {
  39. type: [String, Number, Boolean],
  40. default: 0
  41. }
  42. },
  43. computed: {
  44. __show: {
  45. get(){
  46. console.log('is_show', this.show);
  47. this.is_show = this.show;
  48. return this.show;
  49. },
  50. set(){
  51. }
  52. }
  53. },
  54. data() {
  55. return {
  56. is_show: this.show
  57. };
  58. },
  59. methods: {
  60. cancel() {
  61. this.is_show = false;
  62. this.$emit('cancel', {
  63. type: 'cancel'
  64. });
  65. },
  66. getUserInfo(wx_userinfo){
  67. this.is_show = false;
  68. let _this = this;
  69. if (!wx_userinfo.detail.iv) {
  70. this.$emit('auth', {
  71. type: 'userinfo',
  72. result: 'cancel',
  73. });
  74. return false;
  75. }
  76. console.log('-------用户授权,并获取用户基本信息和加密数据------');
  77. },
  78. getPhoneNumber(wx_phonenumber){
  79. this.is_show = false;
  80. uni.showLoading({
  81. title: '加载中'
  82. });
  83. if (!wx_phonenumber.detail.iv) {
  84. this.$emit('auth', {
  85. type: 'phonenumber',
  86. result: 'cancel',
  87. });
  88. return false;
  89. }
  90. console.log('-------用户授权,并获取用户基本信息和加密数据------');
  91. console.log(wx_phonenumber.detail);
  92. }
  93. }
  94. };
  95. </script>
  96. <style lang="scss">
  97. .use-login{
  98. overflow: hidden;
  99. }
  100. .use-login .l-mask {
  101. position: absolute;
  102. top: 0;
  103. left: 0;
  104. bottom: 0;
  105. right: 0;
  106. background: rgba(51, 51, 51, 0.5);
  107. z-index: 999;
  108. }
  109. .use-login .box-container {
  110. position: absolute;
  111. width: 80vw;
  112. background: #fff;
  113. left: 50%;
  114. transform: translate(-50%, -50%);
  115. top: 50%;
  116. z-index: 999;
  117. border-radius: 20rpx;
  118. text-align: center;
  119. padding: 30rpx;
  120. .title {
  121. margin-top: 30rpx;
  122. font-size: 34rpx;
  123. font-weight: 600;
  124. }
  125. .btn-contaer {
  126. display: flex;
  127. }
  128. button {
  129. background: #eee;
  130. color: #333;
  131. width: 50%;
  132. border-radius: 50rpx;
  133. border: 1px solid #eee;
  134. font-size: 30rpx;
  135. padding: 16rpx 0;
  136. line-height: inherit;
  137. &:last-child {
  138. margin-left: 10px;
  139. background: $base-color;
  140. border: 1px solid $base-color;
  141. color: #fff;
  142. }
  143. }
  144. }
  145. </style>