otherPaymentOrder.vue 10 KB

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