payment.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. }
  174. },
  175. paypacks: async function() {
  176. let res = await this.$request.post("/api/v1/order/packPlaceOrder", {
  177. patient_id: this.infodata.patient_id,
  178. total_amount: this.infodata.total_amount * 100,
  179. service_pack_id: this.infodata.service_pack_id,
  180. is_security: this.infodata.is_security,
  181. guardian_name: this.infodata.guardian_name,
  182. relationship_type: this.infodata.relationship_type,
  183. payment_type: this.infodata.payment_type,
  184. pay_password:this.password
  185. })
  186. console.log(res)
  187. if (res.status == 0) {
  188. this.popupShow = false
  189. this.show = false
  190. uni.showToast({
  191. title: "支付成功!",
  192. duration: 1500
  193. })
  194. setTimeout(() => {
  195. uni.redirectTo({
  196. url: "order?type=" + this.infodata.product_type
  197. })
  198. }, 1500)
  199. }
  200. },
  201. payphone: async function() {
  202. let res = await this.$request.post("/api/v1/order/consultPlaceOrder", {
  203. product_type: this.infodata.product_type,
  204. docter_id: this.infodata.docter_id,
  205. patient_id: this.infodata.patient_id,
  206. total_amount: this.infodata.total_amount * 100,
  207. phone: this.infodata.phone,
  208. phone_minutes: this.infodata.phone_minutes,
  209. payment_type: 2,
  210. pay_password:this.password
  211. })
  212. console.log(res)
  213. if (res.status == 0) {
  214. this.popupShow = false
  215. this.show = false
  216. uni.showToast({
  217. title: "支付成功!",
  218. duration: 1500
  219. })
  220. setTimeout(() => {
  221. uni.redirectTo({
  222. url: "order?type=" + this.infodata.product_type
  223. })
  224. }, 1500)
  225. }
  226. },
  227. paychat: async function() {
  228. let res = await this.$request.post("/api/v1/order/consultPlaceOrder", {
  229. product_type: this.infodata.product_type,
  230. docter_id: this.infodata.docter_id,
  231. patient_id: this.infodata.patient_id,
  232. total_amount: this.infodata.total_amount * 100,
  233. symptoms: this.infodata.symptoms,
  234. medical_imgs: JSON.stringify(this.infodata.medical_imgs),
  235. payment_type: 2,
  236. pay_password:this.password
  237. })
  238. if (res.status == 0) {
  239. this.popupShow = false
  240. this.show = false
  241. uni.showToast({
  242. title: "支付成功!",
  243. duration: 1500
  244. })
  245. setTimeout(() => {
  246. uni.redirectTo({
  247. url: "order?type=" + this.infodata.product_type
  248. })
  249. }, 1500)
  250. }
  251. },
  252. //点击确认支付
  253. payment(e) {
  254. if (this.infodata.product_type == 1) {
  255. this.payphone()
  256. } else if (this.infodata.product_type == 2) {
  257. this.paychat()
  258. } else if (this.infodata.product_type == 6) {
  259. this.paypacks()
  260. } else if(this.infodata.product_type == 3){
  261. this.payyuyue()
  262. }
  263. },
  264. // 按键被点击(点击退格键不会触发此事件)
  265. valChange(val) {
  266. // 将每次按键的值拼接到value变量中,注意+=写法
  267. this.password += val;
  268. console.log(this.password)
  269. if (this.password.length == 6) {
  270. this.payment()
  271. }
  272. },
  273. // 退格键被点击
  274. backspace() {
  275. // 删除value的最后一个字符
  276. if (this.password.length) this.password = this.password.substr(0, this.password.length - 1);
  277. console.log(this.password);
  278. }
  279. },
  280. onShow() {
  281. this.orderAmount = this.norderAmount + "元"
  282. },
  283. onHide() {
  284. this.popupShow = false
  285. },
  286. }
  287. </script>
  288. <style>
  289. /* 支付文字 */
  290. .paymentText {
  291. height: 60rpx;
  292. width: auto;
  293. background-color: #FFFFFF;
  294. padding: 30rpx 0 0 30rpx;
  295. font-size: 24rpx;
  296. }
  297. </style>