作者 朱振飞

init

正在显示 87 个修改的文件 包含 4086 行增加0 行删除

要显示太多修改。

为保证性能只显示 87 of 87+ 个文件。

var ald = require('./utils/ald-stat.js');
//app.js
App({
onLaunch: function () {
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
},
post: function (url, data) {
/**
* 自定义post函数,返回Promise
* +-------------------
* @param {String} url 接口网址
* @param {arrayObject} data 要传的数组对象 like: {name: 'name', age: 32}
* +-------------------
* @return {Promise} promise 返回promise供后续操作
*/
// wx.showLoading({
// title: '加载中',
// })
wx.showNavigationBarLoading()
var promise = new Promise((resolve, reject) => {
//init
let that = this;
let postData = data;
let baseUrl = 'http://zhouli.w.bronet.cn/api/zhouli';
// let baseUrl = ' https://tzzl.superkangaroo.net';
// postData.signature = that.makeSign(postData);
//网络请求
wx.request({
url: baseUrl + url,
data: postData,
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded',
'XX-Token': wx.getStorageSync('token')
},
success: function (res) {//返回取得的数据
if (res.data.code == '20000') {
resolve(res.data.data);
} else if (res.data.code == '20001') {//返回错误提示信息
wx.showModal({
title: '提示',
content: res.data.msg,
success: function (res) {
if (res.confirm) {
wx.removeStorageSync('token');
wx.navigateTo({
url: '/pages/startRecord/startRecord',
})
}
}
})
}else if(res.data.code == '40001'){//返回错误提示信息
wx.showModal({
title: '提示',
content: '登录已过期请重新登录!',
showCancel: false,
success: function(res){
if(res.confirm){
wx.removeStorageSync('token');
wx.navigateTo({
url: '/pages/startRecord/startRecord',
})
}
}
})
} else if (res.data.code == '40000'){
wx.showModal({
title: '提示',
content: res.data.msg,
showCancel: false,
success: function (res) {}
})
} else if (res.data.code == '44004') {
wx.showModal({
title: '提示',
content: res.data.msg,
showCancel: false,
success: function (res) {
wx.navigateBack()
}
})
} else if (res.data.code == '44002'){
// 初始化用户信息判断
let usetrInfoType = {
hasUserInfo: false
}
resolve(usetrInfoType);
// wx.showModal({
// title: '提示',
// content: res.data.msg,
// showCancel: false
// })
}else{
wx.showModal({
title: '提示',
content: res.data.msg,
showCancel: false
})
reject(res.data)
}
setTimeout(function () {
// wx.hideLoading()
wx.hideNavigationBarLoading()
}, 600)
},
error: function (e) {
reject('网络出错');
// wx.hideLoading()
wx.hideNavigationBarLoading()
}
})
});
return promise;
},
nowDate(){
let date = new Date();
let month = date.getMonth()+1;
let day = date.getDate();
return date.getFullYear()+'-'+(month>9?month:('0'+month))+'-'+(day>9?day:('0'+day));
},
minDate(){
let date = new Date();
date.setDate(date.getDate() - 287);
let m = date.getMonth() + 1;
return date.getFullYear() + '-' + m + '-' + date.getDate();
},
globalData: {
userInfo: null,
appInfo:{
}
}
})
\ No newline at end of file
... ...
{
"pages": [
"pages/startRecord/startRecord",
"pages/baseInfo/baseInfo",
"pages/weight/weight",
"pages/bchao/bchao",
"pages/userInfo/userInfo",
"pages/personal/personal",
"pages/xiyiDetail/xieyidetail",
"pages/index/index",
"pages/addbchao/addbchao",
"pages/logs/logs",
"pages/changeBaseInfo/changeBaseInfo",
"pages/addWeight/addWeight",
"pages/changebchao/changebchao"
],
"window": {
"backgroundTextStyle": "dark",
"navigationBarBackgroundColor": "#51DBA2",
"navigationBarTitleText": "孕期体重管理小助手",
"navigationBarTextStyle": "#FFF"
},
"tabBar": {
"color": "#999",
"selectedColor": "#7ED99D",
"backgroundColor": "#000000",
"list": [
{
"text": "体重记录",
"selectedIconPath": "images/1.0.png",
"iconPath": "images/1.1.png",
"pagePath": "pages/weight/weight"
},
{
"text": "孕期B超",
"selectedIconPath": "images/2.0.png",
"iconPath": "images/2.1.png",
"pagePath": "pages/bchao/bchao"
},
{
"text": "个人中心",
"selectedIconPath": "images/3.0.png",
"iconPath": "images/3.1.png",
"pagePath": "pages/personal/personal"
}
]
}
}
\ No newline at end of file
... ...
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}
.z_container{
overflow-x: hidden
}
\ No newline at end of file
... ...
// pages/addWeight/addWeight.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
multiIndex: [0, 0],
weeksArry: [],
weight: ''
},
getWeeks() {
let url = '/user/getWeekDay'
app.post(url, {}).then((res) => {
console.log(res)
this.setData({
multiIndex: [res.default.week, res.default.day],
week: res.default.week,
day: res.default.day
})
console.log(this.data.multiIndex)
let tempData = []
let tempWeeks = []
let tempDays = []
for (let i = 0; i <= this.data.week; i++) {
let tempText = '孕期' + i + '周'
let tempw = {
id: i,
text: tempText
}
tempWeeks.push(tempw)
}
for (let i = 0; i <= this.data.day; i++) {
let tempText = '加' + i + '天'
let tempD = {
id: i,
text: tempText
}
tempDays.push(tempD)
}
tempData[0] = tempWeeks;
tempData[1] = tempDays;
this.setData({
weeksArry: tempData
})
}).catch((errMsg) => {
})
},
bindMultiPickerChange: function (e) {
console.log(e)
let chooseW = this.data.weeksArry[0][e.detail.value[0]]
let chooseD = this.data.weeksArry[1][e.detail.value[1]]
this.setData({
multiIndex: e.detail.value,
week: chooseW.id,
day: chooseD.id
})
},
bindMultiPickerColumnChange: function (e) {
console.log(e)
let row = e.detail.column;
let value = e.detail.value;
let baseWeek = this.data.week;
let weeksArry = this.data.weeksArry;
let tempDays = [];
let nowDays = []
if (row == 0) {
if (value < baseWeek) {
for (let i = 0; i < 7; i++) {
let tempText = '加' + i + '天'
let tempD = {
id: i,
text: tempText
}
tempDays.push(tempD)
}
weeksArry[1] = tempDays;
this.setData({
weeksArry: weeksArry
})
} else {
for (let i = 0; i <= this.data.day; i++) {
let tempText = '加' + i + '天'
let tempD = {
id: i,
text: tempText
}
nowDays.push(tempD)
}
weeksArry[1] = nowDays;
this.setData({
weeksArry: weeksArry
})
}
}
},
getWeight(e) {
console.log(e)
this.setData({
weight: e.detail.value
})
},
addWeight() {
let url = '/user/addWeightLog'
let params = {
create_date: this.data.create_date,
weight: this.data.weight
}
if (params.weight == '' || params.weight == null || params.weight == undefined) {
wx.showToast({
title: '请输入体重',
icon: 'none'
})
} else {
app.post(url, params).then((res) => {
wx.showToast({
title: '添加成功',
})
wx.setStorageSync('newWeight','true')
setTimeout(function(){
wx.switchTab({
url: '/pages/weight/weight',
})
},1000)
}).catch((errMsg) => {
})
}
},
inputDate: function (e) {
this.setData({
create_date: e.detail.value
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// let tempData = []
// let tempWeeks = []
// let tempDays = []
// for (let i = 0; i <= 42; i++) {
// let tempText = '孕期' + i + '周'
// let tempw = {
// id: i,
// text: tempText
// }
// tempWeeks.push(tempw)
// }
// for (let i = 0; i < 7; i++) {
// let tempText = '加' + i + '天'
// let tempD = {
// id: i,
// text: tempText
// }
// tempDays.push(tempD)
// }
// tempData[0] = tempWeeks;
// tempData[1] = tempDays;
// this.setData({
// weeksArry: tempData
// })
// this.getWeeks();
this.setData({
create_date:app.nowDate(),
endDate: app.nowDate(),
startDate: app.minDate()
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "添加孕期体重",
"disableScroll": true
}
\ No newline at end of file
... ...
<!--pages/addWeight/addWeight.wxml-->
<view class='z_container'>
<!--信息记录 -->
<view class='info_box'>
<view class='info_item'>
<view>测量日期</view>
<!-- <text class='info_item_input'>{{create_date}}</text> -->
<picker mode="date" class='sub_item_input' value="{{date}}" start="{{startDate}}" end="{{endDate}}" bindchange="inputDate">
<view class="picker">
<text class='info_item_input'>{{create_date}}</text>
</view>
</picker>
</view>
<view class='info_item'>
<view>测量体重</view>
<input class='info_item_input' type='digit' bindinput='getWeight' value='' placeholder='请输入当天体重' />
<view class='danwei'>kg</view>
</view>
</view>
<view class='save_btn' bindtap='addWeight'>保存</view>
</view>
\ No newline at end of file
... ...
/* pages/addWeight/addWeight.wxss */
@import '../changeBaseInfo/changeBaseInfo.wxss'
\ No newline at end of file
... ...
// pages/addbchao/addbchao.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
weeksArry:[],
create_date:'',
head_circumference:'',
abdominal_circumference:'',
femur_length:'',
neck_length:''
},
getWeeks() {
let url = '/user/getWeekDay'
app.post(url, {}).then((res) => {
console.log(res)
this.setData({
multiIndex: [res.default.week, res.default.day],
week: res.default.week,
day: res.default.day
})
console.log(this.data.multiIndex)
let tempData = []
let tempWeeks = []
let tempDays = []
for (let i = 0; i <= this.data.week; i++) {
let tempText = '孕期' + i + '周'
let tempw = {
id: i,
text: tempText
}
tempWeeks.push(tempw)
}
for (let i = 0; i <= this.data.day; i++) {
let tempText = '加' + i + '天'
let tempD = {
id: i,
text: tempText
}
tempDays.push(tempD)
}
tempData[0] = tempWeeks;
tempData[1] = tempDays;
this.setData({
weeksArry: tempData
})
}).catch((errMsg) => {
})
},
bindMultiPickerChange: function (e) {
console.log(e)
let chooseW = this.data.weeksArry[0][e.detail.value[0]]
let chooseD = this.data.weeksArry[1][e.detail.value[1]]
this.setData({
multiIndex: e.detail.value,
week: chooseW.id,
day: chooseD.id
})
},
bindMultiPickerColumnChange: function (e) {
console.log(e)
let row = e.detail.column;
let value = e.detail.value;
let baseWeek = this.data.week;
let weeksArry = this.data.weeksArry;
let tempDays = [];
let nowDays = []
if(row==0){
if (value < baseWeek){
for (let i = 0; i < 7; i++) {
let tempText = '加' + i + '天'
let tempD = {
id: i,
text: tempText
}
tempDays.push(tempD)
}
weeksArry[1] = tempDays;
this.setData({
weeksArry: weeksArry
})
}else{
for (let i = 0; i <= this.data.day; i++) {
let tempText = '加' + i + '天'
let tempD = {
id: i,
text: tempText
}
nowDays.push(tempD)
}
weeksArry[1] = nowDays;
this.setData({
weeksArry: weeksArry
})
}
}
},
getHead(e){
this.setData({
head_circumference:e.detail.value
})
},
getadominal(e){
this.setData({
abdominal_circumference: e.detail.value
})
},
getfemur(e){
this.setData({
femur_length:e.detail.value
})
},
getneck(e){
this.setData({
neck_length: e.detail.value
})
},
savebinfo(){
let url = '/user/addBCLog'
let params = {
create_date: this.data.create_date,
head_circumference: this.data.head_circumference,
abdominal_circumference: this.data.abdominal_circumference,
femur_length: this.data.femur_length,
neck_length: this.data.neck_length
}
console.log(params)
if(params.head_circumference==''){
wx.showToast({
title: '请输入头围',
icon: 'none'
})
return false
}else if(params.abdominal_circumference == ''){
wx.showToast({
title: '请输入腹围',
icon: 'none'
})
return false
}else if(params.femur_length == ''){
wx.showToast({
title: '请输入股骨长',
icon: 'none'
})
return false
}else if(params.neck_length == ''){
wx.showToast({
title: '请输入胎儿头颈长度',
icon: 'none'
})
return false
}else{
app.post(url,params).then((res)=>{
wx.showToast({
title:'保存成功'
})
setTimeout(function(){
wx.switchTab({
url: '/pages/bchao/bchao',
})
},1000)
})
}
},
inputDate: function (e) {
this.setData({
create_date: e.detail.value
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
create_date: app.nowDate(),
endDate: app.nowDate(),
startDate: app.minDate()
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText":"添加B超记录",
"disableScroll": true
}
\ No newline at end of file
... ...
<view class='z_container'>
<!--信息记录 -->
<view class='info_box'>
<view class='info_item'>
<view>B超检查日期</view>
<!-- <text class='info_item_input'>{{create_date}}</text> -->
<picker mode="date" class='sub_item_input' value="{{date}}" start="{{startDate}}" end="{{endDate}}" bindchange="inputDate">
<view class="picker">
<text class='info_item_input'>{{create_date}}</text>
</view>
</picker>
</view>
<view class='info_item'>
<view>头围</view>
<input class='info_item_input' type='digit' value='' bindinput='getHead' placeholder='' />
<view class='danwei'>mm</view>
</view>
<view class='info_item'>
<view>腹围</view>
<input class='info_item_input' type='digit' value='' bindinput='getadominal' placeholder='' />
<view class='danwei'>mm</view>
</view>
<view class='info_item'>
<view>股骨长</view>
<input class='info_item_input' type='digit' value='' bindinput='getfemur' placeholder='' />
<view class='danwei'>mm</view>
</view>
<view class='info_item'>
<view>双顶径</view>
<input class='info_item_input' type='digit' value='' bindinput='getneck' placeholder='' />
<view class='danwei'>mm</view>
</view>
</view>
<view class='save_btn' bindtap='savebinfo'>保存</view>
</view>
\ No newline at end of file
... ...
/* pages/addbchao/addbchao.wxss */
@import "../userInfo/userInfo.wxss";
.info_box{
background: #FFF;
padding: 0 36rpx 0 30rpx;
margin-top: 30rpx;
}
.danwei{
color: #999
}
... ...
// pages/baseInfo/baseInfo.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
choose: true,
age:null,
height: null,
pre_weight: null,
week: '',
day: '',
current_weight: null,
multiIndex: [0, 0],
weeksArry: [],
taiArry: [{
value: '1',
name: '单胞胎'
}, {
value: '2',
name: '双胞胎'
}],
tai: ['单胞胎', '双包胎'],
index: 0,
is_single_birth: 1
},
bindtaichange(e) {
console.log(e)
this.setData({
index: e.detail.value,
is_single_birth: this.data.taiArry[e.detail.value].value
})
},
choose(){
this.setData({
choose: !this.data.choose
})
},
inputAge(e){
console.log(e)
this.setData({
age: e.detail.value
})
},
inputHeight(e){
this.setData({
height: e.detail.value
})
},
inputWeight(e){
this.setData({
pre_weight: e.detail.value
})
},
inputDate: function (e) {
this.setData({
last_menstruation: e.detail.value
})
let params = {
last_menstruation: e.detail.value
}
let url = '/profile/getGestationalWeek'
let that = this;
app.post(url,params).then((res)=>{
that.setData({
week: res.week,
day: res.day
})
}).catch((errMsg)=>{})
},
bindMultiPickerChange: function (e) {
let chooseW = this.data.weeksArry[0][e.detail.value[0]]
let chooseD = this.data.weeksArry[1][e.detail.value[1]]
this.setData({
multiIndex: e.detail.value,
week: chooseW.id,
day: chooseD.id
})
},
bindMultiPickerColumnChange: function (e) {
},
inputCurrentWeight(e){
this.setData({
current_weight: e.detail.value
})
},
saveBaseInfo(){
let userinfo = {
age: this.data.age,
height: this.data.height,
pre_weight: this.data.pre_weight,
last_menstruation: this.data.last_menstruation,
week: this.data.week,
day: this.data.day,
current_weight: this.data.current_weight,
is_single_birth: this.data.is_single_birth
}
if (userinfo.age == null){
wx.showToast({
icon:'none',
title: '年龄不能为空',
})
return false;
} else if (userinfo.height == null){
wx.showToast({
icon: 'none',
title: '身高不能为空',
})
return false;
} else if (userinfo.pre_weight == null){
wx.showToast({
icon: 'none',
title: '孕前体重不能为空',
})
return false;
} else if (userinfo.last_menstruation == null){
wx.showToast({
icon: 'none',
title: '末次月经时间不能为空',
})
return false;
} else if (userinfo.week == null){
wx.showToast({
icon: 'none',
title: '孕周不能为空',
})
return false;
} else if (userinfo.current_weight == null) {
wx.showToast({
icon: 'none',
title: '孕妇当前体重不能为空',
})
return false;
}else if(!this.data.choose){
wx.showToast({
icon: 'none',
title: '选择用户个人隐私保护协议',
})
return false;
}
let url = '/profile/setGravidaBaseInfo'
app.post(url,userinfo).then((res)=>{
wx.showToast({
title: '保存成功'
})
wx.setStorageSync('first', true)
setTimeout(function(){
wx.switchTab({
url: '/pages/weight/weight',
})
})
}).catch((errMsg)=>{
})
},
viewxieyi() {
wx.navigateTo({
url: '/pages/xiyiDetail/xieyidetail',
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let tempData = []
let tempWeeks = []
let tempDays = []
for(let i = 0; i<=42 ; i++){
let tempText = '孕'+i+'周'
let tempw = {
id: i,
text: tempText
}
tempWeeks.push(tempw)
}
for (let i = 0; i < 7; i++) {
let tempText = '加' + i + '天'
let tempD = {
id: i,
text: tempText
}
tempDays.push(tempD)
}
tempData[0] = tempWeeks;
tempData[1] = tempDays;
this.setData({
weeksArry: tempData,
endDate: app.nowDate(),
startDate: app.minDate()
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "基本信息填写"
}
\ No newline at end of file
... ...
<!--pages/baseInfo/baseInfo.wxml-->
<view class='z_container'>
<view class='top_tips'>
为了给您提供更准确的判断,请将以下信息补充完整。
</view>
<!--基本信息表单 -->
<view class='base_subform'>
<view class='sub_item'>
<view class='sub_item_label'>孕妇年龄</view>
<input class='sub_item_input' type='number' placeholder-style="color:#999" bindinput
='inputAge' placeholder="请输入准确年龄" />
<view class='danwei'>岁</view>
</view>
<view class='sub_item'>
<view class='sub_item_label'>孕妇身高</view>
<input class='sub_item_input' type='digit' placeholder-style="color:#999" bindinput='inputHeight' placeholder="请输入准确身高" /><view class='danwei'>cm</view>
</view>
<view class='sub_item'>
<view class='sub_item_label'>孕前体重</view>
<input class='sub_item_input' type='digit' placeholder-style="color:#999" bindinput='inputWeight' placeholder="请输入准确孕前体重" /><view class='danwei'>kg</view>
</view>
<view class='sub_item'>
<view class='sub_item_label'>末次月经第一天</view>
<picker mode="date" class='sub_item_input' value="{{date}}" start="{{startDate}}" end="{{endDate}}" bindchange="inputDate">
<view class="picker">
<text wx:if="{{!last_menstruation}}">请输入准确末次月经</text>
{{last_menstruation}}
</view>
</picker>
</view>
<view class='sub_item'>
<view class='sub_item_label'>孕周</view>
<text class='sub_item_input'>孕{{week}}<text wx:if="{{week===''}}">几</text>周+{{day}}天</text>
<!-- <picker class='sub_item_input' mode="multiSelector" bindchange="bindMultiPickerChange" bindcolumnchange="bindMultiPickerColumnChange" value="{{multiIndex}}" range="{{weeksArry}}" range-key="text">
<view class="picker">
<text wx:if="{{!week && !day}}">孕几周+天</text>
<text wx:else>孕{{week}}+{{day}}天</text>
</view>
</picker> -->
</view>
<view class='sub_item'>
<view class='sub_item_label'>孕妇当前体重</view>
<input class='sub_item_input' bindinput='inputCurrentWeight' placeholder-style="color:#999" type='digit' placeholder="请输入准确体重" /><view class='danwei'>kg</view>
</view>
<view class='sub_item'>
<view class='sub_item_label'>单/双胞胎</view>
<picker bindchange="bindtaichange" class='sub_item_input' value="{{index}}" range="{{tai}}">
<view class="picker">
<text class='danwei'>{{tai[index]}}</text>
</view>
</picker>
</view>
</view>
<view class='shengming'>
注:由于每位女性月经周期长短不一,所以推测的孕周及预产期与实际有1-2周的出入属正常范围,不影响体重计算。
</view>
<!--个人隐私 -->
<view class='xieyi'>
<view class='check_box' bindtap='choose'>
<image src='/images/righticon.png' wx:if = "{{choose}}" ></image>
</view>
<view class='xieyi_title' bindtap='viewxieyi'>用户个人隐私保护协议</view>
</view>
<!--保存按钮 -->
<view class='save_btn' bindtap='saveBaseInfo'>保存</view>
</view>
\ No newline at end of file
... ...
/* pages/baseInfo/baseInfo.wxss */
.z_container{
height: 100vh;
overflow: hidden;
}
.top_tips{
height: 122rpx;
background-color: #51DBA2;
padding: 0 60rpx;
font-size: 30rpx;
line-height: 45rpx;
color: #FFF;
}
.base_subform{
width: 640rpx;
margin: 30rpx auto;
}
.sub_item{
border-bottom: 1px solid #D8D8D8;
height: 88rpx;
display: flex;
align-items: center;
font-size: 34rpx;
color: #333;
justify-content: space-between;
}
.sub_item_input{
text-align: right;
font-size: 34rpx;
color: #999;
margin-left: auto;
-webkit-margin-start: auto;
}
.save_btn{
width: 670rpx;
margin: 0 auto;
height: 94rpx;
align-items: center;
justify-content: center;
background: #51DBA2;
color: #FFF;
font-size: 36rpx;
display: flex;
border-radius: 10rpx;
position: fixed;
bottom: 62rpx;
left: 40rpx;
}
.xieyi{
height: 44rpx;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
position: fixed;
bottom: 225rpx;
font-size: 30rpx;
color: #6DA9EB;
}
.check_box{
width: 44rpx;
height: 44rpx;
border-radius: 50%;
border: 1px solid #ccc;
margin-right: 17rpx;
}
.check_box image{
width: 100%;
height: 100%;
}
.danwei{
color: #999;
}
.shengming{
font-size: 28rpx;
color: #999;
margin: 0 74rpx;
}
\ No newline at end of file
... ...
// pages/bchao/bchao.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
},
addbchao(){
wx.navigateTo({
url: '/pages/addbchao/addbchao',
})
},
changeRecord(e){
let id = e.currentTarget.id;
wx.navigateTo({
url: '/pages/changebchao/changebchao?id='+id,
})
},
getRecords(){
let url = '/user/getBCLog'
app.post(url,{}).then((res)=>{
wx.hideLoading()
this.setData({
recordsList:res
})
}).catch((errMsg)=>{
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.getRecords()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "孕期B超",
"disableScroll": true
}
\ No newline at end of file
... ...
<!--pages/bchao/bchao.wxml-->
<view class='z_container'>
<view class='top_note'>
详细记录孕期B超检查结果,密切关注宝宝的每一个动向。
</view>
<view class='add_record' bindtap='addbchao'>
添加B超记录
</view>
<view class='record_lists'>
<view class='nodata' wx:if="{{recordsList.length==0}}">
无记录
</view>
<block wx:for="{{recordsList}}" wx:key="">
<view class='record_list'>
<view class='record_container'>
<view class='top_date'>
<view>{{item.create_date}}</view>
<view class='edit' bindtap='changeRecord' id='{{item.id}}'>修改</view>
</view>
<!--label -->
<view class='record_label'>
<view class='lable_item'>
<view>头围</view>
<view>mm</view>
</view>
<view class='lable_item'>
<view>腹围</view>
<view>mm</view>
</view>
<view class='lable_item'>
<view>股骨长</view>
<view>mm</view>
</view>
<view class='lable_item'>
<view>双顶径</view>
<view>mm</view>
</view>
</view>
<view class='label_detail_value'>
<view class='detail_value'>
{{item.head_circumference}}
</view>
<view class='detail_value'>
{{item.abdominal_circumference}}
</view>
<view class='detail_value'>
{{item.femur_length}}
</view>
<view class='detail_value'>
{{item.neck_length}}
</view>
</view>
</view>
</view>
</block>
</view>
</view>
\ No newline at end of file
... ...
/* pages/bchao/bchao.wxss */
.z_container{
background: #EFEFF4;
width: 100%;
height: 100vh;
display: flex;
display: -webkit-flex;
display: -webkit-box;
flex-flow: column;
-webkit-flex-flow: column;
-webkit-box-orient: vertical;
overflow-x: hidden;
}
.top_note{
width: 660rpx;
height: 100rpx;
margin: 65rpx auto 30rpx;
font-size: 30rpx;
color: #999;
}
.add_record{
width: 670rpx;
height: 94rpx;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: center;
font-size: 34rpx;
color: #666666;
border: 1rpx dashed #999;
border-radius: 10rpx;
}
.record_lists{
margin: 90rpx 40rpx 0;
-webkit-box-flex: 1;
-webkit-flex: 1;
flex: 1;
overflow: auto;
}
.record_list{
background-color: #FFF;
border-radius: 10rpx;
padding: 0 15rpx;
margin-bottom: 40rpx;
}
.top_date{
height: 74rpx;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 30rpx;
color: #999;
border-bottom: 1px solid #D8D8D8;
}
.edit{
width: 84rpx;
height: 44rpx;
display: flex;
align-items: center;
justify-content: center;
color: #FFF;
background-color: #51DBA2;
border-radius: 100rpx;
}
.record_label{
height: 122rpx;
display: flex;
justify-content: space-between;
border-bottom: 1rpx solid #D8D8D8;
}
.lable_item{
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
flex: 1;
font-size: 34rpx;
color: #000;
flex-direction: column;
font-weight: 500;
}
.label_detail_value{
display: flex;
justify-content: space-between;
align-items: center;
height: 90rpx;
}
.detail_value{
display: flex;
justify-content: center;
align-items: center;
flex: 1;
font-size: 30rpx;
color: #666;
}
.nodata{
height: 580rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 34rpx;
color: #999;
}
\ No newline at end of file
... ...
// pages/changeBaseInfo/changeBaseInfo.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
tempDate:'',
taiArry:[{
value: '1',
name:'单胞胎'
},{
value: '2',
name: '双胞胎'
}],
tai:['单胞胎','双包胎'],
index: 0,
is_single_birth: 1
},
getuserInfo() {
let url = '/user/getGravidaInfo'
app.post(url, {}).then((res) => {
console.log(res)
this.setData({
age: res.age,
height: res.height,
pre_weight: res.pre_weight,
last_menstruation: res.last_menstruation,
tempDate: res.last_menstruation,
current_weight: res.current_weight,
multiIndex:[res.week,res.day],
index:res.is_single_birth -1
// week: res.week,
// day: res.day,
})
})
},
bindtaichange(e){
console.log(e)
this.setData({
index: e.detail.value,
is_single_birth: this.data.taiArry[e.detail.value].value
})
},
inputDate: function (e) {
this.setData({
last_menstruation: e.detail.value
})
let params = {
last_menstruation: e.detail.value
}
// let url = '/user/checkEditLastMenstruationData'
// app.post(url, params).then(function(res){
// console.log(res)
// })
let tempurl = '/profile/getGestationalWeek'
let that = this;
app.post(tempurl, params).then((res) => {
that.setData({
week: res.week
})
}).catch((errMsg) => { })
},
inputAge(e){
console.log(e)
this.setData({
age: e.detail.value
})
},
inputHeight(e){
this.setData({
height: e.detail.value
})
},
inputWeight(e){
this.setData({
pre_weight: e.detail.value
})
},
bindMultiPickerChange: function (e) {
let chooseW = this.data.weeksArry[0][e.detail.value[0]]
let chooseD = this.data.weeksArry[1][e.detail.value[1]]
this.setData({
multiIndex: e.detail.value,
week: chooseW.id,
day: chooseD.id
})
},
bindMultiPickerColumnChange: function (e) {
},
inputCurrentWeight(e){
this.setData({
current_weight: e.detail.value
})
},
saveBaseInfo(){
let userinfo = {
age: this.data.age,
height: this.data.height,
pre_weight: this.data.pre_weight,
last_menstruation: this.data.last_menstruation,
is_single_birth: this.data.is_single_birth
// week: this.data.week,
// day: this.data.day,
// current_weight: this.data.current_weight
}
if (userinfo.age == null){
wx.showToast({
icon:'none',
title: '年龄不能为空',
})
return false;
} else if (userinfo.height == null){
wx.showToast({
icon: 'none',
title: '身高不能为空',
})
return false;
} else if (userinfo.pre_weight == null){
wx.showToast({
icon: 'none',
title: '孕前体重不能为空',
})
return false;
} else if (userinfo.last_menstruation == null){
wx.showToast({
icon: 'none',
title: '末次月经时间不能为空',
})
return false;
} else if(this.data.week > 41) {
console.log(this.data.week);
wx.showToast({
icon: 'none',
title: '经检测您初次录入末次月经日期与本次修改超出了正常孕期41周,请确认后重新输入',
})
// wx.showModal({
// title: '提示',
// //content: '经检测您初次录入末次月经日期与本次修改超出了正常孕期41周,系统将会删除超出的体重记录数据。',
// content: '经检测您初次录入末次月经日期与本次修改超出了正常孕期41周,请确认后重新输入',
// success: function(res){
// if(res.confirm){
// let url = '/user/editGravidaBaseInfo'
// app.post(url, userinfo).then((res) => {
// wx.showToast({
// title: '保存成功'
// })
// setTimeout(function () {
// wx.switchTab({
// url: '/pages/personal/personal',
// })
// }, 600)
// }).catch((errMsg) => {
// console.log(errMsg)
// })
// }
// }
// })
}else{
let url = '/user/editGravidaBaseInfo'
app.post(url, userinfo).then((res) => {
wx.showToast({
title: '保存成功'
})
setTimeout(function () {
wx.switchTab({
url: '/pages/personal/personal',
})
}, 600)
}).catch((errMsg) => {
console.log(errMsg)
})
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getuserInfo()
let tempData = []
let tempWeeks = []
let tempDays = []
for(let i = 0; i<=42 ; i++){
let tempText = '孕'+i+'周'
let tempw = {
id: i,
text: tempText
}
tempWeeks.push(tempw)
}
for (let i = 0; i < 7; i++) {
let tempText = '加' + i + '天'
let tempD = {
id: i,
text: tempText
}
tempDays.push(tempD)
}
tempData[0] = tempWeeks;
tempData[1] = tempDays;
this.setData({
weeksArry: tempData
})
this.setData({
endDate: app.nowDate(),
startDate: app.minDate()
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "基本信息",
"disableScroll": true
}
\ No newline at end of file
... ...
<!--pages/changeBaseInfo/changeBaseInfo.wxml-->
<view class='z_container'>
<!--信息记录 -->
<view class='info_box'>
<view class='info_item'>
<view>孕妇年龄</view>
<input class='info_item_input' type='number' value='{{age}}' bindinput='inputAge' />
<view class='danwei'>岁</view>
</view>
<view class='info_item'>
<view>孕妇身高</view>
<input class='info_item_input' type='digit' value='{{height}}' bindinput='inputHeight' />
<view class='danwei'>cm</view>
</view>
<view class='info_item'>
<view>孕前体重</view>
<input class='info_item_input' type='digit' value='{{pre_weight}}' bindinput='inputWeight' />
<view class='danwei'>kg</view>
</view>
<view class='info_item'>
<view>末次月经第一天</view>
<picker mode="date" class='sub_item_input' value="{{date}}" start="{{startDate}}" end="{{endDate}}" bindchange="inputDate">
<view class="picker">
<text class='danwei'>{{last_menstruation}}</text>
</view>
</picker>
</view>
<view class='info_item'>
<view>单/双胞胎</view>
<picker bindchange="bindtaichange" class='sub_item_input' value="{{index}}" range="{{tai}}">
<view class="picker">
<text class='danwei'>{{tai[index]}}</text>
</view>
</picker>
</view>
</view>
<view class='save_btn' bindtap='saveBaseInfo'>保存</view>
</view>
... ...
/* pages/changeBaseInfo/changeBaseInfo.wxss */
@import '../addbchao/addbchao.wxss';
.danwei{
color: #999;
font-size: 34rpx;
}
.info_item_input{
margin-left: auto;
}
\ No newline at end of file
... ...
// pages/addbchao/addbchao.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
weeksArry: [],
create_date:'',
head_circumference: '',
abdominal_circumference: '',
femur_length: '',
neck_length: '',
tempId:''
},
getWeeks() {
let url = '/user/getWeekDay'
app.post(url, {}).then((res) => {
console.log(res)
this.setData({
multiIndex: [res.default.week, res.default.day],
week: res.default.week,
day: res.default.day
})
console.log(this.data.multiIndex)
let tempData = []
let tempWeeks = []
let tempDays = []
for (let i = 0; i <= this.data.week; i++) {
let tempText = '孕期' + i + '周'
let tempw = {
id: i,
text: tempText
}
tempWeeks.push(tempw)
}
for (let i = 0; i <= this.data.day; i++) {
let tempText = '加' + i + '天'
let tempD = {
id: i,
text: tempText
}
tempDays.push(tempD)
}
tempData[0] = tempWeeks;
tempData[1] = tempDays;
this.setData({
weeksArry: tempData
})
}).catch((errMsg) => {
})
},
bindMultiPickerChange: function (e) {
console.log(e)
let chooseW = this.data.weeksArry[0][e.detail.value[0]]
let chooseD = this.data.weeksArry[1][e.detail.value[1]]
this.setData({
multiIndex: e.detail.value,
week: chooseW.id,
day: chooseD.id
})
},
bindMultiPickerColumnChange: function (e) {
console.log(e)
let row = e.detail.column;
let value = e.detail.value;
let baseWeek = this.data.week;
let weeksArry = this.data.weeksArry;
let tempDays = [];
let nowDays = []
if (row == 0) {
if (value < baseWeek) {
for (let i = 0; i < 7; i++) {
let tempText = '加' + i + '天'
let tempD = {
id: i,
text: tempText
}
tempDays.push(tempD)
}
weeksArry[1] = tempDays;
this.setData({
weeksArry: weeksArry
})
} else {
for (let i = 0; i <= this.data.day; i++) {
let tempText = '加' + i + '天'
let tempD = {
id: i,
text: tempText
}
nowDays.push(tempD)
}
weeksArry[1] = nowDays;
this.setData({
weeksArry: weeksArry
})
}
}
},
getHead(e) {
this.setData({
head_circumference: e.detail.value
})
},
getadominal(e) {
this.setData({
abdominal_circumference: e.detail.value
})
},
getfemur(e) {
this.setData({
femur_length: e.detail.value
})
},
getneck(e) {
this.setData({
neck_length: e.detail.value
})
},
savebinfo() {
let url = '/user/editBCLog'
let params = {
create_date: this.data.create_date,
head_circumference: this.data.head_circumference,
abdominal_circumference: this.data.abdominal_circumference,
femur_length: this.data.femur_length,
neck_length: this.data.neck_length,
id: this.data.tempId
}
console.log(params)
if (params.head_circumference == '') {
wx.showToast({
title: '请输入头围',
icon: 'none'
})
return false
} else if (params.abdominal_circumference == '') {
wx.showToast({
title: '请输入腹围',
icon: 'none'
})
return false
} else if (params.femur_length == '') {
wx.showToast({
title: '请输入股骨长',
icon: 'none'
})
return false
} else if (params.neck_length == '') {
wx.showToast({
title: '请输入胎儿头颈长度',
icon: 'none'
})
return false
} else {
app.post(url, params).then((res) => {
wx.showToast({
title: '修改成功'
})
setTimeout(function () {
wx.switchTab({
url: '/pages/bchao/bchao',
})
}, 1000)
})
}
},
getinfo(){
let url = '/user/getBCLogDetail'
app.post(url,{id:this.data.tempId}).then((res)=>{
this.setData({
create_date: res.create_date,
head_circumference: res.head_circumference,
abdominal_circumference: res.abdominal_circumference,
femur_length: res.femur_length,
neck_length: res.neck_length,
})
}).catch((errMsg)=>{
})
},
inputDate: function (e) {
this.setData({
create_date: e.detail.value
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
tempId: options.id,
endDate: app.nowDate(),
startDate: app.minDate()
})
this.getinfo()
// let tempData = []
// let tempWeeks = []
// let tempDays = []
// for (let i = 0; i <= 42; i++) {
// let tempText = '孕期' + i + '周'
// let tempw = {
// id: i,
// text: tempText
// }
// tempWeeks.push(tempw)
// }
// for (let i = 0; i < 7; i++) {
// let tempText = '加' + i + '天'
// let tempD = {
// id: i,
// text: tempText
// }
// tempDays.push(tempD)
// }
// tempData[0] = tempWeeks;
// tempData[1] = tempDays;
// this.setData({
// weeksArry: tempData
// })
// this.getWeeks();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "修改B超记录",
"disableScroll": true
}
\ No newline at end of file
... ...
<view class='z_container'>
<!--信息记录 -->
<view class='info_box'>
<view class='info_item'>
<view>B超检查日期</view>
<!-- <text class='info_item_input'>{{create_date}}</text> -->
<picker mode="date" class='sub_item_input' value="{{date}}" start="{{startDate}}" end="{{endDate}}" bindchange="inputDate">
<view class="picker">
<text class='info_item_input'>{{create_date}}</text>
</view>
</picker>
</view>
<view class='info_item'>
<view>头围</view>
<input class='info_item_input' type='digit' value='{{head_circumference}}' bindinput='getHead' placeholder='' />
<view class='danwei'>mm</view>
</view>
<view class='info_item'>
<view>腹围</view>
<input class='info_item_input' type='digit' value='{{abdominal_circumference}}' bindinput='getadominal' placeholder='' />
<view class='danwei'>mm</view>
</view>
<view class='info_item'>
<view>股骨长</view>
<input class='info_item_input' type='digit' value='{{femur_length}}' bindinput='getfemur' placeholder='' />
<view class='danwei'>mm</view>
</view>
<view class='info_item'>
<view>双顶径</view>
<input class='info_item_input' type='digit' value='{{neck_length}}' bindinput='getneck' placeholder='' />
<view class='danwei'>mm</view>
</view>
</view>
<view class='save_btn' bindtap='savebinfo'>保存</view>
</view>
\ No newline at end of file
... ...
/* pages/changebchao/changebchao.wxss */
@import '../addbchao/addbchao.wxss'
\ No newline at end of file
... ...
//index.js
//获取应用实例
const app = getApp()
Page({
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo')
},
//事件处理函数
bindViewTap: function() {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad: function () {
if (app.globalData.userInfo) {
this.setData({
userInfo: app.globalData.userInfo,
hasUserInfo: true
})
} else if (this.data.canIUse){
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
app.userInfoReadyCallback = res => {
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
} else {
// 在没有 open-type=getUserInfo 版本的兼容处理
wx.getUserInfo({
success: res => {
app.globalData.userInfo = res.userInfo
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
}
},
getUserInfo: function(e) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
})
... ...
{}
\ No newline at end of file
... ...
<!--index.wxml-->
<view class="container">
<view class="userinfo">
<button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
<block wx:else>
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" background-size="cover"></image>
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
</block>
</view>
<view class="usermotto">
<text class="user-motto">{{motto}}</text>
</view>
</view>
... ...
/**index.wxss**/
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
}
.userinfo-avatar {
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
}
.userinfo-nickname {
color: #aaa;
}
.usermotto {
margin-top: 200px;
}
\ No newline at end of file
... ...
//logs.js
const util = require('../../utils/util.js')
Page({
data: {
logs: []
},
onLoad: function () {
this.setData({
logs: (wx.getStorageSync('logs') || []).map(log => {
return util.formatTime(new Date(log))
})
})
}
})
... ...
{
"navigationBarTitleText": "查看启动日志"
}
\ No newline at end of file
... ...
<!--logs.wxml-->
<view class="container log-list">
<block wx:for="{{logs}}" wx:for-item="log">
<text class="log-item">{{index + 1}}. {{log}}</text>
</block>
</view>
... ...
.log-list {
display: flex;
flex-direction: column;
padding: 40rpx;
}
.log-item {
margin: 10rpx;
}
... ...
// pages/personal/personal.js
// c
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
},
getuserBaseInfo() {
let url = '/user/getGravidaInfo'
app.post(url, {}).then((res) => {
wx.hideLoading()
this.setData({
age: res.age,
height: res.height,
pre_weight: res.pre_weight,
last_menstruation: res.last_menstruation,
week: res.week,
day: res.day,
name: res.name,
current_weight: res.current_weight,
is_single_birth: res.is_single_birth
})
})
},
getUserInfo(){
wx.navigateTo({
url: '../userInfo/userInfo',
})
},
changebaseInfo(){
wx.navigateTo({
url: '../changeBaseInfo/changeBaseInfo',
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.getuserBaseInfo()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "个人中心",
"disableScroll": true
}
\ No newline at end of file
... ...
<!--pages/personal/personal.wxml-->
<view class='z_container'>
<!--个人信息 -->
<view class='person_info'>
<open-data type="userAvatarUrl" class='image_box'></open-data>
<view class='name'>{{name}}</view>
</view>
<!--周莉医生用户信息-->
<view class='userInfo' bindtap='getUserInfo'>
<view class='left'>
<view class='userInfo_note'>周莉医生用户信息</view>
<view class='userInfo_note_tips'>周莉医生用户请将该内容补充完整</view>
</view>
<view class='right'>
<image src='/images/next.png'></image>
</view>
</view>
<!--baseInfo-->
<view class='baseInfo'>
<view class='baseInfo_item baseInfo_item_top'>
<view style='color:#000'>基本信息</view>
<view class='action' bindtap='changebaseInfo'>修改</view>
</view>
<view class='baseInfo_item'>
<view>孕妇年龄</view>
<view class='detail'>{{age}}岁</view>
</view>
<view class='baseInfo_item'>
<view>孕妇身高</view>
<view class='detail'>{{height}}cm</view>
</view>
<view class='baseInfo_item'>
<view>孕前体重</view>
<view class='detail'>{{pre_weight}}kg</view>
</view>
<view class='baseInfo_item'>
<view>末次月经第一天</view>
<view class='detail'>{{last_menstruation}}</view>
</view>
<view class='baseInfo_item'>
<view>单双胞胎</view>
<view class='detail'>{{is_single_birth=='2'?'双胞胎':'单胞胎'}}</view>
</view>
<!-- <view class='baseInfo_item'>
<view>孕周</view>
<view class='detail'>孕期{{week}}周+{{day}}天</view>
</view>
<view class='baseInfo_item'>
<view>孕妇当前体重</view>
<view class='detail'>{{current_weight}}kg</view>
</view> -->
</view>
</view>
\ No newline at end of file
... ...
/* pages/personal/personal.wxss */
.z_container{
height: 100vh;
background-color: #EFEFF4;
}
.person_info{
height: 170rpx;
width: 100%;
display: flex;
align-items: center;
padding-left: 30rpx;
background: #FFF;
}
.image_box{
width: 106rpx;
height: 106rpx;
border-radius: 50%;
overflow: hidden;
margin-right: 34rpx;
}
.image_box image{
width: 100%;
height: 100%;
}
.name{
font-size: 30rpx;
}
.userInfo{
height: 120rpx;
background: #FFF;
display: flex;
padding-left: 30rpx;
margin-top: 30rpx;
margin-bottom: 30rpx;
align-items: center;
justify-content: center;
}
.left{
display: flex;
flex-direction: column;
justify-content: center;
font-size: 34rpx;
}
.right{
flex: 1;
height: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
}
.right image{
width: 30rpx;
height: 30rpx;
margin-right: 30rpx;
}
.userInfo_note_tips{
font-size: 26rpx;
color: #999;
}
.baseInfo{
margin-top: 30rpx;
background-color: #FFF;
}
.baseInfo_item{
padding: 0 30rpx;
height: 88rpx;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 34rpx;
color: #666;
border-bottom: 1rpx solid #D8D8D8;
}
.baseInfo_item:last-child{
border: none;
}
.baseInfo_item_top{
height: 98rpx;
}
.action{
color: #FFF;
width: 84rpx;
height: 50rpx;
background: #51DBA2;
border-radius: 100px;
justify-content: center;
align-items: center;
font-size: 30rpx;
display: flex;
}
.bottom_menu{
display: flex;
align-items: center;
justify-content: space-around;
height: 98rpx;
background: #F7F7FA;
position: fixed;
bottom: 0;
left: 0;
width: 100%;
border-top: 1rpx solid rgba(247,247,250,.1);
}
\ No newline at end of file
... ...
// pages/startRecord/startRecord.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
// hasToken: false
},
startrecord(){
let url = '/user/getGravidaInfo';
app.post(url,{}).then((res)=>{
if(res.id){
wx.switchTab({
url: '/pages/weight/weight',
})
}else{
wx.navigateTo({
url: '/pages/baseInfo/baseInfo',
})
}
}).catch((errMsg)=>{
})
},
getUserInfo(e) {
let detail = e.detail ;
let that = this ;
wx.login({
success: (res) => {
// 获取code
let code = res.code;
let codeurl = '/public/login';
let params = {
code: code,
encrypted_data: detail.encryptedData,
doctor_id:'',
iv: detail.iv,
raw_data: detail.rawData,
signature: detail.signature,
doctor_id: wx.getStorageSync('doctor_id')
}
console.log(params)
wx.showLoading({
title: '加载中',
})
app.post(codeurl, params).then((res) => {
//正确返回结果
console.log(res)
wx.setStorageSync('token', res.token)
this.setData({
hasToken: true
})
wx.hideLoading()
// 登陆后跳转
that.startrecord()
}).catch((errMsg) => {
console.log(errMsg);//错误提示信息
});
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let token = wx.getStorageSync('token')
if (token != '' && token != null && typeof token != undefined) {
this.setData({
hasToken: true
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"disableScroll": true
}
\ No newline at end of file
... ...
<!--pages/startRecord/startRecord.wxml-->
<view class='z_container'>
<view class='top_png'>
<image src='/images/zhouli.png'></image>
</view>
<!--note -->
<view class='note'>周密记录 顺莉生产</view>
<view class='introduce'>
<view class='introduce_note'>你好,我是北京妇产医院</view>
<view class='introduce_note'>产科主任医师周莉</view>
<!-- <view class='introduce_note'>我与您一起关注您的孕期体重</view> -->
<!-- <view class='introduce_note'>孕期体重小帮手</view> -->
<!-- <view class='introduce_note'>记录、见证你和宝宝的十月旅程</view> -->
<!-- <view class='introduce_note'></view> -->
</view>
<view class='stratBtn' wx:if="{{hasToken}}" bindtap='startrecord'>开始记录</view>
<button class='stratBtn' wx:else open-type="getUserInfo" bindgetuserinfo="getUserInfo">开始记录</button>
</view>
... ...
/* pages/startRecord/startRecord.wxss */
.top_png{
width: 750rpx;
height: 640rpx;
background: #51DBA2;
display: flex;
align-items: center;
justify-content: center;
}
.top_png image{
width: 100%;
height: 100%;
}
.note{
display: flex;
align-items: center;
justify-content: center;
font-size: 74rpx;
margin-top: 60rpx;
}
.introduce{
margin-top: 17rpx;
}
.introduce_note{
font-size: 36rpx;
color: #999;
display: flex;
align-items: center;
justify-content: center;
line-height: 1.6;
}
.stratBtn{
width: 670rpx;
height: 94rpx;
background: #51DBA2;
border-radius: 10rpx;
margin-left: 40rpx;
margin-top: 60rpx;
display: flex;
justify-content: center;
align-items: center;
font-size: 36rpx;
color: #FFF;
}
\ No newline at end of file
... ...
// pages/userInfo/userInfo.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
},
inputName(e){
this.setData({
name: e.detail.value
})
},
inputNum(e){
this.setData({
archives_number: e.detail.value
})
},
inputMobile(e){
this.setData({
mobile: e.detail.value
})
},
getuserInfo(){
let url = '/user/getGravidaInfo'
app.post(url,{}).then((res)=>{
console.log(res)
this.setData({
name: res.name,
archives_number: res.archives_number,
mobile: res.mobile
})
})
},
settingUserInfo(){
let params = {
name: this.data.name,
archives_number: this.data.archives_number,
mobile: this.data.mobile
}
let reg = /^1[3|4|5|7|8][0-9]{9}$/;
if(params.name == '' || typeof params.name == 'undefined' || params.name == null){
wx.showToast({
title: '请填写姓名',
icon: 'none'
})
return false
} else if (params.archives_number == '' || typeof params.archives_number == 'undefined'){
wx.showToast({
title: '请填写建档编号',
icon: 'none'
})
return false
} else if (!reg.test(params.mobile)){
wx.showToast({
title: '联系方式不正确',
icon: 'none'
})
return false
} else{
let url = '/profile/setGravidaInfo'
app.post(url, params).then((res) => {
console.log(res)
wx.showToast({
title: '提交成功',
})
wx.switchTab({
url: '/pages/personal/personal',
})
}).catch((errMsg) => {
})
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getuserInfo()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "用户信息",
"disableScroll": true
}
\ No newline at end of file
... ...
<!--pages/userInfo/userInfo.wxml-->
<view class='z_container'>
<view class='user_top'>
周莉医生用户请将以下的内容补充完整,这可以让医生更好的为您诊断。
</view>
<!--信息记录 -->
<view class='info_box'>
<view class='info_item'>
<view>姓名</view>
<input class='info_item_input' value='{{name}}' bindinput='inputName' />
</view>
<view class='info_item'>
<view>建档登记号</view>
<input class='info_item_input' value='{{archives_number}}' placeholder='请输入建档登记号' bindinput='inputNum' />
</view>
<view class='info_item'>
<view>联系电话</view>
<input class='info_item_input' value='{{mobile}}' type='number' placeholder='请输入联系电话' bindinput='inputMobile' />
</view>
</view>
<view class='save_btn' bindtap='settingUserInfo'>保存</view>
</view>
... ...
/* pages/userInfo/userInfo.wxss */
.z_container{
background-color: #EFEFF4;
height: 100vh;
}
.user_top{
font-size: 30rpx;
padding: 30rpx 46rpx 18rpx;
color: #999;
}
.info_box{
background: #FFF;
padding: 0 36rpx 0 30rpx;
}
.info_item{
height: 88rpx;
border-bottom: 1px solid #E5E5E5;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 34rpx;
color: #333333;
}
.info_item:last-child{
border: none;
}
.info_item_input{
color: #999;
text-align: right;
margin-left: auto;
}
.save_btn{
color: #FFF;
display: flex;
align-items: center;
justify-content: center;
background: #51DBA2;
width: 670rpx;
height: 94rpx;
position: fixed;
bottom: 50rpx;
left: 40rpx;
border-radius: 10rpx;
}
\ No newline at end of file
... ...
// pages/weight/weight.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
weightLists:[],
show: false,
showtype:0,
mask: false,
rote: -15
},
add_record(){
wx.navigateTo({
url: '/pages/addWeight/addWeight',
})
},
get_records(){
let url = '/user/getWeightLog'
app.post(url,{}).then((res)=>{
let rote = parseInt(res.new.scale)
this.setData({
weightLists: res.list,
latestRecord: res.new,
bmi: res.bmi,
rote: rote - 90,
week: res.new.week,
day: res.new.day,
nowWeight: res.new.weight,
residual_quota: res.new.residual_quota,
increase: res.new.increase,
residual_msg: res.new.residual_msg,
baseData:{
week: res.new.week,
day: res.new.day,
nowWeight: res.new.weight,
rote: rote - 90,
residual_quota: res.new.residual_quota,
residual_msg: res.new.residual_msg,
increase: res.new.increase
}
})
let status = this.data.weightLists[0].sign_status
let newWeight = wx.getStorageSync('newWeight')
// let type = status == '1' && 'newWeight' ? '1' : status == '2' && 'newWeight' ? '2' : status == '3' && newWeight ? '3' : status == '4' && newWeight ? '4' : status == '5' && newWeight?'5':'';
if (newWeight){
this.setData({
showtype: 8,
mask: true,
sign_mbi: this.data.weightLists[0].sign_mbi
})
}
}).catch((errMsg)=>{
})
},
showTips(){
let that = this;
let show = this.data.show;
if(!show){
that.setData({
show: !that.data.show
})
setTimeout(function(){
that.setData({
show: !that.data.show
})
},3000)
}
},
showtoast(e){
console.log(e)
let rote = parseInt(e.currentTarget.dataset.roate)
this.setData({
showtype: 8,
mask: true,
sign_mbi: e.currentTarget.dataset.current.sign_mbi,
rote: rote - 90,
week: e.currentTarget.dataset.current.week,
day: e.currentTarget.dataset.current.day,
nowWeight: e.currentTarget.dataset.current.current_weight,
residual_quota: e.currentTarget.dataset.current.residual_quota,
residual_msg: e.currentTarget.dataset.current.residual_msg,
increase: e.currentTarget.dataset.current.increase
})
},
closefirst(){
this.setData({
showtype: 0,
mask: false
// rote: this.data.baseData.rote,
// week: this.data.baseData.week,
// day: this.data.baseData.day,
// nowWeight: this.data.baseData.nowWeight
})
wx.removeStorageSync('first')
wx.removeStorageSync('newWeight')
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let first = wx.getStorageSync('first')
if (first) {
this.setData({
showtype: 6,
mask: true
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.get_records();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "体重记录",
"disableScroll": true
}
\ No newline at end of file
... ...
<!--pages/weight/weight.wxml-->
<view class='z_container'>
<view class='top_watch' >
<view class='todayData'>
<view class='now_data'>孕{{week}}周+{{day}}天</view>
<view class='now_weight'>{{nowWeight}}</view>
</view>
<view class='images_box'>
<image src='/images/circle.png'></image>
</view>
<!--顶部数据 -->
<view class='data_1 data'>{{bmi[0]}}Kg</view>
<view class='data_2 data'>{{bmi[1]}}Kg</view>
<view class='data_3 data'>{{bmi[2]}}Kg</view>
<view class='data_4 data'>{{bmi[3]}}Kg</view>
<!--指针 -->
<image src='/images/zhizhen.png' class='zhizhen' style='transform: rotate({{rote}}deg);'></image>
</view>
<!--topData -->
<view class='top_data'>
<view class='left_data'>
<view class='top_direc'>
{{increase}}
<view class='danwei'>kg</view>
</view>
<view class='top_label'>
较孕前增长
</view>
</view>
<view class='right_data'>
<view class='top_direc'>
{{residual_quota}}
<view class='danwei'>kg</view>
</view>
<view class='top_label' bindtap='showTips'>
<text wx:if="{{residual_quota>0}}">剩余配额</text>
<text wx:else>超过配额</text>
<view class='tips'>!</view>
</view>
</view>
<view class='latestips {{show?"show":""}}'>
<view class='tips_box'>
{{residual_msg}}</view>
</view>
</view>
<!--container -->
<view class='record_container'>
<!--添加记录-->
<view class='add_icon' bindtap='add_record'>
<image src='/images/+@2x.png'></image>
</view>
<!--记录列表-->
<view class='record_label'>
<view class='label_item'>
孕期
</view>
<view class='label_item'>
体重 kg
</view>
<view class='label_item'>
状态
</view>
</view>
<view class='record_lists'>
<block wx:for="{{weightLists}}" wx:key="" >
<view class='record_list' bindtap='showtoast' id='{{item.sign_status}}' data-mbi="{{item.sign_mbi}}" data-roate='{{item.scale}}' data-current="{{item}}">
<view class='record_list_item'>孕{{item.week}}周+{{item.day}}天</view>
<view class='record_list_item'>{{item.current_weight}}</view>
<view class='record_list_item'>
<view class='chaoqing weight_type {{item.sign_status=="1"?"active":""}}'>
<image class='type_icon' src='/images/copy.png'></image>
<text class='cq'>超轻</text>
</view>
<view class='chaoqing weight_type {{item.sign_status=="2"?"active":""}}'>
<image class='type_icon' src='/images/copy.png' ></image>
<text class='cq'>消瘦</text>
</view>
<text class='zhengchang weight_type {{item.sign_status=="3"?"active":""}}' >正常</text>
<view class='chaozhong weight_type {{item.sign_status=="4"?"active":""}}'>
<image class='type_icon' src='/images/up.png'></image>
<text class='cq'>偏重</text>
</view>
<view class='chaozhong weight_type {{item.sign_status=="5"?"active":""}}' >
<image class='type_icon' src='/images/up.png'></image>
<text class='cq'>超重</text>
</view>
</view>
</view>
</block>
</view>
</view>
<view class='biaozhu'>注:算法数据来源于美国医学研究所(IOM)</view>
</view>
<view class='mask' wx:if="{{mask}}" bindtap='closefirst'>
<!--初始测量提示框 -->
<view class='tongyi_toast' wx:if="{{showtype==6}}">
<view class='toast_container'>
<view class='shengming'>体重测量的正确姿势:</view>
<view class='detail'>早上起床后;排空大小便;穿同样的衣服;尽量在吃早饭之前。因为这样称体重,受外界影响比较小,会比较准确。</view>
</view>
<view class='liaojie' bindtap='closefirst'>知道了</view>
</view>
<!--正常 -->
<view class='tongyi_toast' wx:if="{{showtype=='3'}}">
<view class='toast_container'>
<view class='detail'>{{sign_mbi}}</view>
</view>
<view class='liaojie' bindtap='closefirst'>知道了</view>
</view>
<!--超轻 -->
<view class='tongyi_toast' wx:if="{{showtype=='1'}}">
<view class='toast_container'>
<view class='detail'>您目前体重过轻,为不影响您和宝宝的健康,需为身体增加能量,加强营养,您可在公众号图文消息中查看孕妇体重过轻如何增重。</view>
</view>
<view class='liaojie' bindtap='closefirst'>知道了</view>
</view>
<!--偏轻 -->
<view class='tongyi_toast' wx:if="{{showtype=='2'}}">
<view class='toast_container'>
<view class='detail'>您目前体重偏低,为不影响您和宝宝的健康,需为身体增加能量,加强营养,您可在公众号图文消息中查看体重偏低如何增重。</view>
</view>
<view class='liaojie' bindtap='closefirst'>知道了</view>
</view>
<!--超重-->
<view class='tongyi_toast' wx:if="{{showtype=='4'}}">
<view class='toast_container'>
<view class='detail'>您目前体重偏重,为了不影响您和宝宝的健康,建议控制体重增长速度,少食多餐适当运动,您可在公众号图文消息中查看孕期如何合理饮食。</view>
</view>
<view class='liaojie' bindtap='closefirst'>知道了</view>
</view>
<view class='tongyi_toast' wx:if="{{showtype=='5'}}">
<view class='toast_container'>
<view class='detail'>您目前体重超重,为了不影响您和宝宝的健康,建议减重,为避免发生妊娠期合并症,适当运动,您可在公众号图文消息中查看孕期如何科学减重。</view>
</view>
<view class='liaojie' bindtap='closefirst'>知道了</view>
</view>
<!--点击提示 -->
<view class='tongyi_toast' wx:if="{{showtype=='8'}}">
<view class='toast_container'>
<view class='detail'>{{sign_mbi}}</view>
</view>
<view class='liaojie' bindtap='closefirst'>知道了</view>
</view>
</view>
\ No newline at end of file
... ...
/* pages/weight/weight.wxss */
.z_container{
height: 100vh;
overflow: hidden;
background: -webkit-linear-gradient(#52DCA3, #F6FFD5);
background: -o-linear-gradient(#52DCA3, #F6FFD5);
background: -moz-linear-gradient(#52DCA3, #F6FFD5);
background: linear-gradient(#52DCA3, #F6FFD5);
}
.top_watch{
height: 240rpx;
width: 370rpx;
margin: 0 auto;
position: relative;
}
.top_watch image{
width: 100%;
height: 100%;
}
.top_watch .data{
position: absolute;
color: #FFF;
font-size: 25rpx;
z-index: 15;
}
.data_1{
top: 90rpx;
left: -10rpx;
transform: rotate(-54deg);
}
.data_2{
top: 20rpx;
transform: rotate(-18deg);
left: 94rpx;
}
.data_3{
top: 20rpx;
transform: rotate(18deg);
right: 94rpx;
}
.data_4{
top: 90rpx;
transform: rotate(54deg);
right: -10rpx;
}
.images_box{
width: 100%;
height: 185rpx;
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
}
.top_data{
margin: 13rpx 95rpx 0 118rpx;
display: flex;
justify-content: space-between;
color: #FFF;
position: relative;
}
.latestips{
width: 400rpx;
height: 110rpx;
background: #FFF;
position: absolute;
top: 25rpx;
left: -80rpx;
border-radius: 10rpx;
opacity: 0;
transition: 1s;
}
.latestips.show{
opacity: 1;
}
.tips_box{
width: 100%;
height: 100%;
position: relative;
box-sizing: border-box;
padding: 0rpx 10rpx 5rpx 13rpx;
display: flex;
align-items: center;
font-size: 28rpx;
color: #51DBA2;
}
.tips_box:after{
content: '';
display: block;
bottom: 8rpx;
right: -22rpx;
position: absolute;
width: 0;
height: 0;
border-left: 24rpx solid #FFF;
border-top: 10rpx solid transparent;
border-bottom: 10rpx solid transparent;
}
.top_direc{
display: flex;
color: #FFF;
font-size: 64rpx;
height: 90rpx;
font-weight: bold;
align-items: center;
}
.danwei{
font-size: 34rpx;
display: flex;
align-items: flex-end;
justify-content: center;
height: 64rpx;
font-weight: normal;
margin-left: 20rpx;
}
.top_label{
font-size: 30rpx;
display: flex;
align-items: center;
justify-content: center;
}
.tips{
width: 48rpx;
height: 48rpx;
border-radius: 50%;
background-color: #FFF;
color: #DDD;
display: flex;
align-items: center;
margin-left: 15rpx;
justify-content: center;
}
.record_container{
width: 670rpx;
height:570rpx;
background-color: #FFF;
margin: 0 auto;
margin-top: 60rpx;
border-radius: 10rpx;
position: relative;
padding: 0 15rpx;
padding-top: 60rpx;
box-sizing: border-box;
margin-bottom: 4rpx;
}
.add_icon{
width: 100rpx;
height: 100rpx;
display: flex;
align-items: center;
justify-content: center;
position: absolute;
left: 50%;
top: -50rpx;
transform: translateX(-50%);
}
.add_icon image{
width: 100%;
height: 100%;
}
.record_label{
font-size: 34rpx;
color: #333;
font-weight: bold;
display: flex;
justify-content: space-between;
border-bottom: 1rpx solid #D8D8D8;
}
.label_item,.record_list_item{
height: 88rpx;
display: flex;
flex: 1;
align-items: center;
justify-content: center;
}
.type_icon{
width: 28rpx;
height: 28rpx;
margin-right: 8rpx;
}
.record_lists{
height: 430rpx;
overflow-y: auto;
}
.record_list{
font-size: 30rpx;
color: #666;
display: flex;
border-bottom: 1rpx solid #D8D8D8;
}
.record_list:last-child{
border: none;
}
.zhengchang{
color: #56DCA5;
display: none;
}
.chaoqing{
color: #78D2DF;
display: none;
}
.chaozhong{
color: #AA6E6E;
}
.biaozhu{
font-size: 26rpx;
color: #7DAA97;
padding: 10rpx 73rpx;
}
image.zhizhen{
width: 14rpx;
position: absolute;
bottom: 0;
z-index: 15;
height: 193rpx;
left: 50%;
top: 50%;
margin: -75rpx 0 0 -7rpx;
transform-origin: bottom;
-webkit-transform-origin: bottom;
transform: rotate(0deg) ;
transition: 1s;
}
.weight_type{
display: none;
}
.weight_type.active{
display: block;
}
.todayData{
text-align: center;
color: #FFF;
position: absolute;
top: 140rpx;
width: 100%;
font-size: 30rpx;
}
.now_weight{
font-size: 64rpx;
line-height: 64rpx;
font-weight: bold;
}
.mask{
width: 100%;
height: 100%;
display: flex;
position: fixed;
top: 0;
left: 0;
background: rgba(0, 0, 0, .3);
z-index: 20;
}
.tongyi_toast{
width: 560rpx;
margin: 0 auto;
margin-top: 423rpx;
background: #FFF;
border-radius: 10rpx;
overflow: hidden;
position: absolute;
left: 50%;
transform: translateX(-50%);
padding-bottom: 100rpx;
}
.toast_container{
padding: 24rpx;
font-size: 30rpx;
text-align: center;
color: #666;
line-height: 52rpx;
}
.shengming{
text-align: center;
margin-bottom: 10rpx;
}
.liaojie{
height: 100rpx;
border-top: 1rpx #E5E5E5 solid;
display: flex;
align-items: center;
justify-content: center;
font-size: 36rpx;
color: #02BB00;
position: absolute;
bottom: 0;
left: 0;
right: 0;
}
\ No newline at end of file
... ...
// pages/xiyiDetail/xieyidetail.js
let WxParse = require('../../wxParse/wxParse.js');
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
contentHtml: '',
xieyiTitle:''
},
accept(){
wx.navigateBack()
},
//获取协议内容
getxieyi(){
let url = '/Article/getAgreement'
let that = this;
wx.showLoading({
title: '加载中',
})
app.post(url,{}).then((res)=>{
wx.hideLoading()
that.setData({
xieyiTitle: res.post_title
})
WxParse.wxParse('contentHtml', 'html', res.post_content, that, 5);
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getxieyi()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "用户个人隐私保护协议"
}
\ No newline at end of file
... ...
<!--pages/xiyiDetail/xieyidetail.wxml-->
<view class='z_container'>
<view class='xieyiTitle'>{{xieyiTitle}}</view>
<view class='xieyi_detail'>
<import src="/wxParse/wxParse.wxml"/>
<template is="wxParse" data="{{wxParseData:contentHtml.nodes}}"/>
</view>
<view class='accept' bindtap='accept'>接受</view>
</view>
... ...
/* pages/xiyiDetail/xieyidetail.wxss */
.xieyi_detail{
margin: 0 30rpx;
min-height: 100rpx;
font-size: 34rpx;
color: #666;
padding-top: 30rpx;
padding: 0 30rpx;
}
.accept{
width: 670rpx;
height: 94rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 36rpx;
border-radius: 10rpx;
background: #51DBA2;
color: #FFF;
margin: 0 auto;
margin-bottom: 60rpx;
margin-top: 67rpx;
}
.xieyiTitle{
display: flex;
align-items: center;
justify-content: center;
height: 60rpx;
margin-bottom: 50rpx;
margin-top: 40rpx;
}
\ No newline at end of file
... ...
{
"description": "项目配置文件。",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": false,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true
},
"compileType": "miniprogram",
"libVersion": "2.3.2",
"appid": "wx75855734b0730d64",
"projectname": "%E5%91%A8%E8%8E%89%E5%AD%95%E6%9C%9F%E4%BD%93%E9%87%8D%E7%AE%A1%E7%90%86",
"isGameTourist": false,
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"plugin": {
"current": -1,
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"miniprogram": {
"current": -1,
"list": []
}
}
}
\ No newline at end of file
... ...
exports.app_key = "63f73e26b4723f56932f2029a356dd52"; //请在此行填写从阿拉丁后台获取的appkey
exports.getLocation = false; //默认不获取用户坐标位置
exports.plugin = false; //您的小程序中是否使用了插件。根据是否启用插件会有不同的接入方式,请参考文档文档。
\ No newline at end of file
... ...
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):n.Ald=t()}(this,function(){function n(n){this.app=n}function t(t){O=t,this.aldstat=new n(this),y("app","launch")}function o(n){if(O=n,C=n.query.ald_share_src,F=n.query.aldsrc||"",j=n.query.ald_share_src,U=Date.now(),A=Date.now(),!tn){I=""+Date.now()+Math.floor(1e7*Math.random()),E=!1;try{wx.setStorageSync("ald_ifo",!1)}catch(n){}}tn=!1,0!==b&&Date.now()-b>3e5&&(T=""+Date.now()+Math.floor(1e7*Math.random()),A=Date.now()),n.query.ald_share_src&&"1044"==n.scene&&n.shareTicket?wx.getShareInfo({shareTicket:n.shareTicket,success:function(n){G=n,_("event","ald_share_click",JSON.stringify(n))}}):n.query.ald_share_src&&_("event","ald_share_click",1),""===K&&wx.getSetting({withCredentials:!0,success:function(n){if(n.authSetting["scope.userInfo"]){wx.getUserInfo({withCredentials:!0,success:function(n){var t=p();K=n,t.ufo=w(n),q=g(n.userInfo.avatarUrl.split("/")),d(t)}})}}}),y("app","show")}function e(){b=Date.now(),""===K&&wx.getSetting({success:function(n){n.authSetting["scope.userInfo"]&&wx.getUserInfo({withCredentials:!0,success:function(n){K=n,q=g(n.userInfo.avatarUrl.split("/"));var t=p();t.ufo=w(n),d(t)}})}}),y("app","hide")}function a(n){J++,_("event","ald_error_message",n)}function r(n){X=n}function i(){z=this.route,Y=Date.now(),$=0,Z=0}function s(){S("page","hide"),Q=this.route}function c(){S("page","unload"),Q=this.route}function u(){$++}function l(){Z++}function f(n){var t=v(n.path),o={};for(var e in O.query)"ald_share_src"===e&&(o[e]=O.query[e]);var a="";if(a=n.path.indexOf("?")==-1?n.path+"?":n.path.substr(0,n.path.indexOf("?"))+"?",""!==t)for(var e in t)o[e]=t[e];o.ald_share_src?o.ald_share_src.indexOf(N)==-1&&o.ald_share_src.length<200&&(o.ald_share_src=o.ald_share_src+","+N):o.ald_share_src=N;for(var r in o)r.indexOf("ald")==-1&&(a+=r+"="+o[r]+"&");return n.path=a+"ald_share_src="+o.ald_share_src,_("event","ald_share_status",n),n}function h(){function n(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return n()+n()+n()+n()+n()+n()+n()+n()}function d(n){var t=n,o=0,e=0,a=function(r){e++,r?(n={},n.et=Date.now(),n.at=I,n.uu=N,n.v=P,n.ak=t.ak,n.life=t.life,n.ev=t.ev,n.err="err",n.status=o):(H++,n.at=I,n.et=Date.now(),n.uu=N,n.v=P,n.ak=M.app_key,n.wsr=O,n.oifo=E,n.rq_c=H),wx.request({url:"https://"+R+".aldwx.com/d.html",data:n,header:{AldStat:"MiniApp-Stat",waid:M.appid||"",wst:M.appsecret||"",se:L||"",op:k||"",img:q},method:"GET",success:function(n){o=n.statusCode,200!=n.statusCode&&e<=3&&a("errorsend")},fail:function(){e<=3&&a("errorsend")}})};a()}function p(){var n={};for(var t in V)n[t]=V[t];return n}function g(n){for(var t="",o=0;o<n.length;o++)n[o].length>t.length&&(t=n[o]);return t}function w(n){var t={};for(var o in n)"rawData"!=o&&"errMsg"!=o&&(t[o]=n[o]);return t}function v(n){if(n.indexOf("?")==-1)return"";var t={};return n.split("?")[1].split("&").forEach(function(n){var o=n.split("=")[1];t[n.split("=")[0]]=o}),t}function y(n,t){var o=p();o.ev=n,o.life=t,o.ec=J,o.st=B,F&&(o.qr=F,o.sr=F),C&&(o.usr=C),"launch"!==t&&(o.ahs=T),"hide"===t&&(o.hdr=Date.now()-A,o.dr=Date.now()-U,o.ifo=!!E),d(o)}function S(n,t){var o=p();o.ev=n,o.st=Date.now(),o.life=t,o.pp=z,o.pc=Q,o.dr=Date.now()-B,o.ndr=Date.now()-Y,o.rc=$,o.bc=Z,o.ahs=T,X&&"{}"!=JSON.stringify(X)&&(o.ag=X),F&&(o.qr=F,o.sr=F),C&&(o.usr=C),W||(nn=z,W=!0,o.ifp=W,o.fp=z),d(o)}function _(n,t,o){var e=p();e.ev=n,e.tp=t,e.st=B,o&&(e.ct=o),d(e)}function m(n,t,o){if(n[t]){var e=n[t];n[t]=function(n){o.call(this,n,t),e.call(this,n)}}else n[t]=function(n){o.call(this,n,t)}}function D(n){var r={};for(var i in n)"onLaunch"!==i&&"onShow"!==i&&"onHide"!==i&&"onError"!==i&&"onPageNotFound"!==i&&"onUnlaunch"!==i&&(r[i]=n[i]);r.onLaunch=function(o){t.call(this,o),"function"==typeof n.onLaunch&&n.onLaunch.call(this,o)},r.onShow=function(t){o.call(this,t),n.onShow&&"function"==typeof n.onShow&&n.onShow.call(this,t)},r.onHide=function(){e.call(this),n.onHide&&"function"==typeof n.onHide&&n.onHide.call(this)},r.onError=function(t){a.call(this,t),n.onError&&"function"==typeof n.onError&&n.onError.call(this,t)},r.onUnlaunch=function(){n.onUnlaunch&&"function"==typeof n.onUnlaunch&&n.onUnlaunch.call(this)},r.onPageNotFound=function(t){n.onPageNotFound&&"function"==typeof n.onPageNotFound&&n.onPageNotFound.call(this,t)},App(r)}function x(n){var t={};for(var o in n)"onLoad"!==o&&"onReady"!==o&&"onShow"!==o&&"onHide"!==o&&"onUnload"!==o&&"onPullDownRefresh"!==o&&"onReachBottom"!==o&&"onShareAppMessage"!==o&&"onPageScroll"!==o&&"onTabItemTap"!==o&&(t[o]=n[o]);t.onLoad=function(t){r.call(this,t),"function"==typeof n.onLoad&&n.onLoad.call(this,t)},t.onShow=function(t){i.call(this),"function"==typeof n.onShow&&n.onShow.call(this,t)},t.onHide=function(t){s.call(this),"function"==typeof n.onHide&&n.onHide.call(this,t)},t.onUnload=function(t){c.call(this),"function"==typeof n.onUnload&&n.onUnload.call(this,t)},t.onReady=function(t){n.onReady&&"function"==typeof n.onReady&&n.onReady.call(this,t)},t.onReachBottom=function(t){l(),n.onReachBottom&&"function"==typeof n.onReachBottom&&n.onReachBottom.call(this,t)},t.onPullDownRefresh=function(t){u(),n.onPullDownRefresh&&"function"==typeof n.onPullDownRefresh&&n.onPullDownRefresh.call(this,t)},t.onPageScroll=function(t){n.onPageScroll&&"function"==typeof n.onPageScroll&&n.onPageScroll.call(this,t)},t.onTabItemTap=function(t){n.onTabItemTap&&"function"==typeof n.onTabItemTap&&n.onTabItemTap.call(this,t)},n.onShareAppMessage&&"function"==typeof n.onShareAppMessage&&(t.onShareAppMessage=function(t){var o=n.onShareAppMessage.call(this,t);return void 0===o?(o={},o.path=this.route):void 0===o.path&&(o.path=this.route),f.call(this,o)}),Page(t)}var M=require("./ald-stat-conf"),P="7.0.0",R="log",I=""+Date.now()+Math.floor(1e7*Math.random()),T=""+Date.now()+Math.floor(1e7*Math.random()),A="",U=0,b=0,L="",k="",q="",H=0,O="",E="",N=function(){var n="";try{n=wx.getStorageSync("aldstat_uuid")}catch(t){n="uuid_getstoragesync"}if(n)E=!1;else{n=h(),E=!0;try{wx.setStorageSync("aldstat_uuid",n),wx.setStorageSync("ald_ifo",!0)}catch(n){wx.setStorageSync("aldstat_uuid","uuid_getstoragesync")}}return n}(),B=Date.now(),C="",F="",j="",J=0,G="",K="",V={},W=!1,z="",Q="",X="",Y="",Z=0,$=0,nn="",tn=!0;!function(){wx.request({url:"https://"+R+".aldwx.com/config/app.json",header:{AldStat:"MiniApp-Stat"},method:"GET",success:function(n){200===n.statusCode&&(n.data.version!=P&&console.warn("您的SDK不是最新版本,请尽快升级!"),n.data.warn&&console.warn(n.data.warn),n.data.error&&console.error(n.data.error))}})}();try{var on=wx.getSystemInfoSync();V.br=on.brand,V.pm=on.model,V.pr=on.pixelRatio,V.ww=on.windowWidth,V.wh=on.windowHeight,V.lang=on.language,V.wv=on.version,V.wvv=on.platform,V.wsdk=on.SDKVersion,V.sv=on.system}catch(n){}wx.getNetworkType({success:function(n){V.nt=n.networkType}}),wx.getSetting({success:function(n){n.authSetting["scope.userLocation"]?wx.getLocation({type:"wgs84",success:function(n){V.lat=n.latitude,V.lng=n.longitude,V.spd=n.speed}}):M.getLocation&&wx.getLocation({type:"wgs84",success:function(n){V.lat=n.latitude,V.lng=n.longitude,V.spd=n.speed}})}}),n.prototype.debug=function(n){_("debug","0",n)},n.prototype.warn=function(n){_("warn","1",n)},n.prototype.sendEvent=function(n,t){if(""!==n&&"string"==typeof n&&n.length<=255)if("string"==typeof t&&t.length<=255)_("event",n,t);else if("object"==typeof t){if(JSON.stringify(t).length>=255)return void console.error("自定义事件参数不能超过255个字符");_("event",n,JSON.stringify(t))}else void 0===t?_("event",n,!1):console.error("事件参数必须为String,Object类型,且参数长度不能超过255个字符");else console.error("事件名称必须为String类型且不能超过255个字符")},n.prototype.sendSession=function(n){if(""===n||!n)return void console.error("请传入从后台获取的session_key");if(""===M.appid||""===M.appsecret)return void console.error("请在配置文件中填写小程序的appid和appsecret!");L=n;var t=p();t.st=Date.now(),t.tp="session",t.ct="session",t.ev="event",""===K?wx.getSetting({success:function(n){n.authSetting["scope.userInfo"]?wx.getUserInfo({success:function(n){t.ufo=w(n),q=g(n.userInfo.avatarUrl.split("/")),""!==G&&(t.gid=G),d(t)}}):""!==G?(t.gid=G,d(t)):console.warn("用户未授权")}}):(t.ufo=K,""!==G&&(t.gid=G),d(t))},n.prototype.sendOpenid=function(n){if(""===n||!n)return void console.error("openID不能为空");k=n;var t=p();t.st=Date.now(),t.tp="openid",t.ev="event",t.ct="openid",d(t)};return M.plugin?{App:D,Page:x}:function(n){!function(){var n=App,h=Page;App=function(r){m(r,"onLaunch",t),m(r,"onShow",o),m(r,"onHide",e),m(r,"onError",a),n(r)},Page=function(n){var t=n.onShareAppMessage;m(n,"onLoad",r),m(n,"onUnload",c),m(n,"onShow",i),m(n,"onHide",s),m(n,"onReachBottom",l),m(n,"onPullDownRefresh",u),void 0!==t&&null!==t&&(n.onShareAppMessage=function(n){if(void 0!==t){var o=t.call(this,n);return void 0===o?(o={},o.path=this.route):void 0===o.path&&(o.path=this.route),f(o)}}),h(n)}}()}()});
\ No newline at end of file
... ...
const formatTime = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : '0' + n
}
module.exports = {
formatTime: formatTime
}
... ...
/**
* html2Json 改造来自: https://github.com/Jxck/html2json
*
*
* author: Di (微信小程序开发工程师)
* organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
* 垂直微信小程序开发交流社区
*
* github地址: https://github.com/icindy/wxParse
*
* for: 微信小程序富文本解析
* detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
*/
var __placeImgeUrlHttps = "https";
var __emojisReg = '';
var __emojisBaseSrc = '';
var __emojis = {};
var wxDiscode = require('./wxDiscode.js');
var HTMLParser = require('./htmlparser.js');
// Empty Elements - HTML 5
var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr");
// Block Elements - HTML 5
var block = makeMap("br,a,code,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video");
// Inline Elements - HTML 5
var inline = makeMap("abbr,acronym,applet,b,basefont,bdo,big,button,cite,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var");
// Elements that you can, intentionally, leave open
// (and which close themselves)
var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr");
// Attributes that have their values filled in disabled="disabled"
var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected");
// Special Elements (can contain anything)
var special = makeMap("wxxxcode-style,script,style,view,scroll-view,block");
function makeMap(str) {
var obj = {}, items = str.split(",");
for (var i = 0; i < items.length; i++)
obj[items[i]] = true;
return obj;
}
function q(v) {
return '"' + v + '"';
}
function removeDOCTYPE(html) {
return html
.replace(/<\?xml.*\?>\n/, '')
.replace(/<.*!doctype.*\>\n/, '')
.replace(/<.*!DOCTYPE.*\>\n/, '');
}
function trimHtml(html) {
return html
.replace(/\r?\n+/g, '')
.replace(/<!--.*?-->/ig, '')
.replace(/\/\*.*?\*\//ig, '')
.replace(/[ ]+</ig, '<')
}
function html2json(html, bindName) {
//处理字符串
html = removeDOCTYPE(html);
html = trimHtml(html);
html = wxDiscode.strDiscode(html);
//生成node节点
var bufArray = [];
var results = {
node: bindName,
nodes: [],
images:[],
imageUrls:[]
};
var index = 0;
HTMLParser(html, {
start: function (tag, attrs, unary) {
//debug(tag, attrs, unary);
// node for this element
var node = {
node: 'element',
tag: tag,
};
if (bufArray.length === 0) {
node.index = index.toString()
index += 1
} else {
var parent = bufArray[0];
if (parent.nodes === undefined) {
parent.nodes = [];
}
node.index = parent.index + '.' + parent.nodes.length
}
if (block[tag]) {
node.tagType = "block";
} else if (inline[tag]) {
node.tagType = "inline";
} else if (closeSelf[tag]) {
node.tagType = "closeSelf";
}
if (attrs.length !== 0) {
node.attr = attrs.reduce(function (pre, attr) {
var name = attr.name;
var value = attr.value;
if (name == 'class') {
console.dir(value);
// value = value.join("")
node.classStr = value;
}
// has multi attibutes
// make it array of attribute
if (name == 'style') {
console.dir(value);
// value = value.join("")
node.styleStr = value;
}
if (value.match(/ /)) {
value = value.split(' ');
}
// if attr already exists
// merge it
if (pre[name]) {
if (Array.isArray(pre[name])) {
// already array, push to last
pre[name].push(value);
} else {
// single value, make it array
pre[name] = [pre[name], value];
}
} else {
// not exist, put it
pre[name] = value;
}
return pre;
}, {});
}
//对img添加额外数据
if (node.tag === 'img') {
node.imgIndex = results.images.length;
var imgUrl = node.attr.src;
if (imgUrl[0] == '') {
imgUrl.splice(0, 1);
}
imgUrl = wxDiscode.urlToHttpUrl(imgUrl, __placeImgeUrlHttps);
node.attr.src = imgUrl;
node.from = bindName;
results.images.push(node);
results.imageUrls.push(imgUrl);
}
// 处理font标签样式属性
if (node.tag === 'font') {
var fontSize = ['x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', '-webkit-xxx-large'];
var styleAttrs = {
'color': 'color',
'face': 'font-family',
'size': 'font-size'
};
if (!node.attr.style) node.attr.style = [];
if (!node.styleStr) node.styleStr = '';
for (var key in styleAttrs) {
if (node.attr[key]) {
var value = key === 'size' ? fontSize[node.attr[key]-1] : node.attr[key];
node.attr.style.push(styleAttrs[key]);
node.attr.style.push(value);
node.styleStr += styleAttrs[key] + ': ' + value + ';';
}
}
}
//临时记录source资源
if(node.tag === 'source'){
results.source = node.attr.src;
}
if (unary) {
// if this tag doesn't have end tag
// like <img src="hoge.png"/>
// add to parents
var parent = bufArray[0] || results;
if (parent.nodes === undefined) {
parent.nodes = [];
}
parent.nodes.push(node);
} else {
bufArray.unshift(node);
}
},
end: function (tag) {
//debug(tag);
// merge into parent tag
var node = bufArray.shift();
if (node.tag !== tag) console.error('invalid state: mismatch end tag');
//当有缓存source资源时于于video补上src资源
if(node.tag === 'video' && results.source){
node.attr.src = results.source;
delete results.source;
}
if (bufArray.length === 0) {
results.nodes.push(node);
} else {
var parent = bufArray[0];
if (parent.nodes === undefined) {
parent.nodes = [];
}
parent.nodes.push(node);
}
},
chars: function (text) {
//debug(text);
var node = {
node: 'text',
text: text,
textArray:transEmojiStr(text)
};
if (bufArray.length === 0) {
node.index = index.toString()
index += 1
results.nodes.push(node);
} else {
var parent = bufArray[0];
if (parent.nodes === undefined) {
parent.nodes = [];
}
node.index = parent.index + '.' + parent.nodes.length
parent.nodes.push(node);
}
},
comment: function (text) {
//debug(text);
// var node = {
// node: 'comment',
// text: text,
// };
// var parent = bufArray[0];
// if (parent.nodes === undefined) {
// parent.nodes = [];
// }
// parent.nodes.push(node);
},
});
return results;
};
function transEmojiStr(str){
// var eReg = new RegExp("["+__reg+' '+"]");
// str = str.replace(/\[([^\[\]]+)\]/g,':$1:')
var emojiObjs = [];
//如果正则表达式为空
if(__emojisReg.length == 0 || !__emojis){
var emojiObj = {}
emojiObj.node = "text";
emojiObj.text = str;
array = [emojiObj];
return array;
}
//这个地方需要调整
str = str.replace(/\[([^\[\]]+)\]/g,':$1:')
var eReg = new RegExp("[:]");
var array = str.split(eReg);
for(var i = 0; i < array.length; i++){
var ele = array[i];
var emojiObj = {};
if(__emojis[ele]){
emojiObj.node = "element";
emojiObj.tag = "emoji";
emojiObj.text = __emojis[ele];
emojiObj.baseSrc= __emojisBaseSrc;
}else{
emojiObj.node = "text";
emojiObj.text = ele;
}
emojiObjs.push(emojiObj);
}
return emojiObjs;
}
function emojisInit(reg='',baseSrc="/wxParse/emojis/",emojis){
__emojisReg = reg;
__emojisBaseSrc=baseSrc;
__emojis=emojis;
}
module.exports = {
html2json: html2json,
emojisInit:emojisInit
};
... ...
/**
*
* htmlParser改造自: https://github.com/blowsie/Pure-JavaScript-HTML5-Parser
*
* author: Di (微信小程序开发工程师)
* organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
* 垂直微信小程序开发交流社区
*
* github地址: https://github.com/icindy/wxParse
*
* for: 微信小程序富文本解析
* detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
*/
// Regular Expressions for parsing tags and attributes
var startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/,
endTag = /^<\/([-A-Za-z0-9_]+)[^>]*>/,
attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;
// Empty Elements - HTML 5
var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr");
// Block Elements - HTML 5
var block = makeMap("a,address,code,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video");
// Inline Elements - HTML 5
var inline = makeMap("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var");
// Elements that you can, intentionally, leave open
// (and which close themselves)
var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr");
// Attributes that have their values filled in disabled="disabled"
var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected");
// Special Elements (can contain anything)
var special = makeMap("wxxxcode-style,script,style,view,scroll-view,block");
function HTMLParser(html, handler) {
var index, chars, match, stack = [], last = html;
stack.last = function () {
return this[this.length - 1];
};
while (html) {
chars = true;
// Make sure we're not in a script or style element
if (!stack.last() || !special[stack.last()]) {
// Comment
if (html.indexOf("<!--") == 0) {
index = html.indexOf("-->");
if (index >= 0) {
if (handler.comment)
handler.comment(html.substring(4, index));
html = html.substring(index + 3);
chars = false;
}
// end tag
} else if (html.indexOf("</") == 0) {
match = html.match(endTag);
if (match) {
html = html.substring(match[0].length);
match[0].replace(endTag, parseEndTag);
chars = false;
}
// start tag
} else if (html.indexOf("<") == 0) {
match = html.match(startTag);
if (match) {
html = html.substring(match[0].length);
match[0].replace(startTag, parseStartTag);
chars = false;
}
}
if (chars) {
index = html.indexOf("<");
var text = ''
while (index === 0) {
text += "<";
html = html.substring(1);
index = html.indexOf("<");
}
text += index < 0 ? html : html.substring(0, index);
html = index < 0 ? "" : html.substring(index);
if (handler.chars)
handler.chars(text);
}
} else {
html = html.replace(new RegExp("([\\s\\S]*?)<\/" + stack.last() + "[^>]*>"), function (all, text) {
text = text.replace(/<!--([\s\S]*?)-->|<!\[CDATA\[([\s\S]*?)]]>/g, "$1$2");
if (handler.chars)
handler.chars(text);
return "";
});
parseEndTag("", stack.last());
}
if (html == last)
throw "Parse Error: " + html;
last = html;
}
// Clean up any remaining tags
parseEndTag();
function parseStartTag(tag, tagName, rest, unary) {
tagName = tagName.toLowerCase();
if (block[tagName]) {
while (stack.last() && inline[stack.last()]) {
parseEndTag("", stack.last());
}
}
if (closeSelf[tagName] && stack.last() == tagName) {
parseEndTag("", tagName);
}
unary = empty[tagName] || !!unary;
if (!unary)
stack.push(tagName);
if (handler.start) {
var attrs = [];
rest.replace(attr, function (match, name) {
var value = arguments[2] ? arguments[2] :
arguments[3] ? arguments[3] :
arguments[4] ? arguments[4] :
fillAttrs[name] ? name : "";
attrs.push({
name: name,
value: value,
escaped: value.replace(/(^|[^\\])"/g, '$1\\\"') //"
});
});
if (handler.start) {
handler.start(tagName, attrs, unary);
}
}
}
function parseEndTag(tag, tagName) {
// If no tag name is provided, clean shop
if (!tagName)
var pos = 0;
// Find the closest opened tag of the same type
else {
tagName = tagName.toLowerCase();
for (var pos = stack.length - 1; pos >= 0; pos--)
if (stack[pos] == tagName)
break;
}
if (pos >= 0) {
// Close all the open elements, up the stack
for (var i = stack.length - 1; i >= pos; i--)
if (handler.end)
handler.end(stack[i]);
// Remove the open elements from the stack
stack.length = pos;
}
}
};
function makeMap(str) {
var obj = {}, items = str.split(",");
for (var i = 0; i < items.length; i++)
obj[items[i]] = true;
return obj;
}
module.exports = HTMLParser;
... ...