loginWeixin.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <view class="content">
  3. <image class="logo" :src="avatarUrl"></image>
  4. <view class="title">
  5. {{nickName}}
  6. </view>
  7. <form @submit="loginwxSubmit">
  8. <view class="section">
  9. <input class="input-account" name="username" placeholder="请输入用户名" />
  10. </view>
  11. <view class="section">
  12. <input class="input-pwd" password name="password" placeholder="请输入密码" />
  13. </view>
  14. <view class="btn-area">
  15. <button type="primary" formType="submit" :loading="isLoading">绑定微信</button>
  16. </view>
  17. </form>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import {
  23. mapState
  24. } from 'vuex';
  25. import MD5 from '@/assets/scripts/md5';
  26. export default {
  27. data() {
  28. return {
  29. nickName: '',
  30. openId: '',
  31. avatarUrl: '',
  32. pname: '',
  33. password: '',
  34. parm: {
  35. username: "",
  36. password: "",
  37. avatarUrl: "",
  38. nickName: "",
  39. openId: ""
  40. }
  41. };
  42. },
  43. onShow() {
  44. var weixinInfo = uni.getStorageSync("weixinInfo");
  45. this.nickName = weixinInfo.nickName;
  46. this.openId = weixinInfo.openId;
  47. this.avatarUrl = weixinInfo.avatarUrl;
  48. },
  49. computed: {
  50. ...mapState(['isLoading']),
  51. },
  52. methods: {
  53. loginwxSubmit(event) {
  54. uni.hideKeyboard();
  55. // const { value: loginForm } = event.detail;
  56. var username = event.detail.value.username;
  57. var pass = event.detail.value.password;
  58. var password = MD5(pass);
  59. var serverUrl = this.serverurl;
  60. this.parm['username'] = username;
  61. this.parm['password'] = password;
  62. this.parm['avatarUrl'] = this.avatarUrl;
  63. this.parm['nickName'] = this.nickName;
  64. this.parm['openId'] = this.openId;
  65. // debugger;
  66. this.$store.dispatch('loginWXCZ', this.parm)
  67. .then(data => {
  68. var result = data.message;
  69. var weixinInfo = data.data;
  70. var code = data.code;
  71. uni.setStorageSync("globalUser", weixinInfo);
  72. if (code == true) {
  73. uni.reLaunch({
  74. url: '/pages/Charts/mainStatistics',
  75. });
  76. }
  77. }, _ => void uni.stopPullDownRefresh());
  78. },
  79. },
  80. }
  81. </script>
  82. <style lang="scss">
  83. page {
  84. padding: 200upx 0 0 0;
  85. background-image: url('~@/static/backgrounds/login_bg.png');
  86. background-repeat: no-repeat;
  87. background-size: 100% 100%;
  88. position: absolute;
  89. top: 0;
  90. left: 0;
  91. right: 0;
  92. bottom: 0;
  93. .content {
  94. padding: 0 20upx;
  95. display: flex;
  96. flex-flow: column nowrap;
  97. align-items: center;
  98. .logo {
  99. width: 150upx;
  100. height: 150upx;
  101. text-align: center;
  102. margin: 50upx;
  103. }
  104. form {
  105. width: calc(100% - 100upx);
  106. padding: 50upx;
  107. .section {
  108. margin: 50upx 0;
  109. }
  110. .btn-area {
  111. margin-top: 100upx;
  112. button {
  113. background-color: $uni-color-primary;
  114. }
  115. }
  116. }
  117. }
  118. }
  119. </style>