login.vue 6.3 KB

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