| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- <template>
- <view class="loginPage" >
-
- <image src="https:\/\/t38.9026.com\/uploads\/golf\/images\/2022-05-31\/20220531915411.png" mode="" class="image"></image>
- <view class="" style="text-align: center;margin: 100rpx;">日月峡康养旅行</view>
- <view class="logo">
- <image src="../static/login/LOGO@2x.png" mode="widthFix"></image>
- </view>
- <!-- 选择登陆方式 -->
- <view class="btn">
- <button class="phoneNumber" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" withCredentials="true">手机号一键登录</button>
- <!-- <view @click="gologin">
- 手机号一键登录
- </view> -->
- <view class="otherNumber" @click="gootherNuber">
- <view class="icon">
- <image src="../static/login/iconS@2x.png" mode="widthFix"></image>
- </view>
- <view class="" >
- 其他手机号登陆
- </view>
- </view>
- </view>
-
- <view class="aggre">
- 登录即代表您同意我们的
- <text class="underline" @click="terms">用户协议</text>和
- <text class="underline" @click="Policy">隐私政策</text>
- </view>
- </view>
- </template>
- <script>
- import WXBizDataCrypt from "@/static/js/WXBizDataCrypt.js"
- export default{
- data(){
- return{
- tips:"获取验证码",
- value: '',
- // 输入的验证码
- code:'',
- // 获取微信登录的code
- wxCode:'',
- // 解密密钥
- session_key:'',
- // 手机号
- phone:'',
- encryptedData:"",
- iv:'',
- openid:"",
- unionid:'',
- nickName:''
-
- }
- },
- onLoad() {
- this.initLogin()
- },
- methods:{
- // 获取微信登录的code以及发送请求
- initLogin() {
- uni.login({
- success: (res) => {
- // console.log(res)
- if (res.code) { //微信登录成功 已拿到code
- this.wxCode = res.code //保存获取到的code
- console.log(res.code,"WXcode");
- } else {
- console.log('登录失败!' + res.errMsg)
- }
- }
- })
- },
- getPhoneNumber (e) {
- if(e.detail.errMsg=="getPhoneNumber:ok"){
- /*uni.login({
- success: (res) => {
- // console.log(res)
- if (res.code) { //微信登录成功 已拿到code
- this.wxCode = res.code //保存获取到的code */
-
- uni.$u.http.post('/api/login/phone',{
- code:this.wxCode,
- iv:e.detail.iv,
- enc:e.detail.encryptedData
- }).then(res=>{
- console.log(res)
- uni.setStorageSync('token', res.token)
- uni.setStorageSync('phone', res.user.phone)
- this.$store.commit('setToken', res.token)
- this.$store.commit('loginState', res.token)
- this.$store.commit('getUserInfo',{
- //code:this.wxCode,
- phone:res.user.phone,
- })
-
- uni.showToast({
- title: '登录成功',
- icon:"success",
- duration: 1000
- })
- uni.reLaunch({
- url:"/pages/index/index"
- })
- }).catch(err=>{
- console.log(err)
- uni.showToast({
- icon:"error",
- title:err.message,
- })
- })
-
-
-
- }else{
- console.log('用户点击了拒绝') ;
- }
- },
- // getUserInfo(e){
- // uni.getUserInfo({
- // success:(res)=>{
- // console.log(res)
- // // var userInfo = res.userInfo;
- // }
- // })
- // },
-
- // 其他电话号码登录
- gootherNuber(){
- uni.navigateTo({
- url:"otherNumlogin"
- })
- },
- // 政策
- Policy(){
- uni.navigateTo({
- url:"/pages/userCenter/Policy"
- })
- },
- // 政策
- terms(){
- uni.navigateTo({
- url:"/pages/userCenter/Terms"
- })
- },
- }
- }
- </script>
- <style lang="less">
- page{
- color: #ffffff;
- }
- .image{
- position: fixed;
- width: 100%;
- height: 100%;
- top: 0;
- left: 0;
- z-index: -1;
- }
-
- .logo{
- text-align: center;
- margin-top: 197rpx;
- image{
- width: 114rpx;
- }
- }
- .btn{
- text-align: center;
- margin-top: 117rpx;
- .phoneNumber{
- margin: 0 auto;
- width: 654rpx;
- height: 92rpx;
- line-height: 92rpx;
- background: #1E9F6A;
- color: #FFFFFF;
- border-radius: 8rpx 32rpx 8rpx 32rpx;
- }
- .otherNumber{
- display: flex;
- justify-content: center;
- align-items: center;
- margin: 32rpx auto 0;
- width: 654rpx;
- height: 92rpx;
- line-height: 92rpx;
- background: rgba(255, 255, 255, 0.16);
- border-radius: 8rpx 32rpx 8rpx 32rpx;
- border: 1px solid #E2E2E3;
- .icon{
- image{
- width: 38rpx;
- margin: 40rpx 30rpx 0 0;
- }
- }
- }
- }
- .aggre{
- margin-top: 400rpx;
- text-align: center;
- font-family: PingFang-SC-Medium, PingFang-SC;
- font-weight: 500;
- color: #E2E2E2;
- font-size: 26rpx;
- .underline{
- text-decoration:underline;
- padding: 0 6rpx;
- }
- }
- </style>
|