login.vue 2.3 KB

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