提交 334579364477a8e6614d74586d5e31976dfea80a

作者 wangyu
1 个父辈 57c03de0

首页部分添加

1 //app.js 1 //app.js
2 App({ 2 App({
3 onLaunch: function () { 3 onLaunch: function () {
4 - // 展示本地存储能力 4 + var that = this;
  5 + console.log("onlaunch---", "onlaunch");
  6 + //调用API从本地缓存中获取数据
5 var logs = wx.getStorageSync('logs') || [] 7 var logs = wx.getStorageSync('logs') || []
6 logs.unshift(Date.now()) 8 logs.unshift(Date.now())
7 wx.setStorageSync('logs', logs) 9 wx.setStorageSync('logs', logs)
8 -  
9 - // 登录  
10 wx.login({ 10 wx.login({
11 - success: res => {  
12 - // 发送 res.code 到后台换取 openId, sessionKey, unionId 11 + success: function (res) {
  12 + if (res.code) {
  13 + that.getTokenByCode(res.code, true)
  14 + }
13 } 15 }
14 }) 16 })
15 - // 获取用户信息  
16 - wx.getSetting({  
17 - success: res => {  
18 - if (res.authSetting['scope.userInfo']) {  
19 - // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框  
20 - wx.getUserInfo({  
21 - success: res => {  
22 - // 可以将 res 发送给后台解码出 unionId  
23 - this.globalData.userInfo = res.userInfo 17 + },
  18 +
  19 + onShow: function (res) {
  20 + console.log("onShow----", res);
  21 + var that = this;
  22 + that.globalData.onshow_count++;
  23 + if (that.globalData.onshow_count > 1) {//除第一次进入小程序之外的打开时
  24 + wx.login({
  25 + success: function (res) {
  26 + if (res.code) {
  27 + that.getTokenByCode(res.code, false)
  28 + }
  29 + }
  30 + })
  31 + }
  32 + },
24 33
25 - // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回  
26 - // 所以此处加入 callback 以防止这种情况  
27 - if (this.userInfoReadyCallback) {  
28 - this.userInfoReadyCallback(res)  
29 - }  
30 - } 34 + getTokenByCode: function (code, relaunch) {
  35 + var that = this;
  36 + var baseUrl = that.globalData.baseUrl;
  37 + wx.request({
  38 + url: baseUrl + 'uaa/v1/auth/tokens',
  39 + data: {
  40 + "grant_type": "wx_app_code",
  41 + "code": code,
  42 + "scope": "global_access:end_user,tenant:wxe91c67adba6ac02d"
  43 + },
  44 + method: "POST",
  45 + header: {
  46 + 'content-type': 'application/json'
  47 + },
  48 + success: function (res) {
  49 + console.log("getTokenByCode", res.data)
  50 + var user = res.data.user;
  51 + var tenant = res.data.tenant;
  52 + that.globalData.tenant_id = tenant.id;
  53 + that.globalData.userInfo = res.data.user;
  54 + that.globalData.wx_open_id = user.wx_open_id;
  55 + that.globalData.Authorization = "Bearer " + res.data.access_token;
  56 + that.globalData.refresh_token = res.data.refresh_token;
  57 + if (user && user.type == "0") {//匿名用户
  58 + wx.redirectTo({
  59 + url: '../../getPhone/getPhone'
31 }) 60 })
  61 + } else if (user && user.type == "1") {//注册用户
  62 + if (relaunch) {
  63 + wx.reLaunch({ //重新加载
  64 + url: '../../tabbar/home/home'
  65 + })
  66 + }
32 } 67 }
33 - } 68 + },
  69 + fail: function (res) {
  70 + console.log("login-res-fail", res);
  71 + },
34 }) 72 })
35 }, 73 },
  74 + getUserInfo: function (cb) {
  75 + var that = this
  76 + if (this.globalData.userInfo) {
  77 + typeof cb == "function" && cb(this.globalData.userInfo)
  78 + } else {
  79 + //调用登录接口
  80 + wx.getUserInfo({
  81 + withCredentials: false,
  82 + success: function (res) {
  83 + console.log("userInfo---", res)
  84 + that.globalData.userInfo = res.userInfo
  85 + typeof cb == "function" && cb(that.globalData.userInfo)
  86 + }
  87 + })
  88 + }
  89 + },
  90 +
36 globalData: { 91 globalData: {
37 - userInfo: null 92 + onshow_count: 0,
  93 + baseUrl: "http://47.98.47.16:20000/",
  94 + // baseUrl: "https://api.workai.com.cn/",
  95 + OSSUrl: "https://oss.workai.com.cn/",
  96 + userInfo: null,
  97 + hasLogin: false,
  98 + openid: null,
  99 + Authorization: null,
  100 + refresh_token: "",
  101 + tenant_id: "",
  102 + wx_open_id: "",
  103 + newComerOrder: null
38 } 104 }
39 }) 105 })
1 { 1 {
2 - "pages":[  
3 - "pages/index/index",  
4 - "pages/logs/logs" 2 + "pages": [
  3 + "pages/main/home/home",
  4 + "pages/login/login",
  5 + "pages/getPhone/getPhone"
  6 +
5 ], 7 ],
6 - "window":{  
7 - "backgroundTextStyle":"light",  
8 - "navigationBarBackgroundColor": "#fff", 8 + "window": {
  9 + "backgroundTextStyle": "light",
  10 + "navigationBarBackgroundColor": "#4478e3",
9 "navigationBarTitleText": "WeChat", 11 "navigationBarTitleText": "WeChat",
10 - "navigationBarTextStyle":"black" 12 + "navigationBarTextStyle": "#fff"
11 } 13 }
12 -} 14 +}
@@ -8,3 +8,7 @@ @@ -8,3 +8,7 @@
8 padding: 200rpx 0; 8 padding: 200rpx 0;
9 box-sizing: border-box; 9 box-sizing: border-box;
10 } 10 }
  11 +
  12 +.page{
  13 + background-color: #fff;
  14 +}

