1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import {
- getDataSet,
- getEventParam,
- isMobile,
- toast
- } from "../../utils/utils";
- import User from "../../model/user";
- import Route from "../../model/route";
- import Api from "../../model/api";
- import {logicStatus} from '../../model/enum';
- Page({
- data: {
- formData: {
- phone: '',
- verify: '',
- },
- isShowBack: true,
- showRegister: false
- },
- onLoad: function (options) {
- this.getRegsiterDisplayStatus();
- },
- async login(e) {
- if (!isMobile(this.data.formData.phone)) {
- toast('请输入正确的手机号')
- return;
- }
- if (!this.data.formData.verify.trim()) {
- toast('请输入验证码')
- return;
- }
- await User.loginByPhone(this.data.formData);
- const eventChannel = this.getOpenerEventChannel()
- if (eventChannel.emit) {
- eventChannel.emit('login', {
- isLogin: true
- });
- }
- wx.navigateBack();
- },
- register() {
- Route.toRegister()
- },
- async loginByWechat(e) {
- await User.loginByWechat();
- const eventChannel = this.getOpenerEventChannel()
- if (eventChannel.emit) {
- eventChannel.emit('login', {
- isLogin: true
- });
- }
- wx.navigateBack();
- },
- onChange(e) {
- const field = getDataSet(e, "field");
- this.setData({
- [field]: getEventParam(e)
- })
- },
- back() {
- const eventChannel = this.getOpenerEventChannel()
- if (eventChannel.emit) {
- eventChannel.emit('login', {
- isLogin: false
- });
- }
- wx.navigateBack();
- },
- async getRegsiterDisplayStatus() {
- let {
- data
- } = await Api.getPulishDict('sys_register_status');
- if (data && data.length > 0) {
- let status = data[0]['dictValue'];
- let showRegister = logicStatus.YES == status;
- this.setData({
- showRegister
- });
- }
- }
- });
|