123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- <template>
- <view class="content">
- <view class="title">密码登录</view>
- <view class="form vflex">
- <u-input v-model="userInfo.name" placeholder="用户名/手机号"></u-input>
- <u-input :type="pwd_type" v-model="userInfo.password" placeholder="请输入密码">
- <template slot="suffix">
- <view @click="show_pwd" v-if="pwd_type == 'password'">
- <image src="/static/images/login/biyanjing.png" class="pwd_icon"></image>
- </view>
- <view @click="show_pwd" v-if="pwd_type == 'text'">
- <image src="/static/images/login/yanjing.png" class="pwd_icon"></image>
- </view>
- </template>
- </u-input>
- </view>
- <view class="hflex acenter">
- <u-checkbox-group @change="checkboxChange">
- <u-checkbox v-model="agree" shape="circle"></u-checkbox>
- </u-checkbox-group>
- <view class="text">阅读并同意<span class="read" @click="open(0)">《用户服务协议》</span>、<span class="read" @click="open(1)">《个人信息保护政策》</span></view>
- </view>
- <view class="button hflex acenter jcenter" @click="login">
- <view>登录</view>
- </view>
- <view class="hflex acenter jcenter bottom">
- <view class="text_style1" @click="codeLogin">验证码登录</view>
- <view style="margin: 0 10rpx;">|</view>
- <view class="text_style2" @click="forgotPwd">忘记密码</view>
- </view>
- <!-- 弹出层 -->
- <u-modal :show="showProtocol" :title="protocolTitle" confirmColor="#2988FE" @confirm="isRead" confirmText="我已阅读">
- <view class="slot-content">
- <rich-text :nodes="protocolContent"></rich-text>
- </view>
- </u-modal>
- </view>
- </template>
- <script>
- import $api from '@/static/js/api.js'
- var that = ''
- export default {
- data() {
- return {
- userInfo: {
- name: '',
- password: ''
- },
- pwd_type: 'password',
- agree: false,
- showProtocol: false,
- protocolTitle: '',
- protocolContent: '',
- }
- },
- onLoad() {
- that = this
- },
- methods: {
- // 查看密码
- show_pwd() {
- if(that.pwd_type == 'text') {
- that.pwd_type = 'password'
- } else {
- that.pwd_type = 'text'
- }
- },
- // 阅读并同意
- checkboxChange(n) {
- this.agree = !this.agree
- },
- // 打开弹出层
- open(index) {
- const that = this
- // if(index == 0) {
- // $api.req({
- // url: '/api/Publics/config_info'
- // }, function(res) {
- // if (res.code == 1) {
- // that.protocolTitle = '用户协议'
- // that.protocolContent = res.data.xieyi
- // }
- // })
-
- // } else {
- // that.protocolTitle = '隐私政策'
- // that.protocolContent = ''
- // }
- // that.showProtocol = true
- },
- // 登录
- login() {
- if ($api.formCheck(that.userInfo.name,"required") && $api.formCheck(that.userInfo.password, "password")) {
- if (!that.agree) {
- $api.info('请先阅读并同意用户协议和隐私协议')
- } else {
- $api.req({
- url: '/data/api.Login/in',
- method: 'POST',
- data: {
- phone: that.userInfo.name,
- password: that.userInfo.password,
- }
- }, function(res) {
- console.log(res)
- if(res.code == 1) {
- wx.setStorageSync("token",res.data.token)
- wx.setStorageSync("id",res.data.id)
- var options = {
- user: res.data.id.toString(),
- pwd: '123456',
- appKey: uni.WebIM.config.appkey,
- success: function (res2) {
- wx.setStorageSync("HXtoken",res2.access_token)
- $api.jump('/pages/tabbar/mine/mine',3)
- },
- error: function(){
- }
- };
- uni.WebIM.conn.open(options);
- // $api.jump('/pages/tabbar/mine/mine',3)
- /* uni.WebIM.conn.open({
- user: res.data.id,
- pwd: "123456",
- appKey: uni.WebIM.config.appkey
- })
- .then((res2) => {
- console.log("login success",res2);
- wx.setStorageSync("HXtoken",res2.access_token)
- $api.jump('/pages/tabbar/mine/mine',3)
- })
- .catch((reason) => {
- console.log("login fail", reason);
- }); */
- } else {
- $api.info(res.info)
- }
- })
- }
- }
- },
- // 已阅读
- isRead() {
- that.showProtocol = false
- that.agree = true
- },
- // 去验证码登录
- codeLogin() {
- $api.jump('/pages/login/code_login')
- },
- // 忘记密码
- forgotPwd() {
- $api.jump('/pages/login/forgot_pwd')
- }
- },
- }
- </script>
- <style lang="scss" scoped>
- .content::v-deep {
- padding: 0 60rpx;
- .title {
- margin: 64rpx 0;
- font-size: 52rpx;
- color: #222;
- }
- .form {
- margin-bottom: 100rpx;
- .u-input {
- width: 630rpx !important;
- height: 104rpx !important;
- background-color: #f4f4f4;
- border-radius: 52rpx;
- font-size: 30rpx !important;
- box-sizing: border-box;
- padding: 30rpx 48rpx !important;
- margin: 26rpx 0;
- }
- .pwd_icon {
- width: 40rpx;
- height: 40rpx;
- }
- }
- .text {
- font-size: 24rpx;
- color: #9c9c9c;
- }
- .read {
- color: #2a63f3;
- }
- .button {
- width: 100%;
- height: 96rpx;
- background-color: #506dff;
- border-radius: 50rpx;
- box-shadow: 0 4rpx 28rpx 0 rgba(132,123,255,0.4);
- font-size: 40rpx;
- color: #fff;
- margin: 40rpx 0 36rpx;
- }
- .bottom {
- width: 100%;
- .text_style1 {
- font-size: 24rpx;
- color: #555;
- }
- .text_style2 {
- font-size: 24rpx;
- color: #506dff;
- }
- }
- }
- </style>
|