integralPayment.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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.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: wx.getAccountInfoSync().miniProgram.appId
  99. };
  100. console.log('当前小程序信息id',data)
  101. var that=this;
  102. uni.showLoading();
  103. payment(data).then(
  104. res => {
  105. if(res.code==200){
  106. if(res.isPay==0){
  107. if(res.type=="tz"){
  108. uni.setStorageSync("ztPayUrl",res.data.body.url)
  109. uni.navigateTo({
  110. url:"/pages_order/tzPay"
  111. })
  112. }
  113. if(res.type=="yb"){
  114. var payData=JSON.parse(res.data.pay_info)
  115. console.log(payData)
  116. uni.requestPayment({
  117. provider: 'wxpay',
  118. timeStamp: payData.timeStamp,
  119. nonceStr: payData.nonceStr,
  120. package: payData.package,
  121. signType: payData.signType,
  122. paySign: payData.paySign,
  123. success: function(res) {
  124. console.log(that.order.orderId)
  125. uni.hideLoading();
  126. uni.redirectTo({
  127. url:"./integralOrderPaySuccess?orderId="+that.order.orderId
  128. })
  129. },
  130. fail: function(err) {
  131. uni.showToast({
  132. icon:'none',
  133. title:'fail:' + JSON.stringify(err),
  134. });
  135. uni.hideLoading();
  136. }
  137. });
  138. }
  139. else if(res.type=="hf"){
  140. var payData=JSON.parse(res.data.pay_info)
  141. console.log(payData)
  142. uni.requestPayment({
  143. provider: 'wxpay',
  144. timeStamp: payData.timeStamp,
  145. nonceStr: payData.nonceStr,
  146. package: payData.package,
  147. signType: payData.signType,
  148. paySign: payData.paySign,
  149. success: function(res) {
  150. console.log(that.order.orderId)
  151. uni.hideLoading();
  152. uni.redirectTo({
  153. url:"./integralOrderPaySuccess?orderId="+that.order.orderId
  154. })
  155. },
  156. fail: function(err) {
  157. uni.showToast({
  158. icon:'none',
  159. title:'fail:' + JSON.stringify(err),
  160. });
  161. uni.hideLoading();
  162. }
  163. });
  164. }
  165. else if(res.type=="wx"){
  166. uni.requestPayment({
  167. provider: 'wxpay',
  168. timeStamp: res.data.timeStamp,
  169. nonceStr: res.data.nonceStr,
  170. package: res.data.packageValue,
  171. signType: res.data.signType,
  172. paySign: res.data.paySign,
  173. success: function(res) {
  174. console.log(that.order.orderId)
  175. uni.hideLoading();
  176. uni.redirectTo({
  177. url:"./integralOrderPaySuccess?orderId="+that.order.orderId
  178. })
  179. },
  180. fail: function(err) {
  181. uni.showToast({
  182. icon:'none',
  183. title:'fail:' + JSON.stringify(err),
  184. });
  185. uni.hideLoading();
  186. }
  187. });
  188. }
  189. }
  190. else{
  191. uni.hideLoading();
  192. uni.redirectTo({
  193. url:"./integralOrderPaySuccess?orderId="+that.order.orderId
  194. })
  195. }
  196. }else{
  197. uni.showToast({
  198. icon:'none',
  199. title: res.msg,
  200. });
  201. }
  202. },
  203. rej => {}
  204. );
  205. }
  206. }
  207. }
  208. </script>
  209. <style lang="scss">
  210. .inner-box{
  211. padding: 20upx 20upx 300upx;
  212. .time-price{
  213. box-sizing: border-box;
  214. padding: 50upx 0upx;
  215. background: #FFFFFF;
  216. border-radius: 16upx;
  217. display: flex;
  218. flex-direction: column;
  219. align-items: center;
  220. .time{
  221. font-size: 32upx;
  222. font-family: PingFang SC;
  223. font-weight: 500;
  224. color: #222222;
  225. line-height: 1;
  226. text-align: center;
  227. }
  228. .desc{
  229. margin: 30upx 0upx 15upx;
  230. font-size: 26upx;
  231. font-family: PingFang SC;
  232. color: #999999;
  233. line-height: 1;
  234. text-align: center;
  235. }
  236. .price-box{
  237. display: flex;
  238. align-items: flex-end;
  239. margin-top: 28upx;
  240. .unit{
  241. font-size: 32upx;
  242. font-family: PingFang SC;
  243. font-weight: bold;
  244. color: #FF6633;
  245. line-height: 1.3;
  246. margin-right: 10upx;
  247. }
  248. .num{
  249. font-size: 56upx;
  250. font-family: PingFang SC;
  251. font-weight: bold;
  252. color: #FF6633;
  253. line-height: 1;
  254. }
  255. }
  256. }
  257. .order-info{
  258. margin-top: 20upx;
  259. background: #FFFFFF;
  260. border-radius: 16upx;
  261. padding: 40upx 30upx;
  262. .title{
  263. font-size: 30upx;
  264. font-family: PingFang SC;
  265. font-weight: bold;
  266. color: #222222;
  267. line-height: 1;
  268. }
  269. .item{
  270. margin-top: 40upx;
  271. display: flex;
  272. align-items: center;
  273. justify-content: space-between;
  274. .label{
  275. font-size: 26upx;
  276. font-family: PingFang SC;
  277. font-weight: 500;
  278. color: #666666;
  279. line-height: 1;
  280. }
  281. .text{
  282. font-size: 26upx;
  283. font-family: PingFang SC;
  284. font-weight: 500;
  285. color: #222222;
  286. line-height: 32upx;
  287. }
  288. .cont-text{
  289. font-size: 26upx;
  290. font-family: PingFang SC;
  291. font-weight: 500;
  292. color: #666666;
  293. .bold{
  294. color: #111111;
  295. }
  296. }
  297. .sn-box{
  298. display: flex;
  299. align-items: center;
  300. .copy-btn{
  301. width: 58upx;
  302. height: 32upx;
  303. line-height: 32upx;
  304. text-align: center;
  305. font-size: 22upx;
  306. font-family: PingFang SC;
  307. font-weight: 500;
  308. color: #222222;
  309. background: #F5F5F5;
  310. border-radius: 4upx;
  311. margin-left: 24upx;
  312. }
  313. }
  314. }
  315. .line{
  316. width: 100%;
  317. height: 1px;
  318. background: #F0F0F0;
  319. margin-top: 30upx;
  320. }
  321. }
  322. }
  323. .btn-box{
  324. z-index: 9999;
  325. width: 100%;
  326. padding: 30rpx 30upx 0rpx;
  327. position: fixed;
  328. bottom: 0;
  329. left: 0;
  330. box-sizing: border-box;
  331. background-color: #ffffff;
  332. display: flex;
  333. flex-direction: column;
  334. align-items: center;
  335. justify-content: center;
  336. .btn{
  337. margin-bottom: 20rpx;
  338. width: 100%;
  339. height: 88upx;
  340. line-height: 88upx;
  341. text-align: center;
  342. font-size: 34upx;
  343. font-family: PingFang SC;
  344. font-weight: 400;
  345. color: #FFFFFF;
  346. background: #2BC7B9;
  347. border-radius: 10upx;
  348. position: relative;
  349. }
  350. .btn1{
  351. margin-bottom: 20rpx;
  352. width: 100%;
  353. height: 88upx;
  354. line-height: 88upx;
  355. text-align: center;
  356. font-size: 34upx;
  357. font-family: PingFang SC;
  358. font-weight: 400;
  359. color: #2BC7B9;
  360. border: 1rpx solid #2BC7B9;
  361. border-radius: 10upx;
  362. position: relative;
  363. .share-btn {
  364. top:0rpx;
  365. left:0rpx;
  366. position: absolute;
  367. width: 100%;
  368. height: 88upx;
  369. display: flex;
  370. opacity: 0;
  371. }
  372. }
  373. }
  374. </style>