Commit eb430dfd by 程默

fix

parent deb17f7b
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
"build": "node build/build.js wx" "build": "node build/build.js wx"
}, },
"dependencies": { "dependencies": {
"flyio": "^0.6.14",
"mpvue": "^2.0.0", "mpvue": "^2.0.0",
"vuex": "^3.0.1" "vuex": "^3.0.1"
}, },
...@@ -42,6 +43,7 @@ ...@@ -42,6 +43,7 @@
"express": "^4.16.3", "express": "^4.16.3",
"extract-text-webpack-plugin": "^3.0.2", "extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.11", "file-loader": "^1.1.11",
"flyio": "^0.6.14",
"friendly-errors-webpack-plugin": "^1.7.0", "friendly-errors-webpack-plugin": "^1.7.0",
"glob": "^7.1.2", "glob": "^7.1.2",
"html-webpack-plugin": "^3.2.0", "html-webpack-plugin": "^3.2.0",
......
...@@ -11,6 +11,10 @@ console.log(process.env,'-----------------config------') ...@@ -11,6 +11,10 @@ console.log(process.env,'-----------------config------')
//绑定 //绑定
bindUser(options){ bindUser(options){
return requestGET(`${process.env.OLSHOP_URL}/wx/mini_bind_user`,options) return requestGET(`${process.env.OLSHOP_URL}/wx/mini_bind_user`,options)
},
//check unionid
checkUnionid(options){
return requestGET(`${process.env.OLSHOP_URL}/wx/mini_check_union_id`,options)
} }
} }
\ No newline at end of file
import {requestPOST,requestGET} from "@/utils/request.js";
export default {
// 查询是否有分销员资格
getSpokesmanidByShare(){
return requestPOST(`${process.env.OLSHOP_URL}/spokesmanShare/get_spokesmanid_by_share`)
}
}
<template> <template>
<div @click="clickHandle"> <div @click="clickHandle">
<web-view :src="link+page+params" @message="getMessage"></web-view> <web-view :src="link+page+params" @message="getMessage"></web-view>
<!-- <div class="userinfo" @click="bindViewTap">
<img class="userinfo-avatar" v-if="userInfo.avatarUrl" :src="userInfo.avatarUrl" background-size="cover" />
<img class="userinfo-avatar" src="/static/images/user.png" background-size="cover" />
<div class="userinfo-nickname">
<card :text="userInfo.nickName"></card>
</div>
</div>
<div class="usermotto">
<div class="user-motto">
<card :text="motto"></card>
</div>
</div>
<form class="form-container">
<input type="text" class="form-control" :value="motto" placeholder="v-model" />
<input type="text" class="form-control" v-model="motto" placeholder="v-model" />
<input type="text" class="form-control" v-model.lazy="motto" placeholder="v-model.lazy" />
</form>
<a href="/pages/counter/main" class="counter">去往Vuex示例页面</a>
<div class="all">
<div class="left">
</div>
<div class="right">
</div>
</div>-->
</div> </div>
</template> </template>
<script> <script>
// import card from '@/components/card' import spokesman from "@/api/spokesman.js";
export default { export default {
data() { data() {
return { return {
...@@ -48,35 +20,16 @@ export default { ...@@ -48,35 +20,16 @@ export default {
nickName: "mpvue", nickName: "mpvue",
avatarUrl: "http://mpvue.com/assets/logo.png" avatarUrl: "http://mpvue.com/assets/logo.png"
}, },
shareUrl: "" shareUrl: "",
};
},
onShareAppMessage(res) {
console.log("share", res, this.page);
//获取webview当前页面地址
this.shareUrl = res.webViewUrl;
return { //分享
title: this.shareUrl, // 默认是小程序的名称 shopConfig: null,
path: `/pages/index/main?share=${encodeURIComponent(this.shareUrl)}`, // 默认是当前页面 spokesmanGroupId: "1", // 代言人的集团id
imageUrl: spokesmanShopId: "2", // 代言人的门店id
"http://test-bucket-ant.oss-cn-shanghai.aliyuncs.com/product/png/026da85e-d78d-4260-bbe1-4ca5e1fed10d.png", //自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4 spokesmanRelId: "3", //代言人的id
success: function(res) { spokesmanBindId: "4", //代言人街道id
// 转发成功之后的回调 hasInvitationStatus: 0, // 邀请资格:0-不能够邀请下级,1-能够邀请下级
if (res.errMsg == "shareAppMessage:ok") { newHref:""
}
},
fail: function() {
// 转发失败之后的回调
if (res.errMsg == "shareAppMessage:fail cancel") {
// 用户取消转发
} else if (res.errMsg == "shareAppMessage:fail") {
// 转发失败,其中 detail message 为详细失败信息
}
},
complete: function() {
// 转发结束之后的回调(转发成不成功都会执行)
}
}; };
}, },
onLoad(options) { onLoad(options) {
...@@ -85,7 +38,7 @@ export default { ...@@ -85,7 +38,7 @@ export default {
this.options = options; this.options = options;
if (options.share) { if (options.share) {
//来自分享 //来自分享
this.link = options.share; this.link = decodeURIComponent(options.share);
this.page = ""; this.page = "";
this.params = ""; this.params = "";
} else if (options.from && options.from == "login") { } else if (options.from && options.from == "login") {
...@@ -139,6 +92,61 @@ export default { ...@@ -139,6 +92,61 @@ export default {
// break; // break;
// } // }
// } // }
},
async onShareAppMessage(res) {
console.log(111111111111111);
await spokesman.getSpokesmanidByShare().then(res => {
if (res.code == 200) {
if (res.data.hasInvitationStatus == 1) {
this.hasInvitationStatus = 1;
this.spokesmanGroupId = res.data.groupId;
this.spokesmanShopId = res.data.shopId;
this.spokesmanRelId = res.data.spokesmanId;
if (
res.data.spokesmanBindId ||
(res.data.spokesmanBindId != null ||
res.data.belongToShopId != 0 ||
res.data.belongToShopId != "")
) {
this.spokesmanBindId = res.data.belongToShopId;
}
if (this.spokesmanBindId) {
this.newHref = `&spokesmanGroupId=${spokesmanGroupId}&spokesmanShopId=${spokesmanShopId}&spokesmanRelId=${spokesmanRelId}&spokesmanBindId=${spokesmanBindId}`;
} else {
this.newHref = `&spokesmanGroupId=${spokesmanGroupId}&spokesmanShopId=${spokesmanShopId}&spokesmanRelId=${spokesmanRelId}`;
}
}
this.newHref = `&spokesmanGroupId=${spokesmanGroupId}&spokesmanShopId=${spokesmanShopId}&spokesmanRelId=${spokesmanRelId}`;
}
});
// await checkSpokesman();
console.log(this.newHref,'////////');
//获取webview当前页面地址
this.shareUrl = res.webViewUrl+this.newHref;
console.log("share", res, this.shareUrl);
return {
title: this.shareUrl, // 默认是小程序的名称
path: `/pages/index/main?share=${encodeURIComponent(this.shareUrl)}`, // 默认是当前页面
imageUrl:
"http://test-bucket-ant.oss-cn-shanghai.aliyuncs.com/product/png/026da85e-d78d-4260-bbe1-4ca5e1fed10d.png", //自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
success: function(res) {
// 转发成功之后的回调
if (res.errMsg == "shareAppMessage:ok") {
}
},
fail: function() {
// 转发失败之后的回调
if (res.errMsg == "shareAppMessage:fail cancel") {
// 用户取消转发
} else if (res.errMsg == "shareAppMessage:fail") {
// 转发失败,其中 detail message 为详细失败信息
}
},
complete: function() {
// 转发结束之后的回调(转发成不成功都会执行)
}
};
} }
}; };
</script> </script>
......
...@@ -94,26 +94,22 @@ export default { ...@@ -94,26 +94,22 @@ export default {
key: "openid", key: "openid",
data: res.data.data.openid data: res.data.data.openid
}); });
this.isShow = true;
if (res.data.data.isHaveUnion == "true") { if (res.data.data.isHaveUnion == "true") {
this.session_key = res.data.data.session_key; //有账号
this.isHaveUnion = true; this.isHaveUnion = true;
this.backParams += `&sessionid=${res.data.data.sessionId}`; this.backParams += `&sessionid=${res.data.data.sessionId}`;
console.log(res, "mini");
wx.setStorage({ wx.setStorage({
key: "sessionid", key: "sessionid",
data: res.data.data.sessionId data: res.data.data.sessionId
}); });
process.env.sessionid=res.data.data.sessionId;
//有账号
} else { } else {
//需要绑定 //需要绑定
this.isHaveUnion = false; this.isHaveUnion = false;
this.openid = res.data.data.openid;
this.session_key = res.data.data.session_key;
this.appid = res.data.data.appid;
} }
this.appid = res.data.data.appid;
this.session_key = res.data.data.session_key;
this.openid = res.data.data.openid;
this.isShow = true;
} }
}) })
.catch(err => {}); .catch(err => {});
...@@ -131,8 +127,6 @@ export default { ...@@ -131,8 +127,6 @@ export default {
}&params=${encodeURIComponent(this.backParams)}` }&params=${encodeURIComponent(this.backParams)}`
}); });
} else { } else {
//不是会员需要绑定手机号
this.isShowPhone = true;
var data = wx_decode( var data = wx_decode(
process.env.APPID, process.env.APPID,
this.session_key, this.session_key,
...@@ -141,7 +135,35 @@ export default { ...@@ -141,7 +135,35 @@ export default {
); );
this.unionId = data.unionId || ""; this.unionId = data.unionId || "";
this.userInfo = JSON.parse(e.target.rawData); this.userInfo = JSON.parse(e.target.rawData);
console.log("data", data, this.unionId); console.log(this.unionId, "this.unionId");
if (this.unionId) {
login
.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.backParams += `&sessionid=${res.data.data.sessionId}`;
wx.setStorage({
key: "sessionid",
data: res.data.data.sessionId
});
wx.reLaunch({
url: `../index/main?from=login&backpath=${
this.backPath
}&params=${encodeURIComponent(this.backParams)}`
});
} else {
//不是会员需要绑定手机号
this.isShowPhone = true;
}
}
})
.catch(err => {});
} else {
//不是会员需要绑定手机号
this.isShowPhone = true;
}
} }
} }
}, },
...@@ -150,14 +172,14 @@ export default { ...@@ -150,14 +172,14 @@ export default {
success: () => { success: () => {
//session_key 未过期,并且在本生命周期一直有效 //session_key 未过期,并且在本生命周期一直有效
if (e.target.errMsg == "getPhoneNumber:ok") { if (e.target.errMsg == "getPhoneNumber:ok") {
console.log("生命周期一直"); // this.isShowPhone = false;
this.isShowPhone = false;
this.phoneNumber = wx_decode( this.phoneNumber = wx_decode(
process.env.APPID, process.env.APPID,
this.session_key, this.session_key,
e.mp.detail.encryptedData, e.mp.detail.encryptedData,
e.mp.detail.iv + "" e.mp.detail.iv + ""
).phoneNumber; ).phoneNumber;
console.log("生命周期一直", this.phoneNumber);
this.bindUser(); this.bindUser();
} }
}, },
...@@ -178,15 +200,13 @@ export default { ...@@ -178,15 +200,13 @@ export default {
nickname: this.userInfo.nickName nickname: this.userInfo.nickName
}) })
.then(res => { .then(res => {
console.log(res.data, "=================-");
//绑定成功 //绑定成功
if (res.data.code == 200) { if (res.data.code == 200) {
this.backParams += `&sessionid=${res.data.data.sessionId}`; this.backParams += `&sessionid=${res.data.data}`;
wx.setStorage({ wx.setStorage({
key: "sessionid", key: "sessionid",
data: res.data.data.sessionId data: res.data.data
}); });
process.env.sessionid=res.data.data.sessionId;
wx.reLaunch({ wx.reLaunch({
url: `../index/main?from=login&backpath=${ url: `../index/main?from=login&backpath=${
this.backPath this.backPath
......
let shopMixid = "dev001"; let shopMixid = "dev001";
let sessionid = "eedbbdaf-844c-4fcc-8970-1fb92346441c";
console.log('----------------------------', process.env.sessionid);
// wx.getStore // wx.getStore
export async function requestGET(url, options) { export async function requestGET(url, options) {
...@@ -11,7 +9,7 @@ export async function requestGET(url, options) { ...@@ -11,7 +9,7 @@ export async function requestGET(url, options) {
data: options, data: options,
method: "GET", method: "GET",
header: { header: {
"Shop-Mixid": shopMixid, "Shop-Mixid": shopMixid
}, },
success: function (res) { success: function (res) {
resolve(res) resolve(res)
...@@ -31,6 +29,7 @@ export async function requestPOST(url, options) { ...@@ -31,6 +29,7 @@ export async function requestPOST(url, options) {
method: "POST", method: "POST",
header: { header: {
"Shop-Mixid": shopMixid, "Shop-Mixid": shopMixid,
"Authorization": wx.getStorageSync('sessionid') || ""
}, },
success: function (res) { success: function (res) {
resolve(res) resolve(res)
...@@ -43,13 +42,16 @@ export async function requestPOST(url, options) { ...@@ -43,13 +42,16 @@ export async function requestPOST(url, options) {
} }
export function requestPOST1(url, options) { export function requestPOST1(url, options) {
let header=getHeader();
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
wx.request({ wx.request({
url: url, url: url,
data: options, data: options,
method: "POST", method: "POST",
header: header, header: {
"Content-Type": "application/x-www-form-urlencoded",
"Shop-Mixid": shopMixid,
Authorization: wx.getStorageSync('sessionid') || ""
},
success: function (res) { success: function (res) {
resolve(res) resolve(res)
}, },
...@@ -60,15 +62,15 @@ export function requestPOST1(url, options) { ...@@ -60,15 +62,15 @@ export function requestPOST1(url, options) {
}) })
} }
function getHeader() { // function getHeader() {
let sessionid = wx.getStorageSync('sessionid'); // let sessionid = wx.getStorageSync('sessionid');
let header = { // let header = {
"Content-Type": "application/x-www-form-urlencoded", // "Content-Type": "application/x-www-form-urlencoded",
"Shop-Mixid": shopMixid, // "Shop-Mixid": shopMixid,
Authorization: sessionid // Authorization: sessionid
}; // };
// if (!sessionid) { // // if (!sessionid) {
// delete header.Authorization // // delete header.Authorization
// } // // }
return header // return header
} // }
\ No newline at end of file \ No newline at end of file
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