耀实惠小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

298 lines
7.8 KiB

  1. <template>
  2. <view class="drug-user-authentication position-relative">
  3. <view class="drug-user-authentication-item m-b-40">
  4. <view class="drug-user-authentication-title font-32 text-black m-b-20 font-weight-bold">用药人信息</view>
  5. <u-form :model="form" ref="uForm">
  6. <u-form-item label-width="20%" label="姓名" prop="name"><u-input v-model="form.name" input-align="right" placeholder="请输入姓名" /></u-form-item>
  7. <u-form-item label-width="20%" label="出生日期" prop="time">
  8. <view @click="assignModalShow('timeShow')">
  9. <u-input v-model="form.time" disabled placeholder="请选择出生日期" input-align="right" @click="assignModalShow('timeShow')"/>
  10. </view>
  11. </u-form-item>
  12. <u-form-item label-width="20%" label="性别" prop="sex">
  13. <view @click="assignModalShow('sexShow')" >
  14. <u-input v-model="form.sex" disabled placeholder="请选择性别" input-align="right" @click="assignModalShow('sexShow')"/>
  15. </view>
  16. </u-form-item>
  17. <u-form-item label-width="20%" label="身份证" prop="idCard"><u-input v-model="form.idCard" input-align="right" placeholder="请输入身份证号码" /></u-form-item>
  18. <u-form-item label-width="20%" label="身高" prop="height">
  19. <view class="flex align-center">
  20. <u-input class="flex-1" type="number" v-model="form.height" input-align="right" placeholder="请输入身高" />
  21. <text class="font-30 text-black m-l-20">CM</text>
  22. </view>
  23. </u-form-item>
  24. <u-form-item label-width="20%" label="体重" prop="weight">
  25. <view class="flex align-center">
  26. <u-input class="flex-1" type="number" v-model="form.weight" input-align="right" placeholder="请输入体重" />
  27. <text class="font-30 text-black m-l-20">KG</text>
  28. </view>
  29. </u-form-item>
  30. <u-form-item label-width="20%" label="手机号码" type="number" prop="phone"><u-input v-model="form.phone" input-align="right" placeholder="请输入手机号码" /></u-form-item>
  31. </u-form>
  32. </view>
  33. <view class="drug-user-authentication-item flex align-center">
  34. <view class="font-32 text-black m-r-15 font-weight-bold">关系标签</view>
  35. <view class="flex align-center">
  36. <u-tag
  37. v-for="(item, index) in tagList"
  38. :key="index"
  39. :text="item"
  40. mode="dark"
  41. class="m-r-20"
  42. :mode="index === tagCurrent ? 'dark' : 'plain'"
  43. :type="index === tagCurrent ? 'primary' : 'info'"
  44. @click="tagClick(item, index)"
  45. ></u-tag>
  46. </view>
  47. </view>
  48. <view class="drug-user-authentication-footer position-fixed flex align-center justify-center">
  49. <u-button type="primary" shape="circle" @click="preserve">保存并使用</u-button>
  50. </view>
  51. <u-picker mode="time" v-model="timeShow" @confirm="timeConfirm" confirm-color="#01AEEA" zIndex="999999999"></u-picker>
  52. <u-select v-model="sexShow" :list="sexList" @confirm="sexConfirm" confirm-color="#01AEEA"></u-select>
  53. </view>
  54. </template>
  55. <script>
  56. const sexList = [
  57. {
  58. value: '1',
  59. label: '男'
  60. },
  61. {
  62. value: '2',
  63. label: '女'
  64. }
  65. ];
  66. const tagList = ['本人', '家庭成员', '亲戚', '朋友']
  67. export default {
  68. data() {
  69. return {
  70. sexList,
  71. tagList,
  72. tagCurrent: null,
  73. form: {
  74. Id:'',
  75. name: '',
  76. sex: '',
  77. phone: '',
  78. height: '',
  79. weight: '',
  80. idCard: '',
  81. time: '',
  82. relationship: '',
  83. goodsIdDetails: '',
  84. goodsTypeText:''
  85. },
  86. timeShow: false,
  87. sexShow: false,
  88. rules: {
  89. name: [
  90. {
  91. required: true,
  92. message: '请输入姓名'
  93. },
  94. {
  95. validator: (rule, value, callback) => {
  96. let username = /^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,99}$/;
  97. return username.test(value);
  98. },
  99. message: '请输入正确格式的姓名',
  100. trigger: ['blur']
  101. }
  102. ],
  103. idCard: [
  104. {
  105. required: true,
  106. message: '请输入身份证号码'
  107. },
  108. {
  109. message: '请输入正确格式的身份证号码',
  110. validator: (rule, value, callback) => {
  111. return this.$u.test.idCard(value);
  112. }
  113. }
  114. ],
  115. phone: [
  116. {
  117. required: true,
  118. message: '请输入手机号码',
  119. trigger: ['change', 'blur']
  120. },
  121. {
  122. message: '请输入正确格式的手机号码',
  123. validator: (rule, value, callback) => {
  124. return this.$u.test.mobile(value);
  125. }
  126. }
  127. ],
  128. sex: [
  129. {
  130. required: true,
  131. message: '请选择性别',
  132. trigger: ['change', 'blur']
  133. }
  134. ],
  135. time: [
  136. {
  137. required: true,
  138. message: '请选择出生日期',
  139. trigger: ['change', 'blur']
  140. }
  141. ],
  142. weight: [
  143. {
  144. required: true,
  145. message: '请输入体重',
  146. trigger: ['change', 'blur']
  147. }
  148. ],
  149. height: [
  150. {
  151. required: true,
  152. message: '请输入身高',
  153. trigger: ['change', 'blur']
  154. }
  155. ]
  156. },
  157. };
  158. },
  159. onReady() {
  160. this.$refs.uForm.setRules(this.rules);
  161. },
  162. onLoad(options) {
  163. // 将传过来的商品信息存入form 中
  164. this.form.goodsId = options.goodsId;
  165. this.form.typeName = options.typeName;
  166. this.form.isSituation = options.isSituation;
  167. this.form.num = options.num;
  168. this.form.price = options.price;
  169. this.form.goodSkuParam = options.goodSkuParam;
  170. this.form.prescriptionId = options.prescriptionId;
  171. this.form.num = options.num;
  172. this.form.num = options.num;
  173. // this.form.goodsIdDetails = options.goodsId;
  174. this.form.goodsTypeText = options.type;
  175. if(options.Id) {
  176. this.getDrugUserById(options.Id);
  177. }
  178. },
  179. methods: {
  180. assignModalShow (key) {
  181. this[key] = true
  182. },
  183. timeConfirm(time) {
  184. let { year, month, day } = time;
  185. this.form.time = `${year}/${month}/${day}`;
  186. },
  187. // 修改信息查询
  188. getDrugUserById(id) {
  189. uni.showLoading();
  190. this.$api('getDrugUserById',{id}).then(res => {
  191. let { code, result, message} = res;
  192. if(code == 200) {
  193. const form = {
  194. ...result,
  195. Id: id,
  196. name: result.name,
  197. sex: result.sex==1? '男': '女',
  198. phone: result.phone,
  199. height: result.height + '',
  200. weight: result.weight + '',
  201. idCard: result.cardId,
  202. time: result.birthday,
  203. relationship: result.labelValue,
  204. goodsIdDetails: '',
  205. goodsTypeText:'',
  206. }
  207. this.tagList.forEach((item,index) => {
  208. if(item == result.labelValue) {
  209. this.tagCurrent = index
  210. }
  211. });
  212. uni.hideLoading();
  213. this.form = { ...this.form,...form}
  214. console.log(result)
  215. }else {
  216. uni.hideLoading();
  217. this.$Toast(message)
  218. }
  219. }).catch(err => {
  220. uni.hideLoading();
  221. this.$Toast(err.message)
  222. })
  223. },
  224. sexConfirm(arr) {
  225. this.form.sex = arr[0].label
  226. },
  227. preserve() {
  228. console.log(this.form)
  229. this.$refs.uForm.validate(valid => {
  230. console.log(valid)
  231. if (valid) {
  232. console.log(valid)
  233. if (!this.form.relationship) return this.$Toast('请选择关系')
  234. const form = JSON.stringify(this.form);
  235. this.$tools.navigateTo({
  236. url: '/pagesB/nameAuthentication/uploadPapers?form='+form
  237. })
  238. console.log('验证通过');
  239. } else {
  240. console.log('验证失败');
  241. }
  242. });
  243. },
  244. tagClick(item, index) {
  245. this.form.relationship = item
  246. this.tagCurrent = index
  247. }
  248. }
  249. };
  250. </script>
  251. <style lang="scss" scoped>
  252. /deep/ .u-tag {
  253. display: block !important;
  254. width: initial !important;
  255. font-size: 30rpx !important;
  256. padding: 12rpx !important;
  257. }
  258. /deep/ .u-input__input{
  259. font-size: 32rpx !important;
  260. }
  261. /deep/.u-form-item--left__content__label {
  262. width: 140rpx !important;
  263. font-size: 32rpx;
  264. }
  265. /deep/ input{
  266. font-size: 32rpx;
  267. }
  268. .drug-user-authentication {
  269. padding: 20rpx 20rpx 140rpx;
  270. &-footer {
  271. z-index: 1;
  272. height: 120rpx;
  273. bottom: 0;
  274. left: 0;
  275. width: 100%;
  276. background: #fff;
  277. /deep/.u-btn {
  278. width: 660rpx;
  279. height: 80rpx;
  280. }
  281. }
  282. &-item {
  283. background: #ffffff;
  284. border-radius: 12rpx;
  285. box-shadow: 0px 3rpx 6rpx 0px rgba(0,0,0,0.16);
  286. padding: 20rpx 40rpx;
  287. }
  288. }
  289. </style>