加油站付款小程序,打印小票
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.

438 lines
8.9 KiB

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