login.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view class="container login" :style="{paddingTop:CustomBar+'px'}" v-if="isSeller">
  3. <cu-custom :navbar-data='nvabarData' @navigateBack="hanldNavigateBack"></cu-custom>
  4. <view class="login-main">
  5. <image class="logo" src="../../../static/login-logo@3x.png" mode=""></image>
  6. <text class="logo-text">生美/医美采购服务平台</text>
  7. </view>
  8. <view class="login-form">
  9. <view class="login-input">
  10. <input type="text"
  11. v-model="accountNumber"
  12. maxlength="11"
  13. class="input"
  14. placeholder="请输入手机号"
  15. />
  16. </view>
  17. <view class="login-input">
  18. <input v-show="isShowEye" type="text" v-model="password" maxlength="18" class="input" placeholder="请输入密码" autocomplete="new-password"/>
  19. <input v-show="!isShowEye" type="password" v-model="password" :password="true" maxlength="18" class="input" placeholder="请输入密码" autocomplete="new-password"/>
  20. <view class="iconfont" :class="isShowEye ? iconEyen : iconEyes" @click="passwordClick"></view>
  21. </view>
  22. </view>
  23. <view class="login-btn" @click="confirmLogin">登录</view>
  24. <view class="login-tel">客服热线:0755-22907771</view>
  25. </view>
  26. </template>
  27. <script>
  28. import { mapMutations } from 'vuex';
  29. import authorize from '@/common/config/authorize.js'
  30. import { sellerLogin } from '@/api/seller.js'
  31. import { userInfoLogin } from "@/api/use.js"
  32. var self;
  33. export default{
  34. data() {
  35. return{
  36. nvabarData: { //顶部自定义导航
  37. showCapsule: 0, // 是否显示左上角图标 1表示显示 0表示不显示,
  38. showSearch: 0,
  39. title: '登录', // 导航栏 中间的标题
  40. },
  41. isIphoneX:this.$store.state.isIphoneX,
  42. CustomBar:this.CustomBar,// 顶部导航栏高度
  43. isShowEye:false,
  44. isSeller:false,
  45. iconEyes:'icon-yanjing_yincang_o',
  46. iconEyen:'icon-yanjing_xianshi_o',
  47. accountNumber:'', //协销用户登录账号
  48. password:'', //协销登录密码
  49. }
  50. },
  51. onLoad(option) {
  52. this.getOption = JSON.stringify(option)
  53. },
  54. methods:{
  55. ...mapMutations(['login','logout']),
  56. getCheekeyCode(){
  57. authorize.getCode('weixin').then(wechatcode =>{
  58. // 根据微信的code获取用户登录状态:1已登录过 -1未登录过
  59. userInfoLogin({code:wechatcode}).then(response =>{
  60. if(response.data.userIdentity !=1){
  61. this.logout()
  62. uni.removeStorageSync('sessionid')
  63. uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
  64. this.isSeller= true
  65. }else{
  66. this.login(response.data);
  67. this.$store.commit('updateStatus',response.data)
  68. uni.setStorageSync('token',response.data.token)
  69. uni.removeStorageSync('sessionid')
  70. uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
  71. // this.$api.navigateTo('/market/pages/user/user')
  72. this.$api.navigateTo('/market/pages/index/index')
  73. }
  74. }).catch(response =>{
  75. this.logout()
  76. uni.removeStorageSync('sessionid')
  77. uni.setStorageSync('sessionid','JSESSIONID='+response.data)
  78. this.isSeller= true
  79. })
  80. })
  81. },
  82. confirmLogin(){
  83. let params ={
  84. mobile:this.accountNumber,
  85. password:this.password
  86. }
  87. sellerLogin(params).then(response =>{
  88. if(response.code == '0' ){
  89. this.$store.commit('updateStatus',response.data)
  90. this.login(response.data);
  91. uni.setStorageSync('token',response.data.token)
  92. uni.removeStorageSync('sessionid')
  93. uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
  94. // this.$api.navigateTo('/market/pages/user/user')
  95. this.$api.navigateTo('/market/pages/index/index')
  96. }else{
  97. this.$util.msg(response.msg,2000);
  98. }
  99. })
  100. },
  101. storeUpdataeStatus(data){
  102. let user_key = {
  103. clubID:data.clubID,
  104. shopID:data.shopID,
  105. userID:data.userID,
  106. bindMobile:data.bindMobile,
  107. }
  108. uni.setStorageSync('token',data.token)
  109. this.$store.commit('updateStatus',user_key)
  110. this.login(data);
  111. },
  112. passwordClick() { //密码显隐操作
  113. this.isShowEye = !this.isShowEye;
  114. },
  115. },
  116. onShow() {
  117. //查看此微信用户是否已经授权过
  118. authorize.getSetting().then(res =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  119. if(res == 1){
  120. this.getCheekeyCode()
  121. }else{
  122. this.$api.navigateTo('/pages/authorization/authorization?type=2')
  123. }
  124. })
  125. }
  126. }
  127. </script>
  128. <style lang="scss">
  129. .login{
  130. width: 100%;
  131. height: auto;
  132. .model-warp.none{
  133. display: none;
  134. }
  135. .model-warp.show{
  136. display: block;
  137. }
  138. .login-main{
  139. width: 100%;
  140. display: flex;
  141. flex-direction: column;
  142. align-items: center;
  143. height: 198rpx;
  144. padding: 170rpx 0 60rpx 0;
  145. .logo{
  146. width: 138rpx;
  147. height: 118rpx;
  148. display: block;
  149. }
  150. .logo-text{
  151. font-size: 30rpx;
  152. line-height: 44rpx;
  153. color: $color-system;
  154. font-weight: 600;
  155. margin-top: 20rpx;
  156. }
  157. }
  158. .login-input{
  159. width: 654rpx;
  160. height: 40rpx;
  161. padding: 24rpx;
  162. margin: 0 auto;
  163. margin-bottom: 20rpx;
  164. background: #F7F7F7;
  165. border-radius: 14rpx;
  166. position: relative;
  167. .input{
  168. width: 100%;
  169. height: 100%;
  170. background: #F7F7F7;
  171. font-size: $font-size-28;
  172. line-height: 40rpx;
  173. color: #333333;
  174. border-radius: 14rpx;
  175. }
  176. .iconfont{
  177. position: absolute;
  178. right: 0;
  179. top: 0;
  180. font-size: 44rpx;
  181. color: #999999;
  182. font-weight: bold;
  183. z-index: 99;
  184. width: 96rpx;
  185. height: 96rpx;
  186. line-height: 96rpx;
  187. text-align: center;
  188. }
  189. &.link{
  190. background: #FFFFFF;
  191. margin-bottom: 40rpx;
  192. padding: 0 24rpx;
  193. line-height: 40rpx;
  194. font-size: $font-size-28;
  195. .login-reg{
  196. float: left;
  197. color: $color-system;
  198. }
  199. .login-pwd{
  200. float: right;
  201. color: $text-color;
  202. }
  203. }
  204. }
  205. .login-btn{
  206. width: 702rpx;
  207. height: 88rpx;
  208. border-radius: 14rpx;
  209. font-size: $font-size-28;
  210. line-height: 88rpx;
  211. color: #FFFFFF;
  212. margin: 0 auto;
  213. text-align: center;
  214. background: $btn-confirm;
  215. }
  216. .login-tel{
  217. width: 702rpx;
  218. font-size: $font-size-28;
  219. line-height: 240rpx;
  220. margin: 0 auto;
  221. color: $text-color;
  222. text-align: center;
  223. margin-top: 100rpx;
  224. }
  225. .model-authorization{
  226. width: 100%;
  227. height: 100%;
  228. position: fixed;
  229. top: 0;
  230. left: 0;
  231. z-index: 999;
  232. .authorization{
  233. width: 518rpx;
  234. height: 320rpx;
  235. position: absolute;
  236. background: rgba(255,255,255,.7);
  237. left: 0;
  238. right: 0;
  239. bottom: 0;
  240. top: 0;
  241. margin: auto;
  242. .to-btn{
  243. position: absolute;
  244. top: 0;
  245. left: 0;
  246. right: 0;
  247. bottom: 0;
  248. margin: auto;
  249. width: 70%;
  250. height: 88rpx;
  251. font-size: $font-size-28;
  252. line-height: 88rpx;
  253. color: #FFFFFF;
  254. text-align: center;
  255. border-radius: 44rpx;
  256. }
  257. }
  258. }
  259. }
  260. </style>