rechargeSubmit.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <view>
  3. <ujp-navbar title="绑定充电卡" :isBack="isBack">
  4. </ujp-navbar>
  5. <view class="recharge" v-show="!queryInfo">
  6. <view class="recharge-text">
  7. <view class="recharge-title">绑定卡号
  8. <span style="color: red;">*</span>
  9. </view>
  10. <view class="recharge-value">
  11. <u-input v-model="cardNo" :custom-style="customStyle" :placeholder-style="placeholderStyle"
  12. :height="height" placeholder="请填写绑定卡号"></u-input>
  13. </view>
  14. </view>
  15. <view class="recharge-text" style="margin: 16rpx 0;">
  16. <view class="recharge-title">充电卡状态</view>
  17. <view class="recharge-value FF7B00 ">
  18. {{cardText}}
  19. </view>
  20. </view>
  21. <view class="recharge-text">
  22. <view class="recharge-title">手机号码
  23. <span style="color: red;">*</span>
  24. </view>
  25. <view class="recharge-value">
  26. <u-input v-model="phone" :custom-style="customStyle" :placeholder-style="placeholderStyle"
  27. :height="height" placeholder="请填写绑定手机号"></u-input>
  28. </view>
  29. </view>
  30. <view class="recharge-text">
  31. <view class="recharge-title">验证码
  32. <span style="color: red;">*</span>
  33. </view>
  34. <view class="recharge-value">
  35. <u-input v-model="code" :custom-style="customStyle" :placeholder-style="placeholderStyle"
  36. :height="height" placeholder="请填写验证码"></u-input>
  37. </view>
  38. <view class="login-code" @click="getCode">
  39. {{codeTips}}
  40. </view>
  41. </view>
  42. <view class="recharge-text">
  43. <view class="recharge-title">用户姓名</view>
  44. <view class="recharge-value">
  45. <u-input v-model="name" :custom-style="customStyle" :placeholder-style="placeholderStyle"
  46. :height="height" placeholder="请填写用户姓名"></u-input>
  47. </view>
  48. </view>
  49. <view>
  50. <span style="color: red; font-size: 36rpx;margin-right: 12rpx;">* 为必填项</span>
  51. </view>
  52. <view class="foot-btn">
  53. <u-button type="primary" @click="submit" shape="square">发卡</u-button>
  54. </view>
  55. </view>
  56. <view class="recharge" v-show="queryInfo">
  57. <view class="recharge-text">
  58. <view class="recharge-title">绑定卡号</view>
  59. <view class="recharge-value">
  60. {{cardNo}}
  61. </view>
  62. </view>
  63. <view class="recharge-text">
  64. <view class="recharge-title">手机号码</view>
  65. <view class="recharge-value">
  66. {{phone}}
  67. </view>
  68. </view>
  69. <view class="recharge-text">
  70. <view class="recharge-title">用户姓名</view>
  71. <view class="recharge-value">
  72. {{name}}
  73. </view>
  74. </view>
  75. <view class="recharge-text">
  76. <view class="recharge-title">绑定状态</view>
  77. <view class="recharge-value color3a7cf6 ">
  78. 已绑定
  79. </view>
  80. </view>
  81. <view class="foot-btn">
  82. <u-button type="primary" @click="gotoUrl('pages/user/rechargeByPhone?phone='+phone)" shape="square">前往充值</u-button>
  83. </view>
  84. </view>
  85. <u-verification-code change-text="已发送(Xs)" :seconds="sendMsgSecond" ref="uCode" @change="codeChange" @end="end" @start="start">
  86. </u-verification-code>
  87. </view>
  88. </template>
  89. <script>
  90. import {
  91. checkPhone
  92. } from '@/utils'
  93. import * as API from '@/apis/otherRecharge.js'
  94. export default {
  95. data() {
  96. return {
  97. isReady: true,
  98. height: 82,
  99. customStyle: {
  100. 'font-size': '42rpx',
  101. 'line-height': '42rpx',
  102. },
  103. placeholderStyle: {
  104. 'font-size': '42rpx',
  105. 'line-height': '42rpx',
  106. 'color': ' rgba(204, 204, 204, 1)',
  107. },
  108. cardNo:"",
  109. name:"",
  110. phone:"",
  111. code: '',
  112. queryCard:{},
  113. queryInfo:false,
  114. cardText:"请输入",
  115. codeTips: '',
  116. isSendMsgIng: false,
  117. sendMsgSecond: 60 * 1,
  118. }
  119. },
  120. onLoad(op) {
  121. //cardText
  122. },
  123. onReady() {
  124. var time = this.carhelp.get("getvcodetime");
  125. if (time) {
  126. //this.$refs.uCode.start();
  127. var nowtime = new Date().getTime()
  128. var differ = (nowtime - time) / 1000
  129. if (differ < 1* 60) {
  130. this.sendMsgSecond = 1* 60 - parseInt(differ)
  131. this.isSendMsgIng = true;
  132. this.$refs.uCode.start();
  133. }
  134. }
  135. },
  136. watch:{
  137. cardNo(old){
  138. if(old){
  139. this.findByCard()
  140. }else{
  141. this.cardText="请输入";
  142. }
  143. }
  144. },
  145. methods: {
  146. codeChange(text) {
  147. this.codeTips = text;
  148. },
  149. end() {
  150. this.sendMsgSecond = 1* 60;
  151. this.isSendMsgIng = false;
  152. },
  153. start() {
  154. if (!this.isSendMsgIng) {
  155. uni.showLoading({
  156. title: "加载中",
  157. mask: true,
  158. })
  159. API.getVerifyCode(this.phone).then((response) => {
  160. uni.hideLoading();
  161. if (response.data=!"") {
  162. this.carhelp.set("getvcodetime", new Date().getTime());
  163. //倒计时
  164. uni.showToast({
  165. title: "发送成功"
  166. })
  167. } else {
  168. uni.showToast({
  169. title: "您的验证码已经发送[5分钟有效],请勿重复点击"
  170. })
  171. }
  172. }).catch(error => {
  173. uni.showToast({
  174. title: error,
  175. icon: "none"
  176. })
  177. })
  178. }
  179. },
  180. getCode() {
  181. if (this.$refs.uCode.canGetCode) {
  182. } else {
  183. uni.showToast({
  184. title: '您的验证码[5分钟有效],请勿重复点击',
  185. icon: "none"
  186. })
  187. return
  188. }
  189. var checkPhoneResult = checkPhone(this.phone);
  190. if ( checkPhoneResult !== true) {
  191. uni.showToast({
  192. title: checkPhoneResult,
  193. })
  194. return;
  195. }
  196. this.$refs.uCode.start();
  197. },
  198. submitApi() {
  199. uni.showLoading({
  200. title: "加载中",
  201. mask: true,
  202. })
  203. API.bindCard({
  204. cardNo: this.cardNo,
  205. phone: this.phone,
  206. name: this.name,
  207. verifyCode: this.code,
  208. }).then((response) => {
  209. var data = response.data
  210. uni.hideLoading()
  211. this.queryInfo=true
  212. }).catch(error => {
  213. uni.showToast({
  214. title: error
  215. })
  216. })
  217. },
  218. findByCard(){
  219. API.findByCard({
  220. cardNo: this.cardNo,
  221. }).then((response) => {
  222. var data = response.data
  223. if(data.regUser){
  224. this.cardText="当前卡号已被其他用户绑定";
  225. }else{
  226. this.cardText="未绑定";
  227. }
  228. }).catch(error => {
  229. this.cardText=error;
  230. })
  231. },
  232. submit() {
  233. if (!this.cardNo) {
  234. uni.showToast({
  235. title: "请填写绑定卡号",
  236. })
  237. return;
  238. }
  239. if (!this.phone) {
  240. uni.showToast({
  241. title: "请填写绑定手机号",
  242. })
  243. return;
  244. }
  245. if (!this.code) {
  246. uni.showToast({
  247. title: "请填写验证码"
  248. })
  249. return
  250. }
  251. var checkPhoneResult = checkPhone(this.phone);
  252. if (checkPhoneResult !== true) {
  253. uni.showToast({
  254. title: checkPhoneResult,
  255. })
  256. return;
  257. }
  258. uni.showLoading({
  259. title: "加载中",
  260. mask: true,
  261. })
  262. API.findByCard({
  263. cardNo: this.cardNo,
  264. }).then((response) => {
  265. var data = response.data
  266. uni.hideLoading()
  267. if(data.regUser){
  268. uni.showModal({
  269. title:"提示",
  270. content:"当前卡号已被其他用户绑定",
  271. showCancel:false,
  272. })
  273. }else{
  274. this.submitApi()
  275. }
  276. }).catch(error => {
  277. uni.hideLoading()
  278. uni.showModal({
  279. title:"提示",
  280. content:error,
  281. showCancel:false,
  282. })
  283. })
  284. },
  285. },
  286. onShow() {
  287. if (this.isReady) {
  288. }
  289. }
  290. }
  291. </script>
  292. <style>
  293. page {
  294. background-color: #f7f7f7;
  295. }
  296. </style>
  297. <style lang="scss" scoped>
  298. .FF7B00 {
  299. color: #FF7B00;
  300. }
  301. .color3a7cf6{
  302. color: #58ba73;
  303. }
  304. .foot-btn{
  305. margin-top: 80rpx;
  306. }
  307. .recharge {
  308. padding:0 30rpx 30rpx 30rpx;
  309. //background-color: #1677FF;
  310. background-color: #fff;
  311. margin-bottom: 20rpx;
  312. .recharge-text {
  313. font-size: 36rpx;
  314. padding:12rpx;
  315. width: 100%;
  316. display: flex;
  317. align-items: center;
  318. border-bottom: 1px solid #eeeeee;
  319. .recharge-title {
  320. min-width: 30%;
  321. color: rgb(96, 98, 102);
  322. }
  323. }
  324. }
  325. .login-code {
  326. color: #1677ff;
  327. white-space: pre;
  328. }
  329. </style>