rechargeSubmit.vue 7.3 KB

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