diff --git a/src/app.config.ts b/src/app.config.ts index 27ad8f4..459f8dc 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -14,6 +14,8 @@ export default defineAppConfig({ "pages/register/register", 'pages/instrument/instrument', "pages/instrument/intro", + "pages/instrument_manage/index", + "pages/instrument_detail/index", 'pages/privacyPolicy/privacyPolicy', 'pages/userPolicy/userPolicy', 'pages/about/about', diff --git a/src/app.tsx b/src/app.tsx index f5e6821..6f44b5f 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -24,16 +24,8 @@ class App extends Component { return; } + // go("/pages/instrument/intro"); // Taro.switchTab({ - // url: "pages/index/index", - // }); - // go("/pages/initiate/initiate"); // 介绍页 - // go("/pages/entry/entry"); // 介绍页 - // go("/pages/userInfo/userInfo"); // 个人信息完善 - // go("/pages/register/register"); - // go("/pages/instrument/instrument"); - // go("/pages/userInfoDetail/userInfoDetail"); - // Taro.reLaunch({ // url: "/pages/user/user", // }); } diff --git a/src/components/popup/popup-site-swiper.tsx b/src/components/popup/popup-site-swiper.tsx index b70fd7f..5b6fecf 100644 --- a/src/components/popup/popup-site-swiper.tsx +++ b/src/components/popup/popup-site-swiper.tsx @@ -133,7 +133,7 @@ export default class PopupSiteSwiper extends Component { onChange={this.onChange.bind(this)} onAnimationFinish={this.onFinish.bind(this)} duration={800} - indicatorDots={true} + indicatorDots={false} indicatorColor="#999" indicatorActiveColor="#333" > diff --git a/src/pages/entry/entry.tsx b/src/pages/entry/entry.tsx index 33ae05d..97caf50 100644 --- a/src/pages/entry/entry.tsx +++ b/src/pages/entry/entry.tsx @@ -1,7 +1,7 @@ import classnames from "classnames"; import { Component } from "react"; import Taro from "@tarojs/taro"; -import {Block, Image, Swiper, SwiperItem, View,} from "@tarojs/components"; +import { Block, Image, Swiper, SwiperItem, View } from "@tarojs/components"; /*** redux ***/ import { connect } from "react-redux"; import { userRefresh } from "@/store/features/userInfo"; @@ -75,7 +75,7 @@ class Entry extends Component { let detail = JSON.parse(MpSplashDetail_type1); let list = detail.filter((item: any) => item.fileSuffix === "images"); if (list.length === 0) { - Taro.reLaunch({ + Taro.switchTab({ url: "/pages/index/index", }); return; @@ -89,7 +89,7 @@ class Entry extends Component { }); this.setState({ welcomeList }); } else { - Taro.reLaunch({ + Taro.switchTab({ url: "/pages/index/index", }); } @@ -121,7 +121,7 @@ class Entry extends Component { // Taro.switchTab({ // url: "/pages/index/index", // }); - Taro.reLaunch({ + Taro.switchTab({ url: "/pages/index/index", }); } @@ -198,8 +198,6 @@ class Entry extends Component { > {item.desc} - - diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 3cffd00..9792d4b 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -15,7 +15,6 @@ import { import { connect } from "react-redux"; import { userRefresh, tokenRefresh } from "../../store/features/userInfo"; import { setIndexFlag } from "../../store/features/globalStore"; -import { setInstrument } from "../../store/features/instrument"; /*** redux end ***/ /** 自定义组件 **/ @@ -43,7 +42,13 @@ 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, + setStorageSync, +} from "@/utils/traoAPI"; class Index extends Component { // pageCtx = Taro.getCurrentInstance().page; @@ -419,7 +424,7 @@ class Index extends Component { this.bindingInstrument(); } else { // 换绑仪器 - this.bindingInstrument(); + this.exchangeBinding(); } }; // 根据扫码的序列号获取仪器信息 @@ -443,6 +448,7 @@ class Index extends Component { } // 0已绑定 1未绑定 2已解绑 if (instrumentInfo.bindingStatus === 0) { + // 选择仪器有误 this.setState({ isBeforeBinding: true, }); @@ -501,14 +507,11 @@ class Index extends Component { return; } else if (data.code === 202) { // 换绑操作 - this.closeBinding(); this.setState({ isExchangeBinding: true, isVisibleBinding: true }); } else if (data.code === 201) { // 跳转联系客服 - this.closeBinding(); this.setState({ isBindingError: true }); } else { - this.closeBinding(); this.setState({ isBindingError: true }); } }; @@ -524,8 +527,8 @@ class Index extends Component { }); console.log("exchangeBinding", data); Taro.hideLoading(); + this.closeBinding(); if (data.code === 200) { - this.closeBinding(); } else { this.closeBinding(); this.setState({ isBindingError: true }); @@ -549,7 +552,7 @@ class Index extends Component { // 跳转仪器介绍页 goNursing = (item) => { console.log("goNursing", item); - this.props.setInstrument(item); + setStorageSync("instrument_item", JSON.stringify(item)); go("/pages/instrument/intro?id=" + item.id); }; /* 扫码进入逻辑 */ @@ -799,8 +802,5 @@ const mapDispatchToProps = (dispatch) => ({ setIndexFlag(data) { dispatch(setIndexFlag(data)); }, - setInstrument(data) { - dispatch(setInstrument(data)); - }, }); export default connect(mapStateToProps, mapDispatchToProps)(Index); diff --git a/src/pages/initiate/initiate.tsx b/src/pages/initiate/initiate.tsx index 03ae383..8a15e1b 100644 --- a/src/pages/initiate/initiate.tsx +++ b/src/pages/initiate/initiate.tsx @@ -94,13 +94,13 @@ class Initiate extends Component { return; } else { // 1-3.如果介绍页图片也没有,直接跳转首页 - Taro.reLaunch({ + Taro.switchTab({ url: "/pages/index/index", }); } } } else { - Taro.reLaunch({ + Taro.switchTab({ url: "/pages/index/index", }); } @@ -151,7 +151,7 @@ class Initiate extends Component { let detail = JSON.parse(data); let list = detail.filter((item: any) => item.fileSuffix === "images"); if (list.length === 0) { - Taro.reLaunch({ + Taro.switchTab({ url: "/pages/index/index", }); return; diff --git a/src/pages/instrument/instrument.less b/src/pages/instrument/instrument.less index 21a0c03..cdda653 100644 --- a/src/pages/instrument/instrument.less +++ b/src/pages/instrument/instrument.less @@ -22,7 +22,7 @@ page { .footer { position: fixed; - z-index: 1; + z-index: 10; bottom: 0; display: flex; justify-content: center; @@ -75,7 +75,8 @@ page { height: 460rpx; border-radius: 30rpx; // margin: 43rpx 35rpx 51rpx; - margin: 43rpx 35rpx 67rpx; + // margin: 43rpx 35rpx 67rpx; + margin: 43rpx 35rpx 89rpx; background-color: #ababab; } diff --git a/src/pages/instrument/instrument.tsx b/src/pages/instrument/instrument.tsx index 9b00040..f780fe5 100644 --- a/src/pages/instrument/instrument.tsx +++ b/src/pages/instrument/instrument.tsx @@ -18,9 +18,13 @@ import { } from "@tarojs/components"; import { InstrumentInfo } from "../../utils/Interface"; -import { go, back, loading, msg, showModal } from "../../utils/traoAPI"; -import { isVideo } from "../../utils/util"; -import utilHtml from "../../utils/utilhtml"; +import { + go, + back, + msg, + setStorageSync, + getStorageSync, +} from "../../utils/traoAPI"; import { getImgInfo, contraction } from "../../utils/compressImage"; @@ -45,9 +49,8 @@ export default class Instrument extends Component { channelList: [], channelInfo: { id: "", - image: "", + serialImage: "", serial: "", - bind_intro_Video: "", }, equipmentList: [ { @@ -127,13 +130,16 @@ export default class Instrument extends Component { if (result.indexOf("?") > -1) { const bindCode = result.split("?")[1]; console.log("bindCode", bindCode); + const { channelInfo } = this.state; + channelInfo.serial = bindCode; this.setState({ - bindCode, + channelInfo, }); } - this.bindingInstrument(); - // this.getBindCodeInfo(); + setTimeout(() => { + this.scanCodeBinding(); + }, 10); }, fail(err) {}, complete(res) {}, @@ -238,6 +244,9 @@ export default class Instrument extends Component { Taro.chooseMedia({ count: 1, mediaType: ["image"], + sourceType: ["album", "camera"], + sizeType: ["compressed"], + camera: "back", success: async (res) => { const tempFilePath = res.tempFiles[0].tempFilePath; let img = await getImgInfo(tempFilePath); @@ -245,39 +254,26 @@ export default class Instrument extends Component { // 压缩后文件地址 let compressTempFilePath = compressImage.tempFilePath; let { channelInfo } = this.state; - channelInfo.image = compressTempFilePath; + channelInfo.serialImage = compressTempFilePath; this.setState({ channelInfo }); }, }); }; onSubmit = () => { - const that = this; - const { serial, image, buy_id, id } = this.state.channelInfo; + const { serial, serialImage, id } = this.state.channelInfo; if (!serial?.trim()) return msg("请输入设备序列号"); - 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 != 400) { - // that.setState({ - // errorMsg: err.data.msg, - // bindPopup: "errorMsg", - // }); - // } - // }); + if (!serialImage) return msg("请上传序列号照片"); + this.manualCodeBinding(); }; onSelectChange(item) { const { channelInfo } = this.state; if (channelInfo.id === item.id) return; + channelInfo.serial = ""; this.setState({ channelInfo: item, - isVideo: isVideo(item.bind_intro_video), + isVideo: this.isVideo(item.banner), }); } @@ -289,38 +285,96 @@ export default class Instrument extends Component { // go("/pages/user/user"); let isInstrumentJump = Taro.getStorageSync("isInstrumentJump"); if (isInstrumentJump === "true") { - Taro.reLaunch({ + Taro.switchTab({ url: "/pages/user/user", }); } }; + isVideo = (str) => { + if (str.includes(".mp4")) { + return true; + } + return false; + }; + // 未绑定列表 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] }); + let item = data.data[0]; + this.setState({ + equipmentList: data.data, + channelInfo: item, + isVideo: this.isVideo(item.banner), + }); } } }; // 绑定仪器 - bindingInstrument = async () => { + manualCodeBinding = async () => { Taro.showLoading({ title: "请求中...", mask: true, }); - let { instrumentInfo } = this.state; - let { data } = await InstrumentInfo.binding({ - serial: instrumentInfo.serial, + let { channelInfo } = this.state; + let res = await InstrumentInfo.manualCodeBinding({ + serial: channelInfo.serial, + serialImage: channelInfo.serialImage, + instrumentId: channelInfo.id, }); - console.log("bindingInstrument", data); + console.log("bindingInstrument", res); Taro.hideLoading(); - if (data.code === 200) { + if (res.code === 200) { + this.binding(); + } else if (res.code === 204) { + this.setState({ isBindingCheckError: false }); + } else { + this.setState({ isBindingError: true }); + } + }; + scanCodeBinding = async () => { + Taro.showLoading({ + title: "请求中...", + mask: true, + }); + let { channelInfo } = this.state; + let res = await InstrumentInfo.scanCodeBinding({ + serial: channelInfo.serial, + instrumentId: channelInfo.id, + }); + console.log("bindingInstrument", res); + Taro.hideLoading(); + if (res.data.code === 200) { + // this.setState({ isVisibleBinding: false }); + this.binding(); + } else if (res.data.code === 204) { + this.setState({ isBindingCheckError: false }); + } else { + this.setState({ isBindingError: true }); + } + }; + + binding = async () => { + Taro.showLoading({ + title: "请求中...", + mask: true, + }); + + let { channelInfo } = this.state; + let res = await InstrumentInfo.binding({ + serial: channelInfo.serial, + }); + Taro.hideLoading(); + if (res.data.code === 200) { // this.setState({ isVisibleBinding: false }); msg("绑定成功"); + setStorageSync("instrument_item", JSON.stringify(channelInfo)); + go("/pages/instrument/intro?id=" + channelInfo.id); + } else if (res.data.code === 204) { + this.setState({ isBindingCheckError: false }); } else { this.setState({ isBindingError: true }); } @@ -341,7 +395,6 @@ export default class Instrument extends Component { let { isBindingError, isBindingCheckError, - isVideo, channelInfo, inputType, style, @@ -397,7 +450,7 @@ export default class Instrument extends Component { 完成花至美容仪绑定 - {isVideo && channelInfo.bind_intro_Video ? ( + {inputType === 1 ? ( @@ -444,7 +500,7 @@ export default class Instrument extends Component { > @@ -482,7 +538,12 @@ export default class Instrument extends Component { - 填写序列号 + + 填写序列号 + + * + + 查看序列号位置 { - 上传序列号照片 + + 上传序列号照片 + + * + + - {channelInfo.image && ( + {channelInfo.serialImage && ( )} - {!channelInfo.image && ( + {!channelInfo.serialImage && ( { +class Intro extends Component { constructor(props) { super(props); this.state = { name: "template模板页", current: 0, - info: {}, + instrument: {}, introList: [], isNursing: false, }; @@ -35,10 +41,16 @@ export default class Intro extends Component { async onLoad() {} componentDidMount() {} componentWillMount() { - console.log("Taro.Current", Taro.Current); - let params = Taro.Current?.router?.params; - if (params) { - this.getInstrumentInfo(params.id); + // let params = Taro.Current?.router?.params; + // if (params) { + // this.getInstrumentInfo(params.id); + // } + + let strObj = getStorageSync("instrument_item"); + if (strObj) { + let instrument = JSON.parse(strObj); + this.getInstrumentInfo(instrument.id); + this.setState({ instrument }); } } componentWillUnmount() {} @@ -51,49 +63,35 @@ export default class Intro extends Component { onChange(event) { console.info("onchange", event); - const current = event.detail.current; - this.setState({ current }); + // const current = event.detail.current; + // this.setState({ current }); } // 获取设备信息 async getInstrumentInfo(id) { - // const { data: res } = await InstrumentInfo({ id }); - let { data: res } = await InstrumentInfo.instructionInfo({ + let res = await InstrumentInfo.instructionInfo({ instrumentId: id, }); - console.log("instrumentId", res); - // if (res.code === 200) { - // const { intro_json } = res.data.info; - // if (intro_json) { - // try { - // res.data.info.intro_json = JSON.parse(intro_json); - // } catch (e) { - // console.log(e); - // } - // } - // this.setState({ - // info: res.data?.info, - // introList: res.data?.info?.intro_json, - // }); - // } + if (res.data.code === 200) { + this.setState({ introList: res.data.data }); + } } toNursing() { - if (this.state.info.iot === 2) { - this.setState({ isNursing: true }, () => { - this.toHomePage(); - }); - } else { - go("/pages/clock_in2/clock_in2?iid=" + this.state.info.id); - } + // if (this.state.info.iot === 2) { + // this.setState({ isNursing: true }, () => { + // this.toHomePage(); + // }); + // } else { + // go("/pages/clock_in2/clock_in2?iid=" + this.state.info.id); + // } } toHomePage() { - const { isNursing, info } = this.state; - if (isNursing) { - // isNursing ? '/pages/index/index?instrument_id=' + info.id - setStorageSync("introduceId", info.id); - } + // const { isNursing, info } = this.state; + // if (isNursing) { + // setStorageSync("introduceId", info.id); + // } const url = "/pages/index/index"; Taro.switchTab({ url, @@ -101,11 +99,22 @@ export default class Intro extends Component { } render() { - let { name, current, introList, info } = this.state; + let { current, introList, instrument } = this.state; return ( + - + {introList.map((item: any, index: number) => { return ( @@ -120,23 +129,28 @@ export default class Intro extends Component { )} - {info.titile} - {item.title} + {instrument.name} + {item.message} ); })} - - - + + {introList.length && ( + + {introList.map((_item, index) => { + return ( + + ); + })} + + )} @@ -151,3 +165,13 @@ export default class Intro extends Component { ); } } + +const mapStateToProps = (state) => ({ + instrument: state.instrument, +}); +const mapDispatchToProps = (dispatch) => ({ + setInstrument(data) { + dispatch(setInstrument(data)); + }, +}); +export default connect(mapStateToProps, mapDispatchToProps)(Intro); diff --git a/src/pages/instrument_detail/index.less b/src/pages/instrument_detail/index.less new file mode 100644 index 0000000..1ecf702 --- /dev/null +++ b/src/pages/instrument_detail/index.less @@ -0,0 +1,156 @@ +page { + background: #f8f8f8; + padding-bottom: calc(env(safe-area-inset-bottom)); +} +.list { + margin: 26rpx 30rpx 0rpx; + border-radius: 50rpx; + padding-bottom: 0rpx; + overflow: hidden; + position: relative; + height: calc(166rpx * 2); +} +.list > .instrument_img { + position: relative; + height: 100%; + /* top: -250rpx; */ +} +.list > .instrument_img .bind_status { + position: absolute; + top: 40rpx; + font-size: 24rpx; + left: 40rpx; + padding: 6rpx 40rpx; + background: linear-gradient(90deg, #fff0da, #ffe4c0); + border-radius: 30rpx; +} +.list > .instrument_img .titile { + position: absolute; + top: 110rpx; + left: 40rpx; + font-weight: bold; + font-size: 32rpx; + z-index: 99; +} +.list > .instrument_img .iot_versions { + position: absolute; + bottom: 40rpx; + left: 40rpx; + /* font-weight: bold; */ + font-size: 26rpx; + color: #666666; + z-index: 99; +} +.list > .name { + position: absolute; + bottom: 0; + color: #000; + font-size: 30rpx; + font-weight: bold; + padding: 30rpx; +} +.list > .bindbtn { + background: #cab18c; + position: absolute; + right: 6rpx; + top: 6rpx; + font-size: 24rpx; + border-radius: 56rpx; + width: 134rpx; + height: 48rpx; + line-height: 48rpx; + text-align: center; + text-align: center; + color: #fff; +} +.list > .bindbtn2 { + background: rgba(255, 255, 255, 0.6); + position: absolute; + right: 6rpx; + top: 6rpx; + font-size: 24rpx; + border-radius: 56rpx; + width: 134rpx; + height: 48rpx; + line-height: 48rpx; + text-align: center; + color: #000; +} + +.infobox1 { + .box { + .tip { + color: #d3bc8c; + font-size: 24rpx; + padding: 30rpx 30rpx 20rpx; + } + .tip2 { + padding: 30rpx 36rpx 30rpx 30rpx; + font-size: 28rpx; + color: #030000; + font-weight: 500; + display: flex; + align-items: center; + image { + width: 44rpx; + } + } + .inputbox { + width: 690rpx; + height: 80rpx; + background: #f2f2f2; + border: 1px solid #dddddd; + border-radius: 3rpx; + padding: 24rpx 28rpx; + margin: 0 30rpx; + display: flex; + align-items: center; + justify-content: space-between; + position: relative; + border: 1px solid #dddddd; + font-weight: 500; + box-sizing: border-box; + input { + width: 100%; + font-size: 28rpx; + } + .share_icon { + width: 42rpx; + } + .bottom_icon { + width: 20rpx; + } + .value { + font-size: 28rpx; + } + .picker { + position: absolute; + width: 100%; + top: 0; + bottom: 0; + left: 0; + z-index: 99; + opacity: 0; + } + .picker view { + position: absolute; + width: 100%; + top: 0; + bottom: 0; + left: 0; + z-index: 99; + opacity: 0; + } + } + + .serial_img { + width: 160rpx; + height: 160rpx; + margin: 0rpx 30rpx 20rpx; + border-radius: 20rpx; + } + .infobox1 text { + color: #d71229; + } + } +} diff --git a/src/pages/instrument_detail/index.tsx b/src/pages/instrument_detail/index.tsx new file mode 100644 index 0000000..1e53cde --- /dev/null +++ b/src/pages/instrument_detail/index.tsx @@ -0,0 +1,119 @@ +import Taro from "@tarojs/taro"; +import classnames from "classnames"; + +import { Component, PropsWithChildren, useEffect, useState } from "react"; +import { Block, View, Text, Image, Input, Button } from "@tarojs/components"; +import Navbar from "../../components/navbar/navbar"; + +import "./index.less"; +import { getStorageSync } from "@/utils/traoAPI"; + +export default class InstrumentDetail extends Component { + constructor(props) { + super(props); + this.state = { + name: "InstrumentDetail", + info: {}, + }; + } + + async onLoad() { + this.initData(); + } + componentDidMount() {} + + componentWillUnmount() {} + + componentDidShow() {} + + componentDidHide() {} + + async initData() { + let objStr = getStorageSync("instrument_detail"); + if (objStr) { + let info = JSON.parse(objStr); + this.setState({ info: info }); + } + } + + render() { + let { name, info } = this.state; + return ( + + + + + + + 已绑定 + {info.name} + {/* {info.iot == 2 && ( + + 当前软件版本号:{info.iot_versions} + + )} */} + + + + + + + 序列号 + + + + + + + 序列号照片 + + + + + 绑定时间 + + + + + + + 保修时间 + + + + + + {info.id == 74 || + (info.id == 73 && ( + + 软件完整版本号 + + + + + ))} + + + ); + } +} diff --git a/src/pages/instrument_manage/index.config.js b/src/pages/instrument_manage/index.config.js new file mode 100644 index 0000000..8560c5f --- /dev/null +++ b/src/pages/instrument_manage/index.config.js @@ -0,0 +1,3 @@ +export default definePageConfig({ + navigationBarTitleText: "设备管理", +}); diff --git a/src/pages/instrument_manage/index.less b/src/pages/instrument_manage/index.less new file mode 100644 index 0000000..966e9bc --- /dev/null +++ b/src/pages/instrument_manage/index.less @@ -0,0 +1,180 @@ +page { + background: #f8f8f8; + padding-bottom: calc(env(safe-area-inset-bottom)); +} +.instrument_box { + .title { + margin: 35rpx 37rpx; + font-size: 32rpx; + font-weight: bold; + color: #030000; + } +} + +.bind_list, +.un_bind_list { + width: 100%; + white-space: nowrap; + // margin-left: 37rpx; +} + +.un_bind_list { + margin-left: 37rpx; +} + +.bind_list { + height: 650rpx; + .wrapper { + display: inline-block; + position: relative; + width: 661rpx; + margin-right: 16rpx; + .bind_status { + position: absolute; + top: 40rpx; + font-size: 24rpx; + left: 40rpx; + padding: 6rpx 40rpx; + background: linear-gradient(90deg, #fff0da, #ffe4c0); + border-radius: 30rpx; + } + } + .cover { + display: inline-block; + position: relative; + width: 661rpx; + height: 350rpx; + border-radius: 50rpx; + overflow: hidden; + background: #fff; + box-sizing: border-box; + .image { + width: 100%; + height: 350rpx; + } + .title { + font-size: 26rpx; + font-weight: bold; + text-align: center; + color: #000000; + width: 100%; + line-height: 1; + margin: 30rpx 0; + box-sizing: border-box; + } + .intro { + position: absolute; + left: 40rpx; + bottom: 38rpx; + display: flex; + align-items: center; + justify-content: center; + margin-top: 10rpx; + .tips { + font-size: 26rpx; + font-weight: 500; + color: #666666; + text-align: center; + } + .right { + width: 26rpx; + margin-left: 5rpx; + display: inline; + } + } + } + + .bind_cont { + .title { + text-align: center; + font-size: 36rpx; + font-weight: bold; + color: #000000; + } + .bindinfo { + /* display: block; */ + margin: 0 auto; + width: 240rpx; + height: 60rpx; + line-height: 60rpx; + text-align: center; + /* background: transparent; */ + border-radius: 60rpx; + border: 1px solid #000000; + font-size: 26rpx; + color: #000000; + box-sizing: border-box; + } + } +} + +.un_bind_list { + .wrapper { + display: inline-block; + position: relative; + width: 335rpx; + margin-right: 16rpx; + } + .cover { + display: inline-block; + position: relative; + width: 335rpx; + height: 330rpx; + border-radius: 30rpx; + overflow: hidden; + background: #fff; + box-sizing: border-box; + .image { + display: block; + width: 100%; + height: 177rpx; + } + .name { + font-size: 26rpx; + font-weight: bold; + text-align: center; + color: #000000; + width: 100%; + line-height: 1; + margin: 30rpx 0; + box-sizing: border-box; + } + .buy { + display: flex; + align-items: center; + justify-content: center; + margin-top: 10rpx; + .tips { + font-size: 26rpx; + font-weight: 500; + color: #666666; + text-align: center; + } + .right { + width: 26rpx; + margin-left: 5rpx; + display: inline; + } + } + } + .bind_cont { + display: flex; + align-items: center; + justify-content: center; + margin: 30rpx 0; + .tobind { + width: 160rpx; + height: 60rpx; + line-height: 60rpx; + text-align: center; + background: #000000; + border-radius: 50rpx; + font-size: 26rpx; + color: #ffffff; + } + } +} +.scroll { + width: 100%; + overflow: hidden; +} diff --git a/src/pages/instrument_manage/index.tsx b/src/pages/instrument_manage/index.tsx new file mode 100644 index 0000000..893069e --- /dev/null +++ b/src/pages/instrument_manage/index.tsx @@ -0,0 +1,274 @@ +import Taro from "@tarojs/taro"; +import classnames from "classnames"; + +import { Component, PropsWithChildren, useEffect, useState } from "react"; +import { + Block, + View, + Text, + Image, + Input, + Button, + ScrollView, + Swiper, + SwiperItem, +} from "@tarojs/components"; + +import "./index.less"; +import Navbar from "../../components/navbar/navbar"; + +import { InstrumentInfo } from "../../utils/Interface"; +import { go, msg, setStorageSync } from "../../utils/traoAPI"; + +export default class InstrumentManage extends Component { + constructor(props) { + super(props); + this.state = { + name: "InstrumentManage", + userinfo: {}, + imgUrl: "", + imgUrl2: "", + list: [], + bindList: [], + unBindList: [], + page: 1, + isback: false, + //全局参数 + appdata: {}, + tipshow: false, + FR200LIST: [], + devinfo: {}, + current: 0, + }; + } + + async onLoad() { + this.initData(); + } + componentDidMount() {} + + componentWillUnmount() {} + + componentDidShow() {} + + componentDidHide() {} + + async initData() { + this.bindingInstrumentList(); + this.unbindingInstrumentInfoList(); + } + + // 获取已绑定仪器列表 + bindingInstrumentList = async () => { + Taro.showLoading({ + title: "请求中...", + mask: true, + }); + let { data: res } = await InstrumentInfo.bindingInstrumentList(); + Taro.hideLoading(); + if (res.code === 200) { + this.setState({ bindList: res.data }); + } else { + // 仪器列表失败todo + } + }; + // 获取未绑定仪器列表 + unbindingInstrumentInfoList = async () => { + Taro.showLoading({ + title: "请求中...", + mask: true, + }); + let { data: res } = await InstrumentInfo.unbindingInstrumentInfoList(); + Taro.hideLoading(); + if (res.code === 200) { + this.setState({ unBindList: res.data }); + } else { + // 仪器列表失败todo + } + }; + + goIntro(item) { + let bindid = item.id; + go("/pages/introduce/introduce?id=" + bindid); + } + goBind(item) { + let bindid = item.id; + go("/pages/instrument/instrument?id=" + bindid); + } + + goBindInfo(item) { + // let bindid = item.id; + setStorageSync("instrument_detail", JSON.stringify(item)); + go("/pages/instrument_detail/index"); + } + + async lesgobuy(item) { + console.log(item); + // if (item.programs_json) { + // item.programs_json = JSON.parse(item.programs_json); + // // console.log(item.programs_json) + // Taro.navigateToMiniProgram({ + // appId: item.programs_json.buylink, + // path: item.programs_json.buypath, + // envVersion: "release", + // success(res) { + // // 打开成功 + // }, + // fail() {}, + // }); + // } else { + // msg("暂无购买链接"); + // } + } + + render() { + let { bindList, unBindList, current } = this.state; + return ( + + + + {bindList.length && ( + + 我的设备 + + + {bindList.map((item: any, index: number) => { + return ( + + + + + 已绑定 + + + 仪器介绍 + + + + + + + + {item.name} + + 查看绑定信息 + + + + + ); + })} + + {/* + {bindList.map((item, index) => { + if (item.status === 0) { + return ( + + + + 已绑定 + + + 仪器介绍 + + + + + + + + {item.name} + + 查看绑定信息 + + + + ); + } + })} + */} + + + )} + + 未绑定的仪器 + + + {unBindList.map((item, index) => { + if (item.status === 0) { + return ( + + + + {item.name} + + 立即购买 + + + + + + + + 前往绑定 + + + + ); + } + })} + + + + + ); + } +} diff --git a/src/pages/integral_list/integral_list.tsx b/src/pages/integral_list/integral_list.tsx index 722fa9f..defdd6a 100644 --- a/src/pages/integral_list/integral_list.tsx +++ b/src/pages/integral_list/integral_list.tsx @@ -107,12 +107,12 @@ class IntegralList extends Component { envVersion: otherSetting.envVersion, success() { // 打开成功 - // Taro.reLaunch({ + // Taro.switchTab({ // url: "/pages/index/index", // }); }, fail() { - // Taro.reLaunch({ + // Taro.switchTab({ // url: "/pages/index/index", // }); }, @@ -378,7 +378,7 @@ class IntegralList extends Component { confirm={this.officialPopupConfirm} /> - + diff --git a/src/pages/register/register.tsx b/src/pages/register/register.tsx index c276fe2..47b8859 100644 --- a/src/pages/register/register.tsx +++ b/src/pages/register/register.tsx @@ -50,7 +50,7 @@ class Register extends Component { } onSkip = () => { - Taro.reLaunch({ + Taro.switchTab({ url: "/pages/index/index", }); }; diff --git a/src/pages/shop/shop.tsx b/src/pages/shop/shop.tsx index 0d8a1b7..1fb5eaa 100644 --- a/src/pages/shop/shop.tsx +++ b/src/pages/shop/shop.tsx @@ -58,12 +58,12 @@ class Shop extends Component { // sysVersion: otherSetting.sysVersion, success(res) { // 打开成功 - Taro.reLaunch({ + Taro.switchTab({ url: "/pages/index/index", }); }, fail(res) { - Taro.reLaunch({ + Taro.switchTab({ url: "/pages/index/index", }); }, diff --git a/src/pages/user/user.tsx b/src/pages/user/user.tsx index 9523e50..2cd6a52 100644 --- a/src/pages/user/user.tsx +++ b/src/pages/user/user.tsx @@ -264,10 +264,8 @@ class User extends Component { { - this.setState({ isDev: true }); - }} + data-url="/pages/instrument_manage/index?isback=1" + onClick={this.goUrlNoRegister} > { const isScan = Taro.getStorageSync("isScan"); if (isScan) { // Taro.setStorageSync("isScanNotRegisterSkip", true); - Taro.reLaunch({ + Taro.switchTab({ url: "/pages/index/index", }); return; @@ -269,7 +269,7 @@ class UserInfo extends Component { if (isInstrumentJump === "true") { go("/pages/instrument/instrument"); } else { - Taro.reLaunch({ + Taro.switchTab({ url: "/pages/user/user", }); } diff --git a/src/pages/userInfoDetail/userInfoDetail.tsx b/src/pages/userInfoDetail/userInfoDetail.tsx index 40354df..86eb30d 100644 --- a/src/pages/userInfoDetail/userInfoDetail.tsx +++ b/src/pages/userInfoDetail/userInfoDetail.tsx @@ -252,7 +252,7 @@ class UserInfoDetail extends Component { }; goUser = () => { - Taro.reLaunch({ + Taro.switchTab({ url: "/pages/user/user", }); }; diff --git a/src/store/features/instrument.js b/src/store/features/instrument.js index f6de6a4..aad8658 100644 --- a/src/store/features/instrument.js +++ b/src/store/features/instrument.js @@ -25,6 +25,7 @@ const instrumentReducer = createSlice({ }, reducers: { setInstrument(state, { payload }) { + console.log("payload", payload); state = JSON.parse(JSON.stringify(payload)); }, }, diff --git a/src/utils/Interface.js b/src/utils/Interface.js index bf20721..d480bd0 100644 --- a/src/utils/Interface.js +++ b/src/utils/Interface.js @@ -52,6 +52,7 @@ export const UpdateUserUploadFile = (formData) => { { url: "/user/updateUser", filePath: formData.file, + name: "file", }, formData ); @@ -279,12 +280,40 @@ export const InstrumentInfo = { method: "get", }); }, - manualCodeBinding: (data) => { - // 用户手动绑定仪器 + + bindingInstrumentInfo: () => { + // 获取当前用户:绑定记录 instrumentId return Ajax({ - url: "/instrument/manualCodeBinding", - data, - method: "post", + url: "/instrument/bindingInstrumentInfo" + paramsToUrlQueryString(data), + method: "get", + }); + }, + + // manualCodeBinding: (data) => { + // // 用户手动绑定仪器 + // return Ajax({ + // url: "/instrument/manualCodeBinding", + // data, + // method: "post", + // }); + // }, + manualCodeBinding: (formData) => { + // 用户手动绑定仪器 file 图片文件 + return AjaxUploadFile( + { + url: "/instrument/manualCodeBinding", + filePath: formData.serialImage, + name: "serialImage", + }, + formData + ); + }, + + scanCodeBinding: (data) => { + // 用户扫码绑定仪器 serial instrumentId + return Ajax({ + url: "/instrument/scanCodeBinding" + paramsToUrlQueryString(data), + method: "get", }); }, instructionInfo: (data) => { diff --git a/src/utils/request.js b/src/utils/request.js index 4ddf0a4..80a5fed 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -109,8 +109,8 @@ export const AjaxUploadFile = (params, formData) => { return new Promise((reslove, reject) => { let token = getStorageSync("token"); Taro.uploadFile({ - filePath: params.filePath, - name: "file", + filePath: params.filePath, // 上传文件地址 + name: params.name || "file", // 上传文件字段 url: domain + params.url, formData: { ...formData, @@ -299,7 +299,7 @@ const loginReload = async (_params) => { }).then((res) => { Taro.removeStorageSync("token"); Taro.clearStorage(); // 清空所有缓存 - Taro.reLaunch({ + Taro.navigateTo({ url: "/pages/initiate/initiate", }); });