login.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. authorize.getUserInfo('weixin').then(wxResponse =>{
  60. userInfoLogin({code:wechatcode,encryptedData:wxResponse.encryptedData,iv:wxResponse.iv}).then(response =>{
  61. if(response.data.userIdentity !=1){
  62. this.logout()
  63. uni.removeStorageSync('sessionid')
  64. uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
  65. this.isSeller= true
  66. }else{
  67. this.login(response.data);
  68. this.$store.commit('updateStatus',response.data)
  69. uni.setStorageSync('token',response.data.token)
  70. uni.removeStorageSync('sessionid')
  71. uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
  72. // this.$api.navigateTo('/market/pages/user/user')
  73. this.$api.navigateTo('/market/pages/index/index')
  74. }
  75. }).catch(response =>{
  76. this.logout()
  77. uni.removeStorageSync('sessionid')
  78. uni.setStorageSync('sessionid','JSESSIONID='+response.data)
  79. this.isSeller= true
  80. })
  81. })
  82. })
  83. },
  84. confirmLogin(){
  85. let params ={
  86. mobile:this.accountNumber,
  87. password:this.password
  88. }
  89. sellerLogin(params).then(response =>{
  90. if(response.code == '0' ){
  91. this.$store.commit('updateStatus',response.data)
  92. this.login(response.data);
  93. uni.setStorageSync('token',response.data.token)
  94. uni.removeStorageSync('sessionid')
  95. uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
  96. // this.$api.navigateTo('/market/pages/user/user')
  97. this.$api.navigateTo('/market/pages/index/index')
  98. }else{
  99. this.$util.msg(response.msg,2000);
  100. }
  101. })
  102. },
  103. storeUpdataeStatus(data){
  104. let user_key = {
  105. clubID:data.clubID,
  106. shopID:data.shopID,
  107. userID:data.userID,
  108. bindMobile:data.bindMobile,
  109. }
  110. uni.setStorageSync('token',data.token)
  111. this.$store.commit('updateStatus',user_key)
  112. this.login(data);
  113. },
  114. passwordClick() { //密码显隐操作
  115. this.isShowEye = !this.isShowEye;
  116. },
  117. },
  118. onShow() {
  119. //查看此微信用户是否已经授权过
  120. authorize.getSetting().then(res =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  121. if(res == 1){
  122. this.getCheekeyCode()
  123. }else{
  124. this.$api.navigateTo('/pages/authorization/authorization?type=2')
  125. }
  126. })
  127. }
  128. }
  129. </script>
  130. <style lang="scss">
  131. .login{
  132. width: 100%;
  133. height: auto;
  134. .model-warp.none{
  135. display: none;
  136. }
  137. .model-warp.show{
  138. display: block;
  139. }
  140. .login-main{
  141. width: 100%;
  142. display: flex;
  143. flex-direction: column;
  144. align-items: center;
  145. height: 198rpx;
  146. padding: 170rpx 0 60rpx 0;
  147. .logo{
  148. width: 138rpx;
  149. height: 118rpx;
  150. display: block;
  151. }
  152. .logo-text{
  153. font-size: 30rpx;
  154. line-height: 44rpx;
  155. color: $color-system;
  156. font-weight: 600;
  157. margin-top: 20rpx;
  158. }
  159. }
  160. .login-input{
  161. width: 654rpx;
  162. height: 40rpx;
  163. padding: 24rpx;
  164. margin: 0 auto;
  165. margin-bottom: 20rpx;
  166. background: #F7F7F7;
  167. border-radius: 14rpx;
  168. position: relative;
  169. .input{
  170. width: 100%;
  171. height: 100%;
  172. background: #F7F7F7;
  173. font-size: $font-size-28;
  174. line-height: 40rpx;
  175. color: #333333;
  176. border-radius: 14rpx;
  177. }
  178. .iconfont{
  179. position: absolute;
  180. right: 0;
  181. top: 0;
  182. font-size: 44rpx;
  183. color: #999999;
  184. font-weight: bold;
  185. z-index: 99;
  186. width: 96rpx;
  187. height: 96rpx;
  188. line-height: 96rpx;
  189. text-align: center;
  190. }
  191. &.link{
  192. background: #FFFFFF;
  193. margin-bottom: 40rpx;
  194. padding: 0 24rpx;
  195. line-height: 40rpx;
  196. font-size: $font-size-28;
  197. .login-reg{
  198. float: left;
  199. color: $color-system;
  200. }
  201. .login-pwd{
  202. float: right;
  203. color: $text-color;
  204. }
  205. }
  206. }
  207. .login-btn{
  208. width: 702rpx;
  209. height: 88rpx;
  210. border-radius: 14rpx;
  211. font-size: $font-size-28;
  212. line-height: 88rpx;
  213. color: #FFFFFF;
  214. margin: 0 auto;
  215. text-align: center;
  216. background: $btn-confirm;
  217. }
  218. .login-tel{
  219. width: 702rpx;
  220. font-size: $font-size-28;
  221. line-height: 240rpx;
  222. margin: 0 auto;
  223. color: $text-color;
  224. text-align: center;
  225. margin-top: 100rpx;
  226. }
  227. .model-authorization{
  228. width: 100%;
  229. height: 100%;
  230. position: fixed;
  231. top: 0;
  232. left: 0;
  233. z-index: 999;
  234. .authorization{
  235. width: 518rpx;
  236. height: 320rpx;
  237. position: absolute;
  238. background: rgba(255,255,255,.7);
  239. left: 0;
  240. right: 0;
  241. bottom: 0;
  242. top: 0;
  243. margin: auto;
  244. .to-btn{
  245. position: absolute;
  246. top: 0;
  247. left: 0;
  248. right: 0;
  249. bottom: 0;
  250. margin: auto;
  251. width: 70%;
  252. height: 88rpx;
  253. font-size: $font-size-28;
  254. line-height: 88rpx;
  255. color: #FFFFFF;
  256. text-align: center;
  257. border-radius: 44rpx;
  258. }
  259. }
  260. }
  261. }
  262. </style>