1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <template>
- <view style="margin:20rpx">
- <u-field
- v-model="userName"
- label="用户名"
- placeholder="请输入用户名"
- :required = "true"
- >
- </u-field>
- <u-field
- v-model="password"
- label="密码"
- placeholder="请输入密码"
- type="password"
- :required = "true"
- >
- </u-field>
- <u-button type="success" :ripple="true" ripple-bg-color="#909399" @click="login">提交</u-button>
- <view>
- <u-toast ref="uToast" />
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- openId: '',
- unionid : '',
- userName : '',
- password : '',
- type : ''
- }
- },
- onLoad(option) {
- this.openId = option.openId;
- this.unionid = option.unionid;
- //#ifdef MP-WEIXIN
- this.type = "mpWeixin";
- // #endif
- //#ifdef H5
- this.type = "H5";
- // #endif
- },
- methods:{
- login(){
- let self = this;
- if (!this.userName) {
- this.$refs.uToast.show({
- title: "请输入用户名!",
- type: 'error',
- })
- return;
- }
- if (!this.password) {
- this.$refs.uToast.show({
- title: "请输入密码!",
- type: 'error',
- })
- return;
- }
- this.request({
- action : 'login/check',
- data:{
- openId : self.openId,
- unionid : self.unionid,
- userName : self.userName,
- password : self.password,
- type : self.type
- },
- success(resData){
- if (resData.data.code == "200") {
- uni.setStorage({
- key: 'Authorization',
- data: resData.data.data,
- success: function () {
- // 跳转主页
- uni.redirectTo({
- url: '/pages/home/task'
- });
- }
- });
- } else {
- self.$refs.uToast.show({
- title: resData.data.message,
- type: 'error',
- })
- }
- }
- })
- },
- }
- }
- </script>
- <style>
- </style>
|