payment.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. <template>
  2. <view>
  3. <!-- 弹窗 v-model双向绑定值 mode弹出位置 border-radius弹出层圆角-->
  4. <u-popup v-model="popupShow" mode="center" border-radius="14" width="80%" height="40%" close-icon-pos="top-left"
  5. :closeable="true" close-icon-color="#333333" negative-top="250">
  6. <view style="height: 100%;width: 100%;">
  7. <!-- 标题占20% -->
  8. <view style="height: 20%;width: auto;">
  9. <text style="font-size: 30rpx;font-weight: bold;display: flex;justify-content: center;align-items: flex-end;height: 100%;">超级妈力</text>
  10. </view>
  11. <!-- 金额占30% -->
  12. <view style="height: 30%;width: auto;border-bottom: 1rpx solid #EFEFEF;margin-left: 20rpx;margin-right: 20rpx;">
  13. <text style="font-size: 78rpx;font-weight: 700;display: flex;justify-content: center;align-items: center;height: 100%;">¥{{norderAmount}}</text>
  14. </view>
  15. <!-- 支付方式占20% -->
  16. <view style="height: 20%;width: auto;padding-left: 40rpx;">
  17. <view style="font-size: 30rpx;display: flex;align-items: center;height: 100%;">
  18. <text>余额支付 (余额¥{{info.balance/100}}元)</text>
  19. <!-- <text v-else>微信支付</text> -->
  20. </view>
  21. </view>
  22. <!-- 按钮占25% -->
  23. <!-- <view style="height: 25%;width: auto;">
  24. <view style="display: flex;justify-content: center;align-items: center;height: 100%;">
  25. <u-button type="primary" style="width: 100%;" @click="payment">确认支付</u-button>
  26. </view>
  27. </view> -->
  28. <u-message-input :maxlength="maxnum" :disabled-keyboard="true" :value="password" mode="bottomLine" :breathe="true"
  29. :focus="true" :dot-fill="true"></u-message-input>
  30. </view>
  31. </u-popup>
  32. <uni-list :border="false">
  33. <image src="https://zhengda.oss-cn-chengdu.aliyuncs.com/baoma/static/caixian.png" style="width: 100%; height: 5rpx; background-color: #FFFFFF;"></image>
  34. <uni-list-item :border="false">
  35. <view slot="header" style="color:#666666 ; font-size: 28rpx;">
  36. <text v-if="infodata.product_type == '1' ">{{infodata.doctorname}} 电话咨询</text>
  37. <text v-if="infodata.product_type == '2' ">{{infodata.doctorname}} 图文咨询</text>
  38. <text v-if="infodata.product_type == '3' ">{{infodata.doctorname}} 门诊预约</text>
  39. <text v-if="infodata.product_type == '4' ">疫苗接种预约</text>
  40. <text v-if="infodata.product_type == '5' ">儿保预约</text>
  41. <text v-if="infodata.product_type == '6' ">服务包</text>
  42. </view>
  43. <view slot="footer" style="color:#FF4F61 ;font-weight: 500;">
  44. {{orderAmount}}
  45. </view>
  46. </uni-list-item>
  47. <!-- 线条 -->
  48. <u-line color="#EFEFEF" />
  49. <uni-list-item :border="false" :link="true">
  50. <view slot="header" style="color:#666666 ; font-size: 28rpx;">
  51. 优惠券
  52. </view>
  53. <view slot="footer" style="font-size: 30rpx;">
  54. {{coupon}}
  55. </view>
  56. </uni-list-item>
  57. </uni-list>
  58. <u-gap height="20" bg-color="#F6F6F6"></u-gap>
  59. <uni-list :border="false">
  60. <uni-list-item :border="false">
  61. <view slot="header" style="font-size: 28rpx; font-weight: 500;color: #666666;">支付方式</view>
  62. </uni-list-item>
  63. <!-- 加一个单选 -->
  64. <u-radio-group v-model="value" v-for="(item, index) in paymenMethod">
  65. <uni-list-item :border="false" @click="value=item.name" :clickable="true">
  66. <view slot="header">
  67. <text style="font-size: 28rpx;font-weight: 400;color: #333333;">{{item.name}}</text>
  68. </view>
  69. <view slot="footer">
  70. <u-radio @change="radioChange" :key="index" :name="item.name" :disabled="item.disabled">
  71. </u-radio>
  72. </view>
  73. </uni-list-item>
  74. <u-line color="#EFEFEF" />
  75. </u-radio-group>
  76. </uni-list>
  77. <!-- 按钮 -->
  78. <view class="cu-bar bg-white tabbar border shop" style="position: fixed; bottom: 0; z-index: 99;width: 100%;">
  79. <view class="" style="width:75%;">
  80. <text style="padding-left: 30rpx;font-size: 32rpx;">合计:</text>
  81. <text style="padding-left: 20rpx;font-size: 36;font-weight: 500;color: #FF4F61;">{{orderAmount}}</text>
  82. </view>
  83. <view class="submit text-white" @click="confirmpay" style="background-color: rgb(11,115,186); font-size: 32rpx;">确认支付</view>
  84. </view>
  85. <u-keyboard @change="valChange" @backspace="backspace" ref="uKeyboard" mode="number" v-model="popupShow" :tooltip="false"
  86. :mask="false"></u-keyboard>
  87. <u-no-network></u-no-network>
  88. </view>
  89. </template>
  90. <script>
  91. import store from '@/store'
  92. export default {
  93. onLoad(op) {
  94. this.infodata = JSON.parse(op.data)
  95. this.norderAmount = this.infodata.total_amount
  96. console.log(this.infodata)
  97. },
  98. onShow() {
  99. this.orderAmount = this.norderAmount + "元"
  100. this.getUserInfo()
  101. },
  102. data() {
  103. return {
  104. //医生名称
  105. doctorName: '',
  106. ndoctorName: '渣渣宝',
  107. //订单金额
  108. orderAmount: '',
  109. norderAmount: 19.9,
  110. //优惠券
  111. coupon: '不使用优惠券',
  112. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  113. value: '钱包余额支付',
  114. paymenMethod: [{
  115. name: '钱包余额支付',
  116. disabled: false
  117. }],
  118. //弹出层控制
  119. popupShow: false,
  120. //订单类型
  121. //支付数据类型
  122. infodata: {},
  123. info: {},
  124. show: false,
  125. maxnum: 6,
  126. password: ""
  127. }
  128. },
  129. methods: {
  130. // 选中某个单选框时,由radio时触发
  131. radioChange(e) {
  132. console.log(e);
  133. },
  134. // 选中任一radio时,由radio-group触发
  135. radioGroupChange(e) {
  136. // console.log(e);
  137. },
  138. //充值
  139. recharge(e) {
  140. },
  141. click(e) {
  142. console.log(e)
  143. },
  144. confirmpay() {
  145. if (this.info.balance < this.infodata.total_amount * 100) {
  146. uni.showModal({
  147. title: "错误提示",
  148. content: "余额不足,请先充值",
  149. confirmText: "去充值",
  150. success(res) {
  151. if (res.confirm) {
  152. uni.navigateTo({
  153. url: "../personal/recharge"
  154. })
  155. }
  156. }
  157. })
  158. } else {
  159. this.popupShow = true
  160. this.show = true
  161. }
  162. },
  163. getUserInfo: async function() {
  164. let res = await this.$request.post('/api/v1/user/userInfo')
  165. if (res.status == 0) {
  166. this.info = res.data
  167. console.log(this.info)
  168. }
  169. },
  170. payyuyue: async function() {
  171. let res = await this.$request.post("/api/v1/order/appointPlaceOrder", {
  172. product_type: this.infodata.product_type,
  173. docter_id: this.infodata.docter_id,
  174. patient_id: this.infodata.patient_id,
  175. total_amount: this.infodata.total_amount * 100,
  176. organization_id: this.infodata.organization_id,
  177. schedule_date: this.infodata.schedule_date,
  178. time_period_id: this.infodata.time_period_id,
  179. payment_type: this.infodata.payment_type,
  180. pay_password: this.password
  181. })
  182. if (res.status == 0) {
  183. this.popupShow = false
  184. this.show = false
  185. uni.showToast({
  186. title: "支付成功!",
  187. duration: 1500
  188. })
  189. setTimeout(() => {
  190. uni.redirectTo({
  191. url: "order?type=" + this.infodata.product_type
  192. })
  193. }, 1500)
  194. } else {
  195. if (res.message == '密码错误') {
  196. uni.showModal({
  197. title: "提示",
  198. content: res.message,
  199. confirmText: "重试",
  200. success: (res) => {
  201. if (res.confirm) {
  202. this.password = ""
  203. } else if (res.cancel) {
  204. this.popupShow = false
  205. this.show = false
  206. this.password = ""
  207. }
  208. },
  209. })
  210. } else if (res.message == '未设置支付密码') {
  211. uni.showModal({
  212. title: "提示",
  213. content: res.message,
  214. confirmText: "设置",
  215. success: (res) => {
  216. if (res.confirm) {
  217. this.password = ""
  218. uni.navigateTo({
  219. url: "../index/paypassword"
  220. })
  221. } else if (res.cancel) {
  222. this.popupShow = false
  223. this.show = false
  224. this.password = ""
  225. }
  226. },
  227. })
  228. }
  229. }
  230. },
  231. paypacks: async function() {
  232. let res = await this.$request.post("/api/v1/order/packPlaceOrder", {
  233. patient_id: this.infodata.patient_id,
  234. total_amount: this.infodata.total_amount * 100,
  235. service_pack_id: this.infodata.service_pack_id,
  236. is_security: this.infodata.is_security,
  237. guardian_name: this.infodata.guardian_name,
  238. relationship_type: this.infodata.relationship_type,
  239. payment_type: this.infodata.payment_type,
  240. pay_password: this.password
  241. })
  242. console.log(res)
  243. if (res.status == 0) {
  244. this.popupShow = false
  245. this.show = false
  246. uni.showToast({
  247. title: "支付成功!",
  248. duration: 1500
  249. })
  250. setTimeout(() => {
  251. uni.redirectTo({
  252. url: "order?type=" + this.infodata.product_type
  253. })
  254. }, 1500)
  255. } else {
  256. if (res.message == '密码错误') {
  257. uni.showModal({
  258. title: "提示",
  259. content: res.message,
  260. confirmText: "重试",
  261. success: (res) => {
  262. if (res.confirm) {
  263. this.password = ""
  264. } else if (res.cancel) {
  265. this.popupShow = false
  266. this.show = false
  267. this.password = ""
  268. }
  269. },
  270. })
  271. } else if (res.message == '未设置支付密码') {
  272. uni.showModal({
  273. title: "提示",
  274. content: res.message,
  275. confirmText: "设置",
  276. success: (res) => {
  277. if (res.confirm) {
  278. this.password = ""
  279. uni.navigateTo({
  280. url: "../index/paypassword"
  281. })
  282. } else if (res.cancel) {
  283. this.popupShow = false
  284. this.show = false
  285. this.password = ""
  286. }
  287. },
  288. })
  289. }
  290. }
  291. },
  292. payphone: async function() {
  293. let res = await this.$request.post("/api/v1/order/consultPlaceOrder", {
  294. product_type: this.infodata.product_type,
  295. docter_id: this.infodata.docter_id,
  296. patient_id: this.infodata.patient_id,
  297. total_amount: this.infodata.total_amount * 100,
  298. phone: this.infodata.phone,
  299. phone_minutes: this.infodata.phone_minutes,
  300. payment_type: 2,
  301. pay_password: this.password
  302. })
  303. if (res.status == 0) {
  304. this.popupShow = false
  305. this.show = false
  306. uni.showToast({
  307. title: "支付成功!",
  308. duration: 1500
  309. })
  310. setTimeout(() => {
  311. uni.redirectTo({
  312. url: "order?type=" + this.infodata.product_type
  313. })
  314. }, 1500)
  315. } else {
  316. if (res.message == '密码错误') {
  317. uni.showModal({
  318. title: "提示",
  319. content: res.message,
  320. confirmText: "重试",
  321. success: (res) => {
  322. if (res.confirm) {
  323. this.password = ""
  324. } else if (res.cancel) {
  325. this.popupShow = false
  326. this.show = false
  327. this.password = ""
  328. }
  329. },
  330. })
  331. } else if (res.message == '未设置支付密码') {
  332. uni.showModal({
  333. title: "提示",
  334. content: res.message,
  335. confirmText: "设置",
  336. success: (res) => {
  337. if (res.confirm) {
  338. this.password = ""
  339. uni.navigateTo({
  340. url: "../index/paypassword"
  341. })
  342. } else if (res.cancel) {
  343. this.popupShow = false
  344. this.show = false
  345. this.password = ""
  346. }
  347. },
  348. })
  349. }
  350. }
  351. },
  352. paychat: async function() {
  353. let res = await this.$request.post("/api/v1/order/consultPlaceOrder", {
  354. product_type: this.infodata.product_type,
  355. docter_id: this.infodata.docter_id,
  356. patient_id: this.infodata.patient_id,
  357. total_amount: this.infodata.total_amount * 100,
  358. symptoms: this.infodata.symptoms,
  359. medical_imgs: JSON.stringify(this.infodata.medical_imgs),
  360. payment_type: 2,
  361. pay_password: this.password
  362. })
  363. if (res.status == 0) {
  364. this.popupShow = false
  365. this.show = false
  366. uni.showToast({
  367. title: "支付成功!",
  368. duration: 1500
  369. })
  370. setTimeout(() => {
  371. uni.redirectTo({
  372. url: "order?type=" + this.infodata.product_type
  373. })
  374. }, 1500)
  375. } else {
  376. if (res.message == '密码错误') {
  377. uni.showModal({
  378. title: "提示",
  379. content: res.message,
  380. confirmText: "重试",
  381. success: (res) => {
  382. if (res.confirm) {
  383. this.password = ""
  384. } else if (res.cancel) {
  385. this.popupShow = false
  386. this.show = false
  387. this.password = ""
  388. }
  389. },
  390. })
  391. } else if (res.message == '未设置支付密码') {
  392. uni.showModal({
  393. title: "提示",
  394. content: res.message,
  395. confirmText: "设置",
  396. success: (res) => {
  397. if (res.confirm) {
  398. this.password = ""
  399. uni.navigateTo({
  400. url: "../index/paypassword"
  401. })
  402. } else if (res.cancel) {
  403. this.popupShow = false
  404. this.show = false
  405. this.password = ""
  406. }
  407. },
  408. })
  409. }
  410. }
  411. },
  412. payvaccines: async function() {
  413. let res = await this.$request.post("/api/v1/order/appointPlaceOrder", {
  414. product_type: this.infodata.product_type,
  415. patient_id: this.infodata.patient_id,
  416. total_amount: this.infodata.total_amount * 100,
  417. user_coupon_id: "",
  418. organization_id: this.infodata.organization_id,
  419. schedule_date: this.infodata.schedule_date,
  420. time_period_id: this.infodata.time_period_id,
  421. vaccine_id: this.infodata.vaccine_id,
  422. payment_type: this.infodata.payment_type,
  423. pay_password: this.password
  424. })
  425. if (res.status == 0) {
  426. this.popupShow = false
  427. this.show = false
  428. uni.showToast({
  429. title: "支付成功!",
  430. duration: 1500
  431. })
  432. setTimeout(() => {
  433. uni.redirectTo({
  434. url: "order?type=" + this.infodata.product_type
  435. })
  436. }, 1500)
  437. } else {
  438. if (res.message == '密码错误') {
  439. uni.showModal({
  440. title: "提示",
  441. content: res.message,
  442. confirmText: "重试",
  443. success: (res) => {
  444. if (res.confirm) {
  445. this.password = ""
  446. } else if (res.cancel) {
  447. this.popupShow = false
  448. this.show = false
  449. this.password = ""
  450. }
  451. },
  452. })
  453. } else if (res.message == '未设置支付密码') {
  454. uni.showModal({
  455. title: "提示",
  456. content: res.message,
  457. confirmText: "设置",
  458. success: (res) => {
  459. if (res.confirm) {
  460. this.password = ""
  461. uni.navigateTo({
  462. url: "../index/paypassword"
  463. })
  464. } else if (res.cancel) {
  465. this.popupShow = false
  466. this.show = false
  467. this.password = ""
  468. }
  469. },
  470. })
  471. }
  472. }
  473. },
  474. paychildcare: async function() {
  475. console.log(this.infodata.nurse_ids)
  476. let res = await this.$request.post("/api/v1/order/appointPlaceOrder", {
  477. product_type: this.infodata.product_type,
  478. patient_id: this.infodata.patient_id,
  479. total_amount: this.infodata.total_amount * 100,
  480. user_coupon_id: "",
  481. organization_id: this.infodata.organization_id,
  482. schedule_date: this.infodata.schedule_date,
  483. time_period_id: this.infodata.time_period_id,
  484. nurse_ids: JSON.stringify(this.infodata.nurse_ids),
  485. payment_type: this.infodata.payment_type,
  486. pay_password: this.password
  487. })
  488. console.log(res)
  489. if (res.status == 0) {
  490. this.popupShow = false
  491. this.show = false
  492. uni.showToast({
  493. title: "支付成功!",
  494. duration: 1500
  495. })
  496. setTimeout(() => {
  497. uni.redirectTo({
  498. url: "order?type=" + this.infodata.product_type
  499. })
  500. }, 1500)
  501. } else {
  502. if (res.message == '密码错误') {
  503. uni.showModal({
  504. title: "提示",
  505. content: res.message,
  506. confirmText: "重试",
  507. success: (res) => {
  508. if (res.confirm) {
  509. this.password = ""
  510. } else if (res.cancel) {
  511. this.popupShow = false
  512. this.show = false
  513. this.password = ""
  514. }
  515. },
  516. })
  517. } else if (res.message == '未设置支付密码') {
  518. uni.showModal({
  519. title: "提示",
  520. content: res.message,
  521. confirmText: "设置",
  522. success: (res) => {
  523. if (res.confirm) {
  524. this.password = ""
  525. uni.navigateTo({
  526. url: "../index/paypassword"
  527. })
  528. } else if (res.cancel) {
  529. this.popupShow = false
  530. this.show = false
  531. this.password = ""
  532. }
  533. },
  534. })
  535. }
  536. }
  537. },
  538. //点击确认支付
  539. payment(e) {
  540. if (this.infodata.product_type == 1) {
  541. this.payphone()
  542. } else if (this.infodata.product_type == 2) {
  543. this.paychat()
  544. } else if (this.infodata.product_type == 6) {
  545. this.paypacks()
  546. } else if (this.infodata.product_type == 3) {
  547. this.payyuyue()
  548. } else if (this.infodata.product_type == 4) {
  549. this.payvaccines()
  550. } else if (this.infodata.product_type == 5) {
  551. this.paychildcare()
  552. }
  553. },
  554. // 按键被点击(点击退格键不会触发此事件)
  555. valChange(val) {
  556. // 将每次按键的值拼接到value变量中,注意+=写法
  557. this.password += val;
  558. console.log(this.password)
  559. if (this.password.length == 6) {
  560. this.payment()
  561. }
  562. },
  563. // 退格键被点击
  564. backspace() {
  565. // 删除value的最后一个字符
  566. if (this.password.length) this.password = this.password.substr(0, this.password.length - 1);
  567. console.log(this.password);
  568. }
  569. },
  570. onHide() {
  571. this.popupShow = false
  572. },
  573. }
  574. </script>
  575. <style>
  576. /* 支付文字 */
  577. .paymentText {
  578. height: 60rpx;
  579. width: auto;
  580. background-color: #FFFFFF;
  581. padding: 30rpx 0 0 30rpx;
  582. font-size: 24rpx;
  583. }
  584. </style>