add.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  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="true" />
  82. </label>
  83. <label class="radio">
  84. <radio value="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. :value="start"
  127. :current="true"
  128. fields="minute"
  129. @confirm="onConfirm($event,'date')"
  130. :disabled-after="false"
  131. ref="date"
  132. ></w-picker>
  133. <cpicker v-if="filterCates.length > 0" :list="filterCates" :show.sync="cateShow" :did="cate.id" @confirm="selectedCateVal"></cpicker>
  134. </view>
  135. </template>
  136. <script>
  137. var app = getApp();
  138. import cpicker from "../../components/cpicker/cpicker.vue";
  139. import wpicker from "../../components/w-picker/w-picker.vue";
  140. import spsignboard from "../../components/sp-sign-board/components/sp-sign-board/sp-sign-board.vue";
  141. export default {
  142. components: {
  143. cpicker,
  144. wpicker,
  145. spsignboard
  146. },
  147. data() {
  148. return {
  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. saveFlag:false
  190. }
  191. },
  192. onLoad(option) {
  193. var that = this;
  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. console.log(res)
  213. that.wx = res;
  214. });
  215. }
  216. // 生成水印内容
  217. this.refreshMark()
  218. },
  219. onShow() {
  220. var that = this;
  221. app.ajaxReadyCallback = res => { //各个接口统一回调方法
  222. var apiname = res.data.apiname;
  223. console.log(res);
  224. if(apiname == 'dep'){
  225. that.deps = res.data.data;
  226. }else if(apiname == 'cates'){
  227. that.cates = res.data.data;
  228. }else if(apiname == 'protocol'){
  229. that.protocol = res.data.data.content;
  230. } else if(apiname == 'order'){
  231. var payId = res.data.data.payId;
  232. if(payId <= 0 || that.isFirst == 2){
  233. uni.navigateTo({
  234. url: '/pages/index/success'
  235. });
  236. }else{
  237. that.getPayParam(payId);
  238. }
  239. }else if(apiname == 'pay'){
  240. if(that.wx){
  241. that.wx.chooseWXPay({
  242. timestamp: res.data.data.timestamp,
  243. nonceStr: res.data.data.nonceStr,
  244. package: res.data.data.package,
  245. signType: res.data.data.signType,
  246. paySign: res.data.data.paySign,
  247. success: function (r) {
  248. // 支付成功后的回调函数
  249. if (r.errMsg == "chooseWXPay:ok") {
  250. uni.navigateTo({
  251. url: '/pages/index/success'
  252. });
  253. } else {
  254. uni.navigateTo({
  255. url: '/pages/index/fail'
  256. });
  257. }
  258. },
  259. cancel: function(r) {},
  260. fail:function(r){
  261. // uni.showToast({
  262. // title: '支付失败',
  263. // icon: 'none',
  264. // duration: 2000
  265. // })
  266. uni.navigateTo({
  267. url: '/pages/index/fail'
  268. });
  269. }
  270. });
  271. }else{
  272. // uni.showToast({
  273. // title: '支付调用失败,请刷新重试',
  274. // icon: 'none',
  275. // duration: 2000
  276. // })
  277. uni.navigateTo({
  278. url: '/pages/index/fail'
  279. });
  280. }
  281. }
  282. }
  283. app.ajaxReadyCallback2 = res => { //各个接口统一回调方法
  284. var apiname = res.data.apiname;
  285. if(apiname == 'order'){
  286. that.saveFlag = false;
  287. }
  288. }
  289. this.getDep();
  290. this.getCate();
  291. this.getProtocol();
  292. // 监听一次
  293. uni.$on('getSignImg', (e) => {
  294. console.log('getSignImg', e)
  295. // 多签名场景下可根据 sid 区分不同签名
  296. if (e.sid == 'sign-board') {
  297. that.signBase64 = e.base64
  298. that.signTempimg = e.path
  299. that.isSign = true;
  300. this.showSign = false;
  301. this.saveBtn();
  302. }
  303. // 一定注意不能确认签字完成后立马关闭弹窗,否则签字板会销毁,无法获取签名。需要等签名正确获取到之后再关闭弹窗
  304. // this.close()
  305. })
  306. },
  307. methods: {
  308. getUrlCode (name) {
  309. return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ''])[1].replace(/\+/g, '%20')) || null
  310. },
  311. selectGender(){
  312. this.genderShow = true;
  313. },
  314. selectedGenderVal(obj){
  315. console.log(obj)
  316. this.gender = obj;
  317. },
  318. selectDep(){
  319. this.depShow = true;
  320. },
  321. selectedDepVal(obj){
  322. this.dep = obj;
  323. this.cate = {
  324. id: 0,
  325. title: ''
  326. }
  327. this.filterCates = this.cates.filter(item => {
  328. return (item.deps || []).includes(obj.id.toString());
  329. });
  330. if(this.filterCates.length <= 0){
  331. this.filterCates = this.cates.filter(item => {
  332. return (item.deps.length == 0);
  333. });
  334. }
  335. },
  336. selectCate(){
  337. if(this.dep.id == 0){
  338. uni.showToast({
  339. title: '请先选择科室',
  340. icon: 'none',
  341. duration: 2000
  342. })
  343. return
  344. }
  345. this.cateShow = true;
  346. },
  347. selectedCateVal(obj){
  348. console.log(obj)
  349. this.cate = obj;
  350. },
  351. getProtocol(){
  352. app.ajax({
  353. url: app.globalData.serverUrl + 'common/phprotocol',
  354. type: 'POST',
  355. apiname: 'protocol',
  356. });
  357. },
  358. getDep(){
  359. app.ajax({
  360. url: app.globalData.serverUrl + 'common/dep',
  361. type: 'POST',
  362. apiname: 'dep',
  363. });
  364. },
  365. getCate(){
  366. app.ajax({
  367. url: app.globalData.serverUrl + 'Worker/cates',
  368. type: 'POST',
  369. apiname: 'cates',
  370. });
  371. },
  372. getPayParam(payId){
  373. app.ajax({
  374. url: app.globalData.serverUrl + 'PhOrders/pay',
  375. type: 'POST',
  376. apiname: 'pay',
  377. data: {
  378. payId: payId
  379. }
  380. });
  381. },
  382. onConfirm(e,type){
  383. this.start = e.result;
  384. },
  385. onCancel(){
  386. console.log("onCancel");
  387. this.showSign = false;
  388. },
  389. onConfirmBoard(){
  390. console.log("onConfirmBoard");
  391. this.showSign = false;
  392. this.saveBtn();
  393. },
  394. selectStart(){
  395. this.startVisible = true;
  396. },
  397. qrProtocolBtn(){
  398. this.showProtocol = false;
  399. this.isProtocol = true;
  400. this.saveBtn();
  401. },
  402. refreshMark() {
  403. // const currentDate = new Date()
  404. // const year = currentDate.getFullYear()
  405. // const month = String(currentDate.getMonth() + 1).padStart(2, '0')
  406. // const day = String(currentDate.getDate()).padStart(2, '0')
  407. // const hours = String(currentDate.getHours()).padStart(2, '0')
  408. // const minutes = String(currentDate.getMinutes()).padStart(2, '0')
  409. // const seconds = String(currentDate.getSeconds()).padStart(2, '0')
  410. this.markText = ["陪护"];
  411. },
  412. firstTouchStart() {
  413. // 在第一次开始触碰时,更新一下时间水印,防止滞留时间太长造成时间误差(非必要)
  414. this.refreshMark()
  415. // 手动调用组件内绘制水印方法重新绘制
  416. this.$refs.signBoardRef.drawMark(this.markText)
  417. },
  418. reset() {
  419. this.refreshMark()
  420. },
  421. radioChange(e) {
  422. this.isFirst = e.detail.value;
  423. },
  424. saveBtn(){
  425. if(!this.contact){
  426. uni.showToast({
  427. title: '请输入联系人',
  428. icon: 'none',
  429. duration: 2000
  430. })
  431. return;
  432. }
  433. if(!this.phone){
  434. uni.showToast({
  435. title: '请输入手机号',
  436. icon: 'none',
  437. duration: 2000
  438. })
  439. return;
  440. }
  441. if(!this.cate || this.cate.id <= 0){
  442. uni.showToast({
  443. title: '请输入选择服务',
  444. icon: 'none',
  445. duration: 2000
  446. })
  447. return;
  448. }
  449. if(!this.name){
  450. uni.showToast({
  451. title: '请输入姓名',
  452. icon: 'none',
  453. duration: 2000
  454. })
  455. return;
  456. }
  457. if(!this.age){
  458. uni.showToast({
  459. title: '请输入年龄',
  460. icon: 'none',
  461. duration: 2000
  462. })
  463. return;
  464. }
  465. if(!this.bed){
  466. uni.showToast({
  467. title: '请输入床号',
  468. icon: 'none',
  469. duration: 2000
  470. })
  471. return;
  472. }
  473. if(!this.ill){
  474. uni.showToast({
  475. title: '请输入所患疾病',
  476. icon: 'none',
  477. duration: 2000
  478. })
  479. return;
  480. }
  481. if(!this.start){
  482. uni.showToast({
  483. title: '请选择预约时间',
  484. icon: 'none',
  485. duration: 2000
  486. })
  487. return;
  488. }
  489. if(!this.isProtocol){
  490. this.showProtocol = true;
  491. return false;
  492. }
  493. if(!this.isSign || !this.signBase64){
  494. this.showSign = true;
  495. return false;
  496. }
  497. if(this.saveFlag){
  498. return;
  499. }
  500. this.saveFlag = true;
  501. let param = {
  502. contact: this.contact,
  503. phone: this.phone,
  504. name: this.name,
  505. gender: this.gender.id,
  506. age: this.age,
  507. bed: this.bed,
  508. ill: this.ill,
  509. start: this.start,
  510. remark: this.remark,
  511. depId: this.dep.id,
  512. cateId: this.cate.id,
  513. sign: this.signBase64,
  514. isFirst: this.isFirst
  515. }
  516. app.ajax({
  517. url: app.globalData.serverUrl + 'worker/order',
  518. type: 'POST',
  519. apiname: 'order',
  520. data: param
  521. });
  522. }
  523. }
  524. }
  525. </script>
  526. <style lang="scss" scoped>
  527. .navbg{
  528. width: 100%;
  529. height: 300rpx;
  530. }
  531. .book-main{
  532. width: 710rpx;
  533. // position: absolute;
  534. // z-index: 10;
  535. // top: 300rpx;
  536. // left: 0;
  537. // bottom: 0;
  538. // overflow: auto;
  539. overflow-y: auto;
  540. overflow-x: hidden;
  541. }
  542. .book-btn{
  543. width: 710rpx;
  544. height: 90rpx;
  545. line-height: 90rpx;
  546. background-color: var(--themeColor);
  547. color: #ffffff;
  548. font-size: 34rpx;
  549. font-weight: bold;
  550. text-align: center;
  551. border-radius: 10rpx;
  552. }
  553. .protocol-box{
  554. position: fixed;
  555. z-index: 10000;
  556. top: 0;
  557. left: 0;
  558. right: 0;
  559. bottom: 0;
  560. background-color: #ffffff;
  561. padding: 20rpx;
  562. overflow: auto;
  563. }
  564. .protocol-btn{
  565. position: fixed;
  566. z-index: 10001;
  567. left: 20rpx;
  568. right: 20rpx;
  569. bottom: 10rpx;
  570. background-color: var(--themeColor);
  571. height: 90rpx;
  572. line-height: 90rpx;
  573. color: #ffffff;
  574. font-size: 34rpx;
  575. font-weight: bold;
  576. text-align: center;
  577. border-radius: 10rpx;
  578. }
  579. .sign-box{
  580. position: fixed;
  581. z-index: 100000;
  582. top: 0;
  583. left: 0;
  584. right: 0;
  585. bottom: 0;
  586. background-color: #ffffff;
  587. padding: 20rpx;
  588. }
  589. .sign-canvas{
  590. width: 750rpx;
  591. height: 400rpx;
  592. }
  593. .sign-up-btn{
  594. position: fixed;
  595. z-index: 100001;
  596. left: 20rpx;
  597. right: 20rpx;
  598. bottom: 10rpx;
  599. background-color: var(--themeColor);
  600. height: 90rpx;
  601. line-height: 90rpx;
  602. color: #ffffff;
  603. font-size: 34rpx;
  604. font-weight: bold;
  605. text-align: center;
  606. border-radius: 10rpx;
  607. }
  608. .protocol-box image{
  609. max-width: 100%;
  610. }
  611. </style>