Commit 16dc8f30 by lirandong

Merge branch 'weapp' into rn

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