otherPaymentOrder.vue 12 KB

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