create.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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. 'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2684369054,623698254&fm=26&gp=0.jpg',
  91. 'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2684369054,623698254&fm=26&gp=0.jpg',
  92. 'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2684369054,623698254&fm=26&gp=0.jpg',
  93. ],
  94. gasarr: [],
  95. gasallarr: [],
  96. money: [200, 400, 600, 800],
  97. gas: 0,
  98. oName: '',
  99. account: ''
  100. };
  101. },
  102. created() {
  103. console.log(this.$route.query);
  104. },
  105. mounted() {
  106. var r = this.$axios.get('/stationOilGunList', {
  107. params: {
  108. stationId: this.$route.query.stationId
  109. },
  110. });
  111. r.then(res => {
  112. if (res.data.retCode == 0) {
  113. this.gasallarr = this.gasallarr.concat(res.data.data); //追加数据
  114. var gasarr = [];
  115. var gasallarr = [];
  116. var index = gasallarr.length;
  117. if (index > 5) {
  118. for (let i = index - 5; i <= index; i++) {
  119. gasarr.push(this.gasallarr[i]);
  120. }
  121. } else {
  122. for (let i = 0; i < 6; i++) {
  123. gasarr.push(this.gasallarr[i]);
  124. }
  125. }
  126. this.gasarr = gasarr;
  127. }
  128. })
  129. },
  130. methods: {
  131. selectGas: function(num, name) {
  132. this.gas = num;
  133. this.oName = name;
  134. this.showPopup = false;
  135. },
  136. selectGasAll: function(index, num) {
  137. var gasarr = [];
  138. if (index > 5) {
  139. for (let i = index - 5; i <= index; i++) {
  140. gasarr.push(this.gasallarr[i]);
  141. }
  142. } else {
  143. for (let i = 0; i < 6; i++) {
  144. gasarr.push(this.gasallarr[i]);
  145. }
  146. }
  147. this.gasarr = gasarr;
  148. this.gas = num;
  149. this.showPopup = false;
  150. },
  151. toConfirmOrder: function() {
  152. var $this = this;
  153. let data = {
  154. stationId: this.$route.query.stationId,
  155. oilGun: this.gas,
  156. oilName: this.oName,
  157. amt: '0.1',
  158. token: this.$route.query.openId,
  159. userType: '1'
  160. }
  161. var getOrderInfoUrl = '/AddPayOrderInfo';
  162. this.$axios.post(getOrderInfoUrl, data).then(res => {
  163. if (res.data.retCode == 0) {
  164. let stationId=data.stationId;
  165. let stationName=this.$route.query.stationName;
  166. let oilName=data.oilName;
  167. let gas = data.oilGun;
  168. let account = data.amt;
  169. let orderNo = res.data.data;
  170. let openId =data.token;
  171. this.$router.push({
  172. path: '/order/confirm',
  173. query: {
  174. stationId: stationId,
  175. stationName: stationName,
  176. gasNum: gas,
  177. oilName: oilName,
  178. account: account,
  179. orderNo: orderNo,
  180. openId:openId
  181. }
  182. });
  183. } else {
  184. Toast.fail('创建订单失败!请联系管理员');
  185. }
  186. })
  187. },
  188. toastMsg: function() {
  189. if (this.gas <= 0) {
  190. Toast.fail('请选择油枪');
  191. } else if (this.account <= 0) {
  192. Toast.fail('请输入金额');
  193. }
  194. }
  195. }
  196. })
  197. </script>
  198. <style lang="less">
  199. .my-swipe {
  200. z-index: 1;
  201. .van-swipe__indicators {
  202. bottom: 32px;
  203. }
  204. .van-swipe-item {
  205. color: #fff;
  206. font-size: 20px;
  207. line-height: 150px;
  208. text-align: center;
  209. background-color: #39a9ed;
  210. img {
  211. display: block;
  212. box-sizing: border-box;
  213. width: 100%;
  214. height: 185px;
  215. background-color: #fff;
  216. pointer-events: none;
  217. overflow: hidden;
  218. object-fit: cover;
  219. }
  220. }
  221. }
  222. .box {
  223. box-sizing: border-box;
  224. width: 100%;
  225. min-height: 60vh;
  226. background-color: #ffffff;
  227. border-radius: 20px 20px 0 0;
  228. position: absolute;
  229. top: 190px;
  230. left: 0;
  231. z-index: 999;
  232. box-shadow: 0 -2px 2px rgba(0, 0, 0, 0.1);
  233. padding: 0 15px 80px 15px;
  234. .van-button--primary {
  235. background-color: rgb(15, 179, 123);
  236. border-color: rgb(15, 179, 123);
  237. }
  238. h3 {
  239. font-size: 16px;
  240. small {
  241. font-size: 12px;
  242. color: #ccc;
  243. font-weight: normal;
  244. }
  245. span {
  246. font-size: 14px;
  247. color: #ccc;
  248. font-weight: normal;
  249. float: right;
  250. }
  251. }
  252. .input-box {
  253. position: relative;
  254. margin-bottom: 10px;
  255. .my-input {
  256. width: 100%;
  257. height: 44px;
  258. line-height: 44px;
  259. border: 0;
  260. border-radius: 5px;
  261. box-shadow: 0 1px 2px 2px rgba(15, 179, 123, 0.1);
  262. text-indent: 25px;
  263. font-size: 18px;
  264. font-weight: bold;
  265. }
  266. .input-left,
  267. .input-right {
  268. position: absolute;
  269. top: 0;
  270. z-index: 999;
  271. line-height: 44px;
  272. font-size: 12px;
  273. }
  274. .input-left {
  275. left: 10px;
  276. font-weight: bold;
  277. line-height: 46px;
  278. }
  279. .input-right {
  280. right: 10px;
  281. color: #999;
  282. }
  283. }
  284. .gas {
  285. margin-bottom: 10px;
  286. .van-button {
  287. line-height: 1.5em;
  288. border-radius: 3px;
  289. height: 54px;
  290. p {
  291. font-size: 9px;
  292. margin-block: 0;
  293. }
  294. }
  295. .van-button--default {
  296. background-color: #eee;
  297. color: rgb(102, 101, 104);
  298. }
  299. }
  300. .btn-money {
  301. border: 0;
  302. box-shadow: 0 1px 2px 2px rgba(15, 179, 123, 0.1);
  303. color: rgb(168, 170, 170);
  304. height: 40px;
  305. }
  306. .tips {
  307. padding: 10px;
  308. color: rgb(240, 180, 80);
  309. .van-icon {
  310. vertical-align: middle;
  311. }
  312. span {
  313. font-size: 14px;
  314. }
  315. }
  316. .van-popup {
  317. box-sizing: border-box;
  318. padding: 20px;
  319. top: 20vh;
  320. }
  321. .van-goods-action {
  322. height: 80px;
  323. padding: 0 15px;
  324. }
  325. }
  326. </style>