password_login.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <view class="content">
  3. <view class="title">密码登录</view>
  4. <view class="form vflex">
  5. <u-input v-model="userInfo.name" placeholder="用户名/手机号"></u-input>
  6. <u-input :type="pwd_type" v-model="userInfo.password" placeholder="请输入密码">
  7. <template slot="suffix">
  8. <view @click="show_pwd" v-if="pwd_type == 'password'">
  9. <image src="/static/images/login/biyanjing.png" class="pwd_icon"></image>
  10. </view>
  11. <view @click="show_pwd" v-if="pwd_type == 'text'">
  12. <image src="/static/images/login/yanjing.png" class="pwd_icon"></image>
  13. </view>
  14. </template>
  15. </u-input>
  16. </view>
  17. <view class="hflex acenter">
  18. <u-checkbox-group @change="checkboxChange">
  19. <u-checkbox v-model="agree" shape="circle"></u-checkbox>
  20. </u-checkbox-group>
  21. <view class="text">阅读并同意<span class="read" @click="open(0)">《用户服务协议》</span>、<span class="read" @click="open(1)">《个人信息保护政策》</span></view>
  22. </view>
  23. <view class="button hflex acenter jcenter" @click="login">
  24. <view>登录</view>
  25. </view>
  26. <view class="hflex acenter jcenter bottom">
  27. <view class="text_style1" @click="codeLogin">验证码登录</view>
  28. <view style="margin: 0 10rpx;">|</view>
  29. <view class="text_style2" @click="forgotPwd">忘记密码</view>
  30. </view>
  31. <!-- 弹出层 -->
  32. <u-modal :show="showProtocol" :title="protocolTitle" confirmColor="#2988FE" @confirm="isRead" confirmText="我已阅读">
  33. <view class="slot-content">
  34. <rich-text :nodes="protocolContent"></rich-text>
  35. </view>
  36. </u-modal>
  37. </view>
  38. </template>
  39. <script>
  40. import $api from '@/static/js/api.js'
  41. var that = ''
  42. export default {
  43. data() {
  44. return {
  45. userInfo: {
  46. name: '',
  47. password: ''
  48. },
  49. pwd_type: 'password',
  50. agree: false,
  51. showProtocol: false,
  52. protocolTitle: '',
  53. protocolContent: '',
  54. }
  55. },
  56. onLoad() {
  57. that = this
  58. },
  59. methods: {
  60. // 查看密码
  61. show_pwd() {
  62. if(that.pwd_type == 'text') {
  63. that.pwd_type = 'password'
  64. } else {
  65. that.pwd_type = 'text'
  66. }
  67. },
  68. // 阅读并同意
  69. checkboxChange(n) {
  70. this.agree = !this.agree
  71. },
  72. // 打开弹出层
  73. open(index) {
  74. const that = this
  75. // if(index == 0) {
  76. // $api.req({
  77. // url: '/api/Publics/config_info'
  78. // }, function(res) {
  79. // if (res.code == 1) {
  80. // that.protocolTitle = '用户协议'
  81. // that.protocolContent = res.data.xieyi
  82. // }
  83. // })
  84. // } else {
  85. // that.protocolTitle = '隐私政策'
  86. // that.protocolContent = ''
  87. // }
  88. // that.showProtocol = true
  89. },
  90. // 登录
  91. login() {
  92. if ($api.formCheck(that.userInfo.name,"required") && $api.formCheck(that.userInfo.password, "password")) {
  93. if (!that.agree) {
  94. $api.info('请先阅读并同意用户协议和隐私协议')
  95. } else {
  96. $api.req({
  97. url: '/data/api.Login/in',
  98. method: 'POST',
  99. data: {
  100. phone: that.userInfo.name,
  101. password: that.userInfo.password,
  102. }
  103. }, function(res) {
  104. console.log(res)
  105. if(res.code == 1) {
  106. wx.setStorageSync("token",res.data.token)
  107. wx.setStorageSync("id",res.data.id)
  108. var options = {
  109. user: res.data.id.toString(),
  110. pwd: '123456',
  111. appKey: uni.WebIM.config.appkey,
  112. success: function (res2) {
  113. wx.setStorageSync("HXtoken",res2.access_token)
  114. $api.jump('/pages/tabbar/mine/mine',3)
  115. },
  116. error: function(){
  117. }
  118. };
  119. uni.WebIM.conn.open(options);
  120. // $api.jump('/pages/tabbar/mine/mine',3)
  121. /* uni.WebIM.conn.open({
  122. user: res.data.id,
  123. pwd: "123456",
  124. appKey: uni.WebIM.config.appkey
  125. })
  126. .then((res2) => {
  127. console.log("login success",res2);
  128. wx.setStorageSync("HXtoken",res2.access_token)
  129. $api.jump('/pages/tabbar/mine/mine',3)
  130. })
  131. .catch((reason) => {
  132. console.log("login fail", reason);
  133. }); */
  134. } else {
  135. $api.info(res.info)
  136. }
  137. })
  138. }
  139. }
  140. },
  141. // 已阅读
  142. isRead() {
  143. that.showProtocol = false
  144. that.agree = true
  145. },
  146. // 去验证码登录
  147. codeLogin() {
  148. $api.jump('/pages/login/code_login')
  149. },
  150. // 忘记密码
  151. forgotPwd() {
  152. $api.jump('/pages/login/forgot_pwd')
  153. }
  154. },
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. .content::v-deep {
  159. padding: 0 60rpx;
  160. .title {
  161. margin: 64rpx 0;
  162. font-size: 52rpx;
  163. color: #222;
  164. }
  165. .form {
  166. margin-bottom: 100rpx;
  167. .u-input {
  168. width: 630rpx !important;
  169. height: 104rpx !important;
  170. background-color: #f4f4f4;
  171. border-radius: 52rpx;
  172. font-size: 30rpx !important;
  173. box-sizing: border-box;
  174. padding: 30rpx 48rpx !important;
  175. margin: 26rpx 0;
  176. }
  177. .pwd_icon {
  178. width: 40rpx;
  179. height: 40rpx;
  180. }
  181. }
  182. .text {
  183. font-size: 24rpx;
  184. color: #9c9c9c;
  185. }
  186. .read {
  187. color: #2a63f3;
  188. }
  189. .button {
  190. width: 100%;
  191. height: 96rpx;
  192. background-color: #506dff;
  193. border-radius: 50rpx;
  194. box-shadow: 0 4rpx 28rpx 0 rgba(132,123,255,0.4);
  195. font-size: 40rpx;
  196. color: #fff;
  197. margin: 40rpx 0 36rpx;
  198. }
  199. .bottom {
  200. width: 100%;
  201. .text_style1 {
  202. font-size: 24rpx;
  203. color: #555;
  204. }
  205. .text_style2 {
  206. font-size: 24rpx;
  207. color: #506dff;
  208. }
  209. }
  210. }
  211. </style>