login.vue 6.5 KB

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