Commit 46903c9f by 程默

init

parent 9cc1b989
...@@ -3,12 +3,13 @@ var prodEnv = require('./prod.env') ...@@ -3,12 +3,13 @@ var prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {//zjgyl module.exports = merge(prodEnv, {//zjgyl
SHOP_MIXID:"'zjgyl'", SHOP_MIXID:"'antgood'",
NODE_ENV: '"development"', NODE_ENV: '"development"',
BASE_URL:"'https://shop.mayi888.com'", // BASE_URL:"'https://shop.mayi888.com'",
BASE_URL:"'http://192.168.1.146:30004'",
// OLSHOP_URL:'"https://test-m-shop.mayi888.cn/innerApi/shopApiService"',
OLSHOP_URL:'"https://shop.mayi888.com/innerApi/shopApiService"', OLSHOP_URL:'"https://test-m-shop.mayi888.cn/innerApi/shopApiService"',
// IMG_DOMAIN: '"http://test-bucket-ant.oss-cn-shanghai.aliyuncs.com"' // OLSHOP_URL:'"https://shop.mayi888.com/innerApi/shopApiService"',
IMG_DOMAIN: '"http://cdn.mayi888.com"' IMG_DOMAIN: '"http://test-bucket-ant.oss-cn-shanghai.aliyuncs.com"'
// IMG_DOMAIN: '"http://cdn.mayi888.com"'
}) })
<template> <template>
<div class="domain"> <div class="domain">获取微信地址{{address}}----{{openid}}</div>
获取微信地址{{address}}--111
</div>
</template> </template>
<script> <script>
...@@ -10,7 +8,9 @@ import addres from "@/api/userAddress"; ...@@ -10,7 +8,9 @@ import addres from "@/api/userAddress";
export default { export default {
data() { data() {
return { return {
address: wx.getStorageSync('sessionid'), address: wx.getStorageSync("sessionid"),
openid: wx.getStorageSync("openid"),
options: "", options: "",
weChatInfo: "", weChatInfo: "",
userAddressReq: { userAddressReq: {
...@@ -32,21 +32,82 @@ export default { ...@@ -32,21 +32,82 @@ export default {
province_list: area.province_list, province_list: area.province_list,
city_list: area.city_list, city_list: area.city_list,
county_list: area.county_list, county_list: area.county_list,
provinceTwoKey: 0 provinceTwoKey: 0,
openSetting: false
}; };
}, },
onLoad(options) { onLoad(options) {
Object.assign(this.$data, this.$options.data()); Object.assign(this.$data, this.$options.data());
console.log('token',this.address);
this.options = options; this.options = options;
let that = this; console.log("onload");
wx.chooseAddress({ this.init();
success(res) { },
that.disposeAddress(res); onShow() {
} console.log("onshow",this.openSetting);
}); if (this.openSetting) {
this.init();
}
}, },
methods: { methods: {
init() {
wx.showLoading({
title: "加载中"
});
let that = this;
wx.getSetting({
success(res) {
if (!res.authSetting["scope.address"]) {
that.openConfirm();
} else {
console.log(2);
//打开选择地址
wx.chooseAddress({
success: function(res) {
console.log(4);
that.disposeAddress(res);
},
fail: function(res) {
//用户取消
console.log(5);
wx.navigateBack();
}
});
}
},
fail(res) {
console.log("调用失败");
}
});
},
openConfirm() {
wx.hideLoading();
let that = this;
wx.showModal({
content: "检测到您没打开通讯地址的权限,是否去设置打开?",
confirmText: "确认",
cancelText: "取消",
success: function(res) {
console.log(res);
//点击“确认”时打开设置页面
if (res.confirm) {
console.log("用户点击确认");
wx.openSetting({
success: res => {
that.openSetting = true;
}
});
} else {
console.log("用户点击取消");
wx.navigateBack();
}
},
fail: function(res) {
wx.navigateBack();
}
});
},
disposeAddress(val) { disposeAddress(val) {
if (val) { if (val) {
this.weChatInfo = val; this.weChatInfo = val;
...@@ -95,30 +156,47 @@ export default { ...@@ -95,30 +156,47 @@ export default {
} }
} }
}); });
addres.getUserAddressList().then(res => {
if (res.data.code == 200) { addres
let list = res.data.data.list; .getUserAddressList()
if (!list.length > 0) { .then(res => {
this.userAddressReq.isDefaultShipping = 1; if (res.data.code == 200) {
} else { let list = res.data.data.list;
this.userAddressReq.isDefaultShipping = 0; if (!list.length > 0) {
} this.userAddressReq.isDefaultShipping = 1;
addres.addOrEditAddress(this.userAddressReq).then(res => {
if (res.data.code == 200) {
console.log("!!!!!!!!!!!!!",this.options.back);
setTimeout(() => {
wx.reLaunch({
url: `../index/main?from=address&backpath=${this.options.back}`
});
}, 200);
} else { } else {
wx.showToast({ title: res.data.msg, icon: "none" }); this.userAddressReq.isDefaultShipping = 0;
} }
}); addres
}else{ .addOrEditAddress(this.userAddressReq)
wx.showToast({ title: res.data.msg, icon: "none" }); .then(res => {
} if (res.data.code == 200) {
}); console.log("!!!!!!!!!!!!!", this.options.back);
console.log("微信地址", this.userAddressReq);
// setTimeout(() => {
// wx.reLaunch({
// url: `../index/main?from=address&backpath=${this.options.back}`
// });
// }, 200);
} else {
}
wx.showToast({ title: res.data.msg, icon: "none" });
wx.navigateBack();
})
.catch(err => {
wx.showToast({ title: err, icon: "none" });
wx.navigateBack();
});
} else {
wx.showToast({ title: res.data.msg, icon: "none" });
wx.navigateBack();
}
})
.catch(err => {
wx.showToast({ title: err, icon: "none" });
wx.navigateBack();
});
} }
} }
} }
......
...@@ -39,7 +39,10 @@ export default { ...@@ -39,7 +39,10 @@ export default {
onLoad(options) { onLoad(options) {
Object.assign(this.$data, this.$options.data()); Object.assign(this.$data, this.$options.data());
console.log(options, "index------",this.shopId,'-----',this.baseUrl); console.log(options, "index------",this.shopId,'-----',wx.getStorageSync("openid"));
//检测
this.checkLogin();
this.options = options; this.options = options;
if (options.share) { if (options.share) {
//来自分享 //来自分享
...@@ -80,7 +83,9 @@ export default { ...@@ -80,7 +83,9 @@ export default {
key: "openid" key: "openid"
}); });
} else if (options.from && options.from == "address") { } else if (options.from && options.from == "address") {
this.link = decodeURIComponent(options.backpath); this.link = decodeURIComponent(options.backpath);
console.log("???", this.link); console.log("???", this.link);
this.page = ""; this.page = "";
this.params = ""; this.params = "";
...@@ -97,8 +102,8 @@ export default { ...@@ -97,8 +102,8 @@ export default {
console.log("url", this.link + this.page + this.params); console.log("url", this.link + this.page + this.params);
this.getSpokesman(); this.getSpokesman();
}, },
components: { onShow(){
// card // console.log('显示了',options.webViewUrl);
}, },
methods: { methods: {
init() { init() {
...@@ -120,6 +125,13 @@ export default { ...@@ -120,6 +125,13 @@ export default {
} }
}); });
}, },
checkLogin(){
let getOpenid=wx.getStorageSync("openid");
let getSessionid=wx.getStorageSync("sessionid");
if (getOpenid=='' || getSessionid=='') {
this.params+='&logOut=true'
}
},
getLocationHandle() { getLocationHandle() {
wx.getLocation({ wx.getLocation({
type: "wgs84", type: "wgs84",
...@@ -194,7 +206,7 @@ export default { ...@@ -194,7 +206,7 @@ export default {
return { return {
title: this.shareShopName, // 默认是小程序的名称 title: this.shareShopName, // 默认是小程序的名称
path: `/pages/index/main?share=${encodeURIComponent(this.shareUrl)}`, // 默认是当前页面 path: `/pages/index/main?share=${encodeURIComponent(this.shareUrl)}`, // 默认是当前页面
imageUrl: this.shareLogoUrl, imageUrl: 'http://yanxuan.nosdn.127.net/bdd778a60b6672dea21598236b4e4a1d.jpg?x-oss-process=image/resize,m_pad,limit_0,w_400,h_400',
success: function(res) { success: function(res) {
// 转发成功之后的回调 // 转发成功之后的回调
if (res.errMsg == "shareAppMessage:ok") { if (res.errMsg == "shareAppMessage:ok") {
......
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
<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" open-type="getUserInfo" @getuserinfo="getUserInfo">微信一键登录</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 class="enterpriseLogin" @click="eLogin">账号登录</div> -->
</div> </div>
<div class="toCLogin1" v-if="isShowPhone"> <div class="toCLogin1" v-if="isShowPhone">
...@@ -51,6 +56,12 @@ export default { ...@@ -51,6 +56,12 @@ export default {
unionId: "", unionId: "",
userInfo: "", userInfo: "",
NEED_CERTIFIED: "", NEED_CERTIFIED: "",
//----------------
testd: "",
test_sessionId: "",
test_isHaveUnion: "",
test_unionId: ""
}; };
}, },
created() {}, created() {},
...@@ -62,22 +73,15 @@ export default { ...@@ -62,22 +73,15 @@ export default {
if (options.params) { if (options.params) {
this.backParams = serialize(options.params); this.backParams = serialize(options.params);
} }
console.log(options, "登录页面", this.backPath, this.backParams);
console.log(
this.$store.state.spokesmanGroupId,
"-----------0---------------"
);
this.getshop(); this.getshop();
this.init(); this.init();
}, },
methods: { methods: {
getshop() { getshop() {
shop.getShopInfo().then(res => { shop.getShopInfo().then(res => {
console.log(res, "shop");
if (res.data.code == 200) { if (res.data.code == 200) {
this.shopName = res.data.data.shopName; this.shopName = res.data.data.shopName;
this.logoUrl = process.env.IMG_DOMAIN + res.data.data.logoUrl; this.logoUrl = process.env.IMG_DOMAIN + res.data.data.logoUrl;
console.log(this.logoUrl);
} else { } else {
} }
}); });
...@@ -89,14 +93,20 @@ export default { ...@@ -89,14 +93,20 @@ export default {
login login
.miniLogin({ code: res.code }) .miniLogin({ code: res.code })
.then(res => { .then(res => {
wx.showToast({ title: res.data.code, icon: "none" });
if (res.data.code == 200) { if (res.data.code == 200) {
this.testd = JSON.stringify(res.data);
this.test_isHaveUnion = res.data.data.isHaveUnion;
console.log("login---", res.data);
wx.setStorage({ wx.setStorage({
key: "openid", key: "openid",
data: res.data.data.openid data: res.data.data.openid
}); });
if (res.data.data.isHaveUnion == "true") { if (res.data.data.isHaveUnion == "true") {
//有账号 //有账号
this.isHaveUnion = true;
this.backParams += `&sessionid=${ this.backParams += `&sessionid=${
res.data.data.sessionId res.data.data.sessionId
}&needCertified=${res.data.data.NEED_CERTIFIED}`; }&needCertified=${res.data.data.NEED_CERTIFIED}`;
...@@ -105,6 +115,8 @@ export default { ...@@ -105,6 +115,8 @@ export default {
key: "sessionid", key: "sessionid",
data: res.data.data.sessionId data: res.data.data.sessionId
}); });
this.isHaveUnion = true;
} else { } else {
//需要绑定 //需要绑定
this.isHaveUnion = false; this.isHaveUnion = false;
...@@ -113,12 +125,14 @@ export default { ...@@ -113,12 +125,14 @@ export default {
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.isShow = true;
this.test_sessionId = wx.getStorageSync("sessionid");
} else { } else {
wx.showToast({ title: res.data.msg, icon: "none" }); wx.showToast({ title: res.data.msg, icon: "none" });
} }
}) })
.catch(err => { .catch(err => {
wx.showToast({ title: err, icon: "none" }); wx.showToast({ title: err, icon: "none" });
}); });
} }
} }
...@@ -150,35 +164,36 @@ export default { ...@@ -150,35 +164,36 @@ export default {
// return // return
if (this.unionId) { if (this.unionId) {
login login
.checkUnionid({ unionId: this.unionId, openId: this.openid }) .checkUnionid({ unionId: this.unionId, openId: this.openid })
.then(res => { .then(res => {
if (res.data.code == 200) { if (res.data.code == 200) {
console.log("check", res); if (res.data.data.isHaveUnion == "true") {
if (res.data.data.isHaveUnion == "true") { this.NEED_CERTIFIED = res.data.data.NEED_CERTIFIED;
this.NEED_CERTIFIED = res.data.data.NEED_CERTIFIED; this.backParams += `&sessionid=${
this.backParams += `&sessionid=${ res.data.data.sessionId
res.data.data.sessionId }&needCertified=${res.data.data.NEED_CERTIFIED}`;
}&needCertified=${res.data.data.NEED_CERTIFIED}`; wx.setStorage({
wx.setStorage({ key: "sessionid",
key: "sessionid", data: res.data.data.sessionId
data: res.data.data.sessionId });
}); wx.reLaunch({
wx.reLaunch({ url: `../index/main?from=login&backpath=${
url: `../index/main?from=login&backpath=${ this.backPath
this.backPath }&params=${encodeURIComponent(this.backParams)}`
}&params=${encodeURIComponent(this.backParams)}` });
}); } else {
} else { //不是会员需要绑定手机号
//不是会员需要绑定手机号 this.isShowPhone = true;
this.isShowPhone = true;
}
} }
}) }
.catch(err => {}); })
.catch(err => {
wx.showToast({ title: err, icon: "none" });
});
} else { } else {
//不是会员需要绑定手机号 //不是会员需要绑定手机号
this.isShowPhone = true; this.isShowPhone = true;
} }
} }
} else { } else {
......
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