pwLogin.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view class="pw-login-wrap">
  3. <!-- <view v-if="!buildType" style="text-align: center;color: #999999;padding-top: 40px;">{{ envTips }}</view> -->
  4. <view class="logo">
  5. <u-image src="/static/logo.png" width="160" height="48" ></u-image>
  6. </view>
  7. <form class="login-form" @submit="formSubmit">
  8. <view class="form-item">
  9. <input v-model="form.loginName" class="item-inp" name="loginName" type="text" maxlength="30" placeholder="请输入用户名" />
  10. </view>
  11. <view class="form-item">
  12. <input v-model="form.password" class="item-inp" name="password" password type="text" maxlength="12" placeholder="请输入密码" />
  13. </view>
  14. <view class="flex-box" style="margin-top: 60upx;">
  15. <view class="remember-pass">
  16. <u-checkbox v-model="isRemember" value="true" :size="30" :label-size="26" :active-color="$config('primaryColor')" class="login-form-checkbox" @change="rememberChange">记住密码</u-checkbox>
  17. </view>
  18. </view>
  19. <view class="form-btn-con">
  20. <button class="form-btn" :style="{background:$config('primaryColor'),borderRadius:'100px'}" form-type="submit">登录</button>
  21. </view>
  22. </form>
  23. <view class="ysxy" @click="toYs">登录即代表同意<text>隐私政策</text>和<text>服务条款</text></view>
  24. </view>
  25. </template>
  26. <script>
  27. import market from "@/js_sdk/dc-market/market.js"
  28. import { checkVersionToLoadUpdate, setStorageForAppVersion,clzConfirm } from '@/libs/tools'
  29. import { isvalidPhone } from '@/libs/validate.js';
  30. import { login } from '@/api/user.js';
  31. import { getSysVersion } from '@/api/data.js'
  32. export default {
  33. data() {
  34. return {
  35. form: {
  36. loginName: this.$store.state.vuex_user.account,
  37. password: this.$store.state.vuex_user.password
  38. },
  39. isRemember: true, // 是否记住密码
  40. envTips: '',
  41. buildType: '',
  42. };
  43. },
  44. mounted() {
  45. this.isRemember = this.$store.state.vuex_isRemember || true;
  46. this.envTips = getApp().globalData.envTips;
  47. this.buildType = getApp().globalData.buildType;
  48. },
  49. onShow() {
  50. },
  51. methods: {
  52. // 获取微信login code
  53. getWechatCode(){
  54. const _this = this
  55. wx.login({
  56. success (res) {
  57. if (res.code) {
  58. //发起网络请求
  59. let formData = JSON.parse(JSON.stringify(_this.form))
  60. formData.code = res.code
  61. _this.submitForm(formData)
  62. } else {
  63. console.log('登录失败,点击“登录”重试!' + res.errMsg)
  64. }
  65. }
  66. })
  67. },
  68. // 表单提交
  69. formSubmit() {
  70. const _this = this;
  71. // 表单校验
  72. if (_this.form.loginName == '') {
  73. uni.showToast({ icon: 'none', title: '请输入用户名' });
  74. return;
  75. }
  76. if (_this.form.password == '') {
  77. uni.showToast({ icon: 'none', title: '请输入密码' });
  78. return;
  79. }
  80. if (_this.form.password.length < 6 || _this.form.password.length > 12) {
  81. uni.showToast({ icon: 'none', title: '请输入6-12位密码' });
  82. return;
  83. }
  84. uni.showLoading({
  85. title: '正在登录...'
  86. });
  87. this.submitForm(_this.form)
  88. },
  89. submitForm(formData){
  90. const _this = this
  91. // 登录
  92. // login(formData).then(res => {
  93. // uni.hideLoading()
  94. // if (res.status == 200) {
  95. // _this.$u.vuex('vuex_token', res.data)
  96. // getApp().globalData.token = res.data
  97. // //登录成功将用户名密码存储到用户本地
  98. // if (_this.isRemember) {
  99. // //用户勾选“记住密码”
  100. // _this.$u.vuex('vuex_user.account', _this.form.loginName)
  101. // _this.$u.vuex('vuex_user.password', _this.form.password)
  102. // } else {
  103. // //用户没有勾选“记住密码”
  104. // _this.$u.vuex('vuex_user.account', '')
  105. // _this.$u.vuex('vuex_user.password', '')
  106. // _this.form.loginName = ''
  107. // _this.form.password = ''
  108. // }
  109. // uni.setStorageSync('loginTimeOut', 'NO')
  110. // _this.toMain()
  111. // } else {
  112. // uni.showToast({ icon: 'none', title: res.message })
  113. // }
  114. // })
  115. },
  116. toMain() {
  117. // 跳转到首页
  118. uni.switchTab({
  119. url: '/pages/index/index'
  120. });
  121. },
  122. // 忘记密码
  123. forgetPass() {
  124. uni.navigateTo({
  125. url: '/pages/login/forget-pass?username=' + this.form.loginName
  126. });
  127. },
  128. // 判断是否记住密码
  129. rememberChange(e) {
  130. this.isRemember = e.value;
  131. },
  132. toYs(){
  133. uni.navigateTo({
  134. url: '/pages/login/userAuthYs'
  135. })
  136. }
  137. }
  138. };
  139. </script>
  140. <style scoped lang="scss">
  141. @import './login.scss';
  142. </style>