pwLogin.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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.jpg" width="140" height="140" ></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="#07c160" class="login-form-checkbox" @change="rememberChange">记住密码</u-checkbox>
  17. </view>
  18. </view>
  19. <view class="form-btn-con">
  20. <button class="form-btn" 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 (!isvalidPhone(_this.form.loginName)) {
  77. // // uni.showToast({ icon: 'none', title: '请输入正确的手机号码' });
  78. // // return;
  79. // // }
  80. // if (_this.form.password == '') {
  81. // uni.showToast({ icon: 'none', title: '请输入密码' });
  82. // return;
  83. // }
  84. // if (_this.form.password.length < 6 || _this.form.password.length > 12) {
  85. // uni.showToast({ icon: 'none', title: '请输入6-12位密码' });
  86. // return;
  87. // }
  88. // uni.showLoading({
  89. // title: '正在登录...'
  90. // });
  91. // // #ifdef MP-WEIXIN
  92. // // 获取微信login code
  93. // this.getWechatCode()
  94. // // #endif
  95. // // #ifndef MP-WEIXIN
  96. this.submitForm(_this.form)
  97. // // #endif
  98. },
  99. submitForm(formData){
  100. const _this = this
  101. // 登录
  102. // login(formData).then(res => {
  103. // uni.hideLoading()
  104. // if (res.status == 200) {
  105. // _this.$u.vuex('vuex_token', res.data)
  106. // getApp().globalData.token = res.data
  107. // //登录成功将用户名密码存储到用户本地
  108. // if (_this.isRemember) {
  109. // //用户勾选“记住密码”
  110. // _this.$u.vuex('vuex_user.account', _this.form.loginName)
  111. // _this.$u.vuex('vuex_user.password', _this.form.password)
  112. // } else {
  113. // //用户没有勾选“记住密码”
  114. // _this.$u.vuex('vuex_user.account', '')
  115. // _this.$u.vuex('vuex_user.password', '')
  116. // _this.form.loginName = ''
  117. // _this.form.password = ''
  118. // }
  119. // uni.setStorageSync('loginTimeOut', 'NO')
  120. _this.toMain()
  121. // } else {
  122. // uni.showToast({ icon: 'none', title: res.message })
  123. // }
  124. // })
  125. },
  126. toMain() {
  127. // 跳转到首页
  128. uni.switchTab({
  129. url: '/pages/index/index'
  130. });
  131. },
  132. // 忘记密码
  133. forgetPass() {
  134. uni.navigateTo({
  135. url: '/pages/login/forget-pass?username=' + this.form.loginName
  136. });
  137. },
  138. // 判断是否记住密码
  139. rememberChange(e) {
  140. this.isRemember = e.value;
  141. },
  142. toYs(){
  143. uni.navigateTo({
  144. url: '/pages/agreement/agreement'
  145. })
  146. }
  147. }
  148. };
  149. </script>
  150. <style scoped lang="scss">
  151. @import './login.scss';
  152. </style>