guhongwei 3 jaren geleden
bovenliggende
commit
602cd9ff5d

+ 4 - 1
app.json

@@ -1,7 +1,10 @@
 {
   "pages": [
-    "pages/login1/index",
+    "pages/login0/index",
     "pages/login/index",
+    "pages/login1/index",
+    "pages/login2/index",
+    "pages/login2/agreement",
     "pages/index/index",
     "pages/home/index",
     "pages/apply/index",

pages/login copy/index.js → pages/login0/index.js


pages/login copy/index.json → pages/login0/index.json


pages/login copy/index.wxml → pages/login0/index.wxml


pages/login copy/index.wxss → pages/login0/index.wxss


+ 84 - 0
pages/login2/agreement.js

@@ -0,0 +1,84 @@
+// pages/login/login.js
+import WxValidate from '../../utils/wxValidate'
+const app = getApp()
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        frameStyle: { useTop: true, name: '使用协议', leftArrow: true, useBar: false },
+        // 主体高度
+        infoHeight: '',
+    },
+    back: function () {
+        wx.navigateBack({ url: '/pages/login2/index' })
+    },
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+        // 计算高度
+        this.searchHeight()
+    },
+    // 计算高度
+    searchHeight: function () {
+        let frameStyle = this.data.frameStyle;
+        let client = app.globalData.client;
+        let infoHeight = client.windowHeight;
+        // 是否去掉状态栏
+        if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
+        // 是否减去底部菜单
+        if (frameStyle.useBar) infoHeight = infoHeight - 50;
+        if (infoHeight) this.setData({ infoHeight: infoHeight })
+    },
+
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom: function () {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
+
+    }
+})

+ 6 - 0
pages/login2/agreement.json

@@ -0,0 +1,6 @@
+{
+  "component": true,
+  "usingComponents": {
+    "mobile-main": "/commpents/mobile-frame/mobile-main"
+  }
+}

+ 5 - 0
pages/login2/agreement.wxml

@@ -0,0 +1,5 @@
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
+    <view slot="info" class="main" style="height:{{infoHeight}}px;">
+        使用协议
+    </view>
+</mobile-main>

+ 4 - 0
pages/login2/agreement.wxss

@@ -0,0 +1,4 @@
+.main {
+    position: relative;
+    width: 100%;
+}

+ 142 - 0
pages/login2/index.js

