文件名从 pages/login/farmer-login.vue 修改 |
| | |
| | | <template> |
| | | <view class="main-container login-container img100 relative" style="margin-top: 0rpx;"> |
| | | <!-- background-image:url('@/static/images/farmer/login/bg.png') --> |
| | | <!-- background-image:url('@/static/images/supplier/login/bg.png') --> |
| | | |
| | | <image class="component-bg" src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/a5/a54508de179a4942918ecb2c5a4aa9f5bg.png" mode="scaleToFill" /> |
| | | <image class="component-bg" |
| | | src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/a5/a54508de179a4942918ecb2c5a4aa9f5bg.png" |
| | | mode="scaleToFill" /> |
| | | <view class="t-login top-bg"> |
| | | <view class="nav-title">登录</view> |
| | | <view class="login"> |
| | |
| | | <input type="text" :password="true" name="password" placeholder="请输入密码" v-model="password" /> |
| | | </view> |
| | | <view class="t-a input" v-if="loginType=='code'"> |
| | | |
| | | |
| | | <input type="text" name="userName" placeholder="请输入手机号" v-model="phoneNumber" /> |
| | | <view class="get-code" :style="{'color':getCodeBtnColor}" @click.stop="getCode()"> |
| | | {{getCodeText}} |
| | | </view> |
| | | |
| | | <input type="text" name="userName" placeholder="请输入手机号" v-model="phoneNumber" /> |
| | | |
| | | </view> |
| | | |
| | | |
| | |
| | | // import gzmzApi from '@/api/gzmzApi.js' |
| | | // import myCache from '@/utils/myCache.js' |
| | | export default { |
| | | props: { |
| | | // apitype: 'loginSupplier', |
| | | apitype: { |
| | | type:String, |
| | | default(){ |
| | | return 'loginSupplier' |
| | | |
| | | // return 'loginPartner' |
| | | } |
| | | }, |
| | | }, |
| | | data() { |
| | | return { |
| | | openId: '-1', |
| | |
| | | }; |
| | | }, |
| | | methods: { |
| | | getCode() { |
| | | async getCode() { |
| | | uni.hideKeyboard() //隐藏已经显示的软键盘,如果软键盘没有显示则不做任何操作。 |
| | | if (this.getCodeisWaiting) { |
| | | return; |
| | | } |
| | | if (!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(this.phoneNumber))) { //校验手机号码是否有误 |
| | | uni.showToast({ |
| | | title: '请填写正确手机号码', |
| | | icon: "none" |
| | | }); |
| | | this.$message.showToast('请填写正确手机号码') |
| | | return false; |
| | | } |
| | | this.getCodeText = "发送中..." //发送验证码 |
| | | this.getCodeisWaiting = true; |
| | | this.getCodeBtnColor = "rgba(255,255,255,0.5)" //追加样式,修改颜色 |
| | | this.getCodeBtnColor = "#000" //追加样式,修改颜色 |
| | | //示例用定时器模拟请求效果 |
| | | //setTimeout(()用于在指定的毫秒数后调用函数或计算表达式 |
| | | setTimeout(() => { |
| | | const { |
| | | code |
| | | } = await this.$http.request('post', '/api/sms/send/code', { |
| | | data: { |
| | | tel: this.phoneNumber, |
| | | userType: 'supplier' |
| | | } |
| | | }) |
| | | if (code == 0) { |
| | | uni.showToast({ |
| | | title: '验证码已发送', |
| | | icon: "none" |
| | | }); //弹出提示框 |
| | | //示例默认1234,生产中请删除这一句。 |
| | | // this.code = '1234'; //发送验证码,进行填入 |
| | | }); |
| | | this.setTimer(); //调用定时器方法 |
| | | }, 1000) |
| | | } |
| | | // setTimeout(() => { |
| | | // uni.showToast({ |
| | | // title: '验证码已发送', |
| | | // icon: "none" |
| | | // }); //弹出提示框 |
| | | // //示例默认1234,生产中请删除这一句。 |
| | | // // this.code = '1234'; //发送验证码,进行填入 |
| | | // this.setTimer(); //调用定时器方法 |
| | | // }, 1000) |
| | | }, |
| | | //setTimer: 需要每隔一段时间执行一件事的的时候就需要使用SetTimer函数 |
| | | setTimer() { |
| | |
| | | // url: '/pages/index/index' |
| | | // }) |
| | | uni.redirectTo({ |
| | | url: '/sub_pages/farmer/farmer-reg/farmer-reg' |
| | | url: '/sub_pages/supplier/supplier-reg/supplier-reg' |
| | | }) |
| | | |
| | | }, |
| | |
| | | title: '登陆中' |
| | | }); |
| | | var that = this; |
| | | if (this.loginType == 'pwd') { |
| | | if (!that.userName) { |
| | | uni.showToast({ |
| | | title: '请输入用户名', |
| | |
| | | }); |
| | | return; |
| | | } |
| | | } |
| | | if (this.loginType == 'code') { |
| | | if (!that.tel) { |
| | | uni.showToast({ |
| | | title: '请输入手机号', |
| | | icon: 'none' |
| | | }); |
| | | return; |
| | | } |
| | | if (!that.smsCode) { |
| | | uni.showToast({ |
| | | title: '请输入手机验证码', |
| | | icon: 'none' |
| | | }); |
| | | return; |
| | | } |
| | | } |
| | | // if (this.pcfvalue == undefined) { |
| | | // util.showMyToast('必须勾选《用户服务协议》及《隐私政策》'); |
| | | // return; |
| | |
| | | let post = { |
| | | username: this.userName, |
| | | password: this.password, |
| | | tel: this.phoneNumber, |
| | | smsCode: this.smsCode |
| | | // openId: '123456789' |
| | | } |
| | | // const { |
| | | // code |
| | | // } = await this.$http.request('get', '/api/login/admin') |
| | | const resp = await this.$store.dispatch('loginSupplier', post); |
| | | const resp = await this.$store.dispatch(this.apitype, post); |
| | | // uni.hideLoading() |
| | | |
| | | if (resp.code == 0) { |