login.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995
  1. <template>
  2. <view class="container">
  3. <image class="bg-image" src="../../../static/loginBg.png" mode="aspectFill"></image>
  4. <view class="up">
  5. <!-- 258px -->
  6. <view id="HeadArea" style="height: 25%;"></view>
  7. <view id="MidArea">
  8. <view class="action-row align-center " style="background-color: rgba(0, 0, 0, 0.2); padding: 29px 104rpx 29px 104rpx;">
  9. <!-- <view class="text-white text-22px text-center" style="width: 100%;" @tap="onSwitchLogin(true)">手机登录</view> -->
  10. <view class=" text-white " :class="bMobileLogin?'text-22px':'text-16px'" @tap="onSwitchLogin(true)">手机登录</view>
  11. <view class="text-bold text-white">|</view>
  12. <view class=" text-white " :class="!bMobileLogin?'text-22px':'text-16px'" @tap="onSwitchLogin(false)">账号登录</view>
  13. </view>
  14. <view v-if="bMobileLogin">
  15. <!-- 手机端登录,获取验证码 -->
  16. <view v-if="bGetCode">
  17. <view class="input-container" style="margin: 32px 102rpx 0 68rpx;">
  18. <view class="input-row padding" style="width: 318px;">
  19. <m-input type="number" maxlength="11" clearable v-model="account" placeholder="请填写11位手机号码"></m-input>
  20. </view>
  21. </view>
  22. <view class="btn-row" style="margin: 32px 0 0 0;">
  23. <view class="btn-confirm" @tap="onNavToReg">获取验证码</view>
  24. </view>
  25. <!-- <view v-if="appleOauth" class="btn-row" style="margin: 5px 0 0 0;">
  26. <view class="btn-apple-confirm" @tap="onAppleReg">
  27. <image style="width: 48rpx;height: 48rpx;margin-right: 5px;" src="../../../static/img/apple.png"></image>
  28. <view>通过Apple注册</view>
  29. </view>
  30. </view> -->
  31. </view>
  32. <view v-else>
  33. <!-- 手机端登录 -->
  34. <view class="text-22px make-text-bPurple" style="margin: 34px 0 0 96rpx;">输入验证码</view>
  35. <view class="text-16px text-gray" style="margin: 20px 0 0 96rpx;">已发送4位验证码至 +86 {{phoneNumber}}</view>
  36. <view class="code-input-main">
  37. <view class="inputLine">
  38. <!-- <view class="input-item" maxlength="1" :value="inputCode[0]">{{inputCode[0]}}</input> -->
  39. <view class="input-item">{{inputCode[0]}}</view>
  40. <view class="input-item">{{inputCode[1]}}</view>
  41. <view class="input-item">{{inputCode[2]}}</view>
  42. <view class="input-item">{{inputCode[3]}}</view>
  43. </view>
  44. <!-- @input="inputEvent" -->
  45. <input class="code-input-input" v-model="inputCode" maxlength="4" type="number" />
  46. </view>
  47. <view class="btn-row">
  48. <!-- :disabled="inputCode.length<4" -->
  49. <view class="btn-confirm " :class="inputCode.length<4?'disabledBtn':''" @tap="onConfirm">确认</view>
  50. </view>
  51. <view v-if="bCodeDisabled" class="action-row-text">
  52. <view class="action-child text-gray">重新获取({{count}})</view>
  53. <!-- <text style="color: #FFFFFF;">|</text>
  54. <navigator url="../pwd/pwd">忘记密码</navigator> -->
  55. </view>
  56. <view v-else class="action-row-text">
  57. <view class="action-child text-gray" @tap="onGetCode">重新发送验证码</view>
  58. <!-- <text style="color: #FFFFFF;">|</text>
  59. <navigator url="../pwd/pwd">忘记密码</navigator> -->
  60. </view>
  61. <input class='ipt' type="number" :maxlength="Length" :focus="bFocus" @input="onInputFocus" @focus="onFocus"></input>
  62. </view>
  63. </view>
  64. <view v-else>
  65. <!-- 密码登录 -->
  66. <!-- <view class="text-26px text-white" style="margin: 116px 0 0 58rpx;">密码登录</view>
  67. <view class="text-16px text-white" style="margin: 32px 0 0 58rpx;">记录你的运动轨迹,呵护你的身体健康</view> -->
  68. <view class="input-container" style="margin: 10px 102rpx 0 68rpx;">
  69. <view class="input-row padding" style="width: 318px;">
  70. <m-input type="number" clearable v-model="account" placeholder="输入手机号码"></m-input>
  71. </view>
  72. </view>
  73. <view class="input-container" style="margin: 8px 102rpx 0 68rpx;">
  74. <view class="input-row padding" style="width: 318px;">
  75. <m-input type="password" maxlength="14" displayable v-model="password" placeholder="请输入密码"></m-input>
  76. </view>
  77. </view>
  78. <!-- border: 1rpx solid #007AFF; -->
  79. <view class="btn-row" style="margin: 20px 0 0 0;">
  80. <view class="btn-confirm" @tap="bindLogin">登录</view>
  81. </view>
  82. <!-- <view class="action-row " style="margin: 29px 58rpx 0 58rpx;">
  83. <view class="text-14px text-gray">
  84. <text class="cuIcon-roundcheck "></text>
  85. 我已阅读并同意使用<span style="color: rgba(151, 151, 255, 1);">服务协议</span></view>
  86. <view class="text-14px" style="color: rgba(151, 151, 255, 1);">忘记密码?</view>
  87. </view> -->
  88. </view>
  89. </view>
  90. <!-- v-if="hasProvider" style="border: 1rpx solid #000000;"-->
  91. <view class="oauth-row" v-if="bGetCode" v-bind:style="{top: positionTop + 'px'}" >
  92. <view v-if="hasProvider&&providerList.length>0">
  93. <view v-if="(bInstallWechat&&!bHideWeixin)||appleOauth" class="text-14px text-gray">其他登录方式</view>
  94. <!-- <view v-else style="height: 50px;"></view> -->
  95. <view class="flex justify-center align-center margin-top-sm flex-direction">
  96. <!-- <view class="oauth-image" v-for="provider in providerList" :key="provider.value">
  97. <image :src="provider.image" @tap="oauth(provider.value)"></image>
  98. </view> -->
  99. <view v-if="bInstallWechat&&!bHideWeixin" v-for="provider in providerList" :key="provider.value">
  100. <view class="btn-apple-confirm" @tap="oauth(provider.value)">
  101. <image style="width: 48rpx;height: 48rpx;margin-right: 5px;" :src="provider.image"></image>
  102. <view>通过微信注册</view>
  103. </view>
  104. </view>
  105. <view v-if="appleOauth" class="btn-apple-confirm" @tap="onAppleReg">
  106. <image style="width: 48rpx;height: 48rpx;margin-right: 5px;" src="../../../static/img/apple.png"></image>
  107. <view>通过Apple注册</view>
  108. </view>
  109. </view>
  110. </view>
  111. <view class="action-row-text">
  112. <view class=" ">登录即代表同意哔蹦</view>
  113. <view class="text-bold text-decoration" @tap="onSwitchAgree('agreement')">用户协议</view>
  114. <view class=" ">和</view>
  115. <view class="text-bold text-decoration" @tap="onSwitchAgree('privacy')">隐私政策</view>
  116. </view>
  117. </view>
  118. </view>
  119. </view>
  120. </template>
  121. <script>
  122. import config from '../../../common/config.js';
  123. import service from '../../../util/util-js/service.js';
  124. import reqUtil from "@/util/util-js/requstUtil.js";
  125. import verify from '../../../util/util-js/verify.js'
  126. import {
  127. mapState,
  128. mapMutations
  129. } from 'vuex'
  130. import mInput from '../../../components/m-input.vue'
  131. export default {
  132. components: {
  133. mInput
  134. },
  135. data() {
  136. return {
  137. //获取验证码页面
  138. bGetCode: true,
  139. bMobileLogin: true,
  140. providerList: [],
  141. hasProvider: true,
  142. account: '',
  143. password: '',
  144. positionTop: 0,
  145. //输入框参数
  146. Length: 4, //输入框个数
  147. bFocus: false, //聚焦
  148. Value: "", //输入的内容
  149. inputCode: '',
  150. //苹果服务
  151. appleOauth: null,
  152. }
  153. },
  154. computed: mapState(['bNewUser', 'forcedLogin', 'phoneNumber', 'bCodeDisabled', 'count', 'bInstallWechat',
  155. 'bHideWeixin'
  156. ]),
  157. methods: {
  158. ...mapMutations(['login', 'addUserAvatarAndLogin', 'appleUserInfoLogin', 'accountLogin', 'countDown',
  159. 'resetCountDown'
  160. ]),
  161. initProvider() {
  162. // const filters = ['weixin', 'qq', 'sinaweibo'];
  163. const filters = ['weixin'];
  164. uni.getProvider({
  165. service: 'oauth',
  166. success: (res) => {
  167. if (res.provider && res.provider.length) {
  168. for (let i = 0; i < res.provider.length; i++) {
  169. if (~filters.indexOf(res.provider[i])) {
  170. this.providerList.push({
  171. value: res.provider[i],
  172. image: '../../../static/img/' + res.provider[i] + '.png'
  173. });
  174. }
  175. }
  176. this.hasProvider = true;
  177. }
  178. },
  179. fail: (err) => {
  180. console.error('获取服务供应商失败:' + JSON.stringify(err));
  181. }
  182. });
  183. },
  184. initPosition() {
  185. let _self = this;
  186. let headView = uni.createSelectorQuery().in(this).select('#HeadArea');
  187. headView.fields({
  188. size: true,
  189. }, data => {
  190. // console.log("得到节点信息1" + JSON.stringify(data));
  191. let headHeight = data.height;
  192. _self.positionTop = headHeight + 280;
  193. // let midView = uni.createSelectorQuery().in(this).select('#MidArea');
  194. // midView.fields({
  195. // size: true,
  196. // }, data => {
  197. // console.log("得到节点信息2" + JSON.stringify(data));
  198. // let midHeight = data.height;
  199. // /**
  200. // * 使用 absolute 定位,并且设置 bottom 值进行定位。软键盘弹出时,底部会因为窗口变化而被顶上来。
  201. // * 反向使用 top 进行定位,可以避免此问题。
  202. // * uni.getSystemInfoSync().windowHeight - 220
  203. // */
  204. // _self.positionTop = headHeight + midHeight;
  205. // }).exec();
  206. }).exec();
  207. if (plus.runtime.isApplicationExist({
  208. pname: 'com.tencent.mm',
  209. action: 'weixin://'
  210. })) {
  211. //安装了微信
  212. // console.log("安装了微信");
  213. _self.$store.state.bInstallWechat = true;
  214. } else {
  215. //未安装微信
  216. // console.log("未安装微信");
  217. _self.$store.state.bInstallWechat = false;
  218. }
  219. },
  220. bindLogin() {
  221. let _self = this;
  222. /**
  223. * 客户端对账号信息进行一些必要的校验。
  224. * 这里先简单处理
  225. */
  226. if (this.account.length < 11) {
  227. uni.showToast({
  228. icon: 'none',
  229. title: '账号最短为 11 个字符'
  230. });
  231. return;
  232. }
  233. if (this.password.length < 6) {
  234. uni.showToast({
  235. icon: 'none',
  236. title: '密码最短为 6 个字符'
  237. });
  238. return;
  239. }
  240. reqUtil.requestData(config.URL.PASSWORDlOGIN, {
  241. "phoneNumber": this.account,
  242. "password": this.password
  243. }).then(res => {
  244. console.log('requestData PASSWORDlOGIN =====', res);
  245. if (res.code == 0) {
  246. uni.showToast({
  247. title: "成功",
  248. mask: true,
  249. duration: 1000
  250. })
  251. //密码登录成功
  252. uni.setStorageSync('token', res.data.token);
  253. _self.$store.state.bNewUser = res.data.newUser;
  254. _self.accountLogin(function() {
  255. console.log("_self.bNewUser=", _self.bNewUser);
  256. if (_self.bNewUser) {
  257. uni.reLaunch({
  258. url: "../../my-page/userInfo/userInfo"
  259. })
  260. } else {
  261. uni.reLaunch({
  262. url: "../../personal-page/personal/personal"
  263. })
  264. }
  265. });
  266. } else {
  267. uni.showToast({
  268. title: "用户密码错误",
  269. icon: 'none',
  270. mask: true,
  271. duration: 1000
  272. })
  273. }
  274. },
  275. e => {
  276. console.log(e)
  277. });
  278. },
  279. oauth(value) {
  280. let _self = this;
  281. uni.showToast({
  282. title: "",
  283. icon: "loading",
  284. duration: 10000
  285. })
  286. uni.login({
  287. provider: value,
  288. success: (res) => {
  289. // console.log('code11:', res);
  290. // #ifdef APP-PLUS
  291. // android 端微信登录
  292. uni.request({
  293. url: config.URL.ANDROIDLOGINURL,
  294. data: {
  295. openid: res.authResult.openid,
  296. unionid: res.authResult.unionid,
  297. },
  298. success: (res) => {
  299. // console.log('ANDROIDLOGINURL请求返回:', res);
  300. let resData = res.data;
  301. uni.hideToast();
  302. if (resData.code == 0) {
  303. uni.showToast({
  304. title: "登录中..",
  305. icon: "loading",
  306. mask: true,
  307. duration: 10000
  308. })
  309. //登录成功
  310. uni.setStorage({
  311. key: 'token',
  312. data: resData.data.token,
  313. success: function() {
  314. _self.$store.state.bNewUser = resData.data.newUser;
  315. console.log("wx token = ", resData.data.token);
  316. //如果是新用户,则获取用户信息
  317. if (_self.bNewUser) {
  318. uni.getUserInfo({
  319. provider: value,
  320. success: (infoRes) => {
  321. //获取了用户信息后
  322. let userInfo = {
  323. username: infoRes.userInfo.nickName,
  324. gender: 0 //默认是男性
  325. }
  326. //服务器0是男,1是女
  327. //微信的2 对应的女
  328. if (infoRes.userInfo.gender == 2) {
  329. //服务器记录的是1
  330. userInfo.gender = 1;
  331. }
  332. console.log("微信数据:", infoRes, userInfo);
  333. uni.downloadFile({
  334. url: infoRes.userInfo.avatarUrl,
  335. success: (res) => {
  336. // if (res.statusCode === 200) {
  337. // console.log('下载成功');
  338. // }
  339. // console.log(res.tempFilePath);
  340. _self.addUserAvatarAndLogin({
  341. params: userInfo,
  342. filePath: res.tempFilePath,
  343. callback: () => {
  344. _self.$store.state.openid = infoRes.userInfo.openId || '';
  345. uni.hideToast();
  346. uni.reLaunch({
  347. url: "../../my-page/perfectInfo/perfectInfo"
  348. })
  349. }
  350. });
  351. }
  352. });
  353. },
  354. fail: (failRes) => {
  355. uni.hideToast();
  356. console.log('getUserInfo failRes:', failRes);
  357. }
  358. })
  359. } else {
  360. //如果不是新用户,直接获取用户信息
  361. _self.accountLogin(function() {
  362. uni.hideToast();
  363. uni.reLaunch({
  364. url: "../../personal-page/personal/personal"
  365. })
  366. });
  367. }
  368. }
  369. });
  370. } else {
  371. uni.showToast({
  372. title: "验证码错误",
  373. mask: true,
  374. icon: 'none',
  375. duration: 1000
  376. })
  377. }
  378. }
  379. })
  380. // #endif
  381. // #ifdef MP-WEIXIN
  382. uni.request({
  383. url: config.URL.USERlOGINURL,
  384. data: {
  385. appid: 'wxd6dfd60729d33d17',
  386. code: res.code,
  387. source: 1,
  388. },
  389. success: (res) => {
  390. // console.log('请求返回:', res, res.cookies[0]);
  391. // return;
  392. uni.getUserInfo({
  393. provider: value,
  394. success: (infoRes) => {
  395. /**
  396. * 实际开发中,获取用户信息后,需要将信息上报至服务端。
  397. * 服务端可以用 userInfo.openId 作为用户的唯一标识新增或绑定用户信息。
  398. */
  399. // this.toMain(infoRes.userInfo.nickName);
  400. console.log('getUserInfo infoRes:', infoRes)
  401. uni.request({
  402. url: config.URL.WXGETUSERINFO,
  403. data: {
  404. appid: 'wxd6dfd60729d33d17',
  405. encryptedData: infoRes.encryptedData,
  406. iv: infoRes.iv,
  407. signature: infoRes.signature,
  408. rawData: infoRes.rawData
  409. },
  410. success: (wxInfoRes) => {
  411. console.log('WXGETUSERINFO 请求返回:', wxInfoRes);
  412. }
  413. })
  414. },
  415. fail: (failRes) => {
  416. console.log('getUserInfo failRes:', failRes)
  417. }
  418. });
  419. }
  420. })
  421. // #endif
  422. },
  423. fail: (err) => {
  424. console.error('授权登录失败:' + JSON.stringify(err));
  425. }
  426. });
  427. },
  428. callbackUserInfo(userinfo) {
  429. console.log('callbackUserInfo:', userinfo);
  430. },
  431. onSwitchLogin(bMobileLogin) {
  432. // console.log(bMobileLogin);
  433. this.bMobileLogin = bMobileLogin;
  434. //如果是已获取的验证码页面,返回获取验证码界面
  435. if (this.bGetCode == false)
  436. this.bGetCode = true;
  437. // this.bMobileLogin = !this.bMobileLogin;
  438. },
  439. onNavToReg() {
  440. if (!verify.checkPhone(this.account)) {
  441. uni.showToast({
  442. icon: 'none',
  443. title: '输入手机号错误'
  444. });
  445. return;
  446. }
  447. // console.log("手机号正确:",this.account);
  448. // return;
  449. this.$store.state.phoneNumber = this.account;
  450. this.bGetCode = false;
  451. this.onGetCode();
  452. },
  453. //验证码操作
  454. //注册
  455. onConfirm() {
  456. var _self = this;
  457. if (_self.inputCode.length < 4) {
  458. uni.showToast({
  459. title: "请输入4位验证码",
  460. icon: "none",
  461. duration: 2000,
  462. mask: true
  463. })
  464. return;
  465. }
  466. uni.showToast({
  467. title: "",
  468. icon: "loading",
  469. duration: 10000,
  470. mask: true
  471. })
  472. reqUtil.requestData(config.URL.SMSLOGIN, {
  473. "phoneNumber": _self.phoneNumber,
  474. "code": _self.inputCode
  475. }).then(res => {
  476. console.log('requestData GETCODE =====', res);
  477. uni.hideToast();
  478. if (res.code == 0) {
  479. uni.showToast({
  480. title: "登录中..",
  481. icon: "loading",
  482. mask: true,
  483. duration: 3000
  484. })
  485. //登录成功
  486. uni.setStorage({
  487. key: 'token',
  488. data: res.data.token,
  489. success: function() {
  490. _self.$store.state.bNewUser = res.data.newUser;
  491. _self.resetCountDown();
  492. _self.accountLogin(function() {
  493. uni.hideToast();
  494. if (_self.bNewUser) {
  495. uni.reLaunch({
  496. url: "../../my-page/userInfo/userInfo"
  497. })
  498. } else {
  499. uni.reLaunch({
  500. url: "../../personal-page/personal/personal"
  501. })
  502. }
  503. });
  504. }
  505. });
  506. } else {
  507. uni.showToast({
  508. title: "验证码错误",
  509. mask: true,
  510. icon: 'none',
  511. duration: 1000
  512. })
  513. }
  514. },
  515. e => {
  516. console.log(e);
  517. uni.hideToast();
  518. });
  519. },
  520. onGetCode() {
  521. //置灰状态
  522. if (this.bCodeDisabled) return;
  523. //调用store 倒计时
  524. this.countDown(this.phoneNumber);
  525. },
  526. onTap() {
  527. this.bFocus = true;
  528. console.log(this.bFocus);
  529. },
  530. onFocus(e) {
  531. console.log(e);
  532. setTimeout(() => {
  533. // this.bFocus = false;
  534. }, 1000)
  535. },
  536. onInputFocus(e) {
  537. console.log(e.detail.value);
  538. this.Value = e.detail.value;
  539. },
  540. inputEvent(res) {
  541. console.log("input 1 input code components : " + res.detail.value);
  542. /* this.$emit('vueMsg',res.detail.value); */
  543. this.inputCode = res.detail.value;
  544. },
  545. onSwitchAgree(data) {
  546. console.log("=== ", data);
  547. uni.navigateTo({
  548. url: "../../login-page/userAgreement/userAgreement?type=" + data
  549. })
  550. },
  551. onAppleReg() {
  552. this.onAppleLogout(() => {
  553. this.onAppleRegEvent();
  554. })
  555. },
  556. onAppleRegEvent() {
  557. let _self = this;
  558. uni.login({
  559. provider: 'apple',
  560. success: (loginRes) => {
  561. // console.log('apple login:', loginRes);
  562. uni.getUserInfo({
  563. provider: 'apple',
  564. success(resUser) {
  565. //用户信息
  566. console.log("resUser:", resUser);
  567. uni.showToast({
  568. title: '',
  569. icon: 'loading',
  570. mask: true,
  571. duration: 10000,
  572. })
  573. reqUtil.requestData(config.URL.APPLElOGINURL, {
  574. "identityToken": resUser.userInfo.identityToken
  575. }).then(res => {
  576. console.log('requestData apple login =====', res);
  577. uni.hideToast();
  578. if (res.code == 0) {
  579. //登录成功
  580. uni.setStorage({
  581. key: 'token',
  582. data: res.data.token,
  583. success: function() {
  584. _self.$store.state.bNewUser = res.data.newUser;
  585. // console.log("apple token = ", res.data.token);
  586. //如果是新用户,则获取用户信息
  587. if (_self.bNewUser) {
  588. //获取了用户信息后
  589. let tempName = "匿名";
  590. if (resUser.userInfo.fullName.hasOwnProperty("familyName") &&
  591. resUser.userInfo.fullName.hasOwnProperty("givenName")) {
  592. tempName = resUser.userInfo.fullName.familyName + resUser.userInfo.fullName.givenName;
  593. }
  594. let userInfo = {
  595. username: tempName,
  596. gender: 0 //默认是男性
  597. }
  598. // console.log("苹果数据11:", resUser.userInfo);
  599. // console.log("userInfo:", userInfo);
  600. _self.appleUserInfoLogin({
  601. params: userInfo,
  602. callback: () => {
  603. //这里是记录appleid,不是微信
  604. _self.$store.state.appleid = resUser.userInfo.openId || '';
  605. uni.hideToast();
  606. uni.reLaunch({
  607. url: "../../my-page/perfectInfo/perfectInfo"
  608. })
  609. }
  610. });
  611. } else {
  612. //如果不是新用户,直接获取用户信息
  613. _self.accountLogin(function() {
  614. uni.hideToast();
  615. uni.reLaunch({
  616. url: "../../personal-page/personal/personal"
  617. })
  618. });
  619. }
  620. }
  621. });
  622. } else {
  623. uni.showToast({
  624. title: "apple登陆失败",
  625. mask: true,
  626. icon: 'none',
  627. duration: 1000
  628. })
  629. }
  630. },
  631. e => {
  632. console.log(e);
  633. uni.hideToast();
  634. });
  635. }
  636. })
  637. },
  638. fail: (err) => {
  639. //登陆失败
  640. console.log('登陆失败:', err)
  641. uni.showToast({
  642. title: '登陆失败',
  643. icon: 'none'
  644. })
  645. }
  646. })
  647. },
  648. onAppleLogout(callback) {
  649. this.appleOauth.logout(function(e) {
  650. // plus.nativeUI.alert("注销登录认证成功!");
  651. callback(e);
  652. console.log("注销登录认证成功!");
  653. }, function(e) {
  654. // plus.nativeUI.alert("注销登录认证失败: " + JSON.stringify(e));
  655. console.log("注销登录认证失败: " + JSON.stringify(e));
  656. });
  657. },
  658. onGetAppleService() {
  659. // console.log("onGetAppleService");
  660. let _self = this;
  661. plus.oauth.getServices(function(services) {
  662. for (var i in services) {
  663. var service = services[i];
  664. // 获取苹果授权登录对象,苹果授权登录id 为 'apple' iOS13以下系统,不会返回苹果登录对应的 service
  665. if (service.id == 'apple') {
  666. _self.appleOauth = service;
  667. // console.log("this.appleOla:", _self.appleOauth);
  668. break;
  669. }
  670. // console.log("service:", service);
  671. }
  672. }, function(err) {
  673. // 获取 services 失败
  674. })
  675. }
  676. },
  677. onReady() {
  678. this.initPosition();
  679. this.initProvider();
  680. //获取apple相关服务
  681. this.onGetAppleService();
  682. }
  683. }
  684. </script>
  685. <style>
  686. .action-row {
  687. display: flex;
  688. flex-direction: row;
  689. justify-content: space-between;
  690. height: 67px;
  691. }
  692. .action-row navigator {
  693. color: #FFFFFF;
  694. font-size: 16px;
  695. /* padding: 0 20upx; */
  696. }
  697. .action-row-text {
  698. margin-top: 25px;
  699. display: flex;
  700. flex-direction: row;
  701. justify-content: center;
  702. }
  703. .action-child {
  704. /* color: #FFFFFF; */
  705. padding: 0 20upx;
  706. }
  707. .oauth-row {
  708. display: flex;
  709. flex-direction: column;
  710. justify-content: center;
  711. align-content: center;
  712. text-align: center;
  713. position: absolute;
  714. top: 0;
  715. left: 0;
  716. width: 100%;
  717. right: 0;
  718. /* border: 1rpx solid #000000; */
  719. }
  720. .oauth-image {
  721. width: 76rpx;
  722. height: 76rpx;
  723. /* border: 1upx solid #dddddd; */
  724. /* border-radius: 100upx; */
  725. margin: 0 40upx;
  726. /* background-color: #ffffff; */
  727. }
  728. .oauth-image image {
  729. width: 76rpx;
  730. height: 76rpx;
  731. /* margin: 20upx; */
  732. }
  733. .input-group {
  734. background-color: #ffffff;
  735. margin-top: 40upx;
  736. position: relative;
  737. }
  738. .input-group::before {
  739. position: absolute;
  740. right: 0;
  741. top: 0;
  742. left: 0;
  743. height: 1upx;
  744. content: '';
  745. -webkit-transform: scaleY(.5);
  746. transform: scaleY(.5);
  747. background-color: #c8c7cc;
  748. }
  749. .input-group::after {
  750. position: absolute;
  751. right: 0;
  752. bottom: 0;
  753. left: 0;
  754. height: 1upx;
  755. content: '';
  756. -webkit-transform: scaleY(.5);
  757. transform: scaleY(.5);
  758. background-color: #c8c7cc;
  759. }
  760. .input-row {
  761. display: flex;
  762. flex-direction: row;
  763. position: relative;
  764. }
  765. .main-title {
  766. width: 20%;
  767. height: 50upx;
  768. min-height: 50upx;
  769. padding: 15upx 0;
  770. padding-left: 30upx;
  771. line-height: 50upx;
  772. }
  773. .main-info {
  774. width: 20%;
  775. height: 50upx;
  776. min-height: 50upx;
  777. padding: 15upx 0;
  778. padding-left: 30upx;
  779. line-height: 50upx;
  780. }
  781. .btn-row {
  782. /* margin-top: 50upx; */
  783. /* padding: 20upx; */
  784. display: flex;
  785. justify-content: center;
  786. align-items: center;
  787. }
  788. .container {
  789. position: absolute;
  790. top: 0;
  791. bottom: 0;
  792. left: 0;
  793. right: 0;
  794. background-color: #FFFFFF;
  795. }
  796. .bg-image {
  797. position: absolute;
  798. top: 0;
  799. left: 0;
  800. width: 100%;
  801. height: calc(25% + 67px);
  802. opacity: 1;
  803. }
  804. .up {
  805. position: absolute;
  806. z-index: 1;
  807. width: 100%;
  808. height: 100%;
  809. }
  810. .input-container {
  811. border-bottom: 1rpx solid #e7e9eb;
  812. }
  813. .btn-confirm {
  814. width: 636rpx;
  815. height: 102rpx;
  816. background-color: rgba(151, 151, 255, 1);
  817. border-radius: 10px;
  818. display: flex;
  819. justify-content: center;
  820. align-items: center;
  821. font-size: 17px;
  822. color: #FFFFFF;
  823. }
  824. .btn-apple-confirm {
  825. width: 636rpx;
  826. height: 102rpx;
  827. /* background-color: rgba(151, 151, 255, 1); */
  828. border: 1px solid #000000;
  829. border-radius: 10px;
  830. display: flex;
  831. justify-content: center;
  832. align-items: center;
  833. font-size: 17px;
  834. color: #000000;
  835. margin-top: 7px;
  836. }
  837. .disabledBtn {
  838. background-color: rgba(221, 221, 221, 1.0);
  839. }
  840. .code-input-main {
  841. display: flex;
  842. flex-direction: column;
  843. width: 100%;
  844. /* border: 1rpx solid #000000; */
  845. height: 150px;
  846. position: relative;
  847. }
  848. .input-item {
  849. width: 106rpx;
  850. height: 118rpx;
  851. font-size: 20px;
  852. line-height: 118rpx;
  853. background-color: rgba(244, 241, 244, 255);
  854. /* border: 1rpx solid #ddd; */
  855. text-align: center;
  856. border-radius: 8px;
  857. margin-left: 44rpx;
  858. /* margin-right: 40upx; */
  859. color: rgba(86, 86, 86, 1);
  860. font-weight: bold;
  861. }
  862. .inputLine {
  863. display: flex;
  864. justify-content: flex-start;
  865. width: 100%;
  866. top: 80rpx;
  867. left: 52rpx;
  868. position: absolute;
  869. z-index: 1;
  870. }
  871. .code-input-input {
  872. height: 150px;
  873. position: absolute;
  874. width: 100%;
  875. outline: none;
  876. color: transparent;
  877. text-shadow: 0 0 0 transparent;
  878. width: 300%;
  879. left: -100%;
  880. top: 0;
  881. /* background: #000000; */
  882. /* border: 1rpx solid #007AFF; */
  883. z-index: 10;
  884. }
  885. .ipt {
  886. width: 0;
  887. height: 0;
  888. }
  889. .text-decoration {
  890. margin: 0 1rpx;
  891. border-bottom: 1rpx solid rgba(0, 0, 0, 0.3);
  892. padding-bottom: 1rpx;
  893. }
  894. </style>