login.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view class="container login">
  3. <view class="login-main">
  4. <image class="logo" src="https://admin-b.caimei365.com/userfiles/1/images/photo/2020/11/logo.png" mode=""></image>
  5. </view>
  6. <view class="login-form">
  7. <view class="login-input">
  8. <input type="text"
  9. v-model="params.mobileOrEmail"
  10. maxlength="30"
  11. class="input"
  12. placeholder="请输入邮箱/手机号"
  13. />
  14. </view>
  15. <view class="login-input">
  16. <input v-show="isShowEye" type="text" v-model="params.password" maxlength="18" class="input" placeholder="请输入密码" autocomplete="new-password"/>
  17. <input v-show="!isShowEye" type="password" v-model="params.password" :password="true" maxlength="18" class="input" placeholder="请输入密码" autocomplete="new-password"/>
  18. <view class="iconfont" :class="isShowEye ? iconEyen : iconEyes" @click="passwordClick"></view>
  19. </view>
  20. <view class="login-input link">
  21. <view class="login-reg" @click.stop="this.$api.navigateTo('/pages/login/register-select')">免费注册</view>
  22. <view class="login-pwd" @click.stop="this.$api.navigateTo('/pages/login/password')">忘记密码?</view>
  23. </view>
  24. </view>
  25. <view class="login-btn" @click="confirmLogin">登录</view>
  26. <view class="login-btn-last" @click.stop="this.$api.navigateTo(`/pages/login/logincode?data=${getOption}`)">邀请码登录</view>
  27. <view class="login-tel">客服热线:0755-22907771</view>
  28. </view>
  29. </template>
  30. <script>
  31. import { mapState,mapMutations } from 'vuex';
  32. import authorize from '@/common/config/authorize.js'
  33. import wxLogin from "@/common/config/wxLogin.js"
  34. export default{
  35. data() {
  36. return{
  37. isShowEye:false,
  38. iconEyes:'icon-yanjing_yincang_o',
  39. iconEyen:'icon-yanjing_xianshi_o',
  40. getOption:'', //页面传递参数
  41. params:{
  42. mobileOrEmail:'',//用户登录账号
  43. password:'',//用户登录密码
  44. unionId:''
  45. }
  46. }
  47. },
  48. onLoad(option) {
  49. this.getOption = JSON.stringify(option)
  50. },
  51. computed: {
  52. ...mapState(['hasLogin','isWxAuthorize','isLoginType'])
  53. },
  54. methods:{
  55. ...mapMutations(['login']),
  56. async confirmLogin(){
  57. if( this.params.mobileOrEmail == ''){
  58. this.$util.msg('请输入账户名',2000)
  59. return
  60. }
  61. if( this.params.password == ''){
  62. this.$util.msg('请输入密码',2000)
  63. return
  64. }
  65. authorize.checkLogin()
  66. .then(res => {
  67. this.AorganizationLogin()
  68. })
  69. .catch(err => {
  70. this.$api.navigateTo('/pages/authorization/authorization?type=0')
  71. })
  72. },
  73. AorganizationLogin(){
  74. this.UserService.AorganizationLogin(this.params)
  75. .then(response =>{
  76. if(response.code === 0){
  77. this.storeUpdataeStatus(response.data)
  78. this.$api.navigateTo(`/pages/login/bindwechat?data=${JSON.stringify(this.getOption)}&codeType=${response.code}`)
  79. }else if(response.code === -3){
  80. this.$util.modal('','您的企业账号审核未通过,请修改资料','前往修改','',false,() =>{
  81. this.$store.commit('updateStatus',response.data)
  82. this.$api.navigateTo('/pages/login/apply-supplier')
  83. })
  84. }else{
  85. this.$util.msg(response.msg,2000);
  86. }
  87. })
  88. },
  89. storeUpdataeStatus(data){
  90. uni.setStorageSync('token',data.token)
  91. this.$store.commit('updateStatus',data)
  92. this.login(data);
  93. },
  94. passwordClick() { //密码显隐操作
  95. this.isShowEye = !this.isShowEye;
  96. },
  97. async InitAuthorize(){ //是否已授权 0:为取消授权 1:为已授权 2:为未操作
  98. authorize.checkLogin()
  99. .then(res => {
  100. wxLogin.wxLoginQuick()
  101. })
  102. .catch(err => {
  103. this.$api.navigateTo('/pages/authorization/authorization?type=0')
  104. })
  105. }
  106. },
  107. onShow() {
  108. this.$api.getStorage().then((resolve) =>{
  109. this.params.unionId = resolve.unionId
  110. })
  111. this.InitAuthorize()
  112. }
  113. }
  114. </script>
  115. <style lang="scss">
  116. .login{
  117. width: 100%;
  118. height: auto;
  119. .model-warp.none{
  120. display: none;
  121. }
  122. .model-warp.show{
  123. display: block;
  124. }
  125. .login-main{
  126. width: 100%;
  127. display: flex;
  128. flex-direction: column;
  129. align-items: center;
  130. height: 189rpx;
  131. padding:60rpx 0 40rpx 0;
  132. margin-bottom: 70rpx;
  133. .logo{
  134. width:467rpx;
  135. height: 189rpx;
  136. display: block;
  137. }
  138. }
  139. .login-input{
  140. width: 600rpx;
  141. height: 88rpx;
  142. padding: 24rpx 0;
  143. margin: 0 auto;
  144. margin-bottom: 30rpx;
  145. background: #FFFFFF;
  146. position: relative;
  147. box-sizing: border-box;
  148. border-bottom: 1px solid #e1e1e1;
  149. .input{
  150. width: 100%;
  151. height: 100%;
  152. background: #FFFFFF;
  153. font-size: $font-size-28;
  154. line-height: 88rpx;
  155. color: #333333;
  156. }
  157. .iconfont{
  158. position: absolute;
  159. right: 0;
  160. top: 0;
  161. font-size: 44rpx;
  162. color: #999999;
  163. font-weight: bold;
  164. z-index: 99;
  165. width: 96rpx;
  166. height: 96rpx;
  167. line-height: 96rpx;
  168. text-align: center;
  169. }
  170. &.link{
  171. background: #FFFFFF;
  172. margin-bottom: 40rpx;
  173. padding: 0 0;
  174. line-height: 40rpx;
  175. font-size: $font-size-28;
  176. border-bottom: none;
  177. .login-reg{
  178. float: left;
  179. color: $color-system;
  180. }
  181. .login-pwd{
  182. float: right;
  183. color: $text-color;
  184. }
  185. }
  186. }
  187. .login-btn{
  188. width: 600rpx;
  189. height: 88rpx;
  190. border-radius: 44rpx;
  191. font-size: $font-size-28;
  192. line-height: 88rpx;
  193. color: #FFFFFF;
  194. margin: 0 auto;
  195. text-align: center;
  196. background: $btn-confirm;
  197. }
  198. .login-btn-last{
  199. width: 600rpx;
  200. height: 86rpx;
  201. border-radius: 44rpx;
  202. font-size: $font-size-28;
  203. line-height: 88rpx;
  204. color: $color-system;
  205. margin: 0 auto;
  206. text-align: center;
  207. border: 1px solid $color-system;
  208. margin-top: 20rpx;
  209. }
  210. .login-tel{
  211. width: 702rpx;
  212. font-size: $font-size-28;
  213. line-height: 80rpx;
  214. margin: 0 auto;
  215. color: $text-color;
  216. text-align: center;
  217. margin-top: 150rpx;
  218. }
  219. .model-authorization{
  220. width: 100%;
  221. height: 100%;
  222. position: fixed;
  223. top: 0;
  224. left: 0;
  225. z-index: 999;
  226. .authorization{
  227. width: 518rpx;
  228. height: 320rpx;
  229. position: absolute;
  230. background: rgba(255,255,255,.7);
  231. left: 0;
  232. right: 0;
  233. bottom: 0;
  234. top: 0;
  235. margin: auto;
  236. .to-btn{
  237. position: absolute;
  238. top: 0;
  239. left: 0;
  240. right: 0;
  241. bottom: 0;
  242. margin: auto;
  243. width: 70%;
  244. height: 88rpx;
  245. font-size: $font-size-28;
  246. line-height: 88rpx;
  247. color: #FFFFFF;
  248. text-align: center;
  249. border-radius: 44rpx;
  250. }
  251. }
  252. }
  253. }
  254. </style>