payOrder.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <view class="content">
  3. <view class="inner">
  4. <!-- 时间、价格 -->
  5. <view class="time-price">
  6. <text class="time">请在{{payLimitTime}}前完成支付</text>
  7. <view class="price-box">
  8. <text class="unit">¥</text>
  9. <text class="num">{{order.payPrice}}</text>
  10. </view>
  11. </view>
  12. <!-- 支付方式 -->
  13. <view class="pay-type">
  14. <view class="title">支付方式</view>
  15. <view class="item">
  16. <view class="left">
  17. <image src="../../static/images/wecha_pay.png" mode=""></image>
  18. <text class="text">微信支付</text>
  19. </view>
  20. <label>
  21. <checkbox disabled value="" :checked="wxPay" />
  22. </label>
  23. </view>
  24. </view>
  25. <!-- 订单详情查看 -->
  26. <view class="order-info">
  27. <view class="title">订单信息</view>
  28. <view class="item">
  29. <text class="label">订单编号</text>
  30. <view class="sn-box">
  31. <text class="text">{{order.orderCode}}</text>
  32. <view class="copy-btn" @click="copyOrderSn(order.orderCode)">复制</view>
  33. </view>
  34. </view>
  35. <view class="item">
  36. <text class="label">下单时间</text>
  37. <text class="text">{{order.createTime}}</text>
  38. </view>
  39. <view class="item">
  40. <text class="label">支付方式</text>
  41. <text class="text">微信支付</text>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="btn-box">
  46. <view class="btn" @click="payOrder()">去支付</view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import {pay,getStoreOrderById} from '@/api/storeOrder'
  52. export default {
  53. data() {
  54. return {
  55. payLimitTime:null,
  56. order:null,
  57. // 默认选中微信支付
  58. wxPay: true,
  59. }
  60. },
  61. onLoad: function(options) {
  62. if (options.hasOwnProperty('q') && options.q) {
  63. // 通过下面这步解码,可以拿到url的值
  64. const url = decodeURIComponent(options.q)
  65. this.url=url;
  66. // // 对url中携带的参数提取处理
  67. const obj = this.utils.urlToObj(url)
  68. this.orderId=obj.orderId;
  69. }
  70. else if(options!=null&&options.orderId!=null){
  71. this.orderId=options.orderId;
  72. }
  73. },
  74. onShow() {
  75. this.getStoreOrderById();
  76. },
  77. methods: {
  78. copyOrderSn(text) {
  79. // 复制方法
  80. uni.setClipboardData({
  81. data:text,
  82. success:()=>{
  83. uni.showToast({
  84. title:'内容已成功复制到剪切板',
  85. icon:'none'
  86. })
  87. }
  88. });
  89. },
  90. getStoreOrderById(){
  91. var data = {orderId:this.orderId};
  92. var that=this;
  93. uni.showLoading();
  94. getStoreOrderById(data).then(
  95. res => {
  96. if(res.code==200){
  97. console.log(res);
  98. uni.hideLoading();
  99. that.order=res.order;
  100. that.payLimitTime=res.payLimitTime;
  101. }else{
  102. uni.showToast({
  103. icon:'none',
  104. title: res.msg,
  105. });
  106. }
  107. },
  108. rej => {}
  109. );
  110. },
  111. payOrder(){
  112. var data = {orderId:this.order.id};
  113. var that=this;
  114. uni.showLoading();
  115. pay(data).then(
  116. res => {
  117. if(res.code==200){
  118. console.log(res);
  119. uni.requestPayment({
  120. provider: 'wxpay',
  121. timeStamp: res.result.timeStamp,
  122. nonceStr: res.result.nonceStr,
  123. package: res.result.packageValue,
  124. signType: res.result.signType,
  125. paySign: res.result.paySign,
  126. success: function(res) {
  127. uni.hideLoading();
  128. if(that.order.isPrescribe){
  129. //如果是处方订单开处方
  130. uni.redirectTo({
  131. url:"prescribe?orderId="+that.order.id
  132. })
  133. }
  134. else{
  135. //如果是普通订单
  136. uni.redirectTo({
  137. url:"success?order="+JSON.stringify(that.order)
  138. })
  139. }
  140. },
  141. fail: function(err) {
  142. console.log('fail:' + JSON.stringify(err));
  143. uni.hideLoading();
  144. }
  145. });
  146. }else{
  147. uni.showToast({
  148. icon:'none',
  149. title: res.msg,
  150. });
  151. }
  152. },
  153. rej => {}
  154. );
  155. }
  156. }
  157. }
  158. </script>
  159. <style lang="scss">
  160. page{
  161. height: 100%;
  162. background-color: #F2F5F9;
  163. }
  164. .content{
  165. height: 100%;
  166. display: flex;
  167. flex-direction: column;
  168. justify-content: space-between;
  169. .inner{
  170. padding: 20upx;
  171. .time-price{
  172. box-sizing: border-box;
  173. height: 200upx;
  174. background: #FFFFFF;
  175. border-radius: 16upx;
  176. display: flex;
  177. flex-direction: column;
  178. align-items: center;
  179. padding-top: 50upx;
  180. .time{
  181. font-size: 26upx;
  182. font-family: PingFang SC;
  183. font-weight: 500;
  184. color: #999999;
  185. line-height: 1;
  186. text-align: center;
  187. }
  188. .price-box{
  189. display: flex;
  190. align-items: flex-end;
  191. margin-top: 28upx;
  192. .unit{
  193. font-size: 32upx;
  194. font-family: PingFang SC;
  195. font-weight: bold;
  196. color: #FF6633;
  197. line-height: 1.3;
  198. margin-right: 10upx;
  199. }
  200. .num{
  201. font-size: 56upx;
  202. font-family: PingFang SC;
  203. font-weight: bold;
  204. color: #FF6633;
  205. line-height: 1;
  206. }
  207. }
  208. }
  209. .pay-type{
  210. box-sizing: border-box;
  211. height: 192upx;
  212. background: #FFFFFF;
  213. border-radius: 16upx;
  214. margin-top: 20upx;
  215. padding: 40upx 30upx;
  216. display: flex;
  217. flex-direction: column;
  218. justify-content: space-between;
  219. .title{
  220. font-size: 28upx;
  221. font-family: PingFang SC;
  222. font-weight: 500;
  223. color: #999999;
  224. line-height: 1;
  225. }
  226. .item{
  227. display: flex;
  228. align-items: center;
  229. justify-content: space-between;
  230. .left{
  231. display: flex;
  232. align-items: center;
  233. image{
  234. width: 44upx;
  235. height: 44upx;
  236. margin-right: 20upx;
  237. }
  238. .text{
  239. font-size: 30upx;
  240. font-family: PingFang SC;
  241. font-weight: bold;
  242. color: #222222;
  243. line-height: 1;
  244. }
  245. }
  246. }
  247. }
  248. .order-info{
  249. margin-top: 20upx;
  250. background: #FFFFFF;
  251. border-radius: 16upx;
  252. padding: 40upx 30upx;
  253. .title{
  254. font-size: 30upx;
  255. font-family: PingFang SC;
  256. font-weight: bold;
  257. color: #222222;
  258. line-height: 1;
  259. }
  260. .item{
  261. margin-top: 40upx;
  262. display: flex;
  263. align-items: center;
  264. justify-content: space-between;
  265. .label{
  266. font-size: 26upx;
  267. font-family: PingFang SC;
  268. font-weight: 500;
  269. color: #666666;
  270. line-height: 1;
  271. }
  272. .text{
  273. font-size: 26upx;
  274. font-family: PingFang SC;
  275. font-weight: 500;
  276. color: #222222;
  277. line-height: 32upx;
  278. }
  279. .cont-text{
  280. font-size: 26upx;
  281. font-family: PingFang SC;
  282. font-weight: 500;
  283. color: #666666;
  284. .bold{
  285. color: #111111;
  286. }
  287. }
  288. .sn-box{
  289. display: flex;
  290. align-items: center;
  291. .copy-btn{
  292. width: 58upx;
  293. height: 32upx;
  294. line-height: 32upx;
  295. text-align: center;
  296. font-size: 22upx;
  297. font-family: PingFang SC;
  298. font-weight: 500;
  299. color: #222222;
  300. background: #F5F5F5;
  301. border-radius: 4upx;
  302. margin-left: 24upx;
  303. }
  304. }
  305. }
  306. .line{
  307. width: 100%;
  308. height: 1px;
  309. background: #F0F0F0;
  310. margin-top: 30upx;
  311. }
  312. }
  313. }
  314. .btn-box{
  315. height: 121upx;
  316. background: #FFFFFF;
  317. display: flex;
  318. align-items: center;
  319. justify-content: center;
  320. .btn{
  321. width: 91.73%;
  322. height: 88upx;
  323. line-height: 88upx;
  324. font-size: 30upx;
  325. font-family: PingFang SC;
  326. font-weight: bold;
  327. color: #FFFFFF;
  328. text-align: center;
  329. background: #018C39;
  330. border-radius: 44upx;
  331. }
  332. }
  333. }
  334. </style>