integralPayment.vue 8.6 KB

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