123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <template>
- <view class="content">
- <image class="logo" :src="avatarUrl"></image>
- <view class="title">
- {{nickName}}
- </view>
- <form @submit="loginwxSubmit">
- <view class="">
- <view class="title">角色选择</view>
- <radio-group class="level" name="level" @change="radioChange">
- <label class="radio">
- <radio class="radio" value="1" :checked="1==level" /><text>管理员</text>
- </label>
- </br>
- <label class="radio">
- <radio class="radio" value="2" :checked="2==level" /><text>员工</text>
- </label>
- </br>
- <label class="radio">
- <radio class="radio" value="3" :checked="3==level" /><text>游客</text>
- </label>
- </radio-group>
- </view>
- <view class="section" v-show="level==1">
- <input class="input-account" name="code" placeholder="管理员验证码" />
- </view>
- <view class="section" >
- <input class="input-account" name="workname" placeholder="员工名称" />
- </view>
- <view class="section">
- <input class="input-account" name="username" placeholder="请输入用户名" />
- </view>
- <view class="section" v-show="level<=2">
- <input class="input-pwd" password name="password" placeholder="请输入密码" />
- </view>
- <view class="btn-area">
- <button type="primary" formType="submit" :loading="isLoading">绑定微信</button>
- </view>
- </form>
- </view>
- </view>
- </template>
- <script>
- import {
- mapState
- } from 'vuex';
- import MD5 from '@/assets/scripts/md5';
- export default {
- data() {
- return {
- nickName: '',
- openId: '',
- avatarUrl: '',
- pname: '',
- password: '',
- level: 2,
- parm: {
- username: "",
- password: "",
- avatarUrl: "",
- nickName: "",
- openId: ""
- },
- keyEventBind: {
- backbutton: false, //Boolean(默认truee)关闭back按键监听
- menubutton: false //Boolean(默认true)关闭menu按键监听
- }
- };
- },
- onShow() {
- var weixinInfo = uni.getStorageSync("weixinInfo");
- this.nickName = weixinInfo.nickName;
- this.openId = weixinInfo.openId;
- this.avatarUrl = weixinInfo.avatarUrl;
- },
- computed: {
- ...mapState(['isLoading']),
- },
- methods: {
- loginwxSubmit(event) {
- uni.hideKeyboard();
- // const { value: loginForm } = event.detail;
- var username = event.detail.value.username;
- var pass = event.detail.value.password;
- var level = event.detail.value.level;
- var workname = event.detail.value.workname;
- if(level==2&&workname==""){
- uni.showModal({
- title: "提示",
- content: "员工名不能为空",
- success: function(res) {
- return;
- }
- })
- return;
- }
- var code = event.detail.value.code;
- if(level==1){
- if(code == "" || code==null){
- uni.showModal({
- title: "提示",
- content: "管理员需要输入验证码",
- success: function(res) {
- return;
- }
- })
- return;
- }
- if(code!="007"){
- uni.showModal({
- title: "提示",
- content: "验证码错误",
- success: function(res) {
- return;
- }
- })
- return;
- }
- }
- var password = MD5(pass);
- var serverUrl = this.serverurl;
- this.parm['username'] = username;
- this.parm['password'] = password;
- this.parm['level'] = level;
- this.parm['workName'] = workname;
- this.parm['avatarUrl'] = this.avatarUrl;
- this.parm['nickName'] = this.nickName;
- this.parm['openId'] = this.openId;
- // debugger;
- this.$store.dispatch('loginWXCZ', this.parm)
- .then(data => {
- var result = data.message;
- var weixinInfo = data.data;
- var code = data.code;
- uni.setStorageSync("token", data.token);
- uni.setStorageSync("globalUser", weixinInfo);
- uni.setStorageSync("level", this.level);
- if (code == true) {
- uni.reLaunch({
- url: '/pages/Charts/mainStatistics',
- });
- }
- }, _ => void uni.stopPullDownRefresh());
- },
- radioChange: function(evt) {
-
- this.level = evt.target.value;
- }
- },
- }
- </script>
- <style lang="scss">
- page {
- padding: 200upx 0 0 0;
- background-image: url('~@/static/backgrounds/login_bg.png');
- background-repeat: no-repeat;
- background-size: 100% 100%;
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- .content {
- padding: 0 20upx;
- display: flex;
- flex-flow: column nowrap;
- align-items: center;
- .logo {
- width: 150upx;
- height: 150upx;
- text-align: center;
- margin: 50upx;
- }
- form {
- width: calc(100% - 100upx);
- padding: 50upx;
- .level {
- display: flex;
- flex-direction: row;
- }
- .radio {
- padding-top: 10upx;
- padding-left: 10upx;
- }
- .section {
- margin: 50upx 0;
- }
- .btn-area {
- margin-top: 100upx;
- button {
- background-color: $uni-color-primary;
- }
- }
- }
- }
- }
- </style>
|