packageOtherPayment.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <view class="content">
  3. <view>
  4. <u-navbar
  5. title="亲友代付"
  6. @leftClick="leftClick"
  7. >
  8. </u-navbar>
  9. </view>
  10. <view class="inner">
  11. <view class="status_bar" :style="{height: statusBarHeight}"></view>
  12. <!-- 时间、价格 -->
  13. <view class="time-price">
  14. <text class="time">请帮好友支付</text>
  15. <view class="price-box">
  16. <text class="unit">¥</text>
  17. <text class="num" v-if="order.payMoney!=null">{{order.payMoney.toFixed(2)}}</text>
  18. </view>
  19. </view>
  20. <!-- 订单详情查看 -->
  21. <view class="order-info">
  22. <view class="title">订单信息</view>
  23. <view class="item">
  24. <text class="label">订单编号</text>
  25. <view class="sn-box">
  26. <text class="text">{{order.orderSn}}</text>
  27. <view class="copy-btn" @click="copyTest(order.orderSn)">复制</view>
  28. </view>
  29. </view>
  30. <view class="item">
  31. <text class="label">下单时间</text>
  32. <text class="text">{{order.createTime}}</text>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="btn-box">
  37. <view class="btn" @click="payOrder()">帮TA支付</view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import {getSharePackageOrderById,payment} from '@/api/packageOrder'
  43. export default {
  44. data() {
  45. return {
  46. statusBarHeight: uni.getStorageSync('menuInfo').statusBarHeight,
  47. orderId:null,
  48. order:null,
  49. }
  50. },
  51. onLoad(option) {
  52. this.orderId=option.orderId;
  53. },
  54. onShow() {
  55. this.getPackageOrderById();
  56. },
  57. methods: {
  58. leftClick() {
  59. uni.showToast({
  60. title:'请帮好友支付',
  61. icon:'none'
  62. })
  63. },
  64. copyTest(text) {
  65. // 复制方法
  66. uni.setClipboardData({
  67. data:text,
  68. success:()=>{
  69. uni.showToast({
  70. title:'内容已成功复制到剪切板',
  71. icon:'none'
  72. })
  73. }
  74. });
  75. },
  76. getPackageOrderById(){
  77. var data = {orderId:this.orderId};
  78. var that=this;
  79. uni.showLoading();
  80. getSharePackageOrderById(data).then(
  81. res => {
  82. if(res.code==200){
  83. uni.hideLoading();
  84. that.order=res.order;
  85. }else{
  86. uni.showToast({
  87. icon:'none',
  88. title: res.msg,
  89. });
  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.pay_info)
  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:"./packageOrderPaySuccess?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=="wx"){
  139. uni.requestPayment({
  140. provider: 'wxpay',
  141. timeStamp: res.data.timeStamp,
  142. nonceStr: res.data.nonceStr,
  143. package: res.data.packageValue,
  144. signType: res.data.signType,
  145. paySign: res.data.paySign,
  146. success: function(res) {
  147. console.log(that.order.orderId)
  148. uni.hideLoading();
  149. uni.redirectTo({
  150. url:"./packageOrderPaySuccess?orderId="+that.order.orderId
  151. })
  152. },
  153. fail: function(err) {
  154. uni.showToast({
  155. icon:'none',
  156. title:'fail:' + JSON.stringify(err),
  157. });
  158. uni.hideLoading();
  159. }
  160. });
  161. }
  162. }
  163. else{
  164. uni.hideLoading();
  165. uni.redirectTo({
  166. url:"./packageOrderPaySuccess?orderId="+that.order.orderId
  167. })
  168. }
  169. }else{
  170. uni.showToast({
  171. icon:'none',
  172. title: res.msg,
  173. });
  174. this.$reLoginCheck(res.msg)
  175. }
  176. },
  177. rej => {}
  178. );
  179. }
  180. }
  181. }
  182. </script>
  183. <style lang="scss">
  184. page{
  185. height: 100%;
  186. }
  187. .content{
  188. margin-top: 44px;
  189. height: 100%;
  190. .inner{
  191. padding: 20upx;
  192. .time-price{
  193. box-sizing: border-box;
  194. padding: 50upx 0upx;
  195. background: #FFFFFF;
  196. border-radius: 16upx;
  197. display: flex;
  198. flex-direction: column;
  199. align-items: center;
  200. .time{
  201. font-size: 32upx;
  202. font-family: PingFang SC;
  203. font-weight: 500;
  204. color: #222222;
  205. line-height: 1;
  206. text-align: center;
  207. }
  208. .desc{
  209. margin: 30upx 0upx 15upx;
  210. font-size: 26upx;
  211. font-family: PingFang SC;
  212. color: #999999;
  213. line-height: 1;
  214. text-align: center;
  215. }
  216. .price-box{
  217. display: flex;
  218. align-items: flex-end;
  219. margin-top: 28upx;
  220. .unit{
  221. font-size: 32upx;
  222. font-family: PingFang SC;
  223. font-weight: bold;
  224. color: #FF6633;
  225. line-height: 1.3;
  226. margin-right: 10upx;
  227. }
  228. .num{
  229. font-size: 56upx;
  230. font-family: PingFang SC;
  231. font-weight: bold;
  232. color: #FF6633;
  233. line-height: 1;
  234. }
  235. }
  236. }
  237. .order-info{
  238. margin-top: 20upx;
  239. background: #FFFFFF;
  240. border-radius: 16upx;
  241. padding: 40upx 30upx;
  242. .title{
  243. font-size: 30upx;
  244. font-family: PingFang SC;
  245. font-weight: bold;
  246. color: #222222;
  247. line-height: 1;
  248. }
  249. .item{
  250. margin-top: 40upx;
  251. display: flex;
  252. align-items: center;
  253. justify-content: space-between;
  254. .label{
  255. font-size: 26upx;
  256. font-family: PingFang SC;
  257. font-weight: 500;
  258. color: #666666;
  259. line-height: 1;
  260. }
  261. .text{
  262. font-size: 26upx;
  263. font-family: PingFang SC;
  264. font-weight: 500;
  265. color: #222222;
  266. line-height: 32upx;
  267. }
  268. .cont-text{
  269. font-size: 26upx;
  270. font-family: PingFang SC;
  271. font-weight: 500;
  272. color: #666666;
  273. .bold{
  274. color: #111111;
  275. }
  276. }
  277. .sn-box{
  278. display: flex;
  279. align-items: center;
  280. .copy-btn{
  281. width: 58upx;
  282. height: 32upx;
  283. line-height: 32upx;
  284. text-align: center;
  285. font-size: 22upx;
  286. font-family: PingFang SC;
  287. font-weight: 500;
  288. color: #222222;
  289. background: #F5F5F5;
  290. border-radius: 4upx;
  291. margin-left: 24upx;
  292. }
  293. }
  294. }
  295. .line{
  296. width: 100%;
  297. height: 1px;
  298. background: #F0F0F0;
  299. margin-top: 30upx;
  300. }
  301. }
  302. }
  303. .btn-box{
  304. width:100%;
  305. height: 121upx;
  306. display: flex;
  307. align-items: center;
  308. justify-content: center;
  309. flex-direction: column;
  310. .btn{
  311. width: 91.73%;
  312. height: 88upx;
  313. line-height: 88upx;
  314. font-size: 30upx;
  315. font-family: PingFang SC;
  316. font-weight: bold;
  317. color: #FFFFFF;
  318. text-align: center;
  319. background: #2583EB;
  320. border-radius: 44upx;
  321. margin-bottom: 10rpx;
  322. }
  323. }
  324. }
  325. </style>