989 Bytes

  1 +// pages/getPhone/getPhone.js
  2 +const baseUrl = getApp().globalData.baseUrl;
  3 +let Authorization = '';
  4 +var app = getApp();
  5 +Page({
  6 +
  7 + /**
  8 + * 页面的初始数据
  9 + */
  10 + data: {
  11 +
  12 + },
  13 +
  14 + /**
  15 + * 生命周期函数--监听页面加载
  16 + */
  17 + onLoad: function (options) {
  18 + },
  19 + getPhoneNumber: function (e) {
  20 + const _this = this;
  21 + const iv = e.detail.iv;
  22 + const encryptedData = e.detail.encryptedData;
  23 + console.log('getPhoneNumber' ,e)
  24 + if (e.detail.errMsg == 'getPhoneNumber:fail user deny') {
  25 + wx.showModal({
  26 + title: '提示',
  27 + showCancel: false,
  28 + content: '未授权',
  29 + success: function (res) { }
  30 + })
  31 + } else {
  32 + this.login(iv, encryptedData);
  33 + }
  34 + },
  35 + login: function (iv, phone) {
  36 + var that = this;
  37 + var Authorization = getApp().globalData.Authorization;
  38 + const userInfo = app.globalData.userInfo;
  39 + const { opt, salary_unit,id } = that.data;
  40 + wx.request({
  41 + url: baseUrl + "uaa/v1/users/op/bind-mobile",
  42 + data: {
  43 + "mobile": '13691224349',//必传,随便写一个
  44 + "sms_code": '1234',//必传,随便写一个
  45 + "wx_open_id": app.globalData.wx_open_id, //可选,如果传了,绑定到对应的微信号
  46 + "tenant_id": app.globalData.tenant_id,
  47 + "source": "wx_app::" + phone + ":" + iv,
  48 + "scope": "expert"
  49 + },
  50 + method: "POST",
  51 + header: {
  52 + 'content-type': 'application/json', // 默认值
  53 + "Authorization": Authorization
  54 + },
  55 + success: function (res) {
  56 +
  57 + console.log("succ", res);
  58 + if (200 == res.statusCode) {
  59 + app.globalData.Authorization = "Bearer " + res.data.access_token;
  60 + app.globalData.refresh_token = res.data.refresh_token;
  61 + var user = res.data.user;
  62 + var tenant = res.data.tenant;
  63 + app.globalData.tenant_id = tenant.id;
  64 + app.globalData.userInfo = user;
  65 + app.globalData.wx_open_id = user.wx_open_id;
  66 +
  67 + wx.reLaunch({
  68 + url: '../tabbar/home/home'
  69 + })
  70 +
  71 + } else {
  72 + wx.showToast({
  73 + title: '登录失败,请重新登录',
  74 + })
  75 + }
  76 + },
  77 + fail: function (res) {
  78 + console.log("fail ", res.data)
  79 + },
  80 + complete:function (res){
  81 + wx.reLaunch({
  82 + url: '../tabbar/home/home'
  83 + })
  84 + }
  85 + })
  86 + },
  87 + phoneLogin: function () {
  88 + wx.navigateTo({
  89 + url: '../login/login',
  90 + })
  91 + },
  92 +
  93 +})
  1 +{
  2 + "navigationBarTitleText": "共享服务平台",
  3 + "disableScroll" : true,
  4 + "navigationBarBackgroundColor": "#529CE2"
  5 +
  6 +}
  1 +<!--pages/getPhone/getPhone.wxml-->
  2 +<!-- <button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">获取用户手机号</button> -->
  3 +<view class='page'>
  4 + <image src='/images/bg.jpg' class='back-img' mode="bottom aspectFill"></image>
  5 + <view class='content-wrap'>
  6 + <image src='/images/logo.png' class='logo' mode="aspectFit"></image>
  7 + <button open-type="getPhoneNumber" class='btn' bindgetphonenumber="getPhoneNumber">微信快速授权/登录</button>
  8 + <view class='loginByPhone' bindtap='phoneLogin'>输入手机号登录</view>
  9 + </view>
  10 +
  11 +</view>
  1 +/* pages/getPhone/getPhone.wxss */
  2 +.page{
  3 + height: 100%;
  4 +}
  5 +.back-img{
  6 + position: absolute;
  7 + top: 0px;
  8 + width: 100%;
  9 + height: 100%;
  10 +}
  11 +.content-wrap{
  12 + margin-top: 360rpx;
  13 + width: 100%;
  14 +}
  15 +.logo{
  16 + position: relative;
  17 + top: 0rpx;
  18 + height: 60rpx;
  19 + margin: 10px auto;
  20 + display: block;
  21 +}
  22 +
  23 +.btn{
  24 + background: #FFF;
  25 + color: #529CE2;
  26 + height: 84rpx;
  27 + line-height: 84rpx;
  28 + font-size: 28rpx;
  29 + border-radius: 42rpx;
  30 + margin: 120rpx 60rpx 0 60rpx;
  31 +}
  32 +
  33 +.loginByPhone{
  34 + position: relative;
  35 + text-align: center;
  36 + color: #FFF;
  37 + font-size: 28rpx;
  38 + margin: 40rpx;
  39 +}
