nologin.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view>
  3. <u-modal :show="showAuthorizeUser" title="提示" confirmColor="#181a82" @confirm="confirm" @cancel='cancel'
  4. confirmText="立即登录" cancelText="暂不登录" showConfirmButton="true" showCancelButton="true">
  5. <view style="text-align: center;padding: 20rpx;">您还没有登录哦</view>
  6. </u-modal>
  7. <wxinfo ref="wxinfo" v-on:loginback="loginback"></wxinfo>
  8. </view>
  9. </template>
  10. <script>
  11. import loginApi from '@/api/login/login.js';
  12. import mineApi from '@/api/mine/index.js';
  13. import wxinfo from '@/components/wxinfo/wxinfo.vue';
  14. export default {
  15. name: "nologin",
  16. props: [],
  17. components: {
  18. wxinfo
  19. },
  20. data() {
  21. return {
  22. user: {
  23. headimgurl: 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0',
  24. nickname: '',
  25. },
  26. hasUserInfo: false,
  27. logo: '',
  28. // 用户基本信息
  29. userInfo: null,
  30. // 微信,支付宝用户code
  31. code: '',
  32. // 是否弹出登录注册授权弹窗
  33. showAuthorizeUser: false,
  34. showAuthorizePhone: false,
  35. };
  36. },
  37. methods: {
  38. loginback() {
  39. //登录回调
  40. this.$emit('loginback');
  41. },
  42. open() {
  43. let that = this;
  44. uni.login({
  45. provider: 'weixin',
  46. success: loginRes => {
  47. that.code = loginRes.code;
  48. }
  49. });
  50. that.showAuthorizeUser = true
  51. },
  52. cancel() {
  53. this.showAuthorizeUser = false
  54. },
  55. close() {
  56. this.showAuthorizeUser = false
  57. },
  58. getInitInfo() {
  59. let that = this;
  60. that.$emit('getInitInfo');
  61. },
  62. confirm() {
  63. let that = this;
  64. uni.showLoading({
  65. title: '登录中...'
  66. });
  67. // 获取用户基本信息
  68. uni.getUserProfile({
  69. desc: '登陆',
  70. success: function(infoRes) {
  71. let userInfo = JSON.parse(infoRes.rawData);
  72. let logdata = {
  73. type: 1,
  74. code: that.code,
  75. pid: uni.getStorageSync('sys_pid'),
  76. ...userInfo
  77. };
  78. loginApi
  79. .wxlogin_v2(logdata)
  80. .then(res => {
  81. if (res.status == 200) {
  82. that.close();
  83. that.$store.commit('login', res.data.userinfo);
  84. that.$emit('loginback');
  85. if (!res.data.userinfo.nickname || !res.data.userinfo.headimgurl) {
  86. that.$refs.wxinfo.open();
  87. } else{
  88. that.$api.msg('登录成功');
  89. }
  90. } else {
  91. uni.showToast({
  92. title: res.msg,
  93. icon: 'none'
  94. })
  95. }
  96. });
  97. },
  98. fail: err => {
  99. uni.showToast({
  100. title: '授权失败',
  101. icon: 'none'
  102. });
  103. return false;
  104. }
  105. });
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss" scoped>
  111. .auth-btncard {
  112. .btn-unok {
  113. width: 50%;
  114. float: left;
  115. }
  116. .btn-ok {
  117. width: 50%;
  118. float: left;
  119. margin: 0;
  120. padding: 0;
  121. border: 0px solid transparent; //自定义边框
  122. outline: none; //消除默认点击蓝色边框效果
  123. u-button {
  124. margin: 0;
  125. padding: 0;
  126. border: 0px solid transparent; //自定义边框
  127. outline: none; //消除默认点击蓝色边框效果
  128. }
  129. }
  130. }
  131. .auth-card {
  132. text-align: center;
  133. .avatar-img {
  134. width: 150rpx;
  135. height: 150rpx;
  136. overflow: hidden;
  137. border-radius: 100%;
  138. margin-top: 30rpx;
  139. }
  140. .title {
  141. font-size: 20rpx;
  142. }
  143. .content {
  144. margin-top: 10rpx;
  145. }
  146. }
  147. .mine_box {
  148. height: 360upx;
  149. color: #fff;
  150. // background-color: $primarycolor;
  151. .avatar-img {
  152. width: 150rpx;
  153. height: 150rpx;
  154. overflow: hidden;
  155. border-radius: 100%;
  156. /*margin-right: 40rpx;*/
  157. }
  158. .avatar_box {
  159. position: relative;
  160. width: 150rpx;
  161. height: 150rpx;
  162. overflow: hidden;
  163. border-radius: 100%;
  164. margin-right: 40rpx;
  165. .avatar-img {
  166. width: 100%;
  167. height: 100%;
  168. /* #ifdef MP-WEIXIN*/
  169. width: 150rpx;
  170. height: 150rpx;
  171. /* #endif */
  172. }
  173. .get_user_data {
  174. z-index: 11;
  175. opacity: 0;
  176. width: 100%;
  177. height: 100%;
  178. position: absolute;
  179. left: 0;
  180. top: 0;
  181. }
  182. }
  183. .nick-name-box {
  184. height: 100%;
  185. }
  186. .user-nickName {
  187. font-size: 40rpx;
  188. color: #fff;
  189. margin-bottom: 20rpx;
  190. }
  191. .shiming_box {
  192. border-radius: 10upx;
  193. font-size: 28upx;
  194. padding: 10upx 20upx;
  195. background-color: rgba(15, 77, 139, 0.5);
  196. .icon-shezhi {
  197. margin-right: 10rpx;
  198. margin-top: 5rpx;
  199. }
  200. }
  201. }
  202. .authorize-box {
  203. background-color: transparent;
  204. text-align: center;
  205. .authorize-avatar {
  206. width: 200rpx;
  207. height: 200rpx;
  208. }
  209. .authorize-btn {
  210. position: relative;
  211. top: 40rpx;
  212. }
  213. }
  214. /deep/.u-mode-center-box {
  215. background-color: transparent !important;
  216. }
  217. </style>
  218. <style>
  219. .avatar-wrapper {
  220. width: 150rpx;
  221. height: 100rpx;
  222. color: #333 !important;
  223. text-align: center !important;
  224. border: none !important;
  225. border-radius: 0 !important;
  226. background-color: transparent !important;
  227. }
  228. .avatar-wrapper::after {
  229. border: none !important;
  230. }
  231. .avatar {
  232. margin-right: 50rpx;
  233. width: 100rpx;
  234. height: 100rpx;
  235. overflow: hidden;
  236. border-radius: 100%;
  237. }
  238. </style>