绑定弹窗扫码注册逻辑

master
blak-kong 2 years ago
parent a9a1534750
commit 4cebc23867

@ -68,117 +68,84 @@ export default class PopupBinding extends Component<any, any> {
render() {
let {
title,
data,
content,
cancelButtonText,
confirmButtonText,
isShow,
isRegisterBoolean,
isClose,
isLarge,
type = 0,
type,
} = this.props;
return (
<Block>
<PageMeta pageStyle={isShow ? "overflow: hidden;" : ""} />
{type === 1 && (
<PopupConfirm
isShow={isShow}
isClose={false}
title="提示"
// content={
// <Block>
// <View>仪器:小紫弹内测版</View>
// <View>序列号xxxxx</View>
// <View>请问是否确认绑定该仪器?</View>
// </Block>
// }
content={content}
confirmButtonText="确定"
cancelButtonText="暂不绑定"
onClose={this.onClose.bind(this)}
onConfirm={this.onConfirm.bind(this)}
></PopupConfirm>
)}
{type === 2 && (
{!isRegisterBoolean && (
<PopupAlert
isShow={isShow}
title="提示"
// content="序列号库仍在更新,请联系微信助手"
content={content}
content={
<Block>
<View>{data.instrumentName}</View>
<View style="margin-top:20rpx">{data.serial}</View>
<View style="margin-top:20rpx">
</View>
</Block>
}
confirmButtonText="知道了"
textAlgin="center"
isClose={false}
onClose={this.onConfirm2.bind(this)}
onConfirm={this.onConfirm2.bind(this)}
close={this.onClose}
confirm={this.onConfirm}
></PopupAlert>
)}
{/* <Popup
show={isShow}
closeOnClickOverlay={false}
round
overlayStyle="width: 100vw;padding: 0;"
onClick={this.onClickStop}
>
{isClose && (
<View
className="at-icon at-icon-close binding-close"
onClick={this.onClose}
></View>
)}
<View className={classnames("binding-box", "large")}>
{type === 1 && (
{isRegisterBoolean && type === 0 && (
<PopupConfirm
isShow={isShow}
isClose={false}
title="提示"
content={
<Block>
<View className="binding-popup-title">{title}</View>
<View className="binding-popup-content-box">
<View
className={classnames(
"binding-popup-content",
"text-center"
)}
>
{content}
</View>
</View>
<View className="binding-popup-btns">
<Button className="binding-popup-btn2" onClick={this.onClose}>
{cancelButtonText}
</Button>
<Button
className="binding-popup-btn2"
onClick={this.onConfirm}
>
{confirmButtonText}
</Button>
<View className={classnames("text-center")}>
<View>{data.instrumentName}</View>
<View style="margin-top:20rpx">{data.serial}</View>
<View style="margin-top:20rpx"></View>
</View>
</Block>
)}
{type === 2 && (
}
confirmButtonText="确认"
cancelButtonText="暂不绑定"
close={this.onClose}
confirm={this.onConfirm}
></PopupConfirm>
)}
{isRegisterBoolean && type === 2 && (
<PopupConfirm
isShow={isShow}
isClose={false}
title="提示"
content={
<Block>
<View className="binding-popup-title">{title}</View>
<View className="binding-popup-content-box">
<View
className={classnames(
"binding-popup-content",
"text-center"
)}
>
{content}
<View className={classnames("text-center")}>
<View>{data.instrumentName}</View>
<View style="margin-top:20rpx">{data.serial}</View>
<View style="margin-top:20rpx">
<View></View>
<View></View>
</View>
</View>
<View className="binding-popup-footer">
<Button
className="binding-popup-btn"
onClick={this.onConfirm}
>
{confirmButtonText}
</Button>
</View>
</Block>
)}
</View>
</Popup> */}
}
confirmButtonText="确认"
cancelButtonText="暂不换绑"
close={this.onClose}
confirm={this.onConfirm}
></PopupConfirm>
)}
</Block>
);
}

