inquiryPayment.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <template>
  2. <view>
  3. <view class="inner-box" v-if="order!=null">
  4. <!-- 时间、价格 -->
  5. <view class="time-price">
  6. <text class="time">订单金额</text>
  7. <view class="price-box">
  8. <text class="unit">¥</text>
  9. <text class="num" >{{order.payMoney.toFixed(2)}}</text>
  10. </view>
  11. </view>
  12. <!-- 订单详情查看 -->
  13. <view class="order-info">
  14. <view class="title">订单信息</view>
  15. <view class="item">
  16. <text class="label">订单编号</text>
  17. <view class="sn-box">
  18. <text class="text">{{order.orderSn}}</text>
  19. <view class="copy-btn" @click="copyTest(order.orderSn)">复制</view>
  20. </view>
  21. </view>
  22. <view class="item">
  23. <text class="label">下单时间</text>
  24. <text class="text">{{order.createTime}}</text>
  25. </view>
  26. </view>
  27. </view>
  28. <!-- 底部按钮 -->
  29. <view class="btn-box">
  30. <view class="btn" v-if="order!=null" @click="payOrder()">立即支付</view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import {getInquiryOrderById,payment} from '@/api/inquiryOrder.js'
  36. export default {
  37. data() {
  38. return {
  39. payMethod:null,
  40. orderId:null,
  41. order:null,
  42. }
  43. },
  44. onLoad(option) {
  45. this.orderId=option.orderId;
  46. this.payMethod=option.payMethod;
  47. },
  48. onShow() {
  49. this.getInquiryOrderById();
  50. },
  51. methods: {
  52. copyTest(text) {
  53. // 复制方法
  54. uni.setClipboardData({
  55. data:text,
  56. success:()=>{
  57. uni.showToast({
  58. title:'内容已成功复制到剪切板',
  59. icon:'none'
  60. })
  61. }
  62. });
  63. },
  64. getInquiryOrderById(){
  65. var data={orderId:this.orderId};
  66. console.log(data)
  67. getInquiryOrderById(data).then(
  68. res => {
  69. if(res.code==200){
  70. this.order=res.data
  71. if(this.payMethod!=null&&this.payMethod=='app'){
  72. this.payOrder();
  73. }
  74. }else{
  75. }
  76. },
  77. rej => {}
  78. );
  79. },
  80. payOrder(){
  81. var data = {
  82. orderId:this.orderId,
  83. };
  84. var that=this;
  85. uni.showLoading();
  86. payment(data).then(
  87. res => {
  88. if(res.code==200){
  89. if(res.isPay==1){
  90. uni.redirectTo({
  91. url:"/pages_order/inquiryOrderPaySuccess?orderId="+that.order.orderId
  92. })
  93. }
  94. else{
  95. if(res.type=="tz"){
  96. uni.setStorageSync("ztPayUrl",res.data.body.url)
  97. uni.redirectTo({
  98. url:"/pages_order/tzPay"
  99. })
  100. }
  101. else if(res.type=="yb"){
  102. var payData=JSON.parse(res.data.pay_info)
  103. console.log(payData)
  104. uni.requestPayment({
  105. provider: 'wxpay',
  106. timeStamp: payData.timeStamp,
  107. nonceStr: payData.nonceStr,
  108. package: payData.package,
  109. signType: payData.signType,
  110. paySign: payData.paySign,
  111. success: function(res) {
  112. console.log(that.order.orderId)
  113. uni.hideLoading();
  114. uni.redirectTo({
  115. url:"/pages_order/inquiryOrderPaySuccess?orderId="+that.order.orderId
  116. })
  117. },
  118. fail: function(err) {
  119. uni.showToast({
  120. icon:'none',
  121. title:'fail:' + JSON.stringify(err),
  122. });
  123. uni.hideLoading();
  124. }
  125. });
  126. }
  127. else if(res.type=="hf"){
  128. var payData=JSON.parse(res.data.pay_info)
  129. console.log(payData)
  130. uni.requestPayment({
  131. provider: 'wxpay',
  132. timeStamp: payData.timeStamp,
  133. nonceStr: payData.nonceStr,
  134. package: payData.package,
  135. signType: payData.signType,
  136. paySign: payData.paySign,
  137. success: function(res) {
  138. console.log(that.order.orderId)
  139. uni.hideLoading();
  140. uni.redirectTo({
  141. url:"/pages_order/inquiryOrderPaySuccess?orderId="+that.order.orderId
  142. })
  143. },
  144. fail: function(err) {
  145. uni.showToast({
  146. icon:'none',
  147. title:'fail:' + JSON.stringify(err),
  148. });
  149. uni.hideLoading();
  150. }
  151. });
  152. }
  153. else if(res.type=="wx"){
  154. uni.requestPayment({
  155. provider: 'wxpay',
  156. timeStamp: res.data.timeStamp,
  157. nonceStr: res.data.nonceStr,
  158. package: res.data.packageValue,
  159. signType: res.data.signType,
  160. paySign: res.data.paySign,
  161. success: function(res) {
  162. console.log(that.order.orderId)
  163. uni.hideLoading();
  164. uni.redirectTo({
  165. url:"/pages_order/inquiryOrderPaySuccess?orderId="+that.order.orderId
  166. })
  167. },
  168. fail: function(err) {
  169. uni.showToast({
  170. icon:'none',
  171. title:'fail:' + JSON.stringify(err),
  172. });
  173. uni.hideLoading();
  174. }
  175. });
  176. }
  177. }
  178. }else{
  179. uni.showToast({
  180. icon:'none',
  181. title: res.msg,
  182. });
  183. this.$reLoginCheck(res.msg)
  184. }
  185. },
  186. rej => {}
  187. );
  188. }
  189. }
  190. }
  191. </script>
  192. <style lang="scss">
  193. .inner-box{
  194. padding: 20upx 20upx 300upx;
  195. .time-price{
  196. box-sizing: border-box;
  197. padding: 50upx 0upx;
  198. background: #FFFFFF;
  199. border-radius: 16upx;
  200. display: flex;
  201. flex-direction: column;
  202. align-items: center;
  203. .time{
  204. font-size: 32upx;
  205. font-family: PingFang SC;
  206. font-weight: 500;
  207. color: #222222;
  208. line-height: 1;
  209. text-align: center;
  210. }
  211. .desc{
  212. margin: 30upx 0upx 15upx;
  213. font-size: 26upx;
  214. font-family: PingFang SC;
  215. color: #999999;
  216. line-height: 1;
  217. text-align: center;
  218. }
  219. .price-box{
  220. display: flex;
  221. align-items: flex-end;
  222. margin-top: 28upx;
  223. .unit{
  224. font-size: 32upx;
  225. font-family: PingFang SC;
  226. font-weight: bold;
  227. color: #FF6633;
  228. line-height: 1.3;
  229. margin-right: 10upx;
  230. }
  231. .num{
  232. font-size: 56upx;
  233. font-family: PingFang SC;
  234. font-weight: bold;
  235. color: #FF6633;
  236. line-height: 1;
  237. }
  238. }
  239. }
  240. .order-info{
  241. margin-top: 20upx;
  242. background: #FFFFFF;
  243. border-radius: 16upx;
  244. padding: 40upx 30upx;
  245. .title{
  246. font-size: 30upx;
  247. font-family: PingFang SC;
  248. font-weight: bold;
  249. color: #222222;
  250. line-height: 1;
  251. }
  252. .item{
  253. margin-top: 40upx;
  254. display: flex;
  255. align-items: center;
  256. justify-content: space-between;
  257. .label{
  258. font-size: 26upx;
  259. font-family: PingFang SC;
  260. font-weight: 500;
  261. color: #666666;
  262. line-height: 1;
  263. }
  264. .text{
  265. font-size: 26upx;
  266. font-family: PingFang SC;
  267. font-weight: 500;
  268. color: #222222;
  269. line-height: 32upx;
  270. }
  271. .cont-text{
  272. font-size: 26upx;
  273. font-family: PingFang SC;
  274. font-weight: 500;
  275. color: #666666;
  276. .bold{
  277. color: #111111;
  278. }
  279. }
  280. .sn-box{
  281. display: flex;
  282. align-items: center;
  283. .copy-btn{
  284. width: 58upx;
  285. height: 32upx;
  286. line-height: 32upx;
  287. text-align: center;
  288. font-size: 22upx;
  289. font-family: PingFang SC;
  290. font-weight: 500;
  291. color: #222222;
  292. background: #F5F5F5;
  293. border-radius: 4upx;
  294. margin-left: 24upx;
  295. }
  296. }
  297. }
  298. .line{
  299. width: 100%;
  300. height: 1px;
  301. background: #F0F0F0;
  302. margin-top: 30upx;
  303. }
  304. }
  305. }
  306. .btn-box{
  307. z-index: 9999;
  308. width: 100%;
  309. padding: 30rpx 30upx 0rpx;
  310. position: fixed;
  311. bottom: 0;
  312. left: 0;
  313. box-sizing: border-box;
  314. background-color: #ffffff;
  315. display: flex;
  316. flex-direction: column;
  317. align-items: center;
  318. justify-content: center;
  319. .btn{
  320. margin-bottom: 20rpx;
  321. width: 100%;
  322. height: 88upx;
  323. line-height: 88upx;
  324. text-align: center;
  325. font-size: 34upx;
  326. font-family: PingFang SC;
  327. font-weight: 400;
  328. color: #FFFFFF;
  329. background: #C39A58;
  330. border-radius: 10upx;
  331. position: relative;
  332. }
  333. .btn1{
  334. margin-bottom: 20rpx;
  335. width: 100%;
  336. height: 88upx;
  337. line-height: 88upx;
  338. text-align: center;
  339. font-size: 34upx;
  340. font-family: PingFang SC;
  341. font-weight: 400;
  342. color: #C39A58;
  343. border: 1rpx solid #C39A58;
  344. border-radius: 10upx;
  345. position: relative;
  346. .share-btn {
  347. top:0rpx;
  348. left:0rpx;
  349. position: absolute;
  350. width: 100%;
  351. height: 88upx;
  352. display: flex;
  353. opacity: 0;
  354. }
  355. }
  356. }
  357. </style>