mirror of
https://gitee.com/java110/WechatOwnerService.git
synced 2026-02-23 21:36:38 +08:00
业主小程序支持一键登陆
This commit is contained in:
parent
fdbd488cac
commit
c260a49ec6
@ -433,3 +433,34 @@ export function ownerRegiter(_data){
|
||||
}
|
||||
|
||||
|
||||
export function wechatLogin(_data) {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
requestNoAuth({
|
||||
url: url.phoneWechatLogin,
|
||||
method: "POST",
|
||||
data: _data, //动态数据
|
||||
success: function(res) {
|
||||
let _json = res.data;
|
||||
if (_json.code != 0) {
|
||||
reject(_json.msg);
|
||||
return;
|
||||
}
|
||||
//todo 保存业主信息
|
||||
uni.setStorageSync("userInfo",_json.data);
|
||||
uni.setStorageSync("currentCommunityInfo",{
|
||||
communityId:_json.data.communityId,
|
||||
communityName:_json.data.communityName,
|
||||
sCommunityTel:_json.data.communityTel,
|
||||
communityQrCode:_json.data.communityQrCode
|
||||
});
|
||||
resolve(_json.data);
|
||||
},
|
||||
fail: function(e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="order_box">
|
||||
<!-- <view class="order_box">
|
||||
<view class="order_title">我的订单</view>
|
||||
<view class="order_list">
|
||||
<view class="list">
|
||||
@ -22,7 +22,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<auth-owner-dialog ref="authOwnerDialogRef"></auth-owner-dialog>
|
||||
</view>
|
||||
|
||||
125
components/user/wechat-login.vue
Normal file
125
components/user/wechat-login.vue
Normal file
@ -0,0 +1,125 @@
|
||||
<template>
|
||||
<view class="login-container margin-top-sm">
|
||||
<!-- 确保方法名一致 -->
|
||||
<button open-type="getPhoneNumber" @getphonenumber="_getPhoneNumber" class="login-btn">
|
||||
微信手机号一键登录
|
||||
</button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
wechatLogin
|
||||
} from '@/api/user/userApi.js';
|
||||
import {
|
||||
saveOwnerStorage,
|
||||
saveUserLoginInfo,
|
||||
removeUserLoginInfo,
|
||||
getLoginFlag
|
||||
} from '@/lib/java110/utils/StorageUtil.js';
|
||||
export default {
|
||||
name: "wechatLogin",
|
||||
data() {
|
||||
return {
|
||||
encryptedData: '',
|
||||
iv: '',
|
||||
code: '',
|
||||
appId:''
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
_initWechatLogin: function() {
|
||||
let _that = this;
|
||||
uni.login({
|
||||
success: res => {
|
||||
if (res.code) {
|
||||
_that.code = res.code;
|
||||
let accountInfo = uni.getAccountInfoSync();
|
||||
_that.appId = accountInfo.miniProgram.appId;
|
||||
} else {
|
||||
console.error('获取登录code失败:', res);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
_getPhoneNumber(e) {
|
||||
if (e.detail.errMsg === "getPhoneNumber:ok") {
|
||||
// 获取到加密数据
|
||||
const {
|
||||
encryptedData,
|
||||
iv
|
||||
} = e.detail;
|
||||
// 发送到后端解密
|
||||
this.encryptedData = encryptedData;
|
||||
this.iv = iv;
|
||||
this._loginByPhoneNumber();
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '获取手机号失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
_loginByPhoneNumber() {
|
||||
wechatLogin({
|
||||
encryptedData: this.encryptedData,
|
||||
iv: this.iv,
|
||||
code: this.code,
|
||||
appId:this.appId
|
||||
})
|
||||
.then(_user => {
|
||||
//todo 保存登录信息
|
||||
saveUserLoginInfo(_user.userId, _user.token, _user.key);
|
||||
uni.navigateTo({
|
||||
url:'/pages/login/loginInitWechat?communityId='+_user.communityId
|
||||
})
|
||||
}, err => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: err
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 80rpx 40rpx;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
font-size: 40rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 80rpx;
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
line-height: 90rpx;
|
||||
border-radius: 10rpx;
|
||||
background: #07C160;
|
||||
color: white;
|
||||
font-size: 32rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.wechat-icon {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
margin-right: 15rpx;
|
||||
}
|
||||
|
||||
.phone-display {
|
||||
margin-top: 60rpx;
|
||||
font-size: 32rpx;
|
||||
color: #666;
|
||||
}
|
||||
</style>
|
||||
@ -15,7 +15,7 @@ const baseUrl = '/';
|
||||
|
||||
// #ifndef H5
|
||||
//服务器域名 小程序 或者 app 时 后端地址
|
||||
const baseUrl = 'http://wuye.heyiiot.com/';
|
||||
const baseUrl = 'http://127.0.0.1:8008/';
|
||||
// #endif
|
||||
|
||||
let commonBaseUrl = 'http://wuye.heyiiot.com/';
|
||||
|
||||
@ -8,6 +8,7 @@ export default {
|
||||
loginUrl: baseUrl + 'app/loginWx',
|
||||
getWxPhoto: baseUrl + 'app/getWxPhoto',
|
||||
loginOwnerUrl: baseUrl + 'app/loginOwner',
|
||||
phoneWechatLogin: baseUrl + "app/login.phoneWechatLogin",
|
||||
areaUrl: baseUrl + "app/area.listAreas",
|
||||
GetNoticeListUrl: baseUrl + 'app/notice.listNotices', //公告接口
|
||||
saveOwnerRepair: baseUrl + 'app/ownerRepair.saveOwnerRepair', //报修
|
||||
@ -15,7 +16,7 @@ export default {
|
||||
saveOwner: baseUrl + 'app/owner.saveOwnerMember', //家庭成员列表
|
||||
queryOwnerMembers: baseUrl + 'app/owner.queryAppOwnerMembers', //投诉建议列表
|
||||
listComplaints: baseUrl + 'app/complaint.queryUserComplaints', //添加投诉建议
|
||||
listComplaintEvent: baseUrl + 'app/complaint.listComplaintEvent', //添加投诉建议
|
||||
listComplaintEvent: baseUrl + 'app/complaint.listPhoneComplaintEvent', //添加投诉建议
|
||||
saveComplaintAppraise: baseUrl + 'app/complaintAppraise.saveComplaintAppraise', //添加投诉建议
|
||||
listComplaintType: baseUrl + 'app/complaint.queryPhoneComplaintType', //查询投诉类型
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@
|
||||
"quickapp" : {},
|
||||
"mp-weixin" : {
|
||||
"usingComponents" : true,
|
||||
"appid" : "wx0a08dd8124d7f04f",
|
||||
"appid" : "wx702e87d56708f858",
|
||||
"setting" : {
|
||||
"urlCheck" : false,
|
||||
"es6" : false
|
||||
|
||||
12
pages.json
12
pages.json
@ -1119,12 +1119,12 @@
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
"pagePath": "pages/mall/mall",
|
||||
"text": "商圈",
|
||||
"iconPath": "static/images/market.png",
|
||||
"selectedIconPath": "static/images/market-selected.png"
|
||||
},
|
||||
// {
|
||||
// "pagePath": "pages/mall/mall",
|
||||
// "text": "商圈",
|
||||
// "iconPath": "static/images/market.png",
|
||||
// "selectedIconPath": "static/images/market-selected.png"
|
||||
// },
|
||||
|
||||
{
|
||||
"pagePath": "pages/my/my",
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view>
|
||||
<service-property></service-property>
|
||||
<service-homemaking></service-homemaking>
|
||||
<!-- <service-homemaking></service-homemaking> -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
@ -23,17 +23,23 @@
|
||||
<view class="cu-form-group border-bottom">
|
||||
<view class="title">验证码</view>
|
||||
<input v-model="password" placeholder="请输入短信验证码" name="input"></input>
|
||||
<button class='cu-btn bg-green shadow' :disabled="btnDisabled"
|
||||
<button class='cu-btn bg-blue shadow' :disabled="btnDisabled"
|
||||
@click="sendMsgCode()">{{btnValue}}</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="padding flex flex-direction margin-top">
|
||||
<button class="cu-btn bg-green lg" @click="_doLogin()">登录</button>
|
||||
<button class="cu-btn line-orange margin-tb-sm lg" @click="_doRegister()">注册</button>
|
||||
|
||||
<view class="text-center margin-top-sm text-green" @click="_doLoginPhone()">{{phoneLoginName}}</view>
|
||||
<button class="cu-btn bg-blue lg" @click="_doLogin()">登录</button>
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<wechat-login ref="wechatLoginRef"></wechat-login>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
<!-- #ifdef H5 -->
|
||||
<view class="padding-lr flex justify-between">
|
||||
<view class="text-green" @click="_doLoginPhone()">{{phoneLoginName}}</view>
|
||||
<view class="text-green" @click="_doRegister()">注册</view>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
|
||||
</view>
|
||||
</template>
|
||||
@ -60,7 +66,8 @@
|
||||
getWAppId,
|
||||
saveWAppId,
|
||||
getLoginFlag
|
||||
} from '@/lib/java110/utils/StorageUtil.js'
|
||||
} from '@/lib/java110/utils/StorageUtil.js';
|
||||
import wechatLogin from '@/components/user/wechat-login.vue';
|
||||
|
||||
const constant = context.constant;
|
||||
const factory = context.factory;
|
||||
@ -90,6 +97,14 @@
|
||||
if (wAppId) {
|
||||
uni.setStorageSync(constant.mapping.W_APP_ID, wAppId);
|
||||
}
|
||||
// #ifdef MP-WEIXIN
|
||||
setTimeout(function(){
|
||||
that.$refs.wechatLoginRef._initWechatLogin();
|
||||
},1000)
|
||||
// #endif
|
||||
},
|
||||
components:{
|
||||
wechatLogin
|
||||
},
|
||||
methods: {
|
||||
_doLogin: function() {
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="padding flex flex-direction margin-top">
|
||||
<button class="cu-btn bg-green lg" @click="_doRegister()">绑定</button>
|
||||
<button class="cu-btn bg-green lg" @click="_doRegister()">提交</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
import {
|
||||
getCommunityId
|
||||
} from '../../api/community/communityApi.js';
|
||||
import {getRooms} from '@/api/room/roomApi.js';
|
||||
import context from '../../lib/java110/Java110Context.js';
|
||||
const constant = context.constant;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user