otherPaymentOrder.vue 10.0 KB

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