Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
visualcloud
/
Vmatrix-client-taro
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d7943521
authored
Jan 03, 2020
by
hank
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改context
parent
499e8fc9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
102 additions
and
72 deletions
+102
-72
src/common/bluetooth.ts
+16
-6
src/common/utils.ts
+1
-1
src/pages/home/tempaltes/DetailContext.ts
+3
-0
src/pages/home/tempaltes/conpoments/detail_top/index.tsx
+4
-0
src/pages/home/tempaltes/conpoments/temp_detail_content/index.tsx
+11
-1
src/pages/home/tempaltes/detail.tsx
+67
-64
No files found.
src/common/bluetooth.ts
View file @
d7943521
...
...
@@ -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
({
...
...
src/common/utils.ts
View file @
d7943521
...
...
@@ -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
'刚刚'
...
...
src/pages/home/tempaltes/DetailContext.ts
0 → 100644
View file @
d7943521
import
Taro
from
'@tarojs/taro'
const
MyContext
=
Taro
.
createContext
({
templateId
:
''
})
export
default
MyContext
src/pages/home/tempaltes/conpoments/detail_top/index.tsx
View file @
d7943521
...
...
@@ -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
=>
{
...
...
src/pages/home/tempaltes/conpoments/temp_detail_content/index.tsx
View file @
d7943521
...
...
@@ -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
src/pages/home/tempaltes/detail.tsx
View file @
d7943521
...
...
@@ -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
>
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment