耀实惠小程序
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.

469 lines
13 KiB

  1. <template>
  2. <view class="drug-user-authentication position-relative">
  3. <u-form :model="form" ref="uForm">
  4. <view class="drug-user-authentication-item m-b-40">
  5. <view class="drug-user-authentication-title font-30 text-black m-b-20 font-weight-bold">用药人信息</view>
  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="birthday">
  8. <view @click="assignModalShow('timeShow')">
  9. <u-input v-model="form.birthday" disabled placeholder="请选择出生日期" input-align="right" @click="assignModalShow('timeShow')"/>
  10. </view>
  11. </u-form-item>
  12. <u-form-item label-width="20%" label="身份证" prop="cardId"><u-input v-model="form.cardId" input-align="right" placeholder="请输入身份证号码" :clearable="false"/></u-form-item>
  13. <u-form-item label-width="20%" label="手机号码" prop="phone"><u-input v-model="form.phone" type="number" input-align="right" placeholder="请输入手机号码" :clearable="false" /></u-form-item>
  14. </view>
  15. <view class="drug-user-authentication-item m-b-40">
  16. <u-form-item label-width="20%" label="今日体温" prop="temperature"><u-input v-model="form.temperature" type="number" input-align="right" placeholder="请输入今日体温" /></u-form-item>
  17. <u-form-item label-width="20%" label="症状" prop="symptom">
  18. <u-tag
  19. v-for="(item, index) in tagList"
  20. :key="index"
  21. :text="item.name"
  22. mode="dark"
  23. class="m-r-10"
  24. :mode="item.select ? 'dark' : 'plain'"
  25. :type="item.select ? 'primary' : 'info'"
  26. @click="tagClick(item, index)"
  27. ></u-tag>
  28. </u-form-item>
  29. <u-input v-if="showSymptom" placeholder="请输入症状" v-model="symptomVal" type="textarea" :height="100" auto-height />
  30. </view>
  31. <view class="drug-user-authentication-item m-b-40">
  32. <u-form-item prop="isGo">
  33. <view class="">14天内有境外中高风险地区旅居史</view>
  34. <u-radio-group v-model="form.isGo" active-color="#01AEEA">
  35. <u-radio
  36. v-for="(item, index) in travel" :key="index"
  37. :name="item.name"
  38. >
  39. {{item.name}}
  40. </u-radio>
  41. </u-radio-group>
  42. </u-form-item>
  43. <u-form-item label-width="20%" label="所在地区" prop="addr">
  44. <view @click="assignModalShow('regionShow')">
  45. <u-input v-model="form.addr" disabled placeholder="请选择所在地区" input-align="right" @click="assignModalShow('regionShow')"/>
  46. </view>
  47. </u-form-item>
  48. <u-form-item label-width="20%" label="详细地址" prop="address"><u-input placeholder="请输入详细地址" v-model="form.address" type="textarea" :height="100" auto-height /></u-form-item>
  49. </view>
  50. </u-form>
  51. <view class="drug-user-authentication-footer position-fixed flex flex-column align-start justify-between zIndex-1">
  52. <view>
  53. <u-checkbox-group active-color="#01AEEA">
  54. <u-checkbox v-model="isAgreement" shape="circle">
  55. <view class="drug-user-authentication-agreement" >
  56. 同意 <text class="drug-user-authentication-agreement--text" @click.stop="toDetali">防疫登记协议</text>
  57. </view>
  58. </u-checkbox>
  59. </u-checkbox-group>
  60. </view>
  61. <view class="flex justify-center w-100">
  62. <u-button type="primary" shape="circle" @click="preserve">保存并使用</u-button>
  63. </view>
  64. </view>
  65. <u-picker mode="time" v-model="timeShow" @confirm="timeConfirm" confirm-color="#01AEEA" zIndex="999999999"></u-picker>
  66. <u-picker v-model="regionShow" @confirm="regionConfirm" mode="region"></u-picker>
  67. <u-select v-model="sexShow" :list="sexList" @confirm="sexConfirm" confirm-color="#01AEEA"></u-select>
  68. </view>
  69. </template>
  70. <script>
  71. const sexList = [
  72. {
  73. value: '1',
  74. label: '男'
  75. },
  76. {
  77. value: '2',
  78. label: '女'
  79. }
  80. ];
  81. const tagList = [
  82. {
  83. name : '发热',
  84. select: false,
  85. },
  86. {
  87. name : '咳嗽',
  88. select: false,
  89. },
  90. {
  91. name : '胸闷',
  92. select: false,
  93. },
  94. {
  95. name : '无',
  96. select: false,
  97. },
  98. {
  99. name : '其他',
  100. select: false,
  101. }
  102. ]
  103. export default {
  104. data() {
  105. return {
  106. travel: [
  107. { name: '有' },
  108. { name: '无' }
  109. ],
  110. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  111. sexList,
  112. tagList,
  113. tagCurrent: null,
  114. showSymptom: false,
  115. isAgreement: false,
  116. symptomVal: '',
  117. symptomList: [],
  118. form: {
  119. name: '',
  120. phone: '',
  121. cardId: '',
  122. birthday: '',
  123. temperature: '',
  124. symptom: '',
  125. isGo: '',
  126. addr: '',
  127. address: ''
  128. },
  129. timeShow: false,
  130. sexShow: false,
  131. regionShow: false,
  132. options: {},
  133. rules: {
  134. name: [
  135. {
  136. required: true,
  137. message: '请输入姓名'
  138. },
  139. {
  140. validator: (rule, value, callback) => {
  141. let username = /^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,99}$/;
  142. return username.test(value);
  143. },
  144. message: '请输入正确格式的姓名',
  145. trigger: ['blur']
  146. }
  147. ],
  148. cardId: [
  149. {
  150. required: true,
  151. message: '请输入身份证号码'
  152. },
  153. {
  154. message: '请输入正确格式的身份证号码',
  155. validator: (rule, value, callback) => {
  156. return this.$u.test.idCard(value);
  157. }
  158. }
  159. ],
  160. phone: [
  161. {
  162. required: true,
  163. message: '请输入手机号码',
  164. trigger: ['change', 'blur']
  165. },
  166. {
  167. message: '请输入正确格式的手机号码',
  168. validator: (rule, value, callback) => {
  169. return this.$u.test.mobile(value);
  170. }
  171. }
  172. ],
  173. birthday: [
  174. {
  175. required: true,
  176. message: '请选择出生日期',
  177. trigger: ['change', 'blur']
  178. }
  179. ],
  180. temperature: [
  181. {
  182. required: true,
  183. message: '请输入今日体温',
  184. trigger: ['change', 'blur']
  185. }
  186. ],
  187. symptom: [
  188. {
  189. required: true,
  190. message: '请选择症状',
  191. trigger: ['change', 'blur']
  192. }
  193. ],
  194. isGo: [
  195. {
  196. required: true,
  197. message: '请选择14天内有境外、中高风险地区旅居史',
  198. trigger: ['change', 'blur']
  199. }
  200. ],
  201. addr: [
  202. {
  203. required: true,
  204. message: '请输入所在地区',
  205. trigger: ['change', 'blur']
  206. }
  207. ],
  208. address: [
  209. {
  210. required: true,
  211. message: '请输入详细地址',
  212. trigger: ['change', 'blur']
  213. }
  214. ],
  215. },
  216. };
  217. },
  218. onReady() {
  219. this.$refs.uForm.setRules(this.rules);
  220. },
  221. onLoad(options) {
  222. // form: {
  223. // name: '',
  224. // phone: '',
  225. // cardId: '',
  226. // birthday: '',
  227. // temperature: '',
  228. // symptom: '',
  229. // isGo: '',
  230. // addr: '',
  231. // address: ''
  232. // },
  233. this.options = options
  234. if (options.medicineMan) {
  235. let medicineMan = JSON.parse(options.medicineMan)
  236. let { name, phone, cardId, birthday } = medicineMan
  237. this.form = { ...this.form, name, phone, cardId, birthday }
  238. console.log(medicineMan)
  239. }
  240. },
  241. methods: {
  242. // 清除身份证内容
  243. clearText() {
  244. console.log("进来的")
  245. setTimeout(() => {
  246. this.form.cardId = ''
  247. },0)
  248. },
  249. // 清除电话号码
  250. clearText2() {
  251. console.log("进来的")
  252. setTimeout(() => {
  253. this.form.phone = ''
  254. },0)
  255. },
  256. assignModalShow (key) {
  257. this[key] = true
  258. },
  259. timeConfirm(time) {
  260. let { year, month, day } = time;
  261. this.form.birthday = `${year}/${month}/${day}`;
  262. },
  263. regionConfirm (obj) {
  264. console.log(obj)
  265. let {province, city, area} = obj
  266. this.form.addr = `${province.label},${city.label},${area.label}`
  267. },
  268. // 修改信息查询
  269. sexConfirm(arr) {
  270. this.form.sex = arr[0].label
  271. },
  272. preserve() {
  273. const options = this.options
  274. this.$refs.uForm.validate(valid => {
  275. if (valid) {
  276. if (this.showSymptom && !this.symptomVal) return this.$Toast('请输入症状')
  277. if (!this.isAgreement) return this.$Toast('请同意协议')
  278. let params = this.showSymptom && this.symptomVal ? { ...this.form, symptom: this.symptomVal }: this.form
  279. this.$api('setPrevention', params)
  280. .then(res => {
  281. console.log(res)
  282. if (res.code === 200) {
  283. if(this.options.createOrderType === 'shoppingCart'){
  284. this.addShoppingCart(res.result.id)
  285. }else if(this.options.createOrderType === 'confirm') {
  286. this.setOrder(res.result.id)
  287. }else {
  288. this.addShoppingCart(res.result.id);
  289. }
  290. } else {
  291. this.$Toast(res.message)
  292. }
  293. })
  294. console.log('验证通过');
  295. } else {
  296. console.log('验证失败');
  297. }
  298. });
  299. },
  300. // 创建订单
  301. setOrder(id){
  302. const options = this.options
  303. this.$api('teamCreateOrder', {type:2, id: options.goodsId, goodsPrice: options.price, goodsNum: options.num, goodsSku: options.goodSkuParam, orderType: options.orderType, preventionId:id,prescriptionId: this.options.prescriptionId,offlineInfoId: this.options.offlineInfoId,})
  304. .then(res => {
  305. uni.hideLoading()
  306. let { code, message, result } = res
  307. if (code === 200) {
  308. uni.redirectTo({
  309. url: `/pagesC/confirmOrder/confirmOrder?ids=${result.order.id}&orderType=${options.orderType}&payType=${0}`
  310. })
  311. }else if (res.code === 903) {
  312. uni.redirectTo({
  313. url: `/pagesC/subscribe/confirmSubscribe?addressId=${this.options.addressId}&orderType=${this.options.orderType}&goodsId=${this.options.goodsId}&num=${this.options.num}&price=${this.options.price}&goodSkuParam=${this.options.goodSkuParam}&prescriptionId=${this.options.prescriptionId}&preventionId=${id}&medicineMan=${this.options.medicineMan}`
  314. })
  315. }else {
  316. this.$Toast(res.message)
  317. }
  318. }).catch(err => {
  319. this.$Toast(err.message)
  320. })
  321. },
  322. // 加入购物车
  323. addShoppingCart (preventionId) {
  324. this.$api('addShoppingCart', {id: this.options.goodsId, num: this.options.num, price: this.options.price, goodSkuParam: this.options.goodSkuParam, offlineInfoId: this.options.offlineInfoId, prescriptionId: this.options.prescriptionId, preventionId })
  325. .then(res => {
  326. if (res.code === 200) {
  327. uni.$emit('isUpdataShowToast')
  328. this.$Toast(res.message)
  329. // 返回页面
  330. let pages_url = getCurrentPages();
  331. const index = pages_url.findIndex(item => {
  332. return item.route == 'pagesC/goodsInfo/goodsInfo'
  333. });
  334. const length = pages_url.length
  335. // 需要返回的层数
  336. const backIndex = length - (index+1);
  337. uni.navigateBack({
  338. delta: backIndex
  339. })
  340. // setTimeout(() => {
  341. // this.$tools.switchTab({
  342. // url: '/pages/shoppingCart/shoppingCart'
  343. // })
  344. // }, 800)
  345. }else if (res.code === 903) {
  346. this.$tools.redirectTo({
  347. url: `/pagesC/subscribe/confirmSubscribe?addressId=${this.options.addressId}&orderType=${this.options.orderType}&goodsId=${this.options.goodsId}&num=${this.options.num}&price=${this.options.price}&goodSkuParam=${this.options.goodSkuParam}&prescriptionId=${this.options.prescriptionId}&preventionId=${preventionId}&medicineMan=${this.options.medicineMan}`
  348. })
  349. } else {
  350. this.$Toast(res.message)
  351. }
  352. })
  353. },
  354. tagClick(item, index) {
  355. this.tagList[index].select = !this.tagList[index].select
  356. this.showSymptom = false
  357. console.log(item.name == '无')
  358. if(item.name == '无'&& item.select){
  359. this.tagList.forEach((item,selectrIndex) => {
  360. if(selectrIndex !== index) {
  361. item.select = false
  362. }
  363. })
  364. this.symptomList = []
  365. this.symptomList.push(item.name)
  366. this.form.symptom = item.name
  367. return
  368. }else {
  369. this.tagList.forEach(item => {
  370. if(item.name == '无') {
  371. item.select = false
  372. }
  373. })
  374. }
  375. if (item.name == '其他' && item.select) {
  376. this.tagList.forEach((item,selectrIndex) => {
  377. if(selectrIndex !== index) {
  378. item.select = false
  379. }
  380. })
  381. this.symptomList = []
  382. this.symptomList.push(item.name)
  383. this.showSymptom = true
  384. this.form.symptom = item.name
  385. return
  386. }else {
  387. this.tagList.forEach(item => {
  388. if(item.name == '其他') {
  389. item.select = false
  390. }
  391. })
  392. }
  393. if(item.select) {
  394. if(this.symptomList[0] == '无' || this.symptomList[0] == '其他' ){
  395. this.symptomList.splice(0,1)
  396. }
  397. this.symptomList.push(item.name)
  398. this.form.symptom = this.symptomList.join(",")
  399. }else {
  400. const index2 = this.symptomList.filter(item=> item).indexOf(item.name)
  401. this.symptomList.splice(index2,1)
  402. this.form.symptom = this.symptomList.join(",")
  403. }
  404. },
  405. // 协议
  406. toDetali(){
  407. this.$tools.navigateTo({
  408. url: `/pages/agreement/index?title=&type=2`
  409. })
  410. }
  411. }
  412. };
  413. </script>
  414. <style lang="scss" scoped>
  415. .drug-user-authentication {
  416. padding: 20rpx 20rpx 220rpx;
  417. &-footer {
  418. z-index: 10;
  419. height: 160rpx;
  420. padding: 20rpx;
  421. bottom: 0;
  422. left: 0;
  423. width: 100%;
  424. background: #fff;
  425. /deep/.u-btn {
  426. width: 660rpx;
  427. height: 70rpx;
  428. margin: 0 auto;
  429. }
  430. }
  431. &-item {
  432. background: #ffffff;
  433. border-radius: 12rpx;
  434. box-shadow: 0px 3rpx 6rpx 0px rgba(0,0,0,0.16);
  435. padding: 20rpx 40rpx;
  436. }
  437. ::v-deep .u-input__textarea {
  438. background: #e2e2e2;
  439. padding: 10px;
  440. }
  441. ::v-deep .u-checkbox__icon-wrap {
  442. width: 40rpx !important;
  443. height: 40rpx !important;
  444. }
  445. &-agreement {
  446. font-size: 28rpx;
  447. &--text {
  448. color: #01AEEA;
  449. }
  450. }
  451. }
  452. // 设置清空图标大小
  453. </style>