|
|
|
|
@ -12,23 +12,22 @@ import {
|
|
|
|
|
// Button,
|
|
|
|
|
Video,
|
|
|
|
|
ScrollView,
|
|
|
|
|
Canvas,
|
|
|
|
|
} from "@tarojs/components";
|
|
|
|
|
|
|
|
|
|
import { Toast } from "@antmjs/vantui";
|
|
|
|
|
import {
|
|
|
|
|
BuyPropertyList,
|
|
|
|
|
InstrumentBindingAdd,
|
|
|
|
|
InstrumentBindingChangeSerial,
|
|
|
|
|
InstrumentCodeCheck,
|
|
|
|
|
InstrumentList,
|
|
|
|
|
Uploads,
|
|
|
|
|
UserInfo,
|
|
|
|
|
WCUserLogin,
|
|
|
|
|
} from "../../utils/Interface";
|
|
|
|
|
import { go, back, loading, msg, showModal } from "../../utils/traoAPI";
|
|
|
|
|
import { isVideo } from "../../utils/util";
|
|
|
|
|
import utilHtml from "../../utils/utilhtml";
|
|
|
|
|
const log = require("../../utils/log");
|
|
|
|
|
// const log = require("../../utils/log");
|
|
|
|
|
|
|
|
|
|
import { getImgInfo, contraction } from "../../utils/compressImage";
|
|
|
|
|
|
|
|
|
|
import Navbar from "../../components/navbar/navbar";
|
|
|
|
|
|
|
|
|
|
@ -42,11 +41,18 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
style: "font-size: 28rpx; color: #ccc;",
|
|
|
|
|
succeedShow: false,
|
|
|
|
|
tipShow: false,
|
|
|
|
|
isChannelShow: false,
|
|
|
|
|
loading: true,
|
|
|
|
|
channelList: [],
|
|
|
|
|
channelInfo: {},
|
|
|
|
|
equipmentList: [],
|
|
|
|
|
channelInfo: {
|
|
|
|
|
image: "",
|
|
|
|
|
},
|
|
|
|
|
equipmentList: [
|
|
|
|
|
{
|
|
|
|
|
id: 1,
|
|
|
|
|
banner: "",
|
|
|
|
|
titile: "测试",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
isVideo: false,
|
|
|
|
|
inputType: 1, //1.手写 2.扫码绑定
|
|
|
|
|
bindCode: "",
|
|
|
|
|
@ -112,62 +118,62 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
this.setState({
|
|
|
|
|
bindCode,
|
|
|
|
|
});
|
|
|
|
|
this.getBindCodeInfo();
|
|
|
|
|
// this.getBindCodeInfo();
|
|
|
|
|
},
|
|
|
|
|
fail(err) {},
|
|
|
|
|
complete(res) {},
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
getBindCodeInfo = async () => {
|
|
|
|
|
const { bindCode, instrumentList, channelInfo } = this.state;
|
|
|
|
|
// 1.查询资料
|
|
|
|
|
try {
|
|
|
|
|
const { data } = await InstrumentCodeCheck({
|
|
|
|
|
code: bindCode,
|
|
|
|
|
});
|
|
|
|
|
const bindCodeInfo = { ...data.data.bindCodeInfo };
|
|
|
|
|
// 2.判断是否是选中的仪器, 如果不是, 直接弹出scanErrorPopup
|
|
|
|
|
if (channelInfo.id != bindCodeInfo.instrument_id) {
|
|
|
|
|
this.setState({
|
|
|
|
|
bindPopup: "scanErrorPopup",
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const match = instrumentList.find((item) => {
|
|
|
|
|
if (item.id == bindCodeInfo.instrument_id && item.serial) {
|
|
|
|
|
// 找到同一个仪器
|
|
|
|
|
bindCodeInfo.hadBindSame = true;
|
|
|
|
|
if (item.serial == bindCodeInfo.antifakeCode) {
|
|
|
|
|
// 找到同一个序列号
|
|
|
|
|
bindCodeInfo.hadBindSameCode = true;
|
|
|
|
|
} else {
|
|
|
|
|
bindCodeInfo.hadBindSameCode = false;
|
|
|
|
|
}
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
if (item.id == bindCodeInfo.instrument_id) {
|
|
|
|
|
const { channelInfo } = this.state;
|
|
|
|
|
if (channelInfo.id === item.id) return;
|
|
|
|
|
this.setState({
|
|
|
|
|
channelInfo: item,
|
|
|
|
|
isVideo: isVideo(item.bind_intro_video),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (match) {
|
|
|
|
|
bindCodeInfo.hadBind = true;
|
|
|
|
|
} else {
|
|
|
|
|
bindCodeInfo.hadBindSame = false;
|
|
|
|
|
}
|
|
|
|
|
this.setState({
|
|
|
|
|
bindCodeInfo,
|
|
|
|
|
});
|
|
|
|
|
this.judgeBindCode();
|
|
|
|
|
} catch (e) {
|
|
|
|
|
this.judgeBindCode();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
// getBindCodeInfo = async () => {
|
|
|
|
|
// const { bindCode, instrumentList, channelInfo } = this.state;
|
|
|
|
|
// // // 1.查询资料
|
|
|
|
|
// // try {
|
|
|
|
|
// // const { data } = await InstrumentCodeCheck({
|
|
|
|
|
// // code: bindCode,
|
|
|
|
|
// // });
|
|
|
|
|
// // const bindCodeInfo = { ...data.data.bindCodeInfo };
|
|
|
|
|
// // // 2.判断是否是选中的仪器, 如果不是, 直接弹出scanErrorPopup
|
|
|
|
|
// // if (channelInfo.id != bindCodeInfo.instrument_id) {
|
|
|
|
|
// // this.setState({
|
|
|
|
|
// // bindPopup: "scanErrorPopup",
|
|
|
|
|
// // });
|
|
|
|
|
// // return;
|
|
|
|
|
// // }
|
|
|
|
|
// // const match = instrumentList.find((item) => {
|
|
|
|
|
// // if (item.id == bindCodeInfo.instrument_id && item.serial) {
|
|
|
|
|
// // // 找到同一个仪器
|
|
|
|
|
// // bindCodeInfo.hadBindSame = true;
|
|
|
|
|
// // if (item.serial == bindCodeInfo.antifakeCode) {
|
|
|
|
|
// // // 找到同一个序列号
|
|
|
|
|
// // bindCodeInfo.hadBindSameCode = true;
|
|
|
|
|
// // } else {
|
|
|
|
|
// // bindCodeInfo.hadBindSameCode = false;
|
|
|
|
|
// // }
|
|
|
|
|
// // return item;
|
|
|
|
|
// // }
|
|
|
|
|
// // if (item.id == bindCodeInfo.instrument_id) {
|
|
|
|
|
// // const { channelInfo } = this.state;
|
|
|
|
|
// // if (channelInfo.id === item.id) return;
|
|
|
|
|
// // this.setState({
|
|
|
|
|
// // channelInfo: item,
|
|
|
|
|
// // isVideo: isVideo(item.bind_intro_video),
|
|
|
|
|
// // });
|
|
|
|
|
// // }
|
|
|
|
|
// // });
|
|
|
|
|
// // if (match) {
|
|
|
|
|
// // bindCodeInfo.hadBind = true;
|
|
|
|
|
// // } else {
|
|
|
|
|
// // bindCodeInfo.hadBindSame = false;
|
|
|
|
|
// // }
|
|
|
|
|
// // this.setState({
|
|
|
|
|
// // bindCodeInfo,
|
|
|
|
|
// // });
|
|
|
|
|
// // this.judgeBindCode();
|
|
|
|
|
// // } catch (e) {
|
|
|
|
|
// // this.judgeBindCode();
|
|
|
|
|
// // }
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
judgeBindCode = () => {
|
|
|
|
|
const { bindCode, bindCodeInfo } = this.state;
|
|
|
|
|
@ -213,48 +219,24 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onChangeImg() {
|
|
|
|
|
async onChangeImg() {
|
|
|
|
|
Taro.chooseMedia({
|
|
|
|
|
count: 1,
|
|
|
|
|
mediaType: ["image"],
|
|
|
|
|
success: (res) => {
|
|
|
|
|
success: async (res) => {
|
|
|
|
|
const tempFilePath = res.tempFiles[0].tempFilePath;
|
|
|
|
|
Uploads(tempFilePath).then((result) => {
|
|
|
|
|
const url = result.data.link;
|
|
|
|
|
this.setState({ "channelInfo.image": url });
|
|
|
|
|
});
|
|
|
|
|
let img = await getImgInfo(tempFilePath);
|
|
|
|
|
let compressImage = await contraction(img, "compressImage");
|
|
|
|
|
// 压缩后文件地址
|
|
|
|
|
let compressTempFilePath = compressImage.tempFilePath;
|
|
|
|
|
|
|
|
|
|
let { channelInfo } = this.state;
|
|
|
|
|
channelInfo.image = compressTempFilePath;
|
|
|
|
|
this.setState({ channelInfo });
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onChannelShow = () => {
|
|
|
|
|
this.setState({ isChannelShow: true });
|
|
|
|
|
this.getChannelList();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onChannelCancel = () => {
|
|
|
|
|
this.setState({ isChannelShow: false, loading: true });
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onChannelConfirm = (event) => {
|
|
|
|
|
const { id, type_name } = event.detail.value;
|
|
|
|
|
this.setState({
|
|
|
|
|
["channelInfo.buy_id"]: id,
|
|
|
|
|
["channelInfo.type_name"]: type_name,
|
|
|
|
|
});
|
|
|
|
|
this.onChannelCancel();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
getChannelList = () => {
|
|
|
|
|
BuyPropertyList({
|
|
|
|
|
type: 3,
|
|
|
|
|
limit: 9999,
|
|
|
|
|
page: 1,
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
this.setState({ channelList: res.data.data.list, loading: false });
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onSubmit = () => {
|
|
|
|
|
const that = this;
|
|
|
|
|
const { serial, image, buy_id, id } = this.state.channelInfo;
|
|
|
|
|
@ -262,18 +244,18 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
if (!image) return msg("请上传序列号照片");
|
|
|
|
|
// if (!buy_id) return msg('请选择购买渠道');
|
|
|
|
|
loading("绑定中");
|
|
|
|
|
InstrumentBindingAdd({ serial, image, buy_id, instrument_id: id })
|
|
|
|
|
.then((res) => {
|
|
|
|
|
this.setState({ succeedShow: true });
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
if (err.data.code != 500) {
|
|
|
|
|
that.setState({
|
|
|
|
|
errorMsg: err.data.msg,
|
|
|
|
|
bindPopup: "errorMsg",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// InstrumentBindingAdd({ serial, image, buy_id, instrument_id: id })
|
|
|
|
|
// .then((res) => {
|
|
|
|
|
// this.setState({ succeedShow: true });
|
|
|
|
|
// })
|
|
|
|
|
// .catch((err) => {
|
|
|
|
|
// if (err.data.code != 500) {
|
|
|
|
|
// that.setState({
|
|
|
|
|
// errorMsg: err.data.msg,
|
|
|
|
|
// bindPopup: "errorMsg",
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onSelectChange(event) {
|
|
|
|
|
@ -294,6 +276,7 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
let { isVideo, channelInfo, inputType, style, equipmentList } = this.state;
|
|
|
|
|
return (
|
|
|
|
|
<Block>
|
|
|
|
|
<Canvas id="compressImage" canvasId="compressImage" type="2d"></Canvas>
|
|
|
|
|
<Navbar titleSlot="仪器绑定" isBack={true} />
|
|
|
|
|
<View></View>
|
|
|
|
|
<View className="main">
|
|
|
|
|
@ -309,10 +292,10 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
<Video
|
|
|
|
|
className="banner_item"
|
|
|
|
|
autoplay
|
|
|
|
|
object-fit="cover"
|
|
|
|
|
enable-play-gesture
|
|
|
|
|
show-fullscreen-btn={false}
|
|
|
|
|
play-btn-position="center"
|
|
|
|
|
objectFit="cover"
|
|
|
|
|
enablePlayGesture
|
|
|
|
|
showFullscreenBtn={false}
|
|
|
|
|
playBtnPosition="center"
|
|
|
|
|
src={utilHtml.getHttpsUrl(channelInfo.bind_intro_Video)}
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
@ -336,29 +319,28 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
|
|
|
|
|
<ScrollView
|
|
|
|
|
scrollX={true}
|
|
|
|
|
className="instrument_list"
|
|
|
|
|
style="width: 100%; white-space: nowrap;"
|
|
|
|
|
scrollIntoView={"scroll" + channelInfo.id}
|
|
|
|
|
>
|
|
|
|
|
{equipmentList.map((item, index) => {
|
|
|
|
|
return (
|
|
|
|
|
<Block>
|
|
|
|
|
<View
|
|
|
|
|
className={classnames("cover", {
|
|
|
|
|
active_cover: channelInfo.id === item.id,
|
|
|
|
|
})}
|
|
|
|
|
id="{{'scroll' + item.id}}"
|
|
|
|
|
key={index}
|
|
|
|
|
data-item={item}
|
|
|
|
|
onClick={this.onSelectChange}
|
|
|
|
|
>
|
|
|
|
|
<Image
|
|
|
|
|
className="Image"
|
|
|
|
|
src={utilHtml.getHttpsUrl(item.banner)}
|
|
|
|
|
mode="aspectFill"
|
|
|
|
|
></Image>
|
|
|
|
|
<View className="desc">{item.titile}</View>
|
|
|
|
|
</View>
|
|
|
|
|
</Block>
|
|
|
|
|
<View
|
|
|
|
|
className={classnames("cover", {
|
|
|
|
|
active_cover: channelInfo.id === item.id,
|
|
|
|
|
})}
|
|
|
|
|
id={"scroll" + item.id}
|
|
|
|
|
key={index}
|
|
|
|
|
data-item={item}
|
|
|
|
|
onClick={this.onSelectChange}
|
|
|
|
|
>
|
|
|
|
|
<Image
|
|
|
|
|
className="instrument_img"
|
|
|
|
|
src={utilHtml.getHttpsUrl(item.banner)}
|
|
|
|
|
mode="aspectFill"
|
|
|
|
|
></Image>
|
|
|
|
|
<View className="desc">{item.titile}</View>
|
|
|
|
|
</View>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</ScrollView>
|
|
|
|
|
@ -394,7 +376,7 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
<View className="form_item is-inputCode">
|
|
|
|
|
<View className="label_box">
|
|
|
|
|
<View className="label">填写序列号</View>
|
|
|
|
|
<View className="Text" onClick={this.onTipShow}>
|
|
|
|
|
<View className="label_text" onClick={this.onTipShow}>
|
|
|
|
|
<Text className="label-tips">查看序列号位置</Text>
|
|
|
|
|
<Image
|
|
|
|
|
className="right_icon"
|
|
|
|
|
@ -404,19 +386,19 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
<View className="ipt_box">
|
|
|
|
|
<input
|
|
|
|
|
<Input
|
|
|
|
|
className="ipt"
|
|
|
|
|
placeholder="例如:FR10*********1"
|
|
|
|
|
placeholder-style={style}
|
|
|
|
|
onInput={this.onSerial}
|
|
|
|
|
value={channelInfo.serial}
|
|
|
|
|
></input>
|
|
|
|
|
<Image
|
|
|
|
|
></Input>
|
|
|
|
|
{/* <Image
|
|
|
|
|
onClick={this.onScanCode}
|
|
|
|
|
className="icon"
|
|
|
|
|
src={require("../../img/welcome/scan-code.png")}
|
|
|
|
|
mode="widthFix"
|
|
|
|
|
></Image>
|
|
|
|
|
></Image> */}
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
<View className="form_item">
|
|
|
|
|
@ -424,10 +406,10 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
<View className="label">上传序列号照片</View>
|
|
|
|
|
</View>
|
|
|
|
|
<View className="photo_box" onClick={this.onChangeImg}>
|
|
|
|
|
{channelInfo.Image && (
|
|
|
|
|
<Image src={channelInfo.Image}></Image>
|
|
|
|
|
{channelInfo.image && (
|
|
|
|
|
<Image src={channelInfo.image}></Image>
|
|
|
|
|
)}
|
|
|
|
|
{!channelInfo.Image && (
|
|
|
|
|
{!channelInfo.image && (
|
|
|
|
|
<Image
|
|
|
|
|
className="add"
|
|
|
|
|
src={require("../../img/welcome/add.png")}
|
|
|
|
|
@ -458,7 +440,6 @@ export default class Instrument extends Component<any, any> {
|
|
|
|
|
</View>
|
|
|
|
|
)}
|
|
|
|
|
</View>
|
|
|
|
|
<Toast />
|
|
|
|
|
</Block>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|