appointment.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <view class="content">
  3. <view class="top">
  4. <!-- 病人姓名 -->
  5. <view class="input_box flex_item">
  6. <view class="input_left">病人姓名:</view>
  7. <input type="text" value="" placeholder="请输入病人真实姓名" class="input_right" />
  8. </view>
  9. <!-- 联系电话 -->
  10. <view class="input_box flex_item">
  11. <view class="input_left">联系电话:</view>
  12. <input type="number" value="" placeholder="请输入联系电话" class="input_right" />
  13. </view>
  14. <!-- 预约时间 -->
  15. <view class="input_box flex_item">
  16. <view class="input_left">主营项目:</view>
  17. <input type="text" value="" placeholder="请输入详细预约时间" class="input_right" />
  18. </view>
  19. <!-- 详细地址 -->
  20. <view class="input_box flex_item">
  21. <view class="input_left">详细地址:</view>
  22. <input type="text" value="" placeholder="请输入预约的详细地址" class="input_right" />
  23. </view>
  24. </view>
  25. <!-- 提交按钮 -->
  26. <view class="sub-bottom" @click="payopen">提交预约</view>
  27. <!-- 支付弹窗 -->
  28. <!-- 支付弹出窗 -->
  29. <uni-popup ref="popup" type="bottom">
  30. <view class="payment">
  31. <view class="first flex " @click="payclose()">
  32. <text class="word">选择支付方式</text>
  33. <image src="../../static/img/img25.png"></image>
  34. </view>
  35. <view class="pay-type-list">
  36. <view class="type-item b-b" @click="changePayType(1)">
  37. <view class="img"><image class="yue" src="../../static/img/img26.png"></image></view>
  38. <view class="con"><text class="tit">微信支付</text></view>
  39. <label class="radio"><radio value="" color="#FC4141" :checked="payType == 1"></radio></label>
  40. </view>
  41. <view class="type-item flex_item" @click="changePayType(2)">
  42. <view class="img"><image class="yue" src="../../static/img/img017.png"></image></view>
  43. <view class="con"><text class="tit">余额支付</text></view>
  44. <label class="radio"><radio value="" color="#FC4141" :checked="payType == 2"></radio></label>
  45. </view>
  46. </view>
  47. <view class="one"></view>
  48. <view class="Third flex">
  49. <view class="two1">
  50. <text class="two1-1 ">合计:</text>
  51. <text class="two1-2">¥</text>
  52. <text class="two1-2 size">200.0</text>
  53. </view>
  54. <view class="two2" @click.stop="confirm"><text>立即支付</text></view>
  55. </view>
  56. </view>
  57. </uni-popup>
  58. </view>
  59. </template>
  60. <script>
  61. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  62. export default {
  63. components: {
  64. uniPopup
  65. },
  66. data() {
  67. return {
  68. payType: '1', //支付类型
  69. payName: 'weixin',
  70. };
  71. },
  72. methods: {
  73. //选择支付方式
  74. changePayType(type) {
  75. this.payType = type;
  76. if (this.payType == 1) {
  77. this.payName = 'weixin';
  78. }
  79. if (this.payType == 2) {
  80. this.payName = 'yue';
  81. }
  82. console.log(this.payName,"payName")
  83. },
  84. //确认支付
  85. confirm: async function() {
  86. // let obj = this;
  87. // // 判断是否余额不足
  88. // if (obj.payName == 'yue' && +obj.now_money < obj.money) {
  89. // uni.showModal({
  90. // title: '提示',
  91. // content: '账户余额不足!',
  92. // showCancel: false,
  93. // success: res => {},
  94. // fail: () => {},
  95. // complete: () => {}
  96. // });
  97. // return;
  98. // }
  99. // // #ifdef H5
  100. // // 获取当前是否为微信浏览器
  101. // obj.froms = uni.getStorageSync('weichatBrowser') || '';
  102. // // #endif
  103. // firstCreateOrder();
  104. // window.location.href = "http://192.168.0.102/wap/service/service_ing/to_uid/1"
  105. uni.navigateTo({
  106. url: '/pages/order/success'
  107. });
  108. },
  109. // 初次订单创建
  110. firstCreateOrder() {
  111. let obj = this;
  112. // 获取下单页面数据
  113. let data = {
  114. payType: obj.payName, //支付类型 weixin-微信 yue-余额
  115. // #ifdef H5
  116. from: obj.froms ? 'weixin' : 'H5', //来源
  117. // #endif
  118. // #ifdef MP-WEIXIN
  119. from: 'routine', //来源
  120. // #endif
  121. // #ifdef APP-PLUS
  122. from: 'app', //来源
  123. // #endif
  124. };
  125. // 生成订单
  126. createOrderkey(data)
  127. .then(({ data, status, msg }) => {
  128. // 判断是否为余额支付
  129. if (obj.payName == 'yue') {
  130. if (status == 200&&data.status == 'SUCCESS') {
  131. // obj.paySuccessTo();
  132. } else {
  133. obj.$api.msg(msg);
  134. }
  135. } else {
  136. // 立即支付
  137. obj.orderMoneyPay();
  138. }
  139. })
  140. .catch(e => {
  141. console.log(e);
  142. });
  143. },
  144. // 支付金额
  145. orderMoneyPay() {
  146. let obj = this;
  147. orderPay({
  148. uni: obj.orderId,
  149. // #ifdef H5
  150. from: obj.froms ? 'weixin' : 'H5', //来源
  151. // #endif
  152. // #ifdef MP-WEIXIN
  153. from: 'routine', //来源
  154. // #endif
  155. // #ifdef APP-PLUS
  156. from: 'app', //来源
  157. // #endif
  158. paytype: obj.payName //支付类型 weixin-微信 yue-余额
  159. }).then(e => {
  160. // 判断是否为余额支付
  161. if (obj.payName == 'yue') {
  162. if (e.status == 200) {
  163. // obj.paySuccessTo();
  164. } else {
  165. obj.$api.msg(msg);
  166. }
  167. }
  168. // #ifdef H5
  169. if (obj.payName == 'weixin') {
  170. let da = e.data.result.jsConfig;
  171. obj.weichatObj.chooseWXPay({
  172. timestamp: da.timestamp,
  173. nonceStr: da.nonceStr,
  174. package: da.package,
  175. signType: da.signType,
  176. paySign: da.paySign,
  177. success: function(res) {
  178. // obj.paySuccessTo();
  179. },
  180. fail: function (res) {
  181. console.log(res,"失败")
  182. console.log(res.errMsg)
  183. }
  184. });
  185. }
  186. // #endif
  187. // #ifdef MP-WEIXIN
  188. if (obj.payName == 'weixin') {
  189. let da = e.data.result.jsConfig;
  190. wx.requestPayment({
  191. timeStamp: da.timestamp,
  192. nonceStr: da.nonceStr,
  193. package: da.package,
  194. signType: da.signType,
  195. paySign: da.paySign,
  196. success: function(res) {
  197. // obj.paySuccessTo();
  198. }
  199. });
  200. }
  201. // #endif
  202. })
  203. .catch(e => {
  204. // 支付完成
  205. console.log(e.message)
  206. if(e.message == "该订单已支付!"){
  207. // obj.paySuccessTo();
  208. }
  209. });
  210. },
  211. //支付弹窗
  212. payopen() {
  213. this.$refs.popup.onTap();
  214. this.$refs.popup.open();
  215. },
  216. //支付支付弹窗
  217. payclose() {
  218. this.$refs.popup.close();
  219. },
  220. }
  221. };
  222. </script>
  223. <style lang="scss">
  224. .content {
  225. padding-top: 25rpx;
  226. }
  227. .top {
  228. width: 90%;
  229. margin: 0rpx auto;
  230. background: #FFFFFF;
  231. border-radius: 10rpx;
  232. }
  233. //输入框样式
  234. .input_box {
  235. font-size: 28rpx;
  236. border-bottom: 1rpx solid rgba(240, 240, 240, 1);
  237. padding: 37rpx 28rpx;
  238. .input_left {
  239. font-weight: 500;
  240. color: rgba(51, 51, 51, 1);
  241. }
  242. .input_right {
  243. font-size: 28rpx;
  244. }
  245. }
  246. .sub-bottom {
  247. width: 560rpx;
  248. height: 80rpx;
  249. background: $background-color;
  250. box-shadow: 0px 0px 13rpx 3rpx rgba(209, 212, 217, 0.31);
  251. border-radius: 40rpx;
  252. font-size: $font-lg - 2rpx;
  253. font-weight: 500;
  254. color: rgba(255, 255, 255, 1);
  255. line-height: 80rpx;
  256. text-align: center;
  257. margin: 123rpx auto 0;
  258. }
  259. .payment {
  260. background-color: #ffffff;
  261. border-radius: 15rpx 15rpx 0rpx 0rpx;
  262. .first {
  263. border-bottom: 2rpx solid $border-color-light;
  264. padding: 38rpx 25rpx;
  265. .word {
  266. font-size: $uni-font-size-base;
  267. font-weight: bold;
  268. color: $font-color-dark;
  269. }
  270. image {
  271. width: 25rpx;
  272. height: 25rpx;
  273. }
  274. }
  275. .pay-type-list {
  276. margin-top: 20upx;
  277. background-color: #fff;
  278. padding-left: 40upx;
  279. .type-item {
  280. height: 120upx;
  281. padding: 20upx 0;
  282. display: flex;
  283. justify-content: space-between;
  284. align-items: center;
  285. padding-right: 60upx;
  286. font-size: 30upx;
  287. position: relative;
  288. }
  289. .icon {
  290. width: 100upx;
  291. font-size: 52upx;
  292. }
  293. .img {
  294. color: #fe8e2e;
  295. width: 50rpx;
  296. height: 50rpx;
  297. image {
  298. width: 100%;
  299. height: 100%;
  300. }
  301. }
  302. .tit {
  303. font-size: $font-lg;
  304. color: $font-color-dark;
  305. margin-bottom: 4upx;
  306. }
  307. .con {
  308. flex: 1;
  309. display: flex;
  310. flex-direction: column;
  311. padding-left: 25rpx;
  312. font-size: $font-sm;
  313. color: $font-color-light;
  314. }
  315. }
  316. .one {
  317. height: 20rpx;
  318. background-color: #f6f6f6;
  319. }
  320. .Third {
  321. .two1 {
  322. width: 55%;
  323. background-color: #ffffff;
  324. padding-left: 25rpx;
  325. .two1-1 {
  326. font-size: $uni-font-size-base;
  327. font-weight: 400;
  328. color: $font-color-dark;
  329. }
  330. .two1-2 {
  331. font-size: $uni-font-size-sm;
  332. font-weight: bold;
  333. color: $color-red1;
  334. }
  335. .size {
  336. font-size: $uni-font-size-lg + 4rpx;
  337. }
  338. }
  339. .two2 {
  340. width: 45%;
  341. background: $color-red1;
  342. color: #ffffff;
  343. font-size: $uni-font-size-lg;
  344. font-weight: 550;
  345. text-align: center;
  346. padding: 30rpx 0rpx;
  347. }
  348. }
  349. }
  350. .flex {
  351. display: flex;
  352. align-items: center;
  353. }
  354. .flex1 {
  355. display: flex;
  356. justify-content: space-between;
  357. align-items: center;
  358. }
  359. </style>