|
@@ -1,8 +1,928 @@
|
|
|
<template>
|
|
|
- <scroll-view
|
|
|
- style="background-color: #F4F7FF"
|
|
|
- scroll-y="true"
|
|
|
- >
|
|
|
- 手机验证码登录
|
|
|
- </scroll-view>
|
|
|
+ <div class="page">
|
|
|
+ <div class="authorize__head">
|
|
|
+ <div class="head__info">
|
|
|
+ <div class="head__logo">
|
|
|
+ <img :src="getLogo" mode="heightFix"/>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="authorize__form">
|
|
|
+ <div class="form__item line" style="border-bottom: 1px solid #D8DAE0;">
|
|
|
+ <div class="form__label">
|
|
|
+ 手机号码
|
|
|
+ </div>
|
|
|
+ <div class="form__input">
|
|
|
+ <!-- <input type="number" placeholder="请输入您的手机号" v-model="mobile" /> -->
|
|
|
+ <van-field
|
|
|
+ v-model="mobile"
|
|
|
+ type="number"
|
|
|
+ placeholder="请输入您的手机号"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form__item">
|
|
|
+ <div class="form__label">验证码</div>
|
|
|
+ <div class="form__input">
|
|
|
+ <!-- <input type="number" placeholder="请输入验证码" v-model="codeNum"> -->
|
|
|
+ <van-field
|
|
|
+ v-model="codeNum"
|
|
|
+ type="number"
|
|
|
+ placeholder="请输入验证码"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div class="form__code">
|
|
|
+ <wyb-button type="hollow" :count-down="true" :count-down-num="59" width="240px" height="70px" color="#1D1D1D"
|
|
|
+ font-size="28" border-size="1" :radius="['50px']" @click="onCode" :mobile="mobile"
|
|
|
+ @pre-click="handlePreClick">
|
|
|
+ 获取验证码
|
|
|
+ </wyb-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="mgt40">
|
|
|
+ <button class="authorize_btn authorize_btn--phone" @click="onLogin">注册/登录</button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="mgt34">
|
|
|
+ <div style="margin: 0 30px;">
|
|
|
+ <div style="display: flex;align-items: flex-start;">
|
|
|
+ <!-- <checkbox-group @change="protocolChange">
|
|
|
+ <checkbox style="transform: scale(0.8);" color="#808080" value="protocol" :checked="protocolChecked" />
|
|
|
+ </checkbox-group> -->
|
|
|
+ <van-checkbox @change="protocolChange" :value="protocolChecked" color="#ED1C24" name="protocol" icon-size="17" checked-color="#064C8A" shape="square"></van-checkbox>
|
|
|
+ <div style="color: #666666; font-size: 32px; flex: 1;margin-left: 15px;" v-if="brandInfo && brandInfo.protocolName">
|
|
|
+ 已阅读并同意<span style="color: #627ECF;" @click="gotoProtocol('protocol')">《{{ brandInfo.protocolName }}》</span>
|
|
|
+ 和<span style="color: #627ECF;"
|
|
|
+ @click="gotoProtocol('privacyPolicy')">《{{ brandInfo.privacyPolicyName }}》</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <uni-popup ref="popup" :mask-click="false" type="center" style="z-index: 999999;">
|
|
|
+ <div class="auth-popup">
|
|
|
+ <div class="auth-popup__head">
|
|
|
+ <span>微信授权</span>
|
|
|
+ </div>
|
|
|
+ <div class="auth-popup__main">
|
|
|
+ <div class="head__logo">
|
|
|
+ <img :src="getLogo" mode="heightFix"/>
|
|
|
+ </div>
|
|
|
+ <div style="margin-bottom:20px;font-size: 30px;">申请获取以下权限</div>
|
|
|
+ <div style="height:80px;line-height:80px;border-top:1px solid #F0F0F0; color: #999999; font-size: 32px;">
|
|
|
+ 获得你的公开信息(个人信息等)
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="auth-popup__footer">
|
|
|
+ <div class="cancel" @click="noWechatAuthPhoneLogin">取消</div>
|
|
|
+ <div style="flex: 1; border-left: 1px solid #F0F0F0;">
|
|
|
+ <button class="phone-btn" @click="getWxProfile">确认授权</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </uni-popup>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
+
|
|
|
+
|
|
|
+<script>
|
|
|
+import log from '@/utils/log'
|
|
|
+// import wybButton from '@/components/wyb-button/wyb-button.vue'
|
|
|
+import {
|
|
|
+ kipSendRegisterSMS,
|
|
|
+ kipPhoneLogin,
|
|
|
+ kipUpdateWxMember,
|
|
|
+ kipGetUserDetail,
|
|
|
+ kipGetBrandInfo,
|
|
|
+ kipAgreementSave
|
|
|
+} from '@/utils/api-kip.js'
|
|
|
+import MemberCacheTool from '@/utils/member-cache-tool.js'
|
|
|
+import KipCacheTool from '@/utils/kip-cache-tool.js'
|
|
|
+import {
|
|
|
+ crmQueryMemberInfo,
|
|
|
+ crmSaveMemberSource,
|
|
|
+} from '@/utils/api-crm-member.js'
|
|
|
+// var app = getApp()
|
|
|
+import { mapState } from "vuex";
|
|
|
+import {
|
|
|
+ getUTMSource,
|
|
|
+} from '@/utils/utils.js'
|
|
|
+import CacheTool from '@/utils/cache-tool.js'
|
|
|
+
|
|
|
+const {KERRY_ON_BRAND_ID,HANGZHOU_LBS_ID} = CacheTool.getCurEnvConst();
|
|
|
+import { REG_SOURCE } from '@/constants.js'
|
|
|
+import uni from '@/utils/uniHooks.js'
|
|
|
+
|
|
|
+const app = {};
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'Login',
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ mobile: '', // 手机号
|
|
|
+ codeNum: '', // 验证码
|
|
|
+ timer: 60, // 时间
|
|
|
+ url: '',
|
|
|
+ protocolChecked: false,
|
|
|
+ brandInfo: null,
|
|
|
+ lbsInfo: null,
|
|
|
+ preUrl: '',
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ const option = this.$route.query;
|
|
|
+ if ( option && JSON.stringify(option) !== "{}" ) {
|
|
|
+ this.url = JSON.parse(decodeURIComponent(option?.url || '{}'))
|
|
|
+ }
|
|
|
+ this.preUrl = uni.getStorageSync('previousUrl')
|
|
|
+ uni.setStorageSync('previousUrl','/pages/wxLogin/login.vue')
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapState({
|
|
|
+ custTypeId: state => state.custTypeId,
|
|
|
+ mallid: state => state.mallId,
|
|
|
+ groupId: state => state.groupId,
|
|
|
+ member: state => state.member,
|
|
|
+ }),
|
|
|
+ getLogo() {
|
|
|
+ // TODO: logo 需要更具lbs区分进入
|
|
|
+ // return CacheTool.getLogoByMallid(this.mallid)
|
|
|
+ return 'https://kip-public-qa.oss-cn-shanghai.aliyuncs.com/1634707859342-qldc5c.jpg'
|
|
|
+ },
|
|
|
+ isHangzhou() {
|
|
|
+ return uni.getStorageSync('mallid') == HANGZHOU_LBS_ID;
|
|
|
+ },
|
|
|
+ isKerryOn() {
|
|
|
+ return uni.getStorageSync('groupId') == KERRY_ON_BRAND_ID;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ groupId( val ) {
|
|
|
+ console.log('groupId',val)
|
|
|
+ },
|
|
|
+ mallid( val ) {
|
|
|
+ console.log('mallid',val)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ // console.log(154,this.groupId,this.mallid);
|
|
|
+ this.getBrandInfo()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 埋点方法
|
|
|
+ sensorsClick( eventName,params ) {
|
|
|
+ let optionsQuery = uni.getStorageSync('options_query')
|
|
|
+ let fixedParams = {
|
|
|
+ cta_itemno: '',
|
|
|
+ cta_name: '',
|
|
|
+ previous_url: this.preUrl || '',
|
|
|
+ redirect_url: '',
|
|
|
+ // $brand_id: uni.getStorageSync('groupId'),
|
|
|
+ // $location: uni.getStorageSync('mallid'),
|
|
|
+ $channel: optionsQuery.channel || '',
|
|
|
+ // $utm_lbs: this.optionsQuery.utm_lbs || '',
|
|
|
+ $utm_channel: optionsQuery.utm_channel || '',
|
|
|
+ $utm_method: optionsQuery.utm_method || '',
|
|
|
+ $utm_source: optionsQuery.utm_source || '',
|
|
|
+ $utm_function: optionsQuery.utm_function || '',
|
|
|
+ $utm_user: optionsQuery.utm_user || '',
|
|
|
+ },
|
|
|
+ finalParams = Object.assign(fixedParams,params)
|
|
|
+ this.$sensors.track(eventName,finalParams)
|
|
|
+ },
|
|
|
+ // 获取验证码
|
|
|
+ onCode: function () {
|
|
|
+ if ( this.check() ) {
|
|
|
+ this.getCodeData()
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+ // 获取验证码
|
|
|
+ getCodeData: function () {
|
|
|
+ uni.showLoading({
|
|
|
+ title: '加载中'
|
|
|
+ });
|
|
|
+ var datas = {
|
|
|
+ phoneNumber: this.mobile
|
|
|
+ }
|
|
|
+ kipSendRegisterSMS(datas).then(resp => {
|
|
|
+ uni.hideLoading();
|
|
|
+ // console.log(resp);
|
|
|
+ const result = resp.data;
|
|
|
+ if ( result.code == '000000' && result.data ) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '获取验证码成功!',
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ const message = result.message || '发送失败';
|
|
|
+ uni.showToast({
|
|
|
+ title: message,
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ log.error(`短信发送失败, 手机号: ${ datas.phoneNumber }`)
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ uni.hideLoading();
|
|
|
+ uni.showToast({
|
|
|
+ title: '发送注册信息错误',
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ log.error(err);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //授权
|
|
|
+ getWxProfile: function () {
|
|
|
+ let _this = this;
|
|
|
+ this.closeAuthPopup();
|
|
|
+ uni.getUserProfile({
|
|
|
+ desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
|
|
|
+ success: ( res ) => {
|
|
|
+ _this.updateKipMemberByWxProfile(res);
|
|
|
+ },
|
|
|
+ fail: ( res ) => {
|
|
|
+ console.warn(`用户取消授权, ${ JSON.stringify(res) }`)
|
|
|
+ log.warn(`用户取消授权`)
|
|
|
+ // 此时用户已注册,即使用户取消授权,也需要用随机头像昵称登录
|
|
|
+ const isClosePopup = false;
|
|
|
+ _this.noWechatAuthPhoneLogin(isClosePopup);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ queryMember: function () {
|
|
|
+ let _this = this;
|
|
|
+ uni.showLoading({
|
|
|
+ title: '正在加载',
|
|
|
+ mask: true,
|
|
|
+ })
|
|
|
+ kipGetUserDetail().then(resp => {
|
|
|
+ uni.hideLoading()
|
|
|
+ const result = resp.data;
|
|
|
+ if ( result.code === '000000' && result.data ) {
|
|
|
+ const member = result.data;
|
|
|
+ if ( member ) {
|
|
|
+ _this.getKipMemberInfoAfter(member)
|
|
|
+ } else {
|
|
|
+ MemberCacheTool.cleanMemberCache(app);
|
|
|
+ uni.showToast({
|
|
|
+ title: result.message,
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ log.warn(`查询会员信息成功:没有会员信息`)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ MemberCacheTool.cleanMemberCache(app);
|
|
|
+ uni.showToast({
|
|
|
+ title: result.message,
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ log.warn(`查询会员信息失败,${ result.message }`)
|
|
|
+ }
|
|
|
+
|
|
|
+ }).catch(err => {
|
|
|
+ uni.hideLoading()
|
|
|
+ console.error(err);
|
|
|
+ MemberCacheTool.cleanMemberCache(app);
|
|
|
+ uni.showToast({
|
|
|
+ title: '查询会员信息错误',
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ log.warn(`查询会员信息错误`)
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+ // 登录
|
|
|
+ onLogin: function () {
|
|
|
+ let _this = this
|
|
|
+ // 判断会员协议
|
|
|
+ if ( !_this.protocolChecked ) {
|
|
|
+ uni.showModal({
|
|
|
+ title: '请阅读并勾选下方的协议',
|
|
|
+ showCancel: false,
|
|
|
+ })
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if ( _this.check() ) {
|
|
|
+
|
|
|
+ if ( _this.codeNum === '' ) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '请输入验证码',
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ // 调登录接口
|
|
|
+ uni.showLoading({
|
|
|
+ title: '正在登录',
|
|
|
+ mask: true,
|
|
|
+ });
|
|
|
+ uni.login({
|
|
|
+ provider: 'weixin',
|
|
|
+ success: function ( loginRes ) {
|
|
|
+ console.log('===> 手机号登录 ',loginRes)
|
|
|
+ const curJsCode = loginRes.code;
|
|
|
+ const params = {
|
|
|
+ verifyCode: _this.codeNum,
|
|
|
+ phoneNumber: _this.mobile,
|
|
|
+ jsCode: curJsCode,
|
|
|
+ brandId: this.groupId,
|
|
|
+ lbsId: this.mallid
|
|
|
+ }
|
|
|
+ kipPhoneLogin(params).then(resp => {
|
|
|
+ uni.hideLoading()
|
|
|
+ const result = resp.data;
|
|
|
+ if ( result.code == '000000' && result.data ) {
|
|
|
+ log.info(`手机号登录成功:保存授权信息`)
|
|
|
+
|
|
|
+ const authInfo = result.data;
|
|
|
+ const needLogin = authInfo.needLogin;
|
|
|
+ // 此接口返回的needLogin暂时没有true
|
|
|
+ KipCacheTool.setKipCache(authInfo);
|
|
|
+
|
|
|
+
|
|
|
+ // if (!needLogin) {
|
|
|
+ // KipCacheTool.setKipCache(authInfo);
|
|
|
+ // // 请求用户信息
|
|
|
+ // _this.queryMember()
|
|
|
+ // }
|
|
|
+
|
|
|
+ if ( _this.isHangzhou ) {
|
|
|
+ uni.setStorageSync("comfirLocation",'login.vue');
|
|
|
+ uni.setStorageSync("comfirHangzhou",true);
|
|
|
+ } else if ( _this.isKerryOn ) {
|
|
|
+ uni.setStorageSync("comfirLocation",'login.vue');
|
|
|
+ uni.setStorageSync("comfirKerryOn",true);
|
|
|
+ }
|
|
|
+ _this.saveAgreementAction()
|
|
|
+ if ( authInfo.headEmpty ) {
|
|
|
+ _this.openAuthPopup();
|
|
|
+ } else {
|
|
|
+ _this.queryMember();
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ log.warn(`手机号登录请求成功: 未获取到授权信息`)
|
|
|
+ uni.showModal({
|
|
|
+ title: '登录失败',
|
|
|
+ content: result.message,
|
|
|
+ showCancel: false,
|
|
|
+ })
|
|
|
+ KipCacheTool.cleanKipCache()
|
|
|
+ MemberCacheTool.cleanMemberCache(app);
|
|
|
+ }
|
|
|
+
|
|
|
+ }).catch(err => {
|
|
|
+ uni.hideLoading()
|
|
|
+ console.log(err);
|
|
|
+ uni.showToast({
|
|
|
+ title: '登录失败',
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ log.warn(`手机号登录请求失败`)
|
|
|
+ KipCacheTool.cleanKipCache()
|
|
|
+ MemberCacheTool.cleanMemberCache(app);
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+ fail: function ( loginRes ) {
|
|
|
+ uni.showModal({
|
|
|
+ title: '登录失败',
|
|
|
+ content: loginRes.errMsg,
|
|
|
+ showCancel: false,
|
|
|
+ })
|
|
|
+ log.warn(`授权手机号失败`)
|
|
|
+ KipCacheTool.cleanKipCache()
|
|
|
+ MemberCacheTool.cleanMemberCache(app);
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ check: function () {
|
|
|
+ if ( this.mobile === '' ) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '请输入手机号',
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ const regPhone = '/^1[3456789]d{9}$/'
|
|
|
+ let reg = /^1[3456789]\d{9}$/
|
|
|
+ if ( !reg.test(this.mobile) ) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '请输入正确的手机号',
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ },
|
|
|
+ handlePreClick( e ) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '请输入正确的手机号',
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ },
|
|
|
+ gotoProtocol( type ) {
|
|
|
+ const brandId = this.brandInfo.id || ''
|
|
|
+ const lbsId = this.lbsInfo[0].id || ''
|
|
|
+ const isChecked = this.protocolChecked;
|
|
|
+ uni.navigateTo({
|
|
|
+ url: `/pages/protocol/protocol?type=${ type }&brandId=${ brandId }&lbsId=${ lbsId }&isChecked=${ isChecked }`
|
|
|
+ })
|
|
|
+ },
|
|
|
+ protocolChange( e ) {
|
|
|
+ console.log(e)
|
|
|
+ this.protocolChecked = !this.protocolChecked
|
|
|
+ const mallid = this.mallid
|
|
|
+ CacheTool.setAgreeProtocoByMallid(mallid,this.protocolChecked)
|
|
|
+ },
|
|
|
+ getBrandInfo() {
|
|
|
+ const _this = this;
|
|
|
+ const HZ_BRAND_ID = this.groupId;
|
|
|
+ const HZ_LBS_ID = this.mallid;
|
|
|
+ // return
|
|
|
+ const params = {
|
|
|
+ id: HZ_BRAND_ID,
|
|
|
+ lbsId: HZ_LBS_ID
|
|
|
+ }
|
|
|
+ uni.showLoading({
|
|
|
+ title: '正在加载',
|
|
|
+ mask: true,
|
|
|
+ })
|
|
|
+ kipGetBrandInfo(params).then(resp => {
|
|
|
+ uni.hideLoading()
|
|
|
+ // console.log(468, resp);
|
|
|
+ // return
|
|
|
+ if ( !resp || !resp.data.length || resp.code != '000000' ) {
|
|
|
+ log.warn(`获取会员绑定的brand请求成功:未获取到数据`)
|
|
|
+ console.log(`获取会员绑定的brand请求成功:未获取到数据`);
|
|
|
+ const message = resp?.data?.message || '服务不可用';
|
|
|
+ uni.showToast({
|
|
|
+ title: message,
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ const brandArray = resp.data;
|
|
|
+ if ( brandArray && brandArray.length > 0 && brandArray[0] ) {
|
|
|
+ const brandInfo = brandArray[0].brand;
|
|
|
+ _this.brandInfo = brandInfo;
|
|
|
+ const lbsInfo = brandArray[0].lbs;
|
|
|
+ _this.lbsInfo = lbsInfo;
|
|
|
+ }
|
|
|
+ console.log(487, _this.lbsInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ }).catch(err => {
|
|
|
+ uni.hideLoading()
|
|
|
+ console.error(err);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getKipMemberInfoAfter( kipMemberInfo ) {
|
|
|
+ MemberCacheTool.setKipMember(app,kipMemberInfo)
|
|
|
+
|
|
|
+ const _this = this;
|
|
|
+ // 查询 crm 会员
|
|
|
+ uni.showLoading({
|
|
|
+ title: '正在加载',
|
|
|
+ mask: true,
|
|
|
+ })
|
|
|
+ const newGroupId = uni.getStorageSync("groupId");
|
|
|
+ const newMallid = uni.getStorageSync("mallid")
|
|
|
+ const params = {
|
|
|
+ groupId: newGroupId,
|
|
|
+ kipUserId: kipMemberInfo.id,
|
|
|
+ mallId: newMallid
|
|
|
+ }
|
|
|
+ crmQueryMemberInfo(params).then(resp => {
|
|
|
+ uni.hideLoading()
|
|
|
+ log.info(`获取crm会员请求失败`)
|
|
|
+ const result = resp.data;
|
|
|
+ if ( result && result.code == '0' ) {
|
|
|
+ const member = result.data;
|
|
|
+ const optionsQuery = uni.getStorageSync('options_query') || {};
|
|
|
+ if ( member ) {
|
|
|
+ // 这里埋点-登录过但是清空缓存
|
|
|
+ console.log('==>这里走埋点--手机号码---crmQueryMemberInfo',member)
|
|
|
+ // TODO: 埋点公共属性重新赋值
|
|
|
+ _this.$sensors.registerApp({
|
|
|
+ $open_id: _this.globalData?.member?.openId || '',
|
|
|
+ $profile_id: _this.globalData?.member?.kipUserId || member?.kipUserId || '',
|
|
|
+ $member_id: _this.globalData?.member?.id || member?.id || '',
|
|
|
+ $union_id: _this.globalData?.member?.unionid || '',
|
|
|
+ // $location: _this.globalData?.mallid,
|
|
|
+ // $brand_id: _this.globalData?.groupId,
|
|
|
+ // $utm_source: JSON.stringify(uni.getStorageSync('options_query')) || '',
|
|
|
+ // $channel: optionsQuery?.channel || '',
|
|
|
+ $utm_lbs: optionsQuery?.utm_lbs || '',
|
|
|
+ // $utm_channel: optionsQuery?.utm_channel || '',
|
|
|
+ // $utm_method: optionsQuery?.utm_method || '',
|
|
|
+ // $utm_source: optionsQuery?.utm_source || '',
|
|
|
+ // $utm_function: optionsQuery?.utm_function || '',
|
|
|
+ // $utm_user: optionsQuery?.utm_user || '',
|
|
|
+ })
|
|
|
+ MemberCacheTool.setMemberInfoCache(app,member,kipMemberInfo);
|
|
|
+ _this.checkIsNewUser()
|
|
|
+ } else {
|
|
|
+ uni.hideLoading()
|
|
|
+ log.error(`获取crm会员请求失败`)
|
|
|
+ console.error(err)
|
|
|
+ uni.showToast({
|
|
|
+ title: "登录注册失败",
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ KipCacheTool.cleanKipCache()
|
|
|
+ MemberCacheTool.cleanMemberCache(app);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ uni.hideLoading()
|
|
|
+ log.error(`获取crm会员请求失败`)
|
|
|
+ console.error(err)
|
|
|
+ uni.showToast({
|
|
|
+ title: "登录注册失败",
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ KipCacheTool.cleanKipCache()
|
|
|
+ MemberCacheTool.cleanMemberCache(app);
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ uni.hideLoading()
|
|
|
+ log.error(`获取crm会员请求错误`)
|
|
|
+ console.error(err)
|
|
|
+ uni.showToast({
|
|
|
+ title: "登录注册错误",
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ KipCacheTool.cleanKipCache()
|
|
|
+ MemberCacheTool.cleanMemberCache(app);
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+ openAuthPopup() {
|
|
|
+ this.$refs.popup.open();
|
|
|
+ },
|
|
|
+ closeAuthPopup() {
|
|
|
+ this.$refs.popup.close();
|
|
|
+ },
|
|
|
+ checkIsNewUser() {
|
|
|
+ // 除静安和浦东外,完善信息只显示一次
|
|
|
+ if ( this.custTypeId == '0' ) {
|
|
|
+ const isNewUser = KipCacheTool.getKipIsNewUser();
|
|
|
+ if ( isNewUser ) {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/personInfo/personInfo'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.redirectTo({
|
|
|
+ url: '/pages/automatic/automaticMy'
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ const member = this.member;
|
|
|
+ if ( member && ( !member.isCompleted || member.isCompleted == '0' ) ) {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/personInfo/personInfo'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.redirectTo({
|
|
|
+ url: '/pages/automatic/automaticMy'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ updateKipMemberByWxProfile( wxProfile ) {
|
|
|
+ const _this = this;
|
|
|
+ const wxProfileParams = {
|
|
|
+ encryptedData: wxProfile.encryptedData,
|
|
|
+ iv: wxProfile.iv
|
|
|
+ }
|
|
|
+ uni.showLoading({
|
|
|
+ title: '正在加载',
|
|
|
+ mask: true,
|
|
|
+ })
|
|
|
+ // 根据微信授权更新kip会员信息
|
|
|
+ kipUpdateWxMember(wxProfileParams).then(updateResp => {
|
|
|
+ uni.hideLoading()
|
|
|
+ const updateRespResult = updateResp.data;
|
|
|
+ if ( updateRespResult.code === '000000' ) {
|
|
|
+ uni.showLoading({
|
|
|
+ title: '正在加载'
|
|
|
+ })
|
|
|
+ kipGetUserDetail().then(resp => {
|
|
|
+ uni.hideLoading()
|
|
|
+ const result = resp.data;
|
|
|
+ if ( result.code === '000000' && result.data ) {
|
|
|
+ // 存储用户信息
|
|
|
+ const member = result.data;
|
|
|
+ _this.saveMemberSource(member);
|
|
|
+ _this.getKipMemberInfoAfter(member);
|
|
|
+ } else {
|
|
|
+ MemberCacheTool.cleanMemberCache(app);
|
|
|
+ uni.showToast({
|
|
|
+ title: result.message,
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ uni.hideLoading()
|
|
|
+ MemberCacheTool.cleanMemberCache(app);
|
|
|
+ console.log(err);
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ const message = updateRespResult.message || '更新会员失败';
|
|
|
+ uni.showToast({
|
|
|
+ title: message,
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ uni.hideLoading()
|
|
|
+ uni.showToast({
|
|
|
+ title: '更新会员失败',
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ log.error('更新会员信息错误',err);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ noWechatAuthPhoneLogin( isClosePopup = true ) {
|
|
|
+ if ( isClosePopup ) {
|
|
|
+ this.closeAuthPopup();
|
|
|
+ }
|
|
|
+
|
|
|
+ const _this = this;
|
|
|
+ uni.showLoading({
|
|
|
+ title: '正在加载',
|
|
|
+ mask: true,
|
|
|
+ })
|
|
|
+ kipGetUserDetail().then(resp => {
|
|
|
+ uni.hideLoading()
|
|
|
+ const result = resp.data;
|
|
|
+ if ( result.code === '000000' && result.data ) {
|
|
|
+ // 存储用户信息
|
|
|
+ const member = result.data;
|
|
|
+ _this.saveMemberSource(member);
|
|
|
+ _this.getKipMemberInfoAfter(member);
|
|
|
+ } else {
|
|
|
+ MemberCacheTool.cleanMemberCache(app);
|
|
|
+ uni.showToast({
|
|
|
+ title: result.message,
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ uni.hideLoading()
|
|
|
+ MemberCacheTool.cleanMemberCache(app);
|
|
|
+ console.log(err);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ saveMemberSource( kipMember ) {
|
|
|
+ const {phoneNumber,id} = kipMember;
|
|
|
+ const groupId = uni.getStorageSync("groupId");
|
|
|
+ const mallid = uni.getStorageSync("mallid");
|
|
|
+ const params = {
|
|
|
+ kipUserId: id,
|
|
|
+ mobile: phoneNumber,
|
|
|
+ groupId,
|
|
|
+ mallid,
|
|
|
+ }
|
|
|
+ const regSource = app?.globalData.regSource;
|
|
|
+ if ( regSource ) {
|
|
|
+ params.registerSource = regSource.value;
|
|
|
+ params.registerSourceLabel = regSource.label;
|
|
|
+ } else {
|
|
|
+ const defaultRegSource = REG_SOURCE.MINI_APP;
|
|
|
+ params.registerSource = defaultRegSource.value;
|
|
|
+ params.registerSourceLabel = defaultRegSource.label;
|
|
|
+ }
|
|
|
+
|
|
|
+ const tpName = app?.globalData?.tpName || '';
|
|
|
+ const tpId = app?.globalData?.tpId || '';
|
|
|
+ if ( tpName || tpId ) {
|
|
|
+ params.registerSourceRemark = tpName + ':' + tpId;
|
|
|
+ } else {
|
|
|
+ params.registerSourceRemark = '';
|
|
|
+ }
|
|
|
+ const utmStr = getUTMSource();
|
|
|
+ if ( utmStr ) {
|
|
|
+ params.regMemberSourceOriginalParams = JSON.stringify(utmStr);
|
|
|
+ }
|
|
|
+ crmSaveMemberSource(params).then(resp => {
|
|
|
+ if ( resp.data.code !== 0 ) {
|
|
|
+ console.error(resp.data.msg);
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ console.error(err);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ saveAgreementAction() {
|
|
|
+ const params = {
|
|
|
+ protocolStatus: 1,
|
|
|
+ privacyStatus: 1
|
|
|
+ }
|
|
|
+ kipAgreementSave(params).then(resp => {
|
|
|
+ const result = resp.data;
|
|
|
+ console.log('=>[kipAgreementSave]: ',result)
|
|
|
+ }).catch(err => {
|
|
|
+ console.error(err)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+
|
|
|
+<style scoped lang="less">
|
|
|
+.page {
|
|
|
+ background-color: #F4F7FF;
|
|
|
+ height: 100vh;
|
|
|
+}
|
|
|
+
|
|
|
+.authorize__head {
|
|
|
+ width: 100%;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ display: flex;
|
|
|
+ padding-top: 100px;
|
|
|
+ margin-bottom: 54px;
|
|
|
+
|
|
|
+ .head__info {
|
|
|
+ padding-top: 10px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ flex-flow: column;
|
|
|
+
|
|
|
+ .head__logo {
|
|
|
+ height: 75px;
|
|
|
+ text-align: center;
|
|
|
+
|
|
|
+ img {
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .head__text {
|
|
|
+ font-size: 26px;
|
|
|
+ color: #666;
|
|
|
+ margin-top: 16px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.mgt40 {
|
|
|
+ margin-top: 54px;
|
|
|
+}
|
|
|
+
|
|
|
+.mgt34 {
|
|
|
+ margin-top: 34px;
|
|
|
+}
|
|
|
+
|
|
|
+.authorize_btn {
|
|
|
+ height: 100px;
|
|
|
+ width: calc(100% - 60px);
|
|
|
+ border-radius: 100px;
|
|
|
+ line-height: 100px;
|
|
|
+ font-size: 36px;
|
|
|
+ margin: 0 30px;
|
|
|
+}
|
|
|
+
|
|
|
+.authorize_btn--phone {
|
|
|
+ background-color: #333333;
|
|
|
+ color: #FFFFFF;
|
|
|
+}
|
|
|
+
|
|
|
+.authorize__form {
|
|
|
+ width: 100%;
|
|
|
+ border-top: 1px solid #D8DAE0;
|
|
|
+ border-bottom: 1px solid #D8DAE0;
|
|
|
+}
|
|
|
+
|
|
|
+.authorize__form > .form__item {
|
|
|
+ height: 130px;
|
|
|
+ line-height: 130px;
|
|
|
+ margin-left: 36px;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ &.line {
|
|
|
+ border-bottom: 1px solid #D8DAE0;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.authorize__form > .form__item > .form__label {
|
|
|
+ width: 190px;
|
|
|
+ font-size: 34px;
|
|
|
+}
|
|
|
+
|
|
|
+.authorize__form > .form__item > .form__input {
|
|
|
+ flex: 1;
|
|
|
+ margin-right: 30px;
|
|
|
+ height: 130px;
|
|
|
+ line-height: 130px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+
|
|
|
+ input {
|
|
|
+ height: 66px;
|
|
|
+ line-height: 66px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .van-cell {
|
|
|
+ background-color: transparent;
|
|
|
+ font-size: 30px;
|
|
|
+ padding-right: 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.authorize__form > .form__item > .form__code {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ height: 130px;
|
|
|
+ line-height: 130px;
|
|
|
+ margin-right: 30px;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+.auth-popup {
|
|
|
+ position: relative;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-content: space-between;
|
|
|
+ width: 600px;
|
|
|
+ background-color: #FFFFFF;
|
|
|
+ overflow: hidden;
|
|
|
+ border-radius: 10px;
|
|
|
+
|
|
|
+ .auth-popup__head {
|
|
|
+ height: 90px;
|
|
|
+ line-height: 90px;
|
|
|
+ text-align: center;
|
|
|
+ font-size: 34px;
|
|
|
+ font-weight: 600;
|
|
|
+ border-bottom: 1px solid #F0F0F0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .auth-popup__main {
|
|
|
+ text-align: center;
|
|
|
+
|
|
|
+ .head__logo {
|
|
|
+ height: 75px;
|
|
|
+ margin-bottom: 40px;
|
|
|
+ margin: 52px auto 27px auto;
|
|
|
+ text-align: center;
|
|
|
+
|
|
|
+ img {
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .auth-popup__footer {
|
|
|
+ display: flex;
|
|
|
+ font-size: 34px;
|
|
|
+ text-align: center;
|
|
|
+ height: 92px;
|
|
|
+ line-height: 92px;
|
|
|
+ border-top: 1px solid #F0F0F0;
|
|
|
+
|
|
|
+ .cancel {
|
|
|
+ flex: 1;
|
|
|
+ line-height: 92px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .phone-btn {
|
|
|
+ color: #6578C1;
|
|
|
+ background-color: transparent;
|
|
|
+
|
|
|
+ &::after {
|
|
|
+ border: none;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|