Commit 46903c9f by 程默

init

parent 9cc1b989
......@@ -3,12 +3,13 @@ var prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {//zjgyl
SHOP_MIXID:"'zjgyl'",
SHOP_MIXID:"'antgood'",
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"',
// IMG_DOMAIN: '"http://test-bucket-ant.oss-cn-shanghai.aliyuncs.com"'
IMG_DOMAIN: '"http://cdn.mayi888.com"'
OLSHOP_URL:'"https://test-m-shop.mayi888.cn/innerApi/shopApiService"',
// OLSHOP_URL:'"https://shop.mayi888.com/innerApi/shopApiService"',
IMG_DOMAIN: '"http://test-bucket-ant.oss-cn-shanghai.aliyuncs.com"'
// IMG_DOMAIN: '"http://cdn.mayi888.com"'
})
<template>
<div class="domain">
获取微信地址{{address}}--111
</div>
<div class="domain">获取微信地址{{address}}----{{openid}}</div>
</template>
<script>
......@@ -10,7 +8,9 @@ import addres from "@/api/userAddress";
export default {
data() {
return {
address: wx.getStorageSync('sessionid'),
address: wx.getStorageSync("sessionid"),
openid: wx.getStorageSync("openid"),
options: "",
weChatInfo: "",
userAddressReq: {
......@@ -32,21 +32,82 @@ export default {
province_list: area.province_list,
city_list: area.city_list,
county_list: area.county_list,
provinceTwoKey: 0
provinceTwoKey: 0,
openSetting: false
};
},
onLoad(options) {
Object.assign(this.$data, this.$options.data());
console.log('token',this.address);
this.options = options;
console.log("onload");
this.init();
},
onShow() {
console.log("onshow",this.openSetting);
if (this.openSetting) {
this.init();
}
},
methods: {
init() {
wx.showLoading({
title: "加载中"
});
let that = this;
wx.chooseAddress({
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();
}
});
},
methods: {
disposeAddress(val) {
if (val) {
this.weChatInfo = val;
......@@ -95,7 +156,10 @@ export default {
}
}
});
addres.getUserAddressList().then(res => {
addres
.getUserAddressList()
.then(res => {
if (res.data.code == 200) {
let list = res.data.data.list;
if (!list.length > 0) {
......@@ -103,21 +167,35 @@ export default {
} else {
this.userAddressReq.isDefaultShipping = 0;
}
addres.addOrEditAddress(this.userAddressReq).then(res => {
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);
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.showToast({ title: res.data.msg, icon: "none" });
wx.navigateBack();
})
.catch(err => {
wx.showToast({ title: err, icon: "none" });
wx.navigateBack();
});
}else{
} 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 {
onLoad(options) {
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;
if (options.share) {
//来自分享
......@@ -80,7 +83,9 @@ export default {
key: "openid"
});
} else if (options.from && options.from == "address") {
this.link = decodeURIComponent(options.backpath);
console.log("???", this.link);
this.page = "";
this.params = "";
......@@ -97,8 +102,8 @@ export default {
console.log("url", this.link + this.page + this.params);
this.getSpokesman();
},
components: {
// card
onShow(){
// console.log('显示了',options.webViewUrl);
},
methods: {
init() {
......@@ -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() {
wx.getLocation({
type: "wgs84",
......@@ -194,7 +206,7 @@ export default {
return {
title: this.shareShopName, // 默认是小程序的名称
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) {
// 转发成功之后的回调
if (res.errMsg == "shareAppMessage:ok") {
......
......@@ -6,6 +6,11 @@
<div class="btn_info">
<button class="btn" lang="zh_CN" open-type="getUserInfo" @getuserinfo="getUserInfo">微信一键登录</button>
</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 class="toCLogin1" v-if="isShowPhone">
......@@ -51,6 +56,12 @@ export default {
unionId: "",
userInfo: "",
NEED_CERTIFIED: "",
//----------------
testd: "",
test_sessionId: "",
test_isHaveUnion: "",
test_unionId: ""
};
},
created() {},
......@@ -62,22 +73,15 @@ export default {
if (options.params) {
this.backParams = serialize(options.params);
}
console.log(options, "登录页面", this.backPath, this.backParams);
console.log(
this.$store.state.spokesmanGroupId,
"-----------0---------------"
);
this.getshop();
this.init();
},
methods: {
getshop() {
shop.getShopInfo().then(res => {
console.log(res, "shop");
if (res.data.code == 200) {
this.shopName = res.data.data.shopName;
this.logoUrl = process.env.IMG_DOMAIN + res.data.data.logoUrl;
console.log(this.logoUrl);
} else {
}
});
......@@ -89,14 +93,20 @@ export default {
login
.miniLogin({ code: res.code })
.then(res => {
wx.showToast({ title: res.data.code, icon: "none" });
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({
key: "openid",
data: res.data.data.openid
});
if (res.data.data.isHaveUnion == "true") {
//有账号
this.isHaveUnion = true;
this.backParams += `&sessionid=${
res.data.data.sessionId
}&needCertified=${res.data.data.NEED_CERTIFIED}`;
......@@ -105,6 +115,8 @@ export default {
key: "sessionid",
data: res.data.data.sessionId
});
this.isHaveUnion = true;
} else {
//需要绑定
this.isHaveUnion = false;
......@@ -113,6 +125,8 @@ export default {
this.session_key = res.data.data.session_key;
this.openid = res.data.data.openid;
this.isShow = true;
this.test_sessionId = wx.getStorageSync("sessionid");
} else {
wx.showToast({ title: res.data.msg, icon: "none" });
}
......@@ -154,7 +168,6 @@ export default {
.checkUnionid({ unionId: this.unionId, openId: this.openid })
.then(res => {
if (res.data.code == 200) {
console.log("check", res);
if (res.data.data.isHaveUnion == "true") {
this.NEED_CERTIFIED = res.data.data.NEED_CERTIFIED;
this.backParams += `&sessionid=${
......@@ -175,7 +188,9 @@ export default {
}
}
})
.catch(err => {});
.catch(err => {
wx.showToast({ title: err, icon: "none" });
});
} else {
//不是会员需要绑定手机号
this.isShowPhone = true;
......
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