1 -//index.js  
2 -//获取应用实例  
3 -const app = getApp()  
4 -  
5 -Page({  
6 - data: {  
7 - motto: 'Hello World',  
8 - userInfo: {},  
9 - hasUserInfo: false,  
10 - canIUse: wx.canIUse('button.open-type.getUserInfo')  
11 - },  
12 - //事件处理函数  
13 - bindViewTap: function() {  
14 - wx.navigateTo({  
15 - url: '../logs/logs'  
16 - })  
17 - },  
18 - onLoad: function () {  
19 - if (app.globalData.userInfo) {  
20 - this.setData({  
21 - userInfo: app.globalData.userInfo,  
22 - hasUserInfo: true  
23 - })  
24 - } else if (this.data.canIUse){  
25 - // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回  
26 - // 所以此处加入 callback 以防止这种情况  
27 - app.userInfoReadyCallback = res => {  
28 - this.setData({  
29 - userInfo: res.userInfo,  
30 - hasUserInfo: true  
31 - })  
32 - }  
33 - } else {  
34 - // 在没有 open-type=getUserInfo 版本的兼容处理  
35 - wx.getUserInfo({  
36 - success: res => {  
37 - app.globalData.userInfo = res.userInfo  
38 - this.setData({  
39 - userInfo: res.userInfo,  
40 - hasUserInfo: true  
41 - })  
42 - }  
43 - })  
44 - }  
45 - },  
46 - getUserInfo: function(e) {  
47 - console.log(e)  
48 - app.globalData.userInfo = e.detail.userInfo  
49 - this.setData({  
50 - userInfo: e.detail.userInfo,  
51 - hasUserInfo: true  
52 - })  
53 - }  
54 -})  
1 -<!--index.wxml-->  
2 -<view class="container">  
3 - <view class="userinfo">  
4 - <button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>  
5 - <block wx:else>  
6 - <image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>  
7 - <text class="userinfo-nickname">{{userInfo.nickName}}</text>  
8 - </block>  
9 - </view>  
10 - <view class="usermotto">  
11 - <text class="user-motto">{{motto}}</text>  
12 - </view>  
13 -</view>  
1 -/**index.wxss**/  
2 -.userinfo {  
3 - display: flex;  
4 - flex-direction: column;  
5 - align-items: center;  
6 -}  
7 -  
8 -.userinfo-avatar {  
9 - width: 128rpx;  
10 - height: 128rpx;  
11 - margin: 20rpx;  
12 - border-radius: 50%;  
13 -}  
14 -  
15 -.userinfo-nickname {  
16 - color: #aaa;  
17 -}  
18 -  
19 -.usermotto {  
20 - margin-top: 200px;  
21 -}  
  1 +//login.js
  2 +const loginUrl = require('../../config').loginUrl;
  3 +//获取应用实例
  4 +var app = getApp();
  5 +var baseUrl = app.globalData.baseUrl;
  6 +
  7 +Page({
  8 + data: {
  9 + mobile: '',
  10 + verifyCode: "",
  11 + tenant_id: "",
  12 + wx_open_id: "",
  13 + verifyCodeTime: "获取验证码",
  14 + buttonDisable: false
  15 + },
  16 +
  17 + mobileInputEvent: function (e) {
  18 + this.setData({
  19 + mobile: e.detail.value
  20 + });
  21 + },
  22 +
  23 + verifyInputEvent: function (e) {
  24 + this.setData({
  25 + verifyCode: e.detail.value
  26 + });
  27 + console.log("verifyCode", this.data.verifyCode);
  28 + },
  29 +
  30 + verifyCodeEvent: function () {
  31 + console.log("buttonDisable", this.data.buttonDisable);
  32 + if (this.data.buttonDisable) return;
  33 + var that = this;
  34 + var mobile = this.data.mobile;
  35 + var regMobile = /^1[3|4|5|7|8][0-9]{9}$/;
  36 + console.log("mobile---", mobile);
  37 + if (!regMobile.test(mobile)) {
  38 + wx.showToast({
  39 + title: '手机号有误!'
  40 + })
  41 + return;
  42 + }
  43 + var timelength = 60
  44 +
  45 + var intervalId = setInterval(function () {
  46 + timelength = timelength - 1;
  47 + that.setData({
  48 + verifyCodeTime: timelength + 's后重发',
  49 + buttonDisable: true
  50 + })
  51 + if (timelength == 0) {
  52 + clearInterval(intervalId);
  53 + that.setData({
  54 + verifyCodeTime: '获取验证码',
  55 + buttonDisable: false
  56 + })
  57 + }
  58 + }, 1000);
  59 + that.getVerifyCode(mobile);
  60 + },
  61 +
  62 + getVerifyCode: function (mobile) {
  63 + var that = this;
  64 + var Authorization = app.globalData.Authorization;
  65 + that.setData({
  66 + tenant_id: app.globalData.tenant_id,
  67 + wx_open_id: app.globalData.wx_open_id
  68 + })
  69 + wx.request({
  70 + url: baseUrl + 'sms/v1/sms_codes',
  71 + method: "POST",
  72 + data: {
  73 + "mobile": mobile,
  74 + "type": "bindmobile",
  75 + "scope": "global_access:expert"
  76 + },
  77 + header: {
  78 + 'content-type': 'application/json', // 默认值
  79 + "Authorization": Authorization
  80 + },
  81 + success: function (res) {
  82 + console.log(res.data)
  83 + },
  84 + fail(res) {
  85 + console.log(res.data)
  86 + }
  87 + })
  88 + },
  89 +
  90 + login: function () {
  91 + var that = this;
  92 + var Authorization = getApp().globalData.Authorization;
  93 + wx.request({
  94 + url: baseUrl + "uaa/v1/users/op/bind-mobile",
  95 + data: {
  96 + "mobile": that.data.mobile,
  97 + "sms_code": that.data.verifyCode,
  98 + "wx_open_id": that.data.wx_open_id, //可选,如果传了,绑定到对应的微信号
  99 + "tenant_id": that.data.tenant_id,
  100 + "source": "wx_app",
  101 + "scope": "expert"
  102 + },
  103 + method: "POST",
  104 + header: {
  105 + 'content-type': 'application/json', // 默认值
  106 + "Authorization": Authorization
  107 + },
  108 + success: function (res) {
  109 + console.log("succ", res);
  110 + if (200 == res.statusCode) {
  111 + app.globalData.Authorization = "Bearer " + res.data.access_token;
  112 + app.globalData.refresh_token = res.data.refresh_token;
  113 + var user = res.data.user;
  114 + var tenant = res.data.tenant;
  115 + app.globalData.tenant_id = tenant.id;
  116 + app.globalData.userInfo = user;
  117 + app.globalData.wx_open_id = user.wx_open_id;
  118 +
  119 + wx.reLaunch({
  120 + url: '../tabbar/home/home'
  121 + })
  122 + } else {
  123 + wx.showToast({
  124 + title: '请重新登录',
  125 + })
  126 + }
  127 + },
  128 + fail: function (res) {
  129 + console.log("fail ", res.data)
  130 + },
  131 + complete: function (res) {
  132 + wx.reLaunch({
  133 + url: '../tabbar/home/home'
  134 + })
  135 + }
  136 + })
  137 + },
  138 +
  139 + onLoad: function () {
  140 +
  141 + }
  142 +})
  1 +{
  2 + "navigationBarTitleText": "共享服务平台",
  3 + "disableScroll": true,
  4 + "navigationBarBackgroundColor": "#529CE2"
  5 +}
  1 +<!--pages/login/login.wxml-->
  2 +<view class="page">
  3 + <image src='/images/bg.jpg' class='back-img' mode="bottom aspectFill"></image>
  4 + <view class='content-wrap'>
  5 + <image src='/images/logo.png' class='logo' mode="aspectFit"></image>
  6 + <view class="data_item">
  7 + <image src='/images/user_name.png' class='icon' mode="aspectFit"></image>
  8 + <view class='input-wrap'>+86
  9 + <input class="text-area" style='margin-left:20rpx;' bindinput="mobileInputEvent" name="mobile" type="number" placeholder='请输入手机号' placeholder-class='pl-class'></input>
  10 + </view>
  11 + </view>
  12 + <view class="data_item">
  13 + <image src='/images/user_pwd.png' class='icon' mode="aspectFit"></image>
  14 + <view class='input-wrap' style='width:180rpx;'>
  15 + <input class="text-area" name="verify_code" bindinput="verifyInputEvent" placeholder='短信验证码' placeholder-class='pl-class'></input>
  16 + </view>
  17 + <button class="code-btn" bindtap="verifyCodeEvent" disabled="{{buttonDisable}}">{{verifyCodeTime}}</button>
  18 +
  19 + </view>
  20 +
  21 + <view >
  22 + <button class="btn" bindtap="login">登 录</button>
  23 + </view>
  24 + </view>
  25 +
  26 +
  27 +</view>
  1 +/* pages/login/login.wxss */
  2 + @import "../getPhone/getPhone.wxss";
  3 +.data_item{
  4 + position: relative;
  5 + height: 120rpx;
  6 + color: #fff;
  7 + margin: 0 120rpx;
  8 + display: flex;
  9 + border-bottom: 2rpx solid #FFF;
  10 +}
  11 +.pl-class{
  12 + color: #FFF;
  13 + font-size: 28rpx;
  14 +}
  15 +.icon{
  16 + position: absolute;
  17 + width: 32rpx;
  18 + height: 36rpx;
  19 + padding: 42rpx 44rpx ;
  20 +}
  21 +.input-wrap{
  22 + display: flex;
  23 + line-height: 120rpx;
  24 + margin-left: 120rpx;
  25 +}
  26 +.text-area{
  27 + font-size:28rpx;
  28 + margin: auto 0;
  29 + display: flex;
  30 +}
  31 +.code-btn{
  32 + position: absolute;
  33 + color:#529CE2;
  34 + font-size: 28rpx;
  35 + border-radius: 32rpx;
  36 + height: 64rpx;
  37 + right: 0;
  38 + bottom: 28rpx;
  39 +}
  40 +
  41 +
