otherPaymentOrder.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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" >{{payMoney.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>
  46. </view>
  47. <view class="btn-box">
  48. <view class="btn" @click="pay()">帮TA支付</view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import {otherPayment,getStoreOrderById,getMyStoreOrderById} from '@/api/storeOrder'
  54. import {checkpayment} from '@/api/payment'
  55. export default {
  56. data() {
  57. return {
  58. payDelivery:0,
  59. payMoney:0,
  60. config:null,
  61. payType:1,
  62. payLimitTime:null,
  63. order:null,
  64. user:null,
  65. checkTimer: null, // 轮询定时器 ID
  66. maxRetryCount: 10, // 最大轮询次数(可选)
  67. retryCount: 0 // 当前轮询次数(可选)
  68. }
  69. },
  70. onLoad(option) {
  71. this.orderId=JSON.parse(option.orderId);
  72. this.getStoreOrderById();
  73. if (this.checkTimer) {
  74. clearInterval(this.checkTimer);
  75. this.checkTimer = null;
  76. }
  77. },
  78. methods: {
  79. copyOrderSn(text) {
  80. // 复制方法
  81. uni.setClipboardData({
  82. data:text,
  83. success:()=>{
  84. uni.showToast({
  85. title:'内容已成功复制到剪切板',
  86. icon:'none'
  87. })
  88. }
  89. });
  90. },
  91. getStoreOrderById(){
  92. var data = {orderId:this.orderId};
  93. var that=this;
  94. uni.showLoading();
  95. getStoreOrderById(data).then(
  96. res => {
  97. if(res.code==200){
  98. console.log(res);
  99. uni.hideLoading();
  100. that.order=res.order;
  101. this.payMoney=that.order.payMoney;
  102. }else{
  103. uni.showToast({
  104. icon:'none',
  105. title: res.msg,
  106. });
  107. }
  108. },
  109. rej => {}
  110. );
  111. },
  112. pay(){
  113. uni.login({
  114. success: res => {
  115. console.log(res)
  116. this.otherPayment(res.code);
  117. }
  118. });
  119. },
  120. otherPayment(code){
  121. var data = {orderId:this.order.id,code:code };
  122. var that=this;
  123. uni.showLoading();
  124. otherPayment(data).then(
  125. res => {
  126. if(res.code==200){
  127. console.log('json;;;;;',res.result)
  128. var result=res.result;
  129. wx.navigateToMiniProgram({
  130. appId: 'wx1b63de1096c46cde', // 收银台小程序 AppId 固定值
  131. path: '/pages/pay/pay', // 收银台小程序 固定路径
  132. extraData: {
  133. orderNo: result.orderNo,
  134. orderAmt: result.orderAmt,
  135. platMerCstNo: result.platMerCstNo,
  136. platMerCstName: result.platMerCstName,
  137. businessCstNo: result.businessCstNo,
  138. licenseCode: result.licenseCode,
  139. },
  140. envVersion: 'release', // 开发版 develop,体验版 trial,正式环境传 release
  141. success(res) {
  142. uni.showLoading({
  143. title:"查询支付结果中..."
  144. })
  145. // 启动定时器并保存 ID
  146. that.checkTimer = setInterval(() => {
  147. const data = { orderId: that.order.id };
  148. checkpayment(data).then(res => {
  149. if (res.code == 200) {
  150. if (res.status == 3) {
  151. // 跳转前清除定时器
  152. clearInterval(that.checkTimer);
  153. uni.navigateTo({
  154. url: '/pages_user/user/storeOrderDetail?id=' + that.order.id
  155. });
  156. }
  157. // else{
  158. // clearInterval(that.checkTimer);
  159. // setTimeout(()=>{
  160. // uni.navigateTo({
  161. // url: '/pages_user/user/storeOrderDetail?id=' + that.order.id
  162. // });
  163. // },10000)
  164. // }
  165. }
  166. });
  167. }, 4000);
  168. console.log(res)
  169. // 接口调用成功的回调函数
  170. },
  171. fail(res) {
  172. // 接口调用失败的回调函数
  173. console.log(res)
  174. if (that.checkTimer) clearInterval(that.checkTimer);
  175. }
  176. })
  177. // uni.requestPayment({
  178. // provider: 'wxpay',
  179. // timeStamp: result.timeStamp,
  180. // nonceStr: result.nonceStr,
  181. // package: result.package,
  182. // signType: result.signType,
  183. // paySign: result.paySign,
  184. // success: function(res) {
  185. // uni.hideLoading();
  186. // uni.redirectTo({
  187. // url:"otherPaySuccess"
  188. // })
  189. // },
  190. // fail: function(err) {
  191. // uni.showToast({
  192. // icon:'none',
  193. // title:'fail:' + JSON.stringify(err),
  194. // });
  195. // console.log('fail:' + JSON.stringify(err));
  196. // uni.hideLoading();
  197. // }
  198. // });
  199. // uni.requestPayment({
  200. // provider: 'wxpay',
  201. // timeStamp: res.result.timeStamp,
  202. // nonceStr: res.result.nonceStr,
  203. // package: res.result.packageValue,
  204. // signType: res.result.signType,
  205. // paySign: res.result.paySign,
  206. // success: function(res) {
  207. // uni.hideLoading();
  208. // uni.redirectTo({
  209. // url:"otherPaySuccess"
  210. // })
  211. // },
  212. // fail: function(err) {
  213. // uni.showToast({
  214. // icon:'none',
  215. // title:'fail:' + JSON.stringify(err),
  216. // });
  217. // console.log('fail:' + JSON.stringify(err));
  218. // uni.hideLoading();
  219. // }
  220. // });
  221. }else{
  222. uni.showToast({
  223. icon:'none',
  224. title: res.msg,
  225. });
  226. }
  227. },
  228. rej => {}
  229. );
  230. }
  231. }
  232. }
  233. </script>
  234. <style lang="scss">
  235. page{
  236. height: 100%;
  237. }
  238. .content{
  239. height: 100%;
  240. display: flex;
  241. flex-direction: column;
  242. justify-content: space-between;
  243. .inner{
  244. padding: 20upx;
  245. .time-price{
  246. box-sizing: border-box;
  247. padding: 50upx 0upx;
  248. background: #FFFFFF;
  249. border-radius: 16upx;
  250. display: flex;
  251. flex-direction: column;
  252. align-items: center;
  253. .time{
  254. font-size: 32upx;
  255. font-family: PingFang SC;
  256. font-weight: 500;
  257. color: #222222;
  258. line-height: 1;
  259. text-align: center;
  260. }
  261. .desc{
  262. margin: 30upx 0upx 15upx;
  263. font-size: 26upx;
  264. font-family: PingFang SC;
  265. color: #999999;
  266. line-height: 1;
  267. text-align: center;
  268. }
  269. .price-box{
  270. display: flex;
  271. align-items: flex-end;
  272. margin-top: 28upx;
  273. .unit{
  274. font-size: 32upx;
  275. font-family: PingFang SC;
  276. font-weight: bold;
  277. color: #FF6633;
  278. line-height: 1.3;
  279. margin-right: 10upx;
  280. }
  281. .num{
  282. font-size: 56upx;
  283. font-family: PingFang SC;
  284. font-weight: bold;
  285. color: #FF6633;
  286. line-height: 1;
  287. }
  288. }
  289. }
  290. .pay-type{
  291. box-sizing: border-box;
  292. background: #FFFFFF;
  293. border-radius: 16upx;
  294. margin-top: 20upx;
  295. padding: 40upx 30upx;
  296. display: flex;
  297. flex-direction: column;
  298. justify-content: space-between;
  299. .title{
  300. font-size: 28upx;
  301. font-family: PingFang SC;
  302. font-weight: 500;
  303. color: #999999;
  304. line-height: 1;
  305. margin-bottom: 10upx;
  306. }
  307. .item{
  308. padding: 15upx 0upx;
  309. display: flex;
  310. align-items: center;
  311. justify-content: space-between;
  312. .left{
  313. display: flex;
  314. align-items: center;
  315. image{
  316. width: 44upx;
  317. height: 44upx;
  318. margin-right: 20upx;
  319. }
  320. .text{
  321. font-size: 30upx;
  322. font-family: PingFang SC;
  323. font-weight: bold;
  324. color: #222222;
  325. line-height: 1;
  326. }
  327. }
  328. }
  329. }
  330. .order-info{
  331. margin-top: 20upx;
  332. background: #FFFFFF;
  333. border-radius: 16upx;
  334. padding: 40upx 30upx;
  335. .title{
  336. font-size: 30upx;
  337. font-family: PingFang SC;
  338. font-weight: bold;
  339. color: #222222;
  340. line-height: 1;
  341. }
  342. .item{
  343. margin-top: 40upx;
  344. display: flex;
  345. align-items: center;
  346. justify-content: space-between;
  347. .label{
  348. font-size: 26upx;
  349. font-family: PingFang SC;
  350. font-weight: 500;
  351. color: #666666;
  352. line-height: 1;
  353. }
  354. .text{
  355. font-size: 26upx;
  356. font-family: PingFang SC;
  357. font-weight: 500;
  358. color: #222222;
  359. line-height: 32upx;
  360. }
  361. .cont-text{
  362. font-size: 26upx;
  363. font-family: PingFang SC;
  364. font-weight: 500;
  365. color: #666666;
  366. .bold{
  367. color: #111111;
  368. }
  369. }
  370. .sn-box{
  371. display: flex;
  372. align-items: center;
  373. .copy-btn{
  374. width: 58upx;
  375. height: 32upx;
  376. line-height: 32upx;
  377. text-align: center;
  378. font-size: 22upx;
  379. font-family: PingFang SC;
  380. font-weight: 500;
  381. color: #222222;
  382. background: #F5F5F5;
  383. border-radius: 4upx;
  384. margin-left: 24upx;
  385. }
  386. }
  387. }
  388. .line{
  389. width: 100%;
  390. height: 1px;
  391. background: #F0F0F0;
  392. margin-top: 30upx;
  393. }
  394. }
  395. }
  396. .btn-box{
  397. height: 121upx;
  398. background: #FFFFFF;
  399. display: flex;
  400. align-items: center;
  401. justify-content: center;
  402. flex-direction: column;
  403. .btn{
  404. width: 91.73%;
  405. height: 88upx;
  406. line-height: 88upx;
  407. font-size: 30upx;
  408. font-family: PingFang SC;
  409. font-weight: bold;
  410. color: #FFFFFF;
  411. text-align: center;
  412. background: #2BC7B9;
  413. border-radius: 44upx;
  414. margin-bottom: 10rpx;
  415. }
  416. }
  417. }
  418. </style>