修改绑定手机号错误的问题

This commit is contained in:
anhaogxs
2021-02-20 16:01:51 +08:00
parent e2f037e675
commit 44645dd0b7
6 changed files with 712 additions and 738 deletions

View File

@ -1,131 +1,131 @@
<template>
<view class="banner-swiper-box">
<canvas canvas-id="colorThief" class="hide-canvas"></canvas>
<swiper class="banner-carousel Shop-selector-rect" circular @change="swiperChange" :autoplay="true">
<swiper-item v-for="(item, index) in detail" :key="index" class="carousel-item">
<image class="swiper-image " :src="item.pic" @click="goRoll(item)" mode="widthFix" lazy-load>
</image>
</swiper-item>
</swiper>
<view class="banner-swiper-dots">
<text :class="swiperCurrent === index ? 'banner-dot-active' : 'banner-dot'"
v-for="(dot, index) in detail.length" :key="index"></text>
</view>
</view>
<view class="banner-swiper-box">
<canvas canvas-id="colorThief" class="hide-canvas"></canvas>
<swiper class="banner-carousel Shop-selector-rect" circular @change="swiperChange" :autoplay="true">
<swiper-item v-for="(item, index) in detail" :key="index" class="carousel-item">
<image class="swiper-image " :src="item.pic" @click="goRoll(item)" mode="widthFix" lazy-load>
</image>
</swiper-item>
</swiper>
<view class="banner-swiper-dots">
<text :class="swiperCurrent === index ? 'banner-dot-active' : 'banner-dot'" v-for="(dot, index) in detail.length"
:key="index"></text>
</view>
</view>
</template>
<script>
import colorThief from 'miniapp-color-thief';
import colorThief from 'miniapp-color-thief';
export default {
data() {
return {
swiperCurrent: 0, //轮播下标
webviewId: 0,
};
},
props: {
detail: {
type: Array,
default: []
}
},
created: async function () {
await this.doColorThief();
},
computed: {},
methods: {
async doColorThief() {
let that = this;
// 获取轮播图
let item = this.detail[this.swiperCurrent];
// 获取轮播图颜色
let bgcolor = item.color;
// 颜色不存在
if (bgcolor === '') {
that.$set(item, 'bgcolor', '#c40414');
that.$emit('getbgcolor', '#c40414');
} else {
that.$set(item, 'bgcolor', bgcolor);
that.$emit('getbgcolor', bgcolor);
}
export default {
data() {
return {
swiperCurrent: 0, //轮播下标
webviewId: 0,
};
},
props: {
detail: {
type: Array,
default: []
}
},
created: async function() {
await this.doColorThief();
},
computed: {},
methods: {
async doColorThief() {
let that = this;
// 获取轮播图
let item = this.detail[this.swiperCurrent];
// 获取轮播图颜色
let bgcolor = item.color;
// 颜色不存在
if (!bgcolor) {
that.$set(item, 'bgcolor', '#c40414');
that.$emit('getbgcolor', '#c40414');
} else {
that.$set(item, 'bgcolor', bgcolor);
that.$emit('getbgcolor', bgcolor);
}
},
swiperChange(e) {
this.swiperCurrent = e.detail.current;
this.doColorThief();
let bgcolor = this.detail[this.swiperCurrent].bgcolor;
this.$emit('getbgcolor', bgcolor);
},
},
swiperChange(e) {
this.swiperCurrent = e.detail.current;
this.doColorThief();
let bgcolor = this.detail[this.swiperCurrent].bgcolor;
this.$emit('getbgcolor', bgcolor);
},
// 路由跳转
goRoll(item) {
if (item.uniapp_url) {
this.$yrouter.push(item.uniapp_url)
}
},
}
// 路由跳转
goRoll(item) {
if (item.uniapp_url) {
this.$yrouter.push(item.uniapp_url)
}
},
}
}
}
</script>
<style lang="less">
// 轮播
.banner-swiper-box {
background: #fff;
}
// 轮播
.banner-swiper-box {
background: #fff;
}
.banner-swiper-box,
.banner-carousel {
width: 750rpx;
height: 350upx;
position: relative;
.banner-swiper-box,
.banner-carousel {
width: 750rpx;
height: 350upx;
position: relative;
.carousel-item {
width: 100%;
height: 100%;
// padding: 0 28upx;
overflow: hidden;
}
.carousel-item {
width: 100%;
height: 100%;
// padding: 0 28upx;
overflow: hidden;
}
.swiper-image {
width: 100%;
height: 100%;
// border-radius: 10upx;
// background: #ccc;
}
}
.swiper-image {
width: 100%;
height: 100%;
// border-radius: 10upx;
// background: #ccc;
}
}
.banner-swiper-dots {
display: flex;
position: absolute;
left: 50%;
transform: translateX(-50%);
bottom: 20rpx;
z-index: 5;
.banner-swiper-dots {
display: flex;
position: absolute;
left: 50%;
transform: translateX(-50%);
bottom: 20rpx;
z-index: 5;
.banner-dot {
width: 14rpx;
height: 14rpx;
background: rgba(255, 255, 255, 1);
border-radius: 50%;
margin-right: 10rpx;
}
.banner-dot {
width: 14rpx;
height: 14rpx;
background: rgba(255, 255, 255, 1);
border-radius: 50%;
margin-right: 10rpx;
}
.banner-dot-active {
width: 14rpx;
height: 14rpx;
background: #a8700d;
border-radius: 50%;
margin-right: 10rpx;
}
}
.banner-dot-active {
width: 14rpx;
height: 14rpx;
background: #a8700d;
border-radius: 50%;
margin-right: 10rpx;
}
}
.hide-canvas {
position: fixed !important;
top: -99999upx;
left: -99999upx;
z-index: -99999;
}
.hide-canvas {
position: fixed !important;
top: -99999upx;
left: -99999upx;
z-index: -99999;
}
</style>

