login.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987
  1. <template>
  2. <div class="page" ref="showAuth">
  3. <div class="authorize__head">
  4. <div class="head__info">
  5. <div class="head__logo">
  6. <img :src="getLogo" mode="heightFix" />
  7. </div>
  8. </div>
  9. </div>
  10. <div class="authorize__form">
  11. <div class="form__item line" style="border-bottom: 1px solid #d8dae0">
  12. <div class="form__label">手机号码</div>
  13. <div class="form__input">
  14. <!-- <input type="number" placeholder="请输入您的手机号" v-model="mobile" /> -->
  15. <van-field
  16. v-model="mobile"
  17. type="number"
  18. placeholder="请输入您的手机号"
  19. />
  20. </div>
  21. </div>
  22. <div class="form__item">
  23. <div class="form__label">验证码</div>
  24. <div class="form__input">
  25. <!-- <input type="number" placeholder="请输入验证码" v-model="codeNum"> -->
  26. <van-field
  27. v-model="codeNum"
  28. type="number"
  29. placeholder="请输入验证码"
  30. />
  31. </div>
  32. <div class="form__code">
  33. <wyb-button
  34. type="hollow"
  35. :count-down="true"
  36. :count-down-num="59"
  37. width="240px"
  38. height="70px"
  39. color="#1D1D1D"
  40. font-size="28"
  41. border-size="1"
  42. :radius="['50px']"
  43. @click="onCode"
  44. :mobile="mobile"
  45. @pre-click="handlePreClick"
  46. >
  47. 获取验证码
  48. </wyb-button>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="mgt40">
  53. <button class="authorize_btn authorize_btn--phone" @click="onLogin">
  54. 注册/登录
  55. </button>
  56. </div>
  57. <div class="mgt20">
  58. <button class="authorize_btn authorize_btn--phone" @click="passLogin">
  59. 未登录使用
  60. </button>
  61. </div>
  62. <div class="mgt34">
  63. <div style="margin: 0 30px">
  64. <div class="protocolName">
  65. <van-checkbox
  66. @click="protocolChange"
  67. :value="protocolChecked"
  68. color="#ED1C24"
  69. name="protocol"
  70. icon-size="17"
  71. checked-color="#064C8A"
  72. shape="square"
  73. ></van-checkbox>
  74. <div
  75. style="color: #666666; font-size: 32px; flex: 1; margin-left: 15px"
  76. v-if="brandInfo && brandInfo.protocolName"
  77. >
  78. 已阅读并同意<span
  79. style="color: #627ecf"
  80. @click="gotoProtocol('protocol')"
  81. >《{{ brandInfo.protocolName }}》</span
  82. >
  83. 和<span
  84. style="color: #627ecf"
  85. @click="gotoProtocol('privacyPolicy')"
  86. >《{{ brandInfo.privacyPolicyName }}》</span
  87. >
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. <div v-if="showAuth">
  93. <van-popup
  94. v-model="showAuth"
  95. :close-on-click-overlay="false"
  96. position="center"
  97. :get-container="getContainer"
  98. >
  99. <div class="auth-popup">
  100. <div class="auth-popup__head">
  101. <span>微信授权</span>
  102. </div>
  103. <div class="auth-popup__main">
  104. <div class="head__logo">
  105. <img :src="getLogo" mode="heightFix" />
  106. </div>
  107. <div style="margin-bottom: 20px; font-size: 30px">
  108. 申请获取以下权限
  109. </div>
  110. <div
  111. style="
  112. height: 80px;
  113. line-height: 80px;
  114. border-top: 1px solid #f0f0f0;
  115. color: #999999;
  116. font-size: 32px;
  117. "
  118. >
  119. 获得你的公开信息(个人信息等)
  120. </div>
  121. </div>
  122. <div class="auth-popup__footer">
  123. <div class="cancel" @click="noWechatAuthPhoneLogin">取消</div>
  124. <div style="flex: 1; border-left: 1px solid #f0f0f0">
  125. <button class="phone-btn" @click="getWxProfile">确认授权</button>
  126. </div>
  127. </div>
  128. </div>
  129. </van-popup>
  130. </div>
  131. </div>
  132. </template>
  133. <script>
  134. import log from '@/utils/log';
  135. // import wybButton from '@/components/wyb-button/wyb-button.vue'
  136. import {
  137. kipSendRegisterSMS,
  138. kipPhoneLogin,
  139. loginWeixinH5,
  140. kipUpdateWxMember,
  141. kipGetUserDetail,
  142. kipGetBrandInfo,
  143. kipAgreementSave,
  144. } from '@/utils/api-kip.js';
  145. import MemberCacheTool from '@/utils/member-cache-tool.js';
  146. import KipCacheTool from '@/utils/kip-cache-tool.js';
  147. import {
  148. crmQueryMemberInfo,
  149. crmSaveMemberSource,
  150. } from '@/utils/api-crm-member.js';
  151. // var app = getApp()
  152. import { mapState } from 'vuex';
  153. import { getUTMSource } from '@/utils/utils.js';
  154. import CacheTool from '@/utils/cache-tool.js';
  155. // const { KERRY_ON_BRAND_ID, HANGZHOU_LBS_ID } = CacheTool.getCurEnvConst();
  156. import { REG_SOURCE } from '@/constants.js';
  157. import uni from '@/utils/uniHooks.js';
  158. const app = {};
  159. export default {
  160. name: 'Login',
  161. data() {
  162. return {
  163. mobile: '', // 手机号
  164. codeNum: '', // 验证码
  165. timer: 60, // 时间
  166. url: '',
  167. protocolChecked: false,
  168. brandInfo: null,
  169. lbsInfo: null,
  170. preUrl: '',
  171. showAuth: false, // 展示授权弹窗
  172. };
  173. },
  174. created() {
  175. const option = this.$route.query;
  176. if (option && JSON.stringify(option) !== '{}') {
  177. this.url = JSON.parse(decodeURIComponent(option?.url || '{}'));
  178. }
  179. this.preUrl = uni.getStorageSync('previousUrl');
  180. uni.setStorageSync('previousUrl', '/pages/wxLogin/login.vue');
  181. },
  182. computed: {
  183. ...mapState({
  184. custTypeId: (state) => state.custTypeId,
  185. mallid: (state) => state.mallId,
  186. groupId: (state) => state.groupId,
  187. member: (state) => state.member,
  188. }),
  189. getLogo() {
  190. // TODO: logo 需要更具lbs区分进入
  191. // return CacheTool.getLogoByMallid(this.mallid)
  192. return this.brandInfo?.logo || CacheTool.getLogoByMallid(this.mallid);
  193. // return 'https://kip-public-qa.oss-cn-shanghai.aliyuncs.com/1634707859342-qldc5c.jpg';
  194. },
  195. // isHangzhou() {
  196. // return uni.getStorageSync('mallid') == HANGZHOU_LBS_ID;
  197. // },
  198. // isKerryOn() {
  199. // return uni.getStorageSync('groupId') == KERRY_ON_BRAND_ID;
  200. // },
  201. },
  202. watch: {
  203. groupId(val) {
  204. console.log('groupId', val);
  205. },
  206. mallid(val) {
  207. console.log('mallid', val);
  208. },
  209. },
  210. mounted() {
  211. // console.log(154,this.groupId,this.mallid);
  212. this.getBrandInfo();
  213. },
  214. methods: {
  215. getContainer() {
  216. return this.$refs.showAuth;
  217. },
  218. // 获取验证码
  219. onCode: function () {
  220. if (this.check()) {
  221. this.getCodeData();
  222. }
  223. return false;
  224. },
  225. passLogin() {
  226. this.$store.commit('SET_IS_LOGIN', 'loginDenied');
  227. this.$router.replace({ path: 'home' });
  228. },
  229. // 获取验证码
  230. getCodeData: function () {
  231. uni.showLoading({
  232. title: '加载中',
  233. });
  234. var datas = {
  235. phoneNumber: this.mobile,
  236. };
  237. kipSendRegisterSMS(datas)
  238. .then((resp) => {
  239. uni.hideLoading();
  240. console.log(resp);
  241. // return
  242. // const result = resp.data;
  243. if (resp.code == '000000' && resp.data) {
  244. uni.showToast({
  245. title: '获取验证码成功!',
  246. duration: 2000,
  247. icon: 'none',
  248. });
  249. } else {
  250. const message = resp.message || '发送失败';
  251. uni.showToast({
  252. title: message,
  253. duration: 2000,
  254. icon: 'none',
  255. });
  256. log.error(`短信发送失败, 手机号: ${datas.phoneNumber}`);
  257. }
  258. })
  259. .catch((err) => {
  260. uni.hideLoading();
  261. uni.showToast({
  262. title: '发送注册信息错误',
  263. duration: 2000,
  264. icon: 'none',
  265. });
  266. log.error(err);
  267. });
  268. },
  269. //授权
  270. getWxProfile: function () {
  271. let _this = this;
  272. this.closeAuthPopup();
  273. uni.getUserProfile({
  274. desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  275. success: (res) => {
  276. _this.updateKipMemberByWxProfile(res);
  277. },
  278. fail: (res) => {
  279. console.warn(`用户取消授权, ${JSON.stringify(res)}`);
  280. log.warn(`用户取消授权`);
  281. // 此时用户已注册,即使用户取消授权,也需要用随机头像昵称登录
  282. const isClosePopup = false;
  283. _this.noWechatAuthPhoneLogin(isClosePopup);
  284. },
  285. });
  286. },
  287. queryMember: function (callback) {
  288. let _this = this;
  289. uni.showLoading({
  290. title: '正在加载',
  291. mask: true,
  292. });
  293. kipGetUserDetail()
  294. .then((result) => {
  295. uni.hideLoading();
  296. // const result = resp.data;
  297. console.log(323, result);
  298. if (result.code === '000000' && result.data) {
  299. const member = result.data;
  300. console.log(326, member);
  301. if (member) {
  302. _this.getKipMemberInfoAfter(member, callback);
  303. } else {
  304. MemberCacheTool.cleanMemberCache(app);
  305. uni.showToast({
  306. title: result.message,
  307. duration: 2000,
  308. icon: 'none',
  309. });
  310. log.warn(`查询会员信息成功:没有会员信息`);
  311. }
  312. } else {
  313. MemberCacheTool.cleanMemberCache(app);
  314. uni.showToast({
  315. title: result.message,
  316. duration: 2000,
  317. icon: 'none',
  318. });
  319. log.warn(`查询会员信息失败,${result.message}`);
  320. }
  321. })
  322. .catch((err) => {
  323. console.log(349, err);
  324. uni.hideLoading();
  325. console.error(err);
  326. MemberCacheTool.cleanMemberCache(app);
  327. uni.showToast({
  328. title: '查询会员信息错误',
  329. duration: 2000,
  330. icon: 'none',
  331. });
  332. log.warn(`查询会员信息错误`);
  333. });
  334. },
  335. // 登录
  336. onLogin: function () {
  337. let _this = this;
  338. // 判断会员协议
  339. if (!_this.protocolChecked) {
  340. uni.showModal({
  341. title: '请阅读并勾选下方的协议',
  342. showCancel: false,
  343. });
  344. return false;
  345. }
  346. if (_this.check()) {
  347. if (_this.codeNum === '') {
  348. uni.showToast({
  349. title: '请输入验证码',
  350. duration: 2000,
  351. icon: 'none',
  352. });
  353. return false;
  354. }
  355. // 调登录接口
  356. uni.showLoading({
  357. title: '正在登录',
  358. mask: true,
  359. });
  360. // console.log('===> 手机号登录 ', loginRes);
  361. const params = {
  362. verifyCode: _this.codeNum,
  363. phoneNumber: _this.mobile,
  364. };
  365. kipPhoneLogin(params)
  366. .then((result) => {
  367. uni.hideLoading();
  368. // const result = resp.data;
  369. console.log(399, result);
  370. if (result.code == '000000' && result.data) {
  371. log.info(`手机号登录成功:保存授权信息`);
  372. this.$store.commit('SET_MOBILE', _this.mobile);
  373. const authInfo = result.data;
  374. const needLogin = authInfo.needLogin;
  375. // 此接口返回的needLogin暂时没有true
  376. KipCacheTool.setKipCache(authInfo);
  377. // if (!needLogin) {
  378. // KipCacheTool.setKipCache(authInfo);
  379. // // 请求用户信息
  380. // _this.queryMember()
  381. // }
  382. // if (_this.isHangzhou) {
  383. // uni.setStorageSync('comfirLocation', 'login.vue');
  384. // uni.setStorageSync('comfirHangzhou', true);
  385. // } else if (_this.isKerryOn) {
  386. // uni.setStorageSync('comfirLocation', 'login.vue');
  387. // uni.setStorageSync('comfirKerryOn', true);
  388. // }
  389. _this.saveAgreementAction();
  390. _this.queryMember(() => {
  391. // 返回首页
  392. setTimeout(() => {
  393. window.location.href = `${
  394. window.location.origin
  395. }/tparking/${uni.getStorageSync(
  396. 'groupId'
  397. )}/${uni.getStorageSync('mallId')}/`;
  398. }, 200)
  399. });
  400. // _this.$router.push({ path: 'home' });
  401. // setTimeout(() => {
  402. // window.location.reload();
  403. // }, 700);
  404. } else {
  405. log.warn(`手机号登录请求成功: 未获取到授权信息`);
  406. uni.showModal({
  407. title: '登录失败',
  408. content: result.message,
  409. showCancel: false,
  410. });
  411. KipCacheTool.cleanKipCache();
  412. MemberCacheTool.cleanMemberCache(app);
  413. }
  414. })
  415. .catch((err) => {
  416. uni.hideLoading();
  417. console.log(err);
  418. uni.showToast({
  419. title: '登录失败',
  420. duration: 2000,
  421. icon: 'none',
  422. });
  423. log.warn(`手机号登录请求失败`);
  424. KipCacheTool.cleanKipCache();
  425. MemberCacheTool.cleanMemberCache(app);
  426. });
  427. // uni.login({
  428. // provider: 'weixin',
  429. // success: function (loginRes) {
  430. // },
  431. // fail: function (loginRes) {
  432. // uni.showModal({
  433. // title: '登录失败',
  434. // content: loginRes.errMsg,
  435. // showCancel: false,
  436. // });
  437. // log.warn(`授权手机号失败`);
  438. // KipCacheTool.cleanKipCache();
  439. // MemberCacheTool.cleanMemberCache(app);
  440. // },
  441. // });
  442. }
  443. },
  444. check: function () {
  445. if (this.mobile === '') {
  446. uni.showToast({
  447. title: '请输入手机号',
  448. duration: 2000,
  449. icon: 'none',
  450. });
  451. return false;
  452. }
  453. const regPhone = '/^1[3456789]d{9}$/';
  454. let reg = /^1[3456789]\d{9}$/;
  455. if (!reg.test(this.mobile)) {
  456. uni.showToast({
  457. title: '请输入正确的手机号',
  458. duration: 2000,
  459. icon: 'none',
  460. });
  461. return false;
  462. }
  463. return true;
  464. },
  465. handlePreClick(e) {
  466. console.log(428, e);
  467. uni.showToast({
  468. title: '请输入正确的手机号',
  469. duration: 2000,
  470. icon: 'none',
  471. });
  472. },
  473. gotoProtocol(type) {
  474. const brandId = this.brandInfo.id || '';
  475. const lbsId = this.lbsInfo[0].id || '';
  476. const isChecked = this.protocolChecked;
  477. uni.navigateTo({
  478. url: `/pages/protocol/protocol?type=${type}&brandId=${brandId}&lbsId=${lbsId}&isChecked=${isChecked}`,
  479. });
  480. },
  481. protocolChange(e) {
  482. console.log(447, e);
  483. this.protocolChecked = !this.protocolChecked;
  484. // const mallid = this.mallid;
  485. // CacheTool.setAgreeProtocoByMallid(mallid, this.protocolChecked);
  486. },
  487. getBrandInfo() {
  488. const _this = this;
  489. // const HZ_BRAND_ID = this.groupId;
  490. const HZ_BRAND_ID = this.$route.query.groupId;
  491. const HZ_LBS_ID = this.$route.query.mallid;
  492. // return
  493. const params = {
  494. id: HZ_BRAND_ID,
  495. lbsId: HZ_LBS_ID,
  496. };
  497. console.log(509, params);
  498. uni.showLoading({
  499. title: '正在加载',
  500. mask: true,
  501. });
  502. kipGetBrandInfo(params)
  503. .then((resp) => {
  504. uni.hideLoading();
  505. // console.log(468, resp);
  506. // return
  507. if (!resp || !resp.data.length || resp.code != '000000') {
  508. log.warn(`获取会员绑定的brand请求成功:未获取到数据`);
  509. console.log(`获取会员绑定的brand请求成功:未获取到数据`);
  510. const message = resp?.data?.message || '服务不可用';
  511. uni.showToast({
  512. title: message,
  513. duration: 2000,
  514. icon: 'none',
  515. });
  516. } else {
  517. const brandArray = resp.data;
  518. console.log(484, brandArray);
  519. if (brandArray && brandArray.length > 0 && brandArray[0]) {
  520. const brandInfo = brandArray[0].brand;
  521. _this.brandInfo = brandInfo;
  522. console.log(488, brandInfo);
  523. const lbsInfo = brandArray[0].lbs;
  524. _this.lbsInfo = lbsInfo;
  525. }
  526. console.log(487, _this.lbsInfo);
  527. }
  528. })
  529. .catch((err) => {
  530. uni.hideLoading();
  531. console.error(err);
  532. });
  533. },
  534. getKipMemberInfoAfter(kipMemberInfo, callback) {
  535. console.log(550, kipMemberInfo);
  536. MemberCacheTool.setKipMember(app, kipMemberInfo);
  537. const _this = this;
  538. // 查询 crm 会员
  539. uni.showLoading({
  540. title: '正在加载',
  541. mask: true,
  542. });
  543. const newGroupId = uni.getStorageSync('groupId');
  544. const newMallid = uni.getStorageSync('mallId');
  545. const params = {
  546. groupId: newGroupId,
  547. kipUserId: kipMemberInfo.id,
  548. mallId: newMallid,
  549. };
  550. crmQueryMemberInfo(params)
  551. .then((result) => {
  552. uni.hideLoading();
  553. log.info(`获取crm会员请求失败`);
  554. // const result = resp.data;
  555. if (result && result.code == '0') {
  556. const member = result.data;
  557. const optionsQuery = uni.getStorageSync('options_query') || {};
  558. if (member) {
  559. // 这里埋点-登录过但是清空缓存
  560. console.log(
  561. '==>这里走埋点--手机号码---crmQueryMemberInfo',
  562. member
  563. );
  564. this.$store.commit('SET_USER_INFO', member);
  565. this.$store.commit('SET_MEMBER', member);
  566. callback && callback();
  567. } else {
  568. uni.hideLoading();
  569. log.error(`获取crm会员请求失败`);
  570. console.error(err);
  571. uni.showToast({
  572. title: '登录注册失败',
  573. duration: 2000,
  574. icon: 'none',
  575. });
  576. KipCacheTool.cleanKipCache();
  577. MemberCacheTool.cleanMemberCache(app);
  578. }
  579. } else {
  580. uni.hideLoading();
  581. log.error(`获取crm会员请求失败`);
  582. console.error(err);
  583. uni.showToast({
  584. title: '登录注册失败',
  585. duration: 2000,
  586. icon: 'none',
  587. });
  588. KipCacheTool.cleanKipCache();
  589. MemberCacheTool.cleanMemberCache(app);
  590. }
  591. })
  592. .catch((err) => {
  593. uni.hideLoading();
  594. log.error(`获取crm会员请求错误`);
  595. console.error(err);
  596. uni.showToast({
  597. title: '登录注册错误',
  598. duration: 2000,
  599. icon: 'none',
  600. });
  601. KipCacheTool.cleanKipCache();
  602. MemberCacheTool.cleanMemberCache(app);
  603. });
  604. },
  605. openAuthPopup() {
  606. // this.$refs.popup.value = true
  607. this.showAuth = true;
  608. },
  609. closeAuthPopup() {
  610. this.showAuth = false;
  611. // this.$refs.popup.value = false
  612. // this.$refs.popup.inited = false
  613. },
  614. checkIsNewUser() {
  615. // 除静安和浦东外,完善信息只显示一次
  616. if (this.custTypeId == '0') {
  617. const isNewUser = KipCacheTool.getKipIsNewUser();
  618. if (isNewUser) {
  619. uni.navigateTo({
  620. url: '/pages/personInfo/personInfo',
  621. });
  622. } else {
  623. uni.redirectTo({
  624. url: '/pages/automatic/automaticMy',
  625. });
  626. }
  627. } else {
  628. const member = this.member;
  629. if (member && (!member.isCompleted || member.isCompleted == '0')) {
  630. uni.navigateTo({
  631. url: '/pages/personInfo/personInfo',
  632. });
  633. } else {
  634. uni.redirectTo({
  635. url: '/pages/automatic/automaticMy',
  636. });
  637. }
  638. }
  639. },
  640. updateKipMemberByWxProfile(wxProfile) {
  641. const _this = this;
  642. const wxProfileParams = {
  643. encryptedData: wxProfile.encryptedData,
  644. iv: wxProfile.iv,
  645. };
  646. uni.showLoading({
  647. title: '正在加载',
  648. mask: true,
  649. });
  650. // 根据微信授权更新kip会员信息
  651. kipUpdateWxMember(wxProfileParams)
  652. .then((updateRespResult) => {
  653. uni.hideLoading();
  654. // const updateRespResult = updateResp.data;
  655. if (updateRespResult.code === '000000') {
  656. uni.showLoading({
  657. title: '正在加载',
  658. });
  659. kipGetUserDetail()
  660. .then((result) => {
  661. uni.hideLoading();
  662. // const result = resp.data;
  663. if (result.code === '000000' && result.data) {
  664. // 存储用户信息
  665. const member = result.data;
  666. _this.saveMemberSource(member);
  667. _this.getKipMemberInfoAfter(member);
  668. } else {
  669. MemberCacheTool.cleanMemberCache(app);
  670. uni.showToast({
  671. title: result.message,
  672. duration: 2000,
  673. icon: 'none',
  674. });
  675. }
  676. })
  677. .catch((err) => {
  678. uni.hideLoading();
  679. MemberCacheTool.cleanMemberCache(app);
  680. console.log(err);
  681. });
  682. } else {
  683. const message = updateRespResult.message || '更新会员失败';
  684. uni.showToast({
  685. title: message,
  686. duration: 2000,
  687. icon: 'none',
  688. });
  689. }
  690. })
  691. .catch((err) => {
  692. uni.hideLoading();
  693. uni.showToast({
  694. title: '更新会员失败',
  695. duration: 2000,
  696. icon: 'none',
  697. });
  698. log.error('更新会员信息错误', err);
  699. });
  700. },
  701. noWechatAuthPhoneLogin(isClosePopup = true) {
  702. if (isClosePopup) {
  703. this.closeAuthPopup();
  704. }
  705. const _this = this;
  706. uni.showLoading({
  707. title: '正在加载',
  708. mask: true,
  709. });
  710. kipGetUserDetail()
  711. .then((result) => {
  712. uni.hideLoading();
  713. // const result = resp.data;
  714. if (result.code === '000000' && result.data) {
  715. // 存储用户信息
  716. const member = result.data;
  717. _this.saveMemberSource(member);
  718. _this.getKipMemberInfoAfter(member);
  719. } else {
  720. MemberCacheTool.cleanMemberCache(app);
  721. uni.showToast({
  722. title: result.message,
  723. duration: 2000,
  724. icon: 'none',
  725. });
  726. }
  727. })
  728. .catch((err) => {
  729. uni.hideLoading();
  730. MemberCacheTool.cleanMemberCache(app);
  731. console.log(err);
  732. });
  733. },
  734. saveMemberSource(kipMember) {
  735. const { phoneNumber, id } = kipMember;
  736. const groupId = uni.getStorageSync('groupId');
  737. const mallid = uni.getStorageSync('mallid');
  738. const params = {
  739. kipUserId: id,
  740. mobile: phoneNumber,
  741. groupId,
  742. mallid,
  743. };
  744. const regSource = app?.globalData.regSource;
  745. if (regSource) {
  746. params.registerSource = regSource.value;
  747. params.registerSourceLabel = regSource.label;
  748. } else {
  749. const defaultRegSource = REG_SOURCE.MINI_APP;
  750. params.registerSource = defaultRegSource.value;
  751. params.registerSourceLabel = defaultRegSource.label;
  752. }
  753. const tpName = app?.globalData?.tpName || '';
  754. const tpId = app?.globalData?.tpId || '';
  755. if (tpName || tpId) {
  756. params.registerSourceRemark = tpName + ':' + tpId;
  757. } else {
  758. params.registerSourceRemark = '';
  759. }
  760. const utmStr = getUTMSource();
  761. if (utmStr) {
  762. params.regMemberSourceOriginalParams = JSON.stringify(utmStr);
  763. }
  764. crmSaveMemberSource(params)
  765. .then((data) => {
  766. if (data.code !== 0) {
  767. console.error(data.msg);
  768. }
  769. })
  770. .catch((err) => {
  771. console.error(err);
  772. });
  773. },
  774. saveAgreementAction() {
  775. const params = {
  776. protocolStatus: 1,
  777. privacyStatus: 1,
  778. };
  779. kipAgreementSave(params)
  780. .then((result) => {
  781. // const result = resp.data;
  782. console.log('=>[kipAgreementSave]: ', result);
  783. })
  784. .catch((err) => {
  785. console.error(err);
  786. });
  787. },
  788. },
  789. };
  790. </script>
  791. <style scoped lang="less">
  792. .page {
  793. background-color: #f4f7ff;
  794. height: 100vh;
  795. }
  796. .authorize__head {
  797. width: 100%;
  798. justify-content: center;
  799. align-items: center;
  800. display: flex;
  801. padding-top: 100px;
  802. margin-bottom: 54px;
  803. .head__info {
  804. padding-top: 10px;
  805. display: flex;
  806. align-items: center;
  807. justify-content: center;
  808. flex-wrap: wrap;
  809. flex-flow: column;
  810. .head__logo {
  811. height: 75px;
  812. text-align: center;
  813. img {
  814. height: 100%;
  815. }
  816. }
  817. .head__text {
  818. font-size: 26px;
  819. color: #666;
  820. margin-top: 16px;
  821. }
  822. }
  823. }
  824. .mgt40 {
  825. margin-top: 54px;
  826. }
  827. .mgt20 {
  828. margin-top: 20px;
  829. }
  830. .mgt34 {
  831. margin-top: 34px;
  832. }
  833. .authorize_btn {
  834. height: 100px;
  835. width: calc(100% - 60px);
  836. border-radius: 100px;
  837. line-height: 100px;
  838. font-size: 36px;
  839. margin: 0 30px;
  840. }
  841. .authorize_btn--phone {
  842. background-color: #333333;
  843. color: #ffffff;
  844. }
  845. .authorize__form {
  846. width: 100%;
  847. border-top: 1px solid #d8dae0;
  848. border-bottom: 1px solid #d8dae0;
  849. }
  850. .authorize__form > .form__item {
  851. height: 130px;
  852. line-height: 130px;
  853. margin-left: 36px;
  854. display: flex;
  855. flex-direction: row;
  856. &.line {
  857. border-bottom: 1px solid #d8dae0;
  858. }
  859. }
  860. .authorize__form > .form__item > .form__label {
  861. width: 190px;
  862. font-size: 34px;
  863. }
  864. .authorize__form > .form__item > .form__input {
  865. flex: 1;
  866. margin-right: 30px;
  867. height: 130px;
  868. line-height: 130px;
  869. display: flex;
  870. align-items: center;
  871. input {
  872. height: 66px;
  873. line-height: 66px;
  874. }
  875. .van-cell {
  876. background-color: transparent;
  877. font-size: 30px;
  878. padding-right: 0;
  879. }
  880. }
  881. .authorize__form > .form__item > .form__code {
  882. display: flex;
  883. align-items: center;
  884. height: 130px;
  885. line-height: 130px;
  886. margin-right: 30px;
  887. }
  888. .protocolName {
  889. display: flex;
  890. align-items: flex-start;
  891. .van-checkbox {
  892. margin-top: 5px;
  893. }
  894. }
  895. .auth-popup {
  896. position: relative;
  897. display: flex;
  898. flex-direction: column;
  899. align-content: space-between;
  900. width: 600px;
  901. background-color: #ffffff;
  902. overflow: hidden;
  903. border-radius: 10px;
  904. .auth-popup__head {
  905. height: 90px;
  906. line-height: 90px;
  907. text-align: center;
  908. font-size: 34px;
  909. font-weight: 600;
  910. border-bottom: 1px solid #f0f0f0;
  911. }
  912. .auth-popup__main {
  913. text-align: center;
  914. .head__logo {
  915. height: 75px;
  916. margin-bottom: 40px;
  917. margin: 52px auto 27px auto;
  918. text-align: center;
  919. img {
  920. height: 100%;
  921. }
  922. }
  923. }
  924. .auth-popup__footer {
  925. display: flex;
  926. font-size: 34px;
  927. text-align: center;
  928. height: 92px;
  929. line-height: 92px;
  930. border-top: 1px solid #f0f0f0;
  931. .cancel {
  932. flex: 1;
  933. line-height: 92px;
  934. }
  935. .phone-btn {
  936. color: #6578c1;
  937. background-color: transparent;
  938. &::after {
  939. border: none;
  940. }
  941. }
  942. }
  943. }
  944. </style>