1 -//logs.js  
2 -const util = require('../../utils/util.js')  
3 -  
4 -Page({  
5 - data: {  
6 - logs: []  
7 - },  
8 - onLoad: function () {  
9 - this.setData({  
10 - logs: (wx.getStorageSync('logs') || []).map(log => {  
11 - return util.formatTime(new Date(log))  
12 - })  
13 - })  
14 - }  
15 -})  
1 -<!--logs.wxml-->  
2 -<view class="container log-list">  
3 - <block wx:for="{{logs}}" wx:for-item="log">  
4 - <text class="log-item">{{index + 1}}. {{log}}</text>  
5 - </block>  
6 -</view>  
1 -.log-list {  
2 - display: flex;  
3 - flex-direction: column;  
4 - padding: 40rpx;  
5 -}  
6 -.log-item {  
7 - margin: 10rpx;  
8 -}  
  1 +// pages/home/home.js
  2 +Page({
  3 +
  4 + /**
  5 + * 页面的初始数据
  6 + */
  7 + data: {
  8 + list:["",""]
  9 + },
  10 +
  11 + /**
  12 + * 生命周期函数--监听页面加载
  13 + */
  14 + onLoad: function (options) {
  15 +
  16 + },
  17 +
  18 + /**
  19 + * 生命周期函数--监听页面初次渲染完成
  20 + */
  21 + onReady: function () {
  22 +
  23 + },
  24 +
  25 + /**
  26 + * 生命周期函数--监听页面显示
  27 + */
  28 + onShow: function () {
  29 +
  30 + },
  31 +
  32 + /**
  33 + * 生命周期函数--监听页面隐藏
  34 + */
  35 + onHide: function () {
  36 +
  37 + },
  38 +
  39 + /**
  40 + * 生命周期函数--监听页面卸载
  41 + */
  42 + onUnload: function () {
  43 +
  44 + },
  45 +
  46 + /**
  47 + * 页面相关事件处理函数--监听用户下拉动作
  48 + */
  49 + onPullDownRefresh: function () {
  50 +
  51 + },
  52 +
  53 + /**
  54 + * 页面上拉触底事件的处理函数
  55 + */
  56 + onReachBottom: function () {
  57 +
  58 + },
  59 +
  60 + /**
  61 + * 用户点击右上角分享
  62 + */
  63 + onShareAppMessage: function () {
  64 +
  65 + }
  66 +})
