Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mp_snapshot
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄秀兰
mp_snapshot
Commits
bd586ef6
Commit
bd586ef6
authored
Jul 21, 2017
by
黄秀兰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
up
parent
cc1a9f0c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
18 deletions
+92
-18
app.js
+2
-0
components/slider/slider.js
+1
-1
pages/index/index.js
+9
-2
pages/upload-photo/upload-photo.js
+75
-2
pages/upload-photo/upload-photo.wxml
+2
-2
util/addPhoto.js
+3
-11
No files found.
app.js
View file @
bd586ef6
...
@@ -26,6 +26,8 @@ App({
...
@@ -26,6 +26,8 @@ App({
_this
.
api
[
key
]
=
promisify
(
wx
[
key
]);
_this
.
api
[
key
]
=
promisify
(
wx
[
key
]);
});
});
wx
.
setStorageSync
(
'user'
,
''
);
// 登录
// 登录
login
(
this
);
login
(
this
);
},
},
...
...
components/slider/slider.js
View file @
bd586ef6
...
@@ -49,7 +49,7 @@ function renderSliderData ( res, root_images ) {
...
@@ -49,7 +49,7 @@ function renderSliderData ( res, root_images ) {
// create_time
// create_time
var
create_time
;
var
create_time
;
create_time
=
exif
.
create_time
;
create_time
=
exif
.
create_time
;
if
(
exif
.
create_time
.
search
(
/
\/
/g
)
==
-
1
)
{
if
(
exif
.
create_time
.
search
(
/
\/
/g
)
==
-
1
&&
create_time
)
{
var
create_time_arr
=
exif
.
create_time
.
split
(
' '
);
var
create_time_arr
=
exif
.
create_time
.
split
(
' '
);
var
create_time_date
=
create_time_arr
[
0
].
split
(
':'
).
join
(
'-'
);
var
create_time_date
=
create_time_arr
[
0
].
split
(
':'
).
join
(
'-'
);
...
...
pages/index/index.js
View file @
bd586ef6
...
@@ -453,13 +453,16 @@ Page({
...
@@ -453,13 +453,16 @@ Page({
var
_this
=
this
;
var
_this
=
this
;
var
p1
=
this
.
loadTopPhoto
(
current
);
var
p1
=
this
.
loadTopPhoto
(
current
);
var
p2
=
this
.
loadPhotos
(
current
);
var
p2
=
this
.
loadPhotos
(
current
);
var
today_obj
=
this
.
formatTimeStamp
(
Date
.
now
());
var
today
=
today_obj
.
year
+
'-'
+
today_obj
.
month
+
'-'
+
today_obj
.
date
;
this
.
refreshData
(
p1
,
p2
).
then
(
res
=>
{
this
.
refreshData
(
p1
,
p2
).
then
(
res
=>
{
var
top
=
res
[
0
];
var
top
=
res
[
0
];
var
photos
=
res
[
1
];
var
photos
=
res
[
1
];
var
len
=
photos
.
length
;
var
len
=
photos
.
length
;
if
(
len
==
0
)
{
if
(
len
==
0
&&
isEmptyObj
(
top
)
)
{
var
date
;
var
date
;
var
timestamp
=
new
Date
(
current
).
getTime
();
var
timestamp
=
new
Date
(
current
).
getTime
();
...
@@ -476,12 +479,16 @@ Page({
...
@@ -476,12 +479,16 @@ Page({
date
=
next_obj
.
year
+
'-'
+
next_obj
.
month
+
'-'
+
next_obj
.
date
;
date
=
next_obj
.
year
+
'-'
+
next_obj
.
month
+
'-'
+
next_obj
.
date
;
}
}
if
(
today
==
current
)
{
_this
.
init
();
};
_this
.
circleGetCurrent
(
date
,
type
);
_this
.
circleGetCurrent
(
date
,
type
);
}
}
else
{
else
{
wx
.
hideLoading
();
wx
.
hideLoading
();
_this
.
changeDate
(
current
);
_this
.
changeDate
(
current
);
_this
.
setData
({
return
_this
.
setData
({
top_photo
:
top
,
top_photo
:
top
,
photos
:
photos
,
photos
:
photos
,
load_state
:
root_reducer
.
load_state
load_state
:
root_reducer
.
load_state
...
...
pages/upload-photo/upload-photo.js
View file @
bd586ef6
...
@@ -59,9 +59,22 @@ Page({
...
@@ -59,9 +59,22 @@ Page({
this
.
is_uploading
=
false
;
this
.
is_uploading
=
false
;
this
.
renderTags
();
this
.
renderTags
();
app
.
globalData
.
puzzelData
.
forEach
(
function
(
item
,
idx
)
{
app
.
globalData
.
puzzelData
.
forEach
(
function
(
item
,
idx
)
{
item
.
index
=
idx
;
item
.
index
=
idx
;
});
});
var
len
=
app
.
globalData
.
puzzelData
.
length
;
// 一次性添加了大于9张图片
if
(
len
>
9
)
{
app
.
globalData
.
puzzelData
.
splice
(
9
);
wx
.
showToast
({
title
:
'最多上传9张图片'
});
};
len
=
app
.
globalData
.
puzzelData
.
length
;
assignImgInfo
(
len
,
app
.
globalData
.
puzzelData
);
this
.
setData
({
this
.
setData
({
photos
:
app
.
globalData
.
puzzelData
photos
:
app
.
globalData
.
puzzelData
...
@@ -207,8 +220,54 @@ Page({
...
@@ -207,8 +220,54 @@ Page({
});
});
},
err
=>
{
},
err
=>
{
console
.
log
(
err
);
console
.
log
(
err
);
var
code
=
err
.
data
.
code
;
var
msg
=
err
.
data
.
message
;
var
msg
=
err
.
data
.
message
;
if
(
code
===
500002
)
{
var
tags
=
_this
.
data
.
tags
;
var
selectedTags
=
_this
.
data
.
selectedTags
;
var
len
=
tags
.
length
;
var
tag_id
=
err
.
data
.
data
.
id
;
var
idx
;
var
is_exit
=
tags
.
some
(
function
(
item
,
index
)
{
if
(
item
.
id
==
tag_id
)
{
idx
=
index
;
}
return
item
.
id
==
tag_id
});
if
(
!
is_exit
)
{
var
tag
=
{};
tag
.
id
=
tag_id
;
tag
.
text
=
err
.
data
.
data
.
text
;
tag
.
is_selected
=
true
;
tags
.
push
(
tag
);
selectedTags
.
push
(
tag
);
return
_this
.
setData
({
tags
:
tags
,
selectedTags
:
selectedTags
,
value
:
''
});
}
else
{
if
(
!
tags
[
idx
].
is_selected
)
{
tags
[
idx
].
is_selected
=
true
;
selectedTags
.
push
(
tags
[
idx
]);
return
_this
.
setData
({
tags
:
tags
,
selectedTags
:
selectedTags
,
value
:
''
});
}
}
};
if
(
msg
)
{
if
(
msg
)
{
wx
.
showToast
({
wx
.
showToast
({
title
:
msg
title
:
msg
...
@@ -290,7 +349,8 @@ Page({
...
@@ -290,7 +349,8 @@ Page({
});
});
wx
.
showLoading
({
wx
.
showLoading
({
title
:
'图片正在上传中'
title
:
'图片正在上传中'
,
mask
:
true
});
});
if
(
!
this
.
is_uploading
)
{
if
(
!
this
.
is_uploading
)
{
...
@@ -467,10 +527,23 @@ Page({
...
@@ -467,10 +527,23 @@ Page({
var
_this
=
this
;
var
_this
=
this
;
addPhoto
().
then
(
photos
=>
{
addPhoto
().
then
(
photos
=>
{
var
len
=
photos
.
length
;
if
(
len
>
9
)
{
photos
.
splice
(
9
);
wx
.
showToast
({
title
:
'最多上传9张图片'
});
}
photos
.
forEach
(
function
(
item
,
idx
)
{
photos
.
forEach
(
function
(
item
,
idx
)
{
item
.
index
=
idx
;
item
.
index
=
idx
;
});
});
len
=
photos
.
length
;
assignImgInfo
(
len
,
photos
);
_this
.
setData
({
_this
.
setData
({
photos
:
photos
photos
:
photos
});
});
...
...
pages/upload-photo/upload-photo.wxml
View file @
bd586ef6
<block wx:if="{{ route == 'puzzel' }}">
<block wx:if="{{ route == 'puzzel' }}">
<view class="puzzel">
<view class="puzzel">
<button class="btn btn-add-photo" bindtap="addPhoto">添加照片</button>
<button class="btn btn-add-photo" bindtap="addPhoto">添加照片</button>
<view class="tips" wx:if="{{ photos.length > 1 }}">拖动
图片可以调整顺序
</view>
<view class="tips" wx:if="{{ photos.length > 1 }}">拖动
可调整顺序,长按删除,预览方向不影响上传结果
</view>
<view class="photos photos-{{ photos.length }}" bindtouchstart="startMove" bindtouchmove="move" bindtouchend="endMove" bindlongtap="delPhoto">
<view class="photos photos-{{ photos.length }}" bindtouchstart="startMove" bindtouchmove="move" bindtouchend="endMove" bindlongtap="delPhoto">
<block wx:for="{{ photos }}" wx:key="item">
<block wx:for="{{ photos }}" wx:key="item">
<image data-index="{{ index }}" src="{{ item.src }}" class="photo photo-{{ index + 1 }}" mode="aspectFill" style="width: {{ item.width }}px; height: {{ item.height }}px; top: {{ item.y }}px; left: {{ item.x }}px; opacity: {{ item.opacity }}; z-index: {{ item.zIndex }}"></image>
<image data-index="{{ index }}" src="{{ item.src }}" class="photo photo-{{ index + 1 }}" mode="aspectFill" style="width: {{ item.width }}px; height: {{ item.height }}px; top: {{ item.y }}px; left: {{ item.x }}px; opacity: {{ item.opacity }}; z-index: {{ item.zIndex }}"></image>
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
<!-- 编辑框 -->
<!-- 编辑框 -->
<view class="edit-content">
<view class="edit-content">
<textarea placeholder="
说点什么吧~限140字
" placeholder-style="color: #999" bindblur="getContentValue" bindinput="changeTips" value="{{ content }}"/>
<textarea placeholder="
和大家分享分享照片背后的故事(限140字)
" placeholder-style="color: #999" bindblur="getContentValue" bindinput="changeTips" value="{{ content }}"/>
<view class="tips" hidden="{{ remain.hidden }}">还可以输入{{ remain.num }}字</view>
<view class="tips" hidden="{{ remain.hidden }}">还可以输入{{ remain.num }}字</view>
</view>
</view>
...
...
util/addPhoto.js
View file @
bd586ef6
...
@@ -41,8 +41,6 @@ function addPhoto ( route ) {
...
@@ -41,8 +41,6 @@ function addPhoto ( route ) {
console
.
log
(
err
);
console
.
log
(
err
);
});
});
})).
then
(
arr
=>
{
})).
then
(
arr
=>
{
var
total_len
=
app
.
globalData
.
puzzelData
.
length
;
assignImgInfo
(
total_len
,
app
.
globalData
.
puzzelData
);
if
(
route
)
{
if
(
route
)
{
var
is_navigate
=
route_arr
.
some
(
function
(
item
)
{
var
is_navigate
=
route_arr
.
some
(
function
(
item
)
{
...
@@ -52,20 +50,14 @@ function addPhoto ( route ) {
...
@@ -52,20 +50,14 @@ function addPhoto ( route ) {
});
});
if
(
is_navigate
)
{
if
(
is_navigate
)
{
wx
.
navigateTo
({
return
wx
.
navigateTo
({
url
:
'../upload-photo/upload-photo'
url
:
'../upload-photo/upload-photo'
});
});
}
}
}
}
if
(
total_len
>
9
)
{
app
.
globalData
.
puzzelData
.
splice
(
9
);
return
wx
.
showToast
({
title
:
'最多上传9张图片'
});
};
return
Promise
.
resolve
(
app
.
globalData
.
puzzelData
);
return
Promise
.
resolve
(
app
.
globalData
.
puzzelData
);
},
err
=>
{
},
err
=>
{
console
.
log
(
err
);
console
.
log
(
err
);
...
...
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