123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- <template>
- <view class="content">
- <view class="title">密码登录</view>
- <view class="form vflex">
- <u-input v-model="userInfo.name" placeholder="用户名/手机号"></u-input>
- <u-input type="password" v-if="pwd_type" v-model="userInfo.password" placeholder="请输入密码">
- <template slot="suffix">
- <view @click="show_pwd" class="icon_box">
- <image src="/static/images/login/biyanjing.png" class="pwd_icon"></image>
- </view>
- <!-- <view @click="show_pwd" v-else class="icon_box">
- <image src="/static/images/login/yanjing.png" class="pwd_icon"></image>
- </view> -->
- </template>
- </u-input>
- <u-input type="text" v-else v-model="userInfo.password" placeholder="请输入密码">
- <template slot="suffix">
- <view @click="show_pwd" class="icon_box">
- <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" iconSize="20">
- <u-checkbox v-model="agree" shape="circle" iconSize="20"></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: true,
- agree: false,
- showProtocol: false,
- protocolTitle: '',
- protocolContent: '',
- }
- },
- onLoad() {
- that = this
- },
- methods: {
- // 查看密码
- show_pwd() {
- if(that.pwd_type) {
- that.pwd_type = false
- } else {
- that.pwd_type = true
- }
- },
- // 阅读并同意
- checkboxChange(n) {
- this.agree = !this.agree
- },
- // 打开弹出层
- open(index) {
- const that = this
- $api.req({
- url: '/data/api.Login/getloginset'
- }, function(res) {
- if (res.code == 1) {
- if(index == 0) {
- uni.setStorageSync('xieyi',res.data.service_agreement)
- $api.jump('/pages/user/agreement?title=用户服务协议')
- } else {
- uni.setStorageSync('xieyi',res.data.protection_policy)
- $api.jump('/pages/user/agreement?title=个人隐私保护政策')
- }
- }
- })
- },
- // isRead() {
- // that.showProtocol = false
- // },
- // 登录
- login() {
- if (!that.agree) {
- $api.info('请先阅读并同意用户协议和隐私协议')
- } else {
- wx.getSetting({
- success (res){
- if (res.authSetting['scope.userInfo']) {
- // 已经授权,可以直接调用 getUserInfo 获取头像昵称
- wx.login({
- success: function(res) {
- console.log("getUserInfo:",res);
- uni.request({
- url: $api.config.baseUrl + '/data/api.Login/getOpenid',
- method: 'POST',
- data: {
- code: res.code
- },
- header: {
- 'content-type': 'application/json',
- 'api-name': 'wxapp'
- },
- success: (res) => {
- if(res.data.code == 1) {
- $api.req({
- url: '/data/api.Login/in',
- method: 'POST',
- data: {
- phone: that.userInfo.name,
- password: that.userInfo.password,
- openid: res.data.data.openid
- }
- }, function(res) {
- console.log(res)
- if(res.code == 1) {
- uni.setStorageSync("token",res.data.token)
- uni.setStorageSync("id",res.data.id)
- var options = {
- user: res.data.huanxinID,
- pwd: '12345678',
- appKey: uni.WebIM.config.appkey,
- success: function (res2) {
- uni.setStorageSync("myUsername",res.data.huanxinID)
- },
- error: function(){
- }
- };
- uni.WebIM.conn.open(options);
- $api.jump('/pages/tabbar/mine/mine',3)
- } 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;
- }
- .icon_box {
-
- }
- .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>
|