@ -85,6 +85,10 @@ export default class PopupPrivacy extends Component<any, any> {
handleAgreePrivacyAuthorization = (event) => {
// Taro.setStorageSync("isPrivacyPopup", "true");
this.props.closePrivacy(); // 通知父组件关闭
let isScan = Taro.getStorageSync("isScan");
if (isScan) {
go("/pages/register/register");
}
};
onClickStop = (e) => {

@ -0,0 +1,7 @@
.error-tip {
display: flex;
justify-content: center;
align-items: center;
width: 100vw;
height: 90vh;
}

@ -1,6 +1,10 @@
import { Component, PropsWithChildren, useEffect, useState } from "react";
import Taro from "@tarojs/taro";
import { View, Text, Image } from "@tarojs/components";
import { Block, View, Text, Image } from "@tarojs/components";
/** 自定义组件 **/
import Navbar from "../../components/navbar/navbar";
/** 自定义组件 **/
import "./errorpage.less";
@ -8,7 +12,7 @@ export default class Index extends Component<any, any> {
constructor(props) {
super(props);
this.state = {
name: "template模板页",
name: "错误页面",
};
}
@ -24,7 +28,13 @@ export default class Index extends Component<any, any> {
async initData() {}
render() {
let { name } = this.state;
return <View>{name}</View>;
return (
<Block>
<View>
<Navbar isBack={true}></Navbar>
<View className="error-tip"></View>
</View>
</Block>
);
}
}

@ -2,11 +2,6 @@ page {
background: #f3f3f3;
}
// .index-main {
// height: max-content;
// background: #f3f3f3;
// }
/* 隐藏横向滚动条 */
::-webkit-scrollbar {
width: 0;

@ -42,12 +42,7 @@ import {
// css引入
import "taro-ui/rn/style/components/calendar.scss";
import "./index.less";
import {
go,
goJump,
msg,
getStorageSync,
} from "@/utils/traoAPI";
import { go, goJump, msg, getStorageSync } from "@/utils/traoAPI";
class Index extends Component<any, any> {
// pageCtx = Taro.getCurrentInstance().page;
@ -56,6 +51,7 @@ class Index extends Component<any, any> {
constructor(props) {
super(props);
this.state = {
isRegisterBoolean: false, // 是否已登录
isShowPrivacyPopup: false,
isShowSiteSwiper: false,
isNotRegister: false, // 是否未注册
@ -90,11 +86,12 @@ class Index extends Component<any, any> {
bannerCurrent: 0,
/** 绑定仪器 */
isVisibleBinding: false,
isVisibleBinding: false, // 绑定弹窗
isBindingError: false, // 绑定失败
typeBinding: 0,
serial: "", // 仪器序列号
instrumentList: [], // 仪器列表
instrumentInfo: {
bindingStatus: 2,
bindingStatus: 0, // 绑定状态
createBy: null,
createTime: "2024-01-19 17:46:10",
exportFields: [],
@ -105,12 +102,12 @@ class Index extends Component<any, any> {
instrumentSerialIdList: [],
queryInstrumentIds: null,
remark: null,
serial: "1959895",
serial: "", // 设备序列号
source: "导入",
status: 0,
updateBy: null,
updateTime: null,
validStatus: 1,
validStatus: 1, // 有效状态
},
/** 绑定仪器 End */
};
@ -140,13 +137,33 @@ class Index extends Component<any, any> {
componentDidHide() {}
showInit() {
// 非扫码进入小程序,需判断是否跳转欢迎页;扫码进入小程序,直接检测隐私弹窗
if (!this.$instance.router?.params?.q) {
// 判断是否登录
let mobile = Taro.getStorageSync("mobile");
if (mobile) {
this.setState({ isRegisterBoolean: true });
}
// 非扫码进入小程序,需判断是否跳转欢迎页;扫码进入小程序,先缓存序列号,再检测隐私弹窗
let url = this.$instance.router?.params?.q || "";
if (!url) {
// 非扫码进入
Taro.setStorageSync("isScan", false);
const isFirst = Taro.getStorageSync("isWelcome");
if (isFirst) {
this.checkShowPrivacyPopup();
}
} else {
// 扫码进入
Taro.setStorageSync("isScan", true);
if (url) {
let _url = decodeURIComponent(url);
if (_url.indexOf("?")) {
let ids = _url.split("?");
if (ids.length > 1) {
let serial = ids[1];
Taro.setStorageSync("serial", serial);
}
}
}
this.checkShowPrivacyPopup();
}
}
@ -185,14 +202,13 @@ class Index extends Component<any, any> {
initPageData() {
const mobile = Taro.getStorageSync("mobile");
this.GetSiteCarousel();
if (mobile) {
this.GetNoReadMessageNum(); // 查询是否有消息
// let url = this.$instance.router?.params?.q;
// if (url) {
// }
this.getInstrumentInfoBySerial();
this.getInstrumentInfoBySerial(); // 扫码序列号查询:注册后才调用,因为扫码未注册直接跳转注册页
this.bindingInstrumentList(); // 获取已绑定设备
if (!this.props.isShowIndexFlag) {
this.GetSitePopupList();
@ -228,7 +244,6 @@ class Index extends Component<any, any> {
GetSitePopupList = async () => {
let res = await GetSitePopupList(1);
if (res.data.code === 200) {
// console.log("GetSitePopupList", res);
if (res.data.data) {
if (res.data.data.length) {
this.setState({
@ -280,8 +295,7 @@ class Index extends Component<any, any> {
} else {
Taro.setStorageSync("isInstrumentJump", "false"); // 重置
}
let mobile = Taro.getStorageSync("mobile");
if (!mobile) {
if (!this.state.isRegisterBoolean) {
this.alertRegister();
return false;
}
@ -303,12 +317,6 @@ class Index extends Component<any, any> {
public alertRegister = () => {
this.setState({ isNotRegister: true }); // 打开弹窗
// if (!this.props.mobile) {
// this.setState({ isNotRegister: true }); // 打开弹窗
// return;
// } else {
// go("/pages/instrument/instrument");
// }
};
onTimeChange = (value) => {
@ -354,8 +362,22 @@ class Index extends Component<any, any> {
goJump(item);
}
/* 扫码进入逻辑 */
//
/* 仪器与是否扫码进入逻辑 */
// 获取已绑定仪器列表
bindingInstrumentList = async () => {
Taro.showLoading({
title: "请求中...",
mask: true,
});
let { instrumentInfo } = this.state;
let { data } = await InstrumentInfo.bindingInstrumentList();
console.log("bindingInstrument", data);
Taro.hideLoading();
if (data.code === 200) {
this.setState({ instrumentList: data.data });
} else {
}
};
// 是否扫码进入小程序
isSancQrcodeEnter = async () => {
let instance = Taro.getCurrentInstance();
@ -374,11 +396,12 @@ class Index extends Component<any, any> {
});
const { code } = await Taro.login();
const { data } = await WCUserLogin({ code });
Taro.hideLoading();
if (data.code === 200) {
Taro.setStorageSync("isWelcome", true);
Taro.setStorageSync("mobile", data.data.mobile);
this.props.tokenRefresh(data.data);
Taro.hideLoading();
this.initPageData();
} else {
@ -386,42 +409,88 @@ class Index extends Component<any, any> {
this.WCUserLogin();
}
}
closeBinding() {
closeBinding = () => {
this.setState({ isVisibleBinding: false });
}
confirmBinding() {
this.setState({ isVisibleBinding: false });
}
};
confirmBinding = () => {
let { instrumentInfo } = this.state;
// 0未绑定 1 2
if (instrumentInfo.bindingStatus === 0) {
this.bindingInstrument();
}
};
// 根据扫码的序列号获取仪器信息
getInstrumentInfoBySerial = async () => {
let url = this.$instance.router?.params?.q;
if (url) {
let _url = decodeURIComponent(url);
if (_url.indexOf("?")) {
let ids = _url.split("?");
if (ids.length > 1) {
let serial = ids[1];
let { data } = await InstrumentInfo.getInstrumentInfoBySerial({
serial: serial,
});
if (data.code === 200) {
console.log("Data", data);
this.setState({ serial });
}
let url = this.$instance.router?.params?.q || "";
let isScan = Taro.getStorageSync("isScan"); // 判断是否扫码进入
let serial = Taro.getStorageSync("serial"); // 扫码可能跳转注册页,所以先缓存
if (url || isScan) {
let { data } = await InstrumentInfo.getInstrumentInfoBySerial({
serial: serial,
});
if (data.code === 200) {
Taro.removeStorageSync("isScan");
Taro.removeStorageSync("serial"); // 获取成功,以后删除缓存的扫码序列号
let isVisibleBinding = false;
if (data.data.bindingStatus === 0) {
isVisibleBinding = true;
}
// 更新扫码进入仪器信息
this.setState({
isVisibleBinding,
instrumentInfo: data.data,
});
} else {
// 获取失败和绑定失败一个弹窗
this.setState({ isBindingError: true });
}
}
};
// 绑定仪器
bindingInstrument = async () => {
let { serial } = this.state;
Taro.showLoading({
title: "请求中...",
mask: true,
});
let { instrumentInfo } = this.state;
let { data } = await InstrumentInfo.binding({
serial: serial,
serial: instrumentInfo.serial,
});
console.log("bindingInstrument", data);
Taro.hideLoading();
if (data.code === 200) {
console.log("binding", data);
this.setState({ isVisibleBinding: false });
} else {
this.setState({ isBindingError: true });
}
};
exchangeBinding = async () => {
Taro.showLoading({
title: "请求中...",
mask: true,
});
let { instrumentInfo } = this.state;
let { data } = await InstrumentInfo.exchangeBinding({
serial: instrumentInfo.serial,
});
console.log("exchangeBinding", data);
Taro.hideLoading();
if (data.code === 200) {
this.setState({ isVisibleBinding: false });
} else {
this.setState({ isBindingError: true });
}
};
onBindErrorClose = () => {
this.setState({ isBindingError: false });
};
onBindErrorConfirm = () => {
this.onBindErrorClose();
go("/pages/consultant/consultant");
};
// InstrumentInfo
/* 扫码进入逻辑 */
@ -441,7 +510,10 @@ class Index extends Component<any, any> {
bannerCurrent,
// 绑定弹窗
isVisibleBinding,
isBindingError,
isRegisterBoolean,
typeBinding,
instrumentInfo,
} = this.state;
return (
@ -472,11 +544,23 @@ class Index extends Component<any, any> {
/>
<PopupBinding
type={typeBinding}
type={instrumentInfo.bindingStatus}
isShow={isVisibleBinding}
isRegisterBoolean={isRegisterBoolean}
data={instrumentInfo}
close={this.closeBinding}
confirm={this.confirmBinding}
/>
<PopupAlert
isShow={isBindingError}
title="提示"
content="序列号库仍在更新,请联系微信助手"
confirmButtonText="知道了"
textAlgin="center"
isClose={false}
close={this.onBindErrorClose}
confirm={this.onBindErrorConfirm}
></PopupAlert>
{/* <PopupPrivacyTest
closePrivacy={this.closePrivacy.bind(this)}
@ -517,7 +601,6 @@ class Index extends Component<any, any> {
src={require("../../img/index/right.png")}
style="width: 20rpx;height: 20rpx;"
/>
{/* <View className="at-icon at-icon-chevron-right"></View> */}
</View>
<View className="bg-while">
<AtCalendar
@ -561,53 +644,6 @@ class Index extends Component<any, any> {
</View>
</View>
{/* <View className="infobox7">
<View className="nurse_recommend_box flex aitems sb">
<View className="title"></View>
<View className="txt_box flex jcenter aitems" data-url="/pages/care_plan/list/list" onClick={this.goCarePlanList}>
<View className="txt"></View>
<Image className="right_icon" src="/img/index-right.png" mode="aspectFill"></Image>
</View>
</View>
<ScrollView className="scroll_View" enable-flex scroll-x>
<View className="recommend_list flex">
<Block wx:for="{{carePlanList}}" wx:key="index">
<View className="recommend_item" data-url="/pages/care_plan/detail/detail?id={{item.id}}" onClick={this.gourl}>
<Image className="banner_img" src={imgUrl+item.indexBanner} mode="aspectFill"></Image>
<View className="bottom flex sb fc">
<View className="title ellipsis2">{{item.title}}</View>
<View className="join_in {{carePlan.activity.id==item.id&&carePlan.join.status==1?'disabled':''}}">
<Block wx:if="{{carePlan.activity.id===item.id&&carePlan.join.status==1}}"></Block>
<Block wx:else></Block>
</View>
</View>
</View>
</Block>
</View>
</ScrollView>
</View> */}
{/* {bannerList.length && (
<View className="infobox3">
<Swiper
autoplay={true}
onAnimationFinish={this.bannerSwiperchange.bind(this)}
current={bannerCurrent}
>
{bannerList.map((item, index) => {
return (
<SwiperItem
key={"banner_" + index}
onClick={this.gobanner.bind(this)}
data-item={item}
>
<Image src={item.fileUrl} />
</SwiperItem>
);
})}
</Swiper>
</View>
)} */}
<View className="infobox3">
<Swiper
autoplay={true}

@ -116,11 +116,11 @@ class Initiate extends Component<any, any> {
});
const { code } = await Taro.login();
const { data } = await WCUserLogin({ code });
Taro.hideLoading();
if (data.code === 200) {
Taro.setStorageSync("isWelcome", true);
Taro.setStorageSync("mobile", data.data.mobile);
this.props.tokenRefresh(data.data);
Taro.hideLoading();
setTimeout(() => {
this.initData();

@ -49,17 +49,18 @@ page {
.top_title {
height: 45rpx;
font-size: 48rpx;
font-family: PingFang SC;
font-weight: 400;
color: #000;
color: #000000;
line-height: 1;
/*line-height: 60rpx;*/
margin: 70rpx 0 48rpx;
}
.top_tips {
width: 470rpx;
font-size: 26rpx;
/*font-weight: 400;*/
font-family: PingFang SC;
font-weight: 400;
color: #666666;
margin: 0 auto 18rpx;
line-height: 1;
@ -72,9 +73,9 @@ page {
.banner_list {
height: 460rpx;
line-height: 460rpx;
border-radius: 30rpx;
margin: 43rpx 35rpx 51rpx;
// margin: 43rpx 35rpx 51rpx;
margin: 43rpx 35rpx 67rpx;
background-color: #ababab;
}
@ -111,6 +112,7 @@ page {
font-size: 28rpx;
font-weight: bold;
color: #030000;
font-family: PingFang SC;
margin-bottom: 30rpx;
.label_text {
display: flex;
@ -118,7 +120,7 @@ page {
font-size: 26rpx;
color: #666;
.label-tips {
font-weight: normal;
font-weight: 400;
}
.label::after {
content: "*";
@ -197,6 +199,26 @@ page {
border: 2rpx solid transparent;
margin-right: 16rpx;
box-sizing: border-box;
.image {
width: 100%;
height: 160rpx;
}
.desc {
position: absolute;
bottom: 0;
width: 100%;
height: 63rpx;
background-color: #ffffff;
padding: 0 24rpx;
font-size: 26rpx;
font-weight: bold;
color: #000000;
font-family: PingFang SC;
/*text-align: center;*/
line-height: 63rpx;
box-sizing: border-box;
}
}
.cover:last-child {
@ -205,30 +227,9 @@ page {
.active_cover {
border-color: #f4e3cb;
}
.image {
width: 100%;
height: 160rpx;
}
.desc {
position: absolute;
bottom: 0;
width: 100%;
height: 63rpx;
background-color: #ffffff;
padding: 0 27rpx;
font-size: 26rpx;
font-weight: bold;
color: #000000;
/*text-align: center;*/
line-height: 63rpx;
box-sizing: border-box;
}
.active_cover .desc {
background: linear-gradient(90deg, #efdcc2, #fff2df);
.desc {
background: linear-gradient(90deg, #efdcc2, #fff2df);
}
}
.popup_box {

@ -37,6 +37,8 @@ export default class Instrument extends Component<any, any> {
super(props);
this.state = {
name: "instrument",
isBindingError: false,
isBindingCheckError: false,
style: "font-size: 28rpx; color: #ccc;",
succeedShow: false,
tipShow: false,
@ -66,7 +68,9 @@ export default class Instrument extends Component<any, any> {
};
}
async onLoad() {}
async onLoad() {
this.unbindingInstrumentInfoList();
}
componentDidMount() {}
componentWillUnmount() {}
@ -101,8 +105,7 @@ export default class Instrument extends Component<any, any> {
this.setState({ tipShow: true });
};
onTabTap = (e) => {
const { type } = e.currentTarget.dataset;
onTabTap = (type) => {
this.setState({
inputType: type,
});
@ -122,10 +125,15 @@ export default class Instrument extends Component<any, any> {
scanType: ["barCode", "qrCode"],
success: (res) => {
const result = decodeURIComponent(res.result);
const bindCode = result.split("?")[1];
this.setState({
bindCode,
});
if (result.indexOf("?") > -1) {
const bindCode = result.split("?")[1];
console.log("bindCode", bindCode);
this.setState({
bindCode,
});
}
this.bindingInstrument();
// this.getBindCodeInfo();
},
fail(err) {},
@ -183,37 +191,37 @@ export default class Instrument extends Component<any, any> {
// // }
// };
judgeBindCode = () => {
const { bindCode, bindCodeInfo } = this.state;
const opts: any = {};
if (bindCode && !bindCodeInfo) {
// 有仪器码, 但是没有找到信息时
opts.bindPopup = "noFoundPopup";
} else if (bindCode && bindCodeInfo && bindCodeInfo.isLabelCode) {
opts.bindPopup = "labelPopup";
} else if (
bindCode &&
bindCodeInfo.hadBindSame &&
bindCodeInfo.hadBindSameCode
) {
// 有仪器码, 如果有登录, 判断是绑定了同样的仪器和仪器的序列号是一致 -- 不弹弹窗, 回到首页
opts.bindCode = ""; // 重置bindCode
opts.bindPopup = ""; // 隐藏bindPopup
} else if (
bindCode &&
bindCodeInfo.hadBindSame &&
!bindCodeInfo.hadBindSameCode
) {
// 有仪器码, 如果有登录, 判断是绑定了同样的仪器, 但仪器的序列号不一致 -- 判断换绑
opts.bindPopup = "switchBindCodePopup";
} else if (bindCode && !bindCodeInfo.hadBindSame) {
// 有仪器码, 如果有登录, 判断不是绑定了同样的仪器 -- 绑定
opts.bindPopup = "toBindPopup";
}
if (Object.keys(opts).length) {
this.setState(opts);
}
};
// judgeBindCode = () => {
// const { bindCode, bindCodeInfo } = this.state;
// const opts: any = {};
// if (bindCode && !bindCodeInfo) {
// // 有仪器码, 但是没有找到信息时
// opts.bindPopup = "noFoundPopup";
// } else if (bindCode && bindCodeInfo && bindCodeInfo.isLabelCode) {
// opts.bindPopup = "labelPopup";
// } else if (
// bindCode &&
// bindCodeInfo.hadBindSame &&
// bindCodeInfo.hadBindSameCode
// ) {
// // 有仪器码, 如果有登录, 判断是绑定了同样的仪器和仪器的序列号是一致 -- 不弹弹窗, 回到首页
// opts.bindCode = ""; // 重置bindCode
// opts.bindPopup = ""; // 隐藏bindPopup
// } else if (
// bindCode &&
// bindCodeInfo.hadBindSame &&
// !bindCodeInfo.hadBindSameCode
// ) {
// // 有仪器码, 如果有登录, 判断是绑定了同样的仪器, 但仪器的序列号不一致 -- 判断换绑
// opts.bindPopup = "switchBindCodePopup";
// } else if (bindCode && !bindCodeInfo.hadBindSame) {
// // 有仪器码, 如果有登录, 判断不是绑定了同样的仪器 -- 绑定
// opts.bindPopup = "toBindPopup";
// }
// if (Object.keys(opts).length) {
// this.setState(opts);
// }
// };
onCustomerTap = () => {
this.onCancelBind2Tap();
@ -237,8 +245,6 @@ export default class Instrument extends Component<any, any> {
let compressImage = await contraction(img, "compressImage");
// 压缩后文件地址
let compressTempFilePath = compressImage.tempFilePath;
console.log(" this.state", this.state);
let { channelInfo } = this.state;
channelInfo.image = compressTempFilePath;
this.setState({ channelInfo });
@ -252,7 +258,7 @@ export default class Instrument extends Component<any, any> {
if (!serial?.trim()) return msg("请输入设备序列号");
if (!image) return msg("请上传序列号照片");
// if (!buy_id) return msg('请选择购买渠道');
loading("绑定中");
// loading("绑定中");
// InstrumentBindingAdd({ serial, image, buy_id, instrument_id: id })
// .then((res) => {
// this.setState({ succeedShow: true });
@ -267,8 +273,7 @@ export default class Instrument extends Component<any, any> {
// });
};
onSelectChange(event) {
const { item } = event.currentTarget.dataset;
onSelectChange(item) {
const { channelInfo } = this.state;
if (channelInfo.id === item.id) return;
this.setState({
@ -291,11 +296,61 @@ export default class Instrument extends Component<any, any> {
}
};
// 未绑定列表
unbindingInstrumentInfoList = async () => {
let { data } = await InstrumentInfo.unbindingInstrumentInfoList();
if (data.code === 200) {
console.log("data", data);
if (data.data.length) {
this.setState({ equipmentList: data.data, channelInfo: data.data[0] });
}
}
};
// 绑定仪器
bindingInstrument = async () => {
Taro.showLoading({
title: "请求中...",
mask: true,
});
let { instrumentInfo } = this.state;
let { data } = await InstrumentInfo.binding({
serial: instrumentInfo.serial,
});
console.log("bindingInstrument", data);
Taro.hideLoading();
if (data.code === 200) {
// this.setState({ isVisibleBinding: false });
msg("绑定成功");
} else {
this.setState({ isBindingError: true });
}
};
onBindErrorClose = () => {
this.setState({ isBindingError: false });
};
onBindErrorConfirm = () => {
this.onBindErrorClose();
go("/pages/consultant/consultant");
};
onBindCheckErrorClose = () => {
this.setState({ isBindingCheckError: false });
};
render() {
let { isVideo, channelInfo, inputType, style, equipmentList } = this.state;
let {
isBindingError,
isBindingCheckError,
isVideo,
channelInfo,
inputType,
style,
equipmentList,
} = this.state;
return (
<Block>
<PopupAlert
{/* <PopupAlert
isShow={true}
isClose={true}
title="提示"
@ -304,9 +359,35 @@ export default class Instrument extends Component<any, any> {
textAlgin="center"
close={this.closeDev}
confirm={this.closeDev}
/>
<Canvas id="compressImage" canvasId="compressImage" type="2d"></Canvas>
/> */}
<Navbar titleSlot="仪器绑定" isBack={true} />
<PopupAlert
isShow={isBindingError}
title="提示"
content="序列号库仍在更新,请联系微信助手"
confirmButtonText="知道了"
textAlgin="center"
isClose={false}
close={this.onBindErrorClose}
confirm={this.onBindErrorClose}
></PopupAlert>
<PopupAlert
isShow={isBindingCheckError}
title="提示"
content="您选择的仪器有误,请重新选择确认"
confirmButtonText="知道了"
textAlgin="center"
isClose={false}
close={this.onBindCheckErrorClose}
confirm={this.onBindCheckErrorClose}
></PopupAlert>
<Canvas
style="height: 0"
id="compressImage"
canvasId="compressImage"
type="2d"
></Canvas>
<View></View>
<View className="main">
<View className="top">
@ -360,8 +441,7 @@ export default class Instrument extends Component<any, any> {
})}
id={"scroll" + item.id}
key={index}
data-item={item}
onClick={this.onSelectChange}
onClick={this.onSelectChange.bind(this, item)}
>
<Image
className="instrument_img"
@ -369,7 +449,7 @@ export default class Instrument extends Component<any, any> {
mode="aspectFill"
// mode="aspectFit"
></Image>
<View className="desc">{item.titile}</View>
<View className="desc">{item.name}</View>
</View>
);
})}
@ -381,8 +461,7 @@ export default class Instrument extends Component<any, any> {
className={classnames("tab_item", {
"is-active": inputType === 1,
})}
onClick={this.onTabTap}
data-type="1"
onClick={this.onTabTap.bind(this, 1)}
>
<Text></Text>
<View className="tab_active_line"></View>
@ -391,8 +470,7 @@ export default class Instrument extends Component<any, any> {
className={classnames("tab_item", {
"is-active": inputType === 2,
})}
onClick={this.onTabTap}
data-type="2"
onClick={this.onTabTap.bind(this, 2)}
>
<Text></Text>
<View className="tab_active_line"></View>
@ -417,18 +495,13 @@ export default class Instrument extends Component<any, any> {
</View>
<View className="ipt_box">
<Input
maxlength={50}
className="ipt"
placeholder="例如FR10*********1"
placeholder-style={style}
onInput={this.onSerial}
value={channelInfo.serial}
></Input>
{/* <Image
onClick={this.onScanCode}
className="icon"
src={require("../../img/welcome/scan-code.png")}
mode="widthFix"
></Image> */}
</View>
</View>
<View className="form_item">

@ -1,9 +1,9 @@
import classnames from "classnames";
import {Component} from "react";
import { Component } from "react";
import Taro from "@tarojs/taro";
// 引入 Swiper, SwiperItem 组件
import {Block, Button, Image, Text, View} from "@tarojs/components";
import { Block, Button, Image, Text, View } from "@tarojs/components";
/*** redux ***/
import { connect } from "react-redux";
import { setMobile } from "@/store/features/userInfo";
@ -50,7 +50,11 @@ class Register extends Component<any, any> {
}
onSkip = () => {
// go("/pages/instrument/instrument");
const isScan = Taro.getStorageSync("isScan");
if (isScan) {
Taro.setStorageSync("isScanNotRegisterSkip", true);
}
Taro.reLaunch({
url: "/pages/index/index",
});
@ -58,8 +62,7 @@ class Register extends Component<any, any> {
onDisagreeTap = () => {
// 关闭小程序
Taro.exitMiniProgram({
});
Taro.exitMiniProgram({});
};
onClosePrivacyContentPopup = () => {
this.setState({

@ -72,7 +72,7 @@ const userInfoReducer = createSlice({
state.integralText = payload.integralText || "";
Taro.setStorageSync("mobile", state.mobile);
// 设置token和过期时间
let expires = new Date().getTime() + 43200000;
setStorageSync("token", state.token, expires);
},

@ -257,22 +257,17 @@ export const InstrumentInfo = {
method: "get",
});
},
bindingInstrumentList: (data) => {
bindingInstrumentList: () => {
// 获取当前用户:已绑定仪器列表
return Ajax({
url:
"/hzwx/instrument/bindingInstrumentList" + paramsToUrlQueryString(data),
data,
url: "/hzwx/instrument/bindingInstrumentList",
method: "get",
});
},
unbindingInstrumentInfoList: (data) => {
unbindingInstrumentInfoList: () => {
// 获取当前用户:未绑定仪器列表
return Ajax({
url:
"/hzwx/instrument/unbindingInstrumentInfoList" +
paramsToUrlQueryString(data),
data,
url: "/hzwx/instrument/unbindingInstrumentInfoList",
method: "get",
});
},

@ -1,13 +1,17 @@
import { back, showModal, setStorageSync, getStorageSync } from "./traoAPI";
import { go, back, showModal, setStorageSync, getStorageSync } from "./traoAPI";
import { WCUserLogin } from "./Interface";
import Taro from "@tarojs/taro";
import formdata from "./wxFormdata/formData";
import store from "../store";
const global = store.getState().globalStore;
import { tokenRefresh } from "../store/features/userInfo";
const global = store.getState().globalStore;
const global_requestUrlList = []; // 全局正在请求的url地址防止多次点击
// api调用失败重试次数
let api_retry_count = 0;
export const Ajax = (params) => {
const app = Taro.getApp();
const domain = global.domain;
@ -39,18 +43,11 @@ export const Ajax = (params) => {
data: params.data,
success(res) {
if (res.statusCode !== 200) {
if (res.statusCode == 401) {
Taro.showModal({
title: "提示",
content: "登录已过期,请重新登录",
showCancel: false,
}).then((res) => {
setStorageSync("token", null);
Taro.clearStorage(); // 清空所有缓存
Taro.reLaunch({
url: "/pages/initiate/initiate",
});
});
if (res.statusCode == 401 || res.data.code == 403) {
// 自动重新登录
setStorageSync("token", null);
loginReload(params);
return;
}
Taro.showModal({
@ -73,24 +70,8 @@ export const Ajax = (params) => {
reject(res);
return false;
}
const noTipsCodes = [5001, 5002, 5003];
if (noTipsCodes.indexOf(res.data.code) == -1) {
Taro.showModal({
title: "提示",
content: msg,
showCancel: false,
}).then(() => {
reject(res);
if (res.data.code == 401 || res.data.msg === "登录状态已过期") {
setStorageSync("token", null);
Taro.reLaunch({
url: "/pages/initiate/initiate",
});
}
});
} else {
reject(res);
}
reject(res);
return false;
}
@ -101,11 +82,12 @@ export const Ajax = (params) => {
},
fail(err) {
console.log(err);
Taro.showModal({
title: "提示",
content: "请检查网络是否连接",
showCancel: false,
});
go("/pages/errorpage/errorpage");
// Taro.showModal({
// title: "提示",
// content: "请检查网络是否连接",
// showCancel: false,
// });
},
complete() {
// Taro.hideLoading();
@ -162,11 +144,12 @@ export const AjaxUploadFile = (params, formData) => {
reslove(o);
},
fail() {
Taro.showModal({
title: "提示",
content: "请检查网络是否连接",
showCancel: false,
});
go("/pages/errorpage/errorpage");
// Taro.showModal({
// title: "提示",
// content: "请检查网络是否连接",
// showCancel: false,
// });
},
complete() {
Taro.hideLoading();
@ -203,18 +186,10 @@ export const AjaxFormData = (params) => {
data: params.data.buffer,
success(res) {
if (res.statusCode !== 200) {
if (res.statusCode == 401) {
Taro.showModal({
title: "提示",
content: "登录已过期,请重新登录",
showCancel: false,
}).then((res) => {
setStorageSync("token", null);
Taro.clearStorage(); // 清空所有缓存
Taro.reLaunch({
url: "/pages/initiate/initiate",
});
});
if (res.statusCode == 401 || res.data.code == 403) {
// 自动重新登录
setStorageSync("token", null);
loginReload(params);
return;
}
Taro.showModal({
@ -240,11 +215,15 @@ export const AjaxFormData = (params) => {
showCancel: false,
}).then(() => {
reject(res);
if (res.data.code == 401 || res.data.msg === "登录状态已过期") {
if (
res.data.code == 401 ||
res.data.code == 403 ||
res.data.msg === "登录状态已过期"
) {
// 自动重新登录
setStorageSync("token", null);
Taro.reLaunch({
url: "/pages/initiate/initiate",
});
loginReload(params);
return;
}
});
} else {
@ -256,11 +235,12 @@ export const AjaxFormData = (params) => {
},
fail(err) {
console.log(err);
Taro.showModal({
title: "提示",
content: "请检查网络是否连接",
showCancel: false,
});
go("/pages/errorpage/errorpage");
// Taro.showModal({
// title: "提示",
// content: "请检查网络是否连接",
// showCancel: false,
// });
},
complete() {
// Taro.hideLoading();
@ -273,3 +253,56 @@ export const AjaxFormData = (params) => {
});
});
};
// 自动重新登录后,重新发起上一个请求
const AjaxReloadAPI = async (_params) => {
if (api_retry_count === 0) {
Ajax(_params);
}
if (api_retry_count < 3) {
api_retry_count = api_retry_count + 1;
Ajax(_params);
} else {
api_retry_count = 0; // 清空重新调用次数,
Taro.showModal({
title: "提示",
content: "接口请求失败,请联系管理员",
showCancel: false,
}).then((res) => {});
}
};
// 重新登陆后,发起上一个请求
const loginReload = async (_params) => {
Taro.showLoading({
title: "请求中...",
mask: true,
});
const { code } = await Taro.login();
const { data } = await Ajax({
// url: "/wx/user/login",
url: "/hzwx/user/login?code=" + code,
data: { code: code },
method: "POST",
});
Taro.hideLoading();
if (data.code === 200) {
setStorageSync("isWelcome", true);
setStorageSync("mobile", data.data.mobile);
store.dispatch(tokenRefresh(data.data));
Ajax(_params);
} else {
Taro.showModal({
title: "提示",
content: "登录已过期,请重新登录",
showCancel: false,
}).then((res) => {
setStorageSync("token", null);
Taro.clearStorage(); // 清空所有缓存
Taro.reLaunch({
url: "/pages/initiate/initiate",
});
});
}
};

Loading…
Cancel
Save