商品分享功能 — review by 李其昌
Showing
11 changed files
with
188 additions
and
6 deletions
@@ -56,6 +56,7 @@ const config = { | @@ -56,6 +56,7 @@ const config = { | ||
56 | patterns: [ | 56 | patterns: [ |
57 | { from: 'src/assets/', to: 'dist/assets/' }, | 57 | { from: 'src/assets/', to: 'dist/assets/' }, |
58 | { from: 'src/libs/', to: 'dist/libs/' }, | 58 | { from: 'src/libs/', to: 'dist/libs/' }, |
59 | + { from: 'src/components/shareSheet', to: 'dist/components/shareSheet' }, | ||
59 | ], | 60 | ], |
60 | options: { | 61 | options: { |
61 | } | 62 | } |
1 | import { | 1 | import { |
2 | - SHOWSIZEBOX | 2 | + SHOWSIZEBOX, |
3 | + SHOWSHARESHEET | ||
3 | } from '../constants/productDetail' | 4 | } from '../constants/productDetail' |
4 | 5 | ||
5 | export const showSizeBox = (isShow) => { | 6 | export const showSizeBox = (isShow) => { |
@@ -8,4 +9,11 @@ export const showSizeBox = (isShow) => { | @@ -8,4 +9,11 @@ export const showSizeBox = (isShow) => { | ||
8 | type: SHOWSIZEBOX | 9 | type: SHOWSIZEBOX |
9 | } | 10 | } |
10 | } | 11 | } |
12 | + | ||
13 | +export const showSharesheet = (isShow) => { | ||
14 | + return { | ||
15 | + isShow, | ||
16 | + type: SHOWSHARESHEET | ||
17 | + } | ||
18 | +} | ||
11 | 19 |
src/assets/images/wechat@3x.png
0 → 100644
5.81 KB
src/assets/images/wechat_friend@3x.png
0 → 100644
4.8 KB
src/components/shareSheet/shareSheet.js
0 → 100644
1 | +import event from '../../utils/event.js' | ||
2 | + | ||
3 | +const CANCEL_SHARE = 'user-canel-share'; | ||
4 | + | ||
5 | +Component({ | ||
6 | + /** | ||
7 | + * 组件的属性列表 | ||
8 | + */ | ||
9 | + properties: { | ||
10 | + isShow: { | ||
11 | + type: Boolean, | ||
12 | + value: false, | ||
13 | + } | ||
14 | + }, | ||
15 | + | ||
16 | + /** | ||
17 | + * 组件的初始数据 | ||
18 | + */ | ||
19 | + data: { | ||
20 | + | ||
21 | + }, | ||
22 | + | ||
23 | + /** | ||
24 | + * 组件的方法列表 | ||
25 | + */ | ||
26 | + methods: { | ||
27 | + | ||
28 | + onShare: function(event) { | ||
29 | + let index = event.currentTarget.dataset.index; | ||
30 | + if (index == 1) {//微信好友 | ||
31 | + | ||
32 | + } else if (index == 2) {//朋友圈 | ||
33 | + | ||
34 | + } | ||
35 | + console.log('===================================='); | ||
36 | + console.log(index); | ||
37 | + console.log('===================================='); | ||
38 | + }, | ||
39 | + | ||
40 | + onCancel: function() { | ||
41 | + console.log('===================================='); | ||
42 | + console.log(22); | ||
43 | + console.log('===================================='); | ||
44 | + | ||
45 | + event.on(CANCEL_SHARE, () => { | ||
46 | + | ||
47 | + }); | ||
48 | + | ||
49 | + let prePage = getCurrentPages(); | ||
50 | + console.log(prePage); | ||
51 | + if (prePage.length > 0 && prePage[prePage.length - 1].onCancel != undefined) { | ||
52 | + prePage[prePage.length - 1].onCancel(); | ||
53 | + } | ||
54 | + } | ||
55 | + } | ||
56 | +}) |
src/components/shareSheet/shareSheet.json
0 → 100644
src/components/shareSheet/shareSheet.wxml
0 → 100644
1 | +<view class='container'> | ||
2 | + <view class='cover-view' bindtap='onCancel'></view> | ||
3 | + <view class='main-view'> | ||
4 | + <view class='share-view'> | ||
5 | + <view class='item' bindtap='onShare' data-index="1"> | ||
6 | + <image class='icon' src='../../assets/images/wechat_friend@3x.png'></image> | ||
7 | + <text class='title'>微信好友</text> | ||
8 | + </view> | ||
9 | + <view class='item' bindtap='onShare' data-index="2"> | ||
10 | + <image class='icon' src='../../assets/images/wechat@3x.png'></image> | ||
11 | + <text class='title'>朋友圈</text> | ||
12 | + </view> | ||
13 | + </view> | ||
14 | + <view class='line'></view> | ||
15 | + <view class='cancel' bindtap='onCancel'>取消</view> | ||
16 | + </view> | ||
17 | +</view> |
src/components/shareSheet/shareSheet.wxss
0 → 100644
1 | +.container { | ||
2 | + position: fixed; | ||
3 | + top: 0; | ||
4 | + right: 0; | ||
5 | + left: 0; | ||
6 | + bottom: 0; | ||
7 | + z-index: 1000; | ||
8 | +} | ||
9 | +.cover-view { | ||
10 | + background-color: black; | ||
11 | + opacity: 0.4; | ||
12 | + width: 100%; | ||
13 | + height: 100%; | ||
14 | + position: fixed; | ||
15 | + z-index: 1000; | ||
16 | +} | ||
17 | + | ||
18 | +.main-view { | ||
19 | + bottom: 0; | ||
20 | + width: 100%; | ||
21 | + height: 374rpx; | ||
22 | + background-color: white; | ||
23 | + position: fixed; | ||
24 | + z-index: 1200; | ||
25 | +} | ||
26 | +.main-view .share-view { | ||
27 | + height: 262rpx; | ||
28 | + display: flex; | ||
29 | + justify-content: space-evenly; | ||
30 | + align-items: center; | ||
31 | +} | ||
32 | +.main-view .line { | ||
33 | + height: 2rpx; | ||
34 | + margin-left: 40rpx; | ||
35 | + margin-right: 40rpx; | ||
36 | + background-color: #dddddd; | ||
37 | +} | ||
38 | +.main-view .cancel { | ||
39 | + height: 110rpx; | ||
40 | + font-family: PingFang-SC-Regular; | ||
41 | + font-size: 34rpx; | ||
42 | + color: #000000; | ||
43 | + letter-spacing: -0.23px; | ||
44 | + display: flex; | ||
45 | + align-items: center; | ||
46 | + justify-content: center; | ||
47 | +} | ||
48 | + | ||
49 | +.main-view .share-view .item { | ||
50 | + width: 100rpx; | ||
51 | + height: 100%; | ||
52 | +} | ||
53 | +.main-view .share-view .item .icon { | ||
54 | + width: 90rpx; | ||
55 | + height: 90rpx; | ||
56 | + margin-top: 62rpx; | ||
57 | +} | ||
58 | +.main-view .share-view .item .title { | ||
59 | + margin-top: 16rpx; | ||
60 | + font-family: PingFang-SC-Regular; | ||
61 | + font-size: 24rpx; | ||
62 | + color: #000000; | ||
63 | + letter-spacing: -0.16px; | ||
64 | +} |
@@ -4,7 +4,8 @@ import {productDetail as productDetailModel} from '../../models'; | @@ -4,7 +4,8 @@ import {productDetail as productDetailModel} from '../../models'; | ||
4 | import {getImgUrl} from '../../utils'; | 4 | import {getImgUrl} from '../../utils'; |
5 | import {ProductList, SelectSize} from '../../components'; | 5 | import {ProductList, SelectSize} from '../../components'; |
6 | import { connect } from '@tarojs/redux'; | 6 | import { connect } from '@tarojs/redux'; |
7 | -import { showSizeBox } from '../../actions/productDetail' | 7 | +import { showSizeBox, showSharesheet } from '../../actions/productDetail' |
8 | + | ||
8 | 9 | ||
9 | import share from '../../static/images/share.png'; | 10 | import share from '../../static/images/share.png'; |
10 | import collect from '../../static/images/collect.png'; | 11 | import collect from '../../static/images/collect.png'; |
@@ -17,6 +18,9 @@ import event from '../../utils/event' | @@ -17,6 +18,9 @@ import event from '../../utils/event' | ||
17 | }), (dispatch) => ({ | 18 | }), (dispatch) => ({ |
18 | showSizeBox (isShow) { | 19 | showSizeBox (isShow) { |
19 | dispatch(showSizeBox(isShow)) | 20 | dispatch(showSizeBox(isShow)) |
21 | + }, | ||
22 | + showSharesheet (isShow) { | ||
23 | + dispatch(showSharesheet(isShow)) | ||
20 | } | 24 | } |
21 | })) | 25 | })) |
22 | 26 | ||
@@ -30,6 +34,7 @@ export default class ProductDetail extends Component { | @@ -30,6 +34,7 @@ export default class ProductDetail extends Component { | ||
30 | recommendList: [], | 34 | recommendList: [], |
31 | collectTitle: '收藏', | 35 | collectTitle: '收藏', |
32 | isFavorite: false, | 36 | isFavorite: false, |
37 | + isShare: false, | ||
33 | productDec: { | 38 | productDec: { |
34 | color: { | 39 | color: { |
35 | text: '颜色', | 40 | text: '颜色', |
@@ -55,6 +60,11 @@ export default class ProductDetail extends Component { | @@ -55,6 +60,11 @@ export default class ProductDetail extends Component { | ||
55 | }; | 60 | }; |
56 | } | 61 | } |
57 | 62 | ||
63 | + config = { | ||
64 | + usingComponents: { | ||
65 | + 'share-sheet' : '../../components/shareSheet/shareSheet' | ||
66 | + } | ||
67 | + } | ||
58 | componentDidMount() { | 68 | componentDidMount() { |
59 | let id = this.$router.params.id; | 69 | let id = this.$router.params.id; |
60 | 70 | ||
@@ -164,6 +174,16 @@ export default class ProductDetail extends Component { | @@ -164,6 +174,16 @@ export default class ProductDetail extends Component { | ||
164 | } | 174 | } |
165 | } | 175 | } |
166 | 176 | ||
177 | + onClickShare(id, e) { | ||
178 | + let {showSharesheet} = this.props; | ||
179 | + showSharesheet(true); | ||
180 | + } | ||
181 | + | ||
182 | + onCancel() { | ||
183 | + let {showSharesheet} = this.props; | ||
184 | + showSharesheet(false); | ||
185 | + } | ||
186 | + | ||
167 | onClickBuy() { | 187 | onClickBuy() { |
168 | let {showSizeBox} = this.props; | 188 | let {showSizeBox} = this.props; |
169 | 189 | ||
@@ -198,7 +218,7 @@ export default class ProductDetail extends Component { | @@ -198,7 +218,7 @@ export default class ProductDetail extends Component { | ||
198 | <Image src={isFavorite ? collect : collectOff} className="collect-icon"/> | 218 | <Image src={isFavorite ? collect : collectOff} className="collect-icon"/> |
199 | <Text className="text">{collectTitle}</Text> | 219 | <Text className="text">{collectTitle}</Text> |
200 | </View> | 220 | </View> |
201 | - <View className="share"> | 221 | + <View className="share" onClick={this.onClickShare.bind(this, id)}> |
202 | <Image src={share} className="share-icon"/> | 222 | <Image src={share} className="share-icon"/> |
203 | <Text className="text">分享</Text> | 223 | <Text className="text">分享</Text> |
204 | </View> | 224 | </View> |
@@ -234,6 +254,11 @@ export default class ProductDetail extends Component { | @@ -234,6 +254,11 @@ export default class ProductDetail extends Component { | ||
234 | </View> | 254 | </View> |
235 | 255 | ||
236 | { | 256 | { |
257 | + this.props.productDetail.showSharesheet && | ||
258 | + <share-sheet></share-sheet> | ||
259 | + } | ||
260 | + | ||
261 | + { | ||
237 | this.props.productDetail.showSizeBox && | 262 | this.props.productDetail.showSizeBox && |
238 | <SelectSize sizeList={goodsList.size_list} product_id={id}></SelectSize> | 263 | <SelectSize sizeList={goodsList.size_list} product_id={id}></SelectSize> |
239 | } | 264 | } |
1 | -import { SHOWSIZEBOX } from '../constants/productDetail' | 1 | +import { SHOWSIZEBOX, SHOWSHARESHEET } from '../constants/productDetail' |
2 | 2 | ||
3 | const INITIAL_STATE = { | 3 | const INITIAL_STATE = { |
4 | - showSizeBox: false | 4 | + showSizeBox: false, |
5 | + showSharesheet: false | ||
5 | } | 6 | } |
6 | 7 | ||
7 | export default function productDetail (state = INITIAL_STATE, action) { | 8 | export default function productDetail (state = INITIAL_STATE, action) { |
@@ -11,6 +12,11 @@ export default function productDetail (state = INITIAL_STATE, action) { | @@ -11,6 +12,11 @@ export default function productDetail (state = INITIAL_STATE, action) { | ||
11 | ...state, | 12 | ...state, |
12 | showSizeBox: action.isShow | 13 | showSizeBox: action.isShow |
13 | } | 14 | } |
15 | + case SHOWSHARESHEET: | ||
16 | + return { | ||
17 | + ...state, | ||
18 | + showSharesheet: action.isShow | ||
19 | + } | ||
14 | default: | 20 | default: |
15 | return state | 21 | return state |
16 | } | 22 | } |
-
Please register or login to post a comment