Commit d7943521 by hank

修改context

parent 499e8fc9
......@@ -102,12 +102,12 @@ class Bluetooth {
/** 打开蓝牙的监听功能 */
async openListenBle(deviceId: string) {
await bluetooth.notifyBLECharacteristicValueChange({
deviceId,
state: true,
serviceId: BLE_SERVICE_ID,
characteristicId: DEVICE_TOKEN_TOKEN
})
// await bluetooth.notifyBLECharacteristicValueChange({
// deviceId,
// state: true,
// serviceId: BLE_SERVICE_ID,
// characteristicId: DEVICE_TOKEN_TOKEN
// })
await bluetooth.notifyBLECharacteristicValueChange({
deviceId,
state: true,
......@@ -156,6 +156,10 @@ class Bluetooth {
break
case DEVICE_TOKEN_TOKEN:
// 设备 token 信息回调
Taro.showToast({
title: '设备 formatDeviceToken 信息回调' + deviceId,
duration: 5000
})
console.log('设备 formatDeviceToken 信息回调', value, deviceId)
this.formatDeviceToken(deviceId, value)
break
......@@ -239,6 +243,12 @@ class Bluetooth {
deviceId,
state: true,
serviceId: BLE_SERVICE_ID,
characteristicId: DEVICE_TOKEN_TOKEN
})
await bluetooth.notifyBLECharacteristicValueChange({
deviceId,
state: true,
serviceId: BLE_SERVICE_ID,
characteristicId: POST_WIFI_PASS_ID
})
await bluetooth.notifyBLECharacteristicValueChange({
......
......@@ -64,7 +64,7 @@ export function formatTime(date) {
let times = new Date(date).getTime()
const now = new Date().getTime()
const value = now - times
console.log(times, now, value, just, 0 <= value && value <= just)
// console.log(times, now, value, just, 0 <= value && value <= just)
if (0 <= value && value <= just) {
return '刚刚'
......
import Taro from '@tarojs/taro'
const MyContext = Taro.createContext({ templateId: '' })
export default MyContext
......@@ -3,6 +3,7 @@ import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image, Swiper, SwiperItem } from '@tarojs/components'
import api from '@/api/index.ts'
import './index.scss'
// import MyContext from '@/pages/home/tempaltes/DetailContext'
type PageStateProps = {}
......@@ -14,6 +15,7 @@ type PageOwnProps = {
templateDescribe: string
templateShow?: string
templateId?: string
contextType?: object
}
type PageState = {
......@@ -31,8 +33,10 @@ interface DerailTop {
}
class DerailTop extends Component {
// static contextType = MyContext
public sendState = false
componentWillMount() {
console.log(this.context, 'DerailTop context')
const { templateId } = this.props
if (templateId) {
api.common.getCollectionState(String(templateId)).then(res => {
......
......@@ -3,6 +3,7 @@ import DetailTop from '../detail_top'
import { View, Text, Image } from '@tarojs/components'
import Taro from '@tarojs/taro'
import './index.scss'
import MyContext from '@/pages/home/tempaltes/DetailContext'
interface IProps {
detailData: any
......@@ -11,7 +12,13 @@ interface IProps {
onCreate?: () => void
}
export default function TempDetailContent(props: IProps) {
function TempDetailContent(props: IProps) {
// tslint:disable-next-line:no-invalid-this
// tslint:disable-next-line:no-debugger
// debugger
// tslint:disable-next-line:no-invalid-this
console.log(this.context, 'this.context')
const { detailData, filmDataList, templateId } = props
// console.log(templateId, 'TempDetailContent')
if (!templateId) {
......@@ -54,3 +61,6 @@ export default function TempDetailContent(props: IProps) {
</View>
)
}
TempDetailContent.contextType = MyContext
export default TempDetailContent
......@@ -10,7 +10,7 @@ import ListView from '@/conpoments/list_view'
import TempDetailContent from './conpoments/temp_detail_content'
import './scss/detail.scss'
import events from '../../../common/events'
import MyContext from './DetailContext'
type PageOwnProps = {
templateId: string
}
......@@ -150,77 +150,80 @@ class TempDetail extends Component {
render() {
const { detailData, filmDataList, showModal, windowHeight, count, templateId } = this.state
const { onClose } = this.props
console.log(templateId, 'templateId')
return (
<View
className="temp-detail"
catchtouchmove="preventTouchMove"
style={{ height: process.env.TARO_ENV === 'rn' ? windowHeight : '100%' }}
>
<View className="temp-detail-scroll">
{process.env.TARO_ENV === 'rn' ? (
<ScrollView scrollY className="temp-detail-scroll-view">
<TempDetailContent
detailData={detailData}
filmDataList={filmDataList}
templateId={templateId}
/>
</ScrollView>
) : (
<ListView
count={count}
dataListLength={filmDataList.length ? filmDataList.length : 1}
pullingUp={done => this.pullingUp(done)}
pullingDown={done => this.pullingDown(done)}
>
<View className="temp-detail-scroll-view">
<MyContext.Provider value={{ templateId: templateId }}>
<View
className="temp-detail"
catchtouchmove="preventTouchMove"
style={{ height: process.env.TARO_ENV === 'rn' ? windowHeight : '100%' }}
>
<View className="temp-detail-scroll">
{process.env.TARO_ENV === 'rn' ? (
<ScrollView scrollY className="temp-detail-scroll-view">
<TempDetailContent
detailData={detailData}
filmDataList={filmDataList}
templateId={templateId}
/>
<View style={{ height: '20px' }} />
</View>
</ListView>
)}
</View>
<View
className="top-bar-container"
onClick={() => {
events.emit('detailClose')
onClose && onClose()
}}
>
<Image
src="https://visual-clouds.oss-cn-beijing.aliyuncs.com/miniprogram/down-icon2.png"
className="close"
/>
{/* <View className="page-count">1/10</View> */}
{/* <View className="cllection-icon"></View> */}
</View>
<View className="bottom-btn-container">
<View className="bottom-btn" onClick={this.createFilm}>
创建新的作品
</ScrollView>
) : (
<ListView
count={count}
dataListLength={filmDataList.length ? filmDataList.length : 1}
pullingUp={done => this.pullingUp(done)}
pullingDown={done => this.pullingDown(done)}
>
<View className="temp-detail-scroll-view">
<TempDetailContent
detailData={detailData}
filmDataList={filmDataList}
templateId={templateId}
/>
<View style={{ height: '20px' }} />
</View>
</ListView>
)}
</View>
</View>
{showModal ? (
<Modal title="作品信息" onConfirm={this.inputConfirm} onCancel={this.cancelModal}>
<View className="film-modal">
<Text className="film-modal-text">作品名称</Text>
<Input
placeholder="请输入作品名称"
className="film-modal-input"
onInput={this.changeFilmName}
/>
<Text className="film-modal-text">作品描述</Text>
<Input
placeholder="请输入作品描述"
className="film-modal-input"
onInput={this.changeDescribeName}
/>
<View
className="top-bar-container"
onClick={() => {
events.emit('detailClose')
onClose && onClose()
}}
>
<Image
src="https://visual-clouds.oss-cn-beijing.aliyuncs.com/miniprogram/down-icon2.png"
className="close"
/>
{/* <View className="page-count">1/10</View> */}
{/* <View className="cllection-icon"></View> */}
</View>
<View className="bottom-btn-container">
<View className="bottom-btn" onClick={this.createFilm}>
创建新的作品
</View>
</Modal>
) : null}
</View>
</View>
{showModal ? (
<Modal title="作品信息" onConfirm={this.inputConfirm} onCancel={this.cancelModal}>
<View className="film-modal">
<Text className="film-modal-text">作品名称</Text>
<Input
placeholder="请输入作品名称"
className="film-modal-input"
onInput={this.changeFilmName}
/>
<Text className="film-modal-text">作品描述</Text>
<Input
placeholder="请输入作品描述"
className="film-modal-input"
onInput={this.changeDescribeName}
/>
</View>
</Modal>
) : null}
</View>
</MyContext.Provider>
)
}
}
......
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