reAdd.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. <template>
  2. <view>
  3. <view class="container book-main">
  4. <view class="form-box">
  5. <view class="form-box-label">选择科室</view>
  6. <view class="form-box-content" @click="selectDep">
  7. <view class="form-box-content-text" v-if="!dep.title">请选择</view>
  8. <view class="form-box-content-text" v-if="dep.title">{{dep.title}}</view>
  9. <image src="../../images/xiangyou-xiao.png"></image>
  10. </view>
  11. </view>
  12. <view class="form-box">
  13. <view class="form-box-label">联系人 <text class="text-red">*</text></view>
  14. <view class="form-box-content">
  15. <input type="text" v-model="contact" placeholder="请填写" />
  16. </view>
  17. </view>
  18. <view class="form-box">
  19. <view class="form-box-label">联系手机号 <text class="text-red">*</text></view>
  20. <view class="form-box-content">
  21. <input type="tel" v-model="phone" placeholder="请填写" />
  22. </view>
  23. </view>
  24. <view class="form-box">
  25. <view class="form-box-label">选择服务 <text class="text-red">*</text></view>
  26. <view class="form-box-content" @click="selectCate">
  27. <view class="form-box-content-text" v-if="!cate.title">请选择</view>
  28. <view class="form-box-content-text" v-if="cate.title">{{cate.title}}</view>
  29. <image src="../../images/xiangyou-xiao.png"></image>
  30. </view>
  31. </view>
  32. <view class="form-box form-box2">
  33. <view class="form-box-label">被陪护人信息</view>
  34. <view class="form-box-sub">
  35. <view class="form-box-label">姓名<text class="text-red">*</text></view>
  36. <view class="form-box-content">
  37. <input type="text" placeholder="请填写" v-model="name" />
  38. </view>
  39. </view>
  40. <view class="form-box-sub">
  41. <view class="form-box-label">性别<text class="text-red">*</text></view>
  42. <view class="form-box-content" @click="selectGender">
  43. <view class="form-box-content-text">{{gender.title}}</view>
  44. <image src="../../images/xiangyou-xiao.png"></image>
  45. </view>
  46. </view>
  47. <view class="form-box-sub">
  48. <view class="form-box-label">年龄<text class="text-red">*</text></view>
  49. <view class="form-box-content">
  50. <input type="number" placeholder="请填写" v-model="age" />
  51. </view>
  52. </view>
  53. <view class="form-box-sub">
  54. <view class="form-box-label">床号<text class="text-red">*</text></view>
  55. <view class="form-box-content">
  56. <input type="text" placeholder="请填写" v-model="bed" />
  57. </view>
  58. </view>
  59. <view class="form-box-sub">
  60. <view class="form-box-label">所患疾病<text class="text-red">*</text></view>
  61. <view class="form-box-content">
  62. <input type="text" placeholder="请填写" v-model="ill" />
  63. </view>
  64. </view>
  65. </view>
  66. <view class="form-box">
  67. <view class="form-box-label">预约时间<text class="text-red">*</text></view>
  68. <view class="form-box-content">
  69. <view class="form-box-content" @click="selectStart">
  70. <view class="form-box-content-text" v-if="!start">请选择</view>
  71. <view class="form-box-content-text" v-if="start">{{start}}</view>
  72. <image src="../../images/xiangyou-xiao.png"></image>
  73. </view>
  74. </view>
  75. </view>
  76. <view class="form-box">
  77. <view class="form-box-label">是否首次下单</view>
  78. <view class="form-box-content">
  79. <radio-group @change="radioChange">
  80. <label class="radio" style="margin-right: 20rpx;">
  81. <radio value="1" :checked="isFirst ==1" />是
  82. </label>
  83. <label class="radio">
  84. <radio value="2" :checked="isFirst ==2"/>否
  85. </label>
  86. </radio-group>
  87. </view>
  88. </view>
  89. <view class="form-box form-box2">
  90. <view class="form-box-label">备注</view>
  91. <view class="form-box-textarea">
  92. <textarea style="height:120rpx;" v-model="remark" placeholder="请填写" />
  93. </view>
  94. </view>
  95. <view class="book-btn" @click="saveBtn()">提交</view>
  96. </view>
  97. <view class="protocol-box" v-if="showProtocol">
  98. <view v-html="protocol"></view>
  99. <view class="protocol-btn" @click="qrProtocolBtn()">同 意</view>
  100. </view>
  101. <view class="sign-box" v-if="showSign">
  102. <spsignboard
  103. ref="signBoardRef"
  104. sid="sign-board"
  105. bgColor="#ffffff"
  106. :showMark="false"
  107. :mark-text="markText"
  108. :horizontal="false"
  109. :penStyle="{ lineWidth: 4, color: '#000000' }"
  110. :expFile="{ fileType: 'jpg', quality: 0.7 }"
  111. @cancel="onCancel()"
  112. @confirm="onConfirmBoard()"
  113. @reset="reset"
  114. @firstTouchStart="firstTouchStart"
  115. ></spsignboard>
  116. <!-- <view class="sign-up-btn">上传签名</view> -->
  117. </view>
  118. <cpicker v-if="genders.length > 0" :list="genders" :show.sync="genderShow" :did="gender.id" @confirm="selectedGenderVal"></cpicker>
  119. <cpicker v-if="deps.length > 0" :list="deps" :show.sync="depShow" :did="dep.id" @confirm="selectedDepVal"></cpicker>
  120. <w-picker
  121. :visible.sync="startVisible"
  122. mode="date"
  123. startYear="2021"
  124. endYear="5000"
  125. themeColor="#006489"
  126. :current="true"
  127. fields="minute"
  128. @confirm="onConfirm($event,'date')"
  129. :disabled-after="false"
  130. ref="date"
  131. ></w-picker>
  132. <cpicker v-if="filterCates.length > 0" :list="filterCates" :show.sync="cateShow" :did="cate.id" @confirm="selectedCateVal"></cpicker>
  133. </view>
  134. </template>
  135. <script>
  136. var app = getApp();
  137. import cpicker from "../../components/cpicker/cpicker.vue";
  138. import wpicker from "../../components/w-picker/w-picker.vue";
  139. import spsignboard from "../../components/sp-sign-board/components/sp-sign-board/sp-sign-board.vue";
  140. export default {
  141. components: {
  142. cpicker,
  143. wpicker,
  144. spsignboard
  145. },
  146. data() {
  147. return {
  148. info:"",
  149. signBase64: "",
  150. signTempimg: "",
  151. markText: "陪护",
  152. showProtocol: false,
  153. isProtocol: false,
  154. protocol: "", // 协议内容
  155. showSign: false,
  156. isSign: false,
  157. signPath: "", // 签名上传路径
  158. flag: false,
  159. start:'',
  160. startVisible:false,
  161. contact: '',
  162. name: '',
  163. phone: '',
  164. ill: '',
  165. age: '',
  166. bed: '',
  167. gender: {
  168. id: 1,
  169. title: '男'
  170. },
  171. genderShow: false,
  172. genders:[{"id":1,"title":"男"},{"id":2,"title":"女"}],
  173. dep: {
  174. id: 0,
  175. title: ''
  176. },
  177. depShow: false,
  178. deps:[],
  179. remark: '',
  180. cate: {
  181. id: 0,
  182. title: ''
  183. },
  184. cates:[],
  185. cateShow: false,
  186. filterCates:[],
  187. wx: null,
  188. isFirst:1
  189. }
  190. },
  191. onLoad(option) {
  192. var that = this;
  193. that.info = JSON.parse(option.data);
  194. var orgId = this.getUrlCode('orgId');
  195. if(orgId){
  196. uni.setStorageSync(app.globalData.storagePre+'orgId',orgId);
  197. app.globalData.userinfo.orgId = orgId;
  198. }else{
  199. orgId = uni.getStorageSync(app.globalData.storagePre+'orgId');
  200. if(orgId){
  201. app.globalData.userinfo.orgId = orgId;
  202. }else{
  203. uni.showToast({
  204. title: '参数错误',
  205. icon: 'none',
  206. duration: 2000
  207. })
  208. }
  209. }
  210. if (this.$wechat && this.$wechat.isWechat()) {//获取定位经纬度
  211. this.$wechat.getWx(function (res) {
  212. that.wx = res;
  213. });
  214. }
  215. // 生成水印内容
  216. this.refreshMark()
  217. this.setData()
  218. },
  219. onShow() {
  220. var that = this;
  221. app.ajaxReadyCallback = res => { //各个接口统一回调方法
  222. var apiname = res.data.apiname;
  223. if(apiname == 'dep'){
  224. that.deps = res.data.data;
  225. }else if(apiname == 'cates'){
  226. that.cates = res.data.data;
  227. var filterCates = res.data.data.filter(item => {
  228. return (item.deps || []).includes(this.info.depId.toString());
  229. });
  230. var filterCates2 = this.cates.filter(item => {
  231. return (item.deps.length == 0);
  232. });
  233. that.filterCates = filterCates.length > 0 ? filterCates : filterCates2
  234. }else if(apiname == 'protocol'){
  235. that.protocol = res.data.data.content;
  236. } else if(apiname == 'order'){
  237. var payId = res.data.data.payId;
  238. if(payId <= 0 || that.isFirst == 2){
  239. uni.navigateTo({
  240. url: '/pages/index/success'
  241. });
  242. }else{
  243. that.getPayParam(payId);
  244. }
  245. }else if(apiname == 'pay'){
  246. if(that.wx){
  247. that.wx.chooseWXPay({
  248. timestamp: res.data.data.timestamp,
  249. nonceStr: res.data.data.nonceStr,
  250. package: res.data.data.package,
  251. signType: res.data.data.signType,
  252. paySign: res.data.data.paySign,
  253. success: function (r) {
  254. // 支付成功后的回调函数
  255. if (r.errMsg == "chooseWXPay:ok") {
  256. uni.navigateTo({
  257. url: '/pages/index/success'
  258. });
  259. } else {
  260. uni.navigateTo({
  261. url: '/pages/index/fail'
  262. });
  263. }
  264. },
  265. cancel: function(r) {},
  266. fail:function(r){
  267. // uni.showToast({
  268. // title: '支付失败',
  269. // icon: 'none',
  270. // duration: 2000
  271. // })
  272. uni.navigateTo({
  273. url: '/pages/index/fail'
  274. });
  275. }
  276. });
  277. }else{
  278. // uni.showToast({
  279. // title: '支付调用失败,请刷新重试',
  280. // icon: 'none',
  281. // duration: 2000
  282. // })
  283. uni.navigateTo({
  284. url: '/pages/index/fail'
  285. });
  286. }
  287. }
  288. }
  289. this.getDep();
  290. this.getCate();
  291. this.getProtocol();
  292. // 监听一次
  293. uni.$on('getSignImg', (e) => {
  294. // 多签名场景下可根据 sid 区分不同签名
  295. if (e.sid == 'sign-board') {
  296. that.signBase64 = e.base64
  297. that.signTempimg = e.path
  298. that.isSign = true;
  299. this.showSign = false;
  300. this.saveBtn();
  301. }
  302. // 一定注意不能确认签字完成后立马关闭弹窗,否则签字板会销毁,无法获取签名。需要等签名正确获取到之后再关闭弹窗
  303. // this.close()
  304. })
  305. },
  306. methods: {
  307. getUrlCode (name) {
  308. return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ''])[1].replace(/\+/g, '%20')) || null
  309. },
  310. selectGender(){
  311. this.genderShow = true;
  312. },
  313. selectedGenderVal(obj){
  314. this.gender = obj;
  315. },
  316. selectDep(){
  317. this.depShow = true;
  318. },
  319. selectedDepVal(obj){
  320. this.dep = obj;
  321. this.cate = {
  322. id: 0,
  323. title: ''
  324. }
  325. this.filterCates = this.cates.filter(item => {
  326. return (item.deps || []).includes(obj.id.toString());
  327. });
  328. if(this.filterCates.length <= 0){
  329. this.filterCates = this.cates.filter(item => {
  330. return (item.deps.length == 0);
  331. });
  332. }
  333. },
  334. selectCate(){
  335. if(this.dep.id == 0){
  336. uni.showToast({
  337. title: '请先选择科室',
  338. icon: 'none',
  339. duration: 2000
  340. })
  341. return
  342. }
  343. this.cateShow = true;
  344. },
  345. selectedCateVal(obj){
  346. this.cate = obj;
  347. },
  348. getProtocol(){
  349. app.ajax({
  350. url: app.globalData.serverUrl + 'common/phprotocol',
  351. type: 'POST',
  352. apiname: 'protocol',
  353. });
  354. },
  355. getDep(){
  356. app.ajax({
  357. url: app.globalData.serverUrl + 'common/dep',
  358. type: 'POST',
  359. apiname: 'dep',
  360. });
  361. },
  362. getCate(){
  363. app.ajax({
  364. url: app.globalData.serverUrl + 'Worker/cates',
  365. type: 'POST',
  366. apiname: 'cates',
  367. });
  368. },
  369. getPayParam(payId){
  370. app.ajax({
  371. url: app.globalData.serverUrl + 'PhOrders/pay',
  372. type: 'POST',
  373. apiname: 'pay',
  374. data: {
  375. payId: payId
  376. }
  377. });
  378. },
  379. onConfirm(e,type){
  380. this.start = e.result;
  381. },
  382. onCancel(){
  383. this.showSign = false;
  384. },
  385. onConfirmBoard(){
  386. this.showSign = false;
  387. this.saveBtn();
  388. },
  389. selectStart(){
  390. this.startVisible = true;
  391. },
  392. qrProtocolBtn(){
  393. this.showProtocol = false;
  394. this.isProtocol = true;
  395. this.saveBtn();
  396. },
  397. refreshMark() {
  398. // const currentDate = new Date()
  399. // const year = currentDate.getFullYear()
  400. // const month = String(currentDate.getMonth() + 1).padStart(2, '0')
  401. // const day = String(currentDate.getDate()).padStart(2, '0')
  402. // const hours = String(currentDate.getHours()).padStart(2, '0')
  403. // const minutes = String(currentDate.getMinutes()).padStart(2, '0')
  404. // const seconds = String(currentDate.getSeconds()).padStart(2, '0')
  405. this.markText = ["陪护"];
  406. },
  407. firstTouchStart() {
  408. // 在第一次开始触碰时,更新一下时间水印,防止滞留时间太长造成时间误差(非必要)
  409. this.refreshMark()
  410. // 手动调用组件内绘制水印方法重新绘制
  411. this.$refs.signBoardRef.drawMark(this.markText)
  412. },
  413. reset() {
  414. this.refreshMark()
  415. },
  416. radioChange(e) {
  417. this.isFirst = e.detail.value;
  418. },
  419. setData(){
  420. if(this.info.gender == 1){
  421. var gender = {
  422. id: 1,
  423. title: '男'
  424. };
  425. }else{
  426. var gender = {
  427. id: 2,
  428. title: '女'
  429. };
  430. };
  431. const originalTime = this.info.start;
  432. const start = originalTime.slice(0, -3);
  433. this.contact = this.info.contact,
  434. this.phone = this.info.phone,
  435. this.name = this.info.name,
  436. this.gender = gender,
  437. this.age = this.info.age,
  438. this.bed = this.info.bed,
  439. this.ill = this.info.ill,
  440. this.start = start,
  441. this.remark = this.info.remark
  442. this.dep = {
  443. id:this.info.depId,
  444. title:this.info.depName
  445. }
  446. this.cate = {
  447. id:this.info.cateId,
  448. title:this.info.cateName2
  449. }
  450. this.isFirst = this.info.serviceMoney > 0 ? 1 : 2
  451. },
  452. saveBtn(){
  453. if(!this.contact){
  454. uni.showToast({
  455. title: '请输入联系人',
  456. icon: 'none',
  457. duration: 2000
  458. })
  459. return;
  460. }
  461. if(!this.phone){
  462. uni.showToast({
  463. title: '请输入手机号',
  464. icon: 'none',
  465. duration: 2000
  466. })
  467. return;
  468. }
  469. if(!this.cate || this.cate.id <= 0){
  470. uni.showToast({
  471. title: '请输入选择服务',
  472. icon: 'none',
  473. duration: 2000
  474. })
  475. return;
  476. }
  477. if(!this.name){
  478. uni.showToast({
  479. title: '请输入姓名',
  480. icon: 'none',
  481. duration: 2000
  482. })
  483. return;
  484. }
  485. if(!this.age){
  486. uni.showToast({
  487. title: '请输入年龄',
  488. icon: 'none',
  489. duration: 2000
  490. })
  491. return;
  492. }
  493. if(!this.bed){
  494. uni.showToast({
  495. title: '请输入床号',
  496. icon: 'none',
  497. duration: 2000
  498. })
  499. return;
  500. }
  501. if(!this.ill){
  502. uni.showToast({
  503. title: '请输入所患疾病',
  504. icon: 'none',
  505. duration: 2000
  506. })
  507. return;
  508. }
  509. if(!this.start){
  510. uni.showToast({
  511. title: '请选择预约时间',
  512. icon: 'none',
  513. duration: 2000
  514. })
  515. return;
  516. }
  517. if(!this.isProtocol){
  518. this.showProtocol = true;
  519. return false;
  520. }
  521. if(!this.isSign || !this.signBase64){
  522. this.showSign = true;
  523. return false;
  524. }
  525. let param = {
  526. contact: this.contact,
  527. phone: this.phone,
  528. name: this.name,
  529. gender: this.gender.id,
  530. age: this.age,
  531. bed: this.bed,
  532. ill: this.ill,
  533. start: this.start,
  534. remark: this.remark,
  535. depId: this.dep.id,
  536. cateId: this.cate.id,
  537. sign: this.signBase64,
  538. isFirst: this.isFirst
  539. }
  540. app.ajax({
  541. url: app.globalData.serverUrl + 'worker/order',
  542. type: 'POST',
  543. apiname: 'order',
  544. data: param
  545. });
  546. }
  547. }
  548. }
  549. </script>
  550. <style lang="scss" scoped>
  551. .navbg{
  552. width: 100%;
  553. height: 300rpx;
  554. }
  555. .book-main{
  556. width: 710rpx;
  557. // position: absolute;
  558. // z-index: 10;
  559. // top: 300rpx;
  560. // left: 0;
  561. // bottom: 0;
  562. // overflow: auto;
  563. overflow-y: auto;
  564. overflow-x: hidden;
  565. }
  566. .book-btn{
  567. width: 710rpx;
  568. height: 90rpx;
  569. line-height: 90rpx;
  570. background-color: var(--themeColor);
  571. color: #ffffff;
  572. font-size: 34rpx;
  573. font-weight: bold;
  574. text-align: center;
  575. border-radius: 10rpx;
  576. }
  577. .protocol-box{
  578. position: fixed;
  579. z-index: 10000;
  580. top: 0;
  581. left: 0;
  582. right: 0;
  583. bottom: 0;
  584. background-color: #ffffff;
  585. padding: 20rpx;
  586. overflow: auto;
  587. }
  588. .protocol-btn{
  589. position: fixed;
  590. z-index: 10001;
  591. left: 20rpx;
  592. right: 20rpx;
  593. bottom: 10rpx;
  594. background-color: var(--themeColor);
  595. height: 90rpx;
  596. line-height: 90rpx;
  597. color: #ffffff;
  598. font-size: 34rpx;
  599. font-weight: bold;
  600. text-align: center;
  601. border-radius: 10rpx;
  602. }
  603. .sign-box{
  604. position: fixed;
  605. z-index: 100000;
  606. top: 0;
  607. left: 0;
  608. right: 0;
  609. bottom: 0;
  610. background-color: #ffffff;
  611. padding: 20rpx;
  612. }
  613. .sign-canvas{
  614. width: 750rpx;
  615. height: 400rpx;
  616. }
  617. .sign-up-btn{
  618. position: fixed;
  619. z-index: 100001;
  620. left: 20rpx;
  621. right: 20rpx;
  622. bottom: 10rpx;
  623. background-color: var(--themeColor);
  624. height: 90rpx;
  625. line-height: 90rpx;
  626. color: #ffffff;
  627. font-size: 34rpx;
  628. font-weight: bold;
  629. text-align: center;
  630. border-radius: 10rpx;
  631. }
  632. .protocol-box image{
  633. max-width: 100%;
  634. }
  635. </style>