index.vue 7.3 KB

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