login.vue 7.0 KB

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