integralPayment.vue 8.6 KB

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