Commit 372ab1e2 by 宋冰琦

修复部分bug

parent 4557923c
......@@ -24,7 +24,7 @@ export default {
// }
// })
Store.commit('setAuthorization', uni.getStorageSync('Authorization'))
Store.commit('setUserInfo', uni.getStorageSync('userInfo'))
Store.commit('setUserInfo', uni.getStorageSync('UserInfo'))
// uni.showLoading({
// title: '加载中...',
// mask:true
......
......@@ -371,7 +371,7 @@ export default {
height: calc(100vh - var(--scroll-height));
overflow: auto;
width: 585.21rpx;
padding-top: 42rpx;
// padding-top: 42rpx;
}
.buiedcss{
height: calc(100vh - 376rpx - 183rpx);
......@@ -533,7 +533,9 @@ export default {
}
}
.box:first-child {
margin-top: 40rpx;
}
.box:last-child{
// padding-bottom: var(--good-bottom);
padding-bottom: 200rpx;
......
......@@ -346,14 +346,12 @@ export default {
uni.navigateTo({ url: `/orderSubPackage/pages/settlement/index?buyType=1&goodsList=1` })
}
}
let Authorization = uni.getStorageSync('Authorization');
if (!Authorization) {
this.loginByPhoneNumber(e);
const checkLocak = () => {
uni.authorize({
scope: 'scope.userLocation',
success: () => { //1.1 允许授权
console.log("允许授权位置");
settleMentFunc()
gosettleFun()
},
fail: (err) => { //1.2 拒绝授权
wx.exitMiniProgram({ success: (res) => { } })
......@@ -382,7 +380,14 @@ export default {
})
}
})
}
let Authorization = uni.getStorageSync('Authorization');
if (!Authorization) {
this.loginByPhoneNumber(e);
checkLocak()
return
}else{
checkLocak()
}
if(!this.shopState||!this.isInRange){
return
......
......@@ -86,7 +86,7 @@ export default {
return years+'.'+month+'.'+days
},
userInfoStorage() {
return this.$store.state.user.userInfo;
return uni.getStorageSync('UserInfo');
},
systemBarHeight(){
return this.$store.state.user.systemBarHeight
......@@ -170,10 +170,11 @@ export default {
const {...result} = this.userInfoStorage
const sendData ={
...result,
avatarUrl:'',
avatarUrl,
canEditBirthday:this.canEditBirthday
}
Store.commit('setUserInfo', sendData);
this.save(false)
}else{
const { avatarUrl,birthday, id, phone, sex, customerName, canEditBirthday } = this.userInfoStorage
this.canEditBirthday = canEditBirthday
......@@ -208,10 +209,11 @@ export default {
const {userInfo} = res
const Info = {
avatarUrl:userInfo.avatarUrl,
nickName:userInfo.nickName
// nickName:userInfo.nickName
}
this.userInfo.avatarUrl = Info.avatarUrl
this.userInfo.name = Info.nickName
// this.userInfo.name = Info.nickName
this.save(false)
}
})
},
......@@ -233,7 +235,7 @@ export default {
}
})
},
async save() {
async save(isReturn = true) {
const {customerName,...result} = this.userInfoStorage
if(!this.valate){
const {sex,name,id,avatarUrl} = this.userInfo
......@@ -245,8 +247,10 @@ export default {
console.log(sendData)
await Mine.editUserAvatar({avatarUrl:avatarUrl,id})
const { data } = await Mine.editUserInfo(sendData)
console.log(data)
const {code = 0} = data
if(code===200){
this.showToast({ title: '保存成功'})
const data = {
...result,
customerName:name,
......@@ -256,7 +260,8 @@ export default {
}
Store.commit('setUserInfo', data);
uni.setStorage({ key: 'userInfo', data: data });
this.showToast({ title: '保存成功'})
uni.setStorageSync('UserInfo',data)
if(isReturn){
wx.navigateBack({
delta: 1
});
......@@ -264,6 +269,7 @@ export default {
}
}
}
}
}
</script>
......
......@@ -159,7 +159,7 @@ export default {
// 商品详情页点击立即支付进入
if (option.goodsList) {
console.log('详情进入')
this.getMessageFlag()
// this.getMessageFlag()
const shopData = uni.getStorageSync('shopData');
this.shopData = shopData
this.buyType = 3;
......@@ -177,14 +177,23 @@ export default {
if (q) {
console.log('扫码进入',q)
uni.setStorageSync("selectFlag",false)
this.getMessageFlag()
// this.getMessageFlag()
this.saveGetTicket()
User.getLocation((state, params) => {
uni.removeStorageSync('shopCarInfo');
$EventBus.$emit('updateCar');
let id = decodeURIComponent(q).split('?')[1].split('=')[1];
// let id = q;
Menu.getScreenShopCar(id, params).then(res => {
// let id = decodeURIComponent(q).split('?')[1].split('=')[1];
const optionDecode = Utils.getUrlParams2(decodeURIComponent(q))
this.optionDecode = optionDecode
const loginInfo = uni.getStorageSync("loginInfo")
const { id, recognizePerson } = optionDecode
const openid = loginInfo?JSON.parse(loginInfo).openid:""
const sendData = {}
if(recognizePerson){
sendData.faceInfoId = recognizePerson,
sendData.openid = openid
}
Menu.getScreenShopCar(id, params,sendData).then(res => {
const data = JSON.parse(res.data.data);
console.log(data);
this.shopData = data.shop;
......@@ -202,7 +211,7 @@ export default {
// 购物车点击进入
if(uni.getStorageSync('shopCarInfo').length!=0) {
console.log('购物车进入')
this.getMessageFlag()
// this.getMessageFlag()
console.log(uni.getStorageSync('shopCarInfo'))
const shopData = uni.getStorageSync('shopData');
this.shopData = shopData
......@@ -256,7 +265,8 @@ export default {
sendMsgFlag1:false,
sendMsgFlag2:false,
sendMsgFlag3:false
}
},
optionDecode:{}
}
},
computed: {
......@@ -379,6 +389,10 @@ export default {
getPhoneNumber(e) {
if (e.detail.errMsg == 'getPhoneNumber:ok') {
e.loginInfo = this.loginInfo
const { recognizePerson } = this.optionDecode
if(recognizePerson) {
e.faceInfoId = recognizePerson
}
User.getPhoneNumber(e);
} else if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
this.showToast({ title: '已拒绝手机号授权', icon: 'error' })
......
......@@ -70,6 +70,7 @@ import ShopCar from '../../components/shopCar/shopCar.vue'
import Utils from '@/utils/utils'
import Menu from '@/request/menu'
import { $EventBus } from '@/utils/EventBus';
import Store from '@/store';
import Order from '@/request/order'
import OrderQrCode from '@/components/OrderQrCode'
......@@ -140,7 +141,28 @@ export default {
// this.img = 'https://s3.bmp.ovh/imgs/2022/07/02/2cfab823b35322e3.gif'
// }
},
onLoad: async function () {
onLoad: async function (option) {
// 通过扫码进入
const{q} = option
if(q){
const optionDecode = Utils.getUrlParams2(decodeURIComponent(q))
console.log(Utils.getUrlParams2(decodeURIComponent(q)),this.userInfo)
const {num,serial_no,source} = optionDecode
if(source&&this.userms) {
const sendData = {
phone:this.userInfo.phoneNumber,
user_id:this.userInfo.id,
source:source,
param:JSON.stringify({
serial_no,
num
})
}
Menu.sendUserCoupon(sendData)
}else{
Store.commit('setMenuOption', optionDecode);
}
}
uni.getSetting({
success: (res) => {
// 已经授权位置不获取默认店铺
......
......@@ -135,10 +135,12 @@ export default {
if (e.detail.errMsg == 'getPhoneNumber:ok') {
e.loginInfo = this.loginInfo
User.getPhoneNumber(e,async ()=>{
setTimeout(async () => {
const {data:couponData} = await User.getCouponNum()
this.tickNum = couponData?.data||0
});
}, 1000);
});
} else if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
this.showToast({ title: '已拒绝手机号授权', icon: 'error' })
}
......
......@@ -65,7 +65,7 @@ module.exports = (vm) => {
uni.hideLoading();
/* 对响应成功做点什么 可使用async await 做异步操作*/
if (response.data.code !== 200) {
if (response.data.code !== 200 && response.data.code !== 0) {
const phoneNumber = uni.getStorageSync('phoneNumber');
if (response.data.code == 401 && phoneNumber) {
User.getAuthorization(phoneNumber);
......
......@@ -18,11 +18,12 @@ export default {
});
},
// 获取点单屏幕的订单信息
getScreenShopCar(key, location) {
getScreenShopCar(key, location, sendData) {
return uni.$u.http
.post('/application/getData', {
key,
location,
...sendData
})
.then((res) => {
return res;
......@@ -125,5 +126,20 @@ export default {
});
return err;
});
},
// 首页调用发送优惠券接口
sendUserCoupon(data) {
return uni.$u.http
.post('/v1/issue/user/coupon', data)
.then((res) => {
return res;
})
.catch((err) => {
context.showToast({
title: '服务器错误',
icon: 'none',
});
return err;
});
}
};
......@@ -59,6 +59,7 @@ export default {
encryptedData: res.encryptedData,
})
.then((res) => {
console.log(res,'resssssssss')
const { statusCode, data } = res;
const { code, token, phoneNumber } = data;
if (statusCode == 200 && data && code == 200) {
......@@ -99,6 +100,7 @@ export default {
if(code){
this.getOpenId(code).then((res)=>{
const loginInfo = res.data.msg
uni.setStorageSync('loginInfo',loginInfo)
resolve(loginInfo)
})
}
......@@ -107,22 +109,28 @@ export default {
})
},
loginDecrypt(res){
const {faceInfoId} = res.data
return uni.$u.http.post('/weixin/decrypt ', {
session_key:res.loginInfo.session_key,
openId:res.loginInfo.openid,
encryptedData:res.data,
iv:res.iv,
faceInfoId,
source:3
})
},
// 手机号授权登录
getPhoneNumber(res, callback) {
console.log(res)
uni.setStorage({ key: 'userPhoneInfo', data: res });
Store.commit('setUserPhoneInfo', res);
uni.setStorage({ key: 'phoneInfo', data: res });
const loginInfo = res.loginInfo
const iv = res.detail.iv
const data = res.detail.encryptedData
if(res.faceInfoId){
data.faceInfoId = res.faceInfoId
}
wx.checkSession({
success: (res) => {
console.log('seeion未过期')
......@@ -136,6 +144,23 @@ export default {
}
})
},
// 首页调用发送优惠券接口
sendUserCoupon(data) {
return uni.$u.http
.post('/v1/issue/user/coupon', data)
.then((res) => {
Store.commit('setMenuOption', {});
return res;
})
.catch((err) => {
context.showToast({
title: '服务器错误',
icon: 'none',
});
Store.commit('setMenuOption', {});
return err;
});
},
// 获取用户信息
getUserInfo(data) {
return uni.$u.http
......@@ -143,9 +168,10 @@ export default {
.then((res) => {
console.log(res,data)
const { birthday, createTime, id, phone, sex, userName, avatarUrl } = res.data.data
const {avatarUrl:localAvatarUrl} = uni.getStorageSync('UserInfo')
const sendData = {
...data,
avatarUrl: avatarUrl,
avatarUrl: avatarUrl||localAvatarUrl,
sex: sex?1:0,
customerName:userName,
phone: phone.substr(0,3) + "****" + phone.substr(7),
......@@ -159,6 +185,21 @@ export default {
sendData.birthday = Date.parse(birthday)
}
Store.commit('setUserInfo', sendData);
uni.setStorageSync('UserInfo',sendData)
const MenuOption = Store.state.user.menuOption
if(JSON.stringify(MenuOption)!=='{}') {
const {num,serial_no,source} = MenuOption
const sendDataOption = {
phone:sendData.phoneNumber,
user_id:sendData.id,
source:source,
param:JSON.stringify({
serial_no,
num
})
}
this.sendUserCoupon(sendDataOption)
}
})
.catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' });
......
......@@ -6,7 +6,8 @@ const user = {
userPhoneInfo: null,
shopInfo: null, //店铺信息
orderId: null, //扫码进入时携带的订单id
systemBarHeight: {} //设备头部高度信息
systemBarHeight: {}, //设备头部高度信息
menuOption: {}
},
mutations: {
// 保存扫码进入时携带的订单id
......@@ -23,9 +24,12 @@ const user = {
},
// 设置用户允许昵称头像授权时的信息
setUserInfo(state, userInfo) {
console.log(userInfo)
state.userInfo = userInfo;
},
// 设置扫码进入的优惠券信息
setMenuOption(state, data) {
state.menuOption = data
},
// 授权手机号时允许后的信息
setUserPhoneInfo(state, userPhoneInfo) {
state.userPhoneInfo = userPhoneInfo;
......
......@@ -215,4 +215,19 @@ export default {
delta: 1
});
},
// 解析url参数
getUrlParams2(url) {
// 通过 ? 分割获取后面的参数字符串
let urlStr = url.split('?')[1]
// 创建空对象存储参数
let obj = {};
// 再通过 & 将每一个参数单独分割出来
let paramsArr = urlStr.split('&')
for(let i = 0,len = paramsArr.length;i < len;i++){
// 再通过 = 将每一个参数分割为 key:value 的形式
let arr = paramsArr[i].split('=')
obj[arr[0]] = arr[1];
}
return obj
}
};
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