paymentOrderRemain.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <template>
  2. <view class="content">
  3. <view class="inner">
  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" >{{payDelivery.toFixed(2) }}</text>
  10. </view>
  11. </view>
  12. <!-- 支付方式 -->
  13. <view class="pay-type">
  14. <view class="title">支付方式</view>
  15. <radio-group >
  16. <view class="item" >
  17. <view class="left" >
  18. <image src="../../static/images/wecha_pay.png" mode=""></image>
  19. <text class="text">微信支付</text>
  20. </view>
  21. <label>
  22. <radio :value="1" checked />
  23. </label>
  24. </view>
  25. </radio-group>
  26. </view>
  27. <!-- 订单详情查看 -->
  28. <view class="order-info">
  29. <view class="title">订单信息</view>
  30. <view class="item">
  31. <text class="label">订单编号</text>
  32. <view class="sn-box">
  33. <text class="text">{{order.orderCode}}</text>
  34. <view class="copy-btn" @click="copyOrderSn(order.orderCode)">复制</view>
  35. </view>
  36. </view>
  37. <view class="item">
  38. <text class="label">下单时间</text>
  39. <text class="text">{{order.createTime}}</text>
  40. </view>
  41. <view class="item">
  42. <text class="label">订单金额</text>
  43. <text class="text" v-if="order!=null">{{order.payPrice.toFixed(2)}}</text>
  44. </view>
  45. <view class="item">
  46. <text class="label">付款金额</text>
  47. <text class="text" v-if="order!=null">{{order.payMoney.toFixed(2)}}</text>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="btn-box">
  52. <view class="btn" @click="payOrder()">去支付</view>
  53. <view class="other-btn" >
  54. 亲友代付
  55. <button class="share" data-name="shareBtn" open-type="share">分享</button>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. import {getUserInfo} from '@/api/user'
  62. import {payRemain,getStoreOrderById} from '@/api/storeOrder'
  63. export default {
  64. data() {
  65. return {
  66. payDelivery:0.00,
  67. order:null,
  68. user:null,
  69. orderId:null,
  70. }
  71. },
  72. onLoad(option) {
  73. this.orderId=JSON.parse(option.orderId);
  74. console.log(this.orderId)
  75. this.getUserInfo();
  76. uni.showShareMenu({
  77. withShareTicket:true,
  78. //小程序的原生菜单中显示分享按钮,才能够让发送给朋友与分享到朋友圈两个按钮可以点击
  79. menus:["shareAppMessage"] //不设置默认发送给朋友
  80. })
  81. },
  82. onShow() {
  83. this.getStoreOrderById();
  84. },
  85. //发送给朋友
  86. onShareAppMessage(res) {
  87. return {
  88. title: "帮TA支付",
  89. path: '/pages_user/user/otherPaymentOrderRemain?orderId='+this.orderId,
  90. imageUrl: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20250310/aeb776c6aa174d7c94181e5fd212e0f1.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  91. }
  92. },
  93. methods: {
  94. getUserInfo(){
  95. getUserInfo().then(
  96. res => {
  97. if(res.code==200){
  98. if(res.user!=null){
  99. this.user=res.user;
  100. }
  101. }else{
  102. uni.showToast({
  103. icon:'none',
  104. title: "请求失败",
  105. });
  106. }
  107. },
  108. rej => {}
  109. );
  110. },
  111. copyOrderSn(text) {
  112. // 复制方法
  113. uni.setClipboardData({
  114. data:text,
  115. success:()=>{
  116. uni.showToast({
  117. title:'内容已成功复制到剪切板',
  118. icon:'none'
  119. })
  120. }
  121. });
  122. },
  123. getStoreOrderById(){
  124. var data = {orderId:this.orderId};
  125. var that=this;
  126. uni.showLoading();
  127. getStoreOrderById(data).then(
  128. res => {
  129. if(res.code==200){
  130. console.log(res);
  131. uni.hideLoading();
  132. that.order=res.order;
  133. this.payDelivery=that.order.payDelivery;
  134. }else{
  135. uni.showToast({
  136. icon:'none',
  137. title: res.msg,
  138. });
  139. }
  140. },
  141. rej => {}
  142. );
  143. },
  144. payOrder(){
  145. var data = {orderId:this.order.id,payType:1};
  146. var that=this;
  147. uni.showLoading();
  148. payRemain(data).then(
  149. res => {
  150. if(res.code==200){
  151. console.log(res);
  152. uni.requestPayment({
  153. provider: 'wxpay',
  154. timeStamp: res.result.timeStamp,
  155. nonceStr: res.result.nonceStr,
  156. package: res.result.packageValue,
  157. signType: res.result.signType,
  158. paySign: res.result.paySign,
  159. success: function(res) {
  160. uni.hideLoading();
  161. uni.redirectTo({
  162. url:"success?order="+JSON.stringify(that.order)
  163. })
  164. },
  165. fail: function(err) {
  166. console.log('fail:' + JSON.stringify(err));
  167. uni.hideLoading();
  168. }
  169. });
  170. }else{
  171. uni.showToast({
  172. icon:'none',
  173. title: res.msg,
  174. });
  175. }
  176. },
  177. rej => {}
  178. );
  179. }
  180. }
  181. }
  182. </script>
  183. <style lang="scss">
  184. page{
  185. height: 100%;
  186. }
  187. .content{
  188. height: 100%;
  189. display: flex;
  190. flex-direction: column;
  191. justify-content: space-between;
  192. .inner{
  193. padding: 20upx;
  194. .time-price{
  195. box-sizing: border-box;
  196. padding: 50upx 0upx;
  197. background: #FFFFFF;
  198. border-radius: 16upx;
  199. display: flex;
  200. flex-direction: column;
  201. align-items: center;
  202. .time{
  203. font-size: 32upx;
  204. font-family: PingFang SC;
  205. font-weight: 500;
  206. color: #222222;
  207. line-height: 1;
  208. text-align: center;
  209. }
  210. .desc{
  211. margin: 30upx 0upx 15upx;
  212. font-size: 26upx;
  213. font-family: PingFang SC;
  214. color: #999999;
  215. line-height: 1;
  216. text-align: center;
  217. }
  218. .price-box{
  219. display: flex;
  220. align-items: flex-end;
  221. margin-top: 28upx;
  222. .unit{
  223. font-size: 32upx;
  224. font-family: PingFang SC;
  225. font-weight: bold;
  226. color: #FF6633;
  227. line-height: 1.3;
  228. margin-right: 10upx;
  229. }
  230. .num{
  231. font-size: 56upx;
  232. font-family: PingFang SC;
  233. font-weight: bold;
  234. color: #FF6633;
  235. line-height: 1;
  236. }
  237. }
  238. }
  239. .pay-type{
  240. box-sizing: border-box;
  241. background: #FFFFFF;
  242. border-radius: 16upx;
  243. margin-top: 20upx;
  244. padding: 40upx 30upx;
  245. display: flex;
  246. flex-direction: column;
  247. justify-content: space-between;
  248. .title{
  249. font-size: 28upx;
  250. font-family: PingFang SC;
  251. font-weight: 500;
  252. color: #999999;
  253. line-height: 1;
  254. margin-bottom: 10upx;
  255. }
  256. .item{
  257. padding: 15upx 0upx;
  258. display: flex;
  259. align-items: center;
  260. justify-content: space-between;
  261. .left{
  262. display: flex;
  263. align-items: center;
  264. image{
  265. width: 44upx;
  266. height: 44upx;
  267. margin-right: 20upx;
  268. }
  269. .text{
  270. font-size: 30upx;
  271. font-family: PingFang SC;
  272. font-weight: bold;
  273. color: #222222;
  274. line-height: 1;
  275. }
  276. }
  277. }
  278. }
  279. .order-info{
  280. margin-top: 20upx;
  281. background: #FFFFFF;
  282. border-radius: 16upx;
  283. padding: 40upx 30upx;
  284. .title{
  285. font-size: 30upx;
  286. font-family: PingFang SC;
  287. font-weight: bold;
  288. color: #222222;
  289. line-height: 1;
  290. }
  291. .item{
  292. margin-top: 40upx;
  293. display: flex;
  294. align-items: center;
  295. justify-content: space-between;
  296. .label{
  297. font-size: 26upx;
  298. font-family: PingFang SC;
  299. font-weight: 500;
  300. color: #666666;
  301. line-height: 1;
  302. }
  303. .text{
  304. font-size: 26upx;
  305. font-family: PingFang SC;
  306. font-weight: 500;
  307. color: #222222;
  308. line-height: 32upx;
  309. }
  310. .cont-text{
  311. font-size: 26upx;
  312. font-family: PingFang SC;
  313. font-weight: 500;
  314. color: #666666;
  315. .bold{
  316. color: #111111;
  317. }
  318. }
  319. .sn-box{
  320. display: flex;
  321. align-items: center;
  322. .copy-btn{
  323. width: 58upx;
  324. height: 32upx;
  325. line-height: 32upx;
  326. text-align: center;
  327. font-size: 22upx;
  328. font-family: PingFang SC;
  329. font-weight: 500;
  330. color: #222222;
  331. background: #F5F5F5;
  332. border-radius: 4upx;
  333. margin-left: 24upx;
  334. }
  335. }
  336. }
  337. .line{
  338. width: 100%;
  339. height: 1px;
  340. background: #F0F0F0;
  341. margin-top: 30upx;
  342. }
  343. }
  344. }
  345. .btn-box{
  346. height: 242upx;
  347. background: #FFFFFF;
  348. display: flex;
  349. align-items: center;
  350. justify-content: center;
  351. flex-direction: column;
  352. .btn{
  353. width: 91.73%;
  354. height: 88upx;
  355. line-height: 88upx;
  356. font-size: 30upx;
  357. font-family: PingFang SC;
  358. font-weight: bold;
  359. color: #FFFFFF;
  360. text-align: center;
  361. background: #2BC7B9;
  362. border-radius: 44upx;
  363. margin-bottom: 10rpx;
  364. }
  365. .other-btn{
  366. width: 91.73%;
  367. height: 88upx;
  368. line-height: 88upx;
  369. font-size: 30upx;
  370. font-family: PingFang SC;
  371. font-weight: bold;
  372. color: #2BC7B9;
  373. border: 1rpx solid #2BC7B9;
  374. text-align: center;
  375. background: #FFFFFF;
  376. border-radius: 44upx;
  377. margin-bottom: 10rpx;
  378. position: relative;
  379. .share{
  380. display: inline-block;
  381. position: absolute;
  382. top: 0;
  383. left: 0;
  384. width: 100%;
  385. height: 100%;
  386. opacity: 0;
  387. }
  388. }
  389. }
  390. }
  391. </style>