login.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <view class="login">
  3. <view class="app_top">
  4. <view class="welcome">
  5. <view class="desc">您好,</view>
  6. <view class="desc">欢迎来到边民互市贸易</view>
  7. </view>
  8. <image src="../../static/images/my.png" mode="widthFix" class="img"></image>
  9. </view>
  10. <view class="dk">
  11. <view class="bg">
  12. <text class="icon">&#xe8b9;</text>
  13. <input type="number" v-model="form.phone" placeholder="请输入手机号" />
  14. </view>
  15. <view class="bg">
  16. <text class="icon">&#xe8b2;</text>
  17. <input :password="show" v-model="form.password" placeholder="请输入密码" />
  18. <view class="label"><view class="icon" :class="{ active: !show }" @click="show = !show">&#xe7a6;</view></view>
  19. </view>
  20. <view class="xy">
  21. <u-checkbox-group class="checkbox" v-model="form.checked">
  22. <u-checkbox size="15" shape="circle" label="我已阅读并同意" labelSize="13" name="true"></u-checkbox>
  23. </u-checkbox-group>
  24. <text class="a" @click="getAgreement(1)">《用户协议》</text>
  25. <text>和</text>
  26. <text class="a" @click="getAgreement(2)">《隐私政策》</text>
  27. </view>
  28. <button class="btn" @click="submit()">登录</button>
  29. <button class="btn register" @click="toRegister()">注册</button>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. data() {
  36. return {
  37. show: true,
  38. form: {
  39. phone: '',
  40. password: ''
  41. },
  42. rules: {
  43. phone: [
  44. {
  45. required: true,
  46. message: '请输入手机号',
  47. trigger: 'blur,change'
  48. },
  49. {
  50. // 自定义验证函数,见上说明
  51. validator: (rule, value, callback) => {
  52. // 上面有说,返回true表示校验通过,返回false表示不通过
  53. // uni.$u.test.mobile()就是返回true或者false的
  54. // return uni.$u.test.mobile(value);
  55. },
  56. message: '手机号码不正确',
  57. // 触发器可以同时用blur和change
  58. trigger: ['change', 'blur']
  59. }
  60. ],
  61. password: [
  62. {
  63. required: true,
  64. message: '请输入密码',
  65. trigger: 'blur,change'
  66. }
  67. ]
  68. },
  69. radioLabel: '',
  70. value: ['1']
  71. };
  72. },
  73. methods: {
  74. submit() {
  75. this.$refs.uForm
  76. .validate()
  77. .then(res => {
  78. let value = this.value;
  79. if (value.length == 0) {
  80. this.$common.toast('请先同意协议');
  81. return;
  82. }
  83. this.$api.doLogin(this.form).then(resp => {
  84. if (resp.code == 200) {
  85. let data = resp.data;
  86. uni.setStorageSync('token', data.tokenInfo.tokenValue);
  87. uni.setStorageSync('info', data.appUser);
  88. uni.setStorageSync('menu', data.per_list);
  89. this.$common.toBar('/pages/index/index');
  90. }
  91. });
  92. })
  93. .catch(errors => {
  94. uni.$u.toast('校验失败');
  95. });
  96. },
  97. toRegister() {
  98. this.$common.to('/pages/login/chooseRole');
  99. },
  100. getAgreement(id) {
  101. this.$common.to('/pages/login/userAgreement?id=' + id);
  102. }
  103. }
  104. };
  105. </script>
  106. <style lang="scss">
  107. page {
  108. background-color: white;
  109. }
  110. </style>