index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. <template>
  2. <view class="content">
  3. <swiper :indicator-dots="true" indicator-color="rgba(255,255,255,0.5)" indicator-active-color="#ffffff"
  4. :autoplay="true" :interval="4000" :duration="1000" circular>
  5. <swiper-item v-for="item in stationPicList" :key="item.id">
  6. <image :src="item.url" mode="scaleToFill"></image>
  7. </swiper-item>
  8. </swiper>
  9. <view class="box">
  10. <view class="title">
  11. <view class="left">
  12. 选择油枪 |
  13. <text v-if="!selectedGas.oilGunNo">请选择油枪</text>
  14. <text class="selected" v-else>已选择{{selectedGas.oilGunNo}}号油枪</text>
  15. </view>
  16. <!-- <text class="right" @click="openMoreGun">更多 ></text> -->
  17. </view>
  18. <view class="notice-bar-container">
  19. <uni-notice-bar class="notice-bar" scrollable="true" single="true" showIcon="true" :speed="50" :text="notice">
  20. </uni-notice-bar>
  21. </view>
  22. <view class="gun">
  23. <view v-for="item in cutGasList" @click="selectGas(item)"
  24. :class="[item.oilGunId === selectedGas.oilGunId ? 'selected' : '']" :key="item.oilGunId">
  25. <text>{{ item.oilGunNo + "号油枪"}}</text>
  26. <text>{{item.oilName}}</text>
  27. </view>
  28. <view @click="openMoreGun" :class="[showMoreGasSelected? 'selected':'']" v-if="cutGasList.length >= 5">
  29. <text class="more">更多>></text>
  30. </view>
  31. </view>
  32. <view class="title">
  33. <view class="left">
  34. 输入金额 |
  35. <text>建议询问加油员后输入</text>
  36. </view>
  37. </view>
  38. <view class="amount">
  39. <view class="inp">
  40. <input placeholder="点击输入金额"
  41. confirm-type="done"
  42. type="digit"
  43. step="0.01"
  44. min="0"
  45. @blur="inputAccount"
  46. v-model="account"
  47. />
  48. <text>(元)</text>
  49. </view>
  50. <view class="btn">
  51. <view :class="[item === account ? 'selected' : '']" v-for="item in accountList" :key="item"
  52. @click="selectAccount(item)">
  53. {{item}}
  54. </view>
  55. </view>
  56. </view>
  57. <view class="tip">
  58. <image src="../../static/icon/a01-zhuyi.2x.png" mode="scaleToFill"></image>
  59. <text>请勿在油机旁使用手机</text>
  60. </view>
  61. <view class="submit">
  62. <button type="default" :class="[avalibleSettle ? 'avalible' : '']" @click="creatOrder" :loading="loading"
  63. :disabled="!avalibleSettle || loading">
  64. 结算
  65. </button>
  66. </view>
  67. </view>
  68. <uni-popup ref="popup" type="bottom" :maskClick="true">
  69. <view class="more-gun">
  70. <view class="title">
  71. <text>选择油枪号</text>
  72. <view class="icon" @click="closeMoreGun"></view>
  73. </view>
  74. <view class="gun-list">
  75. <scroll-view scroll-y="true">
  76. <view v-for="item in gasList" @click="selectGasPopup(item)"
  77. :class="[item.oilGunId === selectedGas.oilGunId ? 'selected' : '']" :key="item.oilGunId">
  78. <text>{{ item.oilGunNo + "号油枪"}}</text>
  79. <text>{{item.oilName}}</text>
  80. </view>
  81. </scroll-view>
  82. </view>
  83. </view>
  84. </uni-popup>
  85. </view>
  86. </template>
  87. <script>
  88. import {
  89. mapState,
  90. mapMutations
  91. } from "vuex";
  92. import getPermission from "../../util/permission.js"
  93. export default {
  94. data() {
  95. return {
  96. stationPicList: [],
  97. notice: '',
  98. gasList: [],
  99. selectedGas: undefined,
  100. accountList: [100, 200, 300, 400],
  101. account: "",
  102. loading: false,
  103. }
  104. },
  105. created() {
  106. this.init()
  107. },
  108. computed: {
  109. ...mapState(["appId", "stationId", "phoneNumber", "countryCode", "purePhoneNumber", "openId", "unionId",
  110. "userInfo"
  111. ]),
  112. cutGasList() {
  113. return this.gasList.slice(0, 5)
  114. },
  115. showMoreGasSelected() {
  116. if (!this.selectedGas) {
  117. return false
  118. }
  119. const len = this.cutGasList.filter((ele) => {
  120. return ele.oilGunId == this.selectedGas.oilGunId
  121. })
  122. if (len.length === 0) {
  123. return true
  124. }
  125. return false
  126. },
  127. avalibleSettle() {
  128. return !!this.account && this.account > 0 && !!this.selectedGas
  129. }
  130. },
  131. methods: {
  132. ...mapMutations(["updateOrderInfo", "updateSelectedGas"]),
  133. init() {
  134. // 轮播图
  135. this.$Request({
  136. url: "/getStationPicList",
  137. method: "GET",
  138. data: {
  139. stationId: this.stationId
  140. }
  141. }).then((res) => {
  142. if (res.retCode === 0) {
  143. this.stationPicList = res.data
  144. }
  145. })
  146. // 通知消息
  147. this.$Request({
  148. url: "/getStationNoticeInfo",
  149. method: "GET",
  150. data: {
  151. stationId: this.stationId
  152. }
  153. }).then((res) => {
  154. if (res.retCode === 0) {
  155. this.notice = res.data.notice.toString()
  156. }
  157. })
  158. // 获得油枪列表
  159. this.$Request({
  160. url: "/stationOilGunList",
  161. data: {
  162. stationId: this.stationId
  163. }
  164. }).then((res) => {
  165. if (res.retCode === 0) {
  166. this.gasList = res.data
  167. }
  168. })
  169. },
  170. change(e) {
  171. this.current = e.detail.current;
  172. },
  173. openMoreGun() {
  174. this.$refs.popup.open()
  175. },
  176. closeMoreGun() {
  177. this.$refs.popup.close()
  178. },
  179. selectGas(ele) {
  180. this.selectedGas = ele
  181. this.updateSelectedGas(ele)
  182. },
  183. selectGasPopup(ele) {
  184. this.updateSelectedGas(ele)
  185. this.selectedGas = ele
  186. this.$refs.popup.close()
  187. },
  188. selectAccount(ele) {
  189. this.account = ele
  190. },
  191. creatOrder() {
  192. if (!getPermission()) {
  193. return
  194. }
  195. this.loading = true
  196. uni.showLoading({
  197. title: '订单创建中...',
  198. mask: true
  199. });
  200. this.$Request({
  201. url: "/AddPayOrderInfoNew",
  202. method: "POST",
  203. data: {
  204. "userType": "2",
  205. "openId": this.openId,
  206. "stationId": this.stationId,
  207. "orderType": this.selectedGas.oilGunType, //油品是1 非油品2
  208. "receivableAmt": this.account,
  209. "oilName": this.selectedGas.oilName,
  210. "payType": "wx", //wx 微信 dzk电子卡
  211. "oilGun": this.selectedGas.oilGunNo
  212. }
  213. }).then((res) => {
  214. if (res.retCode === 0) {
  215. console.log(res.data)
  216. this.updateOrderInfo(res.data)
  217. this.loading = false
  218. uni.hideLoading();
  219. uni.navigateTo({
  220. url: "/pages/confirm/confirm"
  221. })
  222. } else {
  223. this.loading = false
  224. uni.hideLoading();
  225. uni.showToast({
  226. title: '创建订单失败'
  227. })
  228. }
  229. }).catch((err) => {
  230. uni.showToast({
  231. title: '创建订单失败'
  232. })
  233. }).finally((res) => {
  234. this.loading = false
  235. })
  236. },
  237. inputAccount(e) {
  238. if(isNaN(+ e.detail.value)){
  239. this.account = ''
  240. return
  241. }
  242. this.account = (+ e.detail.value).toFixed(2).toString()
  243. // // const reg = /^[1-9]{1,}(\.)?([0-9]{0,2})?/ // 最小数额1
  244. // const reg = /^[0-9]{1,}(\.)?([0-9]{0,2})?/ // 不设置最小数额
  245. // let res = e.detail.value.match(reg, "");
  246. // console.log(this)
  247. // console.log(res)
  248. // if(res === null){
  249. // this.account = ""
  250. // return
  251. // }
  252. // res = res[0]
  253. // const reg1 = /\.$/
  254. // res = + res.replace(reg1, '')
  255. // if (res == 0) {
  256. // this.account = ''
  257. // return
  258. // }
  259. // this.account = res.toString()
  260. // setTimeout(() => {
  261. // this.account = res.toString()
  262. // }, 0)
  263. }
  264. }
  265. }
  266. </script>
  267. <style lang="scss">
  268. page {
  269. width: 750rpx;
  270. .content {
  271. swiper {
  272. height: 389rpx;
  273. swiper-item {
  274. image {
  275. width: 100%;
  276. height: 100%;
  277. border-radius: 30rpx;
  278. }
  279. }
  280. }
  281. .box {
  282. box-sizing: border-box;
  283. width: 750rpx;
  284. background: #FFFFFF;
  285. border-radius: 36rpx 36rpx 0px 0px;
  286. box-shadow: 0 -2rpx 2rpx rgba(0, 0, 0, 0.1);
  287. padding: 40rpx;
  288. display: flex;
  289. flex-direction: column;
  290. .title {
  291. display: flex;
  292. justify-content: space-between;
  293. .left {
  294. height: 42rpx;
  295. font-size: 32rpx;
  296. font-family: PingFangSC-Medium, PingFang SC;
  297. font-weight: 600;
  298. color: #111111;
  299. line-height: 45rpx;
  300. text {
  301. font-weight: 500;
  302. color: #b0b0b0;
  303. font-size: 28rpx;
  304. margin-left: 8rpx;
  305. }
  306. .selected {
  307. color: #ff0000;
  308. font-weight: 500;
  309. }
  310. }
  311. .right {
  312. height: 40rpx;
  313. font-size: 28rpx;
  314. color: #AAAAAA;
  315. line-height: 40rpx;
  316. margin-top: 4rpx;
  317. }
  318. }
  319. .notice-bar-container {
  320. margin-top: 20rpx;
  321. .notice-bar,
  322. .uni-noticebar {
  323. margin: 0;
  324. border-radius: 20rpx;
  325. overflow: hidden;
  326. }
  327. }
  328. .gun {
  329. display: flex;
  330. flex-wrap: wrap;
  331. justify-content: space-around;
  332. align-content: space-around;
  333. margin-top: 30rpx;
  334. view {
  335. width: 200rpx;
  336. height: 110rpx;
  337. background: rgba(255, 255, 255, 0.08);
  338. box-shadow: 0px 2rpx 9rpx 4rpx rgba(16, 178, 125, 0.1);
  339. border-radius: 12rpx;
  340. display: flex;
  341. flex-direction: column;
  342. justify-content: center;
  343. text-align: center;
  344. margin-bottom: 20rpx;
  345. text {
  346. font-size: 28rpx;
  347. font-weight: 500;
  348. color: #666666;
  349. line-height: 40rpx;
  350. }
  351. text:nth-child(1) {
  352. margin-top: 10rpx;
  353. color: #7c7c7c;
  354. font-size: 20rpx;
  355. line-height: 40rpx;
  356. }
  357. text:nth-child(2) {
  358. font-size: 25rpx;
  359. line-height: 60rpx;
  360. font-weight: 500;
  361. }
  362. text.more {
  363. font-size: 28rpx;
  364. font-weight: 500;
  365. color: #000;
  366. line-height: 100rpx;
  367. margin-top: 0;
  368. }
  369. }
  370. view.selected {
  371. background-color: #0ea374;
  372. text {
  373. color: #FFFFFF;
  374. }
  375. }
  376. }
  377. .title:nth-of-type(4) {
  378. margin-top: 10rpx;
  379. }
  380. .amount {
  381. margin-top: 30rpx;
  382. .inp {
  383. width: 670rpx;
  384. height: 100rpx;
  385. background: rgba(255, 255, 255, 0.08);
  386. box-shadow: 0px 2rpx 9rpx 4rpx rgba(16, 178, 125, 0.1);
  387. border-radius: 13rpx;
  388. position: relative;
  389. input {
  390. position: absolute;
  391. top: 30rpx;
  392. left: 30rpx;
  393. color: #ff0000;
  394. font-weight: 600;
  395. }
  396. text {
  397. position: absolute;
  398. top: 40rpx;
  399. right: 30rpx;
  400. width: 56rpx;
  401. height: 33rpx;
  402. font-size: 24rpx;
  403. color: #AAAAAA;
  404. line-height: 33rpx;
  405. }
  406. }
  407. .btn {
  408. display: flex;
  409. justify-content: space-between;
  410. align-items: center;
  411. margin-top: 20rpx;
  412. view {
  413. width: 153rpx;
  414. height: 80rpx;
  415. background: rgba(255, 255, 255, 0.08);
  416. box-shadow: 0px 2rpx 9rpx 4rpx rgba(16, 178, 125, 0.1);
  417. border-radius: 13rpx;
  418. text-align: center;
  419. line-height: 80rpx;
  420. font-size: 32rpx;
  421. color: #AAAAAA;
  422. }
  423. .selected {
  424. background-color: #0ea374;
  425. color: #fff;
  426. }
  427. }
  428. }
  429. .tip {
  430. display: flex;
  431. justify-content: center;
  432. align-items: center;
  433. height: 60rpx;
  434. margin-top: 20rpx;
  435. image {
  436. display: inline-block;
  437. width: 25rpx;
  438. height: 25rpx;
  439. border-radius: 12.5rpx;
  440. }
  441. text {
  442. font-size: 27rpx;
  443. color: #DB9D28;
  444. line-height: 60rpx;
  445. padding: 0;
  446. margin: 0;
  447. }
  448. }
  449. .submit {
  450. height: 80rpx;
  451. margin-top: 20rpx;
  452. button {
  453. width: 670rpx;
  454. height: 80rpx;
  455. background: #CCCCCC;
  456. border-radius: 45rpx;
  457. font-size: 32rpx;
  458. color: #FFFFFF;
  459. line-height: 80rpx;
  460. text-align: center;
  461. }
  462. button.avalible {
  463. background: #0EA374;
  464. }
  465. }
  466. }
  467. }
  468. .more-gun {
  469. width: 750rpx;
  470. max-height: 985rpx;
  471. background: #F8F8F8;
  472. border-radius: 42rpx 42rpx 0px 0px;
  473. .title {
  474. height: 80rpx;
  475. text-align: center;
  476. position: relative;
  477. text {
  478. width: 160rpx;
  479. font-size: 32rpx;
  480. font-weight: 600;
  481. color: #111111;
  482. line-height: 70rpx;
  483. }
  484. .icon {
  485. width: 45rpx;
  486. height: 45rpx;
  487. background-color: red;
  488. background: url(../../static/icon/6_d05_close.2x.png) no-repeat 0px 0px;
  489. background-size: 100% 100%;
  490. position: absolute;
  491. top: 10rpx;
  492. right: 40rpx;
  493. }
  494. }
  495. .gun-list {
  496. margin-top: 20rpx;
  497. scroll-view {
  498. padding: 0 30rpx;
  499. max-height: 850rpx;
  500. view {
  501. width: 200rpx;
  502. height: 110rpx;
  503. background: rgba(255, 255, 255, 0.08);
  504. box-shadow: 0px 2rpx 9rpx 4rpx rgba(16, 178, 125, 0.1);
  505. border-radius: 12rpx;
  506. display: inline-flex;
  507. flex-direction: column;
  508. justify-content: center;
  509. text-align: center;
  510. margin: 5rpx 15rpx 40rpx 15rpx;
  511. text {
  512. font-size: 28rpx;
  513. font-weight: 500;
  514. color: #666666;
  515. line-height: 40rpx;
  516. }
  517. text:nth-child(1) {
  518. margin-top: 10rpx;
  519. color: #7c7c7c;
  520. font-size: 20rpx;
  521. line-height: 40rpx;
  522. }
  523. text:nth-child(2) {
  524. font-size: 25rpx;
  525. line-height: 60rpx;
  526. font-weight: 500;
  527. }
  528. text.more {
  529. font-size: 28rpx;
  530. font-weight: 500;
  531. color: #000;
  532. line-height: 100rpx;
  533. margin-top: 0;
  534. }
  535. }
  536. .selected {
  537. background-color: #0ea374;
  538. text {
  539. color: #fff;
  540. }
  541. color: #fff;
  542. }
  543. }
  544. }
  545. }
  546. }
  547. </style>