| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <template>
- <view>
- <view style="background: #fff;margin: auto;border-radius: 5%;padding: 50rpx 80rpx;">
- <view>
- <input class="text_2" placeholder="请输入手机号码" v-model="data.mobilephone" />
- </view>
- <view>
- <input class="text_2" password="true" type="safe-password" placeholder="请输入登录密码" v-model="data.mobilepwd" />
- </view>
- <view class="input_2 flex-row" style="display: none;">
- <input class="text_4" placeholder="请输入验证码" v-model="data.inputcode" />
- <text class="text_5" @click="getCode">{{ data.code }}</text>
- </view>
- <button @click="onClick_1" class="text_6">确认登录</button>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- constants: {},
- data: {
- mobilephone: '',
- mobilepwd: '',
- code: '2589',
- inputcode: '2589'
- }
- };
- },
- onLoad(option) {
- // // console.log(option);
- // this.getCode();
- },
- methods: {
- onClick_1() {
- if(!this.data.mobilephone){
- uni.showToast({
- title:"手机号不能为空",
- icon:"none",
- })
- return;
- }
- if(!this.data.mobilepwd){
- uni.showToast({
- title:"密码不能为空",
- icon:"none",
- })
- return;
- }
- if(!this.data.inputcode){
- uni.showToast({
- title:"验证码不能为空",
- icon:"none",
- })
- return;
- }
- if(this.data.inputcode!=this.data.code){
- uni.showToast({
- title:"验证码错误",
- icon:"none",
- })
- this.getCode();
- return;
- }
- var data = new Object();
- data.sjh=this.data.mobilephone;
- data.mm=this.data.mobilepwd;
- this.$api
- .MhPostModel(data, 'user/login')
- .then(res => {
- // console.log('MhUserLogin信息', JSON.stringify(res));
- if (res.data.code != 1) {
- uni.showToast({
- title: res.data.msg,
- icon: 'none'
- });
- this.getCode();
- return;
- } else {
- uni.showToast({
- title: res.data.msg,
- icon: 'none'
- });
- this.$api.setUserinfo(res.data.data);
- uni.switchTab({
- url:"/pages/my/index"
- })
- }
- })
- .catch(err => {
- // console.log('request fail', JSON.stringify(err));
- });
- },
- getCode() {
- var data = new Object();
- this.$api
- .MhUserModel(data, 'MhUserCheckCode')
- .then(res => {
- // console.log('MhUserCheckCode信息', JSON.stringify(res));
- if (res.data.code != 0) {
- uni.showToast({
- title: res.data.msg,
- icon: 'none'
- });
- return;
- } else {
- this.data.code = res.data.info;
- }
- })
- .catch(err => {
- // console.log('request fail', JSON.stringify(err));
- });
- }
- }
- };
- </script>
- <style lang="css">
- page {
- background: url(../../static/loginbg.png) #fff no-repeat;background-size:100% auto;background-position: top;
- padding: 0;height: auto;
- margin: 0;padding-top: 480rpx;
- }
- .text_2{background: #f5f5f8;font-size: 28rpx;height: 90rpx;line-height: 90rpx;padding-left: 20rpx;margin-bottom:30rpx;border-radius: 10rpx;}
- .text_6{background-image: linear-gradient(#829c52, #59723b);color: #fff;border: 0;font-size: 28rpx;height: 90rpx;line-height: 90rpx;}
- </style>
|