index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view class="content">
  3. <view class="status_bar"></view>
  4. <view class="content_body">
  5. <u-avatar src="/static/icon-40@3x.png" mode="square"></u-avatar>
  6. <view class="content_body_pswd">
  7. <u-cell-group>
  8. <u-field v-model="_login.userName" clearable type="text" label="用户名" placeholder="请填写用户名"></u-field>
  9. <u-field v-model="_login.passWord" clearable type="text" password label="密码" placeholder="请填写密码"></u-field>
  10. </u-cell-group>
  11. </view>
  12. <view class="read">
  13. <u-checkbox name="isRead" v-model="isRead">
  14. 已阅读
  15. <span class="agreement" @click="handleToAgreement">《xxx协议》</span>
  16. </u-checkbox>
  17. </view>
  18. <view class="content_body_btn">
  19. <u-button :ripple="true" type="success" @click="doLogin">登录</u-button>
  20. </view>
  21. </view>
  22. <view class=" u-flex u-row-around safe-area-inset-bottom content_footer">
  23. <text>找回密码</text>
  24. <text @tap="clickSheet">更多选项</text>
  25. </view>
  26. <u-action-sheet :list="list" @click="handleAction" v-model="show" border-radius="25" safe-area-inset-bottom></u-action-sheet>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. show: false,
  34. isRead: false,
  35. list: [
  36. {
  37. text: '切换账号',
  38. fontSize: '28'
  39. },
  40. {
  41. text: '注册',
  42. fontSize: '28'
  43. }
  44. ]
  45. };
  46. },
  47. onLoad() {},
  48. onShow() {},
  49. methods: {
  50. handleAction (i) {
  51. if (i === 1) {
  52. this.$u.route({
  53. url: 'pages/register/register'
  54. })
  55. }
  56. },
  57. handleToAgreement () {
  58. this.$u.route({
  59. url: 'pages/agreement/agreement'
  60. })
  61. },
  62. clickSheet() {
  63. this.show = true;
  64. },
  65. doLogin() {
  66. this.$socket.login(this._login.userName, this._login.passWord, null,res=>{
  67. if (res.success) {
  68. // 缓存用户
  69. this.$u.vuex('_user_info', res.response.data)
  70. this.$u.vuex('_login',this._login)
  71. // 缓存通讯录
  72. this.$socket.listGuests(this._user_info.id, res => {
  73. this.$u.vuex('firendList', res.response.data)
  74. })
  75. // 缓存链接
  76. this.$socket.getLinks(this._user_info.id, res=>{
  77. this.$u.vuex('links',res.response.data)
  78. });
  79. // 批量进入房间
  80. this.$socket.getGroups('', this._user_info.id, res => {
  81. let list = res.response.data;
  82. let groupIds = [];
  83. list.forEach(group=>groupIds.push(group.chatId));
  84. this.$socket.joinRoom(groupIds,res=>{})
  85. });
  86. // 跳转到消息列表
  87. this.$u.route({
  88. url: 'pages/home/home',
  89. type: 'switchTab'
  90. });
  91. } else {
  92. uni.showModal({
  93. title:res.reason + ",请稍后再试",
  94. showCancel:false
  95. })
  96. }
  97. })
  98. }
  99. }
  100. };
  101. </script>
  102. <style lang="scss" scoped>
  103. .content {
  104. overflow: hidden;
  105. .status_bar {
  106. height: var(--status-bar-height);
  107. width: 100%;
  108. }
  109. &_body {
  110. margin-top: 170rpx;
  111. text-align: center;
  112. &_tel {
  113. margin-top: 10rpx;
  114. }
  115. &_pswd {
  116. margin-top: 40rpx;
  117. }
  118. &_btn {
  119. margin-top: 120rpx;
  120. padding: 0 20rpx;
  121. }
  122. }
  123. &_footer {
  124. position: absolute;
  125. bottom: 50rpx;
  126. width: 100%;
  127. padding: 0 30rpx;
  128. text {
  129. color: #2979ff;
  130. }
  131. }
  132. .read {
  133. text-align: center;
  134. margin-top: 40rpx;
  135. }
  136. .agreement {
  137. color: red;
  138. }
  139. }
  140. </style>
  141. <style scoped>
  142. >>> .u-border-top:after {
  143. border-top-width: 0px;
  144. }
  145. </style>