Commit 372ab1e2 by 宋冰琦

修复部分bug

parent 4557923c
...@@ -24,7 +24,7 @@ export default { ...@@ -24,7 +24,7 @@ export default {
// } // }
// }) // })
Store.commit('setAuthorization', uni.getStorageSync('Authorization')) Store.commit('setAuthorization', uni.getStorageSync('Authorization'))
Store.commit('setUserInfo', uni.getStorageSync('userInfo')) Store.commit('setUserInfo', uni.getStorageSync('UserInfo'))
// uni.showLoading({ // uni.showLoading({
// title: '加载中...', // title: '加载中...',
// mask:true // mask:true
......
...@@ -371,7 +371,7 @@ export default { ...@@ -371,7 +371,7 @@ export default {
height: calc(100vh - var(--scroll-height)); height: calc(100vh - var(--scroll-height));
overflow: auto; overflow: auto;
width: 585.21rpx; width: 585.21rpx;
padding-top: 42rpx; // padding-top: 42rpx;
} }
.buiedcss{ .buiedcss{
height: calc(100vh - 376rpx - 183rpx); height: calc(100vh - 376rpx - 183rpx);
...@@ -533,7 +533,9 @@ export default { ...@@ -533,7 +533,9 @@ export default {
} }
} }
.box:first-child {
margin-top: 40rpx;
}
.box:last-child{ .box:last-child{
// padding-bottom: var(--good-bottom); // padding-bottom: var(--good-bottom);
padding-bottom: 200rpx; padding-bottom: 200rpx;
......
...@@ -326,63 +326,68 @@ export default { ...@@ -326,63 +326,68 @@ export default {
} }
}, },
async getallNum(e) { async getallNum(e) {
const gosettleFun = async ()=> { const gosettleFun = async ()=> {
const { goods } = this; const { goods } = this;
const { data } = await Order.checkSku({skuId:goods.skuId}) const { data } = await Order.checkSku({skuId:goods.skuId})
const {state,goods:newgoods} = data.data const {state,goods:newgoods} = data.data
const newInfo = JSON.parse(JSON.stringify(newgoods)) const newInfo = JSON.parse(JSON.stringify(newgoods))
newInfo.category = this.goodInfo.category newInfo.category = this.goodInfo.category
this.goodInfo = {...newInfo} this.goodInfo = {...newInfo}
this.initInfo(this.goodInfo) this.initInfo(this.goodInfo)
if(state == 2){ if(state == 2){
this.showToast({ title: '本商品已经售罄', icon: 'none' }); this.showToast({ title: '本商品已经售罄', icon: 'none' });
// this.getMenuList() // this.getMenuList()
return; return;
}else{ }else{
goods.num = this.size goods.num = this.size
Utils.addGoods(goods) Utils.addGoods(goods)
uni.navigateTo({ url: `/orderSubPackage/pages/settlement/index?buyType=1&goodsList=1` }) uni.navigateTo({ url: `/orderSubPackage/pages/settlement/index?buyType=1&goodsList=1` })
}
}
const checkLocak = () => {
uni.authorize({
scope: 'scope.userLocation',
success: () => { //1.1 允许授权
console.log("允许授权位置");
gosettleFun()
},
fail: (err) => { //1.2 拒绝授权
wx.exitMiniProgram({ success: (res) => { } })
console.log("获取位置失败")
uni.showModal({
content: '检测到您没打开地理位置权限,是否去设置打开?',
confirmText: "确认",
cancelText: '取消',
success: (res) => {
if (res.confirm) {
uni.openSetting({//opensetting是调起设置页面的
success: (res) => {
console.log(res)
if(res.authSetting['scope.userLocation'] == true){//判断res.authsetting的值是true还是false
gosettleFun()
}else{
// console.log("什么也不做");
}
}
})
} else {
console.log('取消');
return false;
}
}
})
}
})
} }
}
let Authorization = uni.getStorageSync('Authorization'); let Authorization = uni.getStorageSync('Authorization');
if (!Authorization) { if (!Authorization) {
this.loginByPhoneNumber(e); this.loginByPhoneNumber(e);
uni.authorize({ checkLocak()
scope: 'scope.userLocation',
success: () => { //1.1 允许授权
console.log("允许授权位置");
settleMentFunc()
},
fail: (err) => { //1.2 拒绝授权
wx.exitMiniProgram({ success: (res) => { } })
console.log("获取位置失败")
uni.showModal({
content: '检测到您没打开地理位置权限,是否去设置打开?',
confirmText: "确认",
cancelText: '取消',
success: (res) => {
if (res.confirm) {
uni.openSetting({//opensetting是调起设置页面的
success: (res) => {
console.log(res)
if(res.authSetting['scope.userLocation'] == true){//判断res.authsetting的值是true还是false
gosettleFun()
}else{
// console.log("什么也不做");
}
}
})
} else {
console.log('取消');
return false;
}
}
})
}
})
return return
}else{
checkLocak()
} }
if(!this.shopState||!this.isInRange){ if(!this.shopState||!this.isInRange){
return return
......
...@@ -86,7 +86,7 @@ export default { ...@@ -86,7 +86,7 @@ export default {
return years+'.'+month+'.'+days return years+'.'+month+'.'+days
}, },
userInfoStorage() { userInfoStorage() {
return this.$store.state.user.userInfo; return uni.getStorageSync('UserInfo');
}, },
systemBarHeight(){ systemBarHeight(){
return this.$store.state.user.systemBarHeight return this.$store.state.user.systemBarHeight
...@@ -170,10 +170,11 @@ export default { ...@@ -170,10 +170,11 @@ export default {
const {...result} = this.userInfoStorage const {...result} = this.userInfoStorage
const sendData ={ const sendData ={
...result, ...result,
avatarUrl:'', avatarUrl,
canEditBirthday:this.canEditBirthday canEditBirthday:this.canEditBirthday
} }
Store.commit('setUserInfo', sendData); Store.commit('setUserInfo', sendData);
this.save(false)
}else{ }else{
const { avatarUrl,birthday, id, phone, sex, customerName, canEditBirthday } = this.userInfoStorage const { avatarUrl,birthday, id, phone, sex, customerName, canEditBirthday } = this.userInfoStorage
this.canEditBirthday = canEditBirthday this.canEditBirthday = canEditBirthday
...@@ -208,10 +209,11 @@ export default { ...@@ -208,10 +209,11 @@ export default {
const {userInfo} = res const {userInfo} = res
const Info = { const Info = {
avatarUrl:userInfo.avatarUrl, avatarUrl:userInfo.avatarUrl,
nickName:userInfo.nickName // nickName:userInfo.nickName
} }
this.userInfo.avatarUrl = Info.avatarUrl this.userInfo.avatarUrl = Info.avatarUrl
this.userInfo.name = Info.nickName // this.userInfo.name = Info.nickName
this.save(false)
} }
}) })
}, },
...@@ -233,7 +235,7 @@ export default { ...@@ -233,7 +235,7 @@ export default {
} }
}) })
}, },
async save() { async save(isReturn = true) {
const {customerName,...result} = this.userInfoStorage const {customerName,...result} = this.userInfoStorage
if(!this.valate){ if(!this.valate){
const {sex,name,id,avatarUrl} = this.userInfo const {sex,name,id,avatarUrl} = this.userInfo
...@@ -245,8 +247,10 @@ export default { ...@@ -245,8 +247,10 @@ export default {
console.log(sendData) console.log(sendData)
await Mine.editUserAvatar({avatarUrl:avatarUrl,id}) await Mine.editUserAvatar({avatarUrl:avatarUrl,id})
const { data } = await Mine.editUserInfo(sendData) const { data } = await Mine.editUserInfo(sendData)
console.log(data)
const {code = 0} = data const {code = 0} = data
if(code===200){ if(code===200){
this.showToast({ title: '保存成功'})
const data = { const data = {
...result, ...result,
customerName:name, customerName:name,
...@@ -256,10 +260,12 @@ export default { ...@@ -256,10 +260,12 @@ export default {
} }
Store.commit('setUserInfo', data); Store.commit('setUserInfo', data);
uni.setStorage({ key: 'userInfo', data: data }); uni.setStorage({ key: 'userInfo', data: data });
this.showToast({ title: '保存成功'}) uni.setStorageSync('UserInfo',data)
wx.navigateBack({ if(isReturn){
delta: 1 wx.navigateBack({
}); delta: 1
});
}
} }
} }
} }
......
...@@ -159,7 +159,7 @@ export default { ...@@ -159,7 +159,7 @@ export default {
// 商品详情页点击立即支付进入 // 商品详情页点击立即支付进入
if (option.goodsList) { if (option.goodsList) {
console.log('详情进入') console.log('详情进入')
this.getMessageFlag() // this.getMessageFlag()
const shopData = uni.getStorageSync('shopData'); const shopData = uni.getStorageSync('shopData');
this.shopData = shopData this.shopData = shopData
this.buyType = 3; this.buyType = 3;
...@@ -177,14 +177,23 @@ export default { ...@@ -177,14 +177,23 @@ export default {
if (q) { if (q) {
console.log('扫码进入',q) console.log('扫码进入',q)
uni.setStorageSync("selectFlag",false) uni.setStorageSync("selectFlag",false)
this.getMessageFlag() // this.getMessageFlag()
this.saveGetTicket() this.saveGetTicket()
User.getLocation((state, params) => { User.getLocation((state, params) => {
uni.removeStorageSync('shopCarInfo'); uni.removeStorageSync('shopCarInfo');
$EventBus.$emit('updateCar'); $EventBus.$emit('updateCar');
let id = decodeURIComponent(q).split('?')[1].split('=')[1]; // let id = decodeURIComponent(q).split('?')[1].split('=')[1];
// let id = q; const optionDecode = Utils.getUrlParams2(decodeURIComponent(q))
Menu.getScreenShopCar(id, params).then(res => { 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); const data = JSON.parse(res.data.data);
console.log(data); console.log(data);
this.shopData = data.shop; this.shopData = data.shop;
...@@ -202,7 +211,7 @@ export default { ...@@ -202,7 +211,7 @@ export default {
// 购物车点击进入 // 购物车点击进入
if(uni.getStorageSync('shopCarInfo').length!=0) { if(uni.getStorageSync('shopCarInfo').length!=0) {
console.log('购物车进入') console.log('购物车进入')
this.getMessageFlag() // this.getMessageFlag()
console.log(uni.getStorageSync('shopCarInfo')) console.log(uni.getStorageSync('shopCarInfo'))
const shopData = uni.getStorageSync('shopData'); const shopData = uni.getStorageSync('shopData');
this.shopData = shopData this.shopData = shopData
...@@ -256,7 +265,8 @@ export default { ...@@ -256,7 +265,8 @@ export default {
sendMsgFlag1:false, sendMsgFlag1:false,
sendMsgFlag2:false, sendMsgFlag2:false,
sendMsgFlag3:false sendMsgFlag3:false
} },
optionDecode:{}
} }
}, },
computed: { computed: {
...@@ -379,6 +389,10 @@ export default { ...@@ -379,6 +389,10 @@ export default {
getPhoneNumber(e) { getPhoneNumber(e) {
if (e.detail.errMsg == 'getPhoneNumber:ok') { if (e.detail.errMsg == 'getPhoneNumber:ok') {
e.loginInfo = this.loginInfo e.loginInfo = this.loginInfo
const { recognizePerson } = this.optionDecode
if(recognizePerson) {
e.faceInfoId = recognizePerson
}
User.getPhoneNumber(e); User.getPhoneNumber(e);
} else if (e.detail.errMsg == "getPhoneNumber:fail user deny") { } else if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
this.showToast({ title: '已拒绝手机号授权', icon: 'error' }) this.showToast({ title: '已拒绝手机号授权', icon: 'error' })
......
...@@ -70,6 +70,7 @@ import ShopCar from '../../components/shopCar/shopCar.vue' ...@@ -70,6 +70,7 @@ import ShopCar from '../../components/shopCar/shopCar.vue'
import Utils from '@/utils/utils' import Utils from '@/utils/utils'
import Menu from '@/request/menu' import Menu from '@/request/menu'
import { $EventBus } from '@/utils/EventBus'; import { $EventBus } from '@/utils/EventBus';
import Store from '@/store';
import Order from '@/request/order' import Order from '@/request/order'
import OrderQrCode from '@/components/OrderQrCode' import OrderQrCode from '@/components/OrderQrCode'
...@@ -140,7 +141,28 @@ export default { ...@@ -140,7 +141,28 @@ export default {
// this.img = 'https://s3.bmp.ovh/imgs/2022/07/02/2cfab823b35322e3.gif' // 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({ uni.getSetting({
success: (res) => { success: (res) => {
// 已经授权位置不获取默认店铺 // 已经授权位置不获取默认店铺
......
...@@ -135,10 +135,12 @@ export default { ...@@ -135,10 +135,12 @@ export default {
if (e.detail.errMsg == 'getPhoneNumber:ok') { if (e.detail.errMsg == 'getPhoneNumber:ok') {
e.loginInfo = this.loginInfo e.loginInfo = this.loginInfo
User.getPhoneNumber(e,async ()=>{ User.getPhoneNumber(e,async ()=>{
const {data:couponData} = await User.getCouponNum() setTimeout(async () => {
this.tickNum = couponData?.data||0 const {data:couponData} = await User.getCouponNum()
this.tickNum = couponData?.data||0
}, 1000);
}); });
} else if (e.detail.errMsg == "getPhoneNumber:fail user deny") { } else if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
this.showToast({ title: '已拒绝手机号授权', icon: 'error' }) this.showToast({ title: '已拒绝手机号授权', icon: 'error' })
} }
......
...@@ -65,7 +65,7 @@ module.exports = (vm) => { ...@@ -65,7 +65,7 @@ module.exports = (vm) => {
uni.hideLoading(); uni.hideLoading();
/* 对响应成功做点什么 可使用async await 做异步操作*/ /* 对响应成功做点什么 可使用async await 做异步操作*/
if (response.data.code !== 200) { if (response.data.code !== 200 && response.data.code !== 0) {
const phoneNumber = uni.getStorageSync('phoneNumber'); const phoneNumber = uni.getStorageSync('phoneNumber');
if (response.data.code == 401 && phoneNumber) { if (response.data.code == 401 && phoneNumber) {
User.getAuthorization(phoneNumber); User.getAuthorization(phoneNumber);
......
...@@ -18,11 +18,12 @@ export default { ...@@ -18,11 +18,12 @@ export default {
}); });
}, },
// 获取点单屏幕的订单信息 // 获取点单屏幕的订单信息
getScreenShopCar(key, location) { getScreenShopCar(key, location, sendData) {
return uni.$u.http return uni.$u.http
.post('/application/getData', { .post('/application/getData', {
key, key,
location, location,
...sendData
}) })
.then((res) => { .then((res) => {
return res; return res;
...@@ -125,5 +126,20 @@ export default { ...@@ -125,5 +126,20 @@ export default {
}); });
return err; 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 { ...@@ -59,6 +59,7 @@ export default {
encryptedData: res.encryptedData, encryptedData: res.encryptedData,
}) })
.then((res) => { .then((res) => {
console.log(res,'resssssssss')
const { statusCode, data } = res; const { statusCode, data } = res;
const { code, token, phoneNumber } = data; const { code, token, phoneNumber } = data;
if (statusCode == 200 && data && code == 200) { if (statusCode == 200 && data && code == 200) {
...@@ -99,6 +100,7 @@ export default { ...@@ -99,6 +100,7 @@ export default {
if(code){ if(code){
this.getOpenId(code).then((res)=>{ this.getOpenId(code).then((res)=>{
const loginInfo = res.data.msg const loginInfo = res.data.msg
uni.setStorageSync('loginInfo',loginInfo)
resolve(loginInfo) resolve(loginInfo)
}) })
} }
...@@ -107,22 +109,28 @@ export default { ...@@ -107,22 +109,28 @@ export default {
}) })
}, },
loginDecrypt(res){ loginDecrypt(res){
const {faceInfoId} = res.data
return uni.$u.http.post('/weixin/decrypt ', { return uni.$u.http.post('/weixin/decrypt ', {
session_key:res.loginInfo.session_key, session_key:res.loginInfo.session_key,
openId:res.loginInfo.openid, openId:res.loginInfo.openid,
encryptedData:res.data, encryptedData:res.data,
iv:res.iv, iv:res.iv,
faceInfoId,
source:3 source:3
}) })
}, },
// 手机号授权登录 // 手机号授权登录
getPhoneNumber(res, callback) { getPhoneNumber(res, callback) {
console.log(res)
uni.setStorage({ key: 'userPhoneInfo', data: res }); uni.setStorage({ key: 'userPhoneInfo', data: res });
Store.commit('setUserPhoneInfo', res); Store.commit('setUserPhoneInfo', res);
uni.setStorage({ key: 'phoneInfo', data: res }); uni.setStorage({ key: 'phoneInfo', data: res });
const loginInfo = res.loginInfo const loginInfo = res.loginInfo
const iv = res.detail.iv const iv = res.detail.iv
const data = res.detail.encryptedData const data = res.detail.encryptedData
if(res.faceInfoId){
data.faceInfoId = res.faceInfoId
}
wx.checkSession({ wx.checkSession({
success: (res) => { success: (res) => {
console.log('seeion未过期') console.log('seeion未过期')
...@@ -136,6 +144,23 @@ export default { ...@@ -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) { getUserInfo(data) {
return uni.$u.http return uni.$u.http
...@@ -143,9 +168,10 @@ export default { ...@@ -143,9 +168,10 @@ export default {
.then((res) => { .then((res) => {
console.log(res,data) console.log(res,data)
const { birthday, createTime, id, phone, sex, userName, avatarUrl } = res.data.data const { birthday, createTime, id, phone, sex, userName, avatarUrl } = res.data.data
const {avatarUrl:localAvatarUrl} = uni.getStorageSync('UserInfo')
const sendData = { const sendData = {
...data, ...data,
avatarUrl: avatarUrl, avatarUrl: avatarUrl||localAvatarUrl,
sex: sex?1:0, sex: sex?1:0,
customerName:userName, customerName:userName,
phone: phone.substr(0,3) + "****" + phone.substr(7), phone: phone.substr(0,3) + "****" + phone.substr(7),
...@@ -159,6 +185,21 @@ export default { ...@@ -159,6 +185,21 @@ export default {
sendData.birthday = Date.parse(birthday) sendData.birthday = Date.parse(birthday)
} }
Store.commit('setUserInfo', sendData); 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) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); context.showToast({ title: '服务器错误', icon: 'none' });
......
...@@ -6,7 +6,8 @@ const user = { ...@@ -6,7 +6,8 @@ const user = {
userPhoneInfo: null, userPhoneInfo: null,
shopInfo: null, //店铺信息 shopInfo: null, //店铺信息
orderId: null, //扫码进入时携带的订单id orderId: null, //扫码进入时携带的订单id
systemBarHeight: {} //设备头部高度信息 systemBarHeight: {}, //设备头部高度信息
menuOption: {}
}, },
mutations: { mutations: {
// 保存扫码进入时携带的订单id // 保存扫码进入时携带的订单id
...@@ -23,9 +24,12 @@ const user = { ...@@ -23,9 +24,12 @@ const user = {
}, },
// 设置用户允许昵称头像授权时的信息 // 设置用户允许昵称头像授权时的信息
setUserInfo(state, userInfo) { setUserInfo(state, userInfo) {
console.log(userInfo)
state.userInfo = userInfo; state.userInfo = userInfo;
}, },
// 设置扫码进入的优惠券信息
setMenuOption(state, data) {
state.menuOption = data
},
// 授权手机号时允许后的信息 // 授权手机号时允许后的信息
setUserPhoneInfo(state, userPhoneInfo) { setUserPhoneInfo(state, userPhoneInfo) {
state.userPhoneInfo = userPhoneInfo; state.userPhoneInfo = userPhoneInfo;
......
...@@ -215,4 +215,19 @@ export default { ...@@ -215,4 +215,19 @@ export default {
delta: 1 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