|
@@ -2,14 +2,14 @@
|
|
|
<div id="index_login_container" class="animation-slide-right">
|
|
|
<view class="solid-bottom text-xl padding text-center">
|
|
|
<img class="back regist_back_btn" @click="goIndex" src="https://img.shuimuai.com/fanhui.png"/>
|
|
|
- <text class=" text-bold title_color">注册会员</text>
|
|
|
+ <text class=" text-bold title_color">{{ title }}</text>
|
|
|
</view>
|
|
|
<view class="text-df text-center slogen">请输入手机号码,以便更好的享受我们的服务</view>
|
|
|
<div class="register_form_container text-center">
|
|
|
<form action="">
|
|
|
<view class="cu-form-group">
|
|
|
<view class="title">手机号码</view>
|
|
|
- <input placeholder="请输入手机号" v-model="phone" maxlength="11" />
|
|
|
+ <input placeholder="请输入手机号" v-model="phone" maxlength="11"/>
|
|
|
<view class="cu-capsule radius">
|
|
|
<view class='cu-tag bg-blue '>
|
|
|
+86
|
|
@@ -31,7 +31,8 @@
|
|
|
</div>
|
|
|
|
|
|
<div class="text-center padding">
|
|
|
- <button class="cu-btn lg cu-btn-primary text-white text-center" open-type="getUserInfo" @getuserinfo="getUserinfo"
|
|
|
+ <button class="cu-btn lg cu-btn-primary text-white text-center" open-type="getUserInfo"
|
|
|
+ @getuserinfo="get_Userinfo"
|
|
|
v-if="auth_login">
|
|
|
微信授权登录
|
|
|
</button>
|
|
@@ -53,13 +54,20 @@ var $this
|
|
|
|
|
|
export default {
|
|
|
name: "regist",
|
|
|
+ props: ['title'],
|
|
|
data() {
|
|
|
return {
|
|
|
phone: "",
|
|
|
verfiy_code: "",
|
|
|
time_out: 0,
|
|
|
- invite: 2,
|
|
|
- auth_login: false
|
|
|
+ invite: 0,
|
|
|
+ js_code: "",
|
|
|
+ auth_login: false,
|
|
|
+ _userinfo: {
|
|
|
+ nickName: "",
|
|
|
+ avatarUrl: "",
|
|
|
+ gender: ""
|
|
|
+ },
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
@@ -92,7 +100,13 @@ export default {
|
|
|
},
|
|
|
//微信授权登录
|
|
|
wechat_login($userinfo) {
|
|
|
- let $reg = /\d{6}/
|
|
|
+ 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;
|
|
@@ -102,42 +116,41 @@ export default {
|
|
|
forbidClick: true,
|
|
|
message: '操作中...',
|
|
|
});
|
|
|
- mpvue.login({
|
|
|
- success($res) {
|
|
|
- let $params = {
|
|
|
+
|
|
|
+ let $params = {
|
|
|
+ phone: $this.phone,
|
|
|
+ code: $this.verfiy_code,
|
|
|
+ js_code: $this.js_code,
|
|
|
+ invite: $this.invite,
|
|
|
+ }
|
|
|
+ if ($this._userinfo) {
|
|
|
+ $params['user_name'] = $this._userinfo.nickName
|
|
|
+ $params['portrait'] = $this._userinfo.avatarUrl
|
|
|
+ $params['sex'] = $this._userinfo.gender
|
|
|
+ }
|
|
|
+ //用户注册
|
|
|
+ userRegister($params).then((res) => {
|
|
|
+ let $data = res.data
|
|
|
+ if (!$data['code']) {
|
|
|
+ Toast.clear()
|
|
|
+ $this.login_success($data)
|
|
|
+ } else if ($data['code'] == 201) {
|
|
|
+ // 判断用户已经注册了 就进行登录的操作
|
|
|
+ $params = {
|
|
|
phone: $this.phone,
|
|
|
code: $this.verfiy_code,
|
|
|
- js_code: $res.code,
|
|
|
- invite: $this.invite,
|
|
|
- user_name: $userinfo['nickName'],
|
|
|
- portrait: $userinfo['avatarUrl'],
|
|
|
- sex: $userinfo['gender']
|
|
|
}
|
|
|
- //用户注册
|
|
|
- userRegister($params).then((res) => {
|
|
|
+ userLogin($params).then((res) => {
|
|
|
let $data = res.data
|
|
|
+ Toast.clear()
|
|
|
if (!$data['code']) {
|
|
|
- Toast.clear()
|
|
|
$this.login_success($data)
|
|
|
- } else if ($data['code'] == 201) {
|
|
|
- // 判断用户已经注册了 就进行登录的操作
|
|
|
- $params = {
|
|
|
- phone: $this.phone,
|
|
|
- code: $this.verfiy_code,
|
|
|
- }
|
|
|
- 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) {
|
|
|
+ } else {
|
|
|
Toast.fail($data['errmsg'])
|
|
|
}
|
|
|
})
|
|
|
+ } else if ($data['code'] == 204) {
|
|
|
+ Toast.fail($data['errmsg'])
|
|
|
}
|
|
|
})
|
|
|
},
|
|
@@ -150,7 +163,7 @@ export default {
|
|
|
//获取用户信息
|
|
|
userDetail().then((res) => {
|
|
|
let $data = res.data
|
|
|
- console.log($data)
|
|
|
+ $this.$store.commit('set_userinfo', $data.data);
|
|
|
})
|
|
|
},
|
|
|
//打开倒计时
|
|
@@ -163,26 +176,22 @@ export default {
|
|
|
}, 1000)
|
|
|
},
|
|
|
// 获取用户信息
|
|
|
- getUserinfo() {
|
|
|
- let $reg = /\d{6}/
|
|
|
- if ($reg.test($this.verfiy_code) == false) {
|
|
|
- Toast.fail('请输入正确的验证码')
|
|
|
- return false;
|
|
|
- }
|
|
|
- wx.authorize({
|
|
|
- scope: 'scope.userInfo',
|
|
|
- success(res) {
|
|
|
- wx.getUserInfo({
|
|
|
- success($res) {
|
|
|
- let $userinfo = $res.userInfo
|
|
|
- console.log($userinfo)
|
|
|
- $this.wechat_login($userinfo)
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ get_Userinfo(e) {
|
|
|
+ $this._userinfo = e.mp.detail.userInfo
|
|
|
+ $this.wechat_login()
|
|
|
}
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ // $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)
|
|
|
+ mpvue.login({
|
|
|
+ success($res) {
|
|
|
+ $this.js_code = $res.code
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
created() {
|
|
|
$this = this
|
|
|
wx.getSetting({
|
|
@@ -191,34 +200,13 @@ export default {
|
|
|
if ($authSetting['scope.userInfo']) {
|
|
|
//改为普通登录
|
|
|
$this.auth_login = false
|
|
|
+ } else {
|
|
|
+ $this.auth_login = true
|
|
|
}
|
|
|
+ console.log('auth', $this.auth_login)
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- onLoad(options) {
|
|
|
- // 原有的code
|
|
|
- let $_code = wx.getStorageSync('code')
|
|
|
-
|
|
|
- if (options.q) {
|
|
|
- let url = decodeURIComponent(options.q)
|
|
|
- let $code = url.match(/\?code=(.*)/)[1];
|
|
|
-
|
|
|
- $this.invite = $code + ''
|
|
|
- console.log('1---' + $_code, '2---' + $code)
|
|
|
- //判断新的code 和 旧的code 是否一致 不一致则重新登录
|
|
|
- if ($_code && $_code != $code) {
|
|
|
- Toast.fail('该用户已绑定邀请码')
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- // else {
|
|
|
- // Toast.fail({
|
|
|
- // duration: 0,
|
|
|
- // forbidClick: true,
|
|
|
- // message: '请通过邀请码进入小程序',
|
|
|
- // })
|
|
|
- // }
|
|
|
- }
|
|
|
}
|
|
|
</script>
|
|
|
|