login.vue 7.0 KB

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