Commit 177ece15645952831fc2192298d09dd6b8c96ba5
0 parents
Exists in
master
1.0
Showing 40 changed files with 1694 additions and 0 deletions
- jiandang/app.js
- jiandang/app.json
- jiandang/app.wxss
- jiandang/pages/createDocumentList/createDocumentList.js
- jiandang/pages/createDocumentList/createDocumentList.json
- jiandang/pages/createDocumentList/createDocumentList.wxml
- jiandang/pages/createDocumentList/createDocumentList.wxss
- jiandang/pages/home/home.js
- jiandang/pages/home/home.json
- jiandang/pages/home/home.wxml
- jiandang/pages/home/home.wxss
- jiandang/pages/index/index.js
- jiandang/pages/index/index.json
- jiandang/pages/index/index.wxml
- jiandang/pages/index/index.wxss
- jiandang/pages/login/login.js
- jiandang/pages/login/login.json
- jiandang/pages/login/login.wxml
- jiandang/pages/login/login.wxss
- jiandang/pages/logs/logs.js
- jiandang/pages/logs/logs.json
- jiandang/pages/logs/logs.wxml
- jiandang/pages/logs/logs.wxss
- jiandang/pages/personDetail/personDetail.js
- jiandang/pages/personDetail/personDetail.json
- jiandang/pages/personDetail/personDetail.wxml
- jiandang/pages/personDetail/personDetail.wxss
- jiandang/pages/register/register.js
- jiandang/pages/register/register.json
- jiandang/pages/register/register.wxml
- jiandang/pages/register/register.wxss
- jiandang/pages/resetPassword/resetPassword.js
- jiandang/pages/resetPassword/resetPassword.json
- jiandang/pages/resetPassword/resetPassword.wxml
- jiandang/pages/resetPassword/resetPassword.wxss
- jiandang/project.config.json
- jiandang/utils/apiFile.js
- jiandang/utils/image/icon.png
- jiandang/utils/network_util.js
- jiandang/utils/util.js
jiandang/app.js
View file @
177ece1
| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | +//app.js | |
| 2 | +App({ | |
| 3 | + onLaunch: function (option) { | |
| 4 | + console.log('app_options:', option) | |
| 5 | + var that = this | |
| 6 | + //调用API从本地缓存中获取数据 | |
| 7 | + var userToken = wx.getStorageSync('userToken') | |
| 8 | + console.log('userToken,',userToken) | |
| 9 | + this.globalData.token = userToken || '' | |
| 10 | + // wx.setStorageSync('hospitalId', '2100001700') | |
| 11 | + if (option.query) { | |
| 12 | + if (option.query.mpid) { | |
| 13 | + wx.setStorageSync('mpid', option.query.mpid) | |
| 14 | + } | |
| 15 | + if (option.query.hospitalId) { | |
| 16 | + wx.setStorageSync('hospitalId', option.query.hospitalId) | |
| 17 | + } | |
| 18 | + } | |
| 19 | + this.globalData.openInfo.mpid = wx.getStorageSync('mpid') | |
| 20 | + this.globalData.openInfo.hospitalId = wx.getStorageSync('hospitalId') | |
| 21 | + }, | |
| 22 | + globalData: { | |
| 23 | + openInfo:{}, | |
| 24 | + token:'' | |
| 25 | + } | |
| 26 | +}) | |
| 0 | 27 | \ No newline at end of file |
jiandang/app.json
View file @
177ece1
| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | +{ | |
| 2 | + "pages":[ | |
| 3 | + "pages/home/home", | |
| 4 | + "pages/index/index", | |
| 5 | + "pages/resetPassword/resetPassword", | |
| 6 | + "pages/personDetail/personDetail", | |
| 7 | + "pages/createDocumentList/createDocumentList", | |
| 8 | + | |
| 9 | + "pages/register/register", | |
| 10 | + "pages/logs/logs" | |
| 11 | + ], | |
| 12 | + "window":{ | |
| 13 | + "backgroundTextStyle":"light", | |
| 14 | + "navigationBarBackgroundColor": "#fff", | |
| 15 | + "navigationBarTitleText": "WeChat", | |
| 16 | + "navigationBarTextStyle":"black" | |
| 17 | + } | |
| 18 | +} |
jiandang/app.wxss
View file @
177ece1
| ... | ... | @@ -0,0 +1,45 @@ |
| 1 | +/**app.wxss**/ | |
| 2 | +.container { | |
| 3 | + height: 100%; | |
| 4 | + display: flex; | |
| 5 | + flex-direction: column; | |
| 6 | + align-items: center; | |
| 7 | + justify-content: space-between; | |
| 8 | + padding: 200rpx 0; | |
| 9 | + box-sizing: border-box; | |
| 10 | +} | |
| 11 | + | |
| 12 | +page { | |
| 13 | + width: 100%; | |
| 14 | + height: 100%; | |
| 15 | +} | |
| 16 | + | |
| 17 | +.placeholder { | |
| 18 | + color: #C6C6C8; | |
| 19 | + font-size: 16px; | |
| 20 | +} | |
| 21 | + | |
| 22 | +.themeColor { | |
| 23 | + background: #477DEB; | |
| 24 | +} | |
| 25 | + | |
| 26 | +.hover_color { | |
| 27 | + background: #C6C6C8; | |
| 28 | +} | |
| 29 | + | |
| 30 | +.hover_color_text { | |
| 31 | + color: #C6C6C8; | |
| 32 | +} | |
| 33 | + | |
| 34 | +.bottom_line { | |
| 35 | + border-bottom: solid 1px #E6E6E8; | |
| 36 | +} | |
| 37 | + | |
| 38 | +.loadMoreView { | |
| 39 | + height: 20px; | |
| 40 | + text-align: center; | |
| 41 | + font-size: 12px; | |
| 42 | + width: 100%; | |
| 43 | + background:white; | |
| 44 | + color: rgb(22, 22, 22) | |
| 45 | +} | |
| 0 | 46 | \ No newline at end of file |
jiandang/pages/createDocumentList/createDocumentList.js
View file @
177ece1
| ... | ... | @@ -0,0 +1,125 @@ |
| 1 | +// pages/createDocumentList/createDocumentList.js | |
| 2 | +const networkUtil = require('../../utils/network_util.js') | |
| 3 | +const api = require('../../utils/apiFile.js') | |
| 4 | + | |
| 5 | +var page = 1 | |
| 6 | +// 是否有更多 | |
| 7 | +var hasMore | |
| 8 | +var isRefresh | |
| 9 | + | |
| 10 | +Page({ | |
| 11 | + | |
| 12 | + /** | |
| 13 | + * 页面的初始数据 | |
| 14 | + */ | |
| 15 | + data: { | |
| 16 | + selectArr: [{ title: '预约建档', index: 0 }, { title: '预约成功', index: 1 }], | |
| 17 | + sucList: [], | |
| 18 | + buildList:[], | |
| 19 | + currentIndex:0, | |
| 20 | + hasMore:false, | |
| 21 | + cDate:'' | |
| 22 | + }, | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 生命周期函数--监听页面加载 | |
| 26 | + */ | |
| 27 | + onLoad: function (options) { | |
| 28 | + hasMore = true | |
| 29 | + isRefresh = false | |
| 30 | + var date = new Date() | |
| 31 | + this.data.cDate = { year:date.getFullYear(), month: date.getMonth() + 1} | |
| 32 | + this.requestBuildList() | |
| 33 | + }, | |
| 34 | + clickBar(e){ | |
| 35 | + this.setData({ | |
| 36 | + currentIndex: e.target.dataset.index | |
| 37 | + }) | |
| 38 | + if (e.target.dataset.index == 1 && this.data.sucList.length == 0){ | |
| 39 | + isRefresh = false | |
| 40 | + this.requestSuccessList() | |
| 41 | + } | |
| 42 | + }, | |
| 43 | + // 加载更多 | |
| 44 | + loadMore: function (e) { | |
| 45 | + if (isRefresh == true) { | |
| 46 | + return | |
| 47 | + } | |
| 48 | + this.loadData(this.data.currentIndex) | |
| 49 | + }, | |
| 50 | + myScroll: function (e) { | |
| 51 | + if (e.detail.scrollTop >= e.detail.scrollHeight - wx.getSystemInfoSync().windowHeight - 3) { | |
| 52 | + this.loadMore() | |
| 53 | + } | |
| 54 | + }, | |
| 55 | + loadData(index){ | |
| 56 | + if (index == 0) { | |
| 57 | + if (!hasMore) { | |
| 58 | + return | |
| 59 | + } | |
| 60 | + page++ | |
| 61 | + this.requestBuildList() | |
| 62 | + } else { | |
| 63 | + this.data.cDate.month = this.data.cDate.month - 1 | |
| 64 | + if (this.data.cDate.month == 0) { | |
| 65 | + this.data.cDate.year = this.data.cDate.year - 1 | |
| 66 | + this.data.cDate.month = 12 | |
| 67 | + } | |
| 68 | + console.log('当前时间', this.data.cDate) | |
| 69 | + this.requestSuccessList() | |
| 70 | + } | |
| 71 | + }, | |
| 72 | + tapmore(){ | |
| 73 | + this.loadData(this.data.currentIndex) | |
| 74 | + }, | |
| 75 | + // ------------------网络请求------------------ | |
| 76 | + requestSuccessList(){ | |
| 77 | + networkUtil.showLoading() | |
| 78 | + var self = this | |
| 79 | + isRefresh = true | |
| 80 | + networkUtil._get(api.ArchiveSuccessList, { hospitalId: getApp().globalData.openInfo.hospitalId, month: this.data.cDate.year + '-' + this.data.cDate.month + ''}, function (res) { | |
| 81 | + console.log(res) | |
| 82 | + isRefresh = false | |
| 83 | + var arr = self.data.sucList | |
| 84 | + var temp = {} | |
| 85 | + temp['date'] = self.data.cDate.year + '年' + self.data.cDate.month + '月' | |
| 86 | + temp['data'] = res.data.data | |
| 87 | + console.log('temp', temp) | |
| 88 | + arr.push(temp) | |
| 89 | + self.setData({ | |
| 90 | + sucList: arr | |
| 91 | + }) | |
| 92 | + }, function (res) { | |
| 93 | + isRefresh = false | |
| 94 | + networkUtil.showErrorToast(res.errormsg) | |
| 95 | + }) | |
| 96 | + }, | |
| 97 | + requestBuildList() { | |
| 98 | + var self = this | |
| 99 | + networkUtil.showLoading() | |
| 100 | + networkUtil._get(api.ArchiveBuildList, { hospitalId: getApp().globalData.openInfo.hospitalId,page:page,limit:15}, function (res) { | |
| 101 | + console.log(res) | |
| 102 | + isRefresh = false | |
| 103 | + var arr = [] | |
| 104 | + if (page > 0) {// 加载更多模式 | |
| 105 | + arr = self.data.buildList | |
| 106 | + } | |
| 107 | + if (res.data.data.length < 15) { | |
| 108 | + hasMore = false | |
| 109 | + } | |
| 110 | + arr = arr.concat(res.data.data) | |
| 111 | + self.setData({ | |
| 112 | + buildList: arr, | |
| 113 | + hasMore: hasMore | |
| 114 | + }) | |
| 115 | + }, function (res) { | |
| 116 | + | |
| 117 | + networkUtil.showErrorToast(res.errormsg) | |
| 118 | + }) | |
| 119 | + }, | |
| 120 | + toDetail(e){ | |
| 121 | + wx.navigateTo({ | |
| 122 | + url:'../personDetail/personDetail' | |
| 123 | + }) | |
| 124 | + } | |
| 125 | +}) | |
| 0 | 126 | \ No newline at end of file |
jiandang/pages/createDocumentList/createDocumentList.json
View file @
177ece1
jiandang/pages/createDocumentList/createDocumentList.wxml
View file @
177ece1
| ... | ... | @@ -0,0 +1,29 @@ |
| 1 | +<view class='select_bar' style='background:white'> | |
| 2 | + <view class='select_item' style='{{currentIndex == index ? "border-bottom: solid 2px #477DEB;" : "border-bottom: none" }}' wx:for="{{selectArr}}" wx:key="index" data-index='{{index}}' bindtap='clickBar'>{{item.title}}</view> | |
| 3 | +</view> | |
| 4 | +<scroll-view scroll-y="true" class='scroll_view' bindscroll="myScroll"> | |
| 5 | + <view class='info_bar'> | |
| 6 | + <view>姓名</view> | |
| 7 | + <view>手机号</view> | |
| 8 | + <view>日期</view> | |
| 9 | + </view> | |
| 10 | + <view wx:if="{{currentIndex == 0}}"> | |
| 11 | + <navigator class='info_bar bottom_line' wx:for="{{buildList}}" wx:key="index" url='../personDetail/personDetail?archiveId={{item.archiveId}}'> | |
| 12 | + <view>{{item.userName}}</view> | |
| 13 | + <view>{{item.phone}}</view> | |
| 14 | + <view>{{item.date}}</view> | |
| 15 | + </navigator> | |
| 16 | + </view> | |
| 17 | + <view wx:else> | |
| 18 | + <view wx:for="{{sucList}}" wx:for-item="sucItem"> | |
| 19 | + <view class='date_bar'>{{sucItem.date}}</view> | |
| 20 | + <navigator class='info_bar bottom_line' url='../personDetail/personDetail?archiveId={{item.archiveId}}' wx:for="{{sucItem.data}}" wx:key="index"> | |
| 21 | + <view>{{item.userName}}</view> | |
| 22 | + <view>{{item.phone}}</view> | |
| 23 | + <view>{{item.date}}</view> | |
| 24 | + </navigator> | |
| 25 | + <view class='noData' wx:if="{{sucItem.data.length == 0}}">当月没有数据</view> | |
| 26 | + </view> | |
| 27 | + </view> | |
| 28 | + <view class="loadMoreView" wx:if="{{hasMore || currentIndex == 1}}" bindtap='tapmore'>加载更多...</view> | |
| 29 | +</scroll-view> |
jiandang/pages/createDocumentList/createDocumentList.wxss
View file @
177ece1
| ... | ... | @@ -0,0 +1,71 @@ |
| 1 | +page { | |
| 2 | + background: #efefef; | |
| 3 | +} | |
| 4 | + | |
| 5 | +.select_bar { | |
| 6 | + position: fixed; | |
| 7 | + top: 0px; | |
| 8 | + left: 0px; | |
| 9 | + height: 44px; | |
| 10 | + width: 100%; | |
| 11 | + z-index: 10; | |
| 12 | +} | |
| 13 | + | |
| 14 | +.select_item { | |
| 15 | + height: 41px; | |
| 16 | + margin-left: 15px; | |
| 17 | + margin-right: 15px; | |
| 18 | + font-size: 16px; | |
| 19 | + color: #141B31; | |
| 20 | + line-height: 44px; | |
| 21 | + display: inline-block; | |
| 22 | +} | |
| 23 | + | |
| 24 | +.scroll_view { | |
| 25 | + margin-top:48px; | |
| 26 | + background:#efefef; | |
| 27 | + height: calc(100% - 48px); | |
| 28 | +} | |
| 29 | + | |
| 30 | +.info_bar { | |
| 31 | + height: 44px; | |
| 32 | + display: flex; | |
| 33 | + font-size: 14px; | |
| 34 | + color: #ADADAD; | |
| 35 | + text-align: center; | |
| 36 | + line-height: 44px; | |
| 37 | + background: white; | |
| 38 | + padding-left: 15px; | |
| 39 | +} | |
| 40 | + | |
| 41 | +.date_bar { | |
| 42 | + font-size: 16px; | |
| 43 | + color: #141B31; | |
| 44 | + height: 36px; | |
| 45 | + background: #EFEFEF; | |
| 46 | + line-height: 36px; | |
| 47 | + padding-left: 15px; | |
| 48 | +} | |
| 49 | + | |
| 50 | +.info_bar view:nth-child(1) { | |
| 51 | + flex: 2; | |
| 52 | + text-align: left; | |
| 53 | +} | |
| 54 | + | |
| 55 | +.info_bar view:nth-child(2) { | |
| 56 | + flex: 4; | |
| 57 | + text-align: left; | |
| 58 | +} | |
| 59 | + | |
| 60 | +.info_bar view:nth-child(3) { | |
| 61 | + flex: 3; | |
| 62 | + text-align: left; | |
| 63 | +} | |
| 64 | + | |
| 65 | +.noData { | |
| 66 | + height: 45px; | |
| 67 | + padding-left: 15px; | |
| 68 | + line-height: 45px; | |
| 69 | + background: white | |
| 70 | +} | |
| 71 | + |
jiandang/pages/home/home.js
View file @
177ece1
| ... | ... | @@ -0,0 +1,207 @@ |
| 1 | +// pages/home/home.js | |
| 2 | +import { loginPage } from "../login/login.js" | |
| 3 | +const app = getApp() | |
| 4 | +const networkUtil = require('../../utils/network_util.js') | |
| 5 | +const api = require('../../utils/apiFile.js') | |
| 6 | +var QR_Scare = 2 | |
| 7 | + | |
| 8 | +Page(Object.assign({}, loginPage, { | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * 页面的初始数据 | |
| 12 | + */ | |
| 13 | + data: { | |
| 14 | + // 1首页 2登录 | |
| 15 | + pageType:0, | |
| 16 | + areaName: app.globalData.openInfo.hospitalName || '', | |
| 17 | + imageUrl:'', | |
| 18 | + info:{} | |
| 19 | + }, | |
| 20 | + /** | |
| 21 | + * 生命周期函数--监听页面加载 | |
| 22 | + */ | |
| 23 | + onLoad: function (option) { | |
| 24 | + console.log('home_options:', option) | |
| 25 | + if (app.globalData.token) { | |
| 26 | + this.homePage() | |
| 27 | + this.requestHomeInfo() | |
| 28 | + } else { | |
| 29 | + this.loginPage() | |
| 30 | + } | |
| 31 | + }, | |
| 32 | + onPullDownRefresh(){ | |
| 33 | + console.log('onPullDownRefresh') | |
| 34 | + if (app.globalData.token) { | |
| 35 | + this.requestHomeInfo() | |
| 36 | + } | |
| 37 | + }, | |
| 38 | + homePage(){ | |
| 39 | + this.setData({ | |
| 40 | + pageType: 1 | |
| 41 | + }) | |
| 42 | + wx.setNavigationBarColor({ | |
| 43 | + frontColor: '#ffffff', | |
| 44 | + backgroundColor: '#477DEB' | |
| 45 | + }) | |
| 46 | + wx.setNavigationBarTitle({ | |
| 47 | + title: '基层辅助孕妇建档平台', | |
| 48 | + }) | |
| 49 | + }, | |
| 50 | + loginPage(){ | |
| 51 | + this.setData({ | |
| 52 | + pageType: 2 | |
| 53 | + }) | |
| 54 | + wx.setNavigationBarColor({ | |
| 55 | + frontColor: '#000000', | |
| 56 | + backgroundColor: '#ffffff' | |
| 57 | + }) | |
| 58 | + wx.setNavigationBarTitle({ | |
| 59 | + title: '', | |
| 60 | + }) | |
| 61 | + }, | |
| 62 | + // --------------------------首页-------------------------- | |
| 63 | + requestHomeInfo(){ | |
| 64 | + var self = this | |
| 65 | + networkUtil.showLoading() | |
| 66 | + networkUtil._get(api.BuildCountInfo, { hospitalId: app.globalData.openInfo.hospitalId}, function (res) { | |
| 67 | + console.log(res) | |
| 68 | + self.setData({ | |
| 69 | + info:res.data.data, | |
| 70 | + imageUrl: 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=' + res.data.data.ticket | |
| 71 | + }) | |
| 72 | + self.setQRImage() | |
| 73 | + }, function (res) { | |
| 74 | + networkUtil.showErrorToast(res.errormsg) | |
| 75 | + self.setQRImage() | |
| 76 | + }) | |
| 77 | + }, | |
| 78 | + logout() { | |
| 79 | + var self = this | |
| 80 | + wx.showModal({ | |
| 81 | + title: '提示', | |
| 82 | + content: '是否退出登录?', | |
| 83 | + success: function (res) { | |
| 84 | + if (res.confirm) { | |
| 85 | + wx.setStorageSync('userToken', '') | |
| 86 | + wx.setStorageSync('QR_FilePath', '') | |
| 87 | + app.globalData.token = '' | |
| 88 | + self.loginPage() | |
| 89 | + } else if (res.cancel) { | |
| 90 | + | |
| 91 | + } | |
| 92 | + } | |
| 93 | + }) | |
| 94 | + }, | |
| 95 | + longTapImage() { | |
| 96 | + var self = this | |
| 97 | + wx.showActionSheet({ | |
| 98 | + itemList: ['查看大图'], | |
| 99 | + success: function (res) { | |
| 100 | + console.log('111', res) | |
| 101 | + if (res.tapIndex == 0) { | |
| 102 | + console.log('111', res.tapIndex) | |
| 103 | + wx.previewImage({ | |
| 104 | + urls: [self.data.imageUrl], | |
| 105 | + }) | |
| 106 | + } | |
| 107 | + }, | |
| 108 | + fail: function (res) { | |
| 109 | + console.log(res.errMsg) | |
| 110 | + } | |
| 111 | + }) | |
| 112 | + }, | |
| 113 | + // 二维码相关 | |
| 114 | + setQRImage() { | |
| 115 | + var fileP = wx.getStorageSync('QR_FilePath') | |
| 116 | + if (fileP) { | |
| 117 | + this.drawQR(fileP) | |
| 118 | + this.data.imageUrl = fileP | |
| 119 | + console.log('已经有了', fileP) | |
| 120 | + } else { | |
| 121 | + this.downLoadQR() | |
| 122 | + } | |
| 123 | + }, | |
| 124 | + downLoadQR() { | |
| 125 | + networkUtil.showLoading('获取二维码中') | |
| 126 | + var self = this | |
| 127 | + wx.downloadFile({ | |
| 128 | + url: self.data.imageUrl, | |
| 129 | + success: function (res) { | |
| 130 | + if (res.statusCode === 200) { | |
| 131 | + wx.setStorageSync('QR_FilePath', res.tempFilePath) | |
| 132 | + self.drawQR(res.tempFilePath) | |
| 133 | + // setTimeout(function () { | |
| 134 | + // 延迟等绘制完保存成图片 | |
| 135 | + // wx.canvasToTempFilePath({ | |
| 136 | + // x: 0, | |
| 137 | + // y: 0, | |
| 138 | + // width: 174, | |
| 139 | + // height: 174, | |
| 140 | + // destWidth: 696, | |
| 141 | + // destHeight: 696, | |
| 142 | + // canvasId: 'QR_canvas', | |
| 143 | + // quality: 1, | |
| 144 | + // success: function (res) { | |
| 145 | + // console.log('成功:', res.tempFilePath) | |
| 146 | + // wx.setStorageSync('QR_FilePath', res.tempFilePath) | |
| 147 | + // self.data.imageUrl = res.tempFilePath | |
| 148 | + // } | |
| 149 | + // }) | |
| 150 | + // }, 3500) | |
| 151 | + } | |
| 152 | + }, | |
| 153 | + fail: function () { | |
| 154 | + networkUtil.showErrorToast('未加载出二维码,请下拉刷新页面') | |
| 155 | + }, | |
| 156 | + complete: function () { | |
| 157 | + wx.hideToast() | |
| 158 | + } | |
| 159 | + }) | |
| 160 | + }, | |
| 161 | + drawQR(QRImage) { | |
| 162 | + var ctx = wx.createCanvasContext('QR_canvas', this) | |
| 163 | + ctx.drawImage(QRImage, 0, 0, 174, 174) | |
| 164 | + // ctx.drawImage('../../utils/image/icon.png', 57, 57, 60, 60) | |
| 165 | + ctx.draw() | |
| 166 | + }, | |
| 167 | + // --------------------------登录-------------------------- | |
| 168 | + submitLoginData(e){ | |
| 169 | + console.log(e) | |
| 170 | + var str = '' | |
| 171 | + if (!e.detail.value.phone) { | |
| 172 | + str = '请填写您的手机号' | |
| 173 | + } else if (e.detail.value.phone.length < 11) { | |
| 174 | + str = '请填写正确的手机号' | |
| 175 | + } else if (!e.detail.value.loginPwd) { | |
| 176 | + str = '请输入密码' | |
| 177 | + } else if (e.detail.value.loginPwd.length < 6) { | |
| 178 | + str = '密码必须为6位以上' | |
| 179 | + } | |
| 180 | + if (str) { | |
| 181 | + networkUtil.showErrorToast(str) | |
| 182 | + return | |
| 183 | + } | |
| 184 | + var self = this | |
| 185 | + var param = e.detail.value | |
| 186 | + if (!app.globalData.openInfo.hospitalId){ | |
| 187 | + networkUtil.showErrorToast('未从二维码中获取到医院信息') | |
| 188 | + return | |
| 189 | + } | |
| 190 | + param.hospitalId = app.globalData.openInfo.hospitalId | |
| 191 | + networkUtil.showLoading() | |
| 192 | + networkUtil._get(api.login, param, function (res) { | |
| 193 | + console.log(res) | |
| 194 | + wx.showToast({ | |
| 195 | + title: '登录成功', | |
| 196 | + icon: 'success', | |
| 197 | + duration: 2000 | |
| 198 | + }) | |
| 199 | + app.globalData.token = res.data.token | |
| 200 | + wx.setStorageSync('userToken', res.data.token) | |
| 201 | + self.homePage() | |
| 202 | + self.requestHomeInfo() | |
| 203 | + }, function (res) { | |
| 204 | + networkUtil.showErrorToast(res.errormsg) | |
| 205 | + }) | |
| 206 | + } | |
| 207 | +})) |
jiandang/pages/home/home.json
View file @
177ece1
jiandang/pages/home/home.wxml
View file @
177ece1
| ... | ... | @@ -0,0 +1,56 @@ |
| 1 | +<!--pages/home/home.wxml--> | |
| 2 | +<view style='min-height:100%;background: #477DEB;' wx:if="{{pageType == 1}}"> | |
| 3 | + <view class='topImageBg temp_width'> | |
| 4 | + <view class='top_info_bar'> | |
| 5 | + <text>{{info.userName}}</text> | |
| 6 | + <text>医生</text> | |
| 7 | + <text>{{info.phone}}</text> | |
| 8 | + <text class='exit' bindtap='logout'>退出</text> | |
| 9 | + </view> | |
| 10 | + <!-- <image src='{{imageUrl}}' wx:if=""></image> --> | |
| 11 | + <canvas class="QR_canvas" canvas-id="QR_canvas" bindlongtap='longTapImage'></canvas> | |
| 12 | + <text>预约建档推广二维码</text> | |
| 13 | + </view> | |
| 14 | + | |
| 15 | + <view class='allInfo_bg temp_width'> | |
| 16 | + <view class='allInfo_title cell_width bottom_line'> | |
| 17 | + <text>汇总信息</text> | |
| 18 | + <text style='font-size: 15px;color: #595959;font-weight:500'>{{info.month}}</text> | |
| 19 | + </view> | |
| 20 | + | |
| 21 | + <!-- cell_bg --> | |
| 22 | + <view> | |
| 23 | + <!-- cell --> | |
| 24 | + <view class='allInfo_cell cell_width'> | |
| 25 | + <text class='allInfo_cell_title'>本月建档成功孕妇</text> | |
| 26 | + <view> | |
| 27 | + <text class='allInfo_cell_num'>{{info.currentMonthSuccessCount}}</text> | |
| 28 | + <text class='allInfo_cell_unit'>人</text> | |
| 29 | + </view> | |
| 30 | + </view> | |
| 31 | + <!-- cell --> | |
| 32 | + <view class='allInfo_cell cell_width'> | |
| 33 | + <text class='allInfo_cell_title'>历史建档成功总孕妇</text> | |
| 34 | + <view> | |
| 35 | + <text class='allInfo_cell_num'>{{info.allSuccessCount}}</text> | |
| 36 | + <text class='allInfo_cell_unit'>人</text> | |
| 37 | + </view> | |
| 38 | + </view> | |
| 39 | + <!-- cell --> | |
| 40 | + <view class='allInfo_cell cell_width'> | |
| 41 | + <text class='allInfo_cell_title'>预约建档待确认孕妇</text> | |
| 42 | + <view> | |
| 43 | + <text class='allInfo_cell_num' style='color: #E15555;'>{{info.archiveSuccessCount}}</text> | |
| 44 | + <text class='allInfo_cell_unit'>人</text> | |
| 45 | + </view> | |
| 46 | + </view> | |
| 47 | + | |
| 48 | + <navigator url='../createDocumentList/createDocumentList' class='lookBtn cell_width'>查看建档信息</navigator> | |
| 49 | + <view style='height:30px;'></view> | |
| 50 | + </view> | |
| 51 | + </view> | |
| 52 | + <view style='height:20px'></view> | |
| 53 | +</view> | |
| 54 | + | |
| 55 | +<!-- 登录页面 --> | |
| 56 | +<include src="../login/login.wxml" wx:else/> | |
| 0 | 57 | \ No newline at end of file |
jiandang/pages/home/home.wxss
View file @
177ece1
| ... | ... | @@ -0,0 +1,114 @@ |
| 1 | +/* pages/home/home.wxss */ | |
| 2 | +@import "../login/login.wxss"; | |
| 3 | + | |
| 4 | +.temp_width { | |
| 5 | + width: calc(100% - 20px); | |
| 6 | + margin-left: 10px; | |
| 7 | + background: white; | |
| 8 | +} | |
| 9 | + | |
| 10 | +.topImageBg { | |
| 11 | + display: flex; | |
| 12 | + flex-direction: column; | |
| 13 | + align-items: center; | |
| 14 | + font-size: 15px; | |
| 15 | + color: #595959; | |
| 16 | + height: 308px; | |
| 17 | +} | |
| 18 | + | |
| 19 | +.top_info_bar { | |
| 20 | + width: 100%; | |
| 21 | + height: 44px; | |
| 22 | + background: #F8FAFF; | |
| 23 | + font-size: 15px; | |
| 24 | + color: #888888; | |
| 25 | +} | |
| 26 | + | |
| 27 | +.top_info_bar text:first-child{ | |
| 28 | + color: #333333; | |
| 29 | + font-weight: 555; | |
| 30 | +} | |
| 31 | + | |
| 32 | +.top_info_bar text { | |
| 33 | + margin-left: 10px; | |
| 34 | + height: 100%; | |
| 35 | + line-height: 44px; | |
| 36 | +} | |
| 37 | + | |
| 38 | +.exit { | |
| 39 | + float: right; | |
| 40 | + width: 80px; | |
| 41 | + transform: translateX(-10px); | |
| 42 | + text-align: right; | |
| 43 | + color: #477DEB; | |
| 44 | +} | |
| 45 | + | |
| 46 | +.QR_canvas { | |
| 47 | + width: 174px; | |
| 48 | + height: 174px; | |
| 49 | + margin-top: 30px; | |
| 50 | + margin-bottom: 15px; | |
| 51 | +} | |
| 52 | + | |
| 53 | +.QR_canvas_screen { | |
| 54 | + width: 358px; | |
| 55 | + height: 358px; | |
| 56 | +} | |
| 57 | + | |
| 58 | +.allInfo_bg { | |
| 59 | + margin-top: 10px; | |
| 60 | + | |
| 61 | +} | |
| 62 | + | |
| 63 | +.cell_width { | |
| 64 | + width: calc(100% - 40px); | |
| 65 | + margin-left: 20px; | |
| 66 | +} | |
| 67 | + | |
| 68 | +.allInfo_title { | |
| 69 | + font-size: 20px; | |
| 70 | + color: #333333; | |
| 71 | + font-weight: 555; | |
| 72 | + height: 54px; | |
| 73 | + display: flex; | |
| 74 | + flex-direction: row; | |
| 75 | + align-items: center; | |
| 76 | + justify-content: space-between; | |
| 77 | +} | |
| 78 | + | |
| 79 | +.allInfo_cell { | |
| 80 | + height: 25px; | |
| 81 | + display: flex; | |
| 82 | + justify-content: space-between; | |
| 83 | + align-items: flex-end; | |
| 84 | + margin-top: 16px; | |
| 85 | +} | |
| 86 | + | |
| 87 | +.allInfo_cell_title { | |
| 88 | + font-size: 14px; | |
| 89 | + color: #676B75; | |
| 90 | +} | |
| 91 | + | |
| 92 | +.allInfo_cell view { | |
| 93 | + transform: translateY(5px); | |
| 94 | +} | |
| 95 | + | |
| 96 | +.allInfo_cell_num { | |
| 97 | + font-size: 24px; | |
| 98 | + color: #333333; | |
| 99 | +} | |
| 100 | + | |
| 101 | +.allInfo_cell_unit { | |
| 102 | + font-size: 14px; | |
| 103 | + color: #676B75; | |
| 104 | +} | |
| 105 | + | |
| 106 | +.lookBtn { | |
| 107 | + height: 44px; | |
| 108 | + background: #477DEB; | |
| 109 | + border-radius: 22px; | |
| 110 | + color: white; | |
| 111 | + line-height: 44px; | |
| 112 | + text-align: center; | |
| 113 | + margin-top: 55px; | |
| 114 | +} |
jiandang/pages/index/index.js
View file @
177ece1
jiandang/pages/index/index.json
View file @
177ece1
jiandang/pages/index/index.wxml
View file @
177ece1
jiandang/pages/login/login.js
View file @
177ece1
jiandang/pages/login/login.json
View file @
177ece1
jiandang/pages/login/login.wxml
View file @
177ece1
| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | +<view class='title element_width'>手机号码登录</view> | |
| 2 | +<view class='noti element_width'><text>欢迎使用{{areaName}}基层妇幼辅助孕妇建档平台,请使用注册手机号和密码登录</text></view> | |
| 3 | +<form bindsubmit='submitLoginData'> | |
| 4 | + <view class='input_box element_width bottom_line'> | |
| 5 | + <input maxlength='15' name="phone" placeholder-class='placeholder' placeholder='请输入手机号'></input> | |
| 6 | + </view> | |
| 7 | + <view class='input_box element_width bottom_line'> | |
| 8 | + <input maxlength='20' name="loginPwd" placeholder-class='placeholder' password='true' placeholder='请输入密码'></input> | |
| 9 | + </view> | |
| 10 | + <button class='themeColor loginBtn element_width' form-type='submit' hover-class='hover_color'>登录</button> | |
| 11 | + <view class='bottom_btn'> | |
| 12 | + <navigator url='../register/register'>注册</navigator> | |
| 13 | + <navigator url='../resetPassword/resetPassword'>忘记密码</navigator> | |
| 14 | + </view> | |
| 15 | +</form> | |
| 0 | 16 | \ No newline at end of file |
jiandang/pages/login/login.wxss
View file @
177ece1
| ... | ... | @@ -0,0 +1,49 @@ |
| 1 | +/* pages/login/login.wxss */ | |
| 2 | + | |
| 3 | +.element_width { | |
| 4 | + width: calc(100% - 60px); | |
| 5 | + margin-left: 30px; | |
| 6 | +} | |
| 7 | + | |
| 8 | +.title { | |
| 9 | + font-size: 24px; | |
| 10 | + color: #141B31; | |
| 11 | + font-weight: 600; | |
| 12 | + margin-top: 30px; | |
| 13 | +} | |
| 14 | + | |
| 15 | +.noti { | |
| 16 | + font-size: 14px; | |
| 17 | + color: #7B808F; | |
| 18 | + margin-top: 14px; | |
| 19 | + margin-bottom: 30px; | |
| 20 | +} | |
| 21 | + | |
| 22 | +.input_box { | |
| 23 | + height: 48px; | |
| 24 | + margin-bottom: 10px; | |
| 25 | +} | |
| 26 | + | |
| 27 | +input { | |
| 28 | + height: 100%; | |
| 29 | + font-size: 16px; | |
| 30 | + color: #141B31; | |
| 31 | + text-align: left; | |
| 32 | +} | |
| 33 | + | |
| 34 | +.loginBtn { | |
| 35 | + height: 44px; | |
| 36 | + border-radius: 22px; | |
| 37 | + color: white; | |
| 38 | + line-height: 44px; | |
| 39 | + text-align: center; | |
| 40 | + margin-top: 30px; | |
| 41 | +} | |
| 42 | + | |
| 43 | +.bottom_btn { | |
| 44 | + font-size: 16px; | |
| 45 | + color: #A1A5AA; | |
| 46 | + display: flex; | |
| 47 | + justify-content: space-around; | |
| 48 | + margin-top: 20px; | |
| 49 | +} | |
| 0 | 50 | \ No newline at end of file |
jiandang/pages/logs/logs.js
View file @
177ece1
| ... | ... | @@ -0,0 +1,15 @@ |
| 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 | +}) |
jiandang/pages/logs/logs.json
View file @
177ece1
jiandang/pages/logs/logs.wxml
View file @
177ece1
jiandang/pages/logs/logs.wxss
View file @
177ece1
jiandang/pages/personDetail/personDetail.js
View file @
177ece1
| ... | ... | @@ -0,0 +1,39 @@ |
| 1 | +// pages/personDetail/personDetail.js | |
| 2 | +const networkUtil = require('../../utils/network_util.js') | |
| 3 | +const api = require('../../utils/apiFile.js') | |
| 4 | +const util = require('../../utils/util.js') | |
| 5 | + | |
| 6 | +Page({ | |
| 7 | + | |
| 8 | + /** | |
| 9 | + * 页面的初始数据 | |
| 10 | + */ | |
| 11 | + data: { | |
| 12 | + | |
| 13 | + }, | |
| 14 | + | |
| 15 | + /** | |
| 16 | + * 生命周期函数--监听页面加载 | |
| 17 | + */ | |
| 18 | + onLoad: function (options) { | |
| 19 | + this.requestData(options.archiveId) | |
| 20 | + }, | |
| 21 | + requestData(archiveId) { | |
| 22 | + networkUtil.showLoading() | |
| 23 | + var param = { hospitalId: getApp().globalData.openInfo.hospitalId, archiveId: archiveId} | |
| 24 | + var self = this | |
| 25 | + networkUtil._get(api.ArchiveUserInfo, param, function (res) { | |
| 26 | + var info = JSON.parse(res.data.data) | |
| 27 | + // var b = new Date(info.birthDay * 1000) | |
| 28 | + info.age = util.GetAge(info.idCard) | |
| 29 | + info.idCard | |
| 30 | + // info.birth_date = b.getFullYear() + '年' + (b.getMonth() + 1) + '月' + b.getDate() + '日' | |
| 31 | + info.birth_date = util.getBirthDayFromIdCard(info.idCard) | |
| 32 | + self.setData({ | |
| 33 | + info: info | |
| 34 | + }) | |
| 35 | + }, function (res) { | |
| 36 | + networkUtil.showErrorToast(res.errormsg) | |
| 37 | + }) | |
| 38 | + } | |
| 39 | +}) | |
| 0 | 40 | \ No newline at end of file |
jiandang/pages/personDetail/personDetail.json
View file @
177ece1
jiandang/pages/personDetail/personDetail.wxml
View file @
177ece1
| ... | ... | @@ -0,0 +1,58 @@ |
| 1 | +<view class='section' style='padding-bottom: 20px;'> | |
| 2 | + <view class='title_bar'> | |
| 3 | + <image></image> | |
| 4 | + <text>孕妇基本信息</text> | |
| 5 | + </view> | |
| 6 | + <view class='base_info_cell'> | |
| 7 | + <text>姓名</text> | |
| 8 | + <text>{{info.name}}</text> | |
| 9 | + </view> | |
| 10 | + <view class='base_info_cell'> | |
| 11 | + <text>证件类型</text> | |
| 12 | + <text>身份证</text> | |
| 13 | + </view> | |
| 14 | + <view class='base_info_cell'> | |
| 15 | + <text>证件号</text> | |
| 16 | + <text>{{info.idCard}}</text> | |
| 17 | + </view> | |
| 18 | + <view class='base_info_cell'> | |
| 19 | + <text>国籍</text> | |
| 20 | + <text>{{info.nationality}}</text> | |
| 21 | + </view> | |
| 22 | + <view class='base_info_cell'> | |
| 23 | + <text>民族</text> | |
| 24 | + <text>{{info.nation}}</text> | |
| 25 | + </view> | |
| 26 | + <view class='base_info_cell'> | |
| 27 | + <text>出生日期</text> | |
| 28 | + <text>{{info.birth_date}}</text> | |
| 29 | + </view> | |
| 30 | + <view class='base_info_cell'> | |
| 31 | + <text>年龄</text> | |
| 32 | + <text>{{info.age}}</text> | |
| 33 | + </view> | |
| 34 | +</view> | |
| 35 | + | |
| 36 | +<view class='section'> | |
| 37 | + <view class='title_bar'> | |
| 38 | + <image></image> | |
| 39 | + <text>孕妇联系方式</text> | |
| 40 | + </view> | |
| 41 | + <view class='detail_info_cell bottom_line'> | |
| 42 | + <view>联系方式</view> | |
| 43 | + <view>{{info.data || info.phone}}</view> | |
| 44 | + </view> | |
| 45 | + <view class='detail_info_cell bottom_line'> | |
| 46 | + <view>居住地</view> | |
| 47 | + <view>{{info.currentAddress[0].provinceName + info.currentAddress[0].districtName + info.currentAddress[0].cityName + (info.currentAddress[0].streetName || "") + info.currentAddress[0].address}}</view> | |
| 48 | + </view> | |
| 49 | + <view class='detail_info_cell bottom_line'> | |
| 50 | + <view>户籍地</view> | |
| 51 | + <view>{{info.permanentAddress[0].provinceName + info.permanentAddress[0].districtName + info.permanentAddress[0].cityName + (info.permanentAddress[0].streetName || "") + info.permanentAddress[0].address}}</view> | |
| 52 | + </view> | |
| 53 | + <view class='detail_info_cell bottom_line'> | |
| 54 | + <view>产后休养地</view> | |
| 55 | + <view>{{info.healthResort[0].provinceName + info.healthResort[0].districtName + info.healthResort[0].cityName + (info.healthResort[0].streetName || "") + info.healthResort[0].address}}</view> | |
| 56 | + </view> | |
| 57 | +</view> | |
| 58 | + |
jiandang/pages/personDetail/personDetail.wxss
View file @
177ece1
| ... | ... | @@ -0,0 +1,53 @@ |
| 1 | +page { | |
| 2 | + background: rgb(239, 239, 239) | |
| 3 | +} | |
| 4 | + | |
| 5 | +.section { | |
| 6 | + width: 100%; | |
| 7 | + background: white; | |
| 8 | +} | |
| 9 | + | |
| 10 | +.title_bar { | |
| 11 | + height: 20px; | |
| 12 | + font-size: 16px; | |
| 13 | + color: #141B31; | |
| 14 | + font-weight: 555; | |
| 15 | + margin-top: 10px; | |
| 16 | + padding-top: 20px; | |
| 17 | +} | |
| 18 | + | |
| 19 | +.title_bar image { | |
| 20 | + height: 16px; | |
| 21 | + width: 4px; | |
| 22 | + background: #477DEB; | |
| 23 | + transform: translateY(1px); | |
| 24 | + margin-right: 10px; | |
| 25 | +} | |
| 26 | + | |
| 27 | +.base_info_cell { | |
| 28 | + display: flex; | |
| 29 | + justify-content: space-between; | |
| 30 | + font-size: 15px; | |
| 31 | + color: #141B31; | |
| 32 | + height: 20px; | |
| 33 | + margin-top: 18px; | |
| 34 | + margin-left: 15px; | |
| 35 | + margin-right: 15px; | |
| 36 | +} | |
| 37 | + | |
| 38 | +.base_info_cell text:last-child { | |
| 39 | + color: #777A86; | |
| 40 | +} | |
| 41 | + | |
| 42 | +.detail_info_cell { | |
| 43 | + font-size: 15px; | |
| 44 | + color: #777A86; | |
| 45 | + margin-left: 15px; | |
| 46 | + min-height: 55px; | |
| 47 | + padding-top: 15px; | |
| 48 | +} | |
| 49 | + | |
| 50 | +.detail_info_cell view:first-child { | |
| 51 | + color: #141B31; | |
| 52 | + margin-bottom: 5px; | |
| 53 | +} | |
| 0 | 54 | \ No newline at end of file |
jiandang/pages/register/register.js
View file @
177ece1
| ... | ... | @@ -0,0 +1,129 @@ |
| 1 | +// pages/register/register.js | |
| 2 | +var networkUtil = require('../../utils/network_util.js') | |
| 3 | +var api = require('../../utils/apiFile.js') | |
| 4 | +var util = require('../../utils/util.js') | |
| 5 | + | |
| 6 | +var timeCount = 60; | |
| 7 | +var timer; | |
| 8 | +Page({ | |
| 9 | + /** | |
| 10 | + * 页面的初始数据 | |
| 11 | + */ | |
| 12 | + data: { | |
| 13 | + time: '获取验证码', | |
| 14 | + areaName: getApp().globalData.openInfo.hospitalName || '' | |
| 15 | + }, | |
| 16 | + /** | |
| 17 | + * 生命周期函数--监听页面卸载 | |
| 18 | + */ | |
| 19 | + onUnload: function() { | |
| 20 | + timeCount = 60 | |
| 21 | + clearTimeout(timer) | |
| 22 | + }, | |
| 23 | + | |
| 24 | + /*-------自定义--------*/ | |
| 25 | + // 计时器 | |
| 26 | + keepTime: function() { | |
| 27 | + var that = this | |
| 28 | + timeCount-- | |
| 29 | + that.setData({ | |
| 30 | + time: timeCount + 's' | |
| 31 | + }) | |
| 32 | + if (timeCount == 0) { | |
| 33 | + timeCount = 60 | |
| 34 | + clearTimeout(timer); | |
| 35 | + return | |
| 36 | + } | |
| 37 | + timer = setTimeout(function() { | |
| 38 | + that.keepTime() | |
| 39 | + }, 1000) | |
| 40 | + }, | |
| 41 | + inputPhone(e) { | |
| 42 | + this.data.phone = e.detail.value | |
| 43 | + }, | |
| 44 | + // 获取验证码 | |
| 45 | + getVerifyCode: function(e) { | |
| 46 | + if (timeCount < 60) { | |
| 47 | + return | |
| 48 | + } | |
| 49 | + if (this.data.phone.length != 11 || this.data.phone[0] != '1') { | |
| 50 | + networkUtil.showErrorToast('请填写正确的手机号') | |
| 51 | + return | |
| 52 | + } | |
| 53 | + var that = this | |
| 54 | + networkUtil._get(api.bindDoc, { | |
| 55 | + phone: this.data.phone | |
| 56 | + }, function(res) { | |
| 57 | + | |
| 58 | + }, function(res) { | |
| 59 | + timeCount = 60 | |
| 60 | + clearTimeout(timer); | |
| 61 | + that.setData({ | |
| 62 | + time: '0s' | |
| 63 | + }) | |
| 64 | + networkUtil.showErrorToast('获取验证码失败,请稍后再试') | |
| 65 | + }) | |
| 66 | + if (timeCount == 60) { | |
| 67 | + this.keepTime() | |
| 68 | + } | |
| 69 | + }, | |
| 70 | + submitData(e) { | |
| 71 | + var str = '' | |
| 72 | + if (!e.detail.value.userName) { | |
| 73 | + str = '请填写您的姓名' | |
| 74 | + } else | |
| 75 | + if (!e.detail.value.cardNo) { | |
| 76 | + str = '请填写您的身份证号' | |
| 77 | + } else | |
| 78 | + if (!util.checkIdCard(e.detail.value.cardNo)) { | |
| 79 | + str = '请填写正确的身份证号' | |
| 80 | + } else | |
| 81 | + if (!e.detail.value.phone) { | |
| 82 | + str = '请填写您的手机号' | |
| 83 | + } else | |
| 84 | + if (e.detail.value.phone.length != 11) { | |
| 85 | + str = '请填写正确的手机号' | |
| 86 | + } else | |
| 87 | + if (!e.detail.value.code) { | |
| 88 | + str = '请填写验证码' | |
| 89 | + } else | |
| 90 | + if (!e.detail.value.password) { | |
| 91 | + str = '请输入密码' | |
| 92 | + } else | |
| 93 | + if (!e.detail.value.passwordS) { | |
| 94 | + str = '请再次确认密码' | |
| 95 | + } else | |
| 96 | + if (e.detail.value.password.length < 6) { | |
| 97 | + str = '密码必须为6位以上' | |
| 98 | + } else | |
| 99 | + if (!str && e.detail.value.password != e.detail.value.passwordS) { | |
| 100 | + str = '两次密码输入不一致' | |
| 101 | + } | |
| 102 | + if (str) { | |
| 103 | + networkUtil.showErrorToast(str) | |
| 104 | + return | |
| 105 | + } | |
| 106 | + networkUtil.showLoading() | |
| 107 | + var param = e.detail.value | |
| 108 | + if (!getApp().globalData.openInfo.hospitalId) { | |
| 109 | + networkUtil.showErrorToast('未从二维码中获取到医院信息') | |
| 110 | + return | |
| 111 | + } | |
| 112 | + delete param.passwordS | |
| 113 | + param.hospitalId = getApp().globalData.openInfo.hospitalId | |
| 114 | + networkUtil._post(api.register, param, function(res) { | |
| 115 | + console.log(res) | |
| 116 | + wx.showToast({ | |
| 117 | + title: '注册成功', | |
| 118 | + icon: 'success', | |
| 119 | + duration: 2000 | |
| 120 | + }) | |
| 121 | + setTimeout(function() { | |
| 122 | + wx.navigateBack({}) | |
| 123 | + }, 1000) | |
| 124 | + }, function(res) { | |
| 125 | + | |
| 126 | + networkUtil.showErrorToast(res.errormsg) | |
| 127 | + }, 'application/json') | |
| 128 | + } | |
| 129 | +}) | |
| 0 | 130 | \ No newline at end of file |
jiandang/pages/register/register.json
View file @
177ece1
jiandang/pages/register/register.wxml
View file @
177ece1
| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | +<view class='title element_width'>{{areaName}}基层辅助孕妇建档平台</view> | |
| 2 | +<view class='noti element_width'><text>欢迎使用{{areaName}}基层妇幼辅助孕妇建档平台,成为基层辅助医生需要您绑定以下个人信息</text></view> | |
| 3 | + | |
| 4 | +<form bindsubmit='submitData'> | |
| 5 | + <view class='input_box element_width bottom_line'> | |
| 6 | + <input maxlength='15' placeholder-class='placeholder' name="userName" placeholder='请输入姓名'></input> | |
| 7 | + </view> | |
| 8 | + | |
| 9 | + <view class='input_box element_width bottom_line'> | |
| 10 | + <input maxlength='20' placeholder-class='placeholder' name="cardNo" type='idcard' placeholder='请输入身份证号'></input> | |
| 11 | + </view> | |
| 12 | + | |
| 13 | + <view class='input_box element_width flex_box bottom_line'> | |
| 14 | + <input maxlength='11' placeholder-class='placeholder' bindinput='inputPhone' type='number' name="phone" placeholder='请输入手机号'></input> | |
| 15 | + <view hover-class='hover_color' bindtap='getVerifyCode'>{{time == '0s' ? '再次获取' : time}}</view> | |
| 16 | + </view> | |
| 17 | + | |
| 18 | + <view class='input_box element_width bottom_line'> | |
| 19 | + <input maxlength='8' placeholder-class='placeholder' type='number' name="code" placeholder='请输入验证码'></input> | |
| 20 | + </view> | |
| 21 | + | |
| 22 | + <view class='input_box element_width bottom_line'> | |
| 23 | + <input maxlength='20' placeholder-class='placeholder' name="password" password='true' placeholder='请输入新密码(6位数以上数字或字母组成)'></input> | |
| 24 | + </view> | |
| 25 | + | |
| 26 | + <view class='input_box element_width bottom_line'> | |
| 27 | + <input maxlength='20' placeholder-class='placeholder' name="passwordS" password='true' placeholder='确认密码'></input> | |
| 28 | + </view> | |
| 29 | + | |
| 30 | + <button style='background: #9AB6F3;' form-type='submit' class='themeColor loginBtn element_width' hover-class='hover_color'>提交</button> | |
| 31 | + <view class='bottom_btn'></view> | |
| 32 | +</form> |
jiandang/pages/register/register.wxss
View file @
177ece1
jiandang/pages/resetPassword/resetPassword.js
View file @
177ece1
| ... | ... | @@ -0,0 +1,121 @@ |
| 1 | +//重置密码 | |
| 2 | +var networkUtil = require('../../utils/network_util.js') | |
| 3 | +var api = require('../../utils/apiFile.js') | |
| 4 | + | |
| 5 | +var timeCount = 60; | |
| 6 | +var timer; | |
| 7 | +Page({ | |
| 8 | + | |
| 9 | + /** | |
| 10 | + * 页面的初始数据 | |
| 11 | + */ | |
| 12 | + data: { | |
| 13 | + time: '获取验证码', | |
| 14 | + areaName: getApp().globalData.openInfo.hospitalName || '' | |
| 15 | + }, | |
| 16 | + | |
| 17 | + /** | |
| 18 | + * 生命周期函数--监听页面加载 | |
| 19 | + */ | |
| 20 | + onLoad: function(options) { | |
| 21 | + | |
| 22 | + }, | |
| 23 | + /** | |
| 24 | + * 生命周期函数--监听页面卸载 | |
| 25 | + */ | |
| 26 | + onUnload: function() { | |
| 27 | + timeCount = 60 | |
| 28 | + clearTimeout(timer) | |
| 29 | + }, | |
| 30 | + | |
| 31 | + /*-------自定义--------*/ | |
| 32 | + // 计时器 | |
| 33 | + keepTime: function() { | |
| 34 | + var that = this | |
| 35 | + timeCount-- | |
| 36 | + that.setData({ | |
| 37 | + time: timeCount + 's' | |
| 38 | + }) | |
| 39 | + if (timeCount == 0) { | |
| 40 | + timeCount = 60 | |
| 41 | + clearTimeout(timer); | |
| 42 | + return | |
| 43 | + } | |
| 44 | + timer = setTimeout(function() { | |
| 45 | + that.keepTime() | |
| 46 | + }, 1000) | |
| 47 | + }, | |
| 48 | + inputPhone(e) { | |
| 49 | + this.data.phone = e.detail.value | |
| 50 | + }, | |
| 51 | + // 获取验证码 | |
| 52 | + getVerifyCode: function(e) { | |
| 53 | + if (timeCount < 60) { | |
| 54 | + return | |
| 55 | + } | |
| 56 | + if (this.data.phone.length != 11 || this.data.phone[0] != '1') { | |
| 57 | + networkUtil.showErrorToast('请填写正确的手机号') | |
| 58 | + return | |
| 59 | + } | |
| 60 | + var that = this | |
| 61 | + networkUtil._get(api.bindDoc, { phone: this.data.phone }, function (res) { | |
| 62 | + | |
| 63 | + }, function (res) { | |
| 64 | + timeCount = 60 | |
| 65 | + clearTimeout(timer); | |
| 66 | + that.setData({ | |
| 67 | + time: '0s' | |
| 68 | + }) | |
| 69 | + networkUtil.showErrorToast('获取验证码失败,请稍后再试') | |
| 70 | + }) | |
| 71 | + if (timeCount == 60) { | |
| 72 | + this.keepTime() | |
| 73 | + } | |
| 74 | + }, | |
| 75 | + submitData(e) { | |
| 76 | + var str = '' | |
| 77 | + if (!e.detail.value.phone) { | |
| 78 | + str = '请填写您的手机号' | |
| 79 | + } else | |
| 80 | + if (e.detail.value.phone.length < 11) { | |
| 81 | + str = '请填写正确的手机号' | |
| 82 | + } else if (!e.detail.value.code) { | |
| 83 | + str = '请填写验证码' | |
| 84 | + } else | |
| 85 | + if (!e.detail.value.newPwd) { | |
| 86 | + str = '请输入密码' | |
| 87 | + } else | |
| 88 | + if (!e.detail.value.passwordS) { | |
| 89 | + str = '请再次确认密码' | |
| 90 | + } else | |
| 91 | + if (e.detail.value.newPwd.length < 6) { | |
| 92 | + str = '密码必须为6位以上' | |
| 93 | + } else | |
| 94 | + if (!str && e.detail.value.newPwd != e.detail.value.passwordS) { | |
| 95 | + str = '两次密码输入不一致' | |
| 96 | + } | |
| 97 | + if (str) { | |
| 98 | + networkUtil.showErrorToast(str) | |
| 99 | + return | |
| 100 | + } | |
| 101 | + networkUtil.showLoading() | |
| 102 | + var param = e.detail.value | |
| 103 | + if (!getApp().globalData.openInfo.hospitalId) { | |
| 104 | + networkUtil.showErrorToast('缺少医院iD') | |
| 105 | + return | |
| 106 | + } | |
| 107 | + param.hospitalId = getApp().globalData.openInfo.hospitalId | |
| 108 | + delete param.passwordS | |
| 109 | + networkUtil._get(api.updatePwd, param, function(res) { | |
| 110 | + console.log(res) | |
| 111 | + wx.showToast({ | |
| 112 | + title: '成功修改密码', | |
| 113 | + icon: 'success', | |
| 114 | + duration: 2000 | |
| 115 | + }) | |
| 116 | + setTimeout(function () { wx.navigateBack({}) }, 1000) | |
| 117 | + }, function(res) { | |
| 118 | + networkUtil.showErrorToast(res.errormsg) | |
| 119 | + }) | |
| 120 | + } | |
| 121 | +}) | |
| 0 | 122 | \ No newline at end of file |
jiandang/pages/resetPassword/resetPassword.json
View file @
177ece1
jiandang/pages/resetPassword/resetPassword.wxml
View file @
177ece1
| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | +<view class='title element_width'>重置密码</view> | |
| 2 | +<view class='noti element_width'><text>欢迎使用{{areaName}}基层妇幼辅助孕妇建档平台,忘记密码时需要依据您注册时的手机号进行找回密码</text></view> | |
| 3 | + | |
| 4 | +<form bindsubmit='submitData'> | |
| 5 | + | |
| 6 | + <view class='input_box element_width flex_box bottom_line'> | |
| 7 | + <input maxlength='11' placeholder-class='placeholder' bindinput='inputPhone' type='number' name='phone' placeholder='请输入手机号'></input> | |
| 8 | + <view hover-class='hover_color' bindtap='getVerifyCode'>{{time == '0s' ? '再次获取' : time}}</view> | |
| 9 | + </view> | |
| 10 | + | |
| 11 | + <view class='input_box element_width bottom_line'> | |
| 12 | + <input maxlength='8' placeholder-class='placeholder' type='number' name='code' placeholder='请输入验证码'></input> | |
| 13 | + </view> | |
| 14 | + | |
| 15 | + <view class='input_box element_width bottom_line'> | |
| 16 | + <input maxlength='20' placeholder-class='placeholder' name='newPwd' password='true' placeholder='请输入新密码(6位数以上数字或字母组成)'></input> | |
| 17 | + </view> | |
| 18 | + | |
| 19 | + <view class='input_box element_width bottom_line'> | |
| 20 | + <input maxlength='20' placeholder-class='placeholder' name='passwordS' password='true' placeholder='确认密码'></input> | |
| 21 | + </view> | |
| 22 | + | |
| 23 | + <button style='background: #9AB6F3;' form-type='submit' class='themeColor loginBtn element_width' hover-class='hover_color'>提交</button> | |
| 24 | + <view class='bottom_btn'></view> | |
| 25 | +</form> |
jiandang/pages/resetPassword/resetPassword.wxss
View file @
177ece1
jiandang/project.config.json
View file @
177ece1
| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | +{ | |
| 2 | + "description": "项目配置文件。", | |
| 3 | + "packOptions": { | |
| 4 | + "ignore": [] | |
| 5 | + }, | |
| 6 | + "setting": { | |
| 7 | + "urlCheck": false, | |
| 8 | + "es6": true, | |
| 9 | + "postcss": true, | |
| 10 | + "minified": true, | |
| 11 | + "newFeature": true | |
| 12 | + }, | |
| 13 | + "compileType": "miniprogram", | |
| 14 | + "libVersion": "2.2.2", | |
| 15 | + "appid": "wx721a1c6649fac410", | |
| 16 | + "projectname": "jiandang", | |
| 17 | + "isGameTourist": false, | |
| 18 | + "condition": { | |
| 19 | + "search": { | |
| 20 | + "current": -1, | |
| 21 | + "list": [] | |
| 22 | + }, | |
| 23 | + "conversation": { | |
| 24 | + "current": -1, | |
| 25 | + "list": [] | |
| 26 | + }, | |
| 27 | + "game": { | |
| 28 | + "currentL": -1, | |
| 29 | + "list": [] | |
| 30 | + }, | |
| 31 | + "miniprogram": { | |
| 32 | + "current": -1, | |
| 33 | + "list": [] | |
| 34 | + } | |
| 35 | + } | |
| 36 | +} | |
| 0 | 37 | \ No newline at end of file |
jiandang/utils/apiFile.js
View file @
177ece1
| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | +module.exports = { | |
| 2 | + getOpenId:'wx/getOpenId', | |
| 3 | + /*------建档------*/ | |
| 4 | + | |
| 5 | + // 校验验证码并且绑定建档 | |
| 6 | + login: 'assist/login', | |
| 7 | + // 获取验证码 | |
| 8 | + bindDoc: 'assist/getCodes', | |
| 9 | + // 注册 | |
| 10 | + register: 'assist/regAssistBuildUser', | |
| 11 | + // 首页汇总信息 | |
| 12 | + BuildCountInfo: 'assist/getAssisBuildCountInfo', | |
| 13 | + // 修改密码 | |
| 14 | + updatePwd: 'assist/updatePwd', | |
| 15 | + // 预约成功列表 | |
| 16 | + ArchiveSuccessList: 'assist/getArchiveSuccessList', | |
| 17 | + // 预约建档列表 | |
| 18 | + ArchiveBuildList: 'assist/getArchiveBuildList', | |
| 19 | + // 预约用户信息 | |
| 20 | + ArchiveUserInfo: 'assist/getArchiveUserInfo', | |
| 21 | +} | |
| 0 | 22 | \ No newline at end of file |
jiandang/utils/image/icon.png
View file @
177ece1
42.8 KB
jiandang/utils/network_util.js
View file @
177ece1
| ... | ... | @@ -0,0 +1,168 @@ |
| 1 | + | |
| 2 | +// 测试用户‘花雪莲’,手机号15928512992,验证码666666 | |
| 3 | + | |
| 4 | +// 0测试环境 1正式环境 2演示环境 | |
| 5 | +var Builing_Release_AppStore = 1 | |
| 6 | +// 获取服务器地址 | |
| 7 | +function kServerBaseUrl() { | |
| 8 | + switch (Builing_Release_AppStore) { | |
| 9 | + case 0: | |
| 10 | + return 'https://dev-app-member-api.healthbaby.com.cn/'; | |
| 11 | + case 1: | |
| 12 | + return 'https://app-member-api.healthbaby.com.cn/'; | |
| 13 | + case 2: | |
| 14 | + return 'https://stage-app-member-api.healthbaby.com.cn/'; | |
| 15 | + } | |
| 16 | +} | |
| 17 | + | |
| 18 | +/* | |
| 19 | +* port: 接口名称 类型字符串 | |
| 20 | +* params: 参数 类型json | |
| 21 | +* success: 成功回调 类型function | |
| 22 | +* fail: 失败回调 类型function | |
| 23 | +*/ | |
| 24 | +function _get(port, params, success, fail) { | |
| 25 | + console.log('---------------request_get-----------url:' + kServerBaseUrl() + port,params) | |
| 26 | + wx.request({ | |
| 27 | + url: kServerBaseUrl() + port, | |
| 28 | + data: params, | |
| 29 | + method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT | |
| 30 | + header: { | |
| 31 | + 'content-type': 'application/json', | |
| 32 | + 'Authorization': getApp().globalData.token ? getApp().globalData.token : '' | |
| 33 | + }, // 设置请求的 header | |
| 34 | + success: function (res) { | |
| 35 | + // success | |
| 36 | + successData(res, success, fail) | |
| 37 | + }, | |
| 38 | + fail: function (res) { | |
| 39 | + var error = {} | |
| 40 | + error.errorcode = 404 | |
| 41 | + error.errormsg = '数据获取失败,请稍后再试' | |
| 42 | + console.log(res) | |
| 43 | + // fail | |
| 44 | + fail(error) | |
| 45 | + }, | |
| 46 | + complete: function (res) { | |
| 47 | + // complete | |
| 48 | + wx.hideToast() | |
| 49 | + // 小程序提供的api,通知页面停止下拉刷新效果 | |
| 50 | + wx.stopPullDownRefresh(); | |
| 51 | + } | |
| 52 | + }) | |
| 53 | +} | |
| 54 | + | |
| 55 | +function _post(port, params, success, fail, contentType) { | |
| 56 | + console.log('---------------request_post-----------url:' + port, params) | |
| 57 | + wx.request({ | |
| 58 | + url: kServerBaseUrl() + port, | |
| 59 | + data: params, | |
| 60 | + method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT | |
| 61 | + header: { | |
| 62 | + 'content-type': contentType ? contentType : 'application/x-www-form-urlencoded', | |
| 63 | + 'Authorization': getApp().globalData.token ? getApp().globalData.token : '' | |
| 64 | + }, // 设置请求的 header | |
| 65 | + success: function (res) { | |
| 66 | + // success | |
| 67 | + successData(res, success, fail) | |
| 68 | + }, | |
| 69 | + fail: function (res) { | |
| 70 | + var error = {} | |
| 71 | + error.errorcode = 404 | |
| 72 | + error.errormsg = '数据获取失败,请稍后再试' | |
| 73 | + console.log(res) | |
| 74 | + // fail | |
| 75 | + fail(error) | |
| 76 | + }, | |
| 77 | + complete: function () { | |
| 78 | + // complete | |
| 79 | + wx.hideToast() | |
| 80 | + // 小程序提供的api,通知页面停止下拉刷新效果 | |
| 81 | + wx.stopPullDownRefresh; | |
| 82 | + } | |
| 83 | + }) | |
| 84 | +} | |
| 85 | + | |
| 86 | +function _put(port, params, success, fail, contentType) { | |
| 87 | + console.log('---------------request_PUT-----------url:' + port, params) | |
| 88 | + wx.request({ | |
| 89 | + url: kServerBaseUrl() + port, | |
| 90 | + data: params, | |
| 91 | + method: 'PUT', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT | |
| 92 | + header: { | |
| 93 | + 'content-type': contentType ? contentType : 'application/x-www-form-urlencoded', | |
| 94 | + 'Authorization': getApp().globalData.token ? getApp().globalData.token : '' | |
| 95 | + }, // 设置请求的 header | |
| 96 | + success: function (res) { | |
| 97 | + // success | |
| 98 | + successData(res, success, fail) | |
| 99 | + }, | |
| 100 | + fail: function (res) { | |
| 101 | + var error = {} | |
| 102 | + error.errorcode = 404 | |
| 103 | + error.errormsg = '数据获取失败,请稍后再试' | |
| 104 | + console.log(res) | |
| 105 | + // fail | |
| 106 | + fail(error) | |
| 107 | + }, | |
| 108 | + complete: function () { | |
| 109 | + // complete | |
| 110 | + wx.hideToast() | |
| 111 | + // 小程序提供的api,通知页面停止下拉刷新效果 | |
| 112 | + wx.stopPullDownRefresh; | |
| 113 | + } | |
| 114 | + }) | |
| 115 | +} | |
| 116 | + | |
| 117 | +function successData(res, success, fail) { | |
| 118 | + console.log('res',res) | |
| 119 | + if (res.errorcode && res.errorcode == 0) { | |
| 120 | + success(res) | |
| 121 | + return | |
| 122 | + } | |
| 123 | + if (res.statusCode == 200) { | |
| 124 | + if (res.data.errorcode == 0) { | |
| 125 | + success(res) | |
| 126 | + } else { | |
| 127 | + var error = {} | |
| 128 | + error.errorcode = res.data.errorcode | |
| 129 | + error.errormsg = res.data.errormsg ? res.data.errormsg : '数据获取失败,请稍后再试' | |
| 130 | + console.log(res) | |
| 131 | + fail(error) | |
| 132 | + } | |
| 133 | + } else { | |
| 134 | + var error = {} | |
| 135 | + error.errorcode = res.statusCode | |
| 136 | + error.errormsg = '数据获取失败,请稍后再试' | |
| 137 | + fail(error) | |
| 138 | + } | |
| 139 | +} | |
| 140 | + | |
| 141 | +function showLoading(text) { | |
| 142 | + wx.showToast({ | |
| 143 | + title: text == null ? '加载中...' : text, | |
| 144 | + icon: 'loading', | |
| 145 | + duration: 60000 | |
| 146 | + }) | |
| 147 | +} | |
| 148 | + | |
| 149 | +function showErrorToast(text) { | |
| 150 | + wx.showModal({ | |
| 151 | + title: '提示', | |
| 152 | + content: text, | |
| 153 | + showCancel: false, | |
| 154 | + success: function (res) { | |
| 155 | + } | |
| 156 | + }) | |
| 157 | +} | |
| 158 | + | |
| 159 | +module.exports = { | |
| 160 | + _get: _get, | |
| 161 | + _post: _post, | |
| 162 | + _put: _put, | |
| 163 | + showLoading: showLoading, | |
| 164 | + showErrorToast: showErrorToast, | |
| 165 | + Builing_Release_AppStore: Builing_Release_AppStore, | |
| 166 | +} | |
| 167 | + | |
| 168 | +// networkUtil._get(api,param,function(res){},function(res){}) | |
| 0 | 169 | \ No newline at end of file |
jiandang/utils/util.js
View file @
177ece1
| ... | ... | @@ -0,0 +1,152 @@ |
| 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() | |
| 8 | + | |
| 9 | + return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':') | |
| 10 | +} | |
| 11 | + | |
| 12 | +const formatNumber = n => { | |
| 13 | + n = n.toString() | |
| 14 | + return n[1] ? n : '0' + n | |
| 15 | +} | |
| 16 | + | |
| 17 | +const GetAge = identityCard => { | |
| 18 | + var len = (identityCard + "").length; | |
| 19 | + if (len == 0) { | |
| 20 | + return 0; | |
| 21 | + } else { | |
| 22 | + if ((len != 15) && (len != 18))//身份证号码只能为15位或18位其它不合法 | |
| 23 | + { | |
| 24 | + return 0; | |
| 25 | + } | |
| 26 | + } | |
| 27 | + var strBirthday = ""; | |
| 28 | + if (len == 18)//处理18位的身份证号码从号码中得到生日和性别代码 | |
| 29 | + { | |
| 30 | + strBirthday = identityCard.substr(6, 4) + "/" + identityCard.substr(10, 2) + "/" + identityCard.substr(12, 2); | |
| 31 | + } | |
| 32 | + if (len == 15) { | |
| 33 | + strBirthday = "19" + identityCard.substr(6, 2) + "/" + identityCard.substr(8, 2) + "/" + identityCard.substr(10, 2); | |
| 34 | + } | |
| 35 | + //时间字符串里,必须是“/” | |
| 36 | + var birthDate = new Date(strBirthday); | |
| 37 | + var nowDateTime = new Date(); | |
| 38 | + var age = nowDateTime.getFullYear() - birthDate.getFullYear(); | |
| 39 | + //再考虑月、天的因素;.getMonth()获取的是从0开始的,这里进行比较,不需要加1 | |
| 40 | + if (nowDateTime.getMonth() < birthDate.getMonth() || (nowDateTime.getMonth() == birthDate.getMonth() && nowDateTime.getDate() < birthDate.getDate())) { | |
| 41 | + age--; | |
| 42 | + } | |
| 43 | + return age; | |
| 44 | +} | |
| 45 | + | |
| 46 | +/** | |
| 47 | +* 检查身份证合法 | |
| 48 | +* @param str_idCard sex为human man | |
| 49 | +* @returns {boolean} | |
| 50 | +*/ | |
| 51 | +function checkIdCard(str_idCard, sex) { | |
| 52 | + str_idCard = str_idCard || String(this); | |
| 53 | + var check = function () { | |
| 54 | + var factorArr = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1); | |
| 55 | + var parityBit = new Array("1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"); | |
| 56 | + var varArray = new Array(); | |
| 57 | + var lngProduct = 0; | |
| 58 | + var intCheckDigit; | |
| 59 | + var intStrLen = str_idCard.length; | |
| 60 | + var idNumber = str_idCard; | |
| 61 | + // initialize | |
| 62 | + if ((intStrLen != 15) && (intStrLen != 18)) { | |
| 63 | + return false; | |
| 64 | + } | |
| 65 | + // check and set value | |
| 66 | + for (var i = 0; i < intStrLen; i++) { | |
| 67 | + varArray[i] = idNumber.charAt(i); | |
| 68 | + if ((varArray[i] < '0' || varArray[i] > '9') && (i != 17)) { | |
| 69 | + return false; | |
| 70 | + } else if (i < 17) { | |
| 71 | + varArray[i] = varArray[i] * factorArr[i]; | |
| 72 | + } | |
| 73 | + } | |
| 74 | + | |
| 75 | + if (intStrLen == 18) { | |
| 76 | + var date8 = idNumber.substring(6, 14); | |
| 77 | + | |
| 78 | + if (!/^[0-9]{8}$/.test(date8)) { | |
| 79 | + return false; | |
| 80 | + } | |
| 81 | + var year, month, day; | |
| 82 | + year = date8.substring(0, 4); | |
| 83 | + month = date8.substring(4, 6); | |
| 84 | + day = date8.substring(6, 8); | |
| 85 | + var iaMonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] | |
| 86 | + if (year < 1700 || year > 2500) return false; | |
| 87 | + if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) iaMonthDays[1] = 29; | |
| 88 | + if (month < 1 || month > 12) return false; | |
| 89 | + if (day < 1 || day > iaMonthDays[month - 1]) return false; | |
| 90 | + | |
| 91 | + // calculate the sum of the products | |
| 92 | + for (i = 0; i < 17; i++) { | |
| 93 | + lngProduct = lngProduct + varArray[i]; | |
| 94 | + } | |
| 95 | + // calculate the check digit | |
| 96 | + intCheckDigit = parityBit[lngProduct % 11]; | |
| 97 | + // check last digit | |
| 98 | + if (varArray[17] != intCheckDigit) { | |
| 99 | + return false; | |
| 100 | + } | |
| 101 | + } | |
| 102 | + //length is 15 | |
| 103 | + else { | |
| 104 | + var date6 = idNumber.substring(6, 12); | |
| 105 | + | |
| 106 | + if (!/^[0-9]{6}$/.test(date6)) { | |
| 107 | + return false; | |
| 108 | + } | |
| 109 | + var month, day, year; | |
| 110 | + year = date6.substring(0, 2); | |
| 111 | + month = date6.substring(2, 4); | |
| 112 | + day = date6.substring(4, 6); | |
| 113 | + if (!/^\d{2}$/.test(year)) return false; | |
| 114 | + if (month < 1 || month > 12) return false; | |
| 115 | + if (day < 1 || day > 31) return false; | |
| 116 | + } | |
| 117 | + return true; | |
| 118 | + } | |
| 119 | + if (str_idCard && check(str_idCard)) { | |
| 120 | + if (undefined != sex) { | |
| 121 | + var sexStr = undefined, tmp = 0; | |
| 122 | + if (15 == str_idCard.length) { | |
| 123 | + tmp = str_idCard.substring(str_idCard.length - 1, str_idCard.length); | |
| 124 | + } else if (18 == str_idCard.length) { | |
| 125 | + tmp = str_idCard.substr(str_idCard.length - 2, 1); | |
| 126 | + } | |
| 127 | + if (0 == tmp % 2) { | |
| 128 | + sexStr = 'woman'; | |
| 129 | + } else { | |
| 130 | + sexStr = 'man'; | |
| 131 | + } | |
| 132 | + | |
| 133 | + if (sex != sexStr) return false; | |
| 134 | + } | |
| 135 | + return true; | |
| 136 | + } | |
| 137 | + return false; | |
| 138 | +} | |
| 139 | + | |
| 140 | +function getBirthDayFromIdCard(idCard,unit){ | |
| 141 | + var year = idCard.substring(6, 10) | |
| 142 | + var month = idCard.substring(10, 12) | |
| 143 | + var day = idCard.substring(12, 14) | |
| 144 | + return year + (unit || '年') + month + (unit || '月') + day + (unit || '日') | |
| 145 | +} | |
| 146 | + | |
| 147 | +module.exports = { | |
| 148 | + formatTime: formatTime, | |
| 149 | + GetAge: GetAge, | |
| 150 | + checkIdCard: checkIdCard, | |
| 151 | + getBirthDayFromIdCard: getBirthDayFromIdCard | |
| 152 | +} |