checking.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <view style="margin:20rpx">
  3. <u-field
  4. v-model="userName"
  5. label="用户名"
  6. placeholder="请输入用户名"
  7. :required = "true"
  8. >
  9. </u-field>
  10. <u-field
  11. v-model="password"
  12. label="密码"
  13. placeholder="请输入密码"
  14. type="password"
  15. :required = "true"
  16. >
  17. </u-field>
  18. <u-button type="success" :ripple="true" ripple-bg-color="#909399" @click="login">提交</u-button>
  19. <view>
  20. <u-toast ref="uToast" />
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. openId: '',
  29. unionid : '',
  30. userName : '',
  31. password : '',
  32. type : ''
  33. }
  34. },
  35. onLoad(option) {
  36. this.openId = option.openId;
  37. this.unionid = option.unionid;
  38. //#ifdef MP-WEIXIN
  39. this.type = "mpWeixin";
  40. // #endif
  41. //#ifdef H5
  42. this.type = "H5";
  43. // #endif
  44. },
  45. methods:{
  46. login(){
  47. let self = this;
  48. if (!this.userName) {
  49. this.$refs.uToast.show({
  50. title: "请输入用户名!",
  51. type: 'error',
  52. })
  53. return;
  54. }
  55. if (!this.password) {
  56. this.$refs.uToast.show({
  57. title: "请输入密码!",
  58. type: 'error',
  59. })
  60. return;
  61. }
  62. this.request({
  63. action : 'login/check',
  64. data:{
  65. openId : self.openId,
  66. unionid : self.unionid,
  67. userName : self.userName,
  68. password : self.password,
  69. type : self.type
  70. },
  71. success(resData){
  72. if (resData.data.code == "200") {
  73. uni.setStorage({
  74. key: 'Authorization',
  75. data: resData.data.data,
  76. success: function () {
  77. // 跳转主页
  78. uni.redirectTo({
  79. url: '/pages/home/task'
  80. });
  81. }
  82. });
  83. } else {
  84. self.$refs.uToast.show({
  85. title: resData.data.message,
  86. type: 'error',
  87. })
  88. }
  89. }
  90. })
  91. },
  92. }
  93. }
  94. </script>
  95. <style>
  96. </style>