@@ -0,0 +1,142 @@
+// pages/login/login.js
+import WxValidate from '../../utils/wxValidate'
+const app = getApp()
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    frameStyle: { useTop: false, name: '', leftArrow: false, useBar: false },
+    // 主体高度
+    infoHeight: '',
+    // 使用协议
+    agreement: false
+  },
+  initValidate() {
+    const rules = { phone: { required: true, tel: true }, password: { required: true, } }
+    // 验证字段的提示信息,若不传则调用默认的信息
+    const messages = { phone: { required: '请输入手机号', }, password: { required: '请输入密码', } };
+    this.WxValidate = new WxValidate(rules, messages)
+  },
+  back: function () {
+    wx.navigateBack({ url: '/pages/home/index' })
+  },
+  // 协议选择
+  agreementChange: function (e) {
+    const that = this;
+    let value = e.detail.value;
+    if (value.length > 0) that.setData({ agreement: true })
+    else that.setData({ agreement: false })
+  },
+  // 协议查看
+  agreementView: function () {
+    wx.navigateTo({ url: '/pages/login2/agreement' })
+  },
+  // 提交登录
+  onSubmit: function (e) {
+    const params = e.detail.value;
+    if (!this.WxValidate.checkForm(params)) {
+      const error = this.WxValidate.errorList[0];
+      wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
+      return false
+    } else {
+      if (this.data.agreement) {
+        wx.request({
+          url: app.globalData.publicUrl + `/api/hc/user/login`,
+          method: "post",
+          data: { ...params },
+          header: {},
+          success: (res) => {
+            if (res.data.errcode == '0') {
+              wx.setStorage({ key: "user", data: res.data.data });
+              app.globalData.userInfo = res.data.data;
+              wx.showToast({ title: `账号登录成功`, icon: 'success', duration: 2000 })
+              wx.navigateTo({ url: '/pages/home/index' })
+            } else {
+              wx.showToast({ title: res.data.errmsg, icon: 'error' })
+            }
+          },
+          fail: (res) => { },
+          complete: (res) => { },
+        })
+      } else {
+        wx.showToast({ title: `请同意使用协议`, icon: 'error', duration: 1000 })
+      }
+    }
+  },
+  // 微信登录
+  wxLogin: function () {
+    wx.showToast({ title: `暂未开放`, icon: 'error', duration: 2000 })
+    // wx.navigateTo({ url: '/pages/home/index' })
+  },
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    //验证规则函数
+    this.initValidate()
+    // 计算高度
+    this.searchHeight()
+  },
+  // 计算高度
+  searchHeight: function () {
+    let frameStyle = this.data.frameStyle;
+    let client = app.globalData.client;
+    let infoHeight = client.windowHeight;
+    // 是否去掉状态栏
+    if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
+    // 是否减去底部菜单
+    if (frameStyle.useBar) infoHeight = infoHeight - 50;
+    if (infoHeight) this.setData({ infoHeight: infoHeight })
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 6 - 0
pages/login2/index.json

@@ -0,0 +1,6 @@
+{
+  "component": true,
+  "usingComponents": {
+    "mobile-main": "/commpents/mobile-frame/mobile-main"
+  }
+}

+ 49 - 0
pages/login2/index.wxml

@@ -0,0 +1,49 @@
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
+  <view slot="info" class="main" style="height:{{infoHeight}}px;">
+    <view class="one">
+      <view class="one_1">
+        <view class="one_1_1">耗材采购平台</view>
+        <view class="one_1_2">
+          <form bindsubmit="onSubmit">
+            <view class="content">
+              <view class="left">
+                <text class=" icon iconfont icon-dianhua"></text>
+              </view>
+              <view class="right">
+                <input type='number' name="phone" value="{{form.phone}}" maxlength="11" placeholder='请输入手机号' placeholder-class="placeholder"></input>
+              </view>
+            </view>
+            <view class="content">
+              <view class="left">
+                <text class="icon iconfont icon-mima"></text>
+              </view>
+              <view class="right">
+                <input type='text' name="password" value="{{form.password}}" password placeholder='请输入密码' placeholder-class="placeholder"></input>
+              </view>
+            </view>
+            <view class="btn">
+              <view class="btn_1">
+                <button size="mini" plain="true" bindtap="wxLogin">立即注册</button>
+                <button size="mini" plain="true" bindtap="wxLogin">忘记密码?</button>
+              </view>
+              <view class="btn_2">
+                <button type="primary" size="mini" form-type="submit">登录</button>
+              </view>
+            </view>
+          </form>
+        </view>
+        <view class="one_1_3">
+          <checkbox-group class="check" bindchange="agreementChange">
+            <checkbox class="isXY" value="true" /><text bindtap="agreementView">同意小程序的《使用协议》</text>
+          </checkbox-group>
+        </view>
+      </view>
+      <view class="one_2">
+        一一一一<text>您还可以使用一下方式登录</text>一一一
+      </view>
+      <view class="one_3">
+        <button type="primary" size="mini" bindtap="wxLogin">微信登录</button>
+      </view>
+    </view>
+  </view>
+</mobile-main>

+ 152 - 0
pages/login2/index.wxss

@@ -0,0 +1,152 @@
+.main {
+    position: relative;
+    width: 100%;
+    background: #356363;
+}
+
+.main .one {
+    float: left;
+    width: 80%;
+    margin: 25% 10% 0 10%;
+}
+
+.main .one .one_1 {
+    float: left;
+    width: 93%;
+    height: 350px;
+    overflow: hidden;
+    background-color: #fff;
+    margin: 0 0 20px 0;
+    border-radius: 10px;
+    padding: 10px;
+}
+
+.main .one .one_1 .one_1_1 {
+    float: left;
+    width: 100%;
+    font-size: 20px;
+    font-weight: 700;
+    margin: 25px 0;
+}
+
+.main .one .one_1 .one_1_2 {
+    float: left;
+    width: 100%;
+    margin: 0 0 20px 0;
+}
+
+.main .one .one_1 .one_1_2 .content {
+    float: left;
+    width: 100%;
+    margin: 0 0 15px 0;
+    padding: 10px 0;
+    border-bottom: 1px solid #000;
+}
+
+.main .one .one_1 .one_1_2 .content .left {
+    float: left;
+    width: 20%;
+    text-align: center;
+}
+
+.main .one .one_1 .one_1_2 .content .left .icon {
+    font-size: 30px;
+}
+
+.main .one .one_1 .one_1_2 .content .right {
+    float: left;
+    width: 80%;
+}
+
+.main .one .one_1 .one_1_2 .content .right input {
+    float: left;
+    width: 100%;
+    padding: 4px 0;
+    font-size: 14px;
+}
+
+.main .one .one_1 .one_1_2 .btn {
+    float: left;
+    width: 100%;
+    margin: 15px 0 0 0;
+}
+
+.main .one .one_1 .one_1_2 .btn .btn_1 {
+    float: left;
+    width: 100%;
+    margin: 0 0 10px 0;
+}
+
+.main .one .one_1 .one_1_2 .btn .btn_1 button {
+    border: none;
+    font-size: 12px;
+}
+
+.main .one .one_1 .one_1_2 .btn .btn_1 button:last-child {
+    float: right;
+}
+
+.main .one .one_1 .one_1_2 .btn .btn_2 {
+    float: left;
+    width: 100%;
+    text-align: center;
+}
+
+.main .one .one_1 .one_1_2 .btn .btn_2 button {
+    width: 80%;
+    border-radius: 25px;
+}
+
+.main .one .one_1 .one_1_3 {
+    float: left;
+    width: 100%;
+    font-size: 12px;
+    color: #666;
+}
+
+.main .one .one_1 .one_1_3 .check {
+    padding: 0 50px;
+}
+
+.main .one .one_2 {
+    float: left;
+    width: 100%;
+    color: #ffffff;
+    margin: 0 0 50px 0;
+}
+
+.main .one .one_2 text {
+    padding: 0 10px;
+    font-size: 14px;
+}
+
+.main .one .one_3 {
+    float: left;
+    width: 100%;
+    text-align: center;
+}
+ /* 未选中 */
+checkbox .wx-checkbox-input{
+    /* border-radius: 50%; */
+    width: 30rpx; 
+    height: 30rpx; 
+    /* border: 1rpx solid #aaa;  */
+ }
+ /* 选中 */
+ /* checkbox .wx-checkbox-input.wx-checkbox-input-checked{
+    border: none;
+    background: red;
+ } */
+/* 选中 */
+ /* checkbox .wx-checkbox-input.wx-checkbox-input-checked::before{
+    border-radius: 50%;
+    width: 40rpx;
+    height: 40rpx;
+    line-height: 40rpx;
+    text-align: center;
+    font-size:30rpx; 
+    color:#fff; 
+    background: transparent;
+    transform:translate(-50%, -50%) scale(1);
+    -webkit-transform:translate(-50%, -50%) scale(1);
+ } */