packageOtherPayment.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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. }
  174. },
  175. rej => {}
  176. );
  177. }
  178. }
  179. }
  180. </script>
  181. <style lang="scss">
  182. page{
  183. height: 100%;
  184. }
  185. .content{
  186. margin-top: 44px;
  187. height: 100%;
  188. .inner{
  189. padding: 20upx;
  190. .time-price{
  191. box-sizing: border-box;
  192. padding: 50upx 0upx;
  193. background: #FFFFFF;
  194. border-radius: 16upx;
  195. display: flex;
  196. flex-direction: column;
  197. align-items: center;
  198. .time{
  199. font-size: 32upx;
  200. font-family: PingFang SC;
  201. font-weight: 500;
  202. color: #222222;
  203. line-height: 1;
  204. text-align: center;
  205. }
  206. .desc{
  207. margin: 30upx 0upx 15upx;
  208. font-size: 26upx;
  209. font-family: PingFang SC;
  210. color: #999999;
  211. line-height: 1;
  212. text-align: center;
  213. }
  214. .price-box{
  215. display: flex;
  216. align-items: flex-end;
  217. margin-top: 28upx;
  218. .unit{
  219. font-size: 32upx;
  220. font-family: PingFang SC;
  221. font-weight: bold;
  222. color: #FF6633;
  223. line-height: 1.3;
  224. margin-right: 10upx;
  225. }
  226. .num{
  227. font-size: 56upx;
  228. font-family: PingFang SC;
  229. font-weight: bold;
  230. color: #FF6633;
  231. line-height: 1;
  232. }
  233. }
  234. }
  235. .order-info{
  236. margin-top: 20upx;
  237. background: #FFFFFF;
  238. border-radius: 16upx;
  239. padding: 40upx 30upx;
  240. .title{
  241. font-size: 30upx;
  242. font-family: PingFang SC;
  243. font-weight: bold;
  244. color: #222222;
  245. line-height: 1;
  246. }
  247. .item{
  248. margin-top: 40upx;
  249. display: flex;
  250. align-items: center;
  251. justify-content: space-between;
  252. .label{
  253. font-size: 26upx;
  254. font-family: PingFang SC;
  255. font-weight: 500;
  256. color: #666666;
  257. line-height: 1;
  258. }
  259. .text{
  260. font-size: 26upx;
  261. font-family: PingFang SC;
  262. font-weight: 500;
  263. color: #222222;
  264. line-height: 32upx;
  265. }
  266. .cont-text{
  267. font-size: 26upx;
  268. font-family: PingFang SC;
  269. font-weight: 500;
  270. color: #666666;
  271. .bold{
  272. color: #111111;
  273. }
  274. }
  275. .sn-box{
  276. display: flex;
  277. align-items: center;
  278. .copy-btn{
  279. width: 58upx;
  280. height: 32upx;
  281. line-height: 32upx;
  282. text-align: center;
  283. font-size: 22upx;
  284. font-family: PingFang SC;
  285. font-weight: 500;
  286. color: #222222;
  287. background: #F5F5F5;
  288. border-radius: 4upx;
  289. margin-left: 24upx;
  290. }
  291. }
  292. }
  293. .line{
  294. width: 100%;
  295. height: 1px;
  296. background: #F0F0F0;
  297. margin-top: 30upx;
  298. }
  299. }
  300. }
  301. .btn-box{
  302. width:100%;
  303. height: 121upx;
  304. display: flex;
  305. align-items: center;
  306. justify-content: center;
  307. flex-direction: column;
  308. .btn{
  309. width: 91.73%;
  310. height: 88upx;
  311. line-height: 88upx;
  312. font-size: 30upx;
  313. font-family: PingFang SC;
  314. font-weight: bold;
  315. color: #FFFFFF;
  316. text-align: center;
  317. background: #C39A58;
  318. border-radius: 44upx;
  319. margin-bottom: 10rpx;
  320. }
  321. }
  322. }
  323. </style>