login.vue 6.5 KB

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