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

338 lines
6.9 KiB

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
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="油号" type="line" titleFontSize="34rpx"></uni-section>
  6. <view class="select-oil">
  7. <view class="oil-item">
  8. <view class="oil active-oil"
  9. style="flex-direction: column;">
  10. <view class="number">{{ configList.title.keyCentent }}</view>
  11. <view class="unit">{{ configList.price.keyCentent }}</view>
  12. </view>
  13. </view>
  14. </view>
  15. <uni-section title="输入金额" type="line" titleFontSize="34rpx"></uni-section>
  16. <view class="money-input">
  17. <image src="/static/payment/money.png" mode="widthFix"></image>
  18. <input v-model="form.money" @focus="focus" placeholder="请输入加油金额" type="digit" />
  19. </view>
  20. <view v-if="form.money" class="tip">
  21. 折后共计{{
  22. (form.money *
  23. (configList.preferential ?
  24. configList.preferential.keyCentent
  25. : 1)).toFixed(2)
  26. }}
  27. </view>
  28. <view class="select-money">
  29. <view v-for="(item, index) in rechargeList" class="money-item" :key="index">
  30. <view @click="selectMoney(item.price,index)" :class="{ 'active-money' : currentIndex == index }"
  31. class="money">
  32. <view class="unit"></view>
  33. <view class="number">{{ item.price }}</view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="sumit" @click="submit">提交订单</view>
  38. </view>
  39. <PrivacyAgreementPoup ref="showPrivacy"></PrivacyAgreementPoup>
  40. <!-- <uni-fab
  41. ref="fab"
  42. :content="content"
  43. :horizontal="horizontal"
  44. :vertical="vertical"
  45. :direction="direction"
  46. @trigger="clickMenu" /> -->
  47. <view class="phone"
  48. @click="clickService(configList.phone.keyCentent)">
  49. <uv-icon
  50. size="45rpx"
  51. color="#fff"
  52. name="phone"></uv-icon>
  53. </view>
  54. </view>
  55. </template>
  56. <script setup>
  57. import PrivacyAgreementPoup from "@/components/PrivacyAgreementPoup/PrivacyAgreementPoup.vue";
  58. import { mapState } from 'vuex'
  59. export default {
  60. name: 'Payment',
  61. components: {
  62. PrivacyAgreementPoup
  63. },
  64. computed : {
  65. ...mapState(['configList']),
  66. },
  67. data() {
  68. return {
  69. form: {
  70. money: ''
  71. },
  72. resolvePrivacyAuthorization: {},
  73. currentIndex: -1,
  74. content: [{
  75. iconPath: '/static/payment/wedding-celebration.png',
  76. text: '婚庆服务',
  77. active: false,
  78. path: '/pages/weddingCelebration/weddingCelebration'
  79. }],
  80. horizontal: 'right',
  81. vertical: 'bottom',
  82. direction: 'vertical',
  83. rechargeList : []
  84. }
  85. },
  86. onShow() {
  87. // if (wx.onNeedPrivacyAuthorization) {
  88. // console.log('onNeedPrivacyAuthorization');
  89. // wx.onNeedPrivacyAuthorization(resolve => {
  90. // console.log('onNeedPrivacyAuthorization');
  91. // this.resolvePrivacyAuthorization = resolve
  92. // this.$refs.showPrivacy.init(resolve)
  93. // })
  94. // }
  95. // wx.getPrivacySetting({
  96. // success: res => {
  97. // console.log(res)
  98. // if (res.needAuthorization) {
  99. // // 需要弹出隐私协议
  100. // this.$refs.showPrivacy.init()
  101. // }
  102. // },
  103. // fail: () => {}
  104. // })
  105. this.getRechargePage()
  106. },
  107. methods: {
  108. // 用户选择加油金额
  109. selectMoney(money, item) {
  110. this.form.money = money
  111. this.currentIndex = item
  112. },
  113. //输入框获得焦点
  114. focus() {
  115. },
  116. //用户点击了悬浮按钮
  117. clickMenu({
  118. item
  119. }) {
  120. uni.navigateTo({
  121. url: item.path
  122. })
  123. },
  124. submit() {
  125. if (!uni.getStorageSync('token')) {
  126. return uni.navigateTo({
  127. url: '/pages/login/login'
  128. })
  129. }
  130. let money = (this.form.money *
  131. (this.configList.preferential ?
  132. this.configList.preferential.keyCentent
  133. : 1)).toFixed(2)
  134. // if(!money){
  135. // uni.showToast({
  136. // icon: 'none',
  137. // title: ''
  138. // })
  139. // }
  140. this.$api('createOrderPay', {
  141. money
  142. }, res => {
  143. this.form.money = ''
  144. if(res.code == 200){
  145. uni.requestPayment({
  146. provider: 'wxpay', // 服务提提供商
  147. timeStamp: res.result.timeStamp, // 时间戳
  148. nonceStr: res.result.nonceStr, // 随机字符串
  149. package: res.result.packageValue,
  150. signType: res.result.signType, // 签名算法
  151. paySign: res.result.paySign, // 签名
  152. success: function (res) {
  153. console.log('支付成功',res);
  154. uni.switchTab({
  155. url: '/pages/center/center'
  156. })
  157. },
  158. fail: function (err) {
  159. console.log('支付失败',err);
  160. uni.showToast({
  161. icon:'none',
  162. title:"支付失败"
  163. })
  164. }
  165. });
  166. // uni.showToast({
  167. // icon : 'none',
  168. // title: '支付成功'
  169. // });
  170. }
  171. }, "订单创建中...")
  172. },
  173. //获取充值套餐
  174. getRechargePage(){
  175. this.$api('getRechargePage', res => {
  176. this.rechargeList = res.result.records
  177. })
  178. },
  179. //拨打电话
  180. clickService(phoneNumber) {
  181. uni.makePhoneCall({
  182. phoneNumber,
  183. success: () => {},
  184. fail: () => {}
  185. });
  186. },
  187. }
  188. }
  189. </script>
  190. <style scoped lang="scss">
  191. .payment {
  192. height: 100vh;
  193. background: #F1F5F8;
  194. width: 750rpx;
  195. margin: 0 auto;
  196. .container{
  197. .oil-item{
  198. .active-oil{
  199. }
  200. .oil{
  201. align-items: flex-start;
  202. padding-left: 30rpx;
  203. padding-right: 30rpx;
  204. .number{
  205. font-size: 26rpx;
  206. }
  207. .unit{
  208. font-size: 30rpx;
  209. margin-top: 10rpx;
  210. }
  211. }
  212. }
  213. }
  214. }
  215. .phone{
  216. position: fixed;
  217. right: 100rpx;
  218. bottom: 10%;
  219. background-color: #00aaff;
  220. width: 100rpx;
  221. height: 100rpx;
  222. border-radius: 50rpx;
  223. display: flex;
  224. justify-content: center;
  225. align-items: center;
  226. box-shadow: 0 0 10rpx 10rpx #00aaff55;
  227. }
  228. .container {
  229. width: 96%;
  230. margin: 0rpx auto;
  231. border-radius: 20rpx;
  232. box-sizing: border-box;
  233. padding: 20rpx;
  234. overflow: hidden;
  235. background: white;
  236. margin-top: 20rpx;
  237. }
  238. .money-input {
  239. display: flex;
  240. align-items: center;
  241. background: #F6F7FB;
  242. padding: 30rpx 10rpx;
  243. border-radius: 20rpx;
  244. }
  245. .tip {
  246. color: #00aaff;
  247. margin-top: 10rpx;
  248. }
  249. .money-input image {
  250. width: 45rpx;
  251. }
  252. .money-input input {
  253. font-size: 36rpx;
  254. }
  255. .select-oil,
  256. .select-money {
  257. display: flex;
  258. justify-content: space-between;
  259. flex-wrap: wrap;
  260. margin: 30rpx 0rpx;
  261. }
  262. .select-oil {
  263. margin: 0;
  264. }
  265. .select-oil .oil-item,
  266. .select-money .money-item {
  267. width: 32.33%;
  268. background: #F1F5F8;
  269. border-radius: 20rpx;
  270. margin-bottom: 20rpx;
  271. overflow: hidden;
  272. }
  273. .select-oil .oil,
  274. .select-money .money {
  275. display: flex;
  276. align-items: center;
  277. justify-content: center;
  278. padding: 30rpx 0rpx;
  279. box-sizing: border-box;
  280. color: #5D5C61;
  281. }
  282. .select-oil .active-oil,
  283. .select-money .active-money {
  284. background: #00aaff;
  285. color: white;
  286. }
  287. .select-money .unit {
  288. font-size: 26rpx;
  289. }
  290. .select-money .number {
  291. font-size: 34rpx;
  292. }
  293. .sumit {
  294. background: #33a5fc;
  295. color: white;
  296. font-size: 36rpx;
  297. display: flex;
  298. align-items: center;
  299. justify-content: center;
  300. height: 80rpx;
  301. border-radius: 20rpx;
  302. }
  303. </style>