packageOtherPayment.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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. };
  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:"./packageOrderPaySuccess?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=="wx"){
  138. uni.requestPayment({
  139. provider: 'wxpay',
  140. timeStamp: res.data.timeStamp,
  141. nonceStr: res.data.nonceStr,
  142. package: res.data.packageValue,
  143. signType: res.data.signType,
  144. paySign: res.data.paySign,
  145. success: function(res) {
  146. console.log(that.order.orderId)
  147. uni.hideLoading();
  148. uni.redirectTo({
  149. url:"./packageOrderPaySuccess?orderId="+that.order.orderId
  150. })
  151. },
  152. fail: function(err) {
  153. uni.showToast({
  154. icon:'none',
  155. title:'fail:' + JSON.stringify(err),
  156. });
  157. uni.hideLoading();
  158. }
  159. });
  160. }
  161. }
  162. else{
  163. uni.hideLoading();
  164. uni.redirectTo({
  165. url:"./packageOrderPaySuccess?orderId="+that.order.orderId
  166. })
  167. }
  168. }else{
  169. uni.showToast({
  170. icon:'none',
  171. title: res.msg,
  172. });
  173. this.$reLoginCheck(res.msg)
  174. }
  175. },
  176. rej => {}
  177. );
  178. }
  179. }
  180. }
  181. </script>
  182. <style lang="scss">
  183. page{
  184. height: 100%;
  185. }
  186. .content{
  187. margin-top: 44px;
  188. height: 100%;
  189. .inner{
  190. padding: 20upx;
  191. .time-price{
  192. box-sizing: border-box;
  193. padding: 50upx 0upx;
  194. background: #FFFFFF;
  195. border-radius: 16upx;
  196. display: flex;
  197. flex-direction: column;
  198. align-items: center;
  199. .time{
  200. font-size: 32upx;
  201. font-family: PingFang SC;
  202. font-weight: 500;
  203. color: #222222;
  204. line-height: 1;
  205. text-align: center;
  206. }
  207. .desc{
  208. margin: 30upx 0upx 15upx;
  209. font-size: 26upx;
  210. font-family: PingFang SC;
  211. color: #999999;
  212. line-height: 1;
  213. text-align: center;
  214. }
  215. .price-box{
  216. display: flex;
  217. align-items: flex-end;
  218. margin-top: 28upx;
  219. .unit{
  220. font-size: 32upx;
  221. font-family: PingFang SC;
  222. font-weight: bold;
  223. color: #FF6633;
  224. line-height: 1.3;
  225. margin-right: 10upx;
  226. }
  227. .num{
  228. font-size: 56upx;
  229. font-family: PingFang SC;
  230. font-weight: bold;
  231. color: #FF6633;
  232. line-height: 1;
  233. }
  234. }
  235. }
  236. .order-info{
  237. margin-top: 20upx;
  238. background: #FFFFFF;
  239. border-radius: 16upx;
  240. padding: 40upx 30upx;
  241. .title{
  242. font-size: 30upx;
  243. font-family: PingFang SC;
  244. font-weight: bold;
  245. color: #222222;
  246. line-height: 1;
  247. }
  248. .item{
  249. margin-top: 40upx;
  250. display: flex;
  251. align-items: center;
  252. justify-content: space-between;
  253. .label{
  254. font-size: 26upx;
  255. font-family: PingFang SC;
  256. font-weight: 500;
  257. color: #666666;
  258. line-height: 1;
  259. }
  260. .text{
  261. font-size: 26upx;
  262. font-family: PingFang SC;
  263. font-weight: 500;
  264. color: #222222;
  265. line-height: 32upx;
  266. }
  267. .cont-text{
  268. font-size: 26upx;
  269. font-family: PingFang SC;
  270. font-weight: 500;
  271. color: #666666;
  272. .bold{
  273. color: #111111;
  274. }
  275. }
  276. .sn-box{
  277. display: flex;
  278. align-items: center;
  279. .copy-btn{
  280. width: 58upx;
  281. height: 32upx;
  282. line-height: 32upx;
  283. text-align: center;
  284. font-size: 22upx;
  285. font-family: PingFang SC;
  286. font-weight: 500;
  287. color: #222222;
  288. background: #F5F5F5;
  289. border-radius: 4upx;
  290. margin-left: 24upx;
  291. }
  292. }
  293. }
  294. .line{
  295. width: 100%;
  296. height: 1px;
  297. background: #F0F0F0;
  298. margin-top: 30upx;
  299. }
  300. }
  301. }
  302. .btn-box{
  303. width:100%;
  304. height: 121upx;
  305. display: flex;
  306. align-items: center;
  307. justify-content: center;
  308. flex-direction: column;
  309. .btn{
  310. width: 91.73%;
  311. height: 88upx;
  312. line-height: 88upx;
  313. font-size: 30upx;
  314. font-family: PingFang SC;
  315. font-weight: bold;
  316. color: #FFFFFF;
  317. text-align: center;
  318. background: #C39A58;
  319. border-radius: 44upx;
  320. margin-bottom: 10rpx;
  321. }
  322. }
  323. }
  324. </style>