login.vue 6.4 KB

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