Merge commit '77c7322e'
Showing
2 changed files
with
167 additions
and
12 deletions
| ... | @@ -28,9 +28,8 @@ function pcLogin(data) { | ... | @@ -28,9 +28,8 @@ function pcLogin(data) { |
| 28 | method: 'post', | 28 | method: 'post', |
| 29 | params: data | 29 | params: data |
| 30 | }).then((res) => { | 30 | }).then((res) => { |
| 31 | uni.setStorageSync('userName', data.username) | ||
| 32 | uni.setStorageSync('token', 'Bearer ' + res.data.token) | 31 | uni.setStorageSync('token', 'Bearer ' + res.data.token) |
| 33 | }) | 32 | }).then(getInfo) |
| 34 | } | 33 | } |
| 35 | 34 | ||
| 36 | function h5Login(userName) { | 35 | function h5Login(userName) { |
| ... | @@ -42,7 +41,7 @@ function h5Login(userName) { | ... | @@ -42,7 +41,7 @@ function h5Login(userName) { |
| 42 | } | 41 | } |
| 43 | }).then((res) => { | 42 | }).then((res) => { |
| 44 | uni.setStorageSync('token', 'Bearer ' + res.data.token) | 43 | uni.setStorageSync('token', 'Bearer ' + res.data.token) |
| 45 | }) | 44 | }).then(getInfo) |
| 46 | } | 45 | } |
| 47 | 46 | ||
| 48 | function h5LoginAuto() { | 47 | function h5LoginAuto() { |
| ... | @@ -205,6 +204,60 @@ function getCodeImg() { | ... | @@ -205,6 +204,60 @@ function getCodeImg() { |
| 205 | }) | 204 | }) |
| 206 | } | 205 | } |
| 207 | 206 | ||
| 207 | // 代退图形认证的获取手机验证码 | ||
| 208 | function getSmsCode(data) { | ||
| 209 | return request({ | ||
| 210 | url: '/captchaSmsWithCaptchaImage', | ||
| 211 | method: 'post', | ||
| 212 | params: data | ||
| 213 | }) | ||
| 214 | } | ||
| 215 | |||
| 216 | function loginByPhone(phonenumber, code) { | ||
| 217 | const data = { | ||
| 218 | phonenumber, | ||
| 219 | code | ||
| 220 | } | ||
| 221 | return request({ | ||
| 222 | url: '/userLoginByPhone', | ||
| 223 | method: 'post', | ||
| 224 | params: data | ||
| 225 | }).then((res) => { | ||
| 226 | uni.setStorageSync('token', 'Bearer ' + res.data.token) | ||
| 227 | }).then(getInfo) | ||
| 228 | } | ||
| 229 | |||
| 230 | // 获取用户详细信息 | ||
| 231 | function getInfo() { | ||
| 232 | return request({ | ||
| 233 | url: '/getInfo', | ||
| 234 | method: 'get' | ||
| 235 | }).then(res => { | ||
| 236 | const app = getApp() | ||
| 237 | const user = res.data.user | ||
| 238 | uni.setStorageSync('userName', user.userName) | ||
| 239 | |||
| 240 | switch (user.dept.deptType) { | ||
| 241 | case '1': // 中跆协 | ||
| 242 | app.globalData.userType = '1' | ||
| 243 | break | ||
| 244 | case '2': // 省 | ||
| 245 | case '3': | ||
| 246 | app.globalData.userType = '2' | ||
| 247 | break | ||
| 248 | case '6': // 道馆 | ||
| 249 | app.globalData.userType = '4' | ||
| 250 | break | ||
| 251 | default: // 市、区 | ||
| 252 | app.globalData.userType = '3' | ||
| 253 | break | ||
| 254 | } | ||
| 255 | |||
| 256 | app.globalData.userInfo = user | ||
| 257 | }) | ||
| 258 | } | ||
| 259 | |||
| 260 | |||
| 208 | export { | 261 | export { |
| 209 | getNowOpenId, | 262 | getNowOpenId, |
| 210 | wxLogin, | 263 | wxLogin, |
| ... | @@ -215,6 +268,8 @@ export { | ... | @@ -215,6 +268,8 @@ export { |
| 215 | checkUserAuth, | 268 | checkUserAuth, |
| 216 | initData, | 269 | initData, |
| 217 | getCodeImg, | 270 | getCodeImg, |
| 271 | getSmsCode, | ||
| 218 | h5Login, | 272 | h5Login, |
| 219 | h5LoginAuto | 273 | h5LoginAuto, |
| 274 | loginByPhone | ||
| 220 | } | 275 | } | ... | ... |
| ... | @@ -31,17 +31,20 @@ | ... | @@ -31,17 +31,20 @@ |
| 31 | <form v-if="isActive==1"> | 31 | <form v-if="isActive==1"> |
| 32 | <view class="round-input-item"> | 32 | <view class="round-input-item"> |
| 33 | <image class="icon" src="@/static/login/tag01@2x.png"></image> | 33 | <image class="icon" src="@/static/login/tag01@2x.png"></image> |
| 34 | <input placeholder="请输入手机号" /> | 34 | <uni-easyinput placeholder="请输入手机号" v-model="form2.telNo" /> |
| 35 | </view> | 35 | </view> |
| 36 | <view class="round-input-item"> | 36 | <view class="round-input-item"> |
| 37 | <image class="icon" src="@/static/login/tag02@2x.png"></image> | 37 | <image class="icon" src="@/static/login/tag02@2x.png"></image> |
| 38 | <input placeholder="图形验证码" /> | 38 | <uni-easyinput placeholder="图形验证码" v-model="form2.captcha" /> |
| 39 | <image /> | 39 | <image :src="codeUrl" @click="getCode" /> |
| 40 | </view> | 40 | </view> |
| 41 | <view class="round-input-item"> | 41 | <view class="round-input-item"> |
| 42 | <image class="icon" src="@/static/login/tag04@2x.png"></image> | 42 | <image class="icon" src="@/static/login/tag04@2x.png"></image> |
| 43 | <input placeholder="短信验证码" /> | 43 | <uni-easyinput placeholder="短信验证码" v-model="form2.code" /> |
| 44 | <text>获取验证码</text> | 44 | <text v-if="!countDown.start" @click="getCaptchaSms">获取验证码</text> |
| 45 | <uni-countdown v-if="countDown.start" color="#014A9F" :show-day="false" :show-hour="false" | ||
| 46 | :show-min="false" @timeup="timeup" :start="countDown.start" | ||
| 47 | :second="countDown.second"></uni-countdown> | ||
| 45 | </view> | 48 | </view> |
| 46 | 49 | ||
| 47 | </form> | 50 | </form> |
| ... | @@ -68,9 +71,9 @@ | ... | @@ -68,9 +71,9 @@ |
| 68 | </view> | 71 | </view> |
| 69 | <image class="ren2" src="@/static/login/ren2.png" /> | 72 | <image class="ren2" src="@/static/login/ren2.png" /> |
| 70 | <view class="fixedagree"> | 73 | <view class="fixedagree"> |
| 71 | <image @click="changeAgree(agree)" v-if="agree" src="@/static/login/xz_dwn@2x.png"></image> | 74 | <!-- <image @click="changeAgree(agree)" v-if="agree" src="@/static/login/xz_dwn@2x.png"></image> |
| 72 | <image v-else src="@/static/login/xz2@2x.png"></image> | 75 | <image v-else src="@/static/login/xz2@2x.png"></image> |
| 73 | <view>登录即代表您同意<text>《用户协议》</text><text>《隐私策略》</text></view> | 76 | <view>登录即代表您同意<text>《用户协议》</text><text>《隐私策略》</text></view> --> |
| 74 | </view> | 77 | </view> |
| 75 | </view> | 78 | </view> |
| 76 | </template> | 79 | </template> |
| ... | @@ -83,7 +86,9 @@ import { | ... | @@ -83,7 +86,9 @@ import { |
| 83 | 86 | ||
| 84 | import { | 87 | import { |
| 85 | getCodeImg, | 88 | getCodeImg, |
| 86 | pcLogin | 89 | getSmsCode, |
| 90 | pcLogin, | ||
| 91 | loginByPhone | ||
| 87 | } from '@/common/login.js' | 92 | } from '@/common/login.js' |
| 88 | 93 | ||
| 89 | const isActive = ref(0) | 94 | const isActive = ref(0) |
| ... | @@ -96,6 +101,16 @@ const form = ref({ | ... | @@ -96,6 +101,16 @@ const form = ref({ |
| 96 | code: null, | 101 | code: null, |
| 97 | uuid: null | 102 | uuid: null |
| 98 | }) | 103 | }) |
| 104 | const form2 = ref({ | ||
| 105 | telNo: null, | ||
| 106 | captcha: null, | ||
| 107 | code: null, | ||
| 108 | uuid: null | ||
| 109 | }) | ||
| 110 | const countDown = ref({ | ||
| 111 | start: false, | ||
| 112 | second: 60 | ||
| 113 | }) | ||
| 99 | 114 | ||
| 100 | const app = getApp() | 115 | const app = getApp() |
| 101 | 116 | ||
| ... | @@ -113,6 +128,29 @@ function changeAgree(item) { | ... | @@ -113,6 +128,29 @@ function changeAgree(item) { |
| 113 | } | 128 | } |
| 114 | 129 | ||
| 115 | function login() { | 130 | function login() { |
| 131 | if (isActive.value == 0) { | ||
| 132 | if (!form.value.username) { | ||
| 133 | uni.showToast({ | ||
| 134 | title: '账号不能为空', | ||
| 135 | icon: 'none' | ||
| 136 | }) | ||
| 137 | return | ||
| 138 | } | ||
| 139 | if (!form.value.password) { | ||
| 140 | uni.showToast({ | ||
| 141 | title: '密码不能为空', | ||
| 142 | icon: 'none' | ||
| 143 | }) | ||
| 144 | return | ||
| 145 | } | ||
| 146 | if (!form.value.code) { | ||
| 147 | uni.showToast({ | ||
| 148 | title: '验证码不能为空', | ||
| 149 | icon: 'none' | ||
| 150 | }) | ||
| 151 | return | ||
| 152 | } | ||
| 153 | |||
| 116 | pcLogin(form.value) | 154 | pcLogin(form.value) |
| 117 | .then(() => { | 155 | .then(() => { |
| 118 | app.globalData.isLogin = true | 156 | app.globalData.isLogin = true |
| ... | @@ -121,6 +159,30 @@ function login() { | ... | @@ -121,6 +159,30 @@ function login() { |
| 121 | }) | 159 | }) |
| 122 | }) | 160 | }) |
| 123 | .catch(getCode) | 161 | .catch(getCode) |
| 162 | } else if (isActive.value == 1) { | ||
| 163 | if (!form2.value.telNo) { | ||
| 164 | uni.showToast({ | ||
| 165 | title: '手机号不能为空', | ||
| 166 | icon: 'none' | ||
| 167 | }) | ||
| 168 | return | ||
| 169 | } | ||
| 170 | if (!form2.value.code) { | ||
| 171 | uni.showToast({ | ||
| 172 | title: '短信验证码不能为空', | ||
| 173 | icon: 'none' | ||
| 174 | }) | ||
| 175 | return | ||
| 176 | } | ||
| 177 | |||
| 178 | loginByPhone(form2.value.telNo,form2.value.code) | ||
| 179 | .then(() => { | ||
| 180 | app.globalData.isLogin = true | ||
| 181 | uni.redirectTo({ | ||
| 182 | url: '/pages/index/index' | ||
| 183 | }) | ||
| 184 | }) | ||
| 185 | } | ||
| 124 | } | 186 | } |
| 125 | 187 | ||
| 126 | function goRegister() { | 188 | function goRegister() { |
| ... | @@ -134,8 +196,46 @@ function getCode() { | ... | @@ -134,8 +196,46 @@ function getCode() { |
| 134 | getCodeImg().then((res) => { | 196 | getCodeImg().then((res) => { |
| 135 | codeUrl.value = 'data:image/gif;base64,' + res.data.img | 197 | codeUrl.value = 'data:image/gif;base64,' + res.data.img |
| 136 | form.value.uuid = res.data.uuid | 198 | form.value.uuid = res.data.uuid |
| 199 | form2.value.uuid = res.data.uuid | ||
| 200 | }) | ||
| 201 | } | ||
| 202 | |||
| 203 | // 发送短信验证码 | ||
| 204 | function getCaptchaSms() { | ||
| 205 | if (!form2.value.telNo) { | ||
| 206 | uni.showToast({ | ||
| 207 | title: '手机号不能为空', | ||
| 208 | icon: 'none' | ||
| 137 | }) | 209 | }) |
| 210 | return | ||
| 211 | } | ||
| 212 | if (!form2.value.captcha) { | ||
| 213 | uni.showToast({ | ||
| 214 | title: '图形验证码不能为空', | ||
| 215 | icon: 'none' | ||
| 216 | }) | ||
| 217 | return | ||
| 218 | } | ||
| 219 | |||
| 220 | getSmsCode({ | ||
| 221 | uuid: form2.value.uuid, | ||
| 222 | telNo: form2.value.telNo, | ||
| 223 | code: form2.value.captcha | ||
| 224 | }).then(res => { | ||
| 225 | uni.showToast({ | ||
| 226 | title: '短信验证码下发成功', | ||
| 227 | icon: 'none' | ||
| 228 | }) | ||
| 229 | countDown.value.start = true | ||
| 230 | }).catch(getCode) | ||
| 138 | } | 231 | } |
| 232 | |||
| 233 | function timeup() { | ||
| 234 | countDown.value.start = false | ||
| 235 | countDown.value.second = 60 | ||
| 236 | getCode() | ||
| 237 | } | ||
| 238 | |||
| 139 | </script> | 239 | </script> |
| 140 | 240 | ||
| 141 | <style scoped lang="scss"> | 241 | <style scoped lang="scss"> | ... | ... |
-
Please register or sign in to post a comment