This commit is contained in:
zoujiandong
2024-01-22 08:42:14 +08:00
parent 3a2b2cd3b1
commit 4948f35fb3
573 changed files with 640 additions and 24515 deletions
+490
View File
@@ -0,0 +1,490 @@
// pages/medinceList/medinceList.js
const app = getApp()
import {
family,
addfamily
} from "../../../api/familyDoc";
import {
cart,
editCart
} from "../../../api/goodsCar"
import {throttle} from "../../../utils/util"
Page({
/**
* 页面的初始数据
*/
data: {
img_host:'https://oss.prod.applets.igandanyiyuan.com/applet/patient/static',
show: false,
isLock: false,
showAdd: false,
sex: null,
delId:'',
height:970,
delIndex:-1,
showDialog:false,
currentFamilyId: '',
showPicker: false,
realName: '',
idCard: '', //'',
phoneNumber: '',
relation: "",
relationId:"",
family: [],
list: [],
translist:[],
pageData:[],
columns: [{
text: "本人",
value: 1
},
{
text: "父母",
value: 2
},
{
text: "爱人",
value: 3
},
{
text: "子女",
value: 4
},
{
text: "亲戚",
value: 5
},
{
text: "其他 ",
value: 6
}
]
},
getCart() {
cart().then(data => {
this.setData({
list: data
})
})
},
confirm(event){
let {delId,delIndex}=this.data;
if(event.detail){
this.handleEditCart(delId,0,delIndex, 'minus');
}
},
onCloseDel(event){
let index = event.currentTarget.dataset.id;
//let shopping_cart_num = this.data.list[index].shopping_cart_num;
let product_id = this.data.list[index].product_id;
this.setData({
showDialog:true,
delId:product_id,
delIndex:index
})
},
goBack(){
wx.navigateBack({
delta: 1,
})
},
minusGoods(event) {
if (!this.data.isLock) {
this.setData({
isLock: true
})
let index = event.currentTarget.dataset.id;
let shopping_cart_num = this.data.list[index].shopping_cart_num;
let product_id = this.data.list[index].product_id;
if (shopping_cart_num == 1) {
this.setData({
isLock:false,
showDialog:true,
delId:product_id,
delIndex:index
})
return false
}
--shopping_cart_num;
this.handleEditCart(product_id, shopping_cart_num, index, 'minus');
}
},
addGoods(event) {
if (!this.data.isLock) {
this.setData({
isLock: true
})
let index = event.currentTarget.dataset.id;
let shopping_cart_num = this.data.list[index].shopping_cart_num;
let stock = this.data.list[index].stock;
let product_id = this.data.list[index].product_id;
if(shopping_cart_num>=5){
wx.showToast({
title: '每个药品购买数量不超过5个',
icon: "none"
})
this.setData({
isLock:false
})
return false
}
if (shopping_cart_num == stock) {
this.setData({
isLock:false
})
wx.showToast({
title: '该商品库存已不足',
icon: "none"
})
return false
}
++shopping_cart_num;
this.handleEditCart(product_id, shopping_cart_num, index, 'add');
}
},
handleEditCart(product_id, shopping_cart_num, index, type) {
let item = `list[${index}].shopping_cart_num`;
editCart({
product_id: product_id,
shopping_cart_num: shopping_cart_num
}).then(data => {
let number = this.data.totalNumber;
if (type == "add") {
++number
} else {
--number
};
this.setData({
[item]: shopping_cart_num,
totalNumber: number,
isLock: false
});
if(shopping_cart_num==0){
this.getCart();
}
})
},
showPopup() {
this.setData({
show: true
});
},
onClose() {
this.setData({
show: false
});
},
goPatientList() {
if(this.data.list.length==0){
wx.showToast({
title: '请先选择药品',
icon: "none"
})
return false
}
if (this.data.list.length > 5) {
wx.showToast({
title: '最多选择5种药',
icon: "none"
})
return false
}
this.setData({
show: true
})
},
onCloseAdd() {
this.setData({
showAdd: false
});
},
onConfirmPicker(event) {
const {value} = event.detail;
this.setData({
relationId: `${value.value}`,
relation: `${value.text}`,
showPicker: false
});
},
openPicker() {
this.setData({
showPicker: true
})
},
closePicker() {
this.setData({
showPicker: false
})
},
inputChange(e) {
this.setData({
[e.target.dataset.id]: e.detail.value
})
},
addFamily() {
let {
realName,
idCard,
phoneNumber,
relationId,
sex
} = this.data;
addfamily({
card_name: realName,
type: 1,
id_number: idCard,
mobile: phoneNumber,
is_default: 0,
relation: relationId
}).then((data) => {
this.getFamily();
this.setData({
currentFamilyId:data.family_id,
realName:'',
idCard:'',
phoneNumber:'',
relationId:'',
relation:'',
showAdd:false
})
})
},
addPatient() {
this.setData({
showAdd: true,
currentFamilyId: '',
sex: ''
})
},
selectPatient(e) {
let currentFamilyId=e.currentTarget.dataset.familyid;
let sex=e.currentTarget.dataset.sex;
let name=e.currentTarget.dataset.name;
let age=e.currentTarget.dataset.age;
this.setData({
currentFamilyId:currentFamilyId,
sex:sex
})
},
getFamily() {
family().then((data) => {
this.setData({
family: this.transforpage(data)
})
})
},
transforpage(arr) {
const pages = []
let newArr = arr.concat([{
type: "add"
}])
newArr.forEach((item, index) => {
const page = Math.floor(index / 2)
if (!pages[page]) {
pages[page] = []
}
pages[page].push(item)
});
return pages
},
confirmNext() {
if (!/^[\u4e00-\u9fa5]+(·[\u4e00-\u9fa5]+)*$/.test(this.data.realName)) {
wx.showToast({
title: `姓名要求在2-10个字符`,
icon: 'none',
});
return false;
};
if (!/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(this.data.idCard)) {
wx.showToast({
title: `请输入有效的身份证号`,
icon: 'none',
});
return false;
};
if (!/^1[3456789]\d{9}$/.test(this.data.phoneNumber)) {
wx.showToast({
title: `请输入有效的手机号码!`,
icon: 'none',
});
return false;
}
},
goNext:throttle(function() {
let {list}=this.data;
let arr=[];
for (let i = 0; i < list.length; i++) {
arr[i]={};
arr[i].product_id=list[i].product_id;
arr[i].product_num=list[i].shopping_cart_num;
arr[i].product_name=list[i].product_name;
arr[i].product_spec=list[i].product_spec;
};
this.setData({
translist:arr,
show:false
})
let {
currentFamilyId,
sex,
translist
} = this.data;
app.method.navigateTo({
url: '/patient/pages/writeSick/writeSick?family_id='+currentFamilyId+"&inquiry_type=4&product="+JSON.stringify(translist)+"&sex="+sex
})
}),
goSick:throttle(function() {
if (!/^([\u4e00-\u9fa5\·]{2,10})$/.test(this.data.realName)) {
wx.showToast({
title: `姓名要求在2-10个汉字`,
icon: 'none',
});
return false;
};
if (!/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(this.data.idCard)) {
wx.showToast({
title: `请输入有效的身份证号`,
icon: 'none',
});
return false;
};
if (this.data.phoneNumber) {
if (!/^1[3456789]\d{9}$/.test(this.data.phoneNumber)) {
wx.showToast({
title: `请输入有效的手机号码!`,
icon: 'none',
});
return false;
}
};
let idInfo = this.getIdInfo(this.data.idCard);
if (idInfo.age < 6) {
wx.showToast({
title: `六岁以下儿童不支持线上问诊`,
icon: 'none',
});
return false;
}
this.setData({
sex:idInfo.sex
})
this.addFamily()
}),
//获取身份证号信息
getIdInfo(IdCard) {
var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
if (reg.test(IdCard)) {
let sex
if (parseInt(IdCard.substr(16, 1)) % 2 === 1) {
sex = '1'
} else {
sex = '2'
}
var ageDate = new Date()
var month = ageDate.getMonth() + 1
var day = ageDate.getDate()
var age = ageDate.getFullYear() - IdCard.substring(6, 10) - 1
if (IdCard.substring(10, 12) < month || (IdCard.substring(10, 12) === month && IdCard.substring(12, 14) <= day)) {
age++
}
if (age <= 0) {
age = 1
}
return {
sex,
age
}
} else {
return false;
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
let medinceInfo = options.product;
if (medinceInfo){
var info = JSON.parse(medinceInfo);
info.forEach((item)=>{
item.shopping_cart_num=item.amount;
});
this.setData({
list: info,
pageData:info
})
}else{
this.getCart();
}
this.getFamily();
},
onfocus(event){
this.setData({
height:970+event.height+120
})
},
onblur(event){
this.setData({
height:970
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.setData({
img_host:app.hostConfig().imghost
});
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
})
@@ -0,0 +1,12 @@
{
"usingComponents": {
"van-swipe-cell": "@vant/weapp/swipe-cell/index",
"van-popup": "@vant/weapp/popup/index",
"van-picker": "@vant/weapp/picker/index",
"dialog":"../../../components/dialog/dialog",
"nav":"../../../components/nav/nav"
},
"navigationStyle":"custom",
"disableScroll": true,
"navigationBarTitleText": "肝胆相照互联网医院"
}
+122
View File
@@ -0,0 +1,122 @@
<!--pages/medinceList/medinceList.wxml-->
<!-- <view class="ui-navigatorbar" style="background: #FFFFFF;border-bottom: 1rpx solid #E3E4E5;">
<image class="ui-navigatorbar-back" bindtap="goBack" src="{{img_host+'/back.png'}}" />
<view class="ui-title">药品清单</view>
</view> -->
<nav navName="药品清单"></nav>
<view class="page">
<view class="medincebox">
<view class="bbox" wx:if="{{list.length>0}}">
<van-swipe-cell right-width="{{ 50 }}" class="swipecell" wx:for="{{list}}" wx:key="product_id" >
<van-cell-group style="flex:1">
<view class="cell">
<view class="imgbox">
<image src="{{img_host+'/nomedince.png'}}" class="yaoimg"></image>
<view class="desc">
<view class="tip">处方药品</view>
<view class="tip">依据法规不展示包装</view>
</view>
</view>
<view class="rightinfo">
<view class="name">{{item.product_name}}<text class="namenum">{{item.product_spec}}</text></view>
<view class="yaodian">{{item.manufacturer}}</view>
<view class="own">
<view class="company">
<text wx:if="{{pageData.length==0}}">¥{{item.product_price}}</text>
</view>
<view class="num" wx:if="{{pageData.length==0}}">
<view class="minus" bindtap="minusGoods" data-id="{{index}}">-</view>
<view class="currentnum">{{item.shopping_cart_num}}</view>
<view class="add {{item.shopping_cart_num>=5?'disabled':''}}" bindtap="addGoods" data-id="{{index}}">+</view>
</view>
<view class="num" wx:else><text decode="true">数量&nbsp;</text>{{item.amount}}</view>
</view>
</view>
</view>
</van-cell-group>
<view slot="right" class="delslot" data-id="{{index}}" catchtap="onCloseDel">删除</view>
</van-swipe-cell>
</view>
<view class="nonedata" wx:else="">
购物车为空!
</view>
<view class="btnbox">
<button class="btn" bindtap="goPatientList" plain="true" disabled="{{false}}">选择患者</button>
</view>
</view>
</view>
<van-popup show="{{ show }}" bind:close="onClose" closeable
position="bottom" round
custom-style="min-height: 60%">
<view class="titlepop">选择用药人</view>
<view class="personbox">
<view class="row" wx:for-item="itemName" wx:for="{{family}}" wx:key="*this">
<view class="cell" wx:for-item="item" wx:for="{{itemName}}" wx:key="family_id">
<view class="cellinner" wx:if="{{!item.type}}" bindtap="selectPatient" data-familyId="{{item.family_id}}" data-sex="{{item.sex}}">
<view class="person">
<view class="name">{{item.card_name}}</view>
<view class="tag" wx:if="{{item.relation==1}}">本人</view>
<view class="tag" wx:elif="{{item.relation==2}}">父母</view>
<view class="tag" wx:elif="{{item.relation==3}}">爱人</view>
<view class="tag" wx:elif="{{item.relation==4}}">子女</view>
<view class="tag" wx:elif="{{item.relation==5}}">亲戚</view>
<view class="tag" wx:elif="{{item.relation==6}}">其他</view>
</view>
<view class="desc">
<view class="sex" wx:if="{{item.sex===0}}">性别未知</view>
<view class="sex" wx:elif="{{item.sex==1}}">男</view>
<view class="sex" wx:else>女</view>
<view class="age">{{item.age}}岁</view>
</view>
<image src="{{img_host+'/gou.png'}}" class="gou" wx:if="{{item.family_id==currentFamilyId}}"></image>
</view>
<view class="celladd" bindtap="addPatient" wx:elif="{{item.type}}">
+新建患者
</view>
</view>
</view>
</view>
<view class="btnbox">
<button class="btn" plain="true" disabled="{{currentFamilyId?false:true}}" bindtap="goNext">下一步</button>
</view>
</van-popup>
<van-popup show="{{showAdd}}" round closeable z-index="999" position="bottom" custom-style="height:{{height}}rpx" bind:close="onCloseAdd">
<view class="infobox">
<view class="title">新建患者</view>
<view class="info">
<view class="name">真实姓名<text>*</text></view>
<input value="{{realName}}" type="text" bindinput="inputChange" placeholder="请输入真实姓名" data-id="realName"/>
</view>
<view class="info">
<view class="name">身份证号<text>*</text></view>
<input value="{{idCard}}" type="idcard" bindinput="inputChange" placeholder="请输入真实身份证号" data-id="idCard"/>
</view>
<view class="info">
<view class="name">联系电话</view>
<input value="{{phoneNumber}}" type="number" bindblur="onblur" bindfocus="onfocus" cursor-spacing="100" bindinput="inputChange" bindinput="inputChange" placeholder="请输入联系电话" data-id="phoneNumber"/>
</view>
<view class="info" bindtap="openPicker">
<view class="name">患者关系</view>
<input type="text" value="{{relation}}" placeholder="请选择与患者的关系" disabled="true" />
</view>
<view class="tip">
<view class="warntitle">温馨提示:</view>
<view class="warn">
<view>1、根据国家卫健委要求,就医实行实名制,请如实填写患者信息。</view>
<view>2、信息受隐私保护,仅接诊医生可见。
</view>
<view>3、6岁以下儿童不支持线上问诊,请到线下就诊。
</view>
</view>
</view>
<view class="next" bindtap="goSick">
确定
</view>
</view>
</van-popup>
<van-popup show="{{ showPicker }}" round position="bottom" z-index="99999" custom-style="height:auto" bind:close="closePicker">
<van-picker show-toolbar title="选择与患者之间的关系" columns="{{ columns }}" bind:cancel="closePicker" bind:confirm="onConfirmPicker" />
</van-popup>
<dialog bind:confirm="confirm" showDialog="{{showDialog}}" message="是否在购物车中删除该商品?"></dialog>
+373
View File
@@ -0,0 +1,373 @@
/* pages/medinceList/medinceList.wxss */
.page {
background-color: #fff;
display: flex;
flex-direction: column;
overflow: hidden;
}
.swipecell {
display: flex;
}
.celladd{
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 120rpx;
}
.delslot {
font-size: 28rpx;
font-weight: 400;
color: #FFFFFF;
padding: 0 14px;
height: 100%;
display: flex;
color: #fff;
background: #EF4F20;
align-items: center;
justify-content: center;
}
.medincebox {
flex:1;
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
margin-top: 172rpx;
background-color: #fff;
padding-bottom: 144rpx;
}
.medincebox .cell {
padding: 30rpx 32rpx;
width:100vw;
box-sizing: border-box;
display: flex;
align-items: center;
border-bottom: 1rpx solid #E3E4E5;
}
.rightinfo {
margin-left: 30rpx;
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
}
.medincebox .cell .name {
word-break: break-all;
font-size: 32rpx;
font-weight: bold;
color: #333;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
/* 这里是超出几行省略 */
overflow: hidden;
}
.imgbox {
border-radius:8rpx;
border:1rpx solid #ccc;
width: 200rpx;
height: 200rpx;
display: flex;
align-items: center;
justify-content: center;
position: relative;
}
.yaoimg {
width: 120rpx;
height: 128rpx;
}
.imgbox .desc {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: absolute;
top: 50%;
font-size: 22rpx;
font-weight: 400;
color: #666666;
line-height: 30rpx;
transform: translateY(-50%);
}
.imgbox .desc .tip {
text-align: center;
}
.rightinfo .own {
margin-top: 47rpx;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 28rpx;
font-weight: 400;
color: #333333;
}
.namenum {
font-size: 28rpx;
font-weight: 400;
color: #333333;
}
.yaodian {
margin-top: 25rpx;
color: rgba(51, 51, 51, 1);
font-size: 28rpx;
}
.own .company {
font-size: 34rpx;
font-weight: 600;
color: #EF4F20;
}
.own .num {
display: flex;
align-items: center;
}
.own .currentnum {
font-size: 24rpx;
color: rgba(0, 0, 0, 0.9);
margin: 0 10rpx;
height: 48rpx;
width:48rpx;
display: flex;
align-items: center;
justify-content: center;
background: #E7E7E7;
border-radius: 4rpx;
}
.own .add,
.own .minus {
width: 48rpx;
height: 48rpx;
font-weight: bold;
font-size: 30rpx;
background: #E7E7E7;
display: flex;
align-items: center;
justify-content: center;
border-radius: 4rpx
}
.btnbox{
position: fixed;
width:100%;
bottom:0rpx;
height: 134rpx;
background:#fff;
}
.btnbox .btn{
border-radius: 47rpx;
border:none;
background: #3CC7C0!important;
margin:0 32rpx;
height: 94rpx;
display: flex;
justify-content: center;
align-items: center;
font-size: 36rpx;
color: #FFFFFF!important;
}
.btnbox .btn[disabled]{
color: #000000!important;
background:rgba(0,0,0,0.1)!important;
}
.personbox {
border-radius: 10rpx;
background-color: #fff;
padding: 40rpx 20rpx 144rpx;
overflow-y: scroll;
}
.personbox .row {
margin-top: 30rpx;
display: flex;
justify-content: space-between;
}
.personbox .row:first-child {
margin-top: 0;
}
.personbox .row .cell {
position: relative;
width: 47%;
height: 120rpx;
display: flex;
flex-direction: column;
justify-content: center;
margin-left: 30rpx;
border-radius: 10rpx;
border: 1px solid #CCCCCC;
}
.personbox .row .cell:first-child {
margin-left: 0rpx;
}
.personbox .person {
display: flex;
margin: 0 25rpx;
align-items: center;
}
.personbox .tag {
margin-left: 32rpx;
font-size: 24rpx;
display: flex;
align-items: center;
line-height: 24rpx;
justify-content: center;
color: #666666;
width: 80rpx;
height: 32rpx;
border-radius: 4rpx;
transform: rotateZ(360deg);
border: 1rpx solid #979797;
}
.personbox .desc {
display: flex;
margin: 0 25rpx;
font-size: 28rpx;
color: #666;
margin-top: 3px;
}
.personbox .name {
white-space: nowrap;
overflow: hidden;
max-width: 200rpx;
text-overflow: ellipsis;
font-size: 34rpx;
color: #333;
}
.personbox .age {
margin-left: 12rpx;
}
.personbox .cell .gou {
position: absolute;
bottom: -1rpx;
right: 0rpx;
width: 66rpx;
height: 53.7rpx;
}
.personbox .add {
justify-content: center;
align-items: center;
font-size: 34rpx;
color: #333;
}
.own .add.disabled{
color: #999;
}
.titlepop{
font-size: 34rpx;
font-weight: 400;
color: #333333;
padding:40rpx 0;
text-align: center;
width:100%;
border-bottom:1rpx solid #E7E7E7;
}
.van-icon-cross {
color: #333;
font-size: 40rpx !important;
}
.infobox {
margin-top: 40rpx;
}
.info {
border-bottom: 1rpx solid #E7E7E7;
display: flex;
align-items: center;
height: 112rpx;
color: #333333;
}
.infobox .title {
border-bottom: 1rpx solid #E7E7E7;
text-align: center;
font-size: 34rpx;
padding-bottom: 35rpx;
}
.info .name {
white-space: nowrap;
width: 180rpx;
display: flex;
align-items: center;
margin-left: 52rpx;
color: #333333;
font-size: 34rpx;
}
.info text {
margin-top: 20rpx;
color:#E34D59;
display: flex;
align-items: center;
}
.info input {
margin-left: 15rpx;
margin-right: 52rpx;
flex: 1;
}
.input-placeholder {
color: #999999;
font-size: 28rpx;
}
.tip{
padding:30rpx 52rpx 20rpx;
}
.warntitle{
color: #E34D59;
font-size: 28rpx;
}
.warn{
margin-top: 20rpx;
font-size: 24rpx;
line-height: 36rpx;
color: #666666;
}
.next{
display: flex;
align-items: center;
justify-content: center;
height: 94rpx;
font-size: 36rpx;
left: 30rpx;
right: 30rpx;
margin:0 52rpx;
border-radius: 47rpx;
color: #fff;
margin-bottom: 40rpx;
background: #3CC7C0;
}