login.vue 6.9 KB

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