From c5f055cc1c65677a147c99aff5999c797a8ca706 Mon Sep 17 00:00:00 2001 From: 18650502300 <18650502300@163.com> Date: Sat, 27 Jan 2024 21:16:35 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9D=99=E9=BB=98=E4=BF=9D=E5=AD=98=E6=B8=A0?= =?UTF-8?q?=E9=81=93id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/public.js | 9 ++--- api/user.js | 48 ++++++++++++------------- config/app.js | 10 +++--- config/cache.js | 3 +- libs/wechat.js | 2 +- main.js | 17 ++++----- manifest.json | 5 ++- pages/goods_details/index.vue | 56 ++++++++++++++++-------------- pages/index/index.vue | 16 ++++++--- pages/users/wechat_login/index.vue | 14 +++++--- utils/index.js | 37 ++++++++++++++++++-- 11 files changed, 134 insertions(+), 83 deletions(-) diff --git a/api/public.js b/api/public.js index 713e4eb..9a883a4 100644 --- a/api/public.js +++ b/api/public.js @@ -19,18 +19,19 @@ export function getWechatConfig() { * 获取微信sdk配置 * @returns {*} */ -export function wechatAuth(code, spread) { +export function wechatAuth(code, spread,channelId) { var reg=/^[0-9]+.?[0-9]*$/; //判断字符串是否为数字 ,判断正整数用/^[1-9]+[0-9]*]*$/ spread = reg.test(spread) ? spread : 0; + channelId = reg.test(channelId) ? channelId : 0; return request.get( - "wechat/authorize/login?code=" + code + "&spread_spid=" + spread, {}, + "wechat/authorize/login?code=" + code + "&spread_spid=" + spread+"&channelId="+channelId, {}, { noAuth: true } ); } /** * 获取登录授权login - * + * */ export function getLogo() { @@ -108,4 +109,4 @@ export function appleLogin(data) { */ export function iosBinding(data) { return request.post("ios/binding/phone", data, { noAuth : true }); -} \ No newline at end of file +} diff --git a/api/user.js b/api/user.js index 4a71f76..a28fa9d 100644 --- a/api/user.js +++ b/api/user.js @@ -5,7 +5,7 @@ import Cache from "@/utils/cache.js" /** * 获取用户信息 - * + * */ export function getUserInfo(){ return request.get('user'); @@ -13,7 +13,7 @@ export function getUserInfo(){ /** * 设置用户分享 - * + * */ export function userShare(){ return request.post('user/share'); @@ -83,7 +83,7 @@ export function postSignUser(sign) { /** * 获取签到配置 - * + * */ export function getSignConfig(){ return request.get('user/sign/config') @@ -107,7 +107,7 @@ export function setSignIntegral(){ /** * 签到列表(年月) * @param object data - * + * */ export function getSignMonthList(data){ return request.get('user/sign/month',data) @@ -115,7 +115,7 @@ export function getSignMonthList(data){ /** * 活动状态 - * + * */ export function userActivity(){ return request.get('user/activity'); @@ -136,7 +136,7 @@ export function getRecordApi(q) { } /* - * 提现总金额 + * 提现总金额 * */ export function getCountApi() { return request.get("extract/totalMoney"); @@ -151,7 +151,7 @@ export function getIntegralList(q) { /** * 获取分销海报图片 - * + * */ export function spreadBanner(data){ return request.get('user/spread/banner',data); @@ -167,7 +167,7 @@ export function spreadPeople(data){ } /** - * + * * 推广佣金/提现总和 * @param int type */ @@ -184,7 +184,7 @@ export function getSpreadInfo() { /** - * + * * 推广订单 * @param object data */ @@ -216,7 +216,7 @@ export function extractCash(data){ /** * 提现银行/提现最低金额 - * + * */ export function extractBank(){ return request.get('extract/bank'); @@ -224,7 +224,7 @@ export function extractBank(){ /** * 会员等级列表 - * + * */ export function userLevelGrade(){ return request.get('user/level/grade'); @@ -240,14 +240,14 @@ export function userLevelTask(id){ /** * 检查用户是否可以成为会员 - * + * */ export function userLevelDetection(){ return request.get('user/level/detection'); } /** - * + * * 地址列表 * @param object data */ @@ -274,7 +274,7 @@ export function editAddress(data){ /** * 删除地址 * @param int id - * + * */ export function delAddress(id){ return request.post('address/del',{id:id}) @@ -282,7 +282,7 @@ export function delAddress(id){ /** * 获取单个地址 - * @param int id + * @param int id */ export function getAddressDetail(id){ return request.get('address/detail/'+id); @@ -304,7 +304,7 @@ export function getLogout() { } /** * 小程序充值 - * + * */ export function rechargeRoutine(data){ return request.post('recharge/routine',data) @@ -339,7 +339,7 @@ export function alipayFull(data) { /** * 获取默认地址 - * + * */ export function getAddressDefault(){ return request.get('address/default'); @@ -382,7 +382,7 @@ export function spread(puid) return request.get("user/bindSpread?spreadPid="+ puid); } /** -// * 静默绑定推广人 +// * 静默绑定渠道 // * @param {Object} channelId // */ export function channel(channelId) @@ -392,7 +392,7 @@ export function channel(channelId) /** * 当前用户在佣金排行第几名 - * + * */ export function brokerageRankNumber(data) { @@ -401,7 +401,7 @@ export function brokerageRankNumber(data) /** * 会员等级经验值; - * + * */ export function getlevelInfo() { @@ -410,7 +410,7 @@ export function getlevelInfo() /** * 经验值明细; - * + * */ export function getlevelExpList(data) { @@ -419,7 +419,7 @@ export function getlevelExpList(data) /** * 经验值明细; - * + * */ export function getuserDalance() { @@ -447,7 +447,7 @@ export function computeUser(){ /** * 账单记录; - * + * */ export function getBillList(data) { @@ -480,4 +480,4 @@ export function spreadPeoCount() { */ export function copyrightApi(){ return request.get(`copyright/info`,{},{noAuth:true}); -} \ No newline at end of file +} diff --git a/config/app.js b/config/app.js index a7a2179..0fd5b48 100644 --- a/config/app.js +++ b/config/app.js @@ -1,8 +1,8 @@ //移动端商城API // let domain = 'http://117.50.163.143:20410' -// let domain = 'http://117.50.215.20:20410' -let domain = 'http://192.168.2.14:8081' -// let domain = 'http://106.75.49.247:20410' +let domain = 'http://117.50.215.20:20410' +// let domain = 'http://192.168.2.14:8081' +// let domain = 'http://106.75.49.247:20410' module.exports = { // 请求域名 格式: https://您的域名 @@ -11,14 +11,14 @@ module.exports = { HTTP_REQUEST_URL: domain, // H5商城地址 // HTTP_H5_URL: 'http://106.75.49.247:20410', - HTTP_H5_URL: 'http://192.168.2.14:8081', + HTTP_H5_URL: 'http://117.50.215.20:20410', // #endif // #ifdef H5 HTTP_REQUEST_URL:domain, // #endif HEADER:{ 'content-type': 'application/json', - + }, HEADERPARAMS:{ 'content-type': 'application/x-www-form-urlencoded' diff --git a/config/cache.js b/config/cache.js index 8489bea..bf653ac 100644 --- a/config/cache.js +++ b/config/cache.js @@ -27,10 +27,11 @@ module.exports = { TIPS_KEY: 'TIPS_KEY', SPREAD: 'SPREAD', + CHANNELID: 'CHANNELID', //缓存经度 CACHE_LONGITUDE: 'LONGITUDE', //缓存纬度 CACHE_LATITUDE: 'LATITUDE', //app手机信息 PLATFORM: 'systemPlatform' -} \ No newline at end of file +} diff --git a/libs/wechat.js b/libs/wechat.js index 5d737c1..60e9334 100644 --- a/libs/wechat.js +++ b/libs/wechat.js @@ -217,7 +217,7 @@ class AuthWechat { */ auth(code) { return new Promise((resolve, reject) => { - wechatAuth(code, Cache.get('spread')) + wechatAuth(code, Cache.get('spread'),Cache.get('channelId')) .then(({ data }) => { diff --git a/main.js b/main.js index 0e430f3..1bb0e0e 100644 --- a/main.js +++ b/main.js @@ -29,12 +29,13 @@ import { } from "./utils"; import Auth from './libs/wechat'; import { - SPREAD + SPREAD,CHANNELID } from './config/cache'; Vue.prototype.$wechat = Auth; let cookieName = "VCONSOLE", query = parseQuery(), urlSpread = query["spread"], + urlChannelId = query["channelId"], vconsole = query[cookieName.toLowerCase()], md5Crmeb = "b14d1e9baeced9bb7525ab19ee35f2d2", //CRMEB MD5 加密开启vconsole模式 md5UnCrmeb = "3dca2162c4e101b7656793a1af20295c"; //UN_CREMB MD5 加密关闭vconsole模式 @@ -44,13 +45,13 @@ let cookieName = "VCONSOLE", name: 'spread', value: urlSpread, }) - // var spread = Cache.get(SPREAD); - // urlSpread = parseInt(urlSpread); - // if (!Number.isNaN(urlSpread) && spread !== urlSpread) { - // Cache.set("spread", urlSpread || 0); - // } else if (spread === 0 || typeof spread !== "number") { - // Cache.set("spread", urlSpread || 0); - // } +} +if (urlChannelId) { + urlChannelId = parseInt(urlChannelId); + Cache.setItem({ + name: 'channelId', + value: urlChannelId, + }) } if (vconsole !== undefined) { if (vconsole === md5UnCrmeb && Cache.has(cookieName)) diff --git a/manifest.json b/manifest.json index 0cd85f5..c0ed792 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name" : "先享后付", - "appid" : "__UNI__C7D69AA", //wxb74514b47a2f29d4 wx46c3a73d8c4f7051 __UNI__EB8A7B + "appid" : "__UNI__E7B7107", //wxb74514b47a2f29d4 wx46c3a73d8c4f7051 __UNI__EB8A7B "description" : "crmeb商城", "versionName" : "2.1", "versionCode" : 2, @@ -219,8 +219,7 @@ "async" : { "timeout" : 200000 }, - "title" : "先享后付", - "template" : "template.html" + "title" : "先享后付" }, "plus" : { "statusbar" : { diff --git a/pages/goods_details/index.vue b/pages/goods_details/index.vue index 0ed7579..bd89793 100644 --- a/pages/goods_details/index.vue +++ b/pages/goods_details/index.vue @@ -252,7 +252,7 @@ @getImg="showImg" @installments="installments"> @@ -368,7 +368,7 @@ import shareRedPackets from '@/components/shareRedPackets'; import cusPreviewImg from '@/components/cus-previewImg/cus-previewImg.vue' import { - silenceBindingSpread + silenceBindingSpread,silenceBindingChannelId } from "@/utils"; import parser from "@/components/jyf-parser/jyf-parser"; import { @@ -550,6 +550,8 @@ this.getTokenIsExist(); }, onLoad(options) { + // console.log(JSON.stringify(options),"options.spread") + alert("options.spread"+JSON.stringify(options)) //用户从分享卡片进入的场景下获取主题色配置 this.$set(this, 'theme', this.$Cache.get('theme')); @@ -607,6 +609,7 @@ // #endif if (options.spread) app.globalData.spread = options.spread; + if (options.channelId) app.globalData.channelId = options.channelId; this.getGoodsDetails(); //商品详情 this.getCouponType(); //获取默认的 优惠券类型 @@ -657,11 +660,11 @@ uni.$emit('scroll'); }, methods: { - // - - - - + // + + + + // 请求分期列表 // getfqList: function() { // let data = { @@ -671,7 +674,7 @@ // } // getfenqilist(data).then(res => { // this.fenqlist = res.data.list - + // // localStorage.setItem('fqlist',JSON.stringify(this.fenqlist)) // }) // }, @@ -683,6 +686,7 @@ this.getCartCount(true); //购物车数量 //绑定关系 if (parseInt(app.globalData.spread) > 0) silenceBindingSpread(); + if (parseInt(app.globalData.channelId) > 0) silenceBindingChannelId(); } }); }, @@ -747,7 +751,7 @@ }, /** * 购物车手动填写 - * + * */ iptCartNum: function(e) { this.$set(this.attr.productSelect, 'cart_num', e ? e : 1); @@ -789,7 +793,7 @@ that.$set(that.sharePacket, 'touchstart', true); //滑动屏幕时让分享气泡缩回 }, /* - *去商品详情页 + *去商品详情页 */ goDetail(item) { if (!item.activityH5) { @@ -832,7 +836,7 @@ }, /** * 购物车数量加和数量减 - * + * */ ChangeCartNum: function(changeValue) { //changeValue:是否 加|减 @@ -864,7 +868,7 @@ }, /** * 属性变动赋值 - * + * */ ChangeAttr: function(res) { let productSelect = this.productValue[res]; @@ -913,7 +917,7 @@ }, /** * 优品推荐 - * + * */ getGoods() { getProductGood().then(res => { @@ -948,7 +952,7 @@ }, /** * 获取产品详情 - * + * */ getGoodsDetails: function() { let that = this; @@ -1068,7 +1072,7 @@ }, /** * 默认选中属性 - * + * */ DefaultSelect: function() { let productAttr = this.attr.productAttr; @@ -1121,7 +1125,7 @@ }, /** * 获取优惠券 - * + * */ getCouponList(type) { let that = this; @@ -1176,9 +1180,9 @@ that.$set(that.coupon, 'list', that.coupon.list); that.$set(that.coupon, 'coupon', false); }, - /** - * - * + /** + * + * * 收藏商品 */ setCollect: function() { @@ -1225,7 +1229,7 @@ }, /** * 打开属性加入购物车 - * + * */ joinCart: function(e) { //是否登录 @@ -1312,7 +1316,7 @@ /** * 立即购买 */ - goBuy: Debounce(function(e) { + goBuy: Debounce(function(e) { if (this.isLogin === false) { toLogin(); } else { @@ -1337,7 +1341,7 @@ }, /** * 分享打开 - * + * */ listenerActionSheet: function() { if (this.isLogin === false) { @@ -2529,7 +2533,7 @@ border-radius: 8rpx; text-align: center; } - - - - \ No newline at end of file + + + + diff --git a/pages/index/index.vue b/pages/index/index.vue index 26f9e4e..a3f51e9 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -179,7 +179,7 @@ getTemlIds } from '@/api/api.js'; // #endif - // #ifdef H5 + // #ifdef H5 import { follow } from '@/api/public.js'; @@ -210,7 +210,7 @@ getGroomList } from '@/api/store.js'; import { - silenceBindingSpread, + silenceBindingSpread,silenceBindingChannelId, getCityList } from '@/utils'; import animationType from '@/utils/animationType.js' @@ -418,8 +418,10 @@ let qrCodeValue = this.$util.getUrlParams(decodeURIComponent(options.scene)); let mapeMpQrCodeValue = this.$util.formatMpQrCodeData(qrCodeValue); app.globalData.spread = mapeMpQrCodeValue.spread; + app.globalData.channelId = mapeMpQrCodeValue.channelId; } if (options.spread) app.globalData.spread = options.spread; //非小程序扫码进入情况下,直接获取url中的分销员id保存在globalDta中 + if (options.channelId) app.globalData.channelId = options.channelId; //非小程序扫码进入情况下,直接获取url中的分销员id保存在globalDta中 // #endif // #ifndef MP || APP-PLUS this.navH = 0; @@ -431,6 +433,12 @@ if (this.isLogin && parseInt(app.globalData.spread) > 0) { silenceBindingSpread() } + if (this.isLogin && parseInt(app.globalData.channelId) > 0) { + silenceBindingChannelId() + } + if (this.isLogin && parseInt(options.channelId) > 0) { + silenceBindingChannelId() + } }, onShow() { let self = this; @@ -621,7 +629,7 @@ appVersionConfig() { var that = this; //app升级 - // 获取本地应用资源版本号 + // 获取本地应用资源版本号 getAppVersion().then(res => { that.$set(that.appUpdate, 'androidAddress', res.data.androidAddress); that.$set(that.appUpdate, 'appVersion', res.data.appVersion); @@ -1286,4 +1294,4 @@ height: 344rpx; @include index-gradient(theme); } - \ No newline at end of file + diff --git a/pages/users/wechat_login/index.vue b/pages/users/wechat_login/index.vue index 2b19b98..28a5bd6 100644 --- a/pages/users/wechat_login/index.vue +++ b/pages/users/wechat_login/index.vue @@ -31,7 +31,7 @@ class='iconfont icon-weixin2'>一键绑定手机号 - + @@ -75,7 +75,7 @@ data() { return { isUp: false, // 绑定手机号手动输入弹窗 - phone: '', + phone: '', statusBarHeight: statusBarHeight, isHome: false, isPhoneBox: false, //授权手机号弹窗 @@ -146,8 +146,9 @@ //if(!code) location.replace(decodeURIComponent(decodeURIComponent(option.query.back_url))); if (code && this.options.scope !== 'snsapi_base') { let spread = app.globalData.spread ? app.globalData.spread : 0; + let channelId = app.globalData.channelId ? app.globalData.channelId : 0; //公众号授权登录回调 wechatAuth(code, Cache.get("spread"), loginType) - wechat.auth(code, spread).then(res => { + wechat.auth(code, spread,channelId).then(res => { if (res.type === 'register') { this.authKey = res.key; this.isUp = true @@ -252,6 +253,7 @@ let userInfo = {}; userInfo.code = code; userInfo.spread_spid = app.globalData.spread; //获取推广人ID + userInfo.channelId = app.globalData.channelId; //渠道ID userInfo.avatar = ''; userInfo.nickName = '微信用户'; userInfo.type = 'routine' @@ -267,6 +269,7 @@ let userInfo = res.userInfo; userInfo.code = code; userInfo.spread_spid = app.globalData.spread; //获取推广人ID + userInfo.channelId = app.globalData.channelId; //渠道ID userInfo.avatar = userInfo.userInfo.avatarUrl; userInfo.city = userInfo.userInfo.city; userInfo.country = userInfo.userInfo.country; @@ -306,6 +309,9 @@ if (app.globalData.spread) { spread(app.globalData.spread).then(res => {}) //登录成功后读取spread绑定分销关系 } + if (app.globalData.channelId) { + channelId(app.globalData.channelId).then(res => {}) //登录成功后读取渠道绑定关系 + } self.$util.Tips({ title: res, icon: 'success' @@ -458,4 +464,4 @@ height: 50rpx; } } - \ No newline at end of file + diff --git a/utils/index.js b/utils/index.js index 18af2cc..af345df 100644 --- a/utils/index.js +++ b/utils/index.js @@ -1,6 +1,6 @@ -import { spread } from "@/api/user"; +import { spread,channel } from "@/api/user"; import Cache from "@/utils/cache"; import { getCity } from '@/api/api.js'; @@ -11,7 +11,7 @@ import { getCity } from '@/api/api.js'; export function silenceBindingSpread() { //#ifdef H5 let puid = Cache.get('spread'); - //#endif + //#endif //#ifdef MP || APP-PLUS let puid = getApp().globalData.spread; //#endif @@ -25,7 +25,7 @@ export function silenceBindingSpread() { //#ifdef H5 Cache.clear("spread"); //#endif - + //#ifdef MP || APP-PLUS getApp().globalData.spread = 0; //#endif @@ -35,6 +35,37 @@ export function silenceBindingSpread() { } } +/** + * 静默授权绑定渠道,使用在已经登录后扫描了别人的推广二维码 + * @param {Object} puid + */ +export function silenceBindingChannelId() { + //#ifdef H5 + let puid = Cache.get('channelId'); + //#endif + //#ifdef MP || APP-PLUS + let puid = getApp().globalData.channelId; + //#endif + + puid = parseInt(puid); + if (Number.isNaN(puid)) { + puid = 0; + } + if (puid) { + channel(puid).then(res => {}).catch(res => { + //#ifdef H5 + Cache.clear("channelId"); + //#endif + + //#ifdef MP || APP-PLUS + getApp().globalData.channelId = 0; + //#endif + }); + } else { + Cache.set('channelId', 0); + } +} + export function isWeixin() { return navigator.userAgent.toLowerCase().indexOf("micromessenger") !== -1; }