1 { 1 {
2 - "navigationBarTitleText": "查看启动日志" 2 + "navigationBarTitleText": "自然人税收"
3 } 3 }
  1 +<view class='page'>
  2 +
  3 + <view wx:if="{{list.length>0}}">
  4 + <block wx:for="{{list}}" wx:key="">
  5 + <view class='rectangle_solid_bg'>
  6 + <view style='padding:22rpx'>
  7 + <text class='text_black_28'>小爱同学</text>
  8 + <text class='rectangle_orange_bg text_red_20'>子女</text>
  9 + <text class='text_blue_28'>去完善</text>
  10 + <image class='arrow_wrap' src='/images/arrow_right.png'> </image>
  11 + </view>
  12 + <view style='padding:22rpx'>
  13 + <image class='phone_image_wrap'src='/images/phone.png'></image>
  14 + <text class='text_999_22'>130****8888</text>
  15 +<text style='margin:0rpx 20rpx;color:#999;height:16rpx'>|</text>
  16 + <image class='id_image_wrap'src='/images/id.png'></image>
  17 + <text class='text_999_22'>152000********0000</text>
  18 + </view>
  19 + </view>
  20 + </block>
  21 + </view>
  22 +
  23 + <view class='rectangle_dashed_bg'>
  24 + <view class='text_blue_28'>
  25 + 十 添加家庭成员
  26 + </view>
  27 + </view>
  28 +
  29 +</view>
  1 +/* pages/home/home.wxss */
  2 +
  3 +.rectangle_solid_bg {
  4 + margin: 20rpx 32rpx;
  5 + background: #fff;
  6 + box-shadow: 0 8rpx 28rpx 0 rgba(208, 208, 208, 0.50);
  7 + border-radius: 8rpx;
  8 +}
  9 +
  10 +.rectangle_dashed_bg {
  11 + height: 68rpx;
  12 + margin: 40rpx 32rpx;
  13 + background: #fff;
  14 + border-style: dashed;
  15 + border: 2rpx solid #d7e4fb;
  16 + border-radius: 8rpx;
  17 +}
  18 +
  19 +.rectangle_orange_bg {
  20 + height: 32rpx;
  21 + margin: 0rpx 20rpx;
  22 + opacity: 0.5;
  23 +background: #F9DCD6;
  24 +border-radius: 2px;
  25 +}
  26 +
  27 +.text_red_20 {
  28 + font-family: PingFang-SC-Medium;
  29 + font-size: 20rpx;
  30 + padding: 14rpx;
  31 + text-align: center;
  32 + color: #FF7052;
  33 + letter-spacing: 0;
  34 +}
  35 +
  36 +.text_blue_28 {
  37 + font-family: PingFang-SC-Medium;
  38 + font-size: 28rpx;
  39 + padding: 14rpx;
  40 + text-align: center;
  41 + color: #357aeb;
  42 + letter-spacing: 0;
  43 +}
  44 +
  45 +.text_black_28 {
  46 + font-family: PingFangSC-Regular;
  47 + font-size: 28rpx;
  48 + color: #000;
  49 + line-height: 40rpx;
  50 +}
  51 +
  52 +.text_999_22 {
  53 + font-family: PingFangSC-Regular;
  54 + font-size: 22rpx;
  55 + color: #999;
  56 +}
  57 +
  58 +.arrow_wrap {
  59 + width: 12rpx;
  60 + height: 20rpx;
  61 +}
  62 +
  63 +.phone_image_wrap {
  64 + width: 22rpx;
  65 + height: 20rpx;
  66 + margin-right:12rpx;
  67 +}
  68 +
  69 +.id_image_wrap {
  70 + width: 30rpx;
  71 + height: 20rpx;
  72 + margin-right:12rpx;
  73 +}
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 "ignore": [] 4 "ignore": []
5 }, 5 },
6 "setting": { 6 "setting": {
7 - "urlCheck": true, 7 + "urlCheck": false,
8 "es6": true, 8 "es6": true,
9 "postcss": true, 9 "postcss": true,
10 "minified": true, 10 "minified": true,
1 -const formatTime = date => {  
2 - const year = date.getFullYear()  
3 - const month = date.getMonth() + 1  
4 - const day = date.getDate()  
5 - const hour = date.getHours()  
6 - const minute = date.getMinutes()  
7 - const second = date.getSeconds() 1 +function formatTime(date) {
  2 + var year = date.getFullYear()
  3 + var month = date.getMonth() + 1
  4 + var day = date.getDate()
8 5
9 - return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':') 6 + var hour = date.getHours()
  7 + var minute = date.getMinutes()
  8 + var second = date.getSeconds()
  9 +
  10 + return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute].map(formatNumber).join(':')
10 } 11 }
11 12
12 -const formatNumber = n => { 13 +function formatNumber(n) {
13 n = n.toString() 14 n = n.toString()
14 return n[1] ? n : '0' + n 15 return n[1] ? n : '0' + n
15 } 16 }
16 17
  18 +function formatDateString(dateStr) {
  19 + var date = new Date()
  20 + date.setTime(dateStr * 1000)
  21 + var newDate = this.formatTime(date)
  22 + return newDate
  23 +}
  24 +function yearFormString(dateStr) {
  25 + var date = new Date()
  26 + date.setTime(dateStr * 1000)
  27 + var year = date.getFullYear()
  28 + return year
  29 +}
  30 +function monthFormString(dateStr) {
  31 + var date = new Date()
  32 + date.setTime(dateStr * 1000)
  33 + var month = date.getMonth() + 1
  34 + return month
  35 +}
  36 +function dayFormString(dateStr) {
  37 + var date = new Date()
  38 + date.setTime(dateStr * 1000)
  39 + var day = date.getDate()
  40 + return day
  41 +}
  42 +
  43 +/**
  44 + * 检验18位身份证号码(15位号码可以只检测生日是否正确即可)
  45 + * @author wolfchen
  46 + * @param idCardNo 18为的身份证号码
  47 + * @return Boolean 是否合法
  48 + **/
  49 +function isIDCardNum(idCardNo) {
  50 + var regID_18 = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
  51 + var regID_15 = /^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$/;
  52 + var arrExp = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];//加权因子
  53 + var arrValid = [1, 0, "X", 9, 8, 7, 6, 5, 4, 3, 2];//校验码
  54 + if (regID_15.test(idCardNo)) {
  55 + return true;
  56 + } else if (regID_18.test(idCardNo)) {
  57 + var sum = 0, idx;
  58 + for (var i = 0; i < idCardNo.length - 1; i++) {
  59 + // 对前17位数字与权值乘积求和
  60 + sum += parseInt(idCardNo.substr(i, 1), 10) * arrExp[i];
  61 + }
  62 + // 计算模(固定算法)
  63 + idx = sum % 11;
  64 + // 检验第18为是否与校验码相等
  65 + return arrValid[idx] == idCardNo.substr(17, 1).toUpperCase();
  66 + } else {
  67 + return false;
  68 + }
  69 +}
  70 +
17 module.exports = { 71 module.exports = {
18 - formatTime: formatTime 72 + formatTime: formatTime,
  73 + formatDateString: formatDateString,
  74 + yearFormString: yearFormString,
  75 + monthFormString: monthFormString,
  76 + dayFormString: dayFormString,
  77 + udekapi: udekapi,
  78 + isIDCardNum: isIDCardNum
19 } 79 }
注册登录 后发表评论