payment.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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="popupShow=true,show=true" 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. </view>
  88. </template>
  89. <script>
  90. import store from '@/store'
  91. export default {
  92. onLoad(op) {
  93. this.infodata = JSON.parse(op.data)
  94. this.norderAmount = this.infodata.total_amount
  95. console.log(this.infodata)
  96. },
  97. mounted() {
  98. this.getUserInfo()
  99. },
  100. data() {
  101. return {
  102. //医生名称
  103. doctorName: '',
  104. ndoctorName: '渣渣宝',
  105. //订单金额
  106. orderAmount: '',
  107. norderAmount: 19.9,
  108. //优惠券
  109. coupon: '不使用优惠券',
  110. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  111. value: '钱包余额支付',
  112. paymenMethod: [{
  113. name: '钱包余额支付',
  114. disabled: false
  115. }],
  116. //弹出层控制
  117. popupShow: false,
  118. //订单类型
  119. //支付数据类型
  120. infodata: {},
  121. info: {},
  122. show: false,
  123. maxnum: 6,
  124. password: ""
  125. }
  126. },
  127. methods: {
  128. // 选中某个单选框时,由radio时触发
  129. radioChange(e) {
  130. console.log(e);
  131. },
  132. // 选中任一radio时,由radio-group触发
  133. radioGroupChange(e) {
  134. // console.log(e);
  135. },
  136. //充值
  137. recharge(e) {
  138. },
  139. click(e) {
  140. console.log(e)
  141. },
  142. getUserInfo: async function() {
  143. let res = await this.$request.post('/api/v1/user/userInfo')
  144. if (res.status == 0) {
  145. this.info = res.data
  146. console.log(this.info)
  147. }
  148. },
  149. payyuyue: async function() {
  150. let res = await this.$request.post("/api/v1/order/appointPlaceOrder", {
  151. product_type: this.infodata.product_type,
  152. docter_id: this.infodata.docter_id,
  153. patient_id: this.infodata.patient_id,
  154. total_amount: this.infodata.total_amount * 100,
  155. organization_id: this.infodata.organization_id,
  156. schedule_date: this.infodata.schedule_date,
  157. time_period_id: this.infodata.time_period_id,
  158. payment_type: this.infodata.payment_type,
  159. pay_password: this.password
  160. })
  161. if (res.status == 0) {
  162. this.popupShow = false
  163. this.show = false
  164. uni.showToast({
  165. title: "支付成功!",
  166. duration: 1500
  167. })
  168. setTimeout(() => {
  169. uni.redirectTo({
  170. url: "order?type=" + this.infodata.product_type
  171. })
  172. }, 1500)
  173. } else {
  174. this.popupShow = false
  175. this.show = false
  176. this.password = ""
  177. uni.showModal({
  178. title: "错误提示",
  179. content: "支付密码错误或未设置支付密码",
  180. confirmText: "设置",
  181. success: (res) => {
  182. if (res.confirm) {
  183. uni.navigateTo({
  184. url: "../index/paypassword"
  185. })
  186. }
  187. },
  188. })
  189. }
  190. },
  191. paypacks: async function() {
  192. let res = await this.$request.post("/api/v1/order/packPlaceOrder", {
  193. patient_id: this.infodata.patient_id,
  194. total_amount: this.infodata.total_amount * 100,
  195. service_pack_id: this.infodata.service_pack_id,
  196. is_security: this.infodata.is_security,
  197. guardian_name: this.infodata.guardian_name,
  198. relationship_type: this.infodata.relationship_type,
  199. payment_type: this.infodata.payment_type,
  200. pay_password: this.password
  201. })
  202. console.log(res)
  203. if (res.status == 0) {
  204. this.popupShow = false
  205. this.show = false
  206. uni.showToast({
  207. title: "支付成功!",
  208. duration: 1500
  209. })
  210. setTimeout(() => {
  211. uni.redirectTo({
  212. url: "order?type=" + this.infodata.product_type
  213. })
  214. }, 1500)
  215. } else {
  216. this.popupShow = false
  217. this.show = false
  218. this.password = ""
  219. uni.showModal({
  220. title: "错误提示",
  221. content: "支付密码错误或未设置支付密码",
  222. confirmText: "设置",
  223. success: (res) => {
  224. if (res.confirm) {
  225. uni.navigateTo({
  226. url: "../index/paypassword"
  227. })
  228. }
  229. },
  230. })
  231. }
  232. },
  233. payphone: async function() {
  234. let res = await this.$request.post("/api/v1/order/consultPlaceOrder", {
  235. product_type: this.infodata.product_type,
  236. docter_id: this.infodata.docter_id,
  237. patient_id: this.infodata.patient_id,
  238. total_amount: this.infodata.total_amount * 100,
  239. phone: this.infodata.phone,
  240. phone_minutes: this.infodata.phone_minutes,
  241. payment_type: 2,
  242. pay_password: this.password
  243. })
  244. if (res.status == 0) {
  245. this.popupShow = false
  246. this.show = false
  247. uni.showToast({
  248. title: "支付成功!",
  249. duration: 1500
  250. })
  251. setTimeout(() => {
  252. uni.redirectTo({
  253. url: "order?type=" + this.infodata.product_type
  254. })
  255. }, 1500)
  256. } else {
  257. this.popupShow = false
  258. this.show = false
  259. this.password = ""
  260. uni.showModal({
  261. title: "错误提示",
  262. content: "支付密码错误或未设置支付密码",
  263. confirmText: "设置",
  264. success: (res) => {
  265. if (res.confirm) {
  266. uni.navigateTo({
  267. url: "../index/paypassword"
  268. })
  269. }
  270. },
  271. })
  272. }
  273. },
  274. paychat: async function() {
  275. let res = await this.$request.post("/api/v1/order/consultPlaceOrder", {
  276. product_type: this.infodata.product_type,
  277. docter_id: this.infodata.docter_id,
  278. patient_id: this.infodata.patient_id,
  279. total_amount: this.infodata.total_amount * 100,
  280. symptoms: this.infodata.symptoms,
  281. medical_imgs: JSON.stringify(this.infodata.medical_imgs),
  282. payment_type: 2,
  283. pay_password: this.password
  284. })
  285. if (res.status == 0) {
  286. this.popupShow = false
  287. this.show = false
  288. uni.showToast({
  289. title: "支付成功!",
  290. duration: 1500
  291. })
  292. setTimeout(() => {
  293. uni.redirectTo({
  294. url: "order?type=" + this.infodata.product_type
  295. })
  296. }, 1500)
  297. } else {
  298. this.popupShow = false
  299. this.show = false
  300. this.password = ""
  301. uni.showModal({
  302. title: "错误提示",
  303. content: "支付密码错误或未设置支付密码",
  304. confirmText: "设置",
  305. success: (res) => {
  306. if (res.confirm) {
  307. uni.navigateTo({
  308. url: "../index/paypassword"
  309. })
  310. }
  311. },
  312. })
  313. }
  314. },
  315. //点击确认支付
  316. payment(e) {
  317. if (this.infodata.product_type == 1) {
  318. this.payphone()
  319. } else if (this.infodata.product_type == 2) {
  320. this.paychat()
  321. } else if (this.infodata.product_type == 6) {
  322. this.paypacks()
  323. } else if (this.infodata.product_type == 3) {
  324. this.payyuyue()
  325. }
  326. },
  327. // 按键被点击(点击退格键不会触发此事件)
  328. valChange(val) {
  329. // 将每次按键的值拼接到value变量中,注意+=写法
  330. this.password += val;
  331. console.log(this.password)
  332. if (this.password.length == 6) {
  333. this.payment()
  334. }
  335. },
  336. // 退格键被点击
  337. backspace() {
  338. // 删除value的最后一个字符
  339. if (this.password.length) this.password = this.password.substr(0, this.password.length - 1);
  340. console.log(this.password);
  341. }
  342. },
  343. onShow() {
  344. this.orderAmount = this.norderAmount + "元"
  345. },
  346. onHide() {
  347. this.popupShow = false
  348. },
  349. }
  350. </script>
  351. <style>
  352. /* 支付文字 */
  353. .paymentText {
  354. height: 60rpx;
  355. width: auto;
  356. background-color: #FFFFFF;
  357. padding: 30rpx 0 0 30rpx;
  358. font-size: 24rpx;
  359. }
  360. </style>