Commit 16dc8f30 by lirandong

Merge branch 'weapp' into rn

parents 80b31e2e 63e1dcf2
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
/* rn 特定样式 */ /* rn 特定样式 */
@mixin rn($attr, $value) { @mixin rn($attr, $value) {
/* #ifdef %RN% */ /* #ifdef rn */
#{$attr}: $value; #{$attr}: $value;
/* #endif */ /* #endif */
......
import Taro from '@tarojs/taro' import Taro from '@tarojs/taro'
import { Header } from 'react-navigation'
import AsyncStorage from '@react-native-community/async-storage' import AsyncStorage from '@react-native-community/async-storage'
/** 连接参数 */ /** 连接参数 */
...@@ -31,11 +32,18 @@ export function checkPhone(phone) { ...@@ -31,11 +32,18 @@ export function checkPhone(phone) {
return /^1[3456789]\d{9}$/.test(phone.toString()) return /^1[3456789]\d{9}$/.test(phone.toString())
} }
export function showMyToast({ result, tips }: { result?: any; tips?: string }) { export function showMyToast({ result, title }: { result?: any; title?: string }) {
if (!result && !tips) return if (!result && !title) return
Taro.showToast({ icon: 'none', title: result && result.msg ? result.msg : tips }) Taro.showToast({ icon: 'none', title: result && result.msg ? result.msg : title })
} }
export function getStatusBarHeight() { // export function getStatusBarHeight() {
return Taro.getSystemInfoSync().statusBarHeight + 46 // return Taro.getSystemInfoSync().statusBarHeight + 46
// }
/** 获取屏幕可用高度 */
export function getWindiwHeight() {
const { windowHeight } = Taro.getSystemInfoSync()
const HeaderHeight = process.env.TARO_ENV === 'rn' ? Header.HEIGHT : 0
return windowHeight - HeaderHeight
} }
...@@ -13,13 +13,14 @@ ...@@ -13,13 +13,14 @@
&-wrapper { &-wrapper {
width: 580px; width: 580px;
// height: 600px;
display: flex; display: flex;
margin-top: -50px; margin-top: -50px;
padding-top: 36px; padding-top: 36px;
border-radius: 8px; border-radius: 8px;
flex-direction: column; flex-direction: column;
background-color: white; background-color: white;
// height: auto;
@include rn(height, 600px);
} }
&-title { &-title {
......
...@@ -44,10 +44,10 @@ class AddDevicePIN extends Component { ...@@ -44,10 +44,10 @@ class AddDevicePIN extends Component {
if (!PIN) return if (!PIN) return
try { try {
await api.common.addDevicePIN(PIN) await api.common.addDevicePIN(PIN)
showMyToast({ tips: '添加成功~' }) showMyToast({ title: '添加成功~' })
// console.log({ res }) // console.log({ res })
} catch (error) { } catch (error) {
showMyToast({ result: error, tips: '添加失败~' }) showMyToast({ result: error, title: '添加失败~' })
console.error(error) console.error(error)
} }
} }
......
...@@ -90,11 +90,11 @@ class DeviceSelect extends Component { ...@@ -90,11 +90,11 @@ class DeviceSelect extends Component {
if (!filmId) return if (!filmId) return
try { try {
await api.common.updateEquipmentBinding([...checked], filmId) await api.common.updateEquipmentBinding([...checked], filmId)
showMyToast({ tips: '修改成功~' }) showMyToast({ title: '修改成功~' })
Taro.navigateBack() Taro.navigateBack()
} catch (error) { } catch (error) {
console.error(error) console.error(error)
showMyToast({ tips: '修改失败~' }) showMyToast({ title: '修改失败~' })
} }
} }
......
...@@ -116,10 +116,10 @@ class MyDevice extends Component { ...@@ -116,10 +116,10 @@ class MyDevice extends Component {
try { try {
await api.common.removeDevice(equipmentId) await api.common.removeDevice(equipmentId)
this.getDate() this.getDate()
showMyToast({ tips: '删除成功~' }) showMyToast({ title: '删除成功~' })
} catch (error) { } catch (error) {
console.error(error) console.error(error)
showMyToast({ result: error, tips: '失败成功~' }) showMyToast({ result: error, title: '失败成功~' })
} }
} }
}) })
...@@ -137,10 +137,10 @@ class MyDevice extends Component { ...@@ -137,10 +137,10 @@ class MyDevice extends Component {
// }) // })
// await this.bluetooth(result) // await this.bluetooth(result)
// await api.common.addDeviceToken(result) // await api.common.addDeviceToken(result)
// showMyToast({ tips: '添加成功~' }) // showMyToast({ title: '添加成功~' })
// this.getDate() // this.getDate()
} catch (error) { } catch (error) {
showMyToast({ result: error, tips: '添加失败~' }) showMyToast({ result: error, title: '添加失败~' })
console.error(error) console.error(error)
} }
} }
...@@ -160,7 +160,7 @@ class MyDevice extends Component { ...@@ -160,7 +160,7 @@ class MyDevice extends Component {
const { deviceId } = item const { deviceId } = item
await Taro.createBLEConnection({ deviceId }) await Taro.createBLEConnection({ deviceId })
Taro.stopBluetoothDevicesDiscovery() Taro.stopBluetoothDevicesDiscovery()
showMyToast({ tips: '蓝牙连接成功~' }) showMyToast({ title: '蓝牙连接成功~' })
Taro.showLoading({ title: '获取蓝牙参数...' }) Taro.showLoading({ title: '获取蓝牙参数...' })
const { services } = await Taro.getBLEDeviceServices({ deviceId }) // 获取服务列表 const { services } = await Taro.getBLEDeviceServices({ deviceId }) // 获取服务列表
...@@ -182,7 +182,7 @@ class MyDevice extends Component { ...@@ -182,7 +182,7 @@ class MyDevice extends Component {
await Taro.readBLECharacteristicValue({ deviceId, serviceId, characteristicId }) await Taro.readBLECharacteristicValue({ deviceId, serviceId, characteristicId })
// setTimeout(async () => { // setTimeout(async () => {
// Taro.closeBLEConnection({ deviceId }) // Taro.closeBLEConnection({ deviceId })
// showMyToast({ tips: '连接已断开~' }) // showMyToast({ title: '连接已断开~' })
// }, 10000) // }, 10000)
} }
} }
...@@ -194,7 +194,7 @@ class MyDevice extends Component { ...@@ -194,7 +194,7 @@ class MyDevice extends Component {
Taro.stopBluetoothDevicesDiscovery() Taro.stopBluetoothDevicesDiscovery()
const { errCode } = error const { errCode } = error
if (errCode === 10001) { if (errCode === 10001) {
showMyToast({ tips: '请打开手机蓝牙~' }) showMyToast({ title: '请打开手机蓝牙~' })
} }
} }
} }
......
...@@ -76,10 +76,10 @@ class Films extends Component { ...@@ -76,10 +76,10 @@ class Films extends Component {
try { try {
await api.common.removeFilm(filmId) await api.common.removeFilm(filmId)
this.getData() this.getData()
showMyToast({ tips: '删除成功~' }) showMyToast({ title: '删除成功~' })
} catch (error) { } catch (error) {
console.error(error) console.error(error)
showMyToast({ tips: '失败成功~' }) showMyToast({ title: '失败成功~' })
} }
} }
}) })
......
...@@ -14,13 +14,13 @@ ...@@ -14,13 +14,13 @@
} }
.temp-name { .temp-name {
@include eject(display, block);
@include eject(box-sizing, border-box);
width: 100%; width: 100%;
font-size: 28px; font-size: 28px;
padding-top: 10px; padding-top: 10px;
background-color: white; background-color: white;
@include eject(display, block);
@include eject(box-sizing, border-box);
} }
.equipment-count { .equipment-count {
......
...@@ -14,14 +14,15 @@ interface PageOwnProps {} ...@@ -14,14 +14,15 @@ interface PageOwnProps {}
interface TempItem { interface TempItem {
props: IProps props: IProps
state: PageState state: PageState
// "navigateTo:fail page "pages/home/tempaltes/pages/home/tempaltes/detail?templateId=%5Bobject%20Object%5D&__key_=15656132800593" is not found"
} }
class TempItem extends Component { class TempItem extends Component {
goDetail = () => { goDetail = () => {
const { templateId, filmId } = this.props const { templateId, filmId } = this.props
// Taro.navigateTo({ url: '/pages/home/device/my_film/index' })
if (filmId) { if (filmId) {
Taro.navigateTo({ url: `/pages/home/tempaltes/film_detail?filmId=${filmId}` }) Taro.navigateTo({ url: `/pages/home/tempaltes/film_detail?filmId=${filmId}` })
// Taro.navigateTo({ url: `/pages/home/device/my_film/index` })
} else { } else {
Taro.navigateTo({ url: `/pages/home/tempaltes/detail?templateId=${templateId}` }) Taro.navigateTo({ url: `/pages/home/tempaltes/detail?templateId=${templateId}` })
} }
......
...@@ -7,7 +7,10 @@ import { ComponentClass } from 'react' ...@@ -7,7 +7,10 @@ import { ComponentClass } from 'react'
import Taro, { Component, Config } from '@tarojs/taro' import Taro, { Component, Config } from '@tarojs/taro'
import { View, Text, ScrollView, Button, Input } from '@tarojs/components' import { View, Text, ScrollView, Button, Input } from '@tarojs/components'
import { Header } from 'react-navigation'
import './scss/detail.scss' import './scss/detail.scss'
import { getWindiwHeight, showMyToast } from '@/common/utils'
type PageOwnProps = {} type PageOwnProps = {}
export interface IDetailData { export interface IDetailData {
...@@ -28,6 +31,7 @@ type PageState = { ...@@ -28,6 +31,7 @@ type PageState = {
showModal: boolean showModal: boolean
templateId: string templateId: string
filmDataList: any[] filmDataList: any[]
windowHeight: number
createFilmName: string createFilmName: string
createFilmDescribe: string createFilmDescribe: string
} }
...@@ -52,12 +56,14 @@ class TempDetail extends Component { ...@@ -52,12 +56,14 @@ class TempDetail extends Component {
showModal: false, showModal: false,
filmDataList: [], filmDataList: [],
createFilmName: '', createFilmName: '',
createFilmDescribe: '' createFilmDescribe: '',
windowHeight: getWindiwHeight()
} }
} }
componentWillMount() { componentWillMount() {
this.getData() this.getData()
// console.log('object', Taro.get)
} }
async getData() { async getData() {
...@@ -89,13 +95,17 @@ class TempDetail extends Component { ...@@ -89,13 +95,17 @@ class TempDetail extends Component {
inputConfirm = async () => { inputConfirm = async () => {
const { createFilmDescribe, createFilmName, templateId } = this.state const { createFilmDescribe, createFilmName, templateId } = this.state
if (!createFilmName) {
showMyToast({ title: '视片名称不能为空~' })
return
}
try { try {
await api.common.createFilm(createFilmDescribe, createFilmName, templateId) await api.common.createFilm(createFilmDescribe, createFilmName, templateId)
this.getData() this.getData()
this.cancelModal() this.cancelModal()
Taro.showToast({ title: '创建成功', icon: 'none' }) showMyToast({ title: '创建成功' })
} catch (error) { } catch (error) {
Taro.showToast({ title: '创建失败', icon: 'none' }) showMyToast({ title: '创建失败' })
} }
} }
...@@ -116,9 +126,10 @@ class TempDetail extends Component { ...@@ -116,9 +126,10 @@ class TempDetail extends Component {
} }
render() { render() {
const { detailData, filmDataList, showModal } = this.state const { detailData, filmDataList, showModal, windowHeight } = this.state
return ( return (
<View className="temp-detail"> <View className="temp-detail" style={{ height: windowHeight }}>
<View className="temp-detail-scroll"> <View className="temp-detail-scroll">
<ScrollView scrollY className="temp-detail-scroll-view"> <ScrollView scrollY className="temp-detail-scroll-view">
<DetailTop {...detailData} /> <DetailTop {...detailData} />
......
...@@ -69,6 +69,7 @@ class FilmDetail extends Component { ...@@ -69,6 +69,7 @@ class FilmDetail extends Component {
} }
chengDevice() { chengDevice() {
console.log('chengDevice')
const { filmId } = this.state const { filmId } = this.state
const url = `/pages/home/device/device_bind/index?filmId=${filmId}` const url = `/pages/home/device/device_bind/index?filmId=${filmId}`
Taro.navigateTo({ url }) Taro.navigateTo({ url })
......
...@@ -2,14 +2,15 @@ ...@@ -2,14 +2,15 @@
.temp-detail { .temp-detail {
width: 100%; width: 100%;
height: 100%;
display: flex; display: flex;
position: relative;
flex-direction: column; flex-direction: column;
background-color: white; background-color: white;
&-scroll { &-scroll {
flex: 1; flex: 1;
overflow: hidden; overflow: hidden;
padding-bottom: 90px;
&-view { &-view {
height: 100%; height: 100%;
...@@ -28,13 +29,18 @@ ...@@ -28,13 +29,18 @@
&-content { &-content {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
flex-direction: row;
justify-content: space-between; justify-content: space-between;
} }
} }
&-bottom-btn { &-bottom-btn {
left: 0;
bottom: 0;
width: 100%; width: 100%;
height: 90px;
border-radius: 0; border-radius: 0;
position: absolute;
background-color: $primary-color; background-color: $primary-color;
} }
} }
......
...@@ -34,15 +34,14 @@ ...@@ -34,15 +34,14 @@
&-scroll { &-scroll {
width: 100%; width: 100%;
height: 100%; height: 100%;
padding-top: 20px; padding: 20px 20px 0;
padding-left: 20px;
padding-right: 20px;
@include eject(box-sizing, border-box); @include eject(box-sizing, border-box);
&-list { &-list {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
flex-direction: row;
justify-content: space-between; justify-content: space-between;
} }
} }
......
...@@ -83,7 +83,7 @@ class Login extends Component { ...@@ -83,7 +83,7 @@ class Login extends Component {
}, 1000) }, 1000)
} catch (error) { } catch (error) {
// console.warn('获取验证码失败~', error) // console.warn('获取验证码失败~', error)
showMyToast({ result: error, tips: '获取验证码失败~' }) showMyToast({ result: error, title: '获取验证码失败~' })
} }
// Taro.hideLoading() // Taro.hideLoading()
} }
...@@ -102,7 +102,7 @@ class Login extends Component { ...@@ -102,7 +102,7 @@ class Login extends Component {
} }
} catch (error) { } catch (error) {
// console.warn('用户登录出错~', error) // console.warn('用户登录出错~', error)
showMyToast({ result: error, tips: '用户登录出错~' }) showMyToast({ result: error, title: '用户登录出错~' })
} }
} }
......
import { ADD_TEMP_LIST, ADD_FILM_LIST, ADD_DEVICE_LIST } from '../constants/counter' import { ADD_TEMP_LIST, ADD_FILM_LIST, ADD_DEVICE_LIST } from '../constants/counter'
import { number } from 'prop-types'
export interface ITempItem { export interface ITempItem {
filmId: string filmId: string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment