otherPaymentOrder.vue 11 KB

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