login.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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('/seller/pages/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. if(this.isWxAuthorize){
  97. this.SellerLogin()
  98. }else{
  99. console.log(new Date +'用户未授权微信信息')
  100. this.$api.navigateTo('/pages/authorization/authorization?type=1')
  101. }
  102. },
  103. SellerLogin(){
  104. this.SellerService.SellerLogin(this.params)
  105. .then(response =>{
  106. this.login(response.data);
  107. this.$store.commit('updateStatus',response.data)
  108. uni.setStorageSync('token',response.data.token)
  109. uni.setStorageSync('unionId',response.data.unionId)
  110. this.$api.navigateTo('/seller/pages/index/index')
  111. this.isSeller= false
  112. setTimeout(()=>{
  113. this.isSeller= true
  114. },1500)
  115. })
  116. .catch(error =>{
  117. this.$util.msg(error.msg,2000);
  118. })
  119. },
  120. storeUpdataeStatus(data){
  121. let user_key = {
  122. clubID:data.clubID,
  123. shopID:data.shopID,
  124. userID:data.userID,
  125. bindMobile:data.bindMobile,
  126. }
  127. uni.setStorageSync('token',data.token)
  128. this.$store.commit('updateStatus',user_key)
  129. this.login(data);
  130. },
  131. passwordClick() { //密码显隐操作
  132. this.isShowEye = !this.isShowEye;
  133. },
  134. },
  135. onShow() {
  136. if(this.isWxAuthorize){
  137. this.getWxAuthorize()
  138. }else{
  139. this.$api.navigateTo('/pages/authorization/authorization')
  140. this.isSeller= true
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="scss">
  146. .login{
  147. width: 100%;
  148. height: auto;
  149. .model-warp.none{
  150. display: none;
  151. }
  152. .model-warp.show{
  153. display: block;
  154. }
  155. .login-main{
  156. width: 100%;
  157. display: flex;
  158. flex-direction: column;
  159. align-items: center;
  160. height: 198rpx;
  161. padding: 170rpx 0 60rpx 0;
  162. .logo{
  163. width: 138rpx;
  164. height: 118rpx;
  165. display: block;
  166. }
  167. .logo-text{
  168. font-size: 30rpx;
  169. line-height: 44rpx;
  170. color: $color-system;
  171. font-weight: 600;
  172. margin-top: 20rpx;
  173. }
  174. }
  175. .login-input{
  176. width: 600rpx;
  177. height: 40rpx;
  178. padding: 24rpx 0;
  179. margin: 0 auto;
  180. margin-bottom: 20rpx;
  181. background: #FFFFFF;
  182. position: relative;
  183. border-bottom: 1px solid #E1E1E1;
  184. .input{
  185. width: 100%;
  186. height: 100%;
  187. background: #FFFFFF;
  188. font-size: $font-size-28;
  189. line-height: 40rpx;
  190. color: #333333;
  191. }
  192. .iconfont{
  193. position: absolute;
  194. right: 0;
  195. top: 0;
  196. font-size: 44rpx;
  197. color: #999999;
  198. font-weight: bold;
  199. z-index: 99;
  200. width: 96rpx;
  201. height: 96rpx;
  202. line-height: 96rpx;
  203. text-align: center;
  204. }
  205. &.link{
  206. background: #FFFFFF;
  207. margin-bottom: 40rpx;
  208. padding: 0 24rpx;
  209. line-height: 40rpx;
  210. font-size: $font-size-28;
  211. .login-reg{
  212. float: left;
  213. color: $color-system;
  214. }
  215. .login-pwd{
  216. float: right;
  217. color: $text-color;
  218. }
  219. }
  220. }
  221. .login-btn{
  222. width: 600rpx;
  223. height: 88rpx;
  224. border-radius:44rpx;
  225. font-size: $font-size-28;
  226. line-height: 88rpx;
  227. color: #FFFFFF;
  228. margin: 0 auto;
  229. text-align: center;
  230. background: $btn-confirm;
  231. margin-top: 100rpx;
  232. }
  233. .login-tel{
  234. width: 702rpx;
  235. font-size: $font-size-28;
  236. line-height: 240rpx;
  237. margin: 0 auto;
  238. color: $text-color;
  239. text-align: center;
  240. margin-top: 100rpx;
  241. }
  242. }
  243. </style>