packagePayment.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  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};
  133. if(this.isShow ==0&&this.splitOrderTypes&&this.splitOrderTypes.length > 0) {
  134. data = {
  135. orderId:this.orderId,
  136. splitOrderType: this.splitOrderType
  137. }
  138. }
  139. var that=this;
  140. uni.showLoading();
  141. payment(data).then(
  142. res => {
  143. if(res.code==200){
  144. if(res.isPay==0){
  145. if(res.type=="tz"){
  146. uni.setStorageSync("ztPayUrl",res.data.body.url)
  147. uni.navigateTo({
  148. url:"/pages_order/tzPay"
  149. })
  150. }
  151. if(res.type=="yb"){
  152. var payData=JSON.parse(res.data.pay_info)
  153. console.log(payData)
  154. uni.requestPayment({
  155. provider: 'wxpay',
  156. timeStamp: payData.timeStamp,
  157. nonceStr: payData.nonceStr,
  158. package: payData.package,
  159. signType: payData.signType,
  160. paySign: payData.paySign,
  161. success: function(res) {
  162. console.log(that.order.orderId)
  163. uni.hideLoading();
  164. uni.redirectTo({
  165. url:"./packageOrderPaySuccess?orderId="+that.order.orderId
  166. })
  167. },
  168. fail: function(err) {
  169. uni.showToast({
  170. icon:'none',
  171. title:'fail:' + JSON.stringify(err),
  172. });
  173. uni.hideLoading();
  174. }
  175. });
  176. }
  177. else if(res.type=="hf"){
  178. var payData=JSON.parse(res.data.pay_info)
  179. console.log(payData)
  180. uni.requestPayment({
  181. provider: 'wxpay',
  182. timeStamp: payData.timeStamp,
  183. nonceStr: payData.nonceStr,
  184. package: payData.package,
  185. signType: payData.signType,
  186. paySign: payData.paySign,
  187. success: function(res) {
  188. console.log(that.order.orderId)
  189. uni.hideLoading();
  190. uni.redirectTo({
  191. url:"./packageOrderPaySuccess?orderId="+that.order.orderId
  192. })
  193. },
  194. fail: function(err) {
  195. uni.showToast({
  196. icon:'none',
  197. title:'fail:' + JSON.stringify(err),
  198. });
  199. uni.hideLoading();
  200. }
  201. });
  202. }
  203. else if(res.type=="wx"){
  204. uni.requestPayment({
  205. provider: 'wxpay',
  206. timeStamp: res.data.timeStamp,
  207. nonceStr: res.data.nonceStr,
  208. package: res.data.packageValue,
  209. signType: res.data.signType,
  210. paySign: res.data.paySign,
  211. success: function(res) {
  212. console.log(that.order.orderId)
  213. uni.hideLoading();
  214. uni.redirectTo({
  215. url:"./packageOrderPaySuccess?orderId="+that.order.orderId
  216. })
  217. },
  218. fail: function(err) {
  219. uni.showToast({
  220. icon:'none',
  221. title:'fail:' + JSON.stringify(err),
  222. });
  223. uni.hideLoading();
  224. }
  225. });
  226. }
  227. }
  228. else{
  229. uni.hideLoading();
  230. uni.redirectTo({
  231. url:"./packageOrderPaySuccess?orderId="+that.order.orderId
  232. })
  233. }
  234. }else{
  235. uni.showToast({
  236. icon:'none',
  237. title: res.msg,
  238. });
  239. this.$reLoginCheck(res.msg)
  240. }
  241. },
  242. rej => {}
  243. );
  244. },
  245. splitOrderTypeChange(e){
  246. this.splitOrderType=e.detail.value;
  247. },
  248. }
  249. }
  250. </script>
  251. <style lang="scss">
  252. .inner-box{
  253. padding: 20upx 20upx 300upx;
  254. .time-price{
  255. box-sizing: border-box;
  256. padding: 50upx 0upx;
  257. background: #FFFFFF;
  258. border-radius: 16upx;
  259. display: flex;
  260. flex-direction: column;
  261. align-items: center;
  262. .time{
  263. font-size: 32upx;
  264. font-family: PingFang SC;
  265. font-weight: 500;
  266. color: #222222;
  267. line-height: 1;
  268. text-align: center;
  269. }
  270. .desc{
  271. margin: 30upx 0upx 15upx;
  272. font-size: 26upx;
  273. font-family: PingFang SC;
  274. color: #999999;
  275. line-height: 1;
  276. text-align: center;
  277. }
  278. .price-box{
  279. display: flex;
  280. align-items: flex-end;
  281. margin-top: 28upx;
  282. .unit{
  283. font-size: 32upx;
  284. font-family: PingFang SC;
  285. font-weight: bold;
  286. color: #FF6633;
  287. line-height: 1.3;
  288. margin-right: 10upx;
  289. }
  290. .num{
  291. font-size: 56upx;
  292. font-family: PingFang SC;
  293. font-weight: bold;
  294. color: #FF6633;
  295. line-height: 1;
  296. }
  297. }
  298. }
  299. .order-info{
  300. margin-top: 20upx;
  301. background: #FFFFFF;
  302. border-radius: 16upx;
  303. padding: 40upx 30upx;
  304. .title{
  305. font-size: 30upx;
  306. font-family: PingFang SC;
  307. font-weight: bold;
  308. color: #222222;
  309. line-height: 1;
  310. }
  311. .text{
  312. font-size: 26upx;
  313. font-family: PingFang SC;
  314. font-weight: 500;
  315. color: #222222;
  316. line-height: 32upx;
  317. }
  318. .label{
  319. font-size: 26upx;
  320. font-family: PingFang SC;
  321. font-weight: 500;
  322. color: #666666;
  323. line-height: 1;
  324. }
  325. .item{
  326. margin-top: 40upx;
  327. display: flex;
  328. align-items: center;
  329. justify-content: space-between;
  330. .cont-text{
  331. font-size: 26upx;
  332. font-family: PingFang SC;
  333. font-weight: 500;
  334. color: #666666;
  335. .bold{
  336. color: #111111;
  337. }
  338. }
  339. .sn-box{
  340. display: flex;
  341. align-items: center;
  342. .copy-btn{
  343. width: 58upx;
  344. height: 32upx;
  345. line-height: 32upx;
  346. text-align: center;
  347. font-size: 22upx;
  348. font-family: PingFang SC;
  349. font-weight: 500;
  350. color: #222222;
  351. background: #F5F5F5;
  352. border-radius: 4upx;
  353. margin-left: 24upx;
  354. }
  355. }
  356. }
  357. .line{
  358. width: 100%;
  359. height: 1px;
  360. background: #F0F0F0;
  361. margin-top: 30upx;
  362. }
  363. }
  364. }
  365. .btn-box{
  366. z-index: 9999;
  367. width: 100%;
  368. padding: 30rpx 30upx 0rpx;
  369. position: fixed;
  370. bottom: 0;
  371. left: 0;
  372. box-sizing: border-box;
  373. background-color: #ffffff;
  374. display: flex;
  375. flex-direction: column;
  376. align-items: center;
  377. justify-content: center;
  378. .btn{
  379. margin-bottom: 20rpx;
  380. width: 100%;
  381. height: 88upx;
  382. line-height: 88upx;
  383. text-align: center;
  384. font-size: 34upx;
  385. font-family: PingFang SC;
  386. font-weight: 400;
  387. color: #FFFFFF;
  388. background: #C39A58;
  389. border-radius: 10upx;
  390. position: relative;
  391. }
  392. .btn1{
  393. margin-bottom: 20rpx;
  394. width: 100%;
  395. height: 88upx;
  396. line-height: 88upx;
  397. text-align: center;
  398. font-size: 34upx;
  399. font-family: PingFang SC;
  400. font-weight: 400;
  401. color: #C39A58;
  402. border: 1rpx solid #C39A58;
  403. border-radius: 10upx;
  404. position: relative;
  405. .share-btn {
  406. top:0rpx;
  407. left:0rpx;
  408. position: absolute;
  409. width: 100%;
  410. height: 88upx;
  411. display: flex;
  412. opacity: 0;
  413. }
  414. }
  415. }
  416. </style>