index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <view>
  3. <!-- 商户管理端登录 -->
  4. <view class="login_bg" v-if="login_type === 'system'">
  5. <image src="../../static/img/login-bg.jpg" mode="scaleToFill"></image>
  6. <view class="login-title">商户管理端</view>
  7. <view class="login_content">
  8. <view class="login_info">
  9. <text class="login_tip" v-if="!forgetPwd_istrue">登录</text>
  10. <text class="login_tip" v-else>忘记密码</text>
  11. <!-- <text class="login_line">|</text> -->
  12. <!-- <text @click="login_istrue = false" :class="login_istrue ? '' : 'login_tip'">注册</text> -->
  13. </view>
  14. <view class="login_input" v-if="!forgetPwd_istrue">
  15. <input v-model="mobile" type="number" placeholder="请输入手机号" placeholder-class="inpput-pl" class="input_mobile" />
  16. <input v-model="password" type="password" placeholder="输入登录密码" placeholder-class="inpput-pl" class="input_mobile" style="margin-top: 60rpx;" />
  17. </view>
  18. <view class="login_input" v-else>
  19. <input v-model="forget_pwd.mobile" type="number" placeholder="请输入手机号" placeholder-class="inpput-pl" class="input_mobile" />
  20. <view class="clearfix" style="margin-top: 60rpx;">
  21. <input
  22. v-model="forget_pwd.yzm"
  23. type="number"
  24. placeholder="输入验证码"
  25. placeholder-class="inpput-pl"
  26. class="input_mobile float_left"
  27. style="width: 200rpx;"
  28. />
  29. <text class="yzm_btn float_right">获取验证码</text>
  30. </view>
  31. <input v-model="forget_pwd.password" type="password" placeholder="输入登录密码" placeholder-class="inpput-pl" class="input_mobile" style="margin-top: 60rpx;" />
  32. </view>
  33. <view class="login_bottom clearfix" v-if="!forgetPwd_istrue">
  34. <!-- <text class="password float_left" @click="forgetPwd_istrue=true">忘记密码?</text> -->
  35. <text class="password float_left" @click="login('test')">体验一下</text>
  36. <view class="btn float_right" @click="login()">
  37. <u-loading :show="is_loading" color="#ffffff" mode="flower"></u-loading>
  38. <text>登录</text>
  39. <text class="custom-icon custom-icon-jianto1-copy"></text>
  40. </view>
  41. </view>
  42. <view v-else class="login_bottom clearfix">
  43. <text class="password float_left" @click="forgetPwd_istrue = false">马上登录</text>
  44. <view class="btn float_right" @click="forgetPwd_istrue = false">
  45. <text class="login_tit">确定</text>
  46. <text class="custom-icon custom-icon-jianto1-copy"></text>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. export default {
  55. data() {
  56. return {
  57. login_type: 'system',
  58. login_istrue: true,
  59. is_loading: false,
  60. mobile: '',
  61. password: '',
  62. yzm: '',
  63. forgetPwd_istrue: false,
  64. forget_pwd: {
  65. mobile: '',
  66. password: '',
  67. yzm: ''
  68. }
  69. };
  70. },
  71. onShareAppMessage(res) {},
  72. methods: {
  73. changeLogin() {
  74. this.login_type = this.login_type === 'supplier' ? 'system' : 'supplier';
  75. },
  76. login(test) {
  77. // 体验一下
  78. let mobile = '';
  79. let password = '';
  80. if (test) {
  81. mobile = '18888888888';
  82. password = '123456';
  83. } else {
  84. if (!this.mobile) {
  85. this.$u.toast('请输入登录账号');
  86. return;
  87. }
  88. if (!this.password) {
  89. this.$u.toast('请输入密码');
  90. return;
  91. }
  92. mobile = this.mobile;
  93. password = this.password;
  94. }
  95. this.is_loading = true;
  96. let params = {
  97. mobile: mobile,
  98. password: password
  99. };
  100. if (this.login_type === 'supplier') {
  101. params.source = '2'; //1企业员工, 商户登录 2:供应商登录
  102. }
  103. this.$u.api
  104. .login(params)
  105. .then(res => {
  106. this.is_loading = false;
  107. this.$store.commit('commit_token', res.data.token);
  108. this.$store.commit('commit_hasLogin', true);
  109. if (res.data.enterprise.length > 1) {
  110. this.goPage('/pages/enterprise/index');
  111. } else if (res.data.enterprise.length === 1) {
  112. this.goShop(res.data.enterprise[0]);
  113. } else {
  114. this.$u.toast('抱歉当前账号没有企业');
  115. }
  116. })
  117. .catch(() => {
  118. this.is_loading = false;
  119. });
  120. },
  121. forgetPwd() {
  122. this.forgetPwd_istrue = true;
  123. },
  124. // 进入企业
  125. async goShop(row) {
  126. this.$store.commit('commit_enToken', row.token);
  127. this.$store.commit('commit_enterprise', row);
  128. if (this.login_type === 'system') {
  129. await this.getAclList(row.roleType);
  130. await this.getStaffByToken(row.roleType);
  131. this.goPage('/pages/index/index', 'switchTab');
  132. } else {
  133. await this.getSupplierByUserCenterId();
  134. }
  135. },
  136. //获取供应商详情
  137. async getSupplierByUserCenterId() {
  138. await this.$u.api.getSupplierByUserCenterId().then(res => {
  139. this.$store.commit('commit_supplierToken', res.data.token || '');
  140. this.$store.commit('commit_userInfo', res.data);
  141. // this.goPage('/pages/order/index', 'switchTab');
  142. });
  143. },
  144. // 获取登录权限
  145. async getAclList(roleType) {
  146. await this.$u.api.getAclList(roleType).then(res => {
  147. this.$store.commit('commit_access', res.data);
  148. });
  149. },
  150. async getStaffByToken(roleType) {
  151. await this.$u.api.getStaffByToken(roleType).then(res => {
  152. this.$store.commit('commit_userInfo', {
  153. ...res.data,
  154. name: res.data.name || this.mobile || '18888888888'
  155. });
  156. });
  157. }
  158. }
  159. };
  160. </script>
  161. <style>
  162. page {
  163. background-color: #fff;
  164. }
  165. </style>
  166. <style scoped lang="scss">
  167. .change-login {
  168. position: fixed;
  169. bottom: 0;
  170. height: 80rpx;
  171. width: 100%;
  172. left: 0;
  173. text-align: center;
  174. line-height: 80rpx;
  175. }
  176. .login_bg {
  177. position: relative;
  178. image {
  179. width: 100%;
  180. height: 458rpx;
  181. }
  182. .login-title {
  183. width: 100%;
  184. font-size: 48rpx;
  185. color: #fff;
  186. text-align: center;
  187. text-shadow: 0px 3rpx 24rpx rgba(10, 42, 177, 0.75);
  188. position: absolute;
  189. top: 50%;
  190. left: 50%;
  191. transform: translateX(-50%);
  192. }
  193. .login_icon {
  194. color: #fff;
  195. position: absolute;
  196. top: 24%;
  197. left: 4%;
  198. }
  199. .login_content {
  200. width: 100%;
  201. background-color: #fff;
  202. border-radius: 80rpx 80rpx 0px 0px;
  203. position: absolute;
  204. top: 83%;
  205. left: 0;
  206. .login_info {
  207. height: 280rpx;
  208. // padding-left: 100rpx;
  209. line-height: 280rpx;
  210. font-size: 36rpx;
  211. font-weight: 400;
  212. color: #333333;
  213. text-align: center;
  214. .login_line {
  215. margin: 0 40rpx 0 40rpx;
  216. width: 2rpx;
  217. height: 32rpx;
  218. color: #f1f1f1;
  219. display: inline-block;
  220. }
  221. .login_tip {
  222. font-size: 48rpx;
  223. font-weight: bold;
  224. color: #000000;
  225. }
  226. }
  227. .login_input {
  228. padding: 0 100rpx;
  229. .input_mobile {
  230. height: 100rpx;
  231. background-color: #f4f4fb;
  232. border-radius: 10rpx;
  233. padding: 0 50rpx;
  234. }
  235. .yzm_btn {
  236. width: 220rpx;
  237. height: 98rpx;
  238. border-radius: 12rpx;
  239. border: 1px solid #2979ff;
  240. color: #2979ff;
  241. font-size: 28rpx;
  242. text-align: center;
  243. font-weight: 500;
  244. line-height: 100rpx;
  245. }
  246. }
  247. .login_bottom {
  248. margin-top: 80rpx;
  249. padding: 0 100rpx 0 150rpx;
  250. .password {
  251. font-size: 24rpx;
  252. font-weight: 400;
  253. color: #999999;
  254. line-height: 100rpx;
  255. }
  256. .btn {
  257. width: 283rpx;
  258. height: 100rpx;
  259. background: linear-gradient(90deg, #072afe 0%, #06a0fa 100%);
  260. border-radius: 20rpx;
  261. color: #fff;
  262. padding: 0 60rpx;
  263. font-size: 36rpx;
  264. font-weight: 500;
  265. line-height: 100rpx;
  266. .custom-icon {
  267. margin-left: 46rpx;
  268. line-height: 100rpx;
  269. font-size: 36rpx;
  270. }
  271. }
  272. }
  273. }
  274. }
  275. </style>