packagePayment.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <template>
  2. <view>
  3. <view class="inner-box" v-if="order!=null">
  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" >{{order.payMoney.toFixed(2)}}</text>
  10. </view>
  11. </view>
  12. <!-- 订单详情查看 -->
  13. <view class="order-info">
  14. <view class="title">订单信息</view>
  15. <view class="item">
  16. <text class="label">订单编号</text>
  17. <view class="sn-box">
  18. <text class="text">{{order.orderSn}}</text>
  19. <view class="copy-btn" @click="copyTest(order.orderSn)">复制</view>
  20. </view>
  21. </view>
  22. <view class="item">
  23. <text class="label">下单时间</text>
  24. <text class="text">{{order.createTime}}</text>
  25. </view>
  26. </view>
  27. <view class="order-info" v-if="isShow==0&&splitOrderTypes&&splitOrderTypes.length>0">
  28. <view class="label">配送方式</view>
  29. <radio-group @change="splitOrderTypeChange">
  30. <view class="item" v-for="(it, i) in splitOrderTypes" :key="i">
  31. <view class="left" >
  32. <text class="title">{{it.dictLabel}}</text>
  33. </view>
  34. <label>
  35. <radio :value="it.dictValue" :checked="splitOrderType==it.dictValue" />
  36. </label>
  37. </view>
  38. </radio-group>
  39. </view>
  40. </view>
  41. <!-- 底部按钮 -->
  42. <view class="btn-box">
  43. <view class="btn" v-if="order!=null" @click="payOrder()">立即支付</view>
  44. <!-- <view class="btn1" v-if="order!=null" >
  45. 亲友代付
  46. <button class='share-btn' data-name="shareBtn" open-type="share">
  47. </button>
  48. </view> -->
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import {getDictByKey} from '@/api/common'
  54. import {getPackageOrderById,payment} from '@/api/packageOrder'
  55. export default {
  56. data() {
  57. return {
  58. payMethod:null,
  59. orderId:null,
  60. order:null,
  61. splitOrderType: 1,
  62. splitOrderTypes: [],
  63. isShow: 1
  64. }
  65. },
  66. onLoad(option) {
  67. this.orderId=option.orderId;
  68. this.payMethod=option.payMethod;
  69. },
  70. onShow() {
  71. this.getPackageOrderById();
  72. },
  73. methods: {
  74. getDictByKey(splitOrderType){
  75. var that=this;
  76. var data={key:"sys_package_split_order_type"}
  77. getDictByKey(data).then(
  78. res => {
  79. if(res.code==200&&res.data.length > 0){
  80. const targetValues = splitOrderType.map(String);
  81. const result = res.data.filter(item => targetValues.includes(item.dictValue));
  82. this.splitOrderTypes=result
  83. this.splitOrderType = this.splitOrderTypes[0].dictValue
  84. } else {
  85. this.splitOrderTypes = []
  86. this.splitOrderType = 1
  87. }
  88. },
  89. rej => {}
  90. );
  91. },
  92. copyTest(text) {
  93. // 复制方法
  94. uni.setClipboardData({
  95. data:text,
  96. success:()=>{
  97. uni.showToast({
  98. title:'内容已成功复制到剪切板',
  99. icon:'none'
  100. })
  101. }
  102. });
  103. },
  104. getPackageOrderById(){
  105. var data={orderId:this.orderId};
  106. console.log(data)
  107. uni.hideLoading();
  108. getPackageOrderById(data).then(
  109. res => {
  110. if(res.code==200){
  111. this.order=res.order
  112. this.isShow = res.package ? res.package.isShow : 1;
  113. const splitOrderType = res.package ?res.package.splitOrderType.split(','):[];
  114. if(splitOrderType&&splitOrderType.length > 0) {
  115. this.getDictByKey(splitOrderType);
  116. }
  117. // 让用户自主点击支付
  118. // if(this.payMethod!=null&&this.payMethod=='app'){
  119. // this.payOrder();
  120. // }
  121. }else{
  122. uni.showToast({
  123. title: res.msg,
  124. icon: 'none'
  125. })
  126. }
  127. },
  128. rej => {}
  129. );
  130. },
  131. payOrder(){
  132. let data = {orderId:this.orderId,appId: getApp().globalData.appId};
  133. if(this.isShow ==0&&this.splitOrderTypes&&this.splitOrderTypes.length > 0) {
  134. data = {
  135. orderId:this.orderId,
  136. splitOrderType: this.splitOrderType,
  137. appId: getApp().globalData.appId
  138. }
  139. }
  140. var that=this;
  141. uni.showLoading();
  142. payment(data).then(
  143. res => {
  144. if(res.code==200){
  145. if(res.isPay==0){
  146. if(res.type=="tz"){
  147. uni.setStorageSync("ztPayUrl",res.data.body.url)
  148. uni.navigateTo({
  149. url:"/pages_order/tzPay"
  150. })
  151. }
  152. if(res.type=="yb"){
  153. var payData=JSON.parse(res.data.pay_info)
  154. console.log(payData)
  155. uni.requestPayment({
  156. provider: 'wxpay',
  157. timeStamp: payData.timeStamp,
  158. nonceStr: payData.nonceStr,
  159. package: payData.package,
  160. signType: payData.signType,
  161. paySign: payData.paySign,
  162. success: function(res) {
  163. console.log(that.order.orderId)
  164. uni.hideLoading();
  165. uni.redirectTo({
  166. url:"./packageOrderPaySuccess?orderId="+that.order.orderId
  167. })
  168. },
  169. fail: function(err) {
  170. uni.showToast({
  171. icon:'none',
  172. title:'fail:' + JSON.stringify(err),
  173. });
  174. uni.hideLoading();
  175. }
  176. });
  177. }
  178. else if(res.type=="hf"){
  179. var payData=JSON.parse(res.data.pay_info)
  180. console.log(payData)
  181. uni.requestPayment({
  182. provider: 'wxpay',
  183. timeStamp: payData.timeStamp,
  184. nonceStr: payData.nonceStr,
  185. package: payData.package,
  186. signType: payData.signType,
  187. paySign: payData.paySign,
  188. success: function(res) {
  189. console.log(that.order.orderId)
  190. uni.hideLoading();
  191. uni.redirectTo({
  192. url:"./packageOrderPaySuccess?orderId="+that.order.orderId
  193. })
  194. },
  195. fail: function(err) {
  196. uni.showToast({
  197. icon:'none',
  198. title:'fail:' + JSON.stringify(err),
  199. });
  200. uni.hideLoading();
  201. }
  202. });
  203. }
  204. else if(res.type=="wx"){
  205. uni.requestPayment({
  206. provider: 'wxpay',
  207. timeStamp: res.data.timeStamp,
  208. nonceStr: res.data.nonceStr,
  209. package: res.data.packageValue,
  210. signType: res.data.signType,
  211. paySign: res.data.paySign,
  212. success: function(res) {
  213. console.log(that.order.orderId)
  214. uni.hideLoading();
  215. uni.redirectTo({
  216. url:"./packageOrderPaySuccess?orderId="+that.order.orderId
  217. })
  218. },
  219. fail: function(err) {
  220. uni.showToast({
  221. icon:'none',
  222. title:'fail:' + JSON.stringify(err),
  223. });
  224. uni.hideLoading();
  225. }
  226. });
  227. }
  228. }
  229. else{
  230. uni.hideLoading();
  231. uni.redirectTo({
  232. url:"./packageOrderPaySuccess?orderId="+that.order.orderId
  233. })
  234. }
  235. }else{
  236. uni.showToast({
  237. icon:'none',
  238. title: res.msg,
  239. });
  240. this.$reLoginCheck(res.msg)
  241. }
  242. },
  243. rej => {}
  244. );
  245. },
  246. splitOrderTypeChange(e){
  247. this.splitOrderType=e.detail.value;
  248. },
  249. }
  250. }
  251. </script>
  252. <style lang="scss">
  253. .inner-box{
  254. padding: 20upx 20upx 300upx;
  255. .time-price{
  256. box-sizing: border-box;
  257. padding: 50upx 0upx;
  258. background: #FFFFFF;
  259. border-radius: 16upx;
  260. display: flex;
  261. flex-direction: column;
  262. align-items: center;
  263. .time{
  264. font-size: 32upx;
  265. font-family: PingFang SC;
  266. font-weight: 500;
  267. color: #222222;
  268. line-height: 1;
  269. text-align: center;
  270. }
  271. .desc{
  272. margin: 30upx 0upx 15upx;
  273. font-size: 26upx;
  274. font-family: PingFang SC;
  275. color: #999999;
  276. line-height: 1;
  277. text-align: center;
  278. }
  279. .price-box{
  280. display: flex;
  281. align-items: flex-end;
  282. margin-top: 28upx;
  283. .unit{
  284. font-size: 32upx;
  285. font-family: PingFang SC;
  286. font-weight: bold;
  287. color: #FF6633;
  288. line-height: 1.3;
  289. margin-right: 10upx;
  290. }
  291. .num{
  292. font-size: 56upx;
  293. font-family: PingFang SC;
  294. font-weight: bold;
  295. color: #FF6633;
  296. line-height: 1;
  297. }
  298. }
  299. }
  300. .order-info{
  301. margin-top: 20upx;
  302. background: #FFFFFF;
  303. border-radius: 16upx;
  304. padding: 40upx 30upx;
  305. .title{
  306. font-size: 30upx;
  307. font-family: PingFang SC;
  308. font-weight: bold;
  309. color: #222222;
  310. line-height: 1;
  311. }
  312. .text{
  313. font-size: 26upx;
  314. font-family: PingFang SC;
  315. font-weight: 500;
  316. color: #222222;
  317. line-height: 32upx;
  318. }
  319. .label{
  320. font-size: 26upx;
  321. font-family: PingFang SC;
  322. font-weight: 500;
  323. color: #666666;
  324. line-height: 1;
  325. }
  326. .item{
  327. margin-top: 40upx;
  328. display: flex;
  329. align-items: center;
  330. justify-content: space-between;
  331. .cont-text{
  332. font-size: 26upx;
  333. font-family: PingFang SC;
  334. font-weight: 500;
  335. color: #666666;
  336. .bold{
  337. color: #111111;
  338. }
  339. }
  340. .sn-box{
  341. display: flex;
  342. align-items: center;
  343. .copy-btn{
  344. width: 58upx;
  345. height: 32upx;
  346. line-height: 32upx;
  347. text-align: center;
  348. font-size: 22upx;
  349. font-family: PingFang SC;
  350. font-weight: 500;
  351. color: #222222;
  352. background: #F5F5F5;
  353. border-radius: 4upx;
  354. margin-left: 24upx;
  355. }
  356. }
  357. }
  358. .line{
  359. width: 100%;
  360. height: 1px;
  361. background: #F0F0F0;
  362. margin-top: 30upx;
  363. }
  364. }
  365. }
  366. .btn-box{
  367. z-index: 9999;
  368. width: 100%;
  369. padding: 30rpx 30upx 0rpx;
  370. position: fixed;
  371. bottom: 0;
  372. left: 0;
  373. box-sizing: border-box;
  374. background-color: #ffffff;
  375. display: flex;
  376. flex-direction: column;
  377. align-items: center;
  378. justify-content: center;
  379. .btn{
  380. margin-bottom: 20rpx;
  381. width: 100%;
  382. height: 88upx;
  383. line-height: 88upx;
  384. text-align: center;
  385. font-size: 34upx;
  386. font-family: PingFang SC;
  387. font-weight: 400;
  388. color: #FFFFFF;
  389. background: #2583EB;
  390. border-radius: 10upx;
  391. position: relative;
  392. }
  393. .btn1{
  394. margin-bottom: 20rpx;
  395. width: 100%;
  396. height: 88upx;
  397. line-height: 88upx;
  398. text-align: center;
  399. font-size: 34upx;
  400. font-family: PingFang SC;
  401. font-weight: 400;
  402. color: #2583EB;
  403. border: 1rpx solid #2583EB;
  404. border-radius: 10upx;
  405. position: relative;
  406. .share-btn {
  407. top:0rpx;
  408. left:0rpx;
  409. position: absolute;
  410. width: 100%;
  411. height: 88upx;
  412. display: flex;
  413. opacity: 0;
  414. }
  415. }
  416. }
  417. </style>