payment.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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">
  6. <view style="padding: 0 10%;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;">
  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;">
  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. </view>
  29. </u-popup>
  30. <uni-list :border="false">
  31. <image src="https://zhengda.oss-cn-chengdu.aliyuncs.com/baoma/static/caixian.png" style="width: 100%; height: 5rpx; background-color: #FFFFFF;"></image>
  32. <uni-list-item :border="false">
  33. <view slot="header" style="color:#666666 ; font-size: 28rpx;">
  34. <text v-if="infodata.product_type == '1' ">{{infodata.doctorname}} 电话咨询</text>
  35. <text v-if="infodata.product_type == '2' ">{{infodata.doctorname}} 图文咨询</text>
  36. <text v-if="infodata.product_type == '3' ">{{infodata.doctorname}} 门诊预约</text>
  37. <text v-if="infodata.product_type == '4' ">疫苗接种预约</text>
  38. <text v-if="infodata.product_type == '5' ">儿保预约</text>
  39. <text v-if="infodata.product_type == '6' ">服务包</text>
  40. </view>
  41. <view slot="footer" style="color:#FF4F61 ;font-weight: 500;">
  42. {{orderAmount}}
  43. </view>
  44. </uni-list-item>
  45. <!-- 线条 -->
  46. <u-line color="#EFEFEF" />
  47. <uni-list-item :border="false" :link="true">
  48. <view slot="header" style="color:#666666 ; font-size: 28rpx;">
  49. 优惠券
  50. </view>
  51. <view slot="footer" style="font-size: 30rpx;">
  52. {{coupon}}
  53. </view>
  54. </uni-list-item>
  55. </uni-list>
  56. <u-gap height="20" bg-color="#F6F6F6"></u-gap>
  57. <uni-list :border="false">
  58. <uni-list-item :border="false">
  59. <view slot="header" style="font-size: 28rpx; font-weight: 500;color: #666666;">支付方式</view>
  60. </uni-list-item>
  61. <!-- 加一个单选 -->
  62. <u-radio-group v-model="value" v-for="(item, index) in paymenMethod">
  63. <uni-list-item :border="false" @click="value=item.name" :clickable="true">
  64. <view slot="header">
  65. <text style="font-size: 28rpx;font-weight: 400;color: #333333;">{{item.name}}</text>
  66. </view>
  67. <view slot="footer">
  68. <u-radio @change="radioChange" :key="index" :name="item.name" :disabled="item.disabled">
  69. </u-radio>
  70. </view>
  71. </uni-list-item>
  72. <u-line color="#EFEFEF" />
  73. </u-radio-group>
  74. </uni-list>
  75. <!-- 按钮 -->
  76. <view class="cu-bar bg-white tabbar border shop" style="position: fixed; bottom: 0; z-index: 99;width: 100%;">
  77. <view class="" style="width:75%;">
  78. <text style="padding-left: 30rpx;font-size: 32rpx;">合计:</text>
  79. <text style="padding-left: 20rpx;font-size: 36;font-weight: 500;color: #FF4F61;">{{orderAmount}}</text>
  80. </view>
  81. <view class="submit text-white" @click="popupShow=true" style="background-color: rgb(11,115,186); font-size: 32rpx;">确认支付</view>
  82. </view>
  83. </view>
  84. </template>
  85. <script>
  86. import store from '@/store'
  87. export default {
  88. onLoad(op) {
  89. this.infodata = JSON.parse(op.data)
  90. this.norderAmount = this.infodata.total_amount
  91. },
  92. mounted() {
  93. this.getUserInfo()
  94. },
  95. data() {
  96. return {
  97. //医生名称
  98. doctorName: '',
  99. ndoctorName: '渣渣宝',
  100. //订单金额
  101. orderAmount: '',
  102. norderAmount: 19.9,
  103. //优惠券
  104. coupon: '不使用优惠券',
  105. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  106. value: '钱包余额支付',
  107. paymenMethod: [{
  108. name: '钱包余额支付',
  109. disabled: false
  110. }],
  111. //弹出层控制
  112. popupShow: false,
  113. //订单类型
  114. //支付数据类型
  115. infodata: {},
  116. info: {}
  117. }
  118. },
  119. methods: {
  120. // 选中某个单选框时,由radio时触发
  121. radioChange(e) {
  122. console.log(e);
  123. },
  124. // 选中任一radio时,由radio-group触发
  125. radioGroupChange(e) {
  126. // console.log(e);
  127. },
  128. //充值
  129. recharge(e) {
  130. },
  131. click(e) {
  132. console.log(e)
  133. },
  134. getUserInfo: async function() {
  135. let res = await this.$request.post('/api/v1/user/userInfo')
  136. if (res.status == 0) {
  137. this.info = res.data
  138. console.log(this.info)
  139. }
  140. },
  141. payphone: async function() {
  142. let res = await this.$request.post("/api/v1/order/consultPlaceOrder", {
  143. product_type: this.infodata.product_type,
  144. docter_id: this.infodata.docter_id,
  145. patient_id: this.infodata.patient_id,
  146. total_amount: this.infodata.total_amount * 100,
  147. phone: this.infodata.phone,
  148. phone_minutes: this.infodata.phone_minutes,
  149. payment_type: 2,
  150. })
  151. console.log(res)
  152. if (res.status == 0) {
  153. this.popupShow = false
  154. uni.showToast({
  155. title: "支付成功!",
  156. duration: 1500
  157. })
  158. setTimeout(() => {
  159. uni.redirectTo({
  160. url: "order?type=" + this.infodata.product_type
  161. })
  162. }, 1500)
  163. }
  164. },
  165. paychat: async function() {
  166. let res = await this.$request.post("/api/v1/order/consultPlaceOrder", {
  167. product_type: this.infodata.product_type,
  168. docter_id: this.infodata.docter_id,
  169. patient_id: this.infodata.patient_id,
  170. total_amount: this.infodata.total_amount * 100,
  171. symptoms: this.infodata.symptoms,
  172. medical_imgs: JSON.stringify(this.infodata.medical_imgs),
  173. payment_type: 2
  174. })
  175. if (res.status == 0) {
  176. this.popupShow = false
  177. uni.showToast({
  178. title: "支付成功!",
  179. duration: 1500
  180. })
  181. setTimeout(() => {
  182. uni.redirectTo({
  183. url: "order?type=" + this.infodata.product_type
  184. })
  185. }, 1500)
  186. }
  187. },
  188. //点击确认支付
  189. payment(e) {
  190. if (this.infodata.product_type == 1) {
  191. this.payphone()
  192. } else if (this.infodata.product_type == 2) {
  193. this.paychat()
  194. }
  195. }
  196. },
  197. onShow() {
  198. this.orderAmount = this.norderAmount + "元"
  199. },
  200. onHide() {
  201. this.popupShow = false
  202. }
  203. }
  204. </script>
  205. <style>
  206. /* 支付文字 */
  207. .paymentText {
  208. height: 60rpx;
  209. width: auto;
  210. background-color: #FFFFFF;
  211. padding: 30rpx 0 0 30rpx;
  212. font-size: 24rpx;
  213. }
  214. </style>