phoneRecharge.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <div class="phoneRecharge">
  3. <div class="p_head">
  4. <img src="../../assets/image/payrollback_left@2x.png" class="leftIcon" alt="" @click="$router.replace('/index')">
  5. <span>
  6. <span>
  7. 手机充值
  8. </span>
  9. </span>
  10. </div>
  11. <div class="phoneCard">
  12. <!-- 选择手机卡 -->
  13. <div class="cardContent">
  14. <div class="selectCard">选择手机号</div>
  15. <el-form :model="phoneForm" :rules="phoneFormRule" ref="phoneForm">
  16. <el-form-item prop="phoneCard">
  17. <el-input v-model="phoneForm.phoneCard" placeholder="请输入11位手机号码" />
  18. </el-form-item>
  19. </el-form>
  20. <div class="alert">
  21. <img src="@/assets/image/cardAlert@2x.png" alt="">
  22. <span>请仔细核对手机号,避免造成不必要的损失。</span>
  23. </div>
  24. </div>
  25. <!-- 充值面额 -->
  26. <div class="denomination">
  27. <div style="font-family: PingFang SC;color:#333;">充值面额</div>
  28. <div>
  29. <div
  30. class="denominationCard"
  31. :class="{'activeBorder': idx == curAmountIdx}"
  32. v-for="(item, idx) in phone_amount" :key="item"
  33. @click="hPetrifaction(idx, item)">
  34. <span>{{item}}</span>
  35. <i>优惠价{{item * 0.99}}元</i>
  36. <div :class="{'active': idx == curAmountIdx}"></div>
  37. </div>
  38. </div>
  39. </div>
  40. <div class="recharfeBtn" @click="recharfeBtn">
  41. <img src="@/assets/image/rechargeBtn@2x.png" alt="">
  42. </div>
  43. <!-- 说明 -->
  44. <div class="explain">
  45. <div class="explainHead">
  46. <i></i>
  47. <span>充值说明</span>
  48. <i></i>
  49. </div>
  50. <ol>
  51. <li>1. 充值优惠来自充值平台补贴;</li>
  52. <li>2. 充值后1-10分钟左右到账,运营商将发充值成功短信至充值 手机;</li>
  53. <li>3. 如需开发票请至相应的手机运营商官方APP开取电子发票;</li>
  54. </ol>
  55. </div>
  56. </div>
  57. </div>
  58. </template>
  59. <script>
  60. import Http from '@/extend/Http';
  61. import {Message} from "element-ui";
  62. export default {
  63. name: 'phoneRecharge',
  64. data() {
  65. var validPhone = (rule, value, callback) => {
  66. if (!value) {
  67. return callback(new Error('手机号不能为空'));
  68. } else if (!/^1[3-9]\d{9}$/.test(value)) {
  69. return callback(new Error('请输入合法手机号'));
  70. } else {
  71. callback();
  72. }
  73. };
  74. return {
  75. // 手机号
  76. phoneForm: {
  77. phoneCard: '',
  78. },
  79. phoneFormRule: {
  80. phoneCard: [
  81. { validator: validPhone, trigger: 'blur' }
  82. ]
  83. },
  84. // 充值面额
  85. phone_amount: [],
  86. curAmountIdx: null,
  87. // 当前面额
  88. curAmount: ''
  89. }
  90. },
  91. created() {
  92. this.getDenomination()
  93. },
  94. watch: {
  95. '$route': {
  96. handler(newVal) {
  97. if (newVal.path == '/phoneRecharge' && !localStorage.getItem('access_token')) {
  98. router.replace('/login')
  99. }
  100. }
  101. }
  102. },
  103. methods: {
  104. handleClick(tab, event) {
  105. // console.log(tab, event);
  106. },
  107. // 获取充值面额
  108. async getDenomination() {
  109. let res = await Http.getInstance().getDenomination();
  110. console.log('手机面额', res);
  111. if (res && res.msg == '请求成功') {
  112. this.phone_amount = res.data.phone_amount
  113. }
  114. },
  115. // 选择石化充值面额
  116. hPetrifaction(idx, item) {
  117. this.curAmountIdx = idx
  118. this.curAmount = item
  119. },
  120. // 充值按钮
  121. recharfeBtn() {
  122. if (!this.curAmount) {
  123. Message({
  124. message: '请选择充值金额', type: "warning"
  125. });
  126. return
  127. }
  128. this.$refs.phoneForm.validate(async valid => {
  129. if (valid) {
  130. let res = await Http.getInstance().RechargeOrder({
  131. cardno: this.phoneForm.phoneCard,
  132. amount: this.curAmount
  133. });
  134. console.log('石化充值', res);
  135. if (res && res.msg == '请求成功') {
  136. localStorage.setItem('order_paying', JSON.stringify(res.data));
  137. this.$router.replace({
  138. name: 'opayment',
  139. params: {
  140. order_sn: res.data.order_sn,
  141. type: '1',
  142. recharfe: 'false'
  143. }
  144. });
  145. }
  146. }
  147. })
  148. }
  149. }
  150. }
  151. </script>
  152. <style lang="scss" scoped>
  153. .phoneRecharge {
  154. background-color: #EDF0F5;
  155. position: absolute;
  156. width: 100%;
  157. height: 100%;
  158. box-sizing: border-box;
  159. overflow: auto;
  160. }
  161. // 顶部导航
  162. .p_head{
  163. text-align: center;
  164. position: relative;
  165. top: 1.5rem;
  166. font-size: 2rem;
  167. // font-family: 'PingFang SC';
  168. margin-bottom: 3.667rem;
  169. // font-weight: bold;
  170. line-height: 1.5rem;
  171. .leftIcon{
  172. position: absolute;
  173. left: 1.667rem;
  174. top: 0.7rem;
  175. width: 0.667rem;
  176. }
  177. span {
  178. vertical-align: middle;
  179. }
  180. }
  181. .phoneCard {
  182. padding: 0 1.667rem 7.5rem;
  183. }
  184. .cardContent {
  185. height: 14rem;
  186. background-color: #fff;
  187. padding: 15px 20px;
  188. font-size: 1.167rem;
  189. border-radius: 1.667rem;
  190. font-family: PingFang SC;
  191. color: #333;
  192. .selectCard {
  193. margin-bottom: 1.667rem;
  194. }
  195. /deep/.el-input__inner {
  196. border: 0;
  197. border-bottom: 1px solid #BFBFBF;
  198. border-radius: 0;
  199. // margin-bottom: 1rem;
  200. padding-left: 0;
  201. }
  202. /deep/.el-form-item {
  203. margin-bottom: 10px;
  204. }
  205. .alert {
  206. font-size: 1.2rem;
  207. color: #F58520;
  208. padding-left: 0;
  209. padding-right: 0;
  210. img {
  211. width: 1.2rem;
  212. margin-right: 0.6rem;
  213. }
  214. span {
  215. vertical-align: middle;
  216. }
  217. }
  218. }
  219. .denomination {
  220. width: 100%;
  221. margin-top: 1.667rem;
  222. background-color: #fff;
  223. border-radius: 1.667rem;
  224. padding: 15px 20px;
  225. }
  226. .denominationCard {
  227. // width: 7.917rem;
  228. width: 29.3%;
  229. height: 5rem;
  230. border: 1px solid #E5E5E5;
  231. margin-right: 1.667rem;
  232. margin-top: 1.667rem;
  233. display: inline-block;
  234. // padding-left: 1rem;
  235. position: relative;
  236. span {
  237. display: block;
  238. font-size: 1.167rem;
  239. font-family: PingFang SC;
  240. font-weight: bold;
  241. color: #F58520;
  242. margin-top: 0.5rem;
  243. margin-bottom: 0.3rem;
  244. text-align: center;
  245. }
  246. i {
  247. display: block;
  248. text-align: center;
  249. font-style: normal;
  250. font-size: 1rem;
  251. font-family: PingFang SC;
  252. font-weight: 500;
  253. color: #666666;
  254. }
  255. }
  256. .denominationCard.activeBorder {
  257. border: 2px solid #F58520;
  258. }
  259. .denominationCard:nth-child(3n) {
  260. margin-right: 0;
  261. }
  262. .active {
  263. background-color: #F58520;
  264. -moz-opacity: 0.2;
  265. opacity:.20;
  266. position: absolute;
  267. top: 0;
  268. left: 0;
  269. width: 100%;
  270. height: 100%;
  271. }
  272. .recharfeBtn {
  273. margin: 2.5rem 0;
  274. img {
  275. width: 100%;
  276. }
  277. }
  278. .explainHead {
  279. // padding: 0 4.667rem;
  280. text-align: center;
  281. margin-bottom: 2.083rem;
  282. i {
  283. display: inline-block;
  284. font-style: normal;
  285. width: 6rem;
  286. height: 1px;
  287. background-color: #999;
  288. vertical-align: middle;
  289. }
  290. span {
  291. display: inline-block;
  292. font-size: 1.5rem;
  293. font-family: PingFang SC;
  294. font-weight: 500;
  295. color: #666666;
  296. margin: 0 1.25rem;
  297. }
  298. }
  299. ol li {
  300. font-size: 1.1rem;
  301. font-family: PingFang SC;
  302. font-weight: 500;
  303. color: #666666;
  304. margin-bottom: 1.667rem;
  305. }
  306. @media screen and (max-width: 411px) {
  307. .cardContent .alert {
  308. font-size: 1.1rem;
  309. }
  310. .denominationCard {
  311. margin-right: 1.3rem;
  312. }
  313. .explainHead i {
  314. width: 4rem;
  315. }
  316. }
  317. @media screen and (max-width: 360px) {
  318. .cardContent .alert {
  319. font-size: 1rem;
  320. padding-right: 0;
  321. }
  322. .denominationCard {
  323. margin-right: 1rem;
  324. width: 30%;
  325. i {
  326. -webkit-transform: scale(0.9);
  327. }
  328. }
  329. .explainHead i {
  330. width: 4rem;
  331. }
  332. }
  333. @media screen and (max-width: 350px) {
  334. .denominationCard {
  335. margin-right: 0.4rem;
  336. width: 31.8%;
  337. }
  338. .explainHead i {
  339. width: 3rem;
  340. }
  341. }
  342. @media screen and (max-width: 335px) {
  343. .denominationCard {
  344. width: 32%;
  345. }
  346. }
  347. @media screen and (max-width: 333px) {
  348. .cardContent .alert {
  349. font-size: 1rem;
  350. }
  351. .denominationCard {
  352. width: 34.5%;
  353. margin-right: 1.3rem;
  354. }
  355. .explainHead i {
  356. width: 2.5rem;
  357. }
  358. /deep/.el-tabs--border-card > .el-tabs__content {
  359. height: 14rem;
  360. }
  361. /deep/#tab-petrifaction,
  362. /deep/#tab-petroleum {
  363. padding-left: 2rem;
  364. padding-right: 0;
  365. }
  366. .cardContent .el-input__inner {
  367. font-size: 1rem;
  368. }
  369. .denominationCard:nth-child(3n) {
  370. margin-right: 1.667rem;
  371. }
  372. }
  373. </style>