payment.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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.getUserInfo()
  100. },
  101. data() {
  102. return {
  103. //医生名称
  104. doctorName: '',
  105. ndoctorName: '渣渣宝',
  106. //订单金额
  107. orderAmount: '',
  108. norderAmount: 19.9,
  109. //优惠券
  110. coupon: '不使用优惠券',
  111. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  112. value: '钱包余额支付',
  113. paymenMethod: [{
  114. name: '钱包余额支付',
  115. disabled: false
  116. }],
  117. //弹出层控制
  118. popupShow: false,
  119. //订单类型
  120. //支付数据类型
  121. infodata: {},
  122. info: {},
  123. show: false,
  124. maxnum: 6,
  125. password: ""
  126. }
  127. },
  128. methods: {
  129. // 选中某个单选框时,由radio时触发
  130. radioChange(e) {
  131. console.log(e);
  132. },
  133. // 选中任一radio时,由radio-group触发
  134. radioGroupChange(e) {
  135. // console.log(e);
  136. },
  137. //充值
  138. recharge(e) {
  139. },
  140. click(e) {
  141. console.log(e)
  142. },
  143. confirmpay() {
  144. if (this.info.balance < this.infodata.total_amount * 100) {
  145. uni.showModal({
  146. title: "错误提示",
  147. content: "余额不足,请先充值",
  148. confirmText: "去充值",
  149. success(res) {
  150. if (res.confirm) {
  151. uni.navigateTo({
  152. url: "../personal/recharge"
  153. })
  154. }
  155. }
  156. })
  157. } else {
  158. popupShow = true
  159. show = true
  160. }
  161. },
  162. getUserInfo: async function() {
  163. let res = await this.$request.post('/api/v1/user/userInfo')
  164. if (res.status == 0) {
  165. this.info = res.data
  166. console.log(this.info)
  167. }
  168. },
  169. payyuyue: async function() {
  170. let res = await this.$request.post("/api/v1/order/appointPlaceOrder", {
  171. product_type: this.infodata.product_type,
  172. docter_id: this.infodata.docter_id,
  173. patient_id: this.infodata.patient_id,
  174. total_amount: this.infodata.total_amount * 100,
  175. organization_id: this.infodata.organization_id,
  176. schedule_date: this.infodata.schedule_date,
  177. time_period_id: this.infodata.time_period_id,
  178. payment_type: this.infodata.payment_type,
  179. pay_password: this.password
  180. })
  181. if (res.status == 0) {
  182. this.popupShow = false
  183. this.show = false
  184. uni.showToast({
  185. title: "支付成功!",
  186. duration: 1500
  187. })
  188. setTimeout(() => {
  189. uni.redirectTo({
  190. url: "order?type=" + this.infodata.product_type
  191. })
  192. }, 1500)
  193. } else {
  194. this.popupShow = false
  195. this.show = false
  196. this.password = ""
  197. uni.showModal({
  198. title: "错误提示",
  199. content: "支付密码错误或未设置支付密码",
  200. confirmText: "设置",
  201. success: (res) => {
  202. if (res.confirm) {
  203. uni.navigateTo({
  204. url: "../index/paypassword"
  205. })
  206. }
  207. },
  208. })
  209. }
  210. },
  211. paypacks: async function() {
  212. let res = await this.$request.post("/api/v1/order/packPlaceOrder", {
  213. patient_id: this.infodata.patient_id,
  214. total_amount: this.infodata.total_amount * 100,
  215. service_pack_id: this.infodata.service_pack_id,
  216. is_security: this.infodata.is_security,
  217. guardian_name: this.infodata.guardian_name,
  218. relationship_type: this.infodata.relationship_type,
  219. payment_type: this.infodata.payment_type,
  220. pay_password: this.password
  221. })
  222. console.log(res)
  223. if (res.status == 0) {
  224. this.popupShow = false
  225. this.show = false
  226. uni.showToast({
  227. title: "支付成功!",
  228. duration: 1500
  229. })
  230. setTimeout(() => {
  231. uni.redirectTo({
  232. url: "order?type=" + this.infodata.product_type
  233. })
  234. }, 1500)
  235. } else {
  236. this.popupShow = false
  237. this.show = false
  238. this.password = ""
  239. uni.showModal({
  240. title: "错误提示",
  241. content: "支付密码错误或未设置支付密码",
  242. confirmText: "设置",
  243. success: (res) => {
  244. if (res.confirm) {
  245. uni.navigateTo({
  246. url: "../index/paypassword"
  247. })
  248. }
  249. },
  250. })
  251. }
  252. },
  253. payphone: async function() {
  254. let res = await this.$request.post("/api/v1/order/consultPlaceOrder", {
  255. product_type: this.infodata.product_type,
  256. docter_id: this.infodata.docter_id,
  257. patient_id: this.infodata.patient_id,
  258. total_amount: this.infodata.total_amount * 100,
  259. phone: this.infodata.phone,
  260. phone_minutes: this.infodata.phone_minutes,
  261. payment_type: 2,
  262. pay_password: this.password
  263. })
  264. if (res.status == 0) {
  265. this.popupShow = false
  266. this.show = false
  267. uni.showToast({
  268. title: "支付成功!",
  269. duration: 1500
  270. })
  271. setTimeout(() => {
  272. uni.redirectTo({
  273. url: "order?type=" + this.infodata.product_type
  274. })
  275. }, 1500)
  276. } else {
  277. this.popupShow = false
  278. this.show = false
  279. this.password = ""
  280. uni.showModal({
  281. title: "错误提示",
  282. content: "支付密码错误或未设置支付密码",
  283. confirmText: "设置",
  284. success: (res) => {
  285. if (res.confirm) {
  286. uni.navigateTo({
  287. url: "../index/paypassword"
  288. })
  289. }
  290. },
  291. })
  292. }
  293. },
  294. paychat: async function() {
  295. let res = await this.$request.post("/api/v1/order/consultPlaceOrder", {
  296. product_type: this.infodata.product_type,
  297. docter_id: this.infodata.docter_id,
  298. patient_id: this.infodata.patient_id,
  299. total_amount: this.infodata.total_amount * 100,
  300. symptoms: this.infodata.symptoms,
  301. medical_imgs: JSON.stringify(this.infodata.medical_imgs),
  302. payment_type: 2,
  303. pay_password: this.password
  304. })
  305. if (res.status == 0) {
  306. this.popupShow = false
  307. this.show = false
  308. uni.showToast({
  309. title: "支付成功!",
  310. duration: 1500
  311. })
  312. setTimeout(() => {
  313. uni.redirectTo({
  314. url: "order?type=" + this.infodata.product_type
  315. })
  316. }, 1500)
  317. } else {
  318. this.popupShow = false
  319. this.show = false
  320. this.password = ""
  321. uni.showModal({
  322. title: "错误提示",
  323. content: "支付密码错误或未设置支付密码",
  324. confirmText: "设置",
  325. success: (res) => {
  326. if (res.confirm) {
  327. uni.navigateTo({
  328. url: "../index/paypassword"
  329. })
  330. }
  331. },
  332. })
  333. }
  334. },
  335. payvaccines: async function() {
  336. let res = await this.$request.post("/api/v1/order/appointPlaceOrder", {
  337. product_type: this.infodata.product_type,
  338. patient_id: this.infodata.patient_id,
  339. total_amount: this.infodata.total_amount * 100,
  340. user_coupon_id: "",
  341. organization_id: this.infodata.organization_id,
  342. schedule_date: this.infodata.schedule_date,
  343. time_period_id: this.infodata.time_period_id,
  344. vaccine_id: this.infodata.vaccine_id,
  345. payment_type: this.infodata.payment_type,
  346. pay_password: this.password
  347. })
  348. if (res.status == 0) {
  349. this.popupShow = false
  350. this.show = false
  351. uni.showToast({
  352. title: "支付成功!",
  353. duration: 1500
  354. })
  355. setTimeout(() => {
  356. uni.redirectTo({
  357. url: "order?type=" + this.infodata.product_type
  358. })
  359. }, 1500)
  360. } else {
  361. this.popupShow = false
  362. this.show = false
  363. this.password = ""
  364. uni.showModal({
  365. title: "错误提示",
  366. content: "支付密码错误或未设置支付密码",
  367. confirmText: "设置",
  368. success: (res) => {
  369. if (res.confirm) {
  370. uni.navigateTo({
  371. url: "../index/paypassword"
  372. })
  373. }
  374. },
  375. })
  376. }
  377. },
  378. paychildcare: async function() {
  379. console.log(this.infodata.nurse_ids)
  380. let res = await this.$request.post("/api/v1/order/appointPlaceOrder", {
  381. product_type: this.infodata.product_type,
  382. patient_id: this.infodata.patient_id,
  383. total_amount: this.infodata.total_amount * 100,
  384. user_coupon_id: "",
  385. organization_id: this.infodata.organization_id,
  386. schedule_date: this.infodata.schedule_date,
  387. time_period_id: this.infodata.time_period_id,
  388. nurse_ids: JSON.stringify(this.infodata.nurse_ids),
  389. payment_type: this.infodata.payment_type,
  390. pay_password: this.password
  391. })
  392. console.log(res)
  393. if (res.status == 0) {
  394. this.popupShow = false
  395. this.show = false
  396. uni.showToast({
  397. title: "支付成功!",
  398. duration: 1500
  399. })
  400. setTimeout(() => {
  401. uni.redirectTo({
  402. url: "order?type=" + this.infodata.product_type
  403. })
  404. }, 1500)
  405. } else {
  406. this.popupShow = false
  407. this.show = false
  408. this.password = ""
  409. uni.showModal({
  410. title: "错误提示",
  411. content: "支付密码错误或未设置支付密码",
  412. confirmText: "设置",
  413. success: (res) => {
  414. if (res.confirm) {
  415. uni.navigateTo({
  416. url: "../index/paypassword"
  417. })
  418. }
  419. },
  420. })
  421. }
  422. },
  423. //点击确认支付
  424. payment(e) {
  425. if (this.infodata.product_type == 1) {
  426. this.payphone()
  427. } else if (this.infodata.product_type == 2) {
  428. this.paychat()
  429. } else if (this.infodata.product_type == 6) {
  430. this.paypacks()
  431. } else if (this.infodata.product_type == 3) {
  432. this.payyuyue()
  433. } else if (this.infodata.product_type == 4) {
  434. this.payvaccines()
  435. } else if (this.infodata.product_type == 5) {
  436. this.paychildcare()
  437. }
  438. },
  439. // 按键被点击(点击退格键不会触发此事件)
  440. valChange(val) {
  441. // 将每次按键的值拼接到value变量中,注意+=写法
  442. this.password += val;
  443. console.log(this.password)
  444. if (this.password.length == 6) {
  445. this.payment()
  446. }
  447. },
  448. // 退格键被点击
  449. backspace() {
  450. // 删除value的最后一个字符
  451. if (this.password.length) this.password = this.password.substr(0, this.password.length - 1);
  452. console.log(this.password);
  453. }
  454. },
  455. onShow() {
  456. this.orderAmount = this.norderAmount + "元"
  457. },
  458. onHide() {
  459. this.popupShow = false
  460. },
  461. }
  462. </script>
  463. <style>
  464. /* 支付文字 */
  465. .paymentText {
  466. height: 60rpx;
  467. width: auto;
  468. background-color: #FFFFFF;
  469. padding: 30rpx 0 0 30rpx;
  470. font-size: 24rpx;
  471. }
  472. </style>