login.vue 6.2 KB

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