packagePayment.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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 class="btn1" v-if="order!=null" >
  32. 亲友代付
  33. <button class='share-btn' data-name="shareBtn" open-type="share">
  34. </button>
  35. </view> -->
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import {getPackageOrderById,payment} from '@/api/packageOrder'
  41. export default {
  42. data() {
  43. return {
  44. payMethod:null,
  45. orderId:null,
  46. order:null,
  47. }
  48. },
  49. onLoad(option) {
  50. this.orderId=option.orderId;
  51. this.payMethod=option.payMethod;
  52. },
  53. onShow() {
  54. this.getPackageOrderById();
  55. },
  56. methods: {
  57. copyTest(text) {
  58. // 复制方法
  59. uni.setClipboardData({
  60. data:text,
  61. success:()=>{
  62. uni.showToast({
  63. title:'内容已成功复制到剪切板',
  64. icon:'none'
  65. })
  66. }
  67. });
  68. },
  69. getPackageOrderById(){
  70. var data={orderId:this.orderId};
  71. console.log(data)
  72. getPackageOrderById(data).then(
  73. res => {
  74. if(res.code==200){
  75. this.order=res.order
  76. if(this.payMethod!=null&&this.payMethod=='app'){
  77. this.payOrder();
  78. }
  79. }else{
  80. }
  81. },
  82. rej => {}
  83. );
  84. },
  85. payOrder(){
  86. var data = {
  87. orderId:this.orderId,
  88. };
  89. var that=this;
  90. uni.showLoading();
  91. payment(data).then(
  92. res => {
  93. if(res.code==200){
  94. if(res.isPay==0){
  95. if(res.type=="tz"){
  96. uni.setStorageSync("ztPayUrl",res.data.body.url)
  97. uni.navigateTo({
  98. url:"/pages_order/tzPay"
  99. })
  100. }
  101. 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:"./packageOrderPaySuccess?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:"./packageOrderPaySuccess?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:"./packageOrderPaySuccess?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.hideLoading();
  180. uni.redirectTo({
  181. url:"./packageOrderPaySuccess?orderId="+that.order.orderId
  182. })
  183. }
  184. }else{
  185. uni.showToast({
  186. icon:'none',
  187. title: res.msg,
  188. });
  189. }
  190. },
  191. rej => {}
  192. );
  193. }
  194. }
  195. }
  196. </script>
  197. <style lang="scss">
  198. .inner-box{
  199. padding: 20upx 20upx 300upx;
  200. .time-price{
  201. box-sizing: border-box;
  202. padding: 50upx 0upx;
  203. background: #FFFFFF;
  204. border-radius: 16upx;
  205. display: flex;
  206. flex-direction: column;
  207. align-items: center;
  208. .time{
  209. font-size: 32upx;
  210. font-family: PingFang SC;
  211. font-weight: 500;
  212. color: #222222;
  213. line-height: 1;
  214. text-align: center;
  215. }
  216. .desc{
  217. margin: 30upx 0upx 15upx;
  218. font-size: 26upx;
  219. font-family: PingFang SC;
  220. color: #999999;
  221. line-height: 1;
  222. text-align: center;
  223. }
  224. .price-box{
  225. display: flex;
  226. align-items: flex-end;
  227. margin-top: 28upx;
  228. .unit{
  229. font-size: 32upx;
  230. font-family: PingFang SC;
  231. font-weight: bold;
  232. color: #FF6633;
  233. line-height: 1.3;
  234. margin-right: 10upx;
  235. }
  236. .num{
  237. font-size: 56upx;
  238. font-family: PingFang SC;
  239. font-weight: bold;
  240. color: #FF6633;
  241. line-height: 1;
  242. }
  243. }
  244. }
  245. .order-info{
  246. margin-top: 20upx;
  247. background: #FFFFFF;
  248. border-radius: 16upx;
  249. padding: 40upx 30upx;
  250. .title{
  251. font-size: 30upx;
  252. font-family: PingFang SC;
  253. font-weight: bold;
  254. color: #222222;
  255. line-height: 1;
  256. }
  257. .item{
  258. margin-top: 40upx;
  259. display: flex;
  260. align-items: center;
  261. justify-content: space-between;
  262. .label{
  263. font-size: 26upx;
  264. font-family: PingFang SC;
  265. font-weight: 500;
  266. color: #666666;
  267. line-height: 1;
  268. }
  269. .text{
  270. font-size: 26upx;
  271. font-family: PingFang SC;
  272. font-weight: 500;
  273. color: #222222;
  274. line-height: 32upx;
  275. }
  276. .cont-text{
  277. font-size: 26upx;
  278. font-family: PingFang SC;
  279. font-weight: 500;
  280. color: #666666;
  281. .bold{
  282. color: #111111;
  283. }
  284. }
  285. .sn-box{
  286. display: flex;
  287. align-items: center;
  288. .copy-btn{
  289. width: 58upx;
  290. height: 32upx;
  291. line-height: 32upx;
  292. text-align: center;
  293. font-size: 22upx;
  294. font-family: PingFang SC;
  295. font-weight: 500;
  296. color: #222222;
  297. background: #F5F5F5;
  298. border-radius: 4upx;
  299. margin-left: 24upx;
  300. }
  301. }
  302. }
  303. .line{
  304. width: 100%;
  305. height: 1px;
  306. background: #F0F0F0;
  307. margin-top: 30upx;
  308. }
  309. }
  310. }
  311. .btn-box{
  312. z-index: 9999;
  313. width: 100%;
  314. padding: 30rpx 30upx 0rpx;
  315. position: fixed;
  316. bottom: 0;
  317. left: 0;
  318. box-sizing: border-box;
  319. background-color: #ffffff;
  320. display: flex;
  321. flex-direction: column;
  322. align-items: center;
  323. justify-content: center;
  324. .btn{
  325. margin-bottom: 20rpx;
  326. width: 100%;
  327. height: 88upx;
  328. line-height: 88upx;
  329. text-align: center;
  330. font-size: 34upx;
  331. font-family: PingFang SC;
  332. font-weight: 400;
  333. color: #FFFFFF;
  334. background: #C39A58;
  335. border-radius: 10upx;
  336. position: relative;
  337. }
  338. .btn1{
  339. margin-bottom: 20rpx;
  340. width: 100%;
  341. height: 88upx;
  342. line-height: 88upx;
  343. text-align: center;
  344. font-size: 34upx;
  345. font-family: PingFang SC;
  346. font-weight: 400;
  347. color: #C39A58;
  348. border: 1rpx solid #C39A58;
  349. border-radius: 10upx;
  350. position: relative;
  351. .share-btn {
  352. top:0rpx;
  353. left:0rpx;
  354. position: absolute;
  355. width: 100%;
  356. height: 88upx;
  357. display: flex;
  358. opacity: 0;
  359. }
  360. }
  361. }
  362. </style>