add.vue 15 KB

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