View File

@ -18,14 +18,14 @@
</view>
</view>
<Banner v-if="item.type=='banner'" :detail="item.componentContent.bannerData" @getbgcolor="getbgcolor"></Banner>
<uni-notice-bar v-if="item.type=='noticeBar'" scrollable="true" @click="goRoll(item.componentContent.roll[0])" single="true" :speed="10"
showIcon="true" :text="item.componentContent.roll[0].info"></uni-notice-bar>
<uni-notice-bar v-if="item.type=='noticeBar'" scrollable="true" @click="goRoll(item.componentContent.roll[0])"
single="true" :speed="10" showIcon="true" :text="item.componentContent.roll[0].info"></uni-notice-bar>
<view class="content_box home_content_box">
<!-- 菜单 -->
<Menu :list="item.componentContent.menus" v-if="item.type=='menu'"></Menu>
<Menu :list="item.componentContent.menus" v-if="item.type=='menu'&&item.componentContent.menus"></Menu>
<!-- 滚动新闻 -->
<!-- 广告 -->
<Adv v-if="item.type=='adv'" :detail="item.componentContent.detail" />
<Adv v-if="item.type=='adv'&&item.componentContent.detail" :detail="item.componentContent.detail" />
<!-- 热门榜单 -->
<HotCommodity v-if="item.type=='hotCommodity'" :detail="likeInfo"></HotCommodity>
<!-- 超值拼团 -->
@ -213,26 +213,26 @@
// uni.showLoading({
// title: "加载中",
// });
getCanvas().then(res => {
}).catch(error => {
this.homeData = JSON.parse(error.data.json)
console.log(this.homeData[4])
getCanvas().then(res => {}).catch(error => {
this.homeData = JSON.parse(error.data.json)
console.log(this.homeData)
console.log(222)
})
getHomeData().then((res) => {
that.logoUrl = res.data.logoUrl;
res.data.banner.map((item) => (item.bgcolor = item.color || ""));
that.$set(that, "info", res.data.info);
that.$set(that, "firstList", res.data.firstList);
that.$set(that, "bastList", res.data.bastList);
that.$set(that, "likeInfo", res.data.likeInfo);
that.$set(that, "live", res.data.liveList);
that.$set(that, "lovely", res.data.lovely);
that.$set(that, "benefit", res.data.benefit);
that.$set(that, "couponList", res.data.couponList);
that.$set(that, "combinationList", res.data.combinationList);
uni.hideLoading();
that.setOpenShare();
// that.doColorThief()
that.logoUrl = res.data.logoUrl;
res.data.banner.map((item) => (item.bgcolor = item.color || ""));
that.$set(that, "info", res.data.info);
that.$set(that, "firstList", res.data.firstList);
that.$set(that, "bastList", res.data.bastList);
that.$set(that, "likeInfo", res.data.likeInfo);
that.$set(that, "live", res.data.liveList);
that.$set(that, "lovely", res.data.lovely);
that.$set(that, "benefit", res.data.benefit);
that.$set(that, "couponList", res.data.couponList);
that.$set(that, "combinationList", res.data.combinationList);
uni.hideLoading();
that.setOpenShare();
// that.doColorThief()
});
},
methods: {

View File

@ -6,158 +6,143 @@
</view>
<view class="item acea-row row-between-wrapper">
<input type="text" placeholder="填写验证码" class="codeIput" v-model="captcha" />
<button
class="code font-color-red"
:disabled="disabled"
:class="disabled === true ? 'on' : ''"
@click="code"
>{{ text }}</button>
<button class="code font-color-red" :disabled="disabled" :class="disabled === true ? 'on' : ''" @click="code">{{ text }}</button>
</view>
</view>
<view class="confirmBnt bg-color-red" @click="confirm">确认绑定</view>
</view>
</template>
<script>
import { mapGetters } from "vuex";
import sendVerifyCode from "@/mixins/SendVerifyCode";
import { required, alpha_num, chs_phone } from "@/utils/validate";
import { validatorDefaultCatch } from "@/utils/dialog";
import { registerVerify, bindingPhone } from "@/api/user";
import { mapGetters } from 'vuex'
import sendVerifyCode from '@/mixins/SendVerifyCode'
import { required, alpha_num, chs_phone } from '@/utils/validate'
import { validatorDefaultCatch } from '@/utils/dialog'
import { registerVerify, wxappBindingPhone } from '@/api/user'
export default {
name: "BindingPhone",
name: 'BindingPhone',
components: {},
props: {},
data: function() {
data: function () {
return {
captcha: "",
phone: "" //手机号
};
captcha: '',
phone: '', //手机号
}
},
mixins: [sendVerifyCode],
computed: mapGetters(["userInfo"]),
mounted: function() {},
computed: mapGetters(['userInfo']),
mounted: function () {},
methods: {
async confirm() {
let that = this;
const { phone, captcha } = that;
let that = this
const { phone, captcha } = that
try {
await that
.$validator({
phone: [
chs_phone(chs_phone.message("手机号码")),
alpha_num(alpha_num.message())
],
captcha: [
required(required.message("验证码")),
alpha_num(alpha_num.message("验证码"))
]
phone: [chs_phone(chs_phone.message('手机号码')), alpha_num(alpha_num.message())],
captcha: [required(required.message('验证码')), alpha_num(alpha_num.message('验证码'))],
})
.validate({ phone, captcha });
.validate({ phone, captcha })
} catch (e) {
return validatorDefaultCatch(e);
return validatorDefaultCatch(e)
}
bindingPhone({
wxappBindingPhone({
phone: this.phone,
captcha: this.captcha
captcha: this.captcha,
})
.then(res => {
if (res.data !== undefined && res.data.is_bind) {
uni.showModal({
title: "提示",
content: "确认绑定?",
success: function(res) {
title: '提示',
content: '确认绑定?',
success: function (res) {
if (res.confirm) {
bindingPhone({
wxappBindingPhone({
phone: this.phone,
captcha: this.captcha,
step: 1
step: 1,
})
.then(res => {
uni.showToast({
title: res.msg,
icon: "none",
duration: 2000
});
icon: 'none',
duration: 2000,
})
that.$yrouter.replace({
path: "/pages/user/PersonalData/index"
});
path: '/pages/user/PersonalData/index',
})
})
.catch(res => {
uni.showToast({
title: res.msg,
icon: "none",
duration: 2000
});
icon: 'none',
duration: 2000,
})
that.$yrouter.replace({
path: "/pages/user/PersonalData/index"
});
});
path: '/pages/user/PersonalData/index',
})
})
} else if (res.cancel) {
uni.showToast({
title: "已取消绑定",
icon: "none",
duration: 2000
});
title: '已取消绑定',
icon: 'none',
duration: 2000,
})
that.$yrouter.replace({
path: "/pages/user/PersonalData/index"
});
path: '/pages/user/PersonalData/index',
})
}
}
});
},
})
} else {
uni.showToast({
title: res.msg,
icon: "none",
duration: 2000
});
that.$yrouter.replace({ path: "/pages/user/PersonalData/index" });
icon: 'none',
duration: 2000,
})
that.$yrouter.replace({ path: '/pages/user/PersonalData/index' })
}
})
.catch(res => {
uni.showToast({
title: res.msg,
icon: "none",
duration: 2000
});
});
icon: 'none',
duration: 2000,
})
})
},
async code() {
let that = this;
const { phone } = that;
let that = this
const { phone } = that
try {
await that
.$validator({
phone: [
required(required.message("手机号码")),
chs_phone(chs_phone.message())
]
phone: [required(required.message('手机号码')), chs_phone(chs_phone.message())],
})
.validate({ phone });
.validate({ phone })
} catch (e) {
return validatorDefaultCatch(e);
return validatorDefaultCatch(e)
}
registerVerify({ phone: phone })
.then(res => {
uni.showToast({
title: res.msg,
icon: "none",
duration: 2000
});
that.sendCode();
icon: 'none',
duration: 2000,
})
that.sendCode()
})
.catch(res => {
uni.showToast({
title: res.msg,
icon: "none",
duration: 2000
});
});
}
}
};
icon: 'none',
duration: 2000,
})
})
},
},
}
</script>
<style lang="">
</style>
<style lang=""></style>