|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398 |
- <template>
- <view>
- <view class="head">
- <image class="head-immg" src="https://autoiot.oss-cn-beijing.aliyuncs.com/static/login.png" mode=""></image>
- </view>
- <view class="input">
- <view class="">
- <view class="text-1">
- 您好,
- </view>
- <view class="text-2">
- 欢迎登录销讲助手~
- </view>
- </view>
- <view class="cwjs-cells item-flex" style="margin-top: 80rpx;">
- <view class="cwjs-item center">
- <image src="https://qufang.oss-cn-beijing.aliyuncs.com/channelHelper/user.png" class="logo_input">
- </image>
- <input class="cwjs-item cwjs-input" v-model="username" placeholder="请输入账号名" type="number"
- maxlength="11" placeholder-style="color:#aaa"/>
- </view>
- </view>
- <view class="cwjs-cells item-flex" style="margin-top:13rpx;">
- <view class="cwjs-item center">
- <image src="https://qufang.oss-cn-beijing.aliyuncs.com/channelHelper/lock.png" class="logo_input">
- </image>
- <input class="cwjs-item cwjs-input" placeholder="请输入密码" placeholder-style="color:#AAAAAA"
- type="password" v-model="password" maxlength="16" v-if="passwordType"/>
- <input class="cwjs-item cwjs-input" placeholder="请输入密码" placeholder-style="color:#AAAAAA"
- maxlength="16" v-model="password" v-else/>
- </view>
- <view class="imagesBox" @tap="changeBindPassword">
- <image v-if="passwordType==false" src="../../static/images/zhengkai.png" class="images"
- mode="scaleToFill"></image>
- <image v-if="passwordType==true" src="../../static/images/bishang.png" class="images"
- mode="scaleToFill"></image>
- </view>
- </view>
- <view class="textbox">
- <view class="textbox-1" @tap="bindVerification">验证码登录</view>
- <view class="textbox-2"></view>
- <view class="textbox-11" @tap="bindpassword">忘记密码</view>
- </view>
-
- <view class="button" @tap="bindWxBLogin">立即登录</view>
- </view>
-
- </view>
- </template>
-
- <script>
- var util = require("../../utils/util.js");
- var config = require("../../config");
- var app = getApp();
- var WXB_SESSION_LOGIN_DATA = 'weapp_session_login_data';
- export default {
- data() {
- return {
- username: '',//用户名-测试 13388881113 1234567/ 13033782199 123456
- password: '',//密码
- // username: '13033782199',//用户名-生产 13033782199 654321
- // password: '654321',//密码
- passwordType: true,
- agreeChecked: true
- };
- },
- onLoad: function(options) {
- uni.hideToast();
- },
- methods: {
- //验证码登录
- bindVerification() {
- uni.navigateTo({
- url: '/pages/login/Verification?role=1',
- })
- },
- //忘记密码
- bindpassword() {
- uni.navigateTo({
- url: '/pages/login/Setthepassword',
- })
- },
- //密码选择
- changeBindPassword: function(e) {
- this.passwordType=!this.passwordType;
- },
- //登录
- bindWxBLogin: function(e) {
- util.showBusy('正在登录...');
- var that = this;
- if (this.username == '') {
- util.showNone("请输入账号名");
- return false;
- }
- if (this.password == '') {
- util.showNone("请输入密码");
- return false;
- }
- var loginParams = {
- username: this.username,
- password: this.password,
- scope: 'server',
- grant_type: 'password'
- };
- const user = util.encryption({
- data: loginParams,
- key: 'pigxpigxpigxpigx',
- param: ['password']
- })
- console.log(user)
- // return
- // 请求服务器登录地址,获得会话信息
- uni.request({
- url: config.service.login,
- header: {
- 'Authorization': 'Basic dGVzdDp0ZXN0',
- 'content-type': 'application/x-www-form-urlencoded'
- },
- method: "POST",
- data: {
- username:user.username,
- password:user.password,
- scope: 'server',
- grant_type: 'password'
- },
- success: function(result) {
- var data = result.data; //console.log("登录信息", data);
- if (data) {
- var res = data;
- console.log(res.code)
- if (res.code!=1) {
- var data = {
- 'token': res.access_token
- };
- uni.setStorageSync(WXB_SESSION_LOGIN_DATA, data); //写入缓存
- that.getMenu()
- that.getUser();
- util.showSuccess('登录成功');
- } else {
- util.showNone("账号名或密码错误,请重试");
- return false;
- }
- } else {
- util.showNone(data.message);
- return false;
- }
- },
- // 响应错误
- fail: function(loginResponseError) {
- util.showNone("网络异常,请重试");
- return false;
- }
- });
- },
- getUser(){
- util.getRequestPromise(config.service.getUser, {}, false, "GET").then(data => {
- if (data.user.total==0) {
- uni.showToast({
- title: '暂无绑定项目',
- duration: 2000,
- icon:"none"
- });
- return
- } else {
- let loupan = {
- id: data.houseList[0].id,
- name: data.houseList[0].propertyName
- }
- let users=data.user
- users.zkProperties=data.houseList
- uni.setStorageSync("fendianindex", 0); //写入缓存
-
- uni.setStorageSync("weapp_session_userInfo_data",users); //写入缓存
-
- uni.setStorageSync("buildingID", loupan); //项目id写入缓存
- uni.switchTab({
- url: '/pages/index/index'
- });
- }
-
- });
- },
- //获取权限
- getMenu(){
- uni.request({
- url: config.service.getMenu,
- method: "POST",
- header: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer '+uni.getStorageSync('weapp_session_login_data').token
- },
- success: (data) => {
- let rescor=data.data;
- if (rescor.code == 0) {
- uni.setStorageSync("weapp_session_Menu_data", rescor.data)
- }else{
- uni.showToast({
- title: rescor.msg,
- duration: 2000,
- icon:"none"
- });
- return
- }
- }
- })
- },
-
-
- }
- };
- </script>
- <style lang="scss">
- .cwjs-logo {
- display: block;
- width: 219rpx;
- height: 158rpx;
- margin: 54rpx auto 66rpx;
- }
-
- .cwjs-tips {
- font-size: 24rpx;
- padding: 80rpx 0;
- color: #8a8a8a;
- }
-
- .cwjs-form {
- position: relative;
- margin: 0;
- background-color: #fff;
- border-radius: 10px;
- padding: 20rpx 40rpx 113rpx;
- }
-
- .cwjs-cells {
- width: 510rpx;
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- margin: 0 auto;
- height: 88rpx;
- overflow: hidden;
- border: 1rpx solid #BFC7D3;
- position: relative;
- border-radius: 12rpx;
- }
-
- .center {
- flex: 1;
- }
-
- .cwjs-input {
- height: 48rpx;
- line-height: 48rpx;
- padding: 23rpx 23rpx 23rpx 78rpx;
- font-size: 48rpx !important;
- font-family: PingFangSC-Regular, PingFang SC;
- color: #000;
- }
-
- .images {
- display: block;
- width: 40rpx;
- height: 21rpx;
- margin-right: 30rpx;
- margin-top: 33.5rpx;
- }
-
- .mod-btn {
- position: absolute;
- bottom: -80rpx;
- left: 50%;
- margin-left: -80rpx;
- }
-
-
-
-
- /* 头部 */
-
- .head {
- width: 750rpx;
- height: 500rpx;
- position: relative;
-
- .head-immg {
- width: 750rpx;
- height: 778rpx;
- position: absolute;
- }
- }
-
-
- .logo {
- width: 248rpx;
- height: 248rpx;
- display: block;
- position: absolute;
- top: 134rpx;
- left: 240.5rpx;
- }
-
-
- /* 输入框 */
- .input {
- width: 630rpx;
- height: 824rpx;
- padding: 60rpx 60rpx 80rpx 60rpx;
- box-sizing: border-box;
- background: #FFFFFF;
- box-shadow: 0px 14px 20px -6px rgba(6, 16, 88, 0.1);
- border-radius: 20px;
- position: absolute;
- top: 107rpx;
- left: 60rpx;
- }
-
- .text-1 {
- font-size: 44rpx;
- line-height: 62rpx;
- }
-
- .text-2 {
- margin-top: 16rpx;
- font-size: 36rpx;
- line-height: 50rpx;
- }
-
- .logo_input {
- width: 34rpx;
- height: 38rpx;
- position: absolute;
- top: 25rpx;
- left: 30rpx;
- }
-
- /* 登录 */
- .button {
- width: 510rpx;
- height: 86rpx;
- background: #2671E2;
- box-shadow: 0px 2px 20px 0px rgba(38, 113, 226, 0.5);
- border-radius: 12rpx;
- text-align: center;
- line-height: 89rpx;
- color: #fff;
- margin: 0 auto;
- margin-top: 120rpx;
- font-size: 34rpx;
-
- }
-
- .footer {
- width: 100%;
- height: 157rpx;
- position: absolute;
- bottom: 0;
- left: 0;
- }
-
- .imagesBox {
- width: 80rpx;
- height: 88rpx;
- }
-
-
-
- .login {
- text-decoration: underline;
- text-align: center;
- margin-top: 40px;
- color: #88909E;
- font-size: 28rpx;
- }
-
- .textbox {
- width: 569rpx;
- display: flex;
- margin-top: 40rpx;
- }
-
- .textbox-1 {
- width: 30%;
- font-size: 30rpx;
- color: #999999;
- }
-
- .textbox-11 {
- width: 30%;
- text-align: right;
- font-size: 30rpx;
- color: #999999;
- }
-
- .textbox-2 {
- width: 30%;
- }
- </style>
|