succeed1.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <view class="succeed">
  3. <view class="bg">
  4. 支付成功
  5. </view>
  6. <view class="container">
  7. <view class="voucher">
  8. <view class="title">支付凭证</view>
  9. <view class="tip">请主动提供给加油员查看</view>
  10. <view class="dashed">
  11. </view>
  12. <view class="arch">
  13. <text></text>
  14. <text></text>
  15. </view>
  16. <view class="content">
  17. <view class="oil">
  18. <text>油品</text>
  19. <text>92#</text>
  20. </view>
  21. <view class="origin">
  22. <text>应付</text>
  23. <text>¥10.00</text>
  24. </view>
  25. <view class="amt">
  26. <text>实付</text>
  27. <text>¥11.20</text>
  28. </view>
  29. <view class="time">
  30. <text>时间</text>
  31. <text>11:20:00</text>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="">
  36. <view class="focus"> 更多优惠,请关注我们的公众号 </view>
  37. <official-account class="official"></official-account>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import {
  44. mapState,
  45. mapMutations
  46. } from "vuex";
  47. export default {
  48. data() {
  49. return {
  50. payType: 2, // 1电子卡 2微信
  51. wxPayLoading: false,
  52. creditPayLoading: false,
  53. cardTypeTranslate: ['', '汽油卡', '柴油卡', '非油品卡', 'LNG', 'CNG']
  54. };
  55. },
  56. computed: {
  57. // ...mapState(["orderInfo", "selectedGas", "openId", "stationId"]),
  58. // ...mapState({
  59. // orderInfo: state => state.order.orderInfo,
  60. // openId: state => state.user.openId,
  61. // stationId: state => state.station.stationId,
  62. // selectedGas: state => state.station.selectedGas,
  63. // }),
  64. availableCredit() {
  65. if (this.orderInfo.oilsCardFlag == 0) {
  66. return false
  67. }
  68. if ((+this.orderInfo.balance) < (+this.orderInfo.amt_dzk)) {
  69. return false
  70. }
  71. return true
  72. },
  73. creditFlag() {
  74. return this.orderInfo.oilsCardFlag == '1' ? true : false
  75. }
  76. },
  77. created() {
  78. // console.log(this.orderInfo)
  79. // this.initPayType()
  80. },
  81. mounted() {
  82. // this.$refs.pay.close()
  83. // this.$refs.coupon.open();
  84. },
  85. methods: {
  86. ...mapMutations(["clearLabelId"]),
  87. initPayType() {
  88. if (this.orderInfo.oilsCardFlag == 1 && this.availableCredit) {
  89. this.payType = 1
  90. }
  91. },
  92. closeCoupon() {
  93. this.$refs.coupon.close();
  94. },
  95. async creditPay() {
  96. this.creditPayLoading = true;
  97. if (this.payType === 2) {
  98. this.wxPay()
  99. return
  100. }
  101. uni.showLoading({
  102. title: '支付中...',
  103. mask: true
  104. });
  105. try {
  106. const creditPayData = await this.$Request({
  107. url: "/dzkPaySet",
  108. data: {
  109. "ordNo": this.orderInfo.ordNo
  110. },
  111. })
  112. console.log(creditPayData)
  113. if (creditPayData.retCode !== 0) {
  114. throw new Error(creditPayData.message)
  115. }
  116. this.creditPayLoading = false;
  117. uni.hideLoading();
  118. uni.redirectTo({
  119. url: "/pages/succeed/succeed"
  120. })
  121. } catch (e) {
  122. this.creditPayLoading = false;
  123. uni.hideLoading();
  124. this.showToastAndGoback(e.toString())
  125. }
  126. },
  127. async wxPay() {
  128. this.wxPayLoading = true;
  129. uni.showLoading({
  130. title: '拉取支付...',
  131. mask: true
  132. });
  133. try {
  134. const JhPayData = await this.$Request({
  135. url: "/getJhPayInfo",
  136. method: "POST",
  137. data: {
  138. "ordNo": this.orderInfo.ordNo,
  139. "openId": this.openId,
  140. "stationId": this.stationId,
  141. "userType": "1"
  142. },
  143. })
  144. console.log(JhPayData)
  145. if (JhPayData.retCode !== 0) {
  146. throw new Error("请求信息失败")
  147. }
  148. if (JhPayData.data.code !== '0000') {
  149. throw new Error(JhPayData.data.msg)
  150. }
  151. let timeStamp = JhPayData.data.respData.payTimeStamp;
  152. let nonceStr = JhPayData.data.respData.paynonceStr;
  153. let payPackage = JhPayData.data.respData.payPackage;
  154. let signType = JhPayData.data.signType;
  155. let paySign = JhPayData.data.respData.paySign;
  156. // 填写随行付的信息,启动支付
  157. const [payErr, payData] = await uni.requestPayment({
  158. 'timeStamp': timeStamp,
  159. 'nonceStr': nonceStr,
  160. 'package': payPackage,
  161. 'signType': signType,
  162. 'paySign': paySign,
  163. })
  164. if (!!payData && payData.errMsg === "requestPayment:ok") {
  165. this.wxPayLoading = false;
  166. this.clearLabelId();
  167. uni.hideLoading();
  168. uni.redirectTo({
  169. url: "/pages/succeed/succeed"
  170. })
  171. return;
  172. }
  173. this.wxPayLoading = false;
  174. uni.hideLoading();
  175. if (payErr.errMsg === "requestPayment:fail cancel") {
  176. this.showToastAndGoback("取消了支付")
  177. return;
  178. }
  179. this.showToastAndGoback("支付失败")
  180. } catch (e) {
  181. this.wxPayLoading = false;
  182. uni.hideLoading();
  183. this.showToastAndGoback(e.message)
  184. }
  185. },
  186. showToastAndGoback(title) {
  187. uni.showToast({
  188. title,
  189. mask: true
  190. })
  191. setTimeout(() => {
  192. uni.navigateBack({
  193. delta: 1
  194. })
  195. }, 1500)
  196. },
  197. // selectPayType(type) {
  198. // if (!this.availableCredit && type == 1) {
  199. // return
  200. // }
  201. // if (type === this.payType) {
  202. // this.payType = ""
  203. // return
  204. // }
  205. // this.payType = type
  206. // },
  207. selectPayType() {
  208. if (!this.availableCredit) {
  209. return
  210. }
  211. if (this.payType === 1) {
  212. this.payType = 2
  213. return
  214. }
  215. this.payType = 1
  216. },
  217. goPay() {
  218. if (this.payType === 2) {
  219. this.wxPay()
  220. return
  221. }
  222. if (this.payType === 1) {
  223. // this.$refs.selectPayType.close();
  224. this.$refs.pay.open()
  225. }
  226. },
  227. backToSelectPayType() {
  228. this.$refs.pay.close()
  229. // this.$refs.selectPayType.open();
  230. },
  231. // closeSelectPayType() {
  232. // this.$refs.selectPayType.close();
  233. // }
  234. }
  235. }
  236. </script>
  237. <style lang="scss">
  238. page {
  239. width: 750rpx;
  240. background: #F2F2F2;
  241. .succeed {
  242. .bg {
  243. width: 750rpx;
  244. height: 352rpx;
  245. background: #0ca674;
  246. }
  247. // 占位元素
  248. .container {
  249. width: 690rpx;
  250. margin: 0 auto;
  251. margin-top: -150rpx;
  252. .voucher {
  253. width: 690rpx;
  254. height: 540rpx;
  255. background: #FFFFFF;
  256. border-radius: 14rpx;
  257. box-sizing: border-box;
  258. padding: 21rpx;
  259. box-shadow: 0px 0px 20rpx 0px rgba(0, 0, 0, 0.1);
  260. .title {
  261. height: 44rpx;
  262. font-size: 33rpx;
  263. font-family: PingFangSC-Semibold, PingFang SC;
  264. font-weight: bolder;
  265. color: #1C1C27;
  266. line-height: 44rpx;
  267. text-align: center;
  268. }
  269. .tip {
  270. height: 34rpx;
  271. font-size: 30rpx;
  272. font-family: PingFangSC-Regular, PingFang SC;
  273. font-weight: bold;
  274. color: #F63932;
  275. line-height: 34rpx;
  276. text-align: center;
  277. margin-top: 30rpx;
  278. }
  279. .dashed {
  280. width: 500rpx;
  281. border: 2rpx dashed #c0c0c0;
  282. margin: 20rpx auto 0 auto;
  283. }
  284. .content{
  285. height: 300rpx;
  286. display: flex;
  287. flex-direction: column;
  288. justify-content: space-between;
  289. margin: 40rpx 80rpx 0 80rpx;
  290. >view{
  291. display: flex;
  292. justify-content: space-between;
  293. align-items: center;
  294. text:nth-child(1){
  295. font-size: 33rpx;
  296. font-weight: bold;
  297. color: #1C1C27;
  298. line-height: 40rpx;
  299. }
  300. text:nth-child(2){
  301. font-size: 33rpx;
  302. font-weight: bold;
  303. color: rgba(0, 0, 0, 0.5);
  304. line-height: 40rpx;
  305. color: #1C1C27;
  306. }
  307. }
  308. }
  309. }
  310. }
  311. }
  312. }
  313. </style>