login.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. if(this.isWxAuthorize){
  66. this.AorganizationLogin()
  67. }else{
  68. console.log(new Date +'用户未授权微信信息')
  69. this.$api.navigateTo('/pages/authorization/authorization?type=0')
  70. }
  71. },
  72. AorganizationLogin(){
  73. this.UserService.AorganizationLogin(this.params)
  74. .then(response =>{
  75. if(response.code === 0){
  76. this.storeUpdataeStatus(response.data)
  77. this.$api.navigateTo(`/pages/login/bindwechat?data=${JSON.stringify(this.getOption)}&codeType=${response.code}`)
  78. }else if(response.code === -3){
  79. this.$util.modal('','您的企业账号审核未通过,请修改资料','前往修改','',false,() =>{
  80. this.$store.commit('updateStatus',response.data)
  81. this.$api.navigateTo('/pages/login/apply-supplier')
  82. })
  83. }else{
  84. this.$util.msg(response.msg,2000);
  85. }
  86. })
  87. },
  88. storeUpdataeStatus(data){
  89. uni.setStorageSync('token',data.token)
  90. this.$store.commit('updateStatus',data)
  91. this.login(data);
  92. },
  93. passwordClick() { //密码显隐操作
  94. this.isShowEye = !this.isShowEye;
  95. },
  96. async InitAuthorize(){ //是否已授权 0:为取消授权 1:为已授权 2:为未操作
  97. if(this.isWxAuthorize){
  98. wxLogin.wxLoginQuick()
  99. }else{
  100. console.log(new Date +'用户未授权微信信息')
  101. this.$api.navigateTo('/pages/authorization/authorization?type=0')
  102. }
  103. }
  104. },
  105. onShow() {
  106. this.$api.getStorage().then((resolve) =>{
  107. this.params.unionId = resolve.unionId
  108. })
  109. this.InitAuthorize()
  110. }
  111. }
  112. </script>
  113. <style lang="scss">
  114. .login{
  115. width: 100%;
  116. height: auto;
  117. .model-warp.none{
  118. display: none;
  119. }
  120. .model-warp.show{
  121. display: block;
  122. }
  123. .login-main{
  124. width: 100%;
  125. display: flex;
  126. flex-direction: column;
  127. align-items: center;
  128. height: 189rpx;
  129. padding:60rpx 0 40rpx 0;
  130. margin-bottom: 70rpx;
  131. .logo{
  132. width:467rpx;
  133. height: 189rpx;
  134. display: block;
  135. }
  136. }
  137. .login-input{
  138. width: 600rpx;
  139. height: 88rpx;
  140. padding: 24rpx 0;
  141. margin: 0 auto;
  142. margin-bottom: 30rpx;
  143. background: #FFFFFF;
  144. position: relative;
  145. box-sizing: border-box;
  146. border-bottom: 1px solid #e1e1e1;
  147. .input{
  148. width: 100%;
  149. height: 100%;
  150. background: #FFFFFF;
  151. font-size: $font-size-28;
  152. line-height: 88rpx;
  153. color: #333333;
  154. }
  155. .iconfont{
  156. position: absolute;
  157. right: 0;
  158. top: 0;
  159. font-size: 44rpx;
  160. color: #999999;
  161. font-weight: bold;
  162. z-index: 99;
  163. width: 96rpx;
  164. height: 96rpx;
  165. line-height: 96rpx;
  166. text-align: center;
  167. }
  168. &.link{
  169. background: #FFFFFF;
  170. margin-bottom: 40rpx;
  171. padding: 0 0;
  172. line-height: 40rpx;
  173. font-size: $font-size-28;
  174. border-bottom: none;
  175. .login-reg{
  176. float: left;
  177. color: $color-system;
  178. }
  179. .login-pwd{
  180. float: right;
  181. color: $text-color;
  182. }
  183. }
  184. }
  185. .login-btn{
  186. width: 600rpx;
  187. height: 88rpx;
  188. border-radius: 44rpx;
  189. font-size: $font-size-28;
  190. line-height: 88rpx;
  191. color: #FFFFFF;
  192. margin: 0 auto;
  193. text-align: center;
  194. background: $btn-confirm;
  195. }
  196. .login-btn-last{
  197. width: 600rpx;
  198. height: 86rpx;
  199. border-radius: 44rpx;
  200. font-size: $font-size-28;
  201. line-height: 88rpx;
  202. color: $color-system;
  203. margin: 0 auto;
  204. text-align: center;
  205. border: 1px solid $color-system;
  206. margin-top: 20rpx;
  207. }
  208. .login-tel{
  209. width: 702rpx;
  210. font-size: $font-size-28;
  211. line-height: 80rpx;
  212. margin: 0 auto;
  213. color: $text-color;
  214. text-align: center;
  215. margin-top: 150rpx;
  216. }
  217. .model-authorization{
  218. width: 100%;
  219. height: 100%;
  220. position: fixed;
  221. top: 0;
  222. left: 0;
  223. z-index: 999;
  224. .authorization{
  225. width: 518rpx;
  226. height: 320rpx;
  227. position: absolute;
  228. background: rgba(255,255,255,.7);
  229. left: 0;
  230. right: 0;
  231. bottom: 0;
  232. top: 0;
  233. margin: auto;
  234. .to-btn{
  235. position: absolute;
  236. top: 0;
  237. left: 0;
  238. right: 0;
  239. bottom: 0;
  240. margin: auto;
  241. width: 70%;
  242. height: 88rpx;
  243. font-size: $font-size-28;
  244. line-height: 88rpx;
  245. color: #FFFFFF;
  246. text-align: center;
  247. border-radius: 44rpx;
  248. }
  249. }
  250. }
  251. }
  252. </style>