login.vue 6.5 KB

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