index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <view class="login-wrapper" :style="colorStyle">
  3. <view class="whiteBg">
  4. <view class="list">
  5. <view class="item">
  6. <view class="acea-row row-middle">
  7. <image src="../static/bankcard.png" style="width: 34rpx;" mode="widthFix"></image>
  8. <input type="text" :placeholder="$t(`输入银行卡号`)" v-model="bank_code" />
  9. </view>
  10. </view>
  11. <view class="item">
  12. <view class="acea-row row-middle">
  13. <image src="../static/name.png" style="width: 34rpx;" mode="widthFix"></image>
  14. <input type="text" :placeholder="$t(`姓名`)" v-model="payer_name" />
  15. </view>
  16. </view>
  17. <view class="item">
  18. <view class="acea-row row-middle">
  19. <image src="../static/bankcard.png" style="width: 34rpx; " mode="widthFix"></image>
  20. <input type="text" :placeholder="$t(`身份证号`)" v-model="id_card" />
  21. </view>
  22. </view>
  23. <view class="item">
  24. <view class="acea-row row-middle">
  25. <image src="../static/phone_1.png" style="width: 24rpx; " mode="widthFix"></image>
  26. <input type="text" :placeholder="$t(`输入手机号码`)" v-model="account" :maxlength="11" />
  27. </view>
  28. </view>
  29. <view class="item">
  30. <view class="acea-row row-middle">
  31. <image src="../static/code_2.png" style="width: 28rpx;" mode="widthFix"></image>
  32. <input type="text" :placeholder="$t(`填写验证码`)" :maxlength="6" class="codeIput"
  33. v-model="captcha" />
  34. <button class="code" :disabled="disabled" :class="disabled === true ? 'on' : ''" @click="code">
  35. {{ text }}
  36. </button>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="logon" v-if="!bindCard" @click="loginMobile">{{$t(`绑定`)}}</view>
  41. <view class="logon" v-else @click="cancelBind">{{$t(`取消签约`)}}</view>
  42. <!-- TODO -->
  43. </view>
  44. <Verify @success="success" :captchaType="captchaType" :imgSize="{ width: '330px', height: '155px' }"
  45. ref="verify"></Verify>
  46. </view>
  47. </template>
  48. <script>
  49. import sendVerifyCode from "@/mixins/SendVerifyCode";
  50. import {
  51. saveCardBind,
  52. bindCardVerify,
  53. getCodeApi,
  54. getUserInfo,
  55. getCardBindStatus,
  56. bankCancel
  57. } from "@/api/user";
  58. import colors from '@/mixins/color.js';
  59. import Verify from '../components/verify/index.vue';
  60. export default {
  61. name: "Login",
  62. components: {
  63. Verify
  64. },
  65. mixins: [sendVerifyCode,colors],
  66. data: function() {
  67. return {
  68. bank_code: "",
  69. id_card: "",
  70. payer_name: "",
  71. account: "",
  72. password: "",
  73. captcha: "",
  74. type: "login",
  75. // 用户信息
  76. userInfo:{},
  77. bindCard:false,
  78. };
  79. },
  80. onLoad() {
  81. this.getCardBindStatus();
  82. this.getUserInfo();
  83. },
  84. mounted: function() {
  85. },
  86. methods: {
  87. // 解约
  88. cancelBind(){
  89. bankCancel().then(res => {
  90. that.$util.Tips({
  91. title: "签约已取消"
  92. });
  93. this.bindCard=false
  94. });
  95. },
  96. /**
  97. * 获取个人用户信息
  98. */
  99. getUserInfo: function() {
  100. let that = this;
  101. getUserInfo().then(res => {
  102. that.userInfo = res.data;
  103. that.bank_code=that.userInfo.bank_code;
  104. that.id_card=that.userInfo.bank_id;
  105. that.payer_name=that.userInfo.bank_name;
  106. that.account=that.userInfo.bank_mobile;
  107. });
  108. },
  109. success(data) {
  110. this.$refs.verify.hide()
  111. this.getCode(data);
  112. },
  113. code() {
  114. let that = this
  115. if (!that.account) return that.$util.Tips({
  116. title: that.$t(`请填写手机号码`)
  117. });
  118. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  119. title: that.$t(`请输入正确的手机号码`)
  120. });
  121. this.$refs.verify.show()
  122. },
  123. async loginMobile() {
  124. let that = this;
  125. if (!that.account) return that.$util.Tips({
  126. title: that.$t(`请填写手机号码`)
  127. });
  128. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  129. title: that.$t(`请输入正确的手机号码`)
  130. });
  131. if (!that.captcha) return that.$util.Tips({
  132. title: that.$t(`请填写验证码`)
  133. });
  134. if (!/^[\w\d]+$/i.test(that.captcha)) return that.$util.Tips({
  135. title: that.$t(`请输入正确的验证码`)
  136. });
  137. if (!that.payer_name) return that.$util.Tips({
  138. title: that.$t(`请填写姓名`)
  139. });
  140. if (!that.bank_code) return that.$util.Tips({
  141. title: that.$t(`请填写银行卡号`)
  142. });
  143. if (!that.id_card) return that.$util.Tips({
  144. title: that.$t(`请填写身份证号`)
  145. });
  146. saveCardBind({
  147. code: that.captcha,
  148. })
  149. .then(res => {
  150. let data = res.data;
  151. that.getCardBindStatus();
  152. })
  153. .catch(res => {
  154. that.$util.Tips({
  155. title: res
  156. });
  157. });
  158. },
  159. // 获取签约状态
  160. getCardBindStatus(){
  161. let that = this;
  162. getCardBindStatus().then((e)=>{
  163. console.log(e);
  164. if(e.data.status=='02'){
  165. that.$util.Tips({
  166. title: "已签约"
  167. });
  168. that.bindCard = true;
  169. }
  170. }).catch((e)=>{
  171. console.log(e);
  172. })
  173. },
  174. async getCode(data) {
  175. let that = this;
  176. if (!that.account) return that.$util.Tips({
  177. title: that.$t(`请填写手机号码`)
  178. });
  179. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  180. title: that.$t(`请输入正确的手机号码`)
  181. });
  182. if (!that.payer_name) return that.$util.Tips({
  183. title: that.$t(`请填写姓名`)
  184. });
  185. if (!that.bank_code) return that.$util.Tips({
  186. title: that.$t(`请填写银行卡号`)
  187. });
  188. if (!that.id_card) return that.$util.Tips({
  189. title: that.$t(`请填写身份证号`)
  190. });
  191. await bindCardVerify({
  192. mobile: that.account,
  193. payer_name: that.payer_name,
  194. bank_code: that.bank_code,
  195. id_card: that.id_card,
  196. })
  197. .then(res => {
  198. this.sendCode()
  199. that.$util.Tips({
  200. title: '验证码已发送'
  201. });
  202. })
  203. .catch(res => {
  204. that.$util.Tips({
  205. title: res
  206. });
  207. });
  208. },
  209. }
  210. };
  211. </script>
  212. <style>
  213. page {
  214. background: #fff;
  215. }
  216. </style>
  217. <style lang="scss">
  218. .code img {
  219. width: 100%;
  220. height: 100%;
  221. }
  222. .acea-row.row-middle {
  223. input {
  224. margin-left: 20rpx;
  225. display: block;
  226. }
  227. }
  228. .login-wrapper {
  229. padding: 30rpx;
  230. .whiteBg {
  231. .list {
  232. border-radius: 16rpx;
  233. overflow: hidden;
  234. .item {
  235. border-bottom: 1px solid #F0F0F0;
  236. background: #fff;
  237. .row-middle {
  238. position: relative;
  239. padding: 16rpx 45rpx;
  240. input {
  241. flex: 1;
  242. font-size: 28rpx;
  243. height: 80rpx;
  244. }
  245. .code {
  246. position: absolute;
  247. right: 30rpx;
  248. top: 50%;
  249. color: var(--view-theme);
  250. font-size: 26rpx;
  251. transform: translateY(-50%);
  252. }
  253. }
  254. }
  255. }
  256. .logon {
  257. display: flex;
  258. align-items: center;
  259. justify-content: center;
  260. width: 100%;
  261. height: 86rpx;
  262. margin-top: 80rpx;
  263. background-color: var(--view-theme);
  264. border-radius: 120rpx;
  265. color: #FFFFFF;
  266. font-size: 30rpx;
  267. }
  268. }
  269. }
  270. </style>