login.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955
  1. <template>
  2. <view class="container">
  3. <!-- <image @click="navBack" src="../../static/images/index/close.png" style="width: 32upx;height: 32upx;margin-left: 46upx;"></image> -->
  4. <!-- 小程序状态下登录 -->
  5. <!-- #ifdef MP-WEIXIN -->
  6. <view class="login-box">
  7. <view class="mp_wxBox">
  8. <view>
  9. <view class="logo-box">
  10. <image src="@/static/images/jobApplicant/logo.svg" mode="scaleToFill" />
  11. </view>
  12. <view class="content">
  13. <view>申请获取以下权限</view>
  14. <text>获得你的公开信息(昵称,头像、地区等)</text>
  15. </view>
  16. <view v-if="weixinPhone == true || weixinPhone == 'true'" class="login-btn wechat"
  17. open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
  18. <image src="@/static/images/jobApplicant/phone.svg" mode="scaleToFill" />
  19. 授权手机号
  20. </view>
  21. <button v-else style="background: rgba(13, 39, 247, 1); color: #ffffff" class="bottom"
  22. bindtap="getUserProfile" @tap="login()">
  23. 授权登录
  24. </button>
  25. </view>
  26. </view>
  27. <view style="text-align: center">
  28. <view class="footer">
  29. <view class="check-box" @click="checked = !checked">
  30. <image src="@/static/images/jobApplicant/check.svg" v-if="checked" mode="scaleToFill" />
  31. <image src="@/static/images/jobApplicant/border.svg" v-else mode="scaleToFill" />
  32. </view>
  33. 已阅读并同意<navigator url="/my/setting/xieyi">《亿职赞用户协议》</navigator>
  34. 和<navigator url="/my/setting/mimi">《隐私协议》</navigator>,允许亿职赞统一管理本人账号信息
  35. </view>
  36. </view>
  37. </view>
  38. <!-- #endif -->
  39. <!-- #ifndef MP-WEIXIN -->
  40. <view style="text-align: center" class="login-box">
  41. <view class="logo-box">
  42. <image src="@/static/images/jobApplicant/logo.svg" mode="scaleToFill" />
  43. </view>
  44. <!-- <button class="confirm-btn" style="margin-top: 100rpx" @click="register">
  45. 手机号登录
  46. </button> -->
  47. <!-- #ifdef APP -->
  48. <!-- <view v-if="!isAndroid" class="login-btn apple" :class="{ disabled: !checked }" :disabled="checked" @click="appleLogin">
  49. <image src="@/static/images/ios.svg" mode="scaleToFill" />通过Apple登录
  50. </view> -->
  51. <view v-if="isAndroid" class="login-btn wechat" :class="{ disabled: !checked }" :disabled="checked" @click="wxAppLogin">
  52. <image src="@/static/images/jobApplicant/wx.svg" mode="scaleToFill" />微信登录
  53. </view>
  54. <!-- #endif -->
  55. <view class="login-btn password" :class="{ disabled: !checked }" :disabled="checked" @click="register(1)">
  56. <image src="@/static/images/jobApplicant/account.svg" mode="scaleToFill" />账号密码登录
  57. </view>
  58. <view class="login-btn wechat" :class="{ disabled: !checked }" :disabled="checked" @click="register(2)">
  59. <image src="@/static/images/jobApplicant/phone.svg" mode="scaleToFill" />手机验证码登录
  60. </view>
  61. <!-- <view class="" v-if="isopen" @click="weixinLo" style="width: 100%; padding-top: 100rpx">
  62. <view class="">
  63. <u-icon name="weixin-circle-fill" color="#5fcd73" size="100"></u-icon>
  64. </view>
  65. <view class="login-btn wechat"> 公众号快捷登录 </view>
  66. </view> -->
  67. <!-- 底部信息 -->
  68. <view class="footer">
  69. <view class="check-box" @click="checked = !checked">
  70. <image src="@/static/images/jobApplicant/check.svg" v-if="checked" mode="scaleToFill" />
  71. <image src="@/static/images/jobApplicant/border.svg" v-else mode="scaleToFill" />
  72. </view>
  73. 已阅读并同意<navigator url="/my/setting/xieyi">《亿职赞用户协议》</navigator>
  74. 和<navigator url="/my/setting/mimi">《隐私协议》</navigator>,允许亿职赞统一管理本人账号信息
  75. </view>
  76. <!-- <view class="footer">
  77. <u-checkbox shape="circle" v-model="checked"> </u-checkbox>
  78. <text>同意</text>
  79. 协议地址
  80. <navigator url="/my/setting/mimi" open-type="navigate">《隐私政策》</navigator>
  81. <navigator url="/my/setting/xieyi" open-type="navigate">《用户协议》</navigator>
  82. </view> -->
  83. </view>
  84. <!-- #endif -->
  85. </view>
  86. </template>
  87. <script>
  88. export default {
  89. data() {
  90. return {
  91. checked: false,
  92. mobile: "",
  93. code: "",
  94. weixinLogin: false,
  95. sending: false,
  96. sendTime: "获取验证码",
  97. count: 60,
  98. weixinPhone: false,
  99. sendDataList: {},
  100. sessionkey: "",
  101. phoneNum: false,
  102. isopen: false,
  103. isAndroid:false,
  104. };
  105. },
  106. onLoad(e) {
  107. if (e.inviterCode) {
  108. this.$queue.setData("inviterCode", e.inviterCode);
  109. }
  110. console.log(uni.getSystemInfoSync());
  111. this.isAndroid=uni.getSystemInfoSync().platform=='android'
  112. this.sessionkey = uni.getStorageSync("sessionkey");
  113. this.weixinPhone = uni.getStorageSync("weixinPhone");
  114. console.log(this.weixinPhone);
  115. if (uni.getStorageSync("sendDataList")) {
  116. this.sendDataList = uni.getStorageSync("sendDataList");
  117. }
  118. // //微信登录开启
  119. // this.$Request.getT('/app/common/type/53').then(res => {
  120. // if (res.code == 0) {
  121. // if (res.data && res.data.value && res.data.value == '是') {
  122. // // this.weixinLogin = true;
  123. // }
  124. // }
  125. // });
  126. this.$Request.getT("/app/common/type/188").then((res) => {
  127. if (res.code == 0) {
  128. if (res.data && res.data.value && res.data.value == "是") {
  129. this.phoneNum = true;
  130. }
  131. }
  132. });
  133. // #ifdef H5
  134. let ua = navigator.userAgent.toLowerCase();
  135. if (ua.indexOf("micromessenger") !== -1) {
  136. //公众号是否自动登录 108
  137. this.$Request.getT("/app/common/type/108").then((res) => {
  138. if (res.code == 0) {
  139. if (res.data && res.data.value && res.data.value == "是") {
  140. this.isopen = true;
  141. } else {
  142. this.isopen = false;
  143. }
  144. }
  145. });
  146. } else {
  147. this.isopen = false;
  148. }
  149. this.selbindwx();
  150. // #endif
  151. },
  152. methods: {
  153. selbindwx() {
  154. let ua = navigator.userAgent.toLowerCase();
  155. if (ua.indexOf("micromessenger") !== -1) {
  156. let openid = uni.getStorageSync("openid");
  157. let userId = uni.getStorageSync("userId");
  158. // let that = this;
  159. if (
  160. window.location.href.indexOf("?code=") !== -1 ||
  161. window.location.href.indexOf("&code=") !== -1
  162. ) {
  163. let code;
  164. if (window.location.href.indexOf("?code=") !== -1) {
  165. code = window.location.href.split("?code=")[1].split("&")[0];
  166. } else {
  167. code = window.location.href.split("&code=")[1].split("&")[0];
  168. }
  169. let data = {
  170. code: code,
  171. };
  172. this.$Request.getT("/app/Login/getOpenId", data).then((ret) => {
  173. if (ret.code == 0) {
  174. uni.setStorageSync("openid", ret.data);
  175. this.$Request
  176. .getT("/app/Login/openid/login", {
  177. openId: ret.data,
  178. })
  179. .then((res) => {
  180. if (res.code == 0) {
  181. uni.setStorageSync("token", res.token);
  182. uni.setStorageSync("userName", res.user.userName);
  183. uni.setStorageSync("avatar", res.user.avatar);
  184. uni.setStorageSync("phone", res.user.phone);
  185. uni.setStorageSync("invitationCode", res.user.invitationCode);
  186. this.$queue.setData("inviterCode", res.user.inviterCode);
  187. uni.setStorageSync("sex", res.user.sex);
  188. uni.setStorageSync("userId", res.user.userId);
  189. uni.setStorageSync("openId", res.user.openId);
  190. uni.setStorageSync("userType", res.user.userType);
  191. this.$Request.get("/app/UserVip/isUserVip").then((res) => {
  192. if (res.code == 0 && res.data && res.data.isVip == 2) {
  193. uni.setStorageSync("isVIP", true);
  194. } else {
  195. uni.setStorageSync("isVIP", false);
  196. }
  197. });
  198. //判断是否开启身份选择 是/否
  199. this.$Request.get("/app/common/type/339").then((rest) => {
  200. if (rest.code == 0) {
  201. if (rest.data.value == "是") {
  202. uni.reLaunch({
  203. url: "/pages/public/selectIdentity/selectIdentity",
  204. });
  205. } else {
  206. uni.navigateBack();
  207. }
  208. } else {
  209. uni.navigateBack();
  210. }
  211. });
  212. } else {
  213. uni.navigateTo({
  214. url: "/pages/public/bind",
  215. });
  216. }
  217. });
  218. }
  219. });
  220. }
  221. }
  222. },
  223. // //微信公众号登录
  224. // weixinLo() {
  225. // if (this.checked == false) {
  226. // uni.showToast({
  227. // title: "请先同意《隐私政策》和《用户服务协议》",
  228. // icon: "none",
  229. // });
  230. // return;
  231. // }
  232. // let ua = navigator.userAgent.toLowerCase();
  233. // if (ua.indexOf("micromessenger") !== -1) {
  234. // let openid = uni.getStorageSync("openid");
  235. // let userId = uni.getStorageSync("userId");
  236. // if (!openid) {
  237. // if (
  238. // window.location.href.indexOf("?code=") !== -1 ||
  239. // window.location.href.indexOf("&code=") !== -1
  240. // ) {
  241. // let code;
  242. // if (window.location.href.indexOf("?code=") !== -1) {
  243. // code = window.location.href.split("?code=")[1].split("&")[0];
  244. // } else {
  245. // code = window.location.href.split("&code=")[1].split("&")[0];
  246. // }
  247. // let data = {
  248. // code: code,
  249. // };
  250. // this.$Request.getT("/app/Login/getOpenId", data).then((res) => {
  251. // if (ret.code == 0) {
  252. // uni.setStorageSync("openid", ret.data);
  253. // let datas = {
  254. // openId: ret.data,
  255. // };
  256. // this.$Request.getT("/app/Login/openid/login", datas).then((res) => {
  257. // if (res.code == 0) {
  258. // uni.setStorageSync("token", res.token);
  259. // uni.setStorageSync("userName", res.user.userName);
  260. // uni.setStorageSync("avatar", res.user.avatar);
  261. // uni.setStorageSync("phone", res.user.phone);
  262. // uni.setStorageSync("invitationCode", res.user.invitationCode);
  263. // this.$queue.setData("inviterCode", res.user.inviterCode);
  264. // uni.setStorageSync("sex", res.user.sex);
  265. // uni.setStorageSync("userId", res.user.userId);
  266. // uni.setStorageSync("openId", res.user.openId);
  267. // uni.setStorageSync("userType", res.user.userType);
  268. // this.$Request.get("/app/UserVip/isUserVip").then((res) => {
  269. // if (res.code == 0 && res.data && res.data.isVip ==
  270. // 2) {
  271. // uni.setStorageSync("isVIP", true);
  272. // } else {
  273. // uni.setStorageSync("isVIP", false);
  274. // }
  275. // });
  276. // //判断是否开启身份选择 是/否
  277. // this.$Request.get("/app/common/type/339").then((rest) => {
  278. // if (rest.code == 0) {
  279. // if (rest.data.value == "是") {
  280. // uni.reLaunch({
  281. // url: "/pages/public/selectIdentity/selectIdentity",
  282. // });
  283. // } else {
  284. // uni.navigateBack();
  285. // }
  286. // } else {
  287. // uni.navigateBack();
  288. // }
  289. // });
  290. // } else {
  291. // uni.navigateTo({
  292. // url: "/pages/public/bind",
  293. // });
  294. // }
  295. // });
  296. // }
  297. // });
  298. // } else {
  299. // let that = this;
  300. // window.location.href =
  301. // "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" +
  302. // that.$queue.getWxAppid() +
  303. // "&redirect_uri=" +
  304. // window.location.href.split("#")[0] +
  305. // "&response_type=code&scope=snsapi_userinfo#wechat_redirect";
  306. // }
  307. // } else {
  308. // this.$Request
  309. // .getT("/app/Login/openid/login", {
  310. // openId: openid,
  311. // })
  312. // .then((res) => {
  313. // if (res.code == 0) {
  314. // uni.setStorageSync("token", res.token);
  315. // uni.setStorageSync("userName", res.user.userName);
  316. // uni.setStorageSync("avatar", res.user.avatar);
  317. // uni.setStorageSync("phone", res.user.phone);
  318. // uni.setStorageSync("invitationCode", res.user.invitationCode);
  319. // this.$queue.setData("inviterCode", res.user.inviterCode);
  320. // uni.setStorageSync("sex", res.user.sex);
  321. // uni.setStorageSync("userId", res.user.userId);
  322. // uni.setStorageSync("openId", res.user.openId);
  323. // uni.setStorageSync("userType", res.user.userType);
  324. // this.$Request.get("/app/UserVip/isUserVip").then((res) => {
  325. // if (res.code == 0 && res.data && res.data.isVip == 2) {
  326. // uni.setStorageSync("isVIP", true);
  327. // } else {
  328. // uni.setStorageSync("isVIP", false);
  329. // }
  330. // });
  331. // //判断是否开启身份选择 是/否
  332. // this.$Request.get("/app/common/type/339").then((rest) => {
  333. // if (rest.code == 0) {
  334. // if (rest.data.value == "是") {
  335. // uni.reLaunch({
  336. // url: "/pages/public/selectIdentity/selectIdentity",
  337. // });
  338. // } else {
  339. // uni.navigateBack();
  340. // }
  341. // } else {
  342. // uni.navigateBack();
  343. // }
  344. // });
  345. // } else {
  346. // uni.navigateTo({
  347. // url: "/pages/public/bind",
  348. // });
  349. // }
  350. // });
  351. // }
  352. // }
  353. // },
  354. // wxGetUserInfo(e) {
  355. // if (this.checked) {
  356. // wx.getUserProfile({
  357. // desc: "业务需要",
  358. // success: (infoRes) => {
  359. // console.log(
  360. // "infoRes.encryptedData__________:" + JSON.stringify(infoRes.userInfo)
  361. // );
  362. // let nickName = infoRes.userInfo.nickName; //昵称
  363. // let avatarUrl = infoRes.userInfo.avatarUrl; //头像
  364. // let sex = infoRes.userInfo.gender; //头像
  365. // try {
  366. // this.$queue.showLoading("正在登录中...");
  367. // this.login(nickName, avatarUrl, sex);
  368. // } catch (e) {}
  369. // },
  370. // });
  371. // } else {
  372. // uni.showToast({
  373. // title: "请阅读并同意《隐私协议》和《用户服务协议》",
  374. // icon: "none",
  375. // });
  376. // }
  377. // },
  378. // APP微信登录
  379. wxAppLogin() {
  380. if (!this.checked) {
  381. uni.showToast({
  382. title: "请阅读并同意《隐私协议》和《用户服务协议》",
  383. icon: "none",
  384. });
  385. return;
  386. }
  387. let that = this;
  388. uni.login({
  389. provider: "weixin",
  390. success: function(loginRes) {
  391. console.log(loginRes);
  392. uni.setStorageSync("openId", loginRes.authResult.openid)
  393. uni.setStorageSync("unionId", loginRes.authResult.unionid)
  394. let data = {
  395. wxOpenId: loginRes.authResult.openid,
  396. token: loginRes.authResult.access_token
  397. };
  398. that.$Request.postT("/app/Login/wxAppLogin", data)
  399. .then((res) => {
  400. console.log(res)
  401. if (res.code == 0) {
  402. that.$queue.setData("userId", res.user.userId);
  403. that.$queue.setData("token", res.token);
  404. that.$queue.setData("phone", res.user.phone);
  405. that.$queue.setData("userName", res.user.userName);
  406. that.$queue.setData("avatar", res.user.avatar);
  407. that.$queue.setData("invitationCode", res.user.invitationCode);
  408. that.$queue.setData("inviterCode", res.user.inviterCode);
  409. that.getIsVip();
  410. uni.hideLoading();
  411. that.$queue.setData("userType", res.user.userType);
  412. //判断是否开启身份选择 是/否
  413. that.$Request.get("/app/common/type/339").then((rest) => {
  414. if (rest.code == 0) {
  415. if (rest.data.value == "是") {
  416. // 这里是跳转到选择职场身份的界面
  417. uni.reLaunch({
  418. url: "/pages/public/selectIdentity/selectIdentity",
  419. });
  420. } else {
  421. if (res.user.userType == 2) { //企业
  422. // 原有的。判断第一次根据userType ==null
  423. uni.reLaunch({
  424. url: "/pages/my/index",
  425. });
  426. } else if (res.user.userType == 1) {
  427. uni.reLaunch({
  428. url: "/pages/my/index",
  429. });
  430. } else {
  431. //表示是第一次进来,走引导页
  432. uni.navigateTo({
  433. url: "/pages/my/jobApplicant/guidePage",
  434. });
  435. }
  436. }
  437. } else {
  438. if (res.user.userType == 2) { //企业
  439. // 原有的。判断第一次根据userType ==null
  440. uni.reLaunch({
  441. url: "/pages/my/index",
  442. });
  443. } else if (res.user.userType == 1) {
  444. uni.reLaunch({
  445. url: "/pages/my/index",
  446. });
  447. } else {
  448. //表示是第一次进来,走引导页
  449. uni.navigateTo({
  450. url: "/pages/my/jobApplicant/guidePage",
  451. });
  452. }
  453. }
  454. });
  455. } else {
  456. uni.navigateTo({
  457. url: `/pages/public/loginphone?type=1`,
  458. });
  459. }
  460. })
  461. },
  462. });
  463. },
  464. // appleLogin(){
  465. // if (!this.checked) {
  466. // uni.showToast({
  467. // title: "请阅读并同意《隐私协议》和《用户服务协议》",
  468. // icon: "none",
  469. // });
  470. // return;
  471. // }
  472. // uni.login({
  473. // provider: 'apple',
  474. // success: function (loginRes) {
  475. // // 登录成功
  476. // uni.getUserInfo({
  477. // provider: 'apple',
  478. // success: function(info) {
  479. // // 获取用户信息成功, info.authResult中保存登录认证数据
  480. // uni.navigateTo({
  481. // url: `/pages/public/loginphone?type=1`,
  482. // });
  483. // }
  484. // })
  485. // },
  486. // fail: function (err) {
  487. // // 登录授权失败
  488. // // err.code错误码参考`授权失败错误码(code)说明`
  489. // }
  490. // });
  491. // },
  492. //小程序登录
  493. login(nickName, avatarUrl, sex) {
  494. if (!this.checked) {
  495. uni.showToast({
  496. title: "请阅读并同意《隐私协议》和《用户服务协议》",
  497. icon: "none",
  498. });
  499. return;
  500. }
  501. let that = this;
  502. // 1.wx获取登录用户code
  503. uni.login({
  504. provider: "weixin",
  505. onlyAuthorize: true,
  506. success: function(loginRes) {
  507. console.log(loginRes, "************");
  508. let data = {
  509. code: loginRes.code,
  510. };
  511. that.$Request.get("/app/Login/wxLogin", data)
  512. .then((res) => {
  513. if (res.code == 0) {
  514. uni.hideLoading();
  515. uni.setStorageSync("openId", res.data.open_id);
  516. uni.setStorageSync("unionId", res.data.unionId);
  517. that.sessionkey = res.data.session_key;
  518. let sendData = {
  519. openId: uni.getStorageSync("openId"),
  520. unionId: uni.getStorageSync("unionId"),
  521. userName: "游客",
  522. avatar: "",
  523. sex: "1", //性别
  524. inviterCode: that.$queue.getData(
  525. "inviterCode"), //别人登录进来携带你的邀请码
  526. };
  527. that.sendDataList = sendData;
  528. that.flag = res.data.flag;
  529. // 第一次登录获取手机号
  530. // console.log(that.phoneNum,'**********************1')
  531. // console.log(that.flag,'**********************2')
  532. if (that.flag == "2" && that.phoneNum) {
  533. that.weixinPhone = true;
  534. } else {
  535. that.getWeixinInfo(sendData);
  536. }
  537. } else {
  538. uni.showToast({
  539. icon: "none",
  540. title: res.msg,
  541. duration: 2000,
  542. });
  543. console.log(res, "失败");
  544. }
  545. })
  546. },
  547. });
  548. },
  549. //小程序微信登录后获取手机号
  550. getPhoneNumber: function(e) {
  551. if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
  552. console.log("用户拒绝提供手机号");
  553. } else {
  554. console.log("用户同意提供手机号");
  555. console.log(e);
  556. this.setPhoneByInsert(e.detail.encryptedData, e.detail.iv);
  557. }
  558. },
  559. //小程序微信登录后获取手机号
  560. setPhoneByInsert(decryptData, iv) {
  561. let data = {
  562. decryptData: decryptData,
  563. key: this.sessionkey,
  564. iv: iv,
  565. };
  566. this.$Request.postJson("/app/Login/selectPhone", data).then((res) => {
  567. if (res.code == 0) {
  568. this.phone = res.data.phoneNumber;
  569. this.getWeixinInfo(this.sendDataList);
  570. } else {
  571. uni.showToast({
  572. title: res.msg,
  573. icon: "none",
  574. duration: 2000,
  575. });
  576. }
  577. });
  578. },
  579. getIsVip() {
  580. this.$Request.get("/app/UserVip/isUserVip").then((res) => {
  581. if (res.code == 0) {
  582. // this.isVip = res.data
  583. console.log(res.data);
  584. this.$queue.setData("isVip", res.data);
  585. }
  586. });
  587. },
  588. //获取个人信息
  589. getWeixinInfo(sendData) {
  590. let that = this;
  591. uni.showLoading({
  592. title: "登录中...",
  593. });
  594. let postData = {
  595. openId: sendData.openId, //小程序openId
  596. unionId: sendData.unionId, //unionId
  597. userName: sendData.userName, //微信名称
  598. avatar: sendData.avatar, //头像
  599. sex: sendData.sex, //性别
  600. phone: that.phone,
  601. inviterCode: sendData.inviterCode,
  602. };
  603. that.$Request.postJson("/app/Login/insertWxUser", postData).then((res) => {
  604. uni.hideLoading();
  605. if (res.code == 0) {
  606. uni.setStorageSync("token", res.token);
  607. uni.setStorageSync("userName", res.user.userName);
  608. uni.setStorageSync("avatar", res.user.avatar);
  609. uni.setStorageSync("phone", res.user.phone);
  610. uni.setStorageSync("invitationCode", res.user.invitationCode);
  611. this.$queue.setData("inviterCode", res.user.inviterCode);
  612. uni.setStorageSync("sex", res.user.sex);
  613. uni.setStorageSync("userId", res.user.userId);
  614. uni.setStorageSync("openId", res.user.openId);
  615. uni.setStorageSync("userType", res.user.userType);
  616. this.$Request.get("/app/UserVip/isUserVip").then((res) => {
  617. if (res.code == 0 && res.data && res.data.isVip == 2) {
  618. uni.setStorageSync("isVIP", true);
  619. } else {
  620. uni.setStorageSync("isVIP", false);
  621. }
  622. });
  623. //判断是否开启身份选择 是/否
  624. this.$Request.get("/app/common/type/339").then((rest) => {
  625. if (rest.code == 0) {
  626. if (rest.data.value == "是") {
  627. uni.reLaunch({
  628. url: "/pages/public/selectIdentity/selectIdentity",
  629. });
  630. } else {
  631. uni.navigateBack();
  632. }
  633. } else {
  634. uni.navigateBack();
  635. }
  636. });
  637. } else {
  638. uni.showModal({
  639. showCancel: false,
  640. title: "登录失败",
  641. content: res.msg,
  642. });
  643. }
  644. });
  645. },
  646. forget() {
  647. uni.navigateTo({
  648. url: "/pages/public/pwd",
  649. });
  650. },
  651. register(type) {
  652. if (!this.checked) {
  653. uni.showToast({
  654. title: "请阅读并同意《隐私协议》和《用户服务协议》",
  655. icon: "none",
  656. });
  657. } else {
  658. uni.navigateTo({
  659. url: `/pages/public/loginphone?type=${type}`,
  660. });
  661. }
  662. },
  663. inputChange(e) {
  664. const key = e.currentTarget.dataset.key;
  665. this[key] = e.detail.value;
  666. },
  667. navBack() {
  668. uni.navigateBack();
  669. },
  670. },
  671. };
  672. </script>
  673. <style lang="scss" scoped>
  674. .login-box {
  675. position: absolute;
  676. left: 0;
  677. right: 0;
  678. top: 0;
  679. bottom: 0;
  680. display: flex;
  681. flex-direction: column;
  682. padding: 0 32rpx;
  683. padding-bottom: 180rpx;
  684. box-sizing: border-box;
  685. }
  686. .logo-box {
  687. flex: 1;
  688. display: flex;
  689. justify-content: center;
  690. align-items: center;
  691. image {
  692. width: 160rpx;
  693. height: 160rpx;
  694. }
  695. }
  696. page {
  697. height: 100%;
  698. background: #ffffff !important;
  699. }
  700. /deep/.u-checkbox__label {
  701. margin-right: 0rpx !important;
  702. }
  703. /deep/.u-checkbox {
  704. padding: 0 !important;
  705. }
  706. .footer {
  707. font-family: DM Sans;
  708. font-size: 16rpx;
  709. font-weight: 400;
  710. letter-spacing: 0%;
  711. text-align: left;
  712. display: flex;
  713. align-items: center;
  714. justify-content: center;
  715. color: #605d67;
  716. margin-top: 16rpx;
  717. navigator {
  718. color: #016bf6;
  719. }
  720. .check-box {
  721. display: flex;
  722. justify-content: center;
  723. align-items: center;
  724. margin-right: 16rpx;
  725. image {
  726. width: 24rpx;
  727. height: 24rpx;
  728. }
  729. }
  730. }
  731. .container {
  732. top: 0;
  733. padding: 50rpx 32rpx;
  734. box-sizing: border-box;
  735. position: relative;
  736. overflow: hidden;
  737. color: #fff;
  738. }
  739. .confirm-btn-weixin {
  740. width: 200px;
  741. height: 42px;
  742. line-height: 42px;
  743. border-radius: 30px;
  744. margin-top: 40upx;
  745. background: -moz-linear-gradient(left, #f15b6c, #e10a07 100%);
  746. background: -webkit-gradient(linear,
  747. left top,
  748. left right,
  749. color-stop(0, #f15b6c),
  750. color-stop(100%, #e10a07));
  751. background: -webkit-linear-gradient(left, #f15b6c 0, #e10a07 100%);
  752. background: -o-linear-gradient(left, #f15b6c 0, #e10a07 100%);
  753. background: -ms-linear-gradient(left, #f15b6c 0, #e10a07 100%);
  754. background: linear-gradient(to left, #f15b6c 0, #e10a07 100%);
  755. color: #fff;
  756. font-size: 32upx;
  757. &:after {
  758. border-radius: 60px;
  759. }
  760. }
  761. .confirm-btn {
  762. width: 200px;
  763. height: 42px;
  764. line-height: 42px;
  765. border-radius: 30px;
  766. margin-top: 300upx;
  767. background: -moz-linear-gradient(left, #f15b6c, #e10a07 100%);
  768. background: -webkit-gradient(linear,
  769. left top,
  770. left right,
  771. color-stop(0, #f15b6c),
  772. color-stop(100%, #e10a07));
  773. background: -webkit-linear-gradient(left, #f15b6c 0, #e10a07 100%);
  774. background: -o-linear-gradient(left, #f15b6c 0, #e10a07 100%);
  775. background: -ms-linear-gradient(left, #f15b6c 0, #e10a07 100%);
  776. background: linear-gradient(to left, #f15b6c 0, #e10a07 100%);
  777. color: #fff;
  778. font-size: 32upx;
  779. &:after {
  780. border-radius: 60px;
  781. }
  782. }
  783. .headers {
  784. text-align: center;
  785. }
  786. .headers>image {
  787. width: 400upx;
  788. height: 400upx;
  789. }
  790. // .footer {
  791. // padding-left: 100upx;
  792. // margin-top: 32upx;
  793. // font-size: 24upx;
  794. // color: #666666;
  795. // text-align: center;
  796. // display: flex;
  797. // }
  798. .login-btn {
  799. padding: 0 32rpx;
  800. box-sizing: border-box;
  801. border-radius: 252rpx;
  802. color: rgba(255, 255, 255, 1) !important;
  803. font-family: DM Sans;
  804. font-size: 32rpx;
  805. font-weight: 400;
  806. line-height: 90rpx;
  807. display: flex;
  808. justify-content: center;
  809. align-items: center;
  810. margin-bottom: 16rpx;
  811. width: 100%;
  812. image {
  813. width: 28rpx;
  814. height: 28rpx;
  815. margin-right: 20rpx;
  816. }
  817. }
  818. .wechat {
  819. background: linear-gradient(90.00deg, rgba(13, 39, 247, 1), rgba(19, 193, 234, 1) 100%);
  820. }
  821. .apple{
  822. width:fit-content;
  823. border-radius: 12rpx;
  824. background:#000!important;
  825. margin-left:auto;
  826. margin-right:auto;
  827. }
  828. .password {
  829. background: rgba(1, 107, 246, 1);
  830. }
  831. .disabled {
  832. background: #99c4fa;
  833. }
  834. uni-button[disabled]:not([type]) {
  835. background-color: rgba(1, 107, 246, 1);
  836. }
  837. uni-button:after {
  838. border: none;
  839. }
  840. page {
  841. background: #fff;
  842. }
  843. .send-msg {
  844. border-radius: 30px;
  845. color: black;
  846. background: white;
  847. height: 30px;
  848. font-size: 14px;
  849. line-height: 30px;
  850. }
  851. .container {
  852. top: 0;
  853. padding-top: 32rpx;
  854. position: relative;
  855. width: 100%;
  856. height: 100vh;
  857. overflow: hidden;
  858. background: #ffffff;
  859. color: #fff;
  860. .mp_wxBox {
  861. .headers {
  862. margin: 35% auto 50rpx;
  863. text-align: center;
  864. border-radius: 60rpx;
  865. width: 650rpx;
  866. height: 300rpx;
  867. line-height: 450rpx;
  868. image {
  869. width: 300rpx;
  870. height: 300rpx;
  871. }
  872. }
  873. .content {
  874. text-align: center;
  875. }
  876. text {
  877. display: block;
  878. color: #9d9d9d;
  879. margin-top: 40rpx;
  880. }
  881. .bottom {
  882. line-height: 80upx;
  883. border-radius: 80upx;
  884. margin: 70rpx 50rpx;
  885. height: 80upx;
  886. font-size: 35rpx;
  887. }
  888. }
  889. }
  890. .wrapper {
  891. position: relative;
  892. z-index: 90;
  893. background: #fff;
  894. padding-bottom: 20px;
  895. }
  896. .input-content {
  897. padding: 0 20px;
  898. }
  899. .confirm-btn {
  900. width: 300px;
  901. height: 42px;
  902. line-height: 42px;
  903. border-radius: 30px;
  904. margin-top: 40px;
  905. background: #016bf6;
  906. color: #fff;
  907. // font-size: $font-lg;
  908. &:after {
  909. border-radius: 60px;
  910. }
  911. }
  912. </style>