otherPaymentOrder.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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. <view>
  34. <view class="text" v-for="item in order.orderCodes" :key="item">{{item}}</view>
  35. </view>
  36. <view class="copy-btn" @click="copyOrderSn(orderCode)">复制</view>
  37. </view>
  38. </view>
  39. <view class="item">
  40. <text class="label">下单时间</text>
  41. <text class="text">{{order.createTime}}</text>
  42. </view>
  43. <view class="item">
  44. <text class="label">订单金额</text>
  45. <text class="text" v-if="order!=null">{{order.payPrice.toFixed(2)}}</text>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="btn-box">
  50. <view class="btn" @click="pay()">帮TA支付</view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import {otherPayment,getStoreOrderById,getStoreOrderByCombinationId,otherPaymentByCombinationId} from '@/api/storeOrder'
  56. export default {
  57. data() {
  58. return {
  59. payDelivery:0,
  60. payMoney:0,
  61. config:null,
  62. payType:1,
  63. payLimitTime:null,
  64. order:null,
  65. user:null,
  66. combinationOrderId: "",
  67. orderCode: ''
  68. }
  69. },
  70. onLoad(option) {
  71. this.orderId=option.orderId ? JSON.parse(option.orderId) : '';
  72. this.combinationOrderId = option.combinationOrderId ? decodeURIComponent(option.combinationOrderId) : ''
  73. if(this.combinationOrderId) {
  74. this.getStoreOrderByCombinationId();
  75. } else {
  76. this.getStoreOrderById();
  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. that.order.orderCodes = res.order.orderCode ? [res.order.orderCode] : []
  104. that.orderCode = res.order.orderCode
  105. }else{
  106. uni.showToast({
  107. icon:'none',
  108. title: res.msg,
  109. });
  110. }
  111. },
  112. rej => {}
  113. );
  114. },
  115. getStoreOrderByCombinationId() {
  116. var data = {combinationId:this.combinationOrderId};
  117. var that=this;
  118. uni.showLoading();
  119. getStoreOrderByCombinationId(data).then(
  120. res => {
  121. if(res.code==200){
  122. console.log(res);
  123. uni.hideLoading();
  124. that.order=res.order;
  125. that.orderCode = res.order.orderCodes ? res.order.orderCodes.join(',') : "";
  126. this.payMoney=that.order.payMoney;
  127. }else{
  128. uni.showToast({
  129. icon:'none',
  130. title: res.msg,
  131. });
  132. }
  133. },
  134. rej => {}
  135. );
  136. },
  137. pay(){
  138. uni.login({
  139. success: res => {
  140. console.log(res)
  141. if(this.combinationOrderId) {
  142. this.otherPaymentByCombinationId(res.code)
  143. } else {
  144. this.otherPayment(res.code);
  145. }
  146. }
  147. });
  148. },
  149. otherPayment(code){
  150. var data = {orderId:this.order.id,code:code };
  151. var that=this;
  152. uni.showLoading();
  153. otherPayment(data).then(
  154. res => {
  155. if(res.code==200){
  156. uni.requestPayment({
  157. provider: 'wxpay',
  158. timeStamp: res.result.timeStamp,
  159. nonceStr: res.result.nonceStr,
  160. // package: res.result.packageValue,
  161. package: res.result.packageStr,
  162. signType: res.result.signType,
  163. paySign: res.result.paySign,
  164. success: function(res) {
  165. uni.hideLoading();
  166. uni.redirectTo({
  167. url:"otherPaySuccess"
  168. })
  169. },
  170. fail: function(err) {
  171. uni.showToast({
  172. icon:'none',
  173. title:'fail:' + JSON.stringify(err),
  174. });
  175. console.log('fail:' + JSON.stringify(err));
  176. uni.hideLoading();
  177. }
  178. });
  179. }else{
  180. uni.showToast({
  181. icon:'none',
  182. title: res.msg,
  183. });
  184. }
  185. },
  186. rej => {}
  187. );
  188. },
  189. otherPaymentByCombinationId(code){
  190. var data = {combinationOrderId:this.combinationOrderId,code:code };
  191. var that=this;
  192. uni.showLoading();
  193. otherPaymentByCombinationId(data).then(
  194. res => {
  195. if(res.code==200){
  196. uni.requestPayment({
  197. provider: 'wxpay',
  198. timeStamp: res.result.timeStamp,
  199. nonceStr: res.result.nonceStr,
  200. // package: res.result.packageValue,
  201. package: res.result.packageStr,
  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: #0bb3f2;
  411. border-radius: 44upx;
  412. margin-bottom: 10rpx;
  413. }
  414. }
  415. }
  416. </style>