login.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view class="bg">
  3. <image src="https://axure-file.lanhuapp.com/md5__f93627286149f825890eb821ab5d5abb.png" class="pic" mode="widthFix"></image>
  4. <view class="xy">
  5. <u-checkbox-group class="checkbox" v-model="item.checked">
  6. <u-checkbox size="15" shape="circle" label="我已阅读并同意" labelSize="14" name="true"></u-checkbox>
  7. </u-checkbox-group>
  8. <text class="a" @click="go('/pages/other/agreement?title=用户协议')">《用户协议》</text>
  9. <text>和</text>
  10. <text class="a" @click="go('/pages/other/agreement?title=隐私政策')">《隐私政策》</text>
  11. </view>
  12. <button class="btn" @click="getUserProfile()" :disabled="disabled">
  13. <text class="icon">&#xe62d;</text>
  14. <text>用户登录</text>
  15. </button>
  16. <button class="btn" style="background-color: #607d8b" @click="go('/pages/user/loginDoctor')">
  17. <text class="icon">&#xe6a3;</text>
  18. <text>医生登录</text>
  19. </button>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. item: {},
  27. disabled: false //防止重复点击
  28. };
  29. },
  30. methods: {
  31. getUserProfile() {
  32. let rule = [{ name: 'checked', checkType: 'notnull', errorMsg: '请同意并勾选协议' }];
  33. if (!this.verify.check(this.item, rule)) {
  34. uni.showModal({ content: this.verify.error, showCancel: false });
  35. return false;
  36. }
  37. this.disabled = true;
  38. let code = '';
  39. uni.login({
  40. provider: 'weixin',
  41. success: (res) => {
  42. code = res.code;
  43. }
  44. });
  45. //获取用户信息
  46. uni.getUserProfile({
  47. desc: '用于完善会员资料',
  48. lang: 'zh_CN',
  49. provider: 'weixin',
  50. success: (info) => {
  51. let item = info.userInfo;
  52. item.code = code;
  53. this.http.request({
  54. url: '/app/user/login',
  55. data: item,
  56. method: 'POST',
  57. success: (res) => {
  58. this.disabled = false;
  59. uni.setStorageSync('user', res.data.data);
  60. uni.navigateBack();
  61. },
  62. fail: (res) => {
  63. this.disabled = false;
  64. }
  65. });
  66. },
  67. fail: (res) => {
  68. this.disabled = false;
  69. }
  70. });
  71. },
  72. go(url) {
  73. uni.navigateTo({ url: url });
  74. }
  75. }
  76. };
  77. </script>
  78. <style lang="scss">
  79. .bg {
  80. padding: 30px;
  81. margin-top: -20px;
  82. .pic {
  83. width: 100%;
  84. border-radius: 5px;
  85. }
  86. .btn {
  87. .icon {
  88. padding-right: 5px;
  89. }
  90. }
  91. }
  92. </style>