index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. console.log('登录')
  79. let mobile = '';
  80. let password = '';
  81. if (test) {
  82. mobile = '18888888888';
  83. password = '123456';
  84. } else {
  85. if (!this.mobile) {
  86. this.$u.toast('请输入登录账号');
  87. return;
  88. }
  89. if (!this.password) {
  90. this.$u.toast('请输入密码');
  91. return;
  92. }
  93. mobile = this.mobile;
  94. password = this.password;
  95. }
  96. this.is_loading = true;
  97. let params = {
  98. mobile: mobile,
  99. password: password
  100. };
  101. if (this.login_type === 'supplier') {
  102. params.source = '2'; //1企业员工, 商户登录 2:供应商登录
  103. }
  104. this.$u.api
  105. .login(params)
  106. .then(res => {
  107. this.is_loading = false;
  108. this.$store.commit('commit_token', res.data.token);
  109. this.$store.commit('commit_hasLogin', true);
  110. if (res.data.enterprise.length > 1) {
  111. this.goPage('/pages/enterprise/index');
  112. } else if (res.data.enterprise.length === 1) {
  113. this.goShop(res.data.enterprise[0]);
  114. } else {
  115. this.$u.toast('抱歉当前账号没有企业');
  116. }
  117. })
  118. .catch((err) => {
  119. this.is_loading = false;
  120. console.log(err)
  121. console.log('错误')
  122. });
  123. },
  124. forgetPwd() {
  125. this.forgetPwd_istrue = true;
  126. },
  127. // 进入企业
  128. async goShop(row) {
  129. this.$store.commit('commit_enToken', row.token);
  130. this.$store.commit('commit_enterprise', row);
  131. if (this.login_type === 'system') {
  132. await this.getAclList(row.roleType);
  133. await this.getStaffByToken(row.roleType);
  134. this.goPage('/pages/index/index', 'switchTab');
  135. } else {
  136. await this.getSupplierByUserCenterId();
  137. }
  138. },
  139. //获取供应商详情
  140. async getSupplierByUserCenterId() {
  141. await this.$u.api.getSupplierByUserCenterId().then(res => {
  142. this.$store.commit('commit_supplierToken', res.data.token || '');
  143. this.$store.commit('commit_userInfo', res.data);
  144. // this.goPage('/pages/order/index', 'switchTab');
  145. });
  146. },
  147. // 获取登录权限
  148. async getAclList(roleType) {
  149. await this.$u.api.getAclList(roleType).then(res => {
  150. this.$store.commit('commit_access', res.data);
  151. });
  152. },
  153. async getStaffByToken(roleType) {
  154. await this.$u.api.getStaffByToken(roleType).then(res => {
  155. this.$store.commit('commit_userInfo', {
  156. ...res.data,
  157. name: res.data.name || this.mobile || '18888888888'
  158. });
  159. });
  160. }
  161. }
  162. };
  163. </script>
  164. <style>
  165. page {
  166. background-color: #fff;
  167. }
  168. </style>
  169. <style scoped lang="scss">
  170. .change-login {
  171. position: fixed;
  172. bottom: 0;
  173. height: 80rpx;
  174. width: 100%;
  175. left: 0;
  176. text-align: center;
  177. line-height: 80rpx;
  178. }
  179. .login_bg {
  180. position: relative;
  181. image {
  182. width: 100%;
  183. height: 458rpx;
  184. }
  185. .login-title {
  186. width: 100%;
  187. font-size: 48rpx;
  188. color: #fff;
  189. text-align: center;
  190. text-shadow: 0px 3rpx 24rpx rgba(10, 42, 177, 0.75);
  191. position: absolute;
  192. top: 50%;
  193. left: 50%;
  194. transform: translateX(-50%);
  195. }
  196. .login_icon {
  197. color: #fff;
  198. position: absolute;
  199. top: 24%;
  200. left: 4%;
  201. }
  202. .login_content {
  203. width: 100%;
  204. background-color: #fff;
  205. border-radius: 80rpx 80rpx 0px 0px;
  206. position: absolute;
  207. top: 83%;
  208. left: 0;
  209. .login_info {
  210. height: 280rpx;
  211. // padding-left: 100rpx;
  212. line-height: 280rpx;
  213. font-size: 36rpx;
  214. font-weight: 400;
  215. color: #333333;
  216. text-align: center;
  217. .login_line {
  218. margin: 0 40rpx 0 40rpx;
  219. width: 2rpx;
  220. height: 32rpx;
  221. color: #f1f1f1;
  222. display: inline-block;
  223. }
  224. .login_tip {
  225. font-size: 48rpx;
  226. font-weight: bold;
  227. color: #000000;
  228. }
  229. }
  230. .login_input {
  231. padding: 0 100rpx;
  232. .input_mobile {
  233. height: 100rpx;
  234. background-color: #f4f4fb;
  235. border-radius: 10rpx;
  236. padding: 0 50rpx;
  237. }
  238. .yzm_btn {
  239. width: 220rpx;
  240. height: 98rpx;
  241. border-radius: 12rpx;
  242. border: 1px solid #2979ff;
  243. color: #2979ff;
  244. font-size: 28rpx;
  245. text-align: center;
  246. font-weight: 500;
  247. line-height: 100rpx;
  248. }
  249. }
  250. .login_bottom {
  251. margin-top: 80rpx;
  252. padding: 0 100rpx 0 150rpx;
  253. .password {
  254. font-size: 24rpx;
  255. font-weight: 400;
  256. color: #999999;
  257. line-height: 100rpx;
  258. }
  259. .btn {
  260. width: 283rpx;
  261. height: 100rpx;
  262. background: linear-gradient(90deg, #072afe 0%, #06a0fa 100%);
  263. border-radius: 20rpx;
  264. color: #fff;
  265. padding: 0 60rpx;
  266. font-size: 36rpx;
  267. font-weight: 500;
  268. line-height: 100rpx;
  269. .custom-icon {
  270. margin-left: 46rpx;
  271. line-height: 100rpx;
  272. font-size: 36rpx;
  273. }
  274. }
  275. }
  276. }
  277. }
  278. </style>