Commit 6413a54e by 程智春

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

parents 4f93e67d d8546463
...@@ -14,7 +14,7 @@ export default { ...@@ -14,7 +14,7 @@ export default {
process.env.NODE_ENV == "production" || process.env.NODE_ENV == "production" ||
JSON.stringify(extConfig) == "{}" JSON.stringify(extConfig) == "{}"
) { ) {
extConfig = { mixid: "antgood", shopid: 67 }; // extConfig = { mixid: "antgood", shopid: 67 };
// extConfig = { "mixid":"xyyx", // extConfig = { "mixid":"xyyx",
// "shopid":133 }; // "shopid":133 };
} }
......
import indexApi from "@/api/index";
export function getBcakUrlApi(data) {
return new Promise((resolve, reject) => {
data.fromAppid = 'VsEOuDJqBnGNyXZJWCQS'
indexApi.getSsoCallbackUrl(data).then(res => {
if (res.data.code == 200) {
resolve(res.data.data);
}
});
})
}
export function createdUserJWTApi(data) {
return new Promise((resolve, reject) => {
indexApi.createdUserJWT().then(res => {
if (res.data.code == 200) {
resolve(res.data.data);
}
});
})
}
...@@ -33,6 +33,22 @@ console.log(process.env,'-----------------config------') ...@@ -33,6 +33,22 @@ console.log(process.env,'-----------------config------')
}, },
get_multi_merchant_by_tags(data){ get_multi_merchant_by_tags(data){
return requestPOST(`${process.env.OLSHOP_URL}/shop/get_multi_merchant_by_tags`,data) return requestPOST(`${process.env.OLSHOP_URL}/shop/get_multi_merchant_by_tags`,data)
},
getSsoCallbackUrl(data) {
return requestPOST(
`${process.env.OLSHOP_URL}/common/getSsoCallbackUrl`,
{ data }
);
},
// 动态表单获取token 信息
createdUserJWT(data) {
return requestPOST(
`${process.env.OLSHOP_URL}/user/createUserJWT`,
{
data
}
);
} }
} }
\ No newline at end of file
...@@ -12,9 +12,30 @@ export default { ...@@ -12,9 +12,30 @@ export default {
}, },
// 页面数据 // 页面数据
themePagesInfo(params) { themePagesInfo(params) {
return requestPOST(`${process.env.OLSHOP_URL}/cms/get_shop_install_pages`, params ) return requestPOST(
`${process.env.OLSHOP_URL}/cms/get_shop_install_pages`,
params
);
}, },
checkShowCondition(params) { checkShowCondition(params) {
return requestPOST(`${process.env.OLSHOP_URL}/cms/check_show_condition`, params) return requestPOST(
`${process.env.OLSHOP_URL}/cms/check_show_condition`,
params
);
}, },
// 获取新版会员卡列表
getV3CardList(params) {
return requestPOST(
`${process.env.OLSHOP_URL}/user/membership_card_list`,
{
params
}
);
},
// 领取新版无门槛会员卡
drawV3Card(params) {
return requestPOST(
`${process.env.OLSHOP_URL}/user/draw_membership_card?cardId=${params}`
);
}
}; };
...@@ -6,12 +6,21 @@ import goodsApi from "./api/goods" ...@@ -6,12 +6,21 @@ import goodsApi from "./api/goods"
import orderApi from "./api/order" import orderApi from "./api/order"
import promoteApi from "./api/promote"; import promoteApi from "./api/promote";
import indexApi from './api/index' import indexApi from './api/index'
import { createdUserJWTApi, getBcakUrlApi } from "./api/daoke";
import cartApi from './api/cart' import cartApi from './api/cart'
import classificationApi from "./api/classification"; import classificationApi from "./api/classification";
import spokesmanApi from './api/spokesman' import spokesmanApi from './api/spokesman'
import { DFSImg, concatUrl } from "@/utils/index"; import { DFSImg, concatUrl } from "@/utils/index";
import fenxiaoModel from "@/utils/fenxiaoModel"; import fenxiaoModel from "@/utils/fenxiaoModel";
// import {
// $themeAddToCard,
// $themeArticleLike,
// getCoupon,
// themeMemberCardClick
// } from "@/utils/mayi";
import { $themeToLink, $themeAddToCard, $themeArticleLike } from "@/utils/mayi"; import { $themeToLink, $themeAddToCard, $themeArticleLike } from "@/utils/mayi";
import "@/utils/themeModule";
// import { themeToLinkInit } from "@/utils/themeModule";
import shop from "./api/shop"; import shop from "./api/shop";
import spokesman from "@/api/spokesman"; import spokesman from "@/api/spokesman";
...@@ -35,6 +44,7 @@ app.$mount() ...@@ -35,6 +44,7 @@ app.$mount()
// glob挂载到 // glob挂载到
let mpApp = getApp(); let mpApp = getApp();
Vue.prototype.mpApp = mpApp Vue.prototype.mpApp = mpApp
// 初始化
mpApp.fenxiaoModel = new fenxiaoModel({ mpApp.fenxiaoModel = new fenxiaoModel({
query_login_spoken:spokesman.query_login_spoken, query_login_spoken:spokesman.query_login_spoken,
becomepokesmanCustomer:spokesman.becomepokesmanCustomer, becomepokesmanCustomer:spokesman.becomepokesmanCustomer,
...@@ -47,7 +57,17 @@ mpApp.fenxiaoModel = new fenxiaoModel({ ...@@ -47,7 +57,17 @@ mpApp.fenxiaoModel = new fenxiaoModel({
oneClickShopQuickCopy: spokesman.oneClickShopQuickCopy, oneClickShopQuickCopy: spokesman.oneClickShopQuickCopy,
apply_for_withdraw: spokesman.apply_for_withdraw apply_for_withdraw: spokesman.apply_for_withdraw
}); });
// 多主题方法初始化
global.themeToLinkInit({
homeNative: 2,
wx,
getCoupon,
themeMemberCardClick,
requireFun: {
createdUserJWT: createdUserJWTApi,
getBcakUrl: getBcakUrlApi
}
});
// 数据异步回调函数 // 数据异步回调函数
// 商城 // 商城
mpApp.shopCallBack = function () { } mpApp.shopCallBack = function () { }
...@@ -65,9 +85,9 @@ mpApp.indexBgCallBack = function(){ } ...@@ -65,9 +85,9 @@ mpApp.indexBgCallBack = function(){ }
// 全局数据 // 全局数据
mpApp.processEnv = process.env; mpApp.processEnv = process.env;
console.log('3555555', wx)
// 全局跳转 data为link对象 // 全局跳转 data为link对象
mpApp.$themeToLink = $themeToLink mpApp.$themeToLink = $themeToLink
console.log('3555555', wx)
// 全局加入购物车 // 全局加入购物车
mpApp.$themeAddToCard = $themeAddToCard mpApp.$themeAddToCard = $themeAddToCard
// 文章点赞 // 文章点赞
......
...@@ -4,14 +4,8 @@ ...@@ -4,14 +4,8 @@
<image class="img" mode="aspectFit" :src="logoUrl" /> <image class="img" mode="aspectFit" :src="logoUrl" />
<p class="shopName" v-if="shopName">{{shopName}}</p> <p class="shopName" v-if="shopName">{{shopName}}</p>
<div class="btn_info"> <div class="btn_info">
<button class="btn" lang="zh_CN" open-type="getUserInfo" @getuserinfo="getUserInfo">微信一键登录</button> <button class="btn" lang="zh_CN" @click="getUserProfile">微信一键登录</button>
</div> </div>
<!-- <div>{{testd}}</div>
<div>{{test_sessionId}}</div>--sessionId
<div>{{unionId}}</div>--unionId
<div>{{test_isHaveUnion}}</div>--isHaveUnion-->
<!-- <div class="enterpriseLogin" @click="eLogin">账号登录</div> -->
</div> </div>
<div class="toCLogin1" v-if="isShowPhone"> <div class="toCLogin1" v-if="isShowPhone">
<div class="btn_info1"> <div class="btn_info1">
...@@ -32,13 +26,8 @@ import { wx_decode } from "@/utils/wxIndex.js"; ...@@ -32,13 +26,8 @@ import { wx_decode } from "@/utils/wxIndex.js";
import login from "@/api/login"; import login from "@/api/login";
import shop from "@/api/shop"; import shop from "@/api/shop";
import indexApi from "@/api/index.js"; import indexApi from "@/api/index.js";
var WXBizDataCrypt = require("@/utils/WXBizDataCrypt");
const app = getApp(); const app = getApp();
export default { export default {
name:'login',
components: {
// card
},
data() { data() {
return { return {
code: "", code: "",
...@@ -68,9 +57,9 @@ export default { ...@@ -68,9 +57,9 @@ export default {
test_isHaveUnion: "", test_isHaveUnion: "",
test_unionId: "", test_unionId: "",
fromType:'',//来源类型 mini:小程序跳转到当前登录页 fromType:'',//来源类型 mini:小程序跳转到当前登录页
scene:''//场景
}; };
}, },
created() {},
onShow() { onShow() {
wx.checkSession({ wx.checkSession({
success : () => { success : () => {
...@@ -99,6 +88,7 @@ export default { ...@@ -99,6 +88,7 @@ export default {
}, },
onLoad(options) { onLoad(options) {
Object.assign(this.$data, this.$options.data()); //mpvue 的混合周期 使用小程序生命周期数据未初始化 Object.assign(this.$data, this.$options.data()); //mpvue 的混合周期 使用小程序生命周期数据未初始化
options.scene && (this.scene=options.scene)
if (options.back) { if (options.back) {
this.backPath = options.back; this.backPath = options.back;
} }
...@@ -171,102 +161,64 @@ export default { ...@@ -171,102 +161,64 @@ export default {
}) })
} }
}, },
getUserInfo: function(e) { getUserProfile() {
this.backParams=this.defalutBackParams // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
wx.showLoading({ // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
title: "加载中" wx.getUserProfile({
}); desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
if (e.target.errMsg == "getUserInfo:ok") { success: (e) => {
this.init() this.init()
.then(res => { .then(res => {
console.log("promise", res); //存入openid
//存入openid try {
try { wx.setStorageSync('openid', res.data.data.openid)
wx.setStorageSync('openid', res.data.data.openid) } catch (e) {
} catch (e) { console.log('存入openid失败',e)
console.log('存入openid失败',e)
}
wx.getStorage({
key: "openid",
success (res) {
console.log("promise_openid1",res)
},
fail(err){
console.log("promise_openid2",err)
} }
}) if (res.data.data.isHaveUnion == "true") {
// //有账号
if (res.data.data.isHaveUnion == "true") { this.backParams += `&sessionid=${
//有账号 res.data.data.sessionId
this.backParams += `&sessionid=${ }&needCertified=${res.data.data.NEED_CERTIFIED}`;
res.data.data.sessionId this.NEED_CERTIFIED = res.data.data.NEED_CERTIFIED;
}&needCertified=${res.data.data.NEED_CERTIFIED}`; wx.setStorage({
this.NEED_CERTIFIED = res.data.data.NEED_CERTIFIED; key: "sessionid",
wx.setStorage({ data: res.data.data.sessionId
key: "sessionid", });
data: res.data.data.sessionId
});
this.isHaveUnion = true; this.isHaveUnion = true;
} else { } else {
//需要绑定 //需要绑定
this.isHaveUnion = false; this.isHaveUnion = false;
} }
this.appid = res.data.data.appid; this.appid = res.data.data.appid;
this.session_key = res.data.data.session_key; this.session_key = res.data.data.session_key;
this.openid = res.data.data.openid; this.openid = res.data.data.openid;
this.isShow = true; this.unionId = res.data.data.unionId || '';
this.isShow = true;
//checkLogin //checkLogind
this.checkLogin(e); this.checkLogin(e);
}) })
.catch(err => { .catch(err => {
console.log("err", err); console.log("err", err);
wx.hideLoading(); wx.hideLoading();
wx.showToast({ title: err, icon: "none" }); wx.showToast({ title: err, icon: "none" });
}); });
} else { }
wx.hideLoading(); })
wx.showToast({ title: "获取用户信息失败", icon: "none" });
}
}, },
checkLogin(e) { checkLogin(e) {
console.log(this.isHaveUnion,e) this.userInfo = e.userInfo;
this.$store.commit('setUserInfo',this.userInfo)
if (this.isHaveUnion) { if (this.isHaveUnion) {
wx.hideLoading(); wx.hideLoading();
//是会员 直接登录 //是会员 直接登录
// 0318写直播改后面注释逻辑相同
// wx.reLaunch({
// url: `../index/main?from=login&backpath=${
// this.backPath
// }&params=${encodeURIComponent(this.backParams)}`
// });
// 跳转回小程序页面 // 跳转回小程序页面
var data = wx_decode(
this.appid,
this.session_key,
e.mp.detail.encryptedData,
e.mp.detail.iv
);
this.userInfo = JSON.parse(e.target.rawData);
this.$store.commit('setUserInfo',this.userInfo)
this.addRecord(false); this.addRecord(false);
this.pushPageType(); this.pushPageType();
} else { } else {
var data = wx_decode(
this.appid,
this.session_key,
e.mp.detail.encryptedData,
e.mp.detail.iv
);
this.unionId = data.unionId || "";
this.userInfo = JSON.parse(e.target.rawData);
console.log(this.userInfo, "this.userInfo");
this.$store.commit('setUserInfo',this.userInfo)
if (this.unionId) { if (this.unionId) {
login login
.checkUnionid({ unionId: this.unionId, openId: this.openid }) .checkUnionid({ unionId: this.unionId, openId: this.openid })
...@@ -324,12 +276,13 @@ export default { ...@@ -324,12 +276,13 @@ export default {
wx.navigateBack({ wx.navigateBack({
delta: 1 delta: 1
}); });
}else if (this.scene=='sso') {
wx.redirectTo({
url: `../wxArticle/main?link=${this.backPath}`,
});
}else{ }else{
let parseLink=decodeURIComponent(this.backPath); let parseLink=decodeURIComponent(this.backPath);
let isTabbarIndex =checkTabbarPage(parseLink) let isTabbarIndex =checkTabbarPage(parseLink)
console.log('32111',isTabbarIndex,parseLink,this.backParams)
// wx.navigateBack()
// return
if(isTabbarIndex>-1){ if(isTabbarIndex>-1){
wx.reLaunch({ wx.reLaunch({
url: parseLink == '/' ? '/pages/home/main' : `/pages/tabBar${isTabbarIndex}/main`, url: parseLink == '/' ? '/pages/home/main' : `/pages/tabBar${isTabbarIndex}/main`,
...@@ -341,7 +294,6 @@ export default { ...@@ -341,7 +294,6 @@ export default {
}&params=${encodeURIComponent(this.backParams)}` }&params=${encodeURIComponent(this.backParams)}`
}); });
} }
} }
}, },
getPhoneNumber(e) { getPhoneNumber(e) {
...@@ -378,6 +330,7 @@ export default { ...@@ -378,6 +330,7 @@ export default {
province: this.userInfo.province, province: this.userInfo.province,
city: this.userInfo.city, city: this.userInfo.city,
otherPhone: 0, otherPhone: 0,
articleId: wx.getStorageSync(this.$store.state.mixid+"articleId") || '',
customerSourceType: wx.getStorageSync(this.$store.state.mixid+"articleId")?8:'', customerSourceType: wx.getStorageSync(this.$store.state.mixid+"articleId")?8:'',
customerSourceId: wx.getStorageSync(this.$store.state.mixid+"articleId") || '' customerSourceId: wx.getStorageSync(this.$store.state.mixid+"articleId") || ''
}; };
......
import cart from "@/api/cart" import cart from "@/api/cart"
import shop from "@/api/shop"
import coupon from "@/api/coupon";
import classificationApi from "@/api/classification"; import classificationApi from "@/api/classification";
// 登录白名单 name // 登录白名单 name
export const noLoginList = ["index", "media-video", "goods-goodsInfo", "goods-commodityMenu", "goodsSearch-goodsSearch", "chooseStores", "activty-receivingGift", "activty", "login-register", "login-phoneLogin", "login-authInformation", "login-forgetPassWord", "login-accountLogin", "login-wxRegister", "pay-payList", "comment-evaluateList", "goods-commonProblemList", "article-articlePage", "article-articleList", "goods-posters", "liveBroadcast", "liveBroadcast-list", "personalCenter-coupon-getCoupon", "buyerShow-showDetail", "goods-addGoodsList", "personalCenter-CDkey-exchange", "giftCards-linkReceive", "giftCoupon-preview", "smartForm", "shopCart-shareShopCart", "groupBuying-beInvite", "brandTopics", 'personalCenter-spokesmanCenter', 'personalCenter-spokesmanCenter-mine-spokesmanHomePage', 'liveBroadcast-lived', 'personalCenter-spokesmanCenter-mine-getBusinessCard', 'changeAdr']; export const noLoginList = ["index", "media-video", "goods-goodsInfo", "goods-commodityMenu", "goodsSearch-goodsSearch", "chooseStores", "activty-receivingGift", "activty", "login-register", "login-phoneLogin", "login-authInformation", "login-forgetPassWord", "login-accountLogin", "login-wxRegister", "pay-payList", "comment-evaluateList", "goods-commonProblemList", "article-articlePage", "article-articleList", "goods-posters", "liveBroadcast", "liveBroadcast-list", "personalCenter-coupon-getCoupon", "buyerShow-showDetail", "goods-addGoodsList", "personalCenter-CDkey-exchange", "giftCards-linkReceive", "giftCoupon-preview", "smartForm", "shopCart-shareShopCart", "groupBuying-beInvite", "brandTopics", 'personalCenter-spokesmanCenter', 'personalCenter-spokesmanCenter-mine-spokesmanHomePage', 'liveBroadcast-lived', 'personalCenter-spokesmanCenter-mine-getBusinessCard', 'changeAdr'];
...@@ -154,6 +156,7 @@ export function $themeAddToCard(item, callback) { ...@@ -154,6 +156,7 @@ export function $themeAddToCard(item, callback) {
} }
function toPage(backPath, backParams = "") { function toPage(backPath, backParams = "") {
console.log(backPath, backParams,'--------------------------159');
wx.navigateTo({ wx.navigateTo({
url: `../index/main?from=themeLink&backpath=${encodeURIComponent(backPath)}&params=${encodeURIComponent(backParams)}` url: `../index/main?from=themeLink&backpath=${encodeURIComponent(backPath)}&params=${encodeURIComponent(backParams)}`
}); });
...@@ -233,4 +236,97 @@ export function $themeArticleLike(item, callback) { ...@@ -233,4 +236,97 @@ export function $themeArticleLike(item, callback) {
} else { } else {
} }
}); });
} }
\ No newline at end of file export function getCoupon(code, item) {
console.log("--------------------239");
let usingIntegrals = (item.consumeIntegral - 0).toFixed(0);
let couponCode = code;
console.log(item, "------------------------242");
if (item.receiveCostType == 1) {
wx.showModal({
confirmColor: "#CA173B",
content: `是否消耗${usingIntegrals}积分领取`
})
.then(() => {
useCoupon(2, couponCode, usingIntegrals);
})
.catch(() => {
// on cancel
});
return;
} else {
useCoupon(1, couponCode, usingIntegrals);
}
};
function useCoupon(val, couponCode, usingIntegrals) {
coupon.receive_coupon(couponCode).then(res => {
console.log(res, "cou137");
if (res.data.data == "true") {
if (val == 1) {
wx.showToast({ title: "领取成功", icon: "success" });
} else {
let tit = "积分-" + usingIntegrals;
wx.showToast({ title: tit, icon: "success" });
}
// item.receive=false;
} else {
wx.showToast({title:res.data.msg ,icon :"none"});
// item.receive=true;
}
});
};
export function themeMemberCardClick (item) {
let query = {
portalCardId: item.id
};
shop.getV3CardList(query).then(res => {
console.log(res,'--------------------282')
if (res.data.code == 200) {
let cardData = "";
res.data.data.forEach(innerItem => {
if (innerItem.id == item.id) {
cardData = innerItem;
}
});
if (cardData.receiveWay == 0) {
// 无门槛
let cardId = cardData.id;
let userInfo = wx.getStorageSync("userInfo") ? JSON.parse(wx.getStorageSync("userInfo")) : "";
shop.drawV3Card(cardId).then(res => {
if (res.data.code == 200) {
wx.showToast({
title: `开通【${cardData.title}】成功`,
icon: "none"
});
} else {
if (res.data.msg == "不能重复领卡") {
console.log("---------------------------to-----1")
let backParams = `&cardId=${cardData.id}&userTel=${userInfo.mobilephone}`;
toPage("/personalCenter/membershipCard",backParams);
} else {
wx.showToast({ title: res.data.msg, icon: "none" });
}
}
});
} else if (cardData.receiveWay == 1) {
// 自动领取
console.log("自动领取");
} else if (cardData.receiveWay == 2) {
// 付费购买
if (cardData.receiveStatus == 0) {
console.log("---------------------------to-----2")
let backParams = `&cardId=${cardData.id}`;
toPage("/pay/payCard", backParams);
} else {
console.log("---------------------------to-----3")
let backParams = `&cardId=${cardData.id}&userTel=${userInfo.mobilephone}`;
toPage("/personalCenter/membershipCard", backParams);
}
} else {
console.error("无效的领取方式");
}
} else {
wx.showToast({title:res.data.msg,icon:"none"});
}
});
};
\ No newline at end of file
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
</view> </view>
</view> </view>
<!-- 名称 --> <!-- 名称 -->
<view class="text" style="color: {{selected === index ? componentData.selectTextColor : componentData.defaultTextColor}};font-size:{{selected === index ? componentData.selectionTextNum*2 : componentData.defaultTextNum*2}}rpx"> <view class="text" style="color: {{selected === index ? componentData.selectTextColor : componentData.defaultTextColor}};font-size:{{selected === index ? (componentData.selectText==1?10:componentData.selectionTextNum)*2 : (componentData.defaultText==1?10:componentData.defaultTextNum)*2}}rpx">
{{item.title}}</view> {{item.title}}</view>
<!-- 购物车商品数量 --> <!-- 购物车商品数量 -->
<view class="isCart" wx:if="{{item.link&&item.link.link&&item.link.link=='/shopCart/shoppingCart'&&cartNum>0}}"> <view class="isCart" wx:if="{{item.link&&item.link.link&&item.link.link=='/shopCart/shoppingCart'&&cartNum>0}}">
......
...@@ -1237,10 +1237,9 @@ ...@@ -1237,10 +1237,9 @@
/* font-size: 10px; */ /* font-size: 10px; */
} }
/* .img-view{ .img-view{
display: flex; margin:auto;
align-items: center; }
} */
.img-view image{ .img-view image{
/* object-fit: contain; */ /* object-fit: contain; */
width: 100%; width: 100%;
......
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