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