payOrder.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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="https://jnlzjk-1323137866.cos.ap-chongqing.myqcloud.com/shop/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,appId: wx.getAccountInfoSync().miniProgram.appId};
  113. console.log('当前小程序信息id',data)
  114. var that=this;
  115. uni.showLoading();
  116. pay(data).then(
  117. res => {
  118. if(res.code==200){
  119. console.log(res);
  120. uni.requestPayment({
  121. provider: 'wxpay',
  122. timeStamp: res.result.timeStamp,
  123. nonceStr: res.result.nonceStr,
  124. package: res.result.packageValue,
  125. signType: res.result.signType,
  126. paySign: res.result.paySign,
  127. success: function(res) {
  128. uni.hideLoading();
  129. if(that.order.isPrescribe){
  130. //如果是处方订单开处方
  131. uni.redirectTo({
  132. url:"prescribe?orderId="+that.order.id
  133. })
  134. }
  135. else{
  136. //如果是普通订单
  137. uni.redirectTo({
  138. url:"success?order="+JSON.stringify(that.order)
  139. })
  140. }
  141. },
  142. fail: function(err) {
  143. console.log('fail:' + JSON.stringify(err));
  144. uni.hideLoading();
  145. }
  146. });
  147. }else{
  148. uni.showToast({
  149. icon:'none',
  150. title: res.msg,
  151. });
  152. }
  153. },
  154. rej => {}
  155. );
  156. }
  157. }
  158. }
  159. </script>
  160. <style lang="scss">
  161. page{
  162. height: 100%;
  163. background-color: #F2F5F9;
  164. }
  165. .content{
  166. height: 100%;
  167. display: flex;
  168. flex-direction: column;
  169. justify-content: space-between;
  170. .inner{
  171. padding: 20upx;
  172. .time-price{
  173. box-sizing: border-box;
  174. height: 200upx;
  175. background: #FFFFFF;
  176. border-radius: 16upx;
  177. display: flex;
  178. flex-direction: column;
  179. align-items: center;
  180. padding-top: 50upx;
  181. .time{
  182. font-size: 26upx;
  183. font-family: PingFang SC;
  184. font-weight: 500;
  185. color: #999999;
  186. line-height: 1;
  187. text-align: center;
  188. }
  189. .price-box{
  190. display: flex;
  191. align-items: flex-end;
  192. margin-top: 28upx;
  193. .unit{
  194. font-size: 32upx;
  195. font-family: PingFang SC;
  196. font-weight: bold;
  197. color: #FF6633;
  198. line-height: 1.3;
  199. margin-right: 10upx;
  200. }
  201. .num{
  202. font-size: 56upx;
  203. font-family: PingFang SC;
  204. font-weight: bold;
  205. color: #FF6633;
  206. line-height: 1;
  207. }
  208. }
  209. }
  210. .pay-type{
  211. box-sizing: border-box;
  212. height: 192upx;
  213. background: #FFFFFF;
  214. border-radius: 16upx;
  215. margin-top: 20upx;
  216. padding: 40upx 30upx;
  217. display: flex;
  218. flex-direction: column;
  219. justify-content: space-between;
  220. .title{
  221. font-size: 28upx;
  222. font-family: PingFang SC;
  223. font-weight: 500;
  224. color: #999999;
  225. line-height: 1;
  226. }
  227. .item{
  228. display: flex;
  229. align-items: center;
  230. justify-content: space-between;
  231. .left{
  232. display: flex;
  233. align-items: center;
  234. image{
  235. width: 44upx;
  236. height: 44upx;
  237. margin-right: 20upx;
  238. }
  239. .text{
  240. font-size: 30upx;
  241. font-family: PingFang SC;
  242. font-weight: bold;
  243. color: #222222;
  244. line-height: 1;
  245. }
  246. }
  247. }
  248. }
  249. .order-info{
  250. margin-top: 20upx;
  251. background: #FFFFFF;
  252. border-radius: 16upx;
  253. padding: 40upx 30upx;
  254. .title{
  255. font-size: 30upx;
  256. font-family: PingFang SC;
  257. font-weight: bold;
  258. color: #222222;
  259. line-height: 1;
  260. }
  261. .item{
  262. margin-top: 40upx;
  263. display: flex;
  264. align-items: center;
  265. justify-content: space-between;
  266. .label{
  267. font-size: 26upx;
  268. font-family: PingFang SC;
  269. font-weight: 500;
  270. color: #666666;
  271. line-height: 1;
  272. }
  273. .text{
  274. font-size: 26upx;
  275. font-family: PingFang SC;
  276. font-weight: 500;
  277. color: #222222;
  278. line-height: 32upx;
  279. }
  280. .cont-text{
  281. font-size: 26upx;
  282. font-family: PingFang SC;
  283. font-weight: 500;
  284. color: #666666;
  285. .bold{
  286. color: #111111;
  287. }
  288. }
  289. .sn-box{
  290. display: flex;
  291. align-items: center;
  292. .copy-btn{
  293. width: 58upx;
  294. height: 32upx;
  295. line-height: 32upx;
  296. text-align: center;
  297. font-size: 22upx;
  298. font-family: PingFang SC;
  299. font-weight: 500;
  300. color: #222222;
  301. background: #F5F5F5;
  302. border-radius: 4upx;
  303. margin-left: 24upx;
  304. }
  305. }
  306. }
  307. .line{
  308. width: 100%;
  309. height: 1px;
  310. background: #F0F0F0;
  311. margin-top: 30upx;
  312. }
  313. }
  314. }
  315. .btn-box{
  316. height: 121upx;
  317. background: #FFFFFF;
  318. display: flex;
  319. align-items: center;
  320. justify-content: center;
  321. .btn{
  322. width: 91.73%;
  323. height: 88upx;
  324. line-height: 88upx;
  325. font-size: 30upx;
  326. font-family: PingFang SC;
  327. font-weight: bold;
  328. color: #FFFFFF;
  329. text-align: center;
  330. background: #2BC7B9;
  331. border-radius: 44upx;
  332. }
  333. }
  334. }
  335. </style>