otherPaymentOrder.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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} 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. }
  65. },
  66. onLoad(option) {
  67. this.orderId=JSON.parse(option.orderId);
  68. },
  69. onShow() {
  70. this.$isLogin().then(res => {
  71. if(res){
  72. this.getStoreOrderById();
  73. } else {
  74. uni.navigateTo({
  75. url:'/pages/auth/login',
  76. })
  77. }
  78. })
  79. },
  80. methods: {
  81. copyOrderSn(text) {
  82. // 复制方法
  83. uni.setClipboardData({
  84. data:text,
  85. success:()=>{
  86. uni.showToast({
  87. title:'内容已成功复制到剪切板',
  88. icon:'none'
  89. })
  90. }
  91. });
  92. },
  93. getStoreOrderById(){
  94. var data = {orderId:this.orderId};
  95. var that=this;
  96. uni.showLoading();
  97. getStoreOrderById(data).then(
  98. res => {
  99. if(res.code==200){
  100. console.log(res);
  101. uni.hideLoading();
  102. that.order=res.order;
  103. this.payMoney=that.order.payMoney;
  104. }else{
  105. uni.showToast({
  106. icon:'none',
  107. title: res.msg,
  108. });
  109. }
  110. },
  111. rej => {}
  112. );
  113. },
  114. pay(){
  115. uni.login({
  116. success: res => {
  117. console.log(res)
  118. this.otherPayment(res.code);
  119. }
  120. });
  121. },
  122. otherPayment(code){
  123. var data = {orderId:this.order.id,code:code };
  124. var that=this;
  125. uni.showLoading();
  126. otherPayment(data).then(
  127. res => {
  128. if(res.code==200){
  129. var result=JSON.parse(res.result);
  130. uni.requestPayment({
  131. provider: 'wxpay',
  132. timeStamp: result.timeStamp,
  133. nonceStr: result.nonceStr,
  134. package: result.package,
  135. signType: result.signType,
  136. paySign: result.paySign,
  137. success: function(res) {
  138. uni.hideLoading();
  139. uni.redirectTo({
  140. url:"otherPaySuccess"
  141. })
  142. },
  143. fail: function(err) {
  144. uni.showToast({
  145. icon:'none',
  146. title:'fail:' + JSON.stringify(err),
  147. });
  148. console.log('fail:' + JSON.stringify(err));
  149. uni.hideLoading();
  150. }
  151. });
  152. // uni.requestPayment({
  153. // provider: 'wxpay',
  154. // timeStamp: res.result.timeStamp,
  155. // nonceStr: res.result.nonceStr,
  156. // package: res.result.packageValue,
  157. // signType: res.result.signType,
  158. // paySign: res.result.paySign,
  159. // success: function(res) {
  160. // uni.hideLoading();
  161. // uni.redirectTo({
  162. // url:"otherPaySuccess"
  163. // })
  164. // },
  165. // fail: function(err) {
  166. // uni.showToast({
  167. // icon:'none',
  168. // title:'fail:' + JSON.stringify(err),
  169. // });
  170. // console.log('fail:' + JSON.stringify(err));
  171. // uni.hideLoading();
  172. // }
  173. // });
  174. }else{
  175. uni.showToast({
  176. icon:'none',
  177. title: res.msg,
  178. });
  179. }
  180. },
  181. rej => {}
  182. );
  183. }
  184. }
  185. }
  186. </script>
  187. <style lang="scss">
  188. page{
  189. height: 100%;
  190. }
  191. .content{
  192. height: 100%;
  193. display: flex;
  194. flex-direction: column;
  195. justify-content: space-between;
  196. .inner{
  197. padding: 20upx;
  198. .time-price{
  199. box-sizing: border-box;
  200. padding: 50upx 0upx;
  201. background: #FFFFFF;
  202. border-radius: 16upx;
  203. display: flex;
  204. flex-direction: column;
  205. align-items: center;
  206. .time{
  207. font-size: 32upx;
  208. font-family: PingFang SC;
  209. font-weight: 500;
  210. color: #222222;
  211. line-height: 1;
  212. text-align: center;
  213. }
  214. .desc{
  215. margin: 30upx 0upx 15upx;
  216. font-size: 26upx;
  217. font-family: PingFang SC;
  218. color: #999999;
  219. line-height: 1;
  220. text-align: center;
  221. }
  222. .price-box{
  223. display: flex;
  224. align-items: flex-end;
  225. margin-top: 28upx;
  226. .unit{
  227. font-size: 32upx;
  228. font-family: PingFang SC;
  229. font-weight: bold;
  230. color: #FF6633;
  231. line-height: 1.3;
  232. margin-right: 10upx;
  233. }
  234. .num{
  235. font-size: 56upx;
  236. font-family: PingFang SC;
  237. font-weight: bold;
  238. color: #FF6633;
  239. line-height: 1;
  240. }
  241. }
  242. }
  243. .pay-type{
  244. box-sizing: border-box;
  245. background: #FFFFFF;
  246. border-radius: 16upx;
  247. margin-top: 20upx;
  248. padding: 40upx 30upx;
  249. display: flex;
  250. flex-direction: column;
  251. justify-content: space-between;
  252. .title{
  253. font-size: 28upx;
  254. font-family: PingFang SC;
  255. font-weight: 500;
  256. color: #999999;
  257. line-height: 1;
  258. margin-bottom: 10upx;
  259. }
  260. .item{
  261. padding: 15upx 0upx;
  262. display: flex;
  263. align-items: center;
  264. justify-content: space-between;
  265. .left{
  266. display: flex;
  267. align-items: center;
  268. image{
  269. width: 44upx;
  270. height: 44upx;
  271. margin-right: 20upx;
  272. }
  273. .text{
  274. font-size: 30upx;
  275. font-family: PingFang SC;
  276. font-weight: bold;
  277. color: #222222;
  278. line-height: 1;
  279. }
  280. }
  281. }
  282. }
  283. .order-info{
  284. margin-top: 20upx;
  285. background: #FFFFFF;
  286. border-radius: 16upx;
  287. padding: 40upx 30upx;
  288. .title{
  289. font-size: 30upx;
  290. font-family: PingFang SC;
  291. font-weight: bold;
  292. color: #222222;
  293. line-height: 1;
  294. }
  295. .item{
  296. margin-top: 40upx;
  297. display: flex;
  298. align-items: center;
  299. justify-content: space-between;
  300. .label{
  301. font-size: 26upx;
  302. font-family: PingFang SC;
  303. font-weight: 500;
  304. color: #666666;
  305. line-height: 1;
  306. }
  307. .text{
  308. font-size: 26upx;
  309. font-family: PingFang SC;
  310. font-weight: 500;
  311. color: #222222;
  312. line-height: 32upx;
  313. }
  314. .cont-text{
  315. font-size: 26upx;
  316. font-family: PingFang SC;
  317. font-weight: 500;
  318. color: #666666;
  319. .bold{
  320. color: #111111;
  321. }
  322. }
  323. .sn-box{
  324. display: flex;
  325. align-items: center;
  326. .copy-btn{
  327. width: 58upx;
  328. height: 32upx;
  329. line-height: 32upx;
  330. text-align: center;
  331. font-size: 22upx;
  332. font-family: PingFang SC;
  333. font-weight: 500;
  334. color: #222222;
  335. background: #F5F5F5;
  336. border-radius: 4upx;
  337. margin-left: 24upx;
  338. }
  339. }
  340. }
  341. .line{
  342. width: 100%;
  343. height: 1px;
  344. background: #F0F0F0;
  345. margin-top: 30upx;
  346. }
  347. }
  348. }
  349. .btn-box{
  350. height: 121upx;
  351. background: #FFFFFF;
  352. display: flex;
  353. align-items: center;
  354. justify-content: center;
  355. flex-direction: column;
  356. .btn{
  357. width: 91.73%;
  358. height: 88upx;
  359. line-height: 88upx;
  360. font-size: 30upx;
  361. font-family: PingFang SC;
  362. font-weight: bold;
  363. color: #FFFFFF;
  364. text-align: center;
  365. background: #2583EB;
  366. border-radius: 44upx;
  367. margin-bottom: 10rpx;
  368. }
  369. }
  370. }
  371. </style>