login.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <view>
  3. <view class="login-view">
  4. <image :src="logo" class="logo" mode="widthFix"></image>
  5. <view class="t-login">
  6. <u-button type="primary" class="custom-style" shape="circle" open-type="getPhoneNumber"
  7. @getphonenumber="getPhoneNumber" color="linear-gradient(0deg, #FD5003 0%, #FBA680 100%)"
  8. :ripple="true">
  9. 授权手机号登录
  10. </u-button>
  11. </view>
  12. </view>
  13. <view style="position:absolute; bottom:20rpx;font-size: 20rpx;width: 100%;text-align: center;z-index: -1;">
  14. <image src="/static/images/login/bottom.png" style="
  15. display: block;
  16. width: 60%;
  17. height: auto;
  18. margin: 0 auto 10rpx;" mode="widthFix"></image>
  19. 青岛途宝软件开发有限公司提供技术支持
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import md5 from '@/utils/md5.js'
  25. export default {
  26. data() {
  27. return {
  28. phone: '', //手机号码
  29. pwd: '', //密码
  30. // phone: '13021669111', //手机号码18669858069
  31. // pwd: '123456', //密码
  32. checked: false,
  33. lifeData: {},
  34. logo: "/static/images/logo/logo.png"
  35. }
  36. },
  37. onShow() {},
  38. methods: {
  39. change(e) {
  40. this.checked = !this.checked
  41. },
  42. //当前登录按钮操作
  43. getPhoneNumber(e) {
  44. let this_ = this
  45. if (e.detail.errMsg == 'getPhoneNumber:ok') {
  46. wx.login({
  47. success(res) {
  48. if (res.code) {
  49. wx.getUserInfo({
  50. success: function(rest) {
  51. this_.$u.api.tokenTwo({
  52. telCode: e.detail.code,
  53. loginCode: res.code,
  54. iv: rest.iv,
  55. encryptedData: rest.encryptedData,
  56. applets_id: uni.getAccountInfoSync().miniProgram.appId
  57. }).then(rest => {
  58. uni.showLoading({
  59. title: '登录中',
  60. mask: true
  61. });
  62. this_.$u.api.empowerToken({
  63. username: rest.data.phoneNumber,
  64. union_id: rest.data.unionid,
  65. open_id: rest.data.openid,
  66. applets_id: uni.getAccountInfoSync().miniProgram.appId,
  67. password: md5('123456')
  68. }).then(data => {
  69. uni.hideLoading();
  70. uni.showToast({
  71. icon: 'none',
  72. title: '登录成功',
  73. position: "bottom",
  74. mask: true
  75. })
  76. setTimeout(function() {
  77. this_.$u.func.login(data)
  78. }, 1000);
  79. }).catch(err=>{
  80. uni.hideLoading();
  81. uni.showToast({
  82. icon: 'none',
  83. title: err.error_description,
  84. position: "bottom",
  85. mask: true
  86. })
  87. })
  88. })
  89. },
  90. fail: res => {
  91. uni.showToast({
  92. icon: 'none',
  93. title: '已拒绝授权,请重新授权',
  94. position: "bottom"
  95. })
  96. }
  97. })
  98. } else {
  99. uni.showToast({
  100. icon: 'none',
  101. title: res.errMsg,
  102. position: "bottom"
  103. })
  104. }
  105. }
  106. })
  107. } else if (e.detail.errMsg == 'getPhoneNumber:fail no permission') {
  108. uni.showToast({
  109. icon: 'none',
  110. title: '微信认证过期',
  111. position: "bottom"
  112. })
  113. } else {
  114. uni.showToast({
  115. icon: 'none',
  116. title: '已拒绝授权',
  117. position: "bottom"
  118. })
  119. }
  120. },
  121. }
  122. };
  123. </script>
  124. <style lang="scss" scoped>
  125. .custom-style {
  126. color: #3ab2f7;
  127. margin-top: 140rpx;
  128. box-shadow: 2px 5px 10px 1px rgba(43, 117, 250, 0.3);
  129. }
  130. .txt {
  131. font-size: 32rpx;
  132. font-weight: bold;
  133. color: #333333;
  134. }
  135. .img-a {
  136. width: 100%;
  137. height: 400rpx;
  138. }
  139. .logo {
  140. display: block;
  141. width: 281rpx;
  142. height: auto;
  143. margin: 35% auto;
  144. }
  145. .reg {
  146. font-size: 28rpx;
  147. color: #fff;
  148. height: 90rpx;
  149. line-height: 90rpx;
  150. border-radius: 50rpx;
  151. font-weight: bold;
  152. background: #f5f6fa;
  153. color: #000000;
  154. text-align: center;
  155. margin-top: 30rpx;
  156. }
  157. .login-view {
  158. width: 100%;
  159. }
  160. .t-login {
  161. width: 600rpx;
  162. margin: 0 auto;
  163. font-size: 28rpx;
  164. margin-top: 80rpx;
  165. }
  166. .t-login button {
  167. font-size: 28rpx;
  168. background: #2796f2;
  169. color: #fff;
  170. height: 90rpx;
  171. line-height: 90rpx;
  172. border-radius: 50rpx;
  173. font-weight: bold;
  174. }
  175. .t-login input {
  176. height: 90rpx;
  177. line-height: 90rpx;
  178. margin-bottom: 50rpx;
  179. border-bottom: 1px solid #e9e9e9;
  180. font-size: 28rpx;
  181. }
  182. .t-login .t-a {
  183. position: relative;
  184. }
  185. .t-b {
  186. text-align: left;
  187. font-size: 42rpx;
  188. color: #000;
  189. padding: 130rpx 0 0 70rpx;
  190. font-weight: bold;
  191. line-height: 70rpx;
  192. }
  193. .t-login .t-c {
  194. position: absolute;
  195. right: 22rpx;
  196. top: 22rpx;
  197. background: #5677fc;
  198. color: #fff;
  199. font-size: 24rpx;
  200. border-radius: 50rpx;
  201. height: 50rpx;
  202. line-height: 50rpx;
  203. padding: 0 25rpx;
  204. }
  205. .t-login .t-d {
  206. text-align: center;
  207. color: #999;
  208. margin: 80rpx 0;
  209. }
  210. .t-login .t-e {
  211. text-align: center;
  212. width: 250rpx;
  213. margin: 80rpx auto 0;
  214. }
  215. .t-login .t-g {
  216. float: left;
  217. width: 50%;
  218. }
  219. .t-login .t-e image {
  220. width: 50rpx;
  221. height: 50rpx;
  222. }
  223. .t-login .t-f {
  224. text-align: center;
  225. margin: 150rpx 0 0 0;
  226. color: #666;
  227. }
  228. .t-login .t-f text {
  229. margin-left: 20rpx;
  230. color: #aaaaaa;
  231. font-size: 27rpx;
  232. }
  233. .t-login .uni-input-placeholder {
  234. color: #aeaeae;
  235. }
  236. .cl {
  237. zoom: 1;
  238. }
  239. .cl:after {
  240. clear: both;
  241. display: block;
  242. visibility: hidden;
  243. height: 0;
  244. content: '\20';
  245. }
  246. </style>