123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- const util = require('../../utils/util.js');
- const app = getApp()
- Page({
- data: {
- imgUrls: [
- "../../images/home/banner_1.png",
- "../../images/home/banner_2.png",
- "../../images/home/banner_3.png",
- ],
- routers: [
- {
- name: '填写日报',
- url: '../report/edit',
- img: '../../images/home/edit.png'
- },
- {
- name: '审核日报',
- url: '',
- img: '../../images/home/check.png'
- },
- {
- name: '我的信息',
- url: '',
- img: '../../images/home/my.png'
- },
- {
- name: '暂无更多',
- url: '',
- img: '../../images/home/more.png'
- }
- ],
- disabled: false, //按钮是否禁用
- click: true,
- },
- onLoad: function () {
- },
- // 获取输入的值
- getValue_username: function (e) {
- this.setData({
- username: e.detail.value
- })
- },
-
- getValue_password: function (e) {
- this.setData({
- password: e.detail.value
- })
- },
- // 登录
- formSubmitHandle: function (e) {
- if (this.data.username == "") {
- wx.showToast({
- title: '账号不能为空',
- icon: 'none',
- duration: 1000
- })
- return false;
- } else if (this.data.password == "") {
- wx.showToast({
- title: '密码不能为空',
- icon: 'none',
- duration: 1000
- })
- return false;
- } else {
- if (this.data.click) {
- var that = this;
- that.setData({ click: false });
- wx.login({
- success: res => {
- wx.request({
- url: app.globalData.serverUrl + "/user/loginAdmin",
- method: "POST",
- data: {
- username: that.data.username,
- password: that.data.password,
- },
- header: {
- "Content-Type": "application/x-www-form-urlencoded"
- },
- success: function (res) {
- if (res.data.code == "ok") {
- wx.showToast({
- title: '登录成功',
- icon: 'success',
- duration: 2000
- })
- wx.setStorageSync('userInfo', res.data.data);
- setTimeout(function () {
- wx.reLaunch({
- url: '../cloud/cloud'
- })
- }, 200)
- } else {
- that.setData({ click: true })
- wx.showToast({
- title: res.data.msg,
- icon: 'none',
- duration: 2000
- })
- }
- },
- fail: function (res) {
- that.setData({ click: true })
- wx.showToast({
- title: '登录失败!',
- icon: 'none',
- duration: 2000
- })
- }
- })
- }
- })
- } else {
- wx.showToast({
- title: '登录中,请勿重复点击',
- icon: 'none',
- duration: 1000
- })
- }
- }
- }
- })
|