Commit 9b6b9567 by 程默

fix

parent b5bd1be3
var merge = require('webpack-merge') var merge = require('webpack-merge')
var prodEnv = require('./prod.env') var prodEnv = require('./prod.env')
module.exports = merge(prodEnv, { module.exports = merge(prodEnv, {
NODE_ENV: '"development"', NODE_ENV: '"development"',
APPID:'"wx743dc2f4adb9cf01"', APPID:'"wx743dc2f4adb9cf01"',
......
...@@ -46,6 +46,11 @@ ...@@ -46,6 +46,11 @@
"glob": "^7.1.2", "glob": "^7.1.2",
"html-webpack-plugin": "^3.2.0", "html-webpack-plugin": "^3.2.0",
"http-proxy-middleware": "^0.18.0", "http-proxy-middleware": "^0.18.0",
"mkdirp": "^0.5.1",
"mpvue-loader": "^2.0.0",
"mpvue-template-compiler": "^2.0.0",
"mpvue-webpack-target": "^1.0.3",
"node-sass": "^4.12.0",
"optimize-css-assets-webpack-plugin": "^3.2.0", "optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^2.0.0", "ora": "^2.0.0",
"portfinder": "^1.0.13", "portfinder": "^1.0.13",
...@@ -55,21 +60,18 @@ ...@@ -55,21 +60,18 @@
"px2rpx-loader": "^0.1.10", "px2rpx-loader": "^0.1.10",
"relative": "^3.0.2", "relative": "^3.0.2",
"rimraf": "^2.6.0", "rimraf": "^2.6.0",
"sass-loader": "^7.3.1",
"semver": "^5.3.0", "semver": "^5.3.0",
"shelljs": "^0.8.1", "shelljs": "^0.8.1",
"uglifyjs-webpack-plugin": "^1.2.5", "uglifyjs-webpack-plugin": "^1.2.5",
"url-loader": "^1.0.1", "url-loader": "^1.0.1",
"vue-style-loader": "^4.1.0", "vue-style-loader": "^4.1.0",
"mkdirp": "^0.5.1", "webpack": "^3.11.0",
"mpvue-loader": "^2.0.0",
"mpvue-template-compiler": "^2.0.0",
"mpvue-webpack-target": "^1.0.3",
"webpack-mpvue-vendor-plugin": "^2.0.0",
"webpack-mpvue-asset-plugin": "^2.0.0",
"webpack-bundle-analyzer": "^2.2.1", "webpack-bundle-analyzer": "^2.2.1",
"webpack-dev-middleware-hard-disk": "^1.12.0", "webpack-dev-middleware-hard-disk": "^1.12.0",
"webpack-merge": "^4.1.0", "webpack-merge": "^4.1.0",
"webpack": "^3.11.0" "webpack-mpvue-asset-plugin": "^2.0.0",
"webpack-mpvue-vendor-plugin": "^2.0.0"
}, },
"engines": { "engines": {
"node": ">= 4.0.0", "node": ">= 4.0.0",
......
...@@ -44,9 +44,17 @@ ...@@ -44,9 +44,17 @@
"current": 0, "current": 0,
"list": [ "list": [
{ {
"id": 0,
"name": "pages/index/main",
"pathName": "pages/index/main",
"query": "",
"scene": null
},
{
"id": -1, "id": -1,
"name": "pages/logs/main", "name": "pages/login/main",
"pathName": "pages/logs/main", "pathName": "pages/login/main",
"query": "",
"scene": null "scene": null
} }
] ]
......
import {requestPOST,requestGET} from "@/utils/request.js";
export default {
//登录
getShopInfo(){
return requestPOST(`${process.env.OLSHOP_URL}/shop/get_shop_info`)
}
}
\ No newline at end of file
<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"> <!-- <div class="userinfo" @click="bindViewTap">
<img class="userinfo-avatar" v-if="userInfo.avatarUrl" :src="userInfo.avatarUrl" background-size="cover" /> <img class="userinfo-avatar" v-if="userInfo.avatarUrl" :src="userInfo.avatarUrl" background-size="cover" />
...@@ -37,10 +38,11 @@ ...@@ -37,10 +38,11 @@
export default { export default {
data() { data() {
return { return {
options: {},
session_key: "", session_key: "",
link: "http://localhost:3000", link: "http://localhost:3000",
page: "", page: "",
params: "?mixid=dev001&", params: "?mixid=dev001",
motto: "Hello miniprograme", motto: "Hello miniprograme",
userInfo: { userInfo: {
nickName: "mpvue", nickName: "mpvue",
...@@ -56,38 +58,33 @@ export default { ...@@ -56,38 +58,33 @@ export default {
}; };
}, },
onLoad(options) { onLoad(options) {
Object.assign(this.$data, this.$options.data());
console.log(options, "index"); console.log(options, "index");
this.initData(); this.options = options;
if (options.from=='login') { if (options.from == "login") {
this.page=decodeURIComponent(options.backpath); this.page = decodeURIComponent(options.backpath);
this.params+=decodeURIComponent(options.params); this.params += "&" + decodeURIComponent(options.params);
} else if (options.from=='wxPay') { } else if (options.from == "wxPay") {
} }
console.log("url", this.link, "-", this.page, "-", this.params);
return return;
if (options.payCallback && options.orderSn) { if (options.payCallback && options.orderSn) {
//支付页面跳转过来 //支付页面跳转过来
this.page = options.payCallback; this.page = options.payCallback;
this.params = this.params + "&orderSn=" + options.orderSn; this.params = this.params + "&orderSn=" + options.orderSn;
} else if (options.scene) {//扫码 } else if (options.scene) {
//扫码
// options 中的scene需要使用decodeURIComponent才能获取到生成二维码时传入的scene // options 中的scene需要使用decodeURIComponent才能获取到生成二维码时传入的scene
var scene = decodeURIComponent(options.scene); //参数二维码传递过来的参数 var scene = decodeURIComponent(options.scene); //参数二维码传递过来的参数
var query = options.query.dentistId; // 参数二维码传递过来的场景参数 var query = options.query.dentistId; // 参数二维码传递过来的场景参数
}else if(options){ } else if (options) {
} }
}, },
components: { components: {
// card // card
}, },
methods: { methods: {
initData(){
this.page="";
this.params="?mixid=dev001&";
},
bindViewTap() { bindViewTap() {
const url = "../logs/main"; const url = "../logs/main";
if (mpvuePlatform === "wx") { if (mpvuePlatform === "wx") {
...@@ -101,12 +98,24 @@ export default { ...@@ -101,12 +98,24 @@ export default {
// throw {message: 'custom test'} // throw {message: 'custom test'}
}, },
getMessage(res) { getMessage(res) {
console.log("h5消息"); console.log("h5消息", res);
} }
}, },
onUnload() {
console.log('卸载----------------')
//控制返回按钮
if (this.options.backpath) {
switch (this.options.backpath) {
case "/login/accountLogin":
wx.redirectTo({
url: `../login/main`
});
break;
created() { default:
// let app = getApp() break;
}
}
} }
}; };
</script> </script>
......
<template> <template>
<div class="domain"> <div class="domain">
<button 1234
v-if="getPhone" <div class="toCLogin" v-if="!isShowPhone">
open-type="getPhoneNumber" <p class="shopName" v-if="shopName">{{shopName}}</p>
@getphonenumber="getPhoneNumber" <div class="btn_info">
class="login" <button class="btn" open-type="getUserInfo" @getuserinfo="getUserInfo">微信登录</button>
>微信手机号快捷登录</button> </div>
<div v-else> <div class="enterpriseLogin" @click="eLogin">企业员工登录</div>
</div>
<div class="toCLogin" v-if="isShowPhone">
<div class="btn_info">
<button class="btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">绑定手机号</button>
</div>
</div>
<!-- <div v-else>
<mp-loading <mp-loading
:duration="900" :duration="900"
ext-class="demo0" ext-class="demo0"
...@@ -14,7 +22,7 @@ ...@@ -14,7 +22,7 @@
:show="show" :show="show"
:animated="animated" :animated="animated"
>加载中</mp-loading> >加载中</mp-loading>
</div> </div>-->
</div> </div>
</template> </template>
...@@ -22,27 +30,36 @@ ...@@ -22,27 +30,36 @@
import { serialize } from "@/utils/index"; import { serialize } from "@/utils/index";
import { wx_decode } from "@/utils/wxIndex.js"; import { wx_decode } from "@/utils/wxIndex.js";
import login from "@/api/login"; import login from "@/api/login";
import shop from "@/api/shop";
var WXBizDataCrypt = require("@/utils/WXBizDataCrypt"); var WXBizDataCrypt = require("@/utils/WXBizDataCrypt");
export default { export default {
components: { components: {
// card // card
}, },
data() { data() {
return { return {
session_key: "",
shopName: "",
isShow: true,
isShowPhone: false,
getPhone: false, getPhone: false,
openid: "", openid: "",
appid: "",
phoneNumber: "", phoneNumber: "",
logs: [], logs: [],
tips: "请稍后", tips: "请稍后",
show: true, show: true,
animated: true, animated: true,
backPath: "", backPath: "",
backParams: "" backParams: "",
isHaveUnion: "",
unionId: "",
userInfo: ""
}; };
}, },
created() {}, created() {},
onLoad(options) { onLoad(options) {
Object.assign(this.$data, this.$options.data()); //mpvue 的混合周期 使用小程序生命周期数据未初始化
if (options.back) { if (options.back) {
this.backPath = options.back; this.backPath = options.back;
} }
...@@ -50,10 +67,19 @@ export default { ...@@ -50,10 +67,19 @@ export default {
this.backParams = serialize(options.params); this.backParams = serialize(options.params);
} }
console.log(options, "登录页面", this.backPath, this.backParams); console.log(options, "登录页面", this.backPath, this.backParams);
this.getshop();
this.init(); this.init();
}, },
methods: { methods: {
getshop() {
shop.getShopInfo().then(res => {
console.log(res, "shop");
if (res.data.code == 200) {
this.shopName = res.data.data.shopName;
}
});
},
init() { init() {
wx.login({ wx.login({
success: res => { success: res => {
...@@ -61,25 +87,26 @@ export default { ...@@ -61,25 +87,26 @@ export default {
login login
.miniLogin({ code: res.code }) .miniLogin({ code: res.code })
.then(res => { .then(res => {
console.log(res);
if (res.data.code == 200) { if (res.data.code == 200) {
if (res.data.data.isHaveUnion == "true") { if (res.data.data.isHaveUnion == "true") {
this.session_key = res.data.data.session_key;
this.isHaveUnion = true;
this.backParams += `&sessionid=${res.data.data.sessionId}`;
console.log(this.backParams, "mini");
//有账号 //有账号
wx.setStorage({ // wx.setStorage({
key: "sessionId", // key: "sessionId",
data: res.data.data.sessionId // data: res.data.data.sessionId
}); // });
wx.redirectTo({
url: `../index/main?from=login&backpath=${
this.backPath
}&params=${this.backParams}`
});
} else { } else {
//需要绑定 //需要绑定
this.getPhone = true; this.isHaveUnion = false;
this.openid = res.data.data.openid; this.openid = res.data.data.openid;
this.session_key = res.data.data.session_key;
this.appid = res.data.data.appid;
this.isShow = true;
} }
this.session_key = res.data.data.session_key;
} }
}) })
.catch(err => {}); .catch(err => {});
...@@ -87,11 +114,36 @@ export default { ...@@ -87,11 +114,36 @@ export default {
} }
}); });
}, },
getUserInfo: function(e) {
if (e.target.errMsg == "getUserInfo:ok") {
if (this.isHaveUnion) {
//是会员 直接登录
wx.redirectTo({
url: `../index/main?from=login&backpath=${
this.backPath
}&params=${encodeURIComponent(this.backParams)}`
});
} else {
//不是会员需要绑定手机号
this.isShowPhone = true;
var data = wx_decode(
process.env.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("data", data, this.unionId);
}
}
},
getPhoneNumber(e) { getPhoneNumber(e) {
wx.checkSession({ wx.checkSession({
success: () => { success: () => {
//session_key 未过期,并且在本生命周期一直有效 //session_key 未过期,并且在本生命周期一直有效
if (e.target.errMsg == "getPhoneNumber:ok") { if (e.target.errMsg == "getPhoneNumber:ok") {
this.isShowPhone = false;
this.phoneNumber = wx_decode( this.phoneNumber = wx_decode(
process.env.APPID, process.env.APPID,
this.session_key, this.session_key,
...@@ -99,15 +151,6 @@ export default { ...@@ -99,15 +151,6 @@ export default {
e.mp.detail.iv + "" e.mp.detail.iv + ""
).phoneNumber; ).phoneNumber;
this.bindUser(); this.bindUser();
console.log(this.phoneNumber, "daadadadad");
} else if (e.target.errMsg == "getPhoneNumber:fail user deny") {
console.log("用户取消", this.backParams);
wx.redirectTo({
url: `../index/main?from=login&backpath=${this.backPath}&params=${
encodeURIComponent(this.backParams)
}`
});
} else {
} }
}, },
fail: () => { fail: () => {
...@@ -120,28 +163,95 @@ export default { ...@@ -120,28 +163,95 @@ export default {
login login
.bindUser({ .bindUser({
openId: this.openid, openId: this.openid,
phoneNumber: this.phoneNumber phoneNumber: this.phoneNumber,
unionId: this.unionId,
headImgUrl: this.userInfo.avatarUrl,
gender: this.userInfo.gender,
nickname: this.userInfo.nickName
}) })
.then(res => { .then(res => {
//登录成功 //绑定成功
console.log(res, "binduser"); if (res.data.code == 200) {
wx.setStorage({ this.backParams += `&sessionid=${res.data.data.sessionId}`;
key: "sessionId", // console.log(this.backParams, "binduser");
data: res.data.data.sessionId // wx.setStorage({
}); // key: "sessionId",
// data: res.data.data
// });
wx.redirectTo({
url: `../index/main?from=login&backpath=${
this.backPath
}&params=${encodeURIComponent(this.backParams)}`
});
}
}) })
.catch(err => { .catch(err => {
console.log(err, "bindusererr"); console.log(err, "bindusererr");
}); });
},
backMainHandle() {
wx.redirectTo({
url: `../index/main?from=login&backpath=${
this.backPath
}&params=${encodeURIComponent(this.backParams)}`
});
},
eLogin() {//企业员工登录
wx.redirectTo({
url: `../index/main?from=login&backpath=/login/accountLogin`
});
} }
} }
}; };
</script> </script>
<style> <style lang="scss" scoped>
.login { .domain {
background-color: green; .toCLogin {
margin: 30px; display: flex;
color: #fff; width: 100%;
// padding: 0 35px;
margin-top: 20%;
flex-direction: column;
justify-content: space-around;
align-items: center;
.shopName {
font-size: 16px;
font-weight: bold;
color: #333;
}
.btn_info {
margin: 0 auto;
color: #fff;
align-items: center;
justify-content: space-around;
.btn {
margin-top: 180px;
background-color: #01d10c;
color: #fff;
height: 45px;
width: 200px;
border-radius: 90px;
}
}
.enterpriseLogin {
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
color: #333;
text-decoration: underline;
font-size: 15px;
}
}
.bind {
}
} }
// .login {
// background-color: green;
// margin: 30px;
// color: #fff;
// }
</style> </style>
{ {
"navigationBarTitleText": "查看启动日志"
} }
let shopMixid= "dev001";
export function requestGET(url, options) { export function requestGET(url, options) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
wx.request({ wx.request({
...@@ -6,7 +7,7 @@ export function requestGET(url, options) { ...@@ -6,7 +7,7 @@ export function requestGET(url, options) {
method: "GET", method: "GET",
header: { header: {
"Content-Type": "application/x-www-form-urlencoded", "Content-Type": "application/x-www-form-urlencoded",
"Shop-Mixid": "dev001", "Shop-Mixid": shopMixid,
Authorization: "ce9d0ca7-ba9b-4951-9c42-47cd9b5e4f42" Authorization: "ce9d0ca7-ba9b-4951-9c42-47cd9b5e4f42"
}, },
success: function (res) { success: function (res) {
...@@ -26,8 +27,7 @@ export function requestPOST(url, options) { ...@@ -26,8 +27,7 @@ export function requestPOST(url, options) {
data: options, data: options,
method: "POST", method: "POST",
header: { header: {
"Shop-Mixid": shopMixid,
"Shop-Mixid": "dev001",
Authorization: "ce9d0ca7-ba9b-4951-9c42-47cd9b5e4f42" Authorization: "ce9d0ca7-ba9b-4951-9c42-47cd9b5e4f42"
}, },
success: function (res) { success: function (res) {
......
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