Commit b0b9946d by 程默

Merge branch 'nativehome_tst' of http://code.mayi888.com/chengmo/mayi-mp-shop into nativehome_tst

parents 5a195028 0d88fe85
......@@ -9,9 +9,11 @@ import indexApi from './api/index'
import cartApi from './api/cart'
import classificationApi from "./api/classification";
import spokesmanApi from './api/spokesman'
import { DFSImg } from "@/utils/index";
import { DFSImg, concatUrl } from "@/utils/index";
import fenxiaoModel from "@/utils/fenxiaoModel";
import { $themeToLink, $themeAddToCard, $themeArticleLike } from "@/utils/mayi";
import shop from "./api/shop";
import spokesman from "@/api/spokesman";
Vue.config.productionTip = false
App.mpType = 'app'
......@@ -30,10 +32,22 @@ Vue.prototype.$mpAnalytics = mpAnalytics;
const app = new Vue(App)
app.$mount()
// glob挂载到
let mpApp = getApp();
Vue.prototype.mpApp = mpApp
mpApp.fenxiaoModel = new fenxiaoModel({
query_login_spoken:spokesman.query_login_spoken,
becomepokesmanCustomer:spokesman.becomepokesmanCustomer,
saveCustomerInviterInviteeRel:spokesman.saveCustomerInviterInviteeRel,
getHomePageQuickAccess:spokesman.getHomePageQuickAccess,
query_isEntry:spokesman.query_isEntry,
getDistributorHomepage:spokesman.getDistributorHomepage,
getDistributorHomepageGoodsList: spokesman.getDistributorHomepageGoodsList,
getSpokesmanidByShare: spokesman.getSpokesmanidByShare,
oneClickShopQuickCopy: spokesman.oneClickShopQuickCopy,
apply_for_withdraw: spokesman.apply_for_withdraw
});
// 数据异步回调函数
// 商城
mpApp.shopCallBack = function () { }
......@@ -66,6 +80,7 @@ mpApp.indexApi = indexApi;
mpApp.cartApi = cartApi;
mpApp.classificationApi = classificationApi;
mpApp.DFSImg = DFSImg;
mpApp.concatUrl = concatUrl;
mpApp.spokesmanApi = spokesmanApi
mpApp.getThemePage = getThemePage
......
......@@ -125,8 +125,7 @@ import coupon from '@/components/activity/coupon'
import integralTurntable from '@/components/activity/integralTurntable'
import spellGroup from '@/components/activity/spellGroup'
import { setTabBarActive, checkTabbarPage,themeColor } from "../../utils/mayi.js";
import { getMiniProgram, becomeRelation, getHomePageQuickAccess, query_isEntry, getDistributorHomepage } from "@/utils/mayi_fenxiao";
import { throttle } from "../../utils/index.js"
import { throttle, concatUrl } from "../../utils/index.js"
const app = getApp();
export default {
......@@ -231,24 +230,11 @@ export default {
let that = this;
if(wx.getStorageSync("sessionid")) {
//获取个人名片入口
getHomePageQuickAccess().then(res=>{
app.fenxiaoModel.getHomePageQuickAccess().then(res=>{
that.showMyCard = res;
})
//获取分销信息
this.getSpokesmanInit(options)
}else {
app.globalData.spokesmanInfo = {};
let footerVal = {...app.globalData.footerVal};
console.log('"分销员中心"',footerVal)
if (footerVal.componentData) {
footerVal.componentData.list.forEach(res=>{
if(res.link.name=="分销员中心"||res.link.name=="分销商中心") {
res.show = false
}
})
app.globalData.footerVal = footerVal;
this.$mp.page.selectComponent(".custom-tab-bar").init();
}
}
// 来源
if (options.from == "logout") {
......@@ -317,10 +303,10 @@ export default {
wx.stopPullDownRefresh()
if(wx.getStorageSync("sessionid")) {
query_isEntry().then((data)=>{
console.log(111222,app.fenxiaoModel)
app.fenxiaoModel.query_isEntry().then((data)=>{
//分销弹框信息
app.globalData.applySucessEntry = data;
console.log(app.globalData.applySucessEntry,3333444)
console.log(data,3333444)
if (
data.applyRemind == "true" &&
data.displayEntry == "true"
......@@ -350,20 +336,30 @@ export default {
// that.applySucessEntry = res;
})
}else {
app.globalData.applySucessEntry = {}
let footerVal = {...app.globalData.footerVal};
console.log('"分销员中心"',footerVal)
if (footerVal.componentData) {
footerVal.componentData.list.forEach(res=>{
if(res.link.name=="分销员中心"||res.link.name=="分销商中心") {
res.show = false
}
})
app.globalData.footerVal = footerVal;
this.$mp.page.selectComponent(".custom-tab-bar").init();
}
}
},
async getSpokesmanInit(extConfig) {
getSpokesmanInit(extConfig) {
//绑定上下级关系
await becomeRelation(extConfig)
app.fenxiaoModel.becomeRelation(extConfig).then(res=>{
//获取分销基本信息
console.log(res,333333344444444)
this.getSpokesmanInfo(extConfig)
})
},
getSpokesmanInfo(extConfig) {
let linkVal = '/personalCenter/spokesmanCenter/mine/spokesmanHomePage?from=_goodsInfo';
getMiniProgram().then(res=>{
app.globalData.spokesmanInfo = res;
app.fenxiaoModel.getSpokesmanInfo(true).then(res=>{
if(
res&&
res!='-1'&&
......@@ -378,7 +374,7 @@ export default {
link:linkVal,
});
}
getDistributorHomepage(app.globalData.spokesmanInfo).then(ele=>{
app.fenxiaoModel.getDistributorHomepage(res).then(ele=>{
if(ele.id) {
this.getDistributorHomepageName = '我的小店';
}else {
......@@ -386,15 +382,15 @@ export default {
}
});
if(
app.globalData.spokesmanInfo&&
app.globalData.spokesmanInfo.parentSpokesmanDistributionModel == '1'&&
app.globalData.spokesmanInfo.distributorHomepage.id) {
res&&
res.parentSpokesmanDistributionModel == '1'&&
res.distributorHomepage.id) {
this.showSpokesManHome = true;
}else {
this.showSpokesManHome = false;
}
console.log(app.globalData.spokesmanInfo,555666)
if(app.globalData.spokesmanInfo&&app.globalData.spokesmanInfo.distributionModel == '1') {
console.log(res,555666)
if(res&&res.distributionModel == '1') {
this.showHomepage = true;
}else{
this.showHomepage = false;
......@@ -458,6 +454,39 @@ export default {
});
}
},
onShareAppMessage(res){
app.fenxiaoModel.getSpokesmanidByShare().then(res=>{
let newHref = '/pages/home/main';
if (res.hasInvitationStatus == 1) {
newHref = concatUrl(newHref,res)
}
let title = app.globalData.shopInfo.shopName;
console.log(newHref,3333555666,title)
return {
title: title, // 默认是小程序的名称
path: newHref, // 默认是当前页面
// imageUrl: this.shareLogoUrl,
success: function(res) {
// 转发成功之后的回调
if (res.errMsg == "shareAppMessage:ok") {
console.log(res, "分享成功");
}
},
fail: function() {
// 转发失败之后的回调
if (res.errMsg == "shareAppMessage:fail cancel") {
// 用户取消转发
console.log(res, "分享失败");
} else if (res.errMsg == "shareAppMessage:fail") {
// 转发失败,其中 detail message 为详细失败信息
}
},
complete: function() {
// 转发结束之后的回调(转发成不成功都会执行)
}
};
})
},
onPullDownRefresh(){
console.log('onPullDownRefresh',this.$store.state.extConfig)
app.getShopInfo(this.$store.state.extConfig);
......
class fenxiaoModel{
fenxiaoApi = {
query_login_spoken: null,//查询分销信息
becomepokesmanCustomer: null,//绑定商上级分销关系
saveCustomerInviterInviteeRel: null,//绑定商上级客户关系
getHomePageQuickAccess: null,//查询个人名片入口
query_isEntry: null,//查询成为分销弹框
getDistributorHomepage: null,//查询是否有自己的小店
getDistributorHomepageGoodsList: null,//首页分销商货架信息
getSpokesmanidByShare: null,//获取分销分享信息
oneClickShopQuickCopy: null,//一键开店快速复制
apply_for_withdraw: null,//关闭分销弹框
}
spokesmanInfo = null;//分销信息
applySucessEntry = {};//分销弹框信息
spokesmanidByShareInfo = null;//获取分享信息
distributorHomepageInfo = null;//小店详情
constructor({
query_login_spoken,
becomepokesmanCustomer,
saveCustomerInviterInviteeRel,
getHomePageQuickAccess,
query_isEntry,
getDistributorHomepage,
getDistributorHomepageGoodsList,
getSpokesmanidByShare,
oneClickShopQuickCopy,
apply_for_withdraw,
}){
this.fenxiaoApi.query_login_spoken = query_login_spoken;
this.fenxiaoApi.becomepokesmanCustomer = becomepokesmanCustomer;
this.fenxiaoApi.saveCustomerInviterInviteeRel = saveCustomerInviterInviteeRel;
this.fenxiaoApi.getHomePageQuickAccess = getHomePageQuickAccess;
this.fenxiaoApi.query_isEntry = query_isEntry;
this.fenxiaoApi.getDistributorHomepage = getDistributorHomepage;
this.fenxiaoApi.getDistributorHomepageGoodsList = getDistributorHomepageGoodsList;
this.fenxiaoApi.getSpokesmanidByShare = getSpokesmanidByShare;
this.fenxiaoApi.oneClickShopQuickCopy = oneClickShopQuickCopy;
this.fenxiaoApi.apply_for_withdraw = apply_for_withdraw;
}
//获取分销信息
getSpokesmanInfo(replace = false){
let _this = this
return new Promise(function (resolve, reject) {
if(_this.spokesmanInfo&&!replace) {
resolve(_this.spokesmanInfo)
}else {
_this.setSpokesmanInfo().then(res=>{
resolve(res)
}).catch(res=>{
reject(res)
})
}
});
}
//设置分销信息
setSpokesmanInfo() {
let _this = this
return new Promise(function (resolve, reject) {
_this.fenxiaoApi.query_login_spoken().then(res=>{
if(res.data.code == '200') {
_this.spokesmanInfo = res.data.data;
resolve(res.data.data)
}else {
reject(res)
}
});
});
}
//绑定分销关系
becomeRelation(extConfig) {
let _this = this
return new Promise(function (resolve, reject) {
if(extConfig&&extConfig.spokesmanRelId) {
_this.fenxiaoApi.becomepokesmanCustomer(extConfig.spokesmanRelId).then(res=>{
if(res.data.code == '200') {
resolve(res)
}else {
reject(res)
}
})
}else if(extConfig&&extConfig.userId) {
_this.fenxiaoApi.saveCustomerInviterInviteeRel(extConfig.userId).then(res=>{
if(res.data.code == '200') {
resolve(res)
}else {
reject(res)
}
})
}else {
resolve()
}
})
}
//查询个人名片入口
getHomePageQuickAccess() {
let _this = this
return new Promise(function (resolve, reject) {
_this.fenxiaoApi.getHomePageQuickAccess().then(res=>{
if(res.data.code == '200' && res.data.data == 'true') {
resolve(true)
}else {
reject(false)
}
})
})
}
//查询是否有自己的小店
getDistributorHomepage(spokesmanInfo,replace=false) {
let _this = this
return new Promise(function (resolve, reject) {
if(_this.distributorHomepageInfo&&!replace) {
resolve(_this.distributorHomepageInfo)
}else {
_this.fenxiaoApi.getDistributorHomepage(spokesmanInfo.id).then(res=>{
if (
res.data.code == "200" &&
res.data.data &&
res.data.data != "null" &&
res.data.data != "false"
) {
_this.distributorHomepageInfo = res.data.data
resolve(res.data.data)
}
})
}
})
}
//查询成为分销弹框
query_isEntry() {
let _this = this
return new Promise(function (resolve, reject) {
_this.fenxiaoApi.query_isEntry().then(res=>{
if (
res.data.code == "200" &&
res.data.data &&
res.data.data != "null" &&
res.data.data != "false"
) {
_this.applySucessEntry = res.data.data;
resolve(res.data.data)
}else{
reject(res)
}
})
})
}
//查询分销商货架
getDistributorHomepageGoodsList(data) {
let _this = this
return new Promise(function (resolve, reject) {
_this.fenxiaoApi.getDistributorHomepageGoodsList(data).then(res=>{
if(res.data.code == '200') {
resolve(res.data.data)
}else {
reject(res)
}
})
})
}
//获取分享信息
getSpokesmanidByShare(replace=false) {//replace是否更新数据
let _this = this
return new Promise(function (resolve, reject) {
if(_this.spokesmanidByShareInfo&&!replace) {
resolve(_this.spokesmanidByShareInfo)
}else {
_this.fenxiaoApi.getSpokesmanidByShare().then(res=>{
if(res.data.code == '200') {
_this.spokesmanidByShareInfo = res.data.data;
resolve(res.data.data)
}else {
reject(res)
}
})
}
})
}
//一键复制店铺
oneClickShopQuickCopy(data) {
let _this = this
return new Promise(function (resolve, reject) {
_this.fenxiaoApi.oneClickShopQuickCopy(data).then(res=>{
if(res.data.code == '200') {
resolve(res.data.data)
}else {
reject(res)
}
})
})
}
//关闭分销成功弹框
apply_for_withdraw(data) {
let _this = this
return new Promise(function (resolve, reject) {
_this.fenxiaoApi.apply_for_withdraw(data).then(res=>{
if(res.data.code == '200') {
resolve(res.data.data)
}else {
reject(res)
}
})
})
}
}
export default fenxiaoModel
\ No newline at end of file
......@@ -143,3 +143,28 @@ export function setTimes(value) {
result = `${h}:${m}:${s}`
return result
}
//url拼接参数
export function concatUrl(url,data) {
let setUrl = url;
if(data) {
let cludeData = true;
if(setUrl.indexOf("?") == -1) {
setUrl += "?";
cludeData = false;
}
let index = 0;
for(let key in data) {
if(!cludeData&&index===0) {
setUrl += key+"="+data[key];
}else if(!cludeData&&index!==0) {
setUrl += "&"+key+"="+data[key];
}else if(cludeData&&setUrl.indexOf(key+"=") == -1) {
setUrl += "&"+key+"="+data[key];
}
index += 1
}
return setUrl
}else {
return setUrl
}
}
\ No newline at end of file
......@@ -13,9 +13,7 @@ export function getMiniProgram(query) {
}
//绑定商上下级关系
export function becomeRelation(extConfig) {
spokesman.becomepokesmanCustomer(79988).then(res=>{
})
console.log(extConfig,44445555)
if(extConfig&&extConfig.spokesmanRelId) {
spokesman.becomepokesmanCustomer(extConfig.spokesmanRelId).then(res=>{
......
......@@ -19,8 +19,8 @@ const componentOptions = {
lifetimes: {
created() {},
ready() {
this.setData({ nickname: app.globalData.applySucessEntry.nicknameByDistributor || app.globalData.applySucessEntry.nickname });
console.log(app.globalData.applySucessEntry,222221111111)
this.setData({ nickname: app.fenxiaoModel.applySucessEntry.nicknameByDistributor || app.fenxiaoModel.applySucessEntry.nickname });
console.log(app.fenxiaoModel.applySucessEntry,222221111111)
},
moved() {},
detached() {}
......@@ -49,19 +49,15 @@ const componentOptions = {
methods: {
closePopuop() {
this.setData({ showPop: false });
spokesmanApi.apply_for_withdraw({type:'applyRemindFlag'}).then(res => {
if (res.code == "200") {
console.log(res,9999)
}
app.fenxiaoModel.apply_for_withdraw({type:'applyRemindFlag'}).then(res => {
});
},
toSpokesmanCenter() {
let linkVal = '/personalCenter/spokesmanCenter'
this.setData({ showPop: false });
spokesmanApi.apply_for_withdraw({type:'applyRemindFlag'}).then(res => {
if (res.code == "200") {
console.log(res,9999)
}
app.fenxiaoModel.apply_for_withdraw({type:'applyRemindFlag'}).then(res => {
});
$themeToLink({
type: 1,
......
......@@ -23,7 +23,8 @@ Component({
changeShow: false,
positionName: '定位中',
wxReady: false,
designateAreaObj : null
designateAreaObj : null,
showSpokesManHome: false,
},
ready(){
console.log('++++++++++++++++++++定位组件加载好了++++++++++++++++++++')
......@@ -36,7 +37,20 @@ Component({
this.setData({
designateAreaObj: this.data.datas.componentData.designateAreaObj
})
//分销商货架存在
if(
app.fenxiaoModel.spokesmanInfo&&
app.fenxiaoModel.spokesmanInfo.parentSpokesmanDistributionModel == '1'&&
app.fenxiaoModel.spokesmanInfo.distributorHomepage.id
) {
this.setData({
showSpokesManHome: true
})
}else {
this.setData({
showSpokesManHome: false
})
}
console.log(this.data.datas.componentData.designateAreaObj,'2222')
if (!wx.getStorageSync('location')) {
......
<!--static/nativeComponents/AreaNavigation/index.wxml-->
<van-sticky offset-top="44px" wx:if="{{datas.componentData.scrollPosition}}">
<van-sticky offset-top="{{showSpokesManHome?44:0}}" wx:if="{{datas.componentData.scrollPosition}}">
<view class="area-navigation clearfix" style="background-color:{{datas.componentData.backgroundColor}}">
<view style="width:100%;display:flex;">
<view class="area-l" style="font-size:{{datas.componentData.fontSize / 16 + 'em'}};color:{{datas.componentData.fontColor}};font-weight:{{datas.componentData.fontWeight}}" bindtap="changeOtherCity">
......
......@@ -8,6 +8,9 @@
font-size: 32rpx;
top: 0;
}
.area-navigation-margintop {
padding-top: 100rpx;
}
.area-l{
line-height: 60rpx;
}
......
......@@ -89,22 +89,23 @@ const componentOptions = {
// 组件方法
methods: {
init() {
this.setData({ spokesmanInfo: app.globalData.spokesmanInfo });
this.spokesmanInfo = app.globalData.spokesmanInfo;
let parentSpokesmanHandImage = DFSImg(app.globalData.spokesmanInfo.parentSpokesmanHandImage);
this.setData({ spokesmanInfo: app.fenxiaoModel.spokesmanInfo });
this.spokesmanInfo = app.fenxiaoModel.spokesmanInfo;
let parentSpokesmanHandImage = DFSImg(app.fenxiaoModel.spokesmanInfo.parentSpokesmanHandImage);
this.setData({parentSpokesmanHandImage: parentSpokesmanHandImage});
let query = {
...this.data.query,
distributorHomepageId: this.spokesmanInfo.distributorHomepage.id,
}
spokesmanApi.getDistributorHomepageGoodsList(query).then(res=>{
if(res.data.code == '200'&&res.data.data) {
console.log(query,555555777777)
app.fenxiaoModel.getDistributorHomepageGoodsList(query).then(res=>{
if(res) {
let lists = [];
let num = Math.ceil(res.data.data.length/3);
let num = Math.ceil(res.length/3);
for(let i = 0; i < num; i++) {
lists.push(new Array());
}
res.data.data.forEach((ele,index)=>{
res.forEach((ele,index)=>{
ele.terminalProductGoods.imgUrl = DFSImg(ele.terminalProductGoods.imgUrl)
ele.terminalProductGoods.discountPrice = (ele.terminalProductGoods.discountPrice-0).toFixed(2)
ele.terminalProductGoods.salePrice = (ele.terminalProductGoods.salePrice-0).toFixed(2)
......
......@@ -148,7 +148,7 @@
width: 100%;
left: 0;
top: 0px;
z-index: 9999;
z-index: 99;
background-image: url('https://mayi-newshop.oss-cn-shanghai.aliyuncs.com/product/SNzssemrfc.png');
background-size: 100% 100%;
}
\ No newline at end of file
......@@ -26,7 +26,7 @@ const componentOptions = {
lifetimes: {
created() {},
ready() {
this.setData({ spokesmanInfo: app.globalData.spokesmanInfo });
this.setData({ spokesmanInfo: app.fenxiaoModel.spokesmanInfo });
},
moved() {},
detached() {}
......@@ -59,22 +59,23 @@ const componentOptions = {
},
setNewShop() {
// window.sessionStorage.setItem(getTokenTwo()+'currentState',0)
spokesmanApi.getDistributorHomepage(this.data.spokesmanInfo.id).then(res=>{
app.fenxiaoModel.getDistributorHomepage().then(res=>{
console.log(res,888888888)
if(!this.data.spokesmanInfo.parentId) {
this.initShopDetail()
return
}
if(res.data.code=='200'&&!(res.data.data&&res.data.data.id)) {
if(!(res&&res.id)) {
this.setData({ showPop: true });
}else if(res.data.code=='200'&&res.data.data&&res.data.data.id){
}else if(res&&res.id){
this.initShopDetail()
}
})
},
copyShop() {
console.log(this.data.distributionPrice1,888888888)
spokesmanApi.oneClickShopQuickCopy({grossProfitMargin: parseFloat(this.data.distributionPrice1)}).then(res=>{
if(res.data.data == 'true') {
app.fenxiaoModel.oneClickShopQuickCopy({grossProfitMargin: parseFloat(this.data.distributionPrice1)}).then(res=>{
if(res == 'true') {
this.initShopDetail()
}
})
......
const app = getApp();
const { $themeToLink, processEnv, globalData } = app;
const { $themeToLink, processEnv, globalData, concatUrl } = app;
const componentOptions = {
// 组件选项
options: {
......@@ -68,9 +68,13 @@ const componentOptions = {
this.onClose();
},
copyText(e) {
let { text } = e.currentTarget.dataset;
let pagePath = getCurrentPages()[0].route;
let copyVal = pagePath + text;
let pagePath = `${processEnv.BASE_URL}?mixid=${globalData.shopInfo.shopCode}`;
let copyVal = pagePath;
app.fenxiaoModel.getSpokesmanidByShare().then(res=>{
if (res.hasInvitationStatus == 1) {
copyVal = concatUrl(copyVal,res)
}
console.log(copyVal,11111222)
wx.setClipboardData({
data: copyVal,
success: function(res) {
......@@ -81,16 +85,22 @@ const componentOptions = {
});
}
});
})
},
toPosters() {
let userInfo = wx.getStorageSync("userInfo") ? JSON.parse(wx.getStorageSync("userInfo")):'';
let queryHref = `${processEnv.BASE_URL}?mixid=${globalData.shopInfo.shopCode}`;
app.fenxiaoModel.getSpokesmanidByShare().then(res=>{
if (res.hasInvitationStatus == 1) {
queryHref = concatUrl(queryHref,res)
}
let linkVal = `/goods/posters?type=index&href=${queryHref}`;
if (userInfo) {
linkVal += `&nickname=${userInfo.nickName}`;
}
console.log(linkVal, "------------------linkVal");
$themeToLink({ type: 1, link: linkVal });
})
},
},
// 组件生命周期
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment