login.vue 5.9 KB

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