| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317 |
- <template>
- <view class="verification">
- <navbar :config="config" backColor="#666"></navbar>
- <form @submit="formSubmit">
- <view class="content">
- <view class="password">
- <view class="left">
- 密码登录
- <text @click="goToForgetPass">忘记密码</text>
- </view>
- <view class="right" @click="goToverification">
- 验证码登录<text class="iconfont u-font24 u-999"></text>
- </view>
- </view>
- <view class="phone">
- <view class="number">
- 手机号
- </view>
- <input type="number" value="" name="phone" @input="onPhone" maxlength="11" placeholder="请输入手机号"
- placeholder-class="phone-login" />
- </view>
- <view class="passpwd">
- <view class="number">
- 密码登录
- </view>
- <input type="text" value="" name="pw" password="true" maxlength="11" @input="onPassword" placeholder="请输入登录密码"
- placeholder-class="password-login" />
- </view>
- <view class="agreement">
- <view class="whole">
- <view class="top" v-if="flag" @click="onFlag">
- <icon type="success" color="#FF0000" size="17"></icon>
- </view>
- <view class="top" v-else style="width: 30rpx;height: 30rpx;border-radius: 50%;border: #ccc solid 1rpx;"
- @click="onFlag"></view>
- </view>
- <view class="agree">
- 我已阅读并同意<text @click="goToAgreement">《会员注册协议》</text>
- </view>
- </view>
- <button class="login-button" form-type="submit">
- 登录
- </button>
- <view class="go-to-register" @click="goToregister">
- 去注册
- </view>
- </view>
- </form>
- </view>
- </view>
- </template>
- <script>
- import {
- appLogin,
- getAccountInfo
- } from "../../../api/login.js"
- export default {
- data() {
- return {
- config: {
- back: false, //false是tolbar页面 是则不写
- title: '用户登录',
- color: '#1A1A1A',
- //背景颜色;参数一:透明度(0-1);参数二:背景颜色(array则为线性渐变,string为单色背景)
- backgroundColor: [1, "#fff"],
- statusBarFontColor: '#1A1A1A',
- },
- flag: false, //用户协议
- phone: "", //手机号
- password: "", //密码
- // isPhone:false,
- }
- },
- methods: {
- //忘记密码
- goToForgetPass() {
- uni.navigateTo({
- url: "../setup/forgetPass"
- })
- },
- //跳转用户注册协议
- goToAgreement() {
- uni.navigateTo({
- url: "./agreement"
- })
- },
- //验证码登录
- goToverification() {
- uni.redirectTo({
- url: "./verification"
- })
- },
- //去注册
- goToregister() {
- uni.redirectTo({
- url: "./register"
- })
- },
- //登录
- async formSubmit(e) {
- if (!this.phone) {
- this.$mUtil.toast("请输入手机号")
- return false
- }
- if (!this.password) {
- this.$mUtil.toast("请输入密码")
- return false
- }
- if (this.flag == false) {
- this.$mUtil.toast("请先同意协议")
- return false
- }
- if (!(this.phone.match(this.$mConfig.telRegex))) {
- this.$mUtil.toast("请输入正确的手机号")
- return false
- }
- let param = {
- mobile: this.phone,
- password: this.password,
- cid: uni.getStorageSync('cid')
- }
- let res = await this.$http.post(appLogin, param)
- if (res && res.code == 200) {
- if (res.data.code != 500) {
- this.$mUtil.toast("登录成功")
- uni.setStorageSync('apiToken', res.data.token);
- uni.setStorageSync("shop", res.data.shop);
- this.$http.get(getAccountInfo).then(res => {
- if (res && res.code == 200) {
- uni.setStorageSync("personal", res.data)
- }
- })
- setTimeout(function() {
- uni.navigateBack({
- delta: 1
- })
- }, 1000)
- } else {
- this.$mUtil.toast(res.data.msg)
- }
- }
- },
- //手机号
- onPhone(e) {
- this.phone = e.detail.value
- // if(this.phone.match(this.$mConfig.telRegex)){
- // this.isPhone=true
- // }else{
- // this.isPhone=false
- // }
- },
- //密码
- onPassword(e) {
- this.password = e.detail.value
- },
- //用户协议
- onFlag() {
- this.flag = !this.flag
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- /deep/ .hx-navbar__content__main_center_txt {
- span {
- color: #fff;
- font-size: 36rpx;
- font-weight: 400;
- font-family: PingFang SC, PingFang SC-Regular;
- }
- }
- .phone-login {
- color: #CCCCCC;
- font-size: 28rpx;
- font-weight: 500;
- }
- .password-login {
- color: #CCCCCC;
- font-size: 28rpx;
- font-weight: 500;
- }
- .go-to-register {
- padding: 18rpx 0;
- color: #FA6138;
- font-size: 32rpx;
- font-weight: Regular;
- width: 100%;
- text-align: center;
- margin-top: 24rpx;
- border: 1rpx solid #3775F6;
- border-radius: 20rpx;
- }
- .login-button {
- width: 100%;
- text-align: center;
- margin-top: 70rpx;
- color: #ffffff;
- font-size: 32rpx;
- font-weight: Regular;
- background-color: #FA6138;
- border-radius: 20rpx;
- }
- .agreement {
- margin-top: 40rpx;
- display: flex;
- }
- .agree {
- font-size: 28rpx;
- color: #999999;
- font-weight: Regular;
- margin-left: 10rpx;
- text {
- color: #0047B1;
- }
- }
- .top {
- display: flex;
- align-items: center;
- }
- .choice {
- margin: 0 50rpx;
- display: flex;
- align-items: center;
- .whole {
- display: flex;
- align-items: center;
- }
- }
- .passpwd {
- display: flex;
- margin-top: 40rpx;
- padding-bottom: 32rpx;
- border-bottom: 1rpx solid #E6E6E6;
- .number {
- font-size: 28rpx;
- font-weight: 500;
- color: #333333;
- }
- input {
- flex: 1;
- margin-left: 40rpx;
- }
- }
- .phone {
- display: flex;
- align-items: center;
- margin-top: 40rpx;
- padding-bottom: 32rpx;
- border-bottom: 1rpx solid #e6e6e6;
- .number {
- font-size: 28rpx;
- color: #333333;
- font-weight: 500;
- }
- input {
- flex: 1;
- margin-left: 70rpx;
- }
- }
- .password {
- display: flex;
- .left {
- font-size: 38rpx;
- font-weight: Bold;
- color: #333333;
- line-height: 28rpx;
- flex: 1;
- text {
- font-size: 28rpx;
- color: #666666;
- font-weight: 400;
- margin-left: 20rpx;
- }
- }
- .right {
- color: #666666;
- font-size: 28rpx;
- font-weight: Regular;
- }
- }
- .content {
- margin: 80rpx 50rpx;
- }
- </style>
|