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

255 lines
5.5 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 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. <uni-section title="油号" type="line" titleFontSize="34rpx"></uni-section>
  6. <view class="select-oil">
  7. <view class="oil-item">
  8. <view class="oil active-oil">
  9. <!-- <view class="unit"></view> -->
  10. <view class="number">#95</view>
  11. </view>
  12. </view>
  13. </view>
  14. <uni-section title="输入金额" type="line" titleFontSize="34rpx"></uni-section>
  15. <view class="money-input">
  16. <image src="/static/payment/money.png" mode="widthFix"></image>
  17. <input v-model="form.money" @focus="focus" placeholder="请输入加油金额" type="number" />
  18. </view>
  19. <view v-if="form.money" class="tip">
  20. 折后共计{{
  21. form.money *
  22. (configList.preferential ?
  23. configList.preferential.keyCentent
  24. : 1)
  25. }}
  26. </view>
  27. <view class="select-money">
  28. <view v-for="(item, index) in rechargeList" class="money-item" :key="index">
  29. <view @click="selectMoney(item.price,index)" :class="{ 'active-money' : currentIndex == index }"
  30. class="money">
  31. <view class="unit"></view>
  32. <view class="number">{{ item.price }}</view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="sumit" @click="submit">提交订单</view>
  37. </view>
  38. <PrivacyAgreementPoup ref="showPrivacy"></PrivacyAgreementPoup>
  39. <uni-fab ref="fab" :content="content" :horizontal="horizontal" :vertical="vertical" :direction="direction"
  40. @trigger="clickMenu" />
  41. <showLogin ref="login"></showLogin>
  42. </view>
  43. </template>
  44. <script setup>
  45. import PrivacyAgreementPoup from "../../components/PrivacyAgreementPoup/PrivacyAgreementPoup.vue";
  46. import showLogin from "../../components/showLogin/showLogin.vue";
  47. import { mapState } from 'vuex'
  48. export default {
  49. name: 'Payment',
  50. component: {
  51. PrivacyAgreementPoup,
  52. showLogin
  53. },
  54. computed : {
  55. ...mapState(['configList']),
  56. },
  57. data() {
  58. return {
  59. form: {
  60. money: ''
  61. },
  62. resolvePrivacyAuthorization: {},
  63. currentIndex: 0,
  64. content: [{
  65. iconPath: '/static/payment/wedding-celebration.png',
  66. text: '婚庆服务',
  67. active: false,
  68. path: '/pages/weddingCelebration/weddingCelebration'
  69. }],
  70. horizontal: 'right',
  71. vertical: 'bottom',
  72. direction: 'vertical',
  73. rechargeList : []
  74. }
  75. },
  76. onShow() {
  77. if (wx.onNeedPrivacyAuthorization) {
  78. console.log('onNeedPrivacyAuthorization');
  79. wx.onNeedPrivacyAuthorization(resolve => {
  80. console.log('onNeedPrivacyAuthorization');
  81. this.resolvePrivacyAuthorization = resolve
  82. this.$refs.showPrivacy.value.init(resolve)
  83. })
  84. }
  85. this.getRechargePage()
  86. },
  87. methods: {
  88. // 用户选择加油金额
  89. selectMoney(money, item) {
  90. this.form.money = money
  91. this.currentIndex = item
  92. },
  93. //输入框获得焦点
  94. focus() {
  95. },
  96. //用户点击了悬浮按钮
  97. clickMenu({
  98. item
  99. }) {
  100. uni.navigateTo({
  101. url: item.path
  102. })
  103. },
  104. submit() {
  105. if (this.$refs.login.checkLogin()) {
  106. return
  107. }
  108. this.$api('createOrderPay', this.form, res => {
  109. if(res.code == 200){
  110. // uni.requestPayment({
  111. // provider: 'wxpay', // 服务提提供商
  112. // timeStamp: res.weChatPayData.timestamp, // 时间戳
  113. // nonceStr: res.weChatPayData.noncestr, // 随机字符串
  114. // package: res.weChatPayData.package,
  115. // signType: res.weChatPayData.signtype, // 签名算法
  116. // paySign: res.weChatPayData.sign, // 签名
  117. // success: function (res) {
  118. // console.log('支付成功',res);
  119. // uni.redirectTo({
  120. // url: '/pages/center/center'
  121. // })
  122. // },
  123. // fail: function (err) {
  124. // console.log('支付失败',err);
  125. // uni.showToast({
  126. // icon:'none',
  127. // title:"支付失败"
  128. // })
  129. // }
  130. // });
  131. }
  132. })
  133. },
  134. //获取充值套餐
  135. getRechargePage(){
  136. this.$api('getRechargePage', res => {
  137. this.rechargeList = res.result.records
  138. })
  139. }
  140. }
  141. }
  142. </script>
  143. <style scoped>
  144. .payment {
  145. height: 100vh;
  146. background: #F1F5F8;
  147. width: 750rpx;
  148. margin: 0 auto;
  149. }
  150. .container {
  151. width: 96%;
  152. margin: 0rpx auto;
  153. border-radius: 20rpx;
  154. box-sizing: border-box;
  155. padding: 20rpx;
  156. overflow: hidden;
  157. background: white;
  158. margin-top: 20rpx;
  159. }
  160. .money-input {
  161. display: flex;
  162. align-items: center;
  163. background: #F6F7FB;
  164. padding: 30rpx 10rpx;
  165. border-radius: 20rpx;
  166. }
  167. .tip {
  168. color: #00aaff;
  169. margin-top: 10rpx;
  170. }
  171. .money-input image {
  172. width: 45rpx;
  173. }
  174. .money-input input {
  175. font-size: 36rpx;
  176. }
  177. .select-oil,
  178. .select-money {
  179. display: flex;
  180. justify-content: space-between;
  181. flex-wrap: wrap;
  182. margin: 30rpx 0rpx;
  183. }
  184. .select-oil {
  185. margin: 0;
  186. }
  187. .select-oil .oil-item,
  188. .select-money .money-item {
  189. width: 32.33%;
  190. background: #F1F5F8;
  191. border-radius: 20rpx;
  192. margin-bottom: 20rpx;
  193. overflow: hidden;
  194. }
  195. .select-oil .oil,
  196. .select-money .money {
  197. display: flex;
  198. align-items: center;
  199. justify-content: center;
  200. padding: 30rpx 0rpx;
  201. box-sizing: border-box;
  202. color: #5D5C61;
  203. }
  204. .select-oil .active-oil,
  205. .select-money .active-money {
  206. background: #00aaff;
  207. color: white;
  208. }
  209. .select-money .unit {
  210. font-size: 26rpx;
  211. }
  212. .select-money .number {
  213. font-size: 34rpx;
  214. }
  215. .sumit {
  216. background: #33a5fc;
  217. color: white;
  218. font-size: 36rpx;
  219. display: flex;
  220. align-items: center;
  221. justify-content: center;
  222. height: 80rpx;
  223. border-radius: 20rpx;
  224. }
  225. </style>