针对CRMEB多商户适配最新小程序授权方案

本文详细介绍了小程序的授权流程,包括在移动端`Authorize.vue`组件中如何处理用户授权提示,以及在PHP后端`app/controller/api/Auth.php`的`mpAuth()`方法中如何接收并处理授权信息。通过示例代码展示了从获取用户信息到存储用户数据的全过程,确保用户授权后能正常登录和服务。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

对照下图修改对应文件中的代码。
注意:以下相关的修改代码是多商户V1.3.1版本,如果是其他版本请自行做相关的调整适配。

关于CRMEB多商户可以点击了解源码,演示账号 : demo 密码: crmeb.com

还有更多其他项目了解戳这里:了解更多

加小姐姐了解更多
在这里插入图片描述
一. 移动端修改,如下图对应位置修改;

  1. 文件位置 : components/Authorize.vue
    在这里插入图片描述

如果未做二开,完整代码如下:

<template>
	<view>
		<view class='Popup' v-if='isShowAuth'>
			<view class="logo-auth">
				<image :src='logoUrl' mode="aspectFit"></image>
			</view>
			<view class='title'>授权提醒</view>
			<view class='tip'>请授权头像等信息,以便为您提供更好的服务</view>
			<view class='bottom flex'>
				<view class='item' @click='close'>随便逛逛</view>
				<!-- #ifdef APP-PLUS -->
				<button class='item grant' @click="setUserInfo">去授权</button>
				<!-- #endif -->
				<!-- #ifdef MP -->
				<button v-if="canUseGetUserProfile" class="item grant" hover-class="none"
					@tap="getUserProfile">去授权</button>
				<button v-else class='item grant' type="primary" open-type="getUserInfo" lang="zh_CN"
					@getuserinfo="setUserInfo">去授权</button>
				<!-- #endif -->
			</view>
		</view>
		<view class='mask' v-if='isShowAuth' @click='close'></view>
	</view>
</template>

<script>
	const app = getApp();
	import Cache from '../utils/cache';
	import {
    
		getLogo
	} from '../api/public';
	import {
    
		LOGO_URL
	} from '../config/cache';
	import {
    
		mapGetters
	} from 'vuex';
	import Routine from '../libs/routine';

	export default {
    
		name: 'Authorize',
		props: {
    
			isAuto: {
    
				type: Boolean,
				default: true
			},
			isGoIndex: {
    
				type: Boolean,
				default: true
			},
			isShowAuth: {
    
				type: Boolean,
				default: false
			}
		},
		data() {
    
			return {
    
				logoUrl: app.globalData.routine_logo,
				canUseGetUserProfile: false
			}
		},
		computed: mapGetters(['isLogin', 'userInfo']),
		watch: {
    
			isLogin(n) {
    
				n === true && this.$emit('onLoadFun
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值