加油站付款小程序,打印小票
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

458 lines
9.5 KiB

9 months ago
8 months ago
3 months ago
3 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
3 months ago
3 months ago
9 months ago
3 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
  1. <template>
  2. <view class="payment">
  3. <uni-nav-bar dark :fixed="true" background-color="#00aaff" :border="false" status-bar title="加油" />
  4. <view class="container">
  5. <uni-section title="当前加油站"
  6. type="line"
  7. titleFontSize="34rpx"></uni-section>
  8. <view class="select-oil"
  9. style="justify-content: flex-start;">
  10. <view class="oil-item" v-if="gasStation.name">
  11. <view class="oil active-oil">
  12. {{ gasStation.name }}
  13. </view>
  14. </view>
  15. <!-- <view class="oil-item"
  16. style="margin-left: 20rpx;">
  17. <view class="oil"
  18. style="display: flex;
  19. justify-content: center;
  20. align-items: center;
  21. height: 100%;"
  22. @click="$refs.popup.open()">
  23. 选择站点
  24. </view>
  25. </view> -->
  26. </view>
  27. <!-- <view class="tip">
  28. {{ gasStation.name }}
  29. </view> -->
  30. <uni-section title="油号" type="line" titleFontSize="34rpx"></uni-section>
  31. <view class="select-oil">
  32. <view class="oil-item">
  33. <view class="oil active-oil"
  34. style="flex-direction: column;">
  35. <view class="number">{{ configList.title }}</view>
  36. <view class="unit">{{ configList.price }}</view>
  37. </view>
  38. </view>
  39. </view>
  40. <uni-section title="输入金额" type="line" titleFontSize="34rpx"></uni-section>
  41. <view class="money-input">
  42. <image src="/static/payment/money.png" mode="widthFix"></image>
  43. <input v-model="form.money" @focus="focus" placeholder="请输入加油金额" type="digit" />
  44. </view>
  45. <view v-if="form.money" class="tip">
  46. 折后共计{{
  47. (form.money *
  48. (configList.preferential ?
  49. configList.preferential
  50. : 1)).toFixed(2)
  51. }}
  52. </view>
  53. <view class="select-money">
  54. <view v-for="(item, index) in rechargeList" class="money-item" :key="index">
  55. <view @click="selectMoney(item.price,index)" :class="{ 'active-money' : currentIndex == index }"
  56. class="money">
  57. <view class="unit"></view>
  58. <view class="number">{{ item.price }}</view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="sumit" @click="submit">提交订单</view>
  63. </view>
  64. <PrivacyAgreementPoup ref="showPrivacy"></PrivacyAgreementPoup>
  65. <!-- <uni-fab
  66. ref="fab"
  67. :content="content"
  68. :horizontal="horizontal"
  69. :vertical="vertical"
  70. :direction="direction"
  71. @trigger="clickMenu" /> -->
  72. <view class="phone"
  73. @click="clickService(configList.phone)">
  74. <uv-icon
  75. size="45rpx"
  76. color="#fff"
  77. name="phone"></uv-icon>
  78. </view>
  79. <uv-popup ref="popup"
  80. :round="30"
  81. :closeOnClickOverlay="false"
  82. :customStyle="{'max-height': '80vh'}">
  83. <view class="GasStationList">
  84. <view class="title">
  85. 请选择加油站
  86. </view>
  87. <view class="select-oilx">
  88. <view class="oil-itemx"
  89. @click="setGasStation(item)"
  90. :key="index"
  91. v-for="(item, index) in gasStationList">
  92. <view class="oilx">
  93. {{ item.name }}
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </uv-popup>
  99. </view>
  100. </template>
  101. <script setup>
  102. import PrivacyAgreementPoup from "@/components/PrivacyAgreementPoup/PrivacyAgreementPoup.vue";
  103. import { mapState } from 'vuex'
  104. export default {
  105. name: 'Payment',
  106. components: {
  107. PrivacyAgreementPoup
  108. },
  109. computed : {
  110. ...mapState(['configList', 'gasStationList', 'gasStation']),
  111. },
  112. data() {
  113. return {
  114. form: {
  115. money: ''
  116. },
  117. resolvePrivacyAuthorization: {},
  118. currentIndex: -1,
  119. content: [{
  120. iconPath: '/static/payment/wedding-celebration.png',
  121. text: '婚庆服务',
  122. active: false,
  123. path: '/pages/weddingCelebration/weddingCelebration'
  124. }],
  125. horizontal: 'right',
  126. vertical: 'bottom',
  127. direction: 'vertical',
  128. rechargeList : [],
  129. scene : '',
  130. }
  131. },
  132. onShow() {
  133. this.getGasStationList()
  134. },
  135. onLoad (query) {
  136. // scene 需要使用 decodeURIComponent 才能获取到生成二维码时传入的 scene
  137. const scene = query.shareId
  138. // const scene = decodeURIComponent(query.scene || '')
  139. this.scene = scene
  140. },
  141. methods: {
  142. //获取加油站列表
  143. getGasStationList(){
  144. this.$api('getGasStationList', {
  145. pageNo : 1,
  146. pageSize : 9999999
  147. }, res => {
  148. if(res.code == 200){
  149. // state.gasStationList = res.result.records
  150. this.$store.commit('setGasStationList', res.result.records)
  151. console.log(res.result.records, this.scene);
  152. if(!this.scene && !this.gasStation.id){
  153. // this.$refs.popup.open()
  154. // 默认第一个
  155. this.$store.commit('setGasStation', res.result.records[0])
  156. }else{
  157. res.result.records.forEach(n => {
  158. if(n.id == this.scene){
  159. console.log(n);
  160. this.$store.commit('setGasStation', n)
  161. }
  162. })
  163. }
  164. this.$nextTick(n => {
  165. this.getRechargePage()
  166. })
  167. }
  168. })
  169. },
  170. setGasStation(data){
  171. this.$store.commit('setGasStation', data)
  172. this.$refs.popup.close()
  173. this.$nextTick(n => {
  174. this.getRechargePage()
  175. })
  176. },
  177. // 用户选择加油金额
  178. selectMoney(money, item) {
  179. this.form.money = money
  180. this.currentIndex = item
  181. },
  182. //输入框获得焦点
  183. focus() {
  184. },
  185. //用户点击了悬浮按钮
  186. clickMenu({
  187. item
  188. }) {
  189. uni.navigateTo({
  190. url: item.path
  191. })
  192. },
  193. submit() {
  194. if (!this.gasStation.id) {
  195. return this.$refs.popup.open()
  196. }
  197. if (!uni.getStorageSync('token')) {
  198. return uni.navigateTo({
  199. url: '/pages/login/login'
  200. })
  201. }
  202. let money = (this.form.money *
  203. (this.configList.preferential ?
  204. this.configList.preferential
  205. : 1)).toFixed(2)
  206. // if(!money){
  207. // uni.showToast({
  208. // icon: 'none',
  209. // title: ''
  210. // })
  211. // }
  212. this.$api('twocreateOrderPay', {
  213. money,
  214. shopId : this.gasStation.id,
  215. }, res => {
  216. this.form.money = ''
  217. if(res.code == 200){
  218. uni.requestPayment({
  219. provider: 'wxpay', // 服务提提供商
  220. timeStamp: res.result.timeStamp, // 时间戳
  221. nonceStr: res.result.nonceStr, // 随机字符串
  222. package: res.result.packageValue,
  223. signType: res.result.signType, // 签名算法
  224. paySign: res.result.paySign, // 签名
  225. success: function (res) {
  226. console.log('支付成功',res);
  227. uni.switchTab({
  228. url: '/pages/center/center'
  229. })
  230. },
  231. fail: function (err) {
  232. console.log('支付失败',err);
  233. uni.showToast({
  234. icon:'none',
  235. title:"支付失败"
  236. })
  237. }
  238. });
  239. // uni.showToast({
  240. // icon : 'none',
  241. // title: '支付成功'
  242. // });
  243. }
  244. }, "订单创建中...")
  245. },
  246. //获取充值套餐
  247. getRechargePage(){
  248. this.$api('twogetRechargeList', {
  249. id : this.gasStation.id
  250. }, res => {
  251. this.rechargeList = res.result.records
  252. })
  253. },
  254. //拨打电话
  255. clickService(phoneNumber) {
  256. uni.makePhoneCall({
  257. phoneNumber,
  258. success: () => {},
  259. fail: () => {}
  260. });
  261. },
  262. }
  263. }
  264. </script>
  265. <style scoped lang="scss">
  266. .payment {
  267. /deep/ .uv-popup{
  268. z-index: 99999999 !important;
  269. }
  270. height: 100vh;
  271. background: #F1F5F8;
  272. width: 750rpx;
  273. margin: 0 auto;
  274. .GasStationList{
  275. width: 650rpx;
  276. text-align: center;
  277. max-height: calc(80vh - 20rpx);
  278. overflow: auto;
  279. .title{
  280. padding: 20rpx;
  281. font-size: 35rpx;
  282. margin-top: 10rpx;
  283. font-weight: 900;
  284. position: sticky;
  285. top: 0;
  286. background-color: #fff;
  287. }
  288. .oil-itemx{
  289. width: auto;
  290. box-sizing: border-box;
  291. border-radius: 20rpx;
  292. margin: 20rpx;
  293. padding: 30rpx 20rpx;
  294. overflow: hidden;
  295. background-color: #00aaff;
  296. .oilx{
  297. align-items: flex-start;
  298. padding: 20rpx;
  299. font-size: 30rpx;
  300. color: #fff;
  301. }
  302. }
  303. }
  304. .container{
  305. .oil-item{
  306. .active-oil{
  307. }
  308. .oil{
  309. align-items: flex-start;
  310. padding-left: 30rpx;
  311. padding-right: 30rpx;
  312. .number{
  313. font-size: 26rpx;
  314. }
  315. .unit{
  316. font-size: 30rpx;
  317. margin-top: 10rpx;
  318. }
  319. }
  320. }
  321. }
  322. }
  323. .phone{
  324. position: fixed;
  325. right: 100rpx;
  326. bottom: 10%;
  327. background-color: #00aaff;
  328. width: 100rpx;
  329. height: 100rpx;
  330. border-radius: 50rpx;
  331. display: flex;
  332. justify-content: center;
  333. align-items: center;
  334. box-shadow: 0 0 10rpx 10rpx #00aaff55;
  335. }
  336. .container {
  337. width: 96%;
  338. margin: 0rpx auto;
  339. border-radius: 20rpx;
  340. box-sizing: border-box;
  341. padding: 20rpx;
  342. overflow: hidden;
  343. background: white;
  344. margin-top: 20rpx;
  345. }
  346. .money-input {
  347. display: flex;
  348. align-items: center;
  349. background: #F6F7FB;
  350. padding: 30rpx 10rpx;
  351. border-radius: 20rpx;
  352. }
  353. .tip {
  354. color: #00aaff;
  355. margin-top: 10rpx;
  356. }
  357. .money-input image {
  358. width: 45rpx;
  359. }
  360. .money-input input {
  361. font-size: 36rpx;
  362. }
  363. .select-oil,
  364. .select-money {
  365. display: flex;
  366. justify-content: space-between;
  367. flex-wrap: wrap;
  368. margin: 30rpx 0rpx;
  369. }
  370. .select-oil {
  371. margin: 0;
  372. }
  373. .select-oil .oil-item,
  374. .select-money .money-item {
  375. width: 32.33%;
  376. background: #F1F5F8;
  377. border-radius: 20rpx;
  378. margin-bottom: 20rpx;
  379. overflow: hidden;
  380. }
  381. .select-oil .oil,
  382. .select-money .money {
  383. display: flex;
  384. align-items: center;
  385. justify-content: center;
  386. padding: 30rpx 0rpx;
  387. box-sizing: border-box;
  388. color: #5D5C61;
  389. }
  390. .select-oil .active-oil,
  391. .select-money .active-money {
  392. background: #00aaff;
  393. color: white;
  394. }
  395. .select-money .unit {
  396. font-size: 26rpx;
  397. }
  398. .select-money .number {
  399. font-size: 34rpx;
  400. }
  401. .sumit {
  402. background: #33a5fc;
  403. color: white;
  404. font-size: 36rpx;
  405. display: flex;
  406. align-items: center;
  407. justify-content: center;
  408. height: 80rpx;
  409. border-radius: 20rpx;
  410. }
  411. </style>