create.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <div>
  3. <van-swipe class="my-swipe" :autoplay="5000" indicator-color="#ffffff">
  4. <van-swipe-item v-for="(image, index) in images" :key="index">
  5. <img v-lazy="image" />
  6. </van-swipe-item>
  7. </van-swipe>
  8. <div class="box">
  9. <h3>
  10. 选择油枪号 | <small>选择所加油枪号</small>
  11. <span @click="showPopup=true">更多></span>
  12. </h3>
  13. <van-row gutter="10">
  14. <van-col span="8" v-for="(item, index) in gasarr" :key="index" class="gas">
  15. <van-button :type="gas==item.oilGunNo?'primary':'default'" block @click="selectGas(item.oilGunNo,item.oilName)">
  16. {{item.oilGunNo+'号枪'}}
  17. <p style="font-size: 16px;">{{item.oilName}}</p>
  18. </van-button>
  19. </van-col>
  20. </van-row>
  21. <h3>输入金额 | <small>建议询问加油员后输入</small></h3>
  22. <div class="input-box">
  23. <input type="number" :value="account" class="my-input">
  24. <span class="input-left">¥</span>
  25. <span class="input-right">(元)</span>
  26. </div>
  27. <van-row gutter="10">
  28. <van-col span="6" v-for="(item, index) in money" :key="index">
  29. <van-button type="default" block class="btn-money" @click="account=item">{{item}}</van-button>
  30. </van-col>
  31. </van-row>
  32. <center class="tips">
  33. <van-icon name="warning-o" /> <span>请勿在油机旁使用手机</span></center>
  34. <van-popup v-model="showPopup" round position="bottom" safe-area-inset-bottom>
  35. <center>
  36. <h3>选择油枪号</h3>
  37. </center>
  38. <van-row gutter="10">
  39. <van-col span="8" v-for="(item, index) in gasallarr" :key="index" class="gas">
  40. <van-button :type="gas==item.oilGunNo?'primary':'default'" block @click="selectGasAll(index, item.oilGunNo,item.oilName)">
  41. {{item.oilGunNo+'号枪'}}
  42. <p style="font-size: 16px;">{{item.oilName}}</p>
  43. </van-button>
  44. </van-col>
  45. </van-row>
  46. </van-popup>
  47. <van-goods-action>
  48. <van-goods-action-button type="primary" text="去结算" v-if="gas>0 && account>0" @click="toConfirmOrder()" />
  49. <van-goods-action-button text="去结算" color="#cdcbce" v-else @click="toastMsg" />
  50. </van-goods-action>
  51. </div>
  52. </div>
  53. </template>
  54. <script>
  55. import Vue from 'vue';
  56. import {
  57. Swipe,
  58. SwipeItem,
  59. Lazyload,
  60. Button,
  61. Col,
  62. Row,
  63. Popup,
  64. GoodsAction,
  65. GoodsActionButton,
  66. Icon,
  67. Toast
  68. } from 'vant';
  69. Vue.use(Swipe);
  70. Vue.use(SwipeItem);
  71. Vue.use(Lazyload);
  72. Vue.use(Button);
  73. Vue.use(Col);
  74. Vue.use(Row);
  75. Vue.use(Popup);
  76. Vue.use(GoodsAction);
  77. Vue.use(GoodsActionButton);
  78. Vue.use(Icon);
  79. Vue.use(Toast);
  80. export default Vue.extend({
  81. head() {
  82. return {
  83. title:'一键加油'
  84. }
  85. },
  86. data() {
  87. return {
  88. showPopup: false,
  89. images: [],
  90. gasarr: [],
  91. gasallarr: [],
  92. money: [200, 400, 600, 800],
  93. gas: 0,
  94. oName: '',
  95. account: ''
  96. };
  97. },
  98. created() {
  99. console.log(this.$route.query);
  100. },
  101. mounted() {
  102. var r = this.$axios.get('/stationOilGunList', {
  103. params: {
  104. stationId: this.$route.query.stationId
  105. },
  106. });
  107. r.then(res => {
  108. if (res.data.retCode == 0) {
  109. this.gasallarr = this.gasallarr.concat(res.data.data); //追加数据
  110. var gasarr = [];
  111. var gasallarr = [];
  112. var index = gasallarr.length;
  113. if (index > 5) {
  114. for (let i = index - 5; i <= index; i++) {
  115. gasarr.push(this.gasallarr[i]);
  116. }
  117. } else {
  118. for (let i = 0; i < 6; i++) {
  119. gasarr.push(this.gasallarr[i]);
  120. }
  121. }
  122. this.gasarr = gasarr;
  123. }
  124. })
  125. },
  126. methods: {
  127. selectGas: function(num, name) {
  128. this.gas = num;
  129. this.oName = name;
  130. this.showPopup = false;
  131. },
  132. selectGasAll: function(index, num) {
  133. var gasarr = [];
  134. if (index > 5) {
  135. for (let i = index - 5; i <= index; i++) {
  136. gasarr.push(this.gasallarr[i]);
  137. }
  138. } else {
  139. for (let i = 0; i < 6; i++) {
  140. gasarr.push(this.gasallarr[i]);
  141. }
  142. }
  143. this.gasarr = gasarr;
  144. this.gas = num;
  145. this.showPopup = false;
  146. },
  147. toConfirmOrder: function() {
  148. var $this = this;
  149. let data = {
  150. stationId: this.$route.query.stationId,
  151. oilGun: this.gas,
  152. oilName: this.oName,
  153. amt: '0.1',
  154. token: this.$route.query.openId,
  155. userType: '1'
  156. }
  157. var getOrderInfoUrl = '/AddPayOrderInfo';
  158. this.$axios.post(getOrderInfoUrl, data).then(res => {
  159. if (res.data.retCode == 0) {
  160. let stationId=data.stationId;
  161. let stationName=this.$route.query.stationName;
  162. let oilName=data.oilName;
  163. let gas = data.oilGun;
  164. let account = data.amt;
  165. let orderNo = res.data.data;
  166. let openId =data.token;
  167. this.$router.push({
  168. path: '/order/confirm',
  169. query: {
  170. stationId: stationId,
  171. stationName: stationName,
  172. gasNum: gas,
  173. oilName: oilName,
  174. account: account,
  175. orderNo: orderNo,
  176. openId:openId
  177. }
  178. });
  179. } else {
  180. Toast.fail('创建订单失败!请联系管理员');
  181. }
  182. })
  183. },
  184. toastMsg: function() {
  185. if (this.gas <= 0) {
  186. Toast.fail('请选择油枪');
  187. } else if (this.account <= 0) {
  188. Toast.fail('请输入金额');
  189. }
  190. }
  191. }
  192. })
  193. </script>
  194. <style lang="less">
  195. .my-swipe {
  196. z-index: 1;
  197. .van-swipe__indicators {
  198. bottom: 32px;
  199. }
  200. .van-swipe-item {
  201. color: #fff;
  202. font-size: 20px;
  203. line-height: 150px;
  204. text-align: center;
  205. background-color: #39a9ed;
  206. img {
  207. display: block;
  208. box-sizing: border-box;
  209. width: 100%;
  210. height: 185px;
  211. background-color: #fff;
  212. pointer-events: none;
  213. overflow: hidden;
  214. object-fit: cover;
  215. }
  216. }
  217. }
  218. .box {
  219. box-sizing: border-box;
  220. width: 100%;
  221. min-height: 60vh;
  222. background-color: #ffffff;
  223. border-radius: 20px 20px 0 0;
  224. position: absolute;
  225. top: 190px;
  226. left: 0;
  227. z-index: 999;
  228. box-shadow: 0 -2px 2px rgba(0, 0, 0, 0.1);
  229. padding: 0 15px 80px 15px;
  230. .van-button--primary {
  231. background-color: rgb(15, 179, 123);
  232. border-color: rgb(15, 179, 123);
  233. }
  234. h3 {
  235. font-size: 16px;
  236. small {
  237. font-size: 12px;
  238. color: #ccc;
  239. font-weight: normal;
  240. }
  241. span {
  242. font-size: 14px;
  243. color: #ccc;
  244. font-weight: normal;
  245. float: right;
  246. }
  247. }
  248. .input-box {
  249. position: relative;
  250. margin-bottom: 10px;
  251. .my-input {
  252. width: 100%;
  253. height: 44px;
  254. line-height: 44px;
  255. border: 0;
  256. border-radius: 5px;
  257. box-shadow: 0 1px 2px 2px rgba(15, 179, 123, 0.1);
  258. text-indent: 25px;
  259. font-size: 18px;
  260. font-weight: bold;
  261. }
  262. .input-left,
  263. .input-right {
  264. position: absolute;
  265. top: 0;
  266. z-index: 999;
  267. line-height: 44px;
  268. font-size: 12px;
  269. }
  270. .input-left {
  271. left: 10px;
  272. font-weight: bold;
  273. line-height: 46px;
  274. }
  275. .input-right {
  276. right: 10px;
  277. color: #999;
  278. }
  279. }
  280. .gas {
  281. margin-bottom: 10px;
  282. .van-button {
  283. line-height: 1.5em;
  284. border-radius: 3px;
  285. height: 54px;
  286. p {
  287. font-size: 9px;
  288. margin-block: 0;
  289. }
  290. }
  291. .van-button--default {
  292. background-color: #eee;
  293. color: rgb(102, 101, 104);
  294. }
  295. }
  296. .btn-money {
  297. border: 0;
  298. box-shadow: 0 1px 2px 2px rgba(15, 179, 123, 0.1);
  299. color: rgb(168, 170, 170);
  300. height: 40px;
  301. }
  302. .tips {
  303. padding: 10px;
  304. color: rgb(240, 180, 80);
  305. .van-icon {
  306. vertical-align: middle;
  307. }
  308. span {
  309. font-size: 14px;
  310. }
  311. }
  312. .van-popup {
  313. box-sizing: border-box;
  314. padding: 20px;
  315. top: 20vh;
  316. }
  317. .van-goods-action {
  318. height: 80px;
  319. padding: 0 15px;
  320. }
  321. }
  322. </style>