login.vue 7.0 KB

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