<template>
|
<view class="main">
|
<view class="list">
|
<view class="list-call">
|
<u--input v-model="username"
|
clearable
|
maxlength="32"
|
type="text"
|
placeholder="请输入手机号"
|
prefixIcon="account"
|
prefixIconStyle="font-size: 22px;color: #909399"></u--input>
|
</view>
|
<view class="list-call">
|
<u--input v-model="password"
|
clearable
|
maxlength="32"
|
type="password"
|
placeholder="请输入密码"
|
prefixIcon="lock"
|
prefixIconStyle="font-size: 22px;color: #909399"></u--input>
|
</view>
|
</view>
|
<view class="loginBtn"><u-button type="primary"
|
text="确认"
|
@click="submit()"
|
:loading="submitLoading"></u-button></view>
|
</view>
|
</template>
|
|
<script>
|
import { BaseUrl } from '@/api/publicInterface.js'
|
export default {
|
data() {
|
return {
|
username: '',
|
password: '',
|
code: '',
|
submitLoading: false
|
};
|
},
|
methods: {
|
submit() {
|
if (this.username.length === 0) {
|
return this.$u.toast('请输入手机号')
|
}
|
if (this.password.length === 0) {
|
return this.$u.toast('请输入密码')
|
}
|
this.setUpWxOpenid(this.username, this.password, uni.getStorageSync('bindCode'))
|
},
|
getUserAuth() {
|
wx.getSetting({
|
withSubscriptions: true,
|
success(res) {
|
if (res.subscriptionsSetting == null || res.subscriptionsSetting == undefined ||
|
res.subscriptionsSetting.itemSettings == null || res.subscriptionsSetting
|
.itemSettings == undefined || res.subscriptionsSetting[
|
"bvDqcHRRKEewTz7XVrdwUbrF6ZewSRmiUIB1V_IBJq4"] != 'accept') {
|
wx.requestSubscribeMessage({
|
tmplIds: ['bvDqcHRRKEewTz7XVrdwUbrF6ZewSRmiUIB1V_IBJq4'],
|
success(res) {
|
console.log(res, '获取订阅消息');
|
},
|
fail(e) {
|
console.log(e, '订阅消息失败');
|
}
|
})
|
}
|
}
|
})
|
},
|
setUpWxOpenid(userName, passWord, code) {
|
this.submitLoading = true
|
uni.request({
|
url: `${BaseUrl}/admin/user/setUpWxOpenid`,
|
data: {
|
userName,
|
passWord,
|
code
|
},
|
method: 'POST',
|
header: {
|
'content-type': 'application/x-www-form-urlencoded'
|
},
|
success: (res) => {
|
console.log(res, '绑定结果');
|
if (res.data.code === 1) {
|
this.$u.toast(res.data.msg ? res.data.msg : '绑定失败')
|
this.submitLoading = false
|
} else {
|
this.$u.toast('操作成功')
|
this.submitLoading = false
|
}
|
}
|
})
|
},
|
onShow() {
|
uni.login({
|
success(res) {
|
if (res.code) {
|
console.log(res.code, '获取code');
|
this.code = res.code
|
uni.setStorageSync('bindCode', this.code)
|
} else {
|
uni.showToast({
|
title: '出现错误',
|
duration: 2000
|
});
|
}
|
}
|
})
|
},
|
}
|
}
|
</script>
|
|
<style lang="scss"
|
scoped>
|
@import 'index.scss';
|
|
.main {
|
width: 100%;
|
height: 100%;
|
margin: 0 auto;
|
}
|
|
.loginBtn {
|
width: 80%;
|
margin: 0 auto;
|
}
|
</style>
|