login.vue 6.1 KB

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