123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- <template>
- <view class="login">
- <image class="pic_dlbg" src="/static/img/pic_dlbg.png" mode=""></image>
-
- <view class="content1">
- <image class="pic_dl_hum" src="/static/img/pic_dl_hum.png" mode=""></image>
- <view class="title">潜山市教育局在线收发文系统</view>
- <!-- #ifdef MP-WEIXIN -->
- <view class="formContent">
- <view class="list">
- <view class="lable">账号</view>
- <view class="input">
- <u-input class="uInput" v-model="userData.username" type="text" placeholder="请输入您的账号" :border="false" />
- </view>
- </view>
- <view class="list">
- <view class="lable">密码</view>
- <view class="input">
- <u-input class="uInput" v-model="userData.password" type="password" placeholder="请输入您的密码" :border="false" />
- </view>
- </view>
- <view class="list">
- <xlSliderVerify @success="verifySuccess"></xlSliderVerify>
- </view>
- <view class="list">
- <view class="btn" @click="postLogin">登录</view>
- </view>
- </view>
- <!-- #endif -->
- <!-- #ifndef MP-WEIXIN -->
- <view class="formContent">
- <view class="list">
- <view class="lable">账号</view>
- <view class="input">
- <u-input class="uInput" v-model="userDataAPP.username" type="text" placeholder="请输入您的账号" :border="false" />
- </view>
- </view>
- <view class="list">
- <view class="lable">密码</view>
- <view class="input">
- <u-input class="uInput" v-model="userDataAPP.password" type="password" placeholder="请输入您的密码" :border="false" />
- </view>
- </view>
- <view class="list">
- <view class="lable">验证码</view>
- <view class="input">
- <u-input class="uInput" v-model="userDataAPP.code" type="text" placeholder="请输入验证码" :border="false" />
- <image :src="appcode" mode="" class="appcode" @click="appCode()"></image>
- </view>
- </view>
- <view class="list">
- <xlSliderVerify @success="verifySuccess"></xlSliderVerify>
- </view>
- <view class="list">
- <view class="btn" @click="postLoginAPP">登录</view>
- </view>
- </view>
- <!-- #endif -->
- </view>
- </view>
- </template>
- <script>
- import xlSliderVerify from '@/components/xl-slider-verify/xl-slider-verify.vue'
- export default {
- data() {
- return {
- userData: {
- username: '',
- password: '',
- code: ''
- },
- userDataAPP: {
- username: '',
- password: '',
- code: ''
- },
- isLogin: false,
- mainSwitch: false,
- tmpIds: [],
- appcode: '',
- appuuid: ''
- }
- },
- components:{
- xlSliderVerify
- },
- onLoad() {
- let that = this
- // #ifdef MP-WEIXIN
- wx.getSetting({
- withSubscriptions: true,
- success (res) {
- if (res.subscriptionsSetting.mainSwitch) {
- if (res.subscriptionsSetting.itemSettings != null) {
- that.mainSwitch = true
- for (var key in res.subscriptionsSetting.itemSettings) {
- that.tmpIds.push(key)
- }
- }
- }
- }
- })
-
- // #endif
- // #ifndef MP-WEIXIN
- this.appCode()
- // #endif
- },
- onShow() {
- let that = this
- // #ifdef MP-WEIXIN
- uni.login({
- provider: 'weixin',
- success: function(weixinRes) {
- that.userData.code = weixinRes.code
- console.log(weixinRes);
- }
- });
- // #endif
- },
- methods:{
- async postLogin () {
- if (!this.isLogin){
- uni.showToast({
- title: '请滑动验证条',
- icon: 'none'
- })
- return
- }
- let that = this
- let data = {
- username: that.userData.username,
- password: that.userData.password,
- code: that.userData.code,
- logintype: 'w'
- }
- let res = await that.$u.post('auth/login',data)
- if (res.code == 500) {
- uni.login({
- provider: 'weixin',
- success: function(weixinRes) {
- that.userData.code = weixinRes.code
- console.log(weixinRes);
- }
- });
- return false
- }
- console.log(res);
- uni.setStorage({
- key: 'authToken',
- data: res.data.access_token,
- success: async function() {
- uni.showToast({
- icon: 'none',
- title: '登陆成功'
- })
- // #ifdef MP-WEIXIN
- let res1 = await that.$u.get(`boman-wechat/wechat/p/c/tmpIds`, {})
- let dataList = []
- res1.data.forEach((item) => {
- if (that.tmpIds.indexOf(item) == -1) {
- dataList.push(item)
- }
- })
- if (that.mainSwitch && !dataList.length) {
- setTimeout( () => {
- uni.switchTab({
- url: '/pages/tabbar/index/index'
- })
- },2000)
- } else {
- wx.showModal({
- title: '提示',
- content: '订阅授权通知',
- success : function (res) {
- if (res.confirm) {
- wx.requestSubscribeMessage({
- tmplIds: dataList,
- success (resMessage) {
- uni.switchTab({
- url: '/pages/tabbar/index/index'
- })
- }
- })
- } else if (res.cancel) {
- console.log('用户点击取消')
- uni.switchTab({
- url: '/pages/tabbar/index/index'
- })
- }
- }
- })
- }
- // #endif
-
- }
- });
- },
- verifySuccess(e) {
- this.isLogin = true
- },
- async appCode() {
- let that = this
- let res = await that.$u.get('code')
- that.appcode = 'data:image/gif;base64,' + res.img
- that.appuuid = res.uuid
- },
- async postLoginAPP () {
- if (!this.isLogin){
- uni.showToast({
- title: '请滑动验证条',
- icon: 'none'
- })
- return
- }
- let that = this
- let data = {
- username: that.userDataAPP.username,
- password: that.userDataAPP.password,
- code: that.userDataAPP.code,
- uuid: that.appuuid,
- }
- let res = await that.$u.post('auth/login',data)
- uni.setStorage({
- key: 'authToken',
- data: res.data.access_token,
- success: async function() {
- uni.showToast({
- icon: 'none',
- title: '登陆成功'
- })
- setTimeout( () => {
- uni.switchTab({
- url: '/pages/tabbar/index/index'
- })
- },2000)
- },
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .pic_dlbg{
- width: 100%;
- min-height: 100vh;
- }
- .content1{
- position: absolute;
- width: 100%;
- top: 0;
- left: 0;
- .pic_dl_hum{
- width: 510rpx;
- height: 356rpx;
- margin: 130rpx auto auto auto;
- }
- .title{
- font-size: 38rpx;
- color: #009FE8;
- font-weight: 700;
- text-align: center;
- margin-top: 16rpx;
- }
- .formContent{
- padding: 30rpx 78rpx;
- margin-top: 30rpx;
- .list{
- margin-bottom: 60rpx;
- position: relative;
- .lable{
- font-size: 28rpx;
- color: #343434;
- }
- .input{
- border-bottom: solid 2rpx #009FE8;
- padding: 10rpx 0;
- display: flex;
- align-items: center;
- .uInput{
- width: 100%;
- flex: 1;
- }
- .appcode{
- width: 200rpx;
- height: 60rpx;
- }
- }
- .btn {
- width: 100%;
- height: 90rpx;
- background: #009FE8;
- border-radius: 6rpx;
- color: #fff;
- line-height: 90rpx;
- text-align: center;
- }
- }
- }
- }
- </style>
|