login.vue 6.8 KB

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