|
@@ -1,15 +1,15 @@
|
|
<template>
|
|
<template>
|
|
<div id="index_login_container" class="animation-slide-right">
|
|
<div id="index_login_container" class="animation-slide-right">
|
|
- <view class="solid-bottom text-xl padding text-center">
|
|
|
|
|
|
+ <view class="text-xl padding text-center">
|
|
<img class="back regist_back_btn" @click="goIndex" src="https://img.shuimuai.com/fanhui.png"/>
|
|
<img class="back regist_back_btn" @click="goIndex" src="https://img.shuimuai.com/fanhui.png"/>
|
|
- <text class=" text-bold title_color">{{ title }}</text>
|
|
|
|
|
|
+ <text class=" text-bold title_color">会员{{ title }}</text>
|
|
</view>
|
|
</view>
|
|
<view class="text-df text-center slogen">请输入手机号码,以便更好的享受我们的服务</view>
|
|
<view class="text-df text-center slogen">请输入手机号码,以便更好的享受我们的服务</view>
|
|
<div class="register_form_container text-center">
|
|
<div class="register_form_container text-center">
|
|
<form action="">
|
|
<form action="">
|
|
<view class="cu-form-group">
|
|
<view class="cu-form-group">
|
|
<view class="title">手机号码</view>
|
|
<view class="title">手机号码</view>
|
|
- <input placeholder="请输入手机号" v-model="phone" maxlength="11"/>
|
|
|
|
|
|
+ <input placeholder="请输入手机号" v-model="phone" maxlength="11" @input="check_auth"/>
|
|
<view class="cu-capsule radius">
|
|
<view class="cu-capsule radius">
|
|
<view class='cu-tag bg-blue '>
|
|
<view class='cu-tag bg-blue '>
|
|
+86
|
|
+86
|
|
@@ -21,10 +21,11 @@
|
|
</view>
|
|
</view>
|
|
<view class="cu-form-group">
|
|
<view class="cu-form-group">
|
|
<view class="title">验证码</view>
|
|
<view class="title">验证码</view>
|
|
- <input placeholder="输入验证码" name="input" v-model="verfiy_code" maxlength="6"/>
|
|
|
|
- <button class='cu-btn bg-primary text-white shadow' :disabled="time_out > 0" @click="get_verify_code">
|
|
|
|
- <template v-if="time_out>0">{{ time_out }}后</template>
|
|
|
|
- 获取验证码
|
|
|
|
|
|
+ <input placeholder="输入验证码" name="input" v-model="verfiy_code" maxlength="6" @input="check_auth"/>
|
|
|
|
+ <button class='cu-btn bg-primary text-white shadow' :disabled="time_show" @click="get_verify_code">
|
|
|
|
+ <van-count-down v-if="time_show" :auto-start="time_start" class="control-count-down" @finish="time_finished"
|
|
|
|
+ :time="time_count * 1000" format="ss"/>
|
|
|
|
+ <text>获取验证码</text>
|
|
</button>
|
|
</button>
|
|
</view>
|
|
</view>
|
|
</form>
|
|
</form>
|
|
@@ -33,11 +34,14 @@
|
|
<div class="text-center padding">
|
|
<div class="text-center padding">
|
|
<button class="cu-btn lg cu-btn-primary text-white text-center" open-type="getUserInfo"
|
|
<button class="cu-btn lg cu-btn-primary text-white text-center" open-type="getUserInfo"
|
|
@getuserinfo="get_Userinfo"
|
|
@getuserinfo="get_Userinfo"
|
|
- v-if="auth_login">
|
|
|
|
- 微信授权登录
|
|
|
|
- </button>
|
|
|
|
- <button class="cu-btn lg cu-btn-primary text-white text-center" @click="wechat_login" v-else>微信授权登录
|
|
|
|
|
|
+ :disabled="btn_disabled">
|
|
|
|
+ {{ title }}
|
|
</button>
|
|
</button>
|
|
|
|
+<!-- -->
|
|
|
|
+<!-- <button class="cu-btn lg cu-btn-primary text-white text-center" @click="wechat_login"-->
|
|
|
|
+<!-- :disabled="btn_disabled"-->
|
|
|
|
+<!-- v-else>{{ title }}-->
|
|
|
|
+<!-- </button>-->
|
|
</div>
|
|
</div>
|
|
<view class="text-center text-xs">
|
|
<view class="text-center text-xs">
|
|
<text class="text-gray">如果您在我们的实体店,请在店员的指导下链接脑环</text>
|
|
<text class="text-gray">如果您在我们的实体店,请在店员的指导下链接脑环</text>
|
|
@@ -68,6 +72,10 @@ export default {
|
|
avatarUrl: "",
|
|
avatarUrl: "",
|
|
gender: ""
|
|
gender: ""
|
|
},
|
|
},
|
|
|
|
+ btn_disabled: true,
|
|
|
|
+ time_show: false,
|
|
|
|
+ time_start: false,
|
|
|
|
+ time_count: 60
|
|
}
|
|
}
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
@@ -76,8 +84,18 @@ export default {
|
|
wx.hideKeyboard()
|
|
wx.hideKeyboard()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ check_auth() {
|
|
|
|
+ let $reg = /(13\d|14[579]|15[^4\D]|17[^49\D]|18\d)\d{8}/
|
|
|
|
+ let $verify_reg = /\d{6}/
|
|
|
|
+ if ($reg.test($this.phone) && $verify_reg.test($this.verfiy_code)) {
|
|
|
|
+ $this.btn_disabled = false
|
|
|
|
+ } else {
|
|
|
|
+ $this.btn_disabled = true
|
|
|
|
+ }
|
|
|
|
+ },
|
|
//跳转到首页
|
|
//跳转到首页
|
|
goIndex() {
|
|
goIndex() {
|
|
this.$emit('changeStatus', 'login')
|
|
this.$emit('changeStatus', 'login')
|
|
@@ -101,16 +119,6 @@ export default {
|
|
//微信授权登录
|
|
//微信授权登录
|
|
wechat_login($userinfo) {
|
|
wechat_login($userinfo) {
|
|
console.log('登录')
|
|
console.log('登录')
|
|
- let $reg = /(13\d|14[579]|15[^4\D]|17[^49\D]|18\d)\d{8}/
|
|
|
|
- if ($reg.test($this.phone) == false) {
|
|
|
|
- Toast.fail('请输入正确手机号')
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- $reg = /\d{6}/
|
|
|
|
- if ($reg.test($this.verfiy_code) == false) {
|
|
|
|
- Toast.fail('请输入正确的验证码')
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
Toast.loading({
|
|
Toast.loading({
|
|
duration: 0, // 持续展示 toast
|
|
duration: 0, // 持续展示 toast
|
|
forbidClick: true,
|
|
forbidClick: true,
|
|
@@ -128,36 +136,35 @@ export default {
|
|
$params['portrait'] = $this._userinfo.avatarUrl
|
|
$params['portrait'] = $this._userinfo.avatarUrl
|
|
$params['sex'] = $this._userinfo.gender
|
|
$params['sex'] = $this._userinfo.gender
|
|
}
|
|
}
|
|
- //用户注册
|
|
|
|
- userRegister($params).then((res) => {
|
|
|
|
- let $data = res.data
|
|
|
|
- if (!$data['code']) {
|
|
|
|
|
|
+
|
|
|
|
+ if ($this.title == "注册") {
|
|
|
|
+ userRegister($params).then((res) => {
|
|
|
|
+ let $data = res.data
|
|
|
|
+ if (!$data['code']) {
|
|
|
|
+ Toast.clear()
|
|
|
|
+ $this.login_success($data)
|
|
|
|
+ } else {
|
|
|
|
+ Toast.fail($data['errmsg'])
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ } else if ($this.title == "登录") {
|
|
|
|
+ userLogin($params).then((res) => {
|
|
|
|
+ let $data = res.data
|
|
Toast.clear()
|
|
Toast.clear()
|
|
- $this.login_success($data)
|
|
|
|
- } else if ($data['code'] == 201) {
|
|
|
|
- // 判断用户已经注册了 就进行登录的操作
|
|
|
|
- $params = {
|
|
|
|
- phone: $this.phone,
|
|
|
|
- code: $this.verfiy_code,
|
|
|
|
|
|
+ if (!$data['code']) {
|
|
|
|
+ $this.login_success($data)
|
|
|
|
+ } else {
|
|
|
|
+ Toast.fail($data['errmsg'])
|
|
}
|
|
}
|
|
- userLogin($params).then((res) => {
|
|
|
|
- let $data = res.data
|
|
|
|
- Toast.clear()
|
|
|
|
- if (!$data['code']) {
|
|
|
|
- $this.login_success($data)
|
|
|
|
- } else {
|
|
|
|
- Toast.fail($data['errmsg'])
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- } else if ($data['code'] == 204) {
|
|
|
|
- Toast.fail($data['errmsg'])
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
},
|
|
},
|
|
//登录成功
|
|
//登录成功
|
|
login_success($data) {
|
|
login_success($data) {
|
|
Toast.success($data['errmsg'])
|
|
Toast.success($data['errmsg'])
|
|
$this.$store.commit('set_token', $data['data'])
|
|
$this.$store.commit('set_token', $data['data'])
|
|
|
|
+ $this.$store.commit('set_login')
|
|
$this.$emit('change_login_status', true)
|
|
$this.$emit('change_login_status', true)
|
|
$this.$store.commit('set_invite_code', $this.invite)
|
|
$this.$store.commit('set_invite_code', $this.invite)
|
|
//获取用户信息
|
|
//获取用户信息
|
|
@@ -168,22 +175,27 @@ export default {
|
|
},
|
|
},
|
|
//打开倒计时
|
|
//打开倒计时
|
|
open_time_down() {
|
|
open_time_down() {
|
|
- $this.time_out = 60
|
|
|
|
- setInterval(() => {
|
|
|
|
- if ($this.time_out > 0) {
|
|
|
|
- $this.time_out = $this.time_out - 1
|
|
|
|
- }
|
|
|
|
- }, 1000)
|
|
|
|
|
|
+ $this.time_count = 60
|
|
|
|
+ $this.time_start = $this.time_show = true
|
|
|
|
+ },
|
|
|
|
+ //倒计时结束
|
|
|
|
+ time_finished() {
|
|
|
|
+ $this.time_start = $this.time_show = false
|
|
},
|
|
},
|
|
// 获取用户信息
|
|
// 获取用户信息
|
|
get_Userinfo(e) {
|
|
get_Userinfo(e) {
|
|
- $this._userinfo = e.mp.detail.userInfo
|
|
|
|
- $this.wechat_login()
|
|
|
|
|
|
+ console.log(e)
|
|
|
|
+ if (e.mp.detail.errMsg == "getUserInfo:fail auth deny") {
|
|
|
|
+ Toast.fail('请进行授权登录')
|
|
|
|
+ } else {
|
|
|
|
+ $this._userinfo = e.mp.detail.userInfo
|
|
|
|
+ $this.wechat_login()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
- // $this.invite = $this.$store.getters.get_invite_code ? $this.$store.getters.get_invite_code : wx.getStorageSync('code')
|
|
|
|
- $this.invite = 3
|
|
|
|
|
|
+ $this.invite = $this.$store.getters.get_invite_code ? $this.$store.getters.get_invite_code : wx.getStorageSync('code')
|
|
|
|
+ // $this.invite = 3
|
|
console.log('regist-invite', $this.invite)
|
|
console.log('regist-invite', $this.invite)
|
|
mpvue.login({
|
|
mpvue.login({
|
|
success($res) {
|
|
success($res) {
|