login.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <div class="page">
  3. <div class="main">
  4. <div class="tit">用户登录</div>
  5. <div class="inp-box">
  6. <input
  7. type="text"
  8. name="userName"
  9. v-model="userName"
  10. placeholder="请输入账号"
  11. />
  12. </div>
  13. <div class="inp-box">
  14. <input
  15. type="password"
  16. name="password"
  17. v-model="password"
  18. placeholder="请输入密码"
  19. />
  20. </div>
  21. <button class="btn" @click="submit">确定</button>
  22. <div class="login-other">
  23. <a class="go-register" @click="jumpRegister"
  24. >去注册</a
  25. >
  26. <a
  27. class="find-password"
  28. @click="jump('/pages/index/find-password')"
  29. >找回密码</a
  30. >
  31. </div>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import MyImage from "../../components/image/index";
  37. export default {
  38. name: "",
  39. components: { MyImage },
  40. // 数据
  41. data() {
  42. return {
  43. userName: "",
  44. password: "",
  45. urlQuery:{},
  46. };
  47. },
  48. onLoad(opts) {
  49. this.urlQuery = opts;
  50. uni.hideLoading();
  51. },
  52. onShow() {},
  53. // 函数
  54. methods: {
  55. jumpRegister(){
  56. this.router.push({
  57. path:'/pages/index/register',
  58. query:this.urlQuery
  59. })
  60. },
  61. submit() {
  62. console.log(this.mobile);
  63. if (!this.userName) {
  64. this.fn.showToast(`请输入账号`);
  65. return;
  66. }
  67. if (!this.password) {
  68. this.fn.showToast(`请输入密码`);
  69. return;
  70. }
  71. uni.showLoading({
  72. title: "提交中",
  73. });
  74. uni.login({
  75. provider: "weixin",
  76. success: (result) => {
  77. // 判断团长号 验证
  78. this.login(result.code);
  79. },
  80. });
  81. },
  82. checkcode(data, res) {
  83. this.api
  84. .get("/Group/CheckCode", data, { pass: true })
  85. .then((res) => {
  86. if (res.success) {
  87. if (res.data.verified) {
  88. if (!res.data.storeId) {
  89. this.router.push({
  90. isTabBar: true,
  91. path: "/pages/assistant/index",
  92. });
  93. this.fn.setTabBar([3]);
  94. } else {
  95. this.router.push({
  96. isTabBar: true,
  97. path: "/pages/index/index",
  98. });
  99. this.fn.setTabBar([1, 2]);
  100. }
  101. } else {
  102. this.router.push({
  103. path: "/pages/index/register",
  104. query: {
  105. pidCode: res.data.code,
  106. step: 3,
  107. },
  108. });
  109. this.fn.setTabBar([3]);
  110. }
  111. } else {
  112. this.router.push({
  113. path: "/pages/index/register",
  114. query: {
  115. step: 2,
  116. },
  117. });
  118. this.fn.setTabBar([3]);
  119. }
  120. });
  121. },
  122. login(code) {
  123. this.api
  124. .post("/Login/LoginByAccount", {
  125. userName: this.userName,
  126. password: this.password,
  127. code: code,
  128. })
  129. .then((res) => {
  130. uni.hideLoading();
  131. if (res.success) {
  132. // 判断权限
  133. if (res.data.roleId && res.data.bundleId !== 0) {
  134. // if (res.data.authStatus === 0) {
  135. // // 未注册
  136. // this.router.replace({
  137. // path: "/pages/manage/mina/register",
  138. // });
  139. // return;
  140. // } else if (res.data.authStatus === 90) {
  141. // // 等待注册
  142. // this.router.replace({
  143. // path: "/pages/manage/mina/query",
  144. // });
  145. // return;
  146. // }
  147. // 正常用户
  148. this.$store.commit("user/login", res.data);
  149. this.$store.commit("common/update", {
  150. curShop: {},
  151. });
  152. if (!res.data.storeId) {
  153. this.router.push({
  154. isTabBar: true,
  155. path: "/pages/assistant/index",
  156. });
  157. this.fn.setTabBar([3]);
  158. } else {
  159. this.router.push({
  160. isTabBar: true,
  161. path: "/pages/index/index",
  162. });
  163. this.fn.setTabBar([1, 2]);
  164. }
  165. this.fn.roleHandle();
  166. return;
  167. } else {
  168. // 正常用户
  169. this.$store.commit("user/login", res.data);
  170. this.$store.commit("common/update", {
  171. curShop: {},
  172. });
  173. this.checkcode(
  174. {
  175. // code: "hht2120201",
  176. platform: res.data.fromPlatform,
  177. },
  178. res
  179. );
  180. }
  181. } else {
  182. this.fn.showModal({
  183. title: "登录失败",
  184. content: res.message,
  185. showCancel: false,
  186. });
  187. }
  188. });
  189. },
  190. },
  191. // 数据计算
  192. computed: {},
  193. // 数据监听
  194. watch: {},
  195. };
  196. </script>
  197. <style lang="scss" scoped>
  198. .page {
  199. height: 100vh;
  200. background-color: #fff;
  201. }
  202. .main {
  203. padding-top: px(120);
  204. padding-left: px(40);
  205. padding-right: px(40);
  206. }
  207. .tit {
  208. font-size: px(50);
  209. padding-bottom: px(100);
  210. text-align: center;
  211. padding-bottom: px(60);
  212. }
  213. .inp-box {
  214. display: flex;
  215. justify-content: space-between;
  216. align-items: center;
  217. border-bottom: 1px solid #c3c1c2;
  218. padding: px(30) 0;
  219. margin-bottom: px(30);
  220. }
  221. .inp-box span {
  222. font-size: px(32);
  223. color: #e92e25;
  224. border-radius: px(15);
  225. border: 1px solid #e92e25;
  226. width: px(230);
  227. height: px(80);
  228. text-align: center;
  229. line-height: px(80);
  230. flex-shrink: 0;
  231. margin-left: px(30);
  232. }
  233. .inp-box input {
  234. width: 100%;
  235. }
  236. .inp-box .dis {
  237. color: #999;
  238. border-color: #999;
  239. pointer-events: none;
  240. }
  241. .btn {
  242. margin-top: px(120);
  243. color: #fff;
  244. background-color: rgb(0, 188, 38);
  245. font-size: px(44);
  246. }
  247. .find-password {
  248. color: #666;
  249. }
  250. .login-other {
  251. margin-top: px(50);
  252. font-size: px(44);
  253. display: flex;
  254. justify-content: space-between;
  255. align-items: center;
  256. .go-register {
  257. color: #4395ff;
  258. }
  259. }
  260. </style>