Commit 9b6b9567 by 程默

fix

parent b5bd1be3
var merge = require('webpack-merge')
var prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
APPID:'"wx743dc2f4adb9cf01"',
......
......@@ -46,6 +46,11 @@
"glob": "^7.1.2",
"html-webpack-plugin": "^3.2.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",
"ora": "^2.0.0",
"portfinder": "^1.0.13",
......@@ -55,21 +60,18 @@
"px2rpx-loader": "^0.1.10",
"relative": "^3.0.2",
"rimraf": "^2.6.0",
"sass-loader": "^7.3.1",
"semver": "^5.3.0",
"shelljs": "^0.8.1",
"uglifyjs-webpack-plugin": "^1.2.5",
"url-loader": "^1.0.1",
"vue-style-loader": "^4.1.0",
"mkdirp": "^0.5.1",
"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": "^3.11.0",
"webpack-bundle-analyzer": "^2.2.1",
"webpack-dev-middleware-hard-disk": "^1.12.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": {
"node": ">= 4.0.0",
......
......@@ -44,9 +44,17 @@
"current": 0,
"list": [
{
"id": 0,
"name": "pages/index/main",
"pathName": "pages/index/main",
"query": "",
"scene": null
},
{
"id": -1,
"name": "pages/logs/main",
"pathName": "pages/logs/main",
"name": "pages/login/main",
"pathName": "pages/login/main",
"query": "",
"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>
<div @click="clickHandle">
加载中。。。
<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" />
......@@ -37,10 +38,11 @@
export default {
data() {
return {
options: {},
session_key: "",
link: "http://localhost:3000",
page: "",
params: "?mixid=dev001&",
params: "?mixid=dev001",
motto: "Hello miniprograme",
userInfo: {
nickName: "mpvue",
......@@ -56,38 +58,33 @@ export default {
};
},
onLoad(options) {
Object.assign(this.$data, this.$options.data());
console.log(options, "index");
this.initData();
if (options.from=='login') {
this.page=decodeURIComponent(options.backpath);
this.params+=decodeURIComponent(options.params);
} else if (options.from=='wxPay') {
this.options = options;
if (options.from == "login") {
this.page = decodeURIComponent(options.backpath);
this.params += "&" + decodeURIComponent(options.params);
} else if (options.from == "wxPay") {
}
return
console.log("url", this.link, "-", this.page, "-", this.params);
return;
if (options.payCallback && options.orderSn) {
//支付页面跳转过来
this.page = options.payCallback;
this.params = this.params + "&orderSn=" + options.orderSn;
} else if (options.scene) {//扫码
} else if (options.scene) {
//扫码
// options 中的scene需要使用decodeURIComponent才能获取到生成二维码时传入的scene
var scene = decodeURIComponent(options.scene); //参数二维码传递过来的参数
var query = options.query.dentistId; // 参数二维码传递过来的场景参数
}else if(options){
} else if (options) {
}
},
components: {
// card
},
methods: {
initData(){
this.page="";
this.params="?mixid=dev001&";
},
bindViewTap() {
const url = "../logs/main";
if (mpvuePlatform === "wx") {
......@@ -101,12 +98,24 @@ export default {
// throw {message: 'custom test'}
},
getMessage(res) {
console.log("h5消息");
console.log("h5消息", res);
}
},
created() {
// let app = getApp()
onUnload() {
console.log('卸载----------------')
//控制返回按钮
if (this.options.backpath) {
switch (this.options.backpath) {
case "/login/accountLogin":
wx.redirectTo({
url: `../login/main`
});
break;
default:
break;
}
}
}
};
</script>
......
<template>
<div class="domain">
<button
v-if="getPhone"
open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber"
class="login"
>微信手机号快捷登录</button>
<div v-else>
1234
<div class="toCLogin" v-if="!isShowPhone">
<p class="shopName" v-if="shopName">{{shopName}}</p>
<div class="btn_info">
<button class="btn" open-type="getUserInfo" @getuserinfo="getUserInfo">微信登录</button>
</div>
<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
:duration="900"
ext-class="demo0"
......@@ -14,7 +22,7 @@
:show="show"
:animated="animated"
>加载中</mp-loading>
</div>
</div>-->
</div>
</template>
......@@ -22,27 +30,36 @@
import { serialize } from "@/utils/index";
import { wx_decode } from "@/utils/wxIndex.js";
import login from "@/api/login";
import shop from "@/api/shop";
var WXBizDataCrypt = require("@/utils/WXBizDataCrypt");
export default {
components: {
// card
},
data() {
return {
session_key: "",
shopName: "",
isShow: true,
isShowPhone: false,
getPhone: false,
openid: "",
appid: "",
phoneNumber: "",
logs: [],
tips: "请稍后",
show: true,
animated: true,
backPath: "",
backParams: ""
backParams: "",
isHaveUnion: "",
unionId: "",
userInfo: ""
};
},
created() {},
onLoad(options) {
Object.assign(this.$data, this.$options.data()); //mpvue 的混合周期 使用小程序生命周期数据未初始化
if (options.back) {
this.backPath = options.back;
}
......@@ -50,10 +67,19 @@ export default {
this.backParams = serialize(options.params);
}
console.log(options, "登录页面", this.backPath, this.backParams);
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;
}
});
},
init() {
wx.login({
success: res => {
......@@ -61,25 +87,26 @@ export default {
login
.miniLogin({ code: res.code })
.then(res => {
console.log(res);
if (res.data.code == 200) {
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({
key: "sessionId",
data: res.data.data.sessionId
});
wx.redirectTo({
url: `../index/main?from=login&backpath=${
this.backPath
}&params=${this.backParams}`
});
// wx.setStorage({
// key: "sessionId",
// data: res.data.data.sessionId
// });
} else {
//需要绑定
this.getPhone = true;
this.isHaveUnion = false;
this.openid = res.data.data.openid;
}
this.session_key = res.data.data.session_key;
this.appid = res.data.data.appid;
this.isShow = true;
}
}
})
.catch(err => {});
......@@ -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) {
wx.checkSession({
success: () => {
//session_key 未过期,并且在本生命周期一直有效
if (e.target.errMsg == "getPhoneNumber:ok") {
this.isShowPhone = false;
this.phoneNumber = wx_decode(
process.env.APPID,
this.session_key,
......@@ -99,15 +151,6 @@ export default {
e.mp.detail.iv + ""
).phoneNumber;
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: () => {
......@@ -120,28 +163,95 @@ export default {
login
.bindUser({
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 => {
//登录成功
console.log(res, "binduser");
wx.setStorage({
key: "sessionId",
data: res.data.data.sessionId
//绑定成功
if (res.data.code == 200) {
this.backParams += `&sessionid=${res.data.data.sessionId}`;
// console.log(this.backParams, "binduser");
// wx.setStorage({
// key: "sessionId",
// data: res.data.data
// });
wx.redirectTo({
url: `../index/main?from=login&backpath=${
this.backPath
}&params=${encodeURIComponent(this.backParams)}`
});
}
})
.catch(err => {
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>
<style>
.login {
background-color: green;
margin: 30px;
<style lang="scss" scoped>
.domain {
.toCLogin {
display: flex;
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>
{
"navigationBarTitleText": "查看启动日志"
}
let shopMixid= "dev001";
export function requestGET(url, options) {
return new Promise((resolve, reject) => {
wx.request({
......@@ -6,7 +7,7 @@ export function requestGET(url, options) {
method: "GET",
header: {
"Content-Type": "application/x-www-form-urlencoded",
"Shop-Mixid": "dev001",
"Shop-Mixid": shopMixid,
Authorization: "ce9d0ca7-ba9b-4951-9c42-47cd9b5e4f42"
},
success: function (res) {
......@@ -26,8 +27,7 @@ export function requestPOST(url, options) {
data: options,
method: "POST",
header: {
"Shop-Mixid": "dev001",
"Shop-Mixid": shopMixid,
Authorization: "ce9d0ca7-ba9b-4951-9c42-47cd9b5e4f42"
},
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