payOrder.vue 7.5 KB

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