roose 4 лет назад
Родитель
Сommit
d2dbc6d592

+ 69 - 3
pages/identity/Identity.js

@@ -1,9 +1,75 @@
 const app = require('../../utils/util.js');
-import WxValidate from '../../utils/WxValidate';
-const tools = require('../../utils/tools.js');
+var util = require('../../utils/md5.js')
 Page({
   data: {
-    name:'',
+    defaultType1: true,
+    passwordType1: true
   },
+  eyeStatus1() {
+    if (this.data.defaultType1) {
+      this.setData({
+        passwordType1: false,
+        defaultType1: false,
+      })
+    } else {
+      this.setData({
+        passwordType1: true,
+        defaultType1: true,
+      })
+    }
+  },
+  formSubmit(e) {
+    console.log(e.detail, "daying");
+    var password = e.detail.value.pwd;
+    wx.request({
+      url: app.globalData.publicUrl + '/applet/bing',
+      method: "GET",
+      data: {
+        name: e.detail.value.name,
+        pwd: util.hexMD5(password),
+        appletsId: wx.getStorageSync('openId')
+      },
+      success: (res) => {
+        if (res.data.code == 0) {
+          wx.switchTab({
+            url: '/pages/index/index',
+          })
+          wx.setStorageSync('user', 'user')
+        }
+      }
+    })
+
+  },
+  onLoad: function () {
+    var that = this;
+    wx.login({
+      success: res => {
+        // 获取到用户的 code 之后:res.code
+        console.log("用户的code:" + res.code);
+        const appid = "wx1c015df104db7030"
+        const secret = "d1956c1b5d3601657c98b0dc80a006f7"
+        let url = 'https://api.weixin.qq.com/sns/jscode2session?appid=' + appid + '&secret=' + secret + '&js_code=' + res.code + '&grant_type=authorization_code';
+        wx.request({
+          // 自行补上自己的 APPID 和 SECRET
+          url: url,
+          success: res => {
+            // 获取到用户的 openid
+            console.log("用户的openid:" + res.data.openid);
+            wx.setStorageSync('openId', res.data.openid)
+            wx.request({
+              url: app.globalData.publicUrl + '/applet/isExist',
+              method: "GET",
+              data: {
+                appletsId: wx.getStorageSync('openId')
+              },
+              success: (res) => {
 
+              }
+            })
+          }
+        });
+      }
+    });
+
+  },
 })

+ 1 - 1
pages/identity/Identity.json

@@ -1,4 +1,4 @@
 {
-  "navigationBarTitleText":"身份卡",
+  "navigationBarTitleText":"登录",
   "usingComponents": {}
 }

+ 22 - 1
pages/identity/Identity.wxml

@@ -1 +1,22 @@
-<view>身份卡111</view>
+<view>
+	<image src="/images/bg_main_new.jpg" style="width: 100%; height: 400rpx;"> </image>
+	<view class="home">
+		民政信息采集系统
+	</view>
+	<form bindsubmit="formSubmit">
+		<view class="box">
+			<view class="name">
+				<image src="/images/user.png" style="width: 40rpx; height: 40rpx;"> </image>
+				<input name='name' class="weui-input" placeholder="请输入账号" />
+			</view>
+			<view class="name" style=" margin-top: 50rpx;">
+				<image src="/images/pwd.png" style="width: 40rpx; height: 40rpx;"> </image>
+				<input name='pwd' class="weui-input" password='{{passwordType1}}' placeholder="请输入密码" />
+				<image src='{{defaultType1? "/images/eye_close.png": "/images/eye_open.png"}}' class='eye-image' bindtap='eyeStatus1'></image>
+			</view>
+			<view class="register">
+				<button formType="submit">登录并绑定微信号</button>
+			</view>
+		</view>
+	</form>
+</view>

+ 43 - 0
pages/identity/Identity.wxss

@@ -0,0 +1,43 @@
+.home {
+  text-align: center;
+  margin-top: 60rpx;
+  font-weight: bold;
+}
+
+.name {
+  display: flex;
+  border: 1px solid #ccc;
+  padding: 20rpx;
+  border-radius: 10rpx;
+}
+
+.box {
+  width: 80%;
+  margin: 0 auto;
+  margin-top: 60rpx;
+}
+
+input {
+  margin-left: 20rpx;
+  width: 430rpx;
+}
+
+.eye-image {
+  color: #fff;
+  width: 50rpx;
+  height: 50rpx;
+  margin-left: 20rpx;
+}
+
+.register {
+  margin-top: 60rpx;
+}
+
+button:not([size='mini']) {
+  width: 100% !important;
+  margin-left: auto;
+  margin-right: auto;
+  color: white;
+  background: #1989FA;
+  font-size: 28rpx;
+}

+ 0 - 18
pages/identity/time.wxs

@@ -1,18 +0,0 @@
-var formatDate = function (date) {
-  var date = getDate(date);
-  console.log(date)
-  var year = date.getFullYear()
-  var month = date.getMonth() + 1
-  var day = date.getDay()
-  var h = date.getHours();
-  h = h < 10 ? ('0' + h) : h;
-  var m = date.getMinutes();
-  m = m < 10 ? ('0' + m) : m;
-  var s = date.getSeconds();
-  s = s < 10 ? ('0' + s) : s;
-  return year + '/' + month + '/' + day + " " + h + ":" + m + ":" + s;
-}
-
-module.exports = {
-  formatDate: formatDate
-}