Commit e8d508a0 by songbingqi

完成我的信息修改接口联调

parent 793441f5
......@@ -3,8 +3,10 @@
<scroll-view class="nav-left" :style="[heightStyle]" :class="[shopCarFlag||shopState===0?'shopCarcss':'' ]" scroll-y :scroll-top="scrollLeftTop" scroll-with-animation>
<view class="nav-left-item" v-for="(item,index) in classifyData" @click="categoryClickMain(item.id)" :key="item.id"
:class="item.id == categoryId ? 'active' : ''">
<view class="imgbox" v-if="item.src&&sizeList[index].width"><image :style="{'height':sizeList[index].height+'rpx','width':sizeList[index].width+'rpx'}" :src="item.src"/></view>
<view :style="{'margin-top':'10rpx'}"><span>{{ item.name }}</span></view>
<view class="imgbox" v-if="item.icon&&sizeList[index].width">
<image :style="{'height':sizeList[index].height+'rpx','width':sizeList[index].width+'rpx'}" :src="item.icon"/>
</view>
<view :style="{'margin-top':'4rpx'}"><span>{{ item.name }}</span></view>
<!-- <view :class="item.id == categoryId ? 'active-line' : ''"></view> -->
</view>
</scroll-view>
......@@ -115,12 +117,14 @@ export default {
this.categoryPostion = data
}).exec();
})
// categorys[0]?categorys[0].src = 'http://fakeimg.pl/43x42/':''
// categorys[1]?categorys[1].src = 'http://fakeimg.pl/54x34/':''
// categorys[2]?categorys[2].src = 'http://fakeimg.pl/32x30/':''
categorys.map(item=>{
this.imagesHeight(item.src)
})
// console.log(categorys)
// categorys[0]?categorys[0].icon = 'https://s1.ax1x.com/2022/08/05/vnHQw6.jpg':''
// categorys[1]?categorys[1].icon = 'https://s1.ax1x.com/2022/08/05/vnHQw6.jpg':''
// categorys[2]?categorys[2].icon = 'https://s1.ax1x.com/2022/08/05/vnHQw6.jpg':''
// categorys.map((item,index)=>{
// this.imagesHeight(item.src,index)
// })
if(categorys.length!=0)this.imagesHeight(categorys)
return categorys
}
},
......@@ -138,17 +142,46 @@ export default {
});
},
methods: {
async imagesHeight(src) {
const val = await uni.getImageInfo({
src
async imagesHeight(list,index) {
// return
let i = 0
const newList = list.map(item=>{
return ''
})
console.log(val)
if(val.length==2){
this.sizeList.push({
width:val[1].width,
height:val[1].height
const func = async () => {
if(list[i].icon){
const val = await uni.getImageInfo({
src: list[i].icon
})
let w = val[1].width
let h = val[1].height
if(w>80){
w = 60
}
if(h>60){
h = 60
}
newList[i] = {
width:w,
height:h
}
}
i++
if(i<newList.length){
func()
}else{
this.sizeList = newList
}
}
func()
// console.log(val)
// if(val.length==2){
// this.sizeList[index] = {
// width:val[1].width,
// height:val[1].height
// }
// }
},
getSku(data) {
const { skus } = data;
......@@ -263,14 +296,19 @@ export default {
color: #666666;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
justify-content: center;
font-family: PingFangSC-Regular, PingFang SC;
.imgbox {
height: auto;
width: 100%;
text-align: center;
// margin-top: 21.8rpx;
// border: 1px solid red;
width: 80rpx;
height: 60rpx;
line-height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
}
}
......
......@@ -8,6 +8,7 @@
<view class="infoItem name">
<view class="label">昵称</view>
<view class="input"><input type="text" v-model="userInfo.name"></view>
<view class="tip" v-if="valate">{{valateText}}</view>
</view>
<view class="infoItem phone">
<view class="label">手机</view>
......@@ -22,7 +23,6 @@
<view class="checkLabel">{{item.label}}</view>
</view>
</view>
</view>
</view>
<view class="infoItem birthday">
......@@ -30,15 +30,17 @@
<view class="input">
<view class="birthdayBox">
<view class="text">{{birthdayComuted}}</view>
<view class="btn" @click="changeBirthday">修改</view>
<view class="btn" v-if="canEditBirthday" @click="changeBirthday">修改</view>
</view>
</view>
</view>
</view>
<view class="saveBtn">
<button class="btn">保存</button>
<button class="btn" @click="save">保存</button>
</view>
</view>
<show-toast ref="toast"/>
<!-- <button @click="exit">退出</button> -->
<u-datetime-picker
......@@ -64,6 +66,7 @@
<script>
import Modal from '@/components/Modal/index.vue'
import Mine from '@/request/mine'
export default {
components: { Modal },
computed:{
......@@ -76,8 +79,38 @@ export default {
return years+'.'+month+'.'+days
}
},
watch:{
'userInfo.name':{
handler(val){
console.log(val)
if(!/^[0-9a-zA-z\u4e00-\u9fa5]{0,7}$/.test(val)){
this.valateText = '最多7个字符,不可输入标点符号及特殊字符'
this.valate = true
}else{
if(!val){
this.valateText = '请输入昵称'
this.valate = true
}else{
this.valateText = ''
this.valate = false
}
}
}
}
},
data() {
return {
valateText:'',
canEditBirthday:true,
valate:false,
rules:{
name:[
{
required: true,
errorMessage: '请输入姓名'
}
]
},
timerShow: false,
birthdayModalShow:false,
value1: Number(new Date()),
......@@ -86,7 +119,8 @@ export default {
name:'脸脸',
phone:'152****8932',
sex:0,
birthday:1658679810130
birthday:1658679810130,
id:''
},
sexList:[
{
......@@ -100,18 +134,35 @@ export default {
]
}
},
onLoad(option) {
async onLoad(option) {
const {info} = option
const {avatarUrl,gender,nickName} = JSON.parse(decodeURIComponent(info))
const {avatarUrl,gender=0,nickName='点点'} = info?JSON.parse(decodeURIComponent(info)):{}
const {data} = await Mine.getUserInfo()
const { birthday, createTime, id, phone, sex, userName } = data.data
this.userInfo.id = id
this.canEditBirthday = !birthday
if(!birthday){
this.userInfo.birthday = Date.parse(createTime)
}else{
this.userInfo.birthday = Date.parse(birthday)
}
this.userInfo.avatarUrl = avatarUrl
this.userInfo.sex = gender
this.userInfo.name = nickName
const phoneNumber = uni.getStorageSync('phoneNumber')
this.userInfo.phone = phoneNumber.substr(0,3) + "****" + phoneNumber.substr(7)
this.userInfo.sex = sex?sex?1:0:gender
this.userInfo.name = userName?userName:nickName
this.userInfo.phone = phone.substr(0,3) + "****" + phone.substr(7)
},
methods:{
choseTime(e) {
async choseTime(e) {
const sendDate = {
birthday:this.userInfo.birthday,
id:this.userInfo.id
}
const {data} = await Mine.editBirthdat(sendDate)
const {code} = data
if(code===200){
this.showToast({ title: '修改成功'})
this.userInfo.birthday = e.value
}
this.timerShow = false
},
openTimer() {
......@@ -131,6 +182,22 @@ export default {
console.log(123)
}
})
},
async save() {
if(!this.valate){
const {sex,name,id} = this.userInfo
const sendData = {
sex: Number(sex)===0?false:true,
userName: name,
id
}
console.log(sendData)
const { data } = await Mine.editUserInfo(sendData)
const {code = 0} = data
if(code===200){
this.showToast({ title: '保存成功'})
}
}
}
}
}
......@@ -164,6 +231,18 @@ export default {
padding: 0rpx 38rpx 0rpx 40rpx;
margin-top: 24rpx;
.name {
position: relative;
.tip {
position: absolute;
font-size: 18rpx;
color: red;
bottom: 9rpx;
left: 190rpx;
}
}
.infoItem {
height: 96rpx;
border-bottom: 1rpx solid #ECECEC;
......
......@@ -259,24 +259,32 @@ export default {
}else{
if(this.agreeTerms)uni.setStorageSync('TermsStatus',true)
}
const tmpid = ['1uErx-15S-3vuopXSvvsxCeM_Jd-1iZC-nXzd2yW3QU', 'Q4HDwBEvpTXpwtZktqWm4SZOTEuQK1x48xjqjD2GqyM', 'Fu_CPIXa0cnJ4EDdVKqFQ3qqKJccMqt2oorI5mfNq74']
const val = {}
wx.requestSubscribeMessage({
// 'Oq_zfRWRXijvXenRmfD2PARgpvdYlbkjR4laxKmBqb0'
tmplIds: ['1uErx-15S-3vuopXSvvsxCeM_Jd-1iZC-nXzd2yW3QU', 'Q4HDwBEvpTXpwtZktqWm4SZOTEuQK1x48xjqjD2GqyM', 'Fu_CPIXa0cnJ4EDdVKqFQ3qqKJccMqt2oorI5mfNq74'],
tmplIds: tmpid,
success: (res) => {
const finalValue = Object.values(res).indexOf('reject')
tmpid.forEach(item=>{
val[item] = res[item]==='accept'?true:false
})
if(finalValue===-1){
uni.setStorageSync('isMessage', 'true')
User.setAllow(1)
this.saveReserve()
this.saveReserve(val)
}else{
User.setAllow(2)
this.saveReserve()
this.saveReserve(val)
}
},
fail: (err) => {
tmpid.forEach(item=>{
val[item] = false
})
console.log(err);
User.setAllow(2)
this.saveReserve()
this.saveReserve(val)
}
})
},
......@@ -309,7 +317,7 @@ export default {
}
},
//结算组装数据发起订单
async saveReserve() {
async saveReserve(val={}) {
// 组装购物车数据或者立即支付数据
let list = [];
if (this.payType == '1') {
......@@ -317,9 +325,27 @@ export default {
} else {
list = uni.getStorageSync('goodsList').filter((v) => v.flag == true);
}
const shopInfo = uni.getStorageSync('shopData')
const {lat,lng} = shopInfo
// sendMsgFlag1:下单成功通知
// sendMsgFlag2:订单状态变更通知
// sendMsgFlag3:取餐提醒
const sendMsgFlag1 = val['1uErx-15S-3vuopXSvvsxCeM_Jd-1iZC-nXzd2yW3QU']?1:0
const sendMsgFlag2 = val['Q4HDwBEvpTXpwtZktqWm4SZOTEuQK1x48xjqjD2GqyM']?1:0
const sendMsgFlag3 = val['Fu_CPIXa0cnJ4EDdVKqFQ3qqKJccMqt2oorI5mfNq74']?1:0
let res = await Utils.AssemblyOrder(this.shopData, this.totalPrice, this.totalNum, this.buyType, list);
if (res) {
let orderInfo = await Menu.saveReserve({...res,couponId:this.selectCouponId||''});
const sendData = {
...res,
couponId:this.selectCouponId||'',
lat,
lng,
sendMsgFlag1,
sendMsgFlag2,
sendMsgFlag3
}
let orderInfo = await Menu.saveReserve(sendData);
if (orderInfo && orderInfo.data.code == 200) {
await Menu.requestPayment(orderInfo.data.data, res, this.buyType);
}
......
......@@ -41,5 +41,39 @@ export default {
.catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' });
});
},
// 获取用户信息
getUserInfo() {
return uni.$u.http
.get(`/system/customer/detail`, {})
.then((res) => {
return res;
})
.catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' });
});
},
// 更改用户生日
editBirthdat(data) {
return uni.$u.http
.post(`/system/customer/update/birth`, data)
.then((res) => {
return res;
})
.catch((err) => {
context.showToast({ title: err.data.msg, icon: 'none' });
return err
});
},
// 更改用户昵称、性别
editUserInfo(data) {
return uni.$u.http
.post(`/system/customer/update/base`, data)
.then((res) => {
return res;
})
.catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' });
});
}
};
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