paymentOrderRemain.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  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: '/static/logo.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,appId: getApp().globalData.appId};
  146. var that=this;
  147. uni.showLoading();
  148. payRemain(data).then(
  149. res => {
  150. if(res.code==200){
  151. console.log(res);
  152. if(res.type == 'wx') {
  153. result = JSON.parse(res.result);
  154. } else {
  155. result = res.result
  156. }
  157. uni.requestPayment({
  158. provider: 'wxpay',
  159. timeStamp: result.timeStamp,
  160. nonceStr: result.nonceStr,
  161. package: result.packageValue,
  162. signType: result.signType,
  163. paySign: result.paySign,
  164. success: function(res) {
  165. uni.hideLoading();
  166. uni.redirectTo({
  167. url:"success?order="+JSON.stringify(that.order)
  168. })
  169. },
  170. fail: function(err) {
  171. console.log('fail:' + JSON.stringify(err));
  172. uni.hideLoading();
  173. }
  174. });
  175. }else{
  176. uni.showToast({
  177. icon:'none',
  178. title: res.msg,
  179. });
  180. }
  181. },
  182. rej => {}
  183. );
  184. }
  185. }
  186. }
  187. </script>
  188. <style lang="scss">
  189. page{
  190. height: 100%;
  191. }
  192. .content{
  193. height: 100%;
  194. display: flex;
  195. flex-direction: column;
  196. justify-content: space-between;
  197. .inner{
  198. padding: 20upx;
  199. .time-price{
  200. box-sizing: border-box;
  201. padding: 50upx 0upx;
  202. background: #FFFFFF;
  203. border-radius: 16upx;
  204. display: flex;
  205. flex-direction: column;
  206. align-items: center;
  207. .time{
  208. font-size: 32upx;
  209. font-family: PingFang SC;
  210. font-weight: 500;
  211. color: #222222;
  212. line-height: 1;
  213. text-align: center;
  214. }
  215. .desc{
  216. margin: 30upx 0upx 15upx;
  217. font-size: 26upx;
  218. font-family: PingFang SC;
  219. color: #999999;
  220. line-height: 1;
  221. text-align: center;
  222. }
  223. .price-box{
  224. display: flex;
  225. align-items: flex-end;
  226. margin-top: 28upx;
  227. .unit{
  228. font-size: 32upx;
  229. font-family: PingFang SC;
  230. font-weight: bold;
  231. color: #FF6633;
  232. line-height: 1.3;
  233. margin-right: 10upx;
  234. }
  235. .num{
  236. font-size: 56upx;
  237. font-family: PingFang SC;
  238. font-weight: bold;
  239. color: #FF6633;
  240. line-height: 1;
  241. }
  242. }
  243. }
  244. .pay-type{
  245. box-sizing: border-box;
  246. background: #FFFFFF;
  247. border-radius: 16upx;
  248. margin-top: 20upx;
  249. padding: 40upx 30upx;
  250. display: flex;
  251. flex-direction: column;
  252. justify-content: space-between;
  253. .title{
  254. font-size: 28upx;
  255. font-family: PingFang SC;
  256. font-weight: 500;
  257. color: #999999;
  258. line-height: 1;
  259. margin-bottom: 10upx;
  260. }
  261. .item{
  262. padding: 15upx 0upx;
  263. display: flex;
  264. align-items: center;
  265. justify-content: space-between;
  266. .left{
  267. display: flex;
  268. align-items: center;
  269. image{
  270. width: 44upx;
  271. height: 44upx;
  272. margin-right: 20upx;
  273. }
  274. .text{
  275. font-size: 30upx;
  276. font-family: PingFang SC;
  277. font-weight: bold;
  278. color: #222222;
  279. line-height: 1;
  280. }
  281. }
  282. }
  283. }
  284. .order-info{
  285. margin-top: 20upx;
  286. background: #FFFFFF;
  287. border-radius: 16upx;
  288. padding: 40upx 30upx;
  289. .title{
  290. font-size: 30upx;
  291. font-family: PingFang SC;
  292. font-weight: bold;
  293. color: #222222;
  294. line-height: 1;
  295. }
  296. .item{
  297. margin-top: 40upx;
  298. display: flex;
  299. align-items: center;
  300. justify-content: space-between;
  301. .label{
  302. font-size: 26upx;
  303. font-family: PingFang SC;
  304. font-weight: 500;
  305. color: #666666;
  306. line-height: 1;
  307. }
  308. .text{
  309. font-size: 26upx;
  310. font-family: PingFang SC;
  311. font-weight: 500;
  312. color: #222222;
  313. line-height: 32upx;
  314. }
  315. .cont-text{
  316. font-size: 26upx;
  317. font-family: PingFang SC;
  318. font-weight: 500;
  319. color: #666666;
  320. .bold{
  321. color: #111111;
  322. }
  323. }
  324. .sn-box{
  325. display: flex;
  326. align-items: center;
  327. .copy-btn{
  328. width: 58upx;
  329. height: 32upx;
  330. line-height: 32upx;
  331. text-align: center;
  332. font-size: 22upx;
  333. font-family: PingFang SC;
  334. font-weight: 500;
  335. color: #222222;
  336. background: #F5F5F5;
  337. border-radius: 4upx;
  338. margin-left: 24upx;
  339. }
  340. }
  341. }
  342. .line{
  343. width: 100%;
  344. height: 1px;
  345. background: #F0F0F0;
  346. margin-top: 30upx;
  347. }
  348. }
  349. }
  350. .btn-box{
  351. height: 242upx;
  352. background: #FFFFFF;
  353. display: flex;
  354. align-items: center;
  355. justify-content: center;
  356. flex-direction: column;
  357. .btn{
  358. width: 91.73%;
  359. height: 88upx;
  360. line-height: 88upx;
  361. font-size: 30upx;
  362. font-family: PingFang SC;
  363. font-weight: bold;
  364. color: #FFFFFF;
  365. text-align: center;
  366. background: #1BB99D;
  367. border-radius: 44upx;
  368. margin-bottom: 10rpx;
  369. }
  370. .other-btn{
  371. width: 91.73%;
  372. height: 88upx;
  373. line-height: 88upx;
  374. font-size: 30upx;
  375. font-family: PingFang SC;
  376. font-weight: bold;
  377. color: #1BB99D;
  378. border: 1rpx solid #1BB99D;
  379. text-align: center;
  380. background: #FFFFFF;
  381. border-radius: 44upx;
  382. margin-bottom: 10rpx;
  383. position: relative;
  384. .share{
  385. display: inline-block;
  386. position: absolute;
  387. top: 0;
  388. left: 0;
  389. width: 100%;
  390. height: 100%;
  391. opacity: 0;
  392. }
  393. }
  394. }
  395. }
  396. </style>