优惠卷和商品卷

This commit is contained in:
wwz
2025-03-10 16:33:43 +08:00
parent 70edc6756d
commit 5342133cbd
30 changed files with 2820 additions and 3338 deletions

View File

@@ -3,19 +3,21 @@
<view class="box_box">
<view class="box_item flex-between">
<text class="top_box_one_text">当前账号</text>
<input type="number" v-model="mobile" placeholder="请输入手机号" maxlength="11" disabled="disabled" />
<button v-if="!mobile" class="getPhone" open-type="getPhoneNumber" @getphonenumber="getPhone">
<input type="number" v-model="form.mobile" placeholder="请输入手机号" maxlength="11" disabled="disabled" />
<button v-if="!form.mobile" class="getPhone" open-type="getPhoneNumber" @getphonenumber="getPhone">
<view class="text">获取手机号</view>
</button>
</view>
<view class="box_item flex-between" style="position:relative;">
<text class="top_box_one_text"></text>
<input type="number" v-model="form.checkCode" placeholder="请输入验证码" style="padding-right: 140rpx;color: #333" />
<input type="number" v-model="form.checkCode" placeholder="请输入验证码"
style="padding-right: 140rpx;color: #333" />
<view class="top_box_one_texts">
<view v-if="showText == true" class="yzm" @click="CodeRegister">{{ Recapture }}</view>
<view v-if="datalist.showText == true" class="yzm" @click="CodeRegister">{{ datalist.Recapture }}
</view>
<view v-else style="color: #ccc; background-color: #f9f9f9; border-radius:16px; padding: 10rpx;">
{{ second }}s重新发送
{{ datalist.second }}s重新发送
</view>
</view>
</view>
@@ -29,178 +31,179 @@
<input type="number" v-model="form.payPassword" placeholder="请再次输入密码" maxlength="6"
:password="!payPasswords" />
</view>
</view>
<view class="flex-colum">
<view class="Box_bottom" :class="(form.checkCode!=''&&form.password!=''&&form.payPassword!='')?'active':''" @click="userInfosavePayPassword">确定</view>
<view class="Box_bottom" :class="(form.checkCode!=''&&form.password!=''&&form.payPassword!='')?'active':''"
@click="userInfosavePayPassword">确定</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
isPwd: "",
mobile: "",
form: {
mobile: '',
password: '',
payPassword: '',
checkCode: ''
},
passwords: false,
payPasswords: false,
// 注册定时器 初始值
second: 60,
showText: true,
Recapture: '获取验证码',
shopUserInfo: null,
};
},
onLoad(e) {
console.log(e)
if ( e.shopUserInfo ) {
this.shopUserInfo = JSON.parse(e.shopUserInfo);
console.log(this.shopUserInfo)
this.isPwd = this.shopUserInfo.isPwd;
this.mobile = this.shopUserInfo.telephone ? ( this.shopUserInfo.telephone.slice(0, 3)+'****'+this.shopUserInfo.telephone.slice(7) ) : '';
this.form.mobile = this.shopUserInfo.telephone;
}
<script setup>
import {
reactive,
onMounted
} from 'vue';
},
methods: {
async CodeRegister() {
const res = await this.api.phoneValidateCode({
// post 手机验证码
phone: this.form.mobile
});
if (res.code == 0) {
uni.showToast({
title: '验证码获取成功',
icon: 'none'
});
// 定时器
this.showText = false;
this.Recapture = '重新获取';
var interval = setInterval(() => {
let times = --this.second;
this.second = times < 10 ? '0' + times : times; //小于10秒补 0
}, 1000);
setTimeout(() => {
clearInterval(interval);
this.second = 60;
this.showText = true;
}, 60000);
}
},
/**
* 获取手机号
* @param {Object} d
*/
async getPhone(d) {
if (d.detail.iv) {
uni.login({
provider: 'weixin',
success: async (data) => {
console.log(data)
let res = await this.api.userwxlogins({
code: data.code,
encryptedData: d.detail.encryptedData,
iv: d.detail.iv,
})
this.form.mobile = res.data;
this.mobile = this.form.mobile ? ( this.form.mobile.slice(0, 3)+'****'+this.form.mobile.slice(7) ) : '';
let res2 = await this.api.upVipPhont({
id: this.shopUserInfo.id,
telephone: res.data,
})
}
})
}
},
async loginwxuserInfo() {
let res = await this.api.loginwxuserInfo({
userId: uni.cache.get('userInfo').id
})
if (res.code == 0) {
uni.cache.set('userInfo', res.data);
}
},
async userInfosavePayPassword() {
const shopUserInfo = reactive({
shopInfo: "",
shopId: ''
})
if (this.form.mobile.length != 11 && this.isPwd == 0) {
uni.showToast({
title: '手机号必须是11位',
icon: 'none'
});
return false;
}
if (this.form.password == null || this.form.password == '') {
uni.showToast({
title: '请输入密码',
icon: 'none'
});
return false;
}
if (this.form.payPassword == null || this.form.payPassword == '') {
uni.showToast({
title: '请输入确认密码',
icon: 'none'
});
return false;
}
if (this.form.password.length != 6 || this.form.payPassword.length != 6) {
uni.showToast({
title: '密码必须是6位',
icon: 'none'
});
return false;
}
if (this.form.payPassword != this.form.password) {
uni.showToast({
title: '密码和确认密码不一致',
icon: 'none'
});
return false;
}
if (this.form.checkCode == null || this.form.checkCode == '') {
uni.showToast({
title: '请输入验证码',
icon: 'none'
});
return false;
}
let res = await this.api.loginresetPwd({
vipId: this.shopUserInfo.id,
pwd: this.form.password,
code: this.form.checkCode
})
const form = reactive({
mobile: '',
password: '',
payPassword: '',
checkCode: ''
})
if (res.code == 0) {
if (uni.cache.get('userInfo').isPwd != 0) {
uni.showToast({
title: '修改成功',
icon: 'none'
});
} else {
uni.showToast({
title: '设置成功',
icon: 'none'
});
}
setTimeout(() => {
// 获取用户信息
this.loginwxuserInfo()
uni.navigateBack();
}, 1000);
}
}
const datalist = reactive({
isPwd: "",
passwords: false,
payPasswords: false,
// 注册定时器 初始值
second: 60,
showText: true,
Recapture: '获取验证码',
shopUserInfo: null,
})
const CodeRegister = async () => {
const res = await this.api.phoneValidateCode({
// post 手机验证码
phone: form.mobile
});
if (res) {
uni.showToast({
title: '验证码获取成功',
icon: 'none'
});
// 定时器
datalist.showText = false;
datalist.Recapture = '重新获取';
var interval = setInterval(() => {
let times = --datalist.second;
datalist.second = times < 10 ? '0' + times : times; //小于10秒补 0
}, 1000);
setTimeout(() => {
clearInterval(interval);
datalist.second = 60;
datalist.showText = true;
}, 60000);
}
};
}
/**
* 获取手机号
* @param {Object} d
*/
const getPhone = async (d) => {
if (d.detail.iv) {
uni.login({
provider: 'weixin',
success: async (data) => {
console.log(data)
let res = await this.api.userwxlogins({
code: data.code,
encryptedData: d.detail.encryptedData,
iv: d.detail.iv,
})
// form.mobile = res ? (res.slice(0, 3) + '****' + res.slice(7)) : '';
form.mobile = res
}
})
}
}
const loginwxuserInfo = async () => {
let res = await this.api.loginwxuserInfo({
userId: uni.cache.get('userInfo').id
})
if (res.code == 0) {
uni.cache.set('userInfo', res.data);
}
}
const userInfosavePayPassword = async () => {
if (form.mobile.length != 11) {
uni.showToast({
title: '手机号必须是11位',
icon: 'none'
});
return false;
}
if (form.password == null || form.password == '') {
uni.showToast({
title: '请输入密码',
icon: 'none'
});
return false;
}
if (form.payPassword == null || form.payPassword == '') {
uni.showToast({
title: '请输入确认密码',
icon: 'none'
});
return false;
}
if (form.password.length != 6 || form.payPassword.length != 6) {
uni.showToast({
title: '密码必须是6位',
icon: 'none'
});
return false;
}
if (form.payPassword != form.password) {
uni.showToast({
title: '密码和确认密码不一致',
icon: 'none'
});
return false;
}
if (form.checkCode == null || form.checkCode == '') {
uni.showToast({
title: '请输入验证码',
icon: 'none'
});
return false;
}
let res = await this.api.loginresetPwd({
vipId: this.shopUserInfo.id,
pwd: this.form.password,
code: this.form.checkCode
})
if (res.code == 0) {
if (datalist.isPwd != 0) {
uni.showToast({
title: '修改成功',
icon: 'none'
});
} else {
uni.showToast({
title: '设置成功',
icon: 'none'
});
}
setTimeout(() => {
// 获取用户信息
this.loginwxuserInfo()
uni.navigateBack();
}, 1000);
}
}
onMounted(async () => {
// 获取当前页面栈
const pages = getCurrentPages();
// 获取当前页面实例
const currentPage = pages[pages.length - 1];
// 获取页面参数
const options = currentPage.options;
shopUserInfo.shopInfo = JSON.parse(decodeURIComponent(options.shopInfo))
console.log(shopUserInfo)
})
</script>
<style lang="scss">
@@ -226,6 +229,7 @@
.box_item {
border-bottom: 1rpx solid #E5E5E5;
position: relative;
.top_box_one_text {
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 500;
@@ -247,7 +251,7 @@
position: absolute;
right: 0;
margin: auto;
font-size: 28rpx;
font-size: 24rpx;
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
font-weight: 400;
color: #5082fd;
@@ -262,10 +266,12 @@
}
}
}
.box_item:nth-child(1){
.box_item:nth-child(1) {
border-bottom: none;
border-top: 1rpx solid #E5E5E5;
input{
input {
border-bottom: 1rpx solid #E5E5E5;
color: #333;
}
@@ -289,11 +295,13 @@
color: #ffffff;
text-align: center;
}
.Box_bottom.active{
.Box_bottom.active {
background-color: #E3AD7F;
}
}
.getPhone{
.getPhone {
line-height: initial;
background-color: none;
border: 2rpx solid #E3AD7F;