Commit 4ee9880a463061fe600eeb4f226a902875bdd60a
Exists in
master
解决冲突
Showing
14 changed files
Show diff stats
src/components/BottomSheet/BottomSheet.vue
1 | <template> | 1 | <template> |
2 | <view class="BottomSheetContent"> | 2 | <view class="BottomSheetContent"> |
3 | <view class="sheet" :class="{sheetShow:isShowBottom,sheeHide:!isShowBottom}" @touchmove.stop.prevent="moveHandle" @click="closeSheet()"> | 3 | <view class="sheet" :class="{sheetShow:isShowBottom,sheeHide:!isShowBottom}" @touchmove.stop.prevent="moveHandle" @click="closeSheet()"> |
4 | <scroll-view scroll-y="true" class="sheetView" :class="{sheetView_active:isShowBottom}" @click.stop="stopEvent()" > | 4 | <scroll-view scroll-y="true" class="sheetView" :class="{sheetView_active:isShowBottom}" @click.stop="stopEvent()" > |
5 | <view class="BottomSheetContent"> | 5 | <view class="BottomSheetContent"> |
6 | <view class="goodInfo"> | 6 | <view class="goodInfo"> |
7 | <view class="imageWrap"> | 7 | <view class="imageWrap"> |
8 | <image | 8 | <image |
9 | :src="skuItem.pic" | 9 | :src="skuItem.pic" |
10 | mode="aspectFill" | 10 | mode="aspectFill" |
11 | style="width: 188rpx;height: 168rpx;" | 11 | style="width: 188rpx;height: 168rpx;" |
12 | 12 | ||
13 | ></image> | 13 | ></image> |
14 | 14 | ||
15 | </view> | 15 | </view> |
16 | <view class="infoRight"> | 16 | <view class="infoRight"> |
17 | <text class="goodName">{{goodInfo.p_name}}</text> | 17 | <text class="goodName">{{goodInfo.p_name}}</text> |
18 | <text class="remarks">支持7天无理由退货 顺丰发货</text> | 18 | <text class="remarks">支持7天无理由退货 顺丰发货</text> |
19 | <view class="priceBox"> | 19 | <view class="priceBox"> |
20 | <view class="price">¥{{skuItem.real_price || '暂无'}}</view> | 20 | <view class="price">¥{{skuItem.real_price || '暂无'}}</view> |
21 | <text>(限购{{maxCount}}副)</text> | 21 | <text>(限购{{maxCount}}副)</text> |
22 | <view class="counter"> | 22 | <view class="counter"> |
23 | <view | 23 | <view |
24 | class="btn" | 24 | class="btn" |
25 | disabled="this.addDisabled" | 25 | disabled="this.addDisabled" |
26 | type="default" | 26 | type="default" |
27 | @click="counter(false)" | 27 | @click="counter(false)" |
28 | >-</view> | 28 | >-</view> |
29 | <text>{{count}}</text> | 29 | <text>{{count}}</text> |
30 | <view | 30 | <view |
31 | class="btn" | 31 | class="btn" |
32 | disabled="this.desDisabled" | 32 | disabled="this.desDisabled" |
33 | type="default" | 33 | type="default" |
34 | @click="counter(true)" | 34 | @click="counter(true)" |
35 | >+</view> | 35 | >+</view> |
36 | </view> | 36 | </view> |
37 | </view> | 37 | </view> |
38 | </view> | 38 | </view> |
39 | </view> | 39 | </view> |
40 | <view class="peopleChoose"> | 40 | <view class="peopleChoose"> |
41 | <view class="title">选择使用人</view> | 41 | <view class="title">选择使用人</view> |
42 | <view class="loveList"> | 42 | <view class="loveList"> |
43 | <view class="peopleName" v-for="(item,index) in loveList" :key='index' :class="{ active2: loveCurrent === index }" | 43 | <view class="peopleName" v-for="(item,index) in loveList" :key='index' :class="{ active2: loveCurrent === index }" |
44 | @click="onClickLoveItem(index,item.name)"> | 44 | @click="onClickLoveItem(index,item.name)"> |
45 | {{item.name}} | 45 | {{item.name}} |
46 | </view> | 46 | </view> |
47 | </view> | 47 | </view> |
48 | </view> | 48 | </view> |
49 | <view class="goods-data" v-if="isCart !== 3"> | 49 | <view class="goods-data" v-if="isCart !== 3"> |
50 | <view class="opCollapse"> | 50 | <view class="opCollapse"> |
51 | <view class="body"> | 51 | <view class="body"> |
52 | <template v-if="opIsOpen"> | 52 | <template v-if="opIsOpen"> |
53 | <view class="goods-form"> | 53 | <view class="goods-form"> |
54 | <view class="p1"> | 54 | <view class="p1"> |
55 | <image class="image2" src="../../static/img/myOpticsData/dataWrite.png" mode="aspectFit"></image> | 55 | <image class="image2" src="../../static/img/myOpticsData/dataWrite.png" mode="aspectFit"></image> |
56 | 填写验光数据 | 56 | 填写验光数据 |
57 | </view> | 57 | </view> |
58 | <text class="p2">没有验光数据?请到线下眼镜店验光哦~</text> | 58 | <text class="p2">没有验光数据?请到线下眼镜店验光哦~</text> |
59 | <view class="picker"> | 59 | <view class="picker"> |
60 | <view class="picker-choice"> | 60 | <view class="picker-choice"> |
61 | <view class="choice-left"> | 61 | <view class="choice-left"> |
62 | <text class="pd">验光单取名:</text> | 62 | <text class="pd">验光单取名:</text> |
63 | </view> | 63 | </view> |
64 | <input type="text" @blur="handleInput" class="input" | 64 | <input type="text" @blur="handleInput" class="input" |
65 | placeholder="请输入名称" maxlength="20" :value="name" /> | 65 | placeholder="请输入名称" maxlength="20" :value="name" /> |
66 | </view> | 66 | </view> |
67 | </view> | 67 | </view> |
68 | <view class="picker" > | 68 | <view class="picker" > |
69 | <view class="picker-choice"> | 69 | <view class="picker-choice"> |
70 | <view class="choice-left"> | 70 | <view class="choice-left"> |
71 | <text class="p11">{{pickerInfoList[0].nameC}}</text> | 71 | <text class="p11">{{pickerInfoList[0].nameC}}</text> |
72 | <text class="p12">{{pickerInfoList[0].nameE}}</text> | 72 | <text class="p12">{{pickerInfoList[0].nameE}}</text> |
73 | </view> | 73 | </view> |
74 | <text class="p13">左 (OD)</text> | 74 | <text class="p13">左 (OD)</text> |
75 | <!-- <text class="p14">{{pickerInfoList[0].nameArray1[pickerInfoList[0].nameIndex1]}}</text> --> | 75 | <!-- <text class="p14">{{pickerInfoList[0].nameArray1[pickerInfoList[0].nameIndex1]}}</text> --> |
76 | <picker @change="bindPickerChange01" :value="pickerInfoList[0].nameIndex1" :range="pickerInfoList[0].nameArray1"> | 76 | <picker @change="bindPickerChange01" :value="pickerInfoList[0].nameIndex1" :range="pickerInfoList[0].nameArray1"> |
77 | <view class="p14"> | 77 | <view class="p14"> |
78 | {{pickerInfoList[0].nameArray1[pickerInfoList[0].nameIndex1]}} | 78 | {{pickerInfoList[0].nameArray1[pickerInfoList[0].nameIndex1]}} |
79 | <image src="../../static/detail-tabicon.png" ></image> | 79 | <image src="../../static/detail-tabicon.png" ></image> |
80 | </view> | 80 | </view> |
81 | <!-- <image src="../../static/detail-tabicon.png" ></image> --> | 81 | <!-- <image src="../../static/detail-tabicon.png" ></image> --> |
82 | </picker> | 82 | </picker> |
83 | <text class="p13">右 (OS)</text> | 83 | <text class="p13">右 (OS)</text> |
84 | <!-- <text class="p14">{{pickerInfoList[0].nameArray2[pickerInfoList[0].nameIndex2]}}</text> --> | 84 | <!-- <text class="p14">{{pickerInfoList[0].nameArray2[pickerInfoList[0].nameIndex2]}}</text> --> |
85 | <picker @change="bindPickerChange02" :value="pickerInfoList[0].nameIndex2" :range="pickerInfoList[0].nameArray2"> | 85 | <picker @change="bindPickerChange02" :value="pickerInfoList[0].nameIndex2" :range="pickerInfoList[0].nameArray2"> |
86 | <view class="p14"> | 86 | <view class="p14"> |
87 | {{pickerInfoList[0].nameArray2[pickerInfoList[0].nameIndex2]}} | 87 | {{pickerInfoList[0].nameArray2[pickerInfoList[0].nameIndex2]}} |
88 | <image src="../../static/detail-tabicon.png" ></image> | 88 | <image src="../../static/detail-tabicon.png" ></image> |
89 | </view> | 89 | </view> |
90 | <!-- <image src="../../static/detail-tabicon.png" ></image> --> | 90 | <!-- <image src="../../static/detail-tabicon.png" ></image> --> |
91 | </picker> | 91 | </picker> |
92 | </view> | 92 | </view> |
93 | </view> | 93 | </view> |
94 | <view class="picker" > | 94 | <view class="picker" > |
95 | <view class="picker-choice"> | 95 | <view class="picker-choice"> |
96 | <view class="choice-left"> | 96 | <view class="choice-left"> |
97 | <text class="p11">{{pickerInfoList[1].nameC}}</text> | 97 | <text class="p11">{{pickerInfoList[1].nameC}}</text> |
98 | <text class="p12">{{pickerInfoList[1].nameE}}</text> | 98 | <text class="p12">{{pickerInfoList[1].nameE}}</text> |
99 | </view> | 99 | </view> |
100 | <text class="p13">左 (OD)</text> | 100 | <text class="p13">左 (OD)</text> |
101 | <!-- <text class="p14">{{pickerInfoList[1].nameArray1[pickerInfoList[1].nameIndex1]}}</text> --> | 101 | <!-- <text class="p14">{{pickerInfoList[1].nameArray1[pickerInfoList[1].nameIndex1]}}</text> --> |
102 | <picker @change="bindPickerChange11" :value="pickerInfoList[1].nameIndex1" :range="pickerInfoList[1].nameArray1"> | 102 | <picker @change="bindPickerChange11" :value="pickerInfoList[1].nameIndex1" :range="pickerInfoList[1].nameArray1"> |
103 | <view class="p14"> | 103 | <view class="p14"> |
104 | {{pickerInfoList[1].nameArray1[pickerInfoList[1].nameIndex1]}} | 104 | {{pickerInfoList[1].nameArray1[pickerInfoList[1].nameIndex1]}} |
105 | <image src="../../static/detail-tabicon.png" ></image> | 105 | <image src="../../static/detail-tabicon.png" ></image> |
106 | </view> | 106 | </view> |
107 | <!-- <image src="../../static/detail-tabicon.png" ></image> --> | 107 | <!-- <image src="../../static/detail-tabicon.png" ></image> --> |
108 | </picker> | 108 | </picker> |
109 | <text class="p13">右 (OS)</text> | 109 | <text class="p13">右 (OS)</text> |
110 | <!-- <text class="p14">{{pickerInfoList[1].nameArray2[pickerInfoList[1].nameIndex2]}}</text> --> | 110 | <!-- <text class="p14">{{pickerInfoList[1].nameArray2[pickerInfoList[1].nameIndex2]}}</text> --> |
111 | <picker @change="bindPickerChange12" :value="pickerInfoList[1].nameIndex2" :range="pickerInfoList[1].nameArray2"> | 111 | <picker @change="bindPickerChange12" :value="pickerInfoList[1].nameIndex2" :range="pickerInfoList[1].nameArray2"> |
112 | <view class="p14"> | 112 | <view class="p14"> |
113 | {{pickerInfoList[1].nameArray2[pickerInfoList[1].nameIndex2]}} | 113 | {{pickerInfoList[1].nameArray2[pickerInfoList[1].nameIndex2]}} |
114 | <image src="../../static/detail-tabicon.png" ></image> | 114 | <image src="../../static/detail-tabicon.png" ></image> |
115 | </view> | 115 | </view> |
116 | <!-- <image src="../../static/detail-tabicon.png" ></image> --> | 116 | <!-- <image src="../../static/detail-tabicon.png" ></image> --> |
117 | </picker> | 117 | </picker> |
118 | </view> | 118 | </view> |
119 | </view> | 119 | </view> |
120 | <view class="picker" > | 120 | <view class="picker" > |
121 | <view class="picker-choice"> | 121 | <view class="picker-choice"> |
122 | <view class="choice-left"> | 122 | <view class="choice-left"> |
123 | <text class="p11">{{pickerInfoList[2].nameC}}</text> | 123 | <text class="p11">{{pickerInfoList[2].nameC}}</text> |
124 | <text class="p12">{{pickerInfoList[2].nameE}}</text> | 124 | <text class="p12">{{pickerInfoList[2].nameE}}</text> |
125 | </view> | 125 | </view> |
126 | <text class="p13">左 (OD)</text> | 126 | <text class="p13">左 (OD)</text> |
127 | <picker @change="bindPickerChange21" :value="pickerInfoList[2].nameIndex1" :range="pickerInfoList[2].nameArray1"> | 127 | <picker @change="bindPickerChange21" :value="pickerInfoList[2].nameIndex1" :range="pickerInfoList[2].nameArray1"> |
128 | <view class="p14"> | 128 | <view class="p14"> |
129 | {{pickerInfoList[2].nameArray1[pickerInfoList[2].nameIndex1]}} | 129 | {{pickerInfoList[2].nameArray1[pickerInfoList[2].nameIndex1]}} |
130 | <image src="../../static/detail-tabicon.png" ></image> | 130 | <image src="../../static/detail-tabicon.png" ></image> |
131 | </view> | 131 | </view> |
132 | </picker> | 132 | </picker> |
133 | <text class="p13">右 (OS)</text> | 133 | <text class="p13">右 (OS)</text> |
134 | <!-- <text class="p14">{{pickerInfoList[2].nameArray2[pickerInfoList[2].nameIndex2]}}</text> --> | 134 | <!-- <text class="p14">{{pickerInfoList[2].nameArray2[pickerInfoList[2].nameIndex2]}}</text> --> |
135 | <picker @change="bindPickerChange22" :value="pickerInfoList[2].nameIndex2" :range="pickerInfoList[2].nameArray2"> | 135 | <picker @change="bindPickerChange22" :value="pickerInfoList[2].nameIndex2" :range="pickerInfoList[2].nameArray2"> |
136 | <view class="p14"> | 136 | <view class="p14"> |
137 | {{pickerInfoList[2].nameArray2[pickerInfoList[2].nameIndex2]}} | 137 | {{pickerInfoList[2].nameArray2[pickerInfoList[2].nameIndex2]}} |
138 | <image src="../../static/detail-tabicon.png" ></image> | 138 | <image src="../../static/detail-tabicon.png" ></image> |
139 | </view> | 139 | </view> |
140 | <!-- <image src="../../static/detail-tabicon.png" ></image> --> | 140 | <!-- <image src="../../static/detail-tabicon.png" ></image> --> |
141 | </picker> | 141 | </picker> |
142 | </view> | 142 | </view> |
143 | </view> | 143 | </view> |
144 | <view class="picker"> | 144 | <view class="picker"> |
145 | <view class="picker-choice"> | 145 | <view class="picker-choice"> |
146 | <view class="choice-left"> | 146 | <view class="choice-left"> |
147 | <text class="pd">瞳距:</text> | 147 | <text class="pd">瞳距:</text> |
148 | </view> | 148 | </view> |
149 | <input type="digit" @change="handleInputPd" class="input" | 149 | <input type="digit" @change="handleInputPd" class="input" |
150 | placeholder="请输入瞳距,单位cm" maxlength="20" :value="pd" /> | 150 | placeholder="请输入瞳距,单位cm" maxlength="20" :value="pd" /> |
151 | </view> | 151 | </view> |
152 | </view> | 152 | </view> |
153 | <view class="picker" > | 153 | <view class="picker" > |
154 | <view class="picker-choice"> | 154 | <view class="picker-choice"> |
155 | <view class="choice-left"> | 155 | <view class="choice-left"> |
156 | <text class="p11">{{pickerInfoList[3].nameC}}</text> | 156 | <text class="p11">{{pickerInfoList[3].nameC}}</text> |
157 | </view> | 157 | </view> |
158 | <text class="p13-date">年 (Y)</text> | 158 | <text class="p13-date">年 (Y)</text> |
159 | <picker @change="bindPickerChange41" :value="pickerInfoList[3].nameIndex1" :range="pickerInfoList[3].nameArray1"> | 159 | <picker @change="bindPickerChange41" :value="pickerInfoList[3].nameIndex1" :range="pickerInfoList[3].nameArray1"> |
160 | <view class="p14" style="width: 30px;"> | 160 | <view class="p14" style="width: 30px;"> |
161 | {{pickerInfoList[3].nameArray1[pickerInfoList[3].nameIndex1]}} | 161 | {{pickerInfoList[3].nameArray1[pickerInfoList[3].nameIndex1]}} |
162 | <image src="../../static/detail-tabicon.png" ></image> | 162 | <image src="../../static/detail-tabicon.png" ></image> |
163 | </view> | 163 | </view> |
164 | </picker> | 164 | </picker> |
165 | <text class="p13-date">月 (M)</text> | 165 | <text class="p13-date">月 (M)</text> |
166 | <picker @change="bindPickerChange42" :value="pickerInfoList[3].nameIndex2" :range="pickerInfoList[3].nameArray2"> | 166 | <picker @change="bindPickerChange42" :value="pickerInfoList[3].nameIndex2" :range="pickerInfoList[3].nameArray2"> |
167 | <view class="p14" style="width: 30px;"> | 167 | <view class="p14" style="width: 30px;"> |
168 | {{pickerInfoList[3].nameArray2[pickerInfoList[3].nameIndex2]}} | 168 | {{pickerInfoList[3].nameArray2[pickerInfoList[3].nameIndex2]}} |
169 | <image src="../../static/detail-tabicon.png" ></image> | 169 | <image src="../../static/detail-tabicon.png" ></image> |
170 | </view> | 170 | </view> |
171 | </picker> | 171 | </picker> |
172 | <text class="p13-date">日 (D)</text> | 172 | <text class="p13-date">日 (D)</text> |
173 | <picker @change="bindPickerChange43" :value="pickerInfoList[3].nameIndex3" :range="pickerInfoList[3].nameArray3"> | 173 | <picker @change="bindPickerChange43" :value="pickerInfoList[3].nameIndex3" :range="pickerInfoList[3].nameArray3"> |
174 | <view class="p14" style="width: 30px;"> | 174 | <view class="p14" style="width: 30px;"> |
175 | {{pickerInfoList[3].nameArray3[pickerInfoList[3].nameIndex3]}} | 175 | {{pickerInfoList[3].nameArray3[pickerInfoList[3].nameIndex3]}} |
176 | <image src="../../static/detail-tabicon.png" ></image> | 176 | <image src="../../static/detail-tabicon.png" ></image> |
177 | </view> | 177 | </view> |
178 | </picker> | 178 | </picker> |
179 | </view> | 179 | </view> |
180 | </view> | 180 | </view> |
181 | <view class="confirm"> | 181 | <view class="confirm"> |
182 | <image class="image1" :src="confirm ? tabicon[0] : tabicon[1]" @tap="changeConfirm"></image> | 182 | <image class="image1" :src="confirm ? tabicon[0] : tabicon[1]" @tap="changeConfirm"></image> |
183 | <text>确认以上输入信息来源于我的验光数据!</text> | 183 | <text>确认以上输入信息来源于我的验光数据!</text> |
184 | </view> | 184 | </view> |
185 | </view> | 185 | </view> |
186 | </template> | 186 | </template> |
187 | <template v-else> | 187 | <template v-else> |
188 | <view | 188 | <view |
189 | v-for="item in pickerInfoList" | 189 | v-for="item in pickerInfoList" |
190 | :key="item.key" | 190 | :key="item.key" |
191 | class="bodyBox" | 191 | class="bodyBox" |
192 | > | 192 | > |
193 | <template v-if="item.nameC==='验光日期'"> | 193 | <template v-if="item.nameC==='验光日期'"> |
194 | <text class="names">{{item.nameC}}</text> | 194 | <text class="names">{{item.nameC}}</text> |
195 | <text style="margin-right: 5px;">{{item.nameArray1[item.nameIndex1]}}年</text> | 195 | <text style="margin-right: 5px;">{{item.nameArray1[item.nameIndex1]}}年</text> |
196 | <text style="margin-right: 5px;">{{item.nameArray2[item.nameIndex2]}}月</text> | 196 | <text style="margin-right: 5px;">{{item.nameArray2[item.nameIndex2]}}月</text> |
197 | <text>{{item.nameArray3[item.nameIndex2]}}日</text> | 197 | <text>{{item.nameArray3[item.nameIndex2]}}日</text> |
198 | </template> | 198 | </template> |
199 | <template v-else> | 199 | <template v-else> |
200 | <template v-if="item.nameC==='度数'"> | 200 | <template v-if="item.nameC==='度数'"> |
201 | <text style="display: inline;">*</text> | 201 | <text style="display: inline;">*</text> |
202 | </template> | 202 | </template> |
203 | 203 | ||
204 | <text class="names">{{item.nameC}}</text> | 204 | <text class="names">{{item.nameC}}</text> |
205 | <text style="margin-right: 10px;">左 {{item.nameArray1[item.nameIndex1]}}</text> | 205 | <text style="margin-right: 10px;">左 {{item.nameArray1[item.nameIndex1]}}</text> |
206 | <text>右 {{item.nameArray2[item.nameIndex2]}}</text> | 206 | <text>右 {{item.nameArray2[item.nameIndex2]}}</text> |
207 | </template> | 207 | </template> |
208 | </view> | 208 | </view> |
209 | </template> | 209 | </template> |
210 | </view> | 210 | </view> |
211 | </view> | 211 | </view> |
212 | </view> | 212 | </view> |
213 | <view class="choose"> | 213 | <view class="choose"> |
214 | <view | 214 | <view |
215 | class="chooseItem_1_content" | 215 | class="chooseItem_1_content" |
216 | v-for="(item,index) in attrList" | 216 | v-for="(item,index) in attrList" |
217 | :key="index" | 217 | :key="index" |
218 | > | 218 | > |
219 | <UniCollapse @change="changeShow(index)"> | 219 | <UniCollapse @change="changeShow(index)"> |
220 | <UniCollapseItem | 220 | <UniCollapseItem |
221 | :open="show[index]" | 221 | :open="show[index]" |
222 | :title="item.meta_name" | 222 | :title="item.meta_name" |
223 | showAnimation=false | 223 | showAnimation=false |
224 | > | 224 | > |
225 | <view class="chooseItem_1_content"> | 225 | <view class="chooseItem_1_content"> |
226 | <view class="itemsWrap" v-if="isCart ==3"> | 226 | <view class="itemsWrap" v-if="isCart ==3"> |
227 | <view | 227 | <view |
228 | class="item2" | 228 | class="item2" |
229 | v-for="(one,i) in item.attr" | 229 | v-for="(one,i) in item.attr" |
230 | :key="i" | 230 | :key="i" |
231 | :class="{ active2: current[index] === i}" | 231 | :class="{ active2: current[index] === i}" |
232 | @click="cartOnClickItem(index, i,one.aid)" | 232 | @click="cartOnClickItem(index, i,one.aid)" |
233 | >{{one.name}}</view> | 233 | >{{one.name}}</view> |
234 | </view> | 234 | </view> |
235 | <view class="itemsWrap" v-else> | 235 | <view class="itemsWrap" v-else> |
236 | <view | 236 | <view |
237 | class="item2" | 237 | class="item2" |
238 | v-for="(one,i) in item.attr" | 238 | v-for="(one,i) in item.attr" |
239 | :key="i" | 239 | :key="i" |
240 | :class="{ active2: current[index] === i }" | 240 | :class="{ active2: current[index] === i }" |
241 | @click="cartOnClickItem(index, i,one.aid)" | 241 | @click="cartOnClickItem(index, i,one.aid)" |
242 | >{{one.name}}</view> | 242 | >{{one.name}}</view> |
243 | </view> | 243 | </view> |
244 | </view> | 244 | </view> |
245 | </UniCollapseItem> | 245 | </UniCollapseItem> |
246 | </UniCollapse> | 246 | </UniCollapse> |
247 | <view | 247 | <view |
248 | class="chooseRes" | 248 | class="chooseRes" |
249 | v-show="!show[index]" | 249 | v-show="!show[index]" |
250 | >* {{attrList[index].attr[current[index]].name}}</view> | 250 | >* {{attrList[index].attr[current[index]].name}}</view> |
251 | </view> | 251 | </view> |
252 | </view> | 252 | </view> |
253 | <view | 253 | <view |
254 | class="button" | 254 | class="button" |
255 | @click.native="addCart" | 255 | @click.native="addCart" |
256 | v-if="isCart == 1" | 256 | v-if="isCart == 1" |
257 | > | 257 | > |
258 | 加入购物车 | 258 | 加入购物车 |
259 | </view> | 259 | </view> |
260 | <view | 260 | <view |
261 | class="button" | 261 | class="button" |
262 | @click="toComfirmOrder" | 262 | @click="toComfirmOrder" |
263 | v-if="isCart == 2" | 263 | v-if="isCart == 2" |
264 | > | 264 | > |
265 | 立即结算 | 265 | 立即结算 |
266 | </view> | 266 | </view> |
267 | <view | 267 | <view |
268 | class="button" | 268 | class="button" |
269 | @click="comfirmChoose" | 269 | @click="comfirmChoose" |
270 | v-if="isCart == 3" | 270 | v-if="isCart == 3" |
271 | > | 271 | > |
272 | 确定 | 272 | 确定 |
273 | </view> | 273 | </view> |
274 | </view> | 274 | </view> |
275 | </scroll-view> | 275 | </scroll-view> |
276 | </view> | 276 | </view> |
277 | </view> | 277 | </view> |
278 | </template> | 278 | </template> |
279 | <script> | 279 | <script> |
280 | import UniCollapse from '@/components/UniCollapse/UniCollapse.vue' | 280 | import UniCollapse from '@/components/UniCollapse/UniCollapse.vue' |
281 | import UniCollapseItem from '@/components/UniCollapseItem/UniCollapseItem.vue' | 281 | import UniCollapseItem from '@/components/UniCollapseItem/UniCollapseItem.vue' |
282 | import store from '@/store' | 282 | import store from '@/store' |
283 | export default { | 283 | export default { |
284 | components: { | 284 | components: { |
285 | UniCollapse, | 285 | UniCollapse, |
286 | UniCollapseItem, | 286 | UniCollapseItem, |
287 | }, | 287 | }, |
288 | props: { | 288 | props: { |
289 | isShowBottom : Boolean, | 289 | isShowBottom : Boolean, |
290 | pid: Number, | 290 | pid: Number, |
291 | sk_id:String, | 291 | sk_id:String, |
292 | propMpId:String, | 292 | propMpId:String, |
293 | goodInfo:Object, | 293 | goodInfo:Object, |
294 | isCart:Number, | 294 | isCart:Number, |
295 | cart_id:Number, | 295 | cart_id:Number, |
296 | index:Number | 296 | index:Number |
297 | }, | 297 | }, |
298 | data() { | 298 | data() { |
299 | return { | 299 | return { |
300 | loveCurrent:Number, | 300 | loveCurrent:Number, |
301 | count: 1, | 301 | count: 1, |
302 | // pid: 0, | 302 | // pid: 0, |
303 | maxCount: 20, | 303 | maxCount: 20, |
304 | dataName: '', // 验光数据人员名称 | 304 | dataName: '', // 验光数据人员名称 |
305 | isDataName: false, // 是否是已存在的人员数据 | 305 | isDataName: false, // 是否是已存在的人员数据 |
306 | dataConfirm: false, // 已确认所输入验光数据 | 306 | dataConfirm: false, // 已确认所输入验光数据 |
307 | opIsOpen: true, | 307 | opIsOpen: true, |
308 | addDisabled: false, | 308 | addDisabled: false, |
309 | desDisabled: false, | 309 | desDisabled: false, |
310 | current: [], | 310 | current: [], |
311 | show: [true,true], | 311 | show: [true,true], |
312 | checkedData: {}, | 312 | checkedData: {}, |
313 | // 度数相关数据 | 313 | // 度数相关数据 |
314 | pickerInfoList: [ | 314 | pickerInfoList: [ |
315 | { nameC: '度数', nameE: '(SPH)', nameArray1: [''], nameIndex1: 0, nameArray2: [''], nameIndex2: 0, key: 0 }, | 315 | { nameC: '度数', nameE: '(SPH)', nameArray1: [''], nameIndex1: 0, nameArray2: [''], nameIndex2: 0, key: 0 }, |
316 | { nameC: '散光', nameE: '(CYL)', nameArray1: [''], nameIndex1: 0, nameArray2: [''], nameIndex2: 0, key: 1 }, | 316 | { nameC: '散光', nameE: '(CYL)', nameArray1: [''], nameIndex1: 0, nameArray2: [''], nameIndex2: 0, key: 1 }, |
317 | { nameC: '散光轴位', nameE: '(AXI)', nameArray1: [''], nameIndex1: 0, nameArray2: [''], nameIndex2: 0, key: 2 }, | 317 | { nameC: '散光轴位', nameE: '(AXI)', nameArray1: [''], nameIndex1: 0, nameArray2: [''], nameIndex2: 0, key: 2 }, |
318 | { nameC: '验光日期', nameE: '', nameArray1: [''], nameIndex1: 0, nameArray2: ['', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], nameIndex2: 0, nameArray3: [''], nameIndex3: 0 }, | 318 | { nameC: '验光日期', nameE: '', nameArray1: [''], nameIndex1: 0, nameArray2: ['', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], nameIndex2: 0, nameArray3: [''], nameIndex3: 0 }, |
319 | ], | 319 | ], |
320 | confirm: false, // 用户是否确认 | 320 | confirm: false, // 用户是否确认 |
321 | tabicon: ['/static/detail-button.png', '/static/detail-button-unselected.png'], | 321 | tabicon: ['/static/detail-button.png', '/static/detail-button-unselected.png'], |
322 | name: '', | 322 | name: '', |
323 | oldname: '', // 用于判读用户是否改变名字 | 323 | oldname: '', // 用于判读用户是否改变名字 |
324 | pickerInfoChioce: { | 324 | pickerInfoChioce: { |
325 | leftSph: '', | 325 | leftSph: '', |
326 | rightSph: '', | 326 | rightSph: '', |
327 | leftCyl: '', | 327 | leftCyl: '', |
328 | rightCyl: '', | 328 | rightCyl: '', |
329 | leftAxi: '', | 329 | leftAxi: '', |
330 | rightAxi: '', | 330 | rightAxi: '', |
331 | time: { | 331 | time: { |
332 | year: 0, | 332 | year: 0, |
333 | month: 0, | 333 | month: 0, |
334 | day: 0, | 334 | day: 0, |
335 | }, | 335 | }, |
336 | }, | 336 | }, |
337 | pd: '', // 瞳距 | 337 | pd: '', // 瞳距 |
338 | oldpd: '', // 用于判断用户是否改变瞳距 | 338 | oldpd: '', // 用于判断用户是否改变瞳距 |
339 | kinds: 1, // kinds=1,提交为新增验光,2为修改 | 339 | kinds: 1, // kinds=1,提交为新增验光,2为修改 |
340 | mp_id: Number, | 340 | mp_id: Number, |
341 | skuValueArray:[], | 341 | skuValueArray:[], |
342 | skId:String | 342 | skId:String |
343 | } | 343 | } |
344 | }, | 344 | }, |
345 | computed: { | 345 | computed: { |
346 | //进购物车选择的人的index | 346 | //进购物车选择的人的index |
347 | p_current(){ | 347 | p_current(){ |
348 | const getLoveItemIndex = (item) => item.mp_id == this.propMpId | 348 | const getLoveItemIndex = (item) => item.mp_id == this.propMpId |
349 | const p_current = this.$store.state.myLoveList.loveList.findIndex(getLoveItemIndex ) | 349 | const p_current = this.$store.state.myLoveList.loveList.findIndex(getLoveItemIndex ) |
350 | if(this.isCart == 3){ | 350 | if(this.isCart == 3){ |
351 | this.loveCurrent = p_current | 351 | this.loveCurrent = p_current |
352 | } | 352 | } |
353 | return p_current | 353 | return p_current |
354 | }, | 354 | }, |
355 | arr_current(){ | 355 | arr_current(){ |
356 | if(this.isCart == 3){ | 356 | if(this.isCart == 3){ |
357 | const skId = this.sk_id | 357 | const skId = this.sk_id |
358 | const skuValue = this.skuItem.sku_value | 358 | const skuValue = this.skuItem.sku_value |
359 | const skuValueArray = skuValue.split('_') | 359 | const skuValueArray = skuValue.split('_') |
360 | this.skuValueArray = skuValueArray | 360 | this.skuValueArray = skuValueArray |
361 | const attrList = this.$store.state.read.goodInfo.attrList | 361 | const attrList = this.$store.state.read.goodInfo.attrList |
362 | for (let i = 0;i<attrList.length;i++) { | 362 | for (let i = 0;i<attrList.length;i++) { |
363 | const getArrIndex = (item) => item.aid == skuValueArray[i] | 363 | const getArrIndex = (item) => item.aid == skuValueArray[i] |
364 | const arr_current = this.$store.state.read.goodInfo.attrList[i].attr.findIndex(getArrIndex ) | 364 | const arr_current = this.$store.state.read.goodInfo.attrList[i].attr.findIndex(getArrIndex ) |
365 | // console.log('arr_current',arr_current) | 365 | // console.log('arr_current',arr_current) |
366 | this.current.push(arr_current) | 366 | this.current.push(arr_current) |
367 | } | 367 | } |
368 | }else{ | 368 | }else{ |
369 | return null | 369 | return null |
370 | } | 370 | } |
371 | }, | 371 | }, |
372 | loveList() { | 372 | loveList() { |
373 | return this.$store.state.myLoveList.loveList || [] | 373 | return this.$store.state.myLoveList.loveList || [] |
374 | }, | 374 | }, |
375 | attrList() { | 375 | attrList() { |
376 | // console.log('attrList',this.$store.state.read.goodInfo.attrList) | 376 | // console.log('attrList',this.$store.state.read.goodInfo.attrList) |
377 | let attrList = this.$store.state.read.goodInfo.attrList | 377 | let attrList = this.$store.state.read.goodInfo.attrList |
378 | if(attrList !== undefined){ | 378 | if(attrList !== undefined){ |
379 | return attrList | 379 | return attrList |
380 | }else{ | 380 | }else{ |
381 | return [] | 381 | return [] |
382 | } | 382 | } |
383 | }, | 383 | }, |
384 | skuList() { | 384 | skuList() { |
385 | // console.log('skuList',this.$store.state.read.goodInfo.skuList) | 385 | // console.log('skuList',this.$store.state.read.goodInfo.skuList) |
386 | return this.$store.state.read.goodInfo.skuList | 386 | return this.$store.state.read.goodInfo.skuList |
387 | }, | 387 | }, |
388 | skuItem(){ | 388 | skuItem(){ |
389 | // if(this.isCart == 3){ | 389 | // if(this.isCart == 3){ |
390 | const skuList = this.$store.state.read.goodInfo.skuList | 390 | const skuList = this.$store.state.read.goodInfo.skuList |
391 | const skuItem = skuList.filter(item => item.sk_id === this.skId)[0] | 391 | const skuItem = skuList.filter(item => item.sk_id === this.skId)[0] |
392 | return skuItem | 392 | return skuItem |
393 | // }else{ | 393 | // }else{ |
394 | // const skuList = this.$store.state.read.goodInfo.skuList | 394 | // const skuList = this.$store.state.read.goodInfo.skuList |
395 | // const skuItem = skuList[0] | 395 | // const skuItem = skuList[0] |
396 | // return skuItem | 396 | // return skuItem |
397 | // } | 397 | // } |
398 | }, | 398 | }, |
399 | mpList() { | 399 | mpList() { |
400 | 400 | ||
401 | return this.$store.state.myLoveList.loveList | 401 | return this.$store.state.myLoveList.loveList |
402 | }, | 402 | }, |
403 | }, | 403 | }, |
404 | created() { | 404 | created() { |
405 | this.skuValueArray = this.skuList[0].sku_value.split("_") | 405 | this.skuValueArray = this.skuList[0].sku_value.split("_") |
406 | // console.log(this.sk_id) | 406 | // console.log(this.sk_id) |
407 | this.mp_id = this.propMpId | 407 | this.mp_id = this.propMpId |
408 | const pid = this.pid | 408 | const pid = this.pid |
409 | if(this.isCart!==3){ | 409 | if(this.isCart!==3){ |
410 | this.skId = this.skuList[0].sk_id | 410 | this.skId = this.skuList[0].sk_id |
411 | const current = [] | 411 | const current = [] |
412 | const show = [] | 412 | const show = [] |
413 | for (let index = 0; index < this.attrList.length; index++) { | 413 | for (let index = 0; index < this.attrList.length; index++) { |
414 | current.push(0) | 414 | current.push(0) |
415 | show.push(true) | 415 | show.push(true) |
416 | } | 416 | } |
417 | this.current = current | 417 | this.current = current |
418 | this.show = show | 418 | this.show = show |
419 | }else{ | 419 | }else{ |
420 | this.skId = this.sk_id | 420 | this.skId = this.sk_id |
421 | } | 421 | } |
422 | 422 | ||
423 | //获取关心的人列表 | 423 | //获取关心的人列表 |
424 | store.dispatch('myLoveList/getLoveList', { | 424 | store.dispatch('myLoveList/getLoveList', { |
425 | uid: this.$store.state.user.userInfo.uid, | 425 | uid: this.$store.state.user.userInfo.uid, |
426 | }); | 426 | }); |
427 | 427 | ||
428 | 428 | ||
429 | // 初始化SPL、CYL、AXI的值 | 429 | // 初始化SPL、CYL、AXI的值 |
430 | for (let j = 0; j < 3; j++) { | 430 | for (let j = 0; j < 3; j++) { |
431 | for (let i = -12; i < 6; i++) { | 431 | for (let i = -12; i < 6; i++) { |
432 | this.pickerInfoList[j].nameArray1.push(i) | 432 | this.pickerInfoList[j].nameArray1.push(i) |
433 | this.pickerInfoList[j].nameArray1.push(i + 0.5) | 433 | this.pickerInfoList[j].nameArray1.push(i + 0.5) |
434 | this.pickerInfoList[j].nameArray2.push(i) | 434 | this.pickerInfoList[j].nameArray2.push(i) |
435 | this.pickerInfoList[j].nameArray2.push(i + 0.5) | 435 | this.pickerInfoList[j].nameArray2.push(i + 0.5) |
436 | if (i >= -6) { | 436 | if (i >= -6) { |
437 | this.pickerInfoList[j].nameArray1.push(i + 0.25) | 437 | this.pickerInfoList[j].nameArray1.push(i + 0.25) |
438 | this.pickerInfoList[j].nameArray1.push(i + 0.75) | 438 | this.pickerInfoList[j].nameArray1.push(i + 0.75) |
439 | this.pickerInfoList[j].nameArray2.push(i + 0.25) | 439 | this.pickerInfoList[j].nameArray2.push(i + 0.25) |
440 | this.pickerInfoList[j].nameArray2.push(i + 0.75) | 440 | this.pickerInfoList[j].nameArray2.push(i + 0.75) |
441 | } | 441 | } |
442 | if (i === 5) { | 442 | if (i === 5) { |
443 | this.pickerInfoList[j].nameArray1.push(i + 1) | 443 | this.pickerInfoList[j].nameArray1.push(i + 1) |
444 | this.pickerInfoList[j].nameArray2.push(i + 1) | 444 | this.pickerInfoList[j].nameArray2.push(i + 1) |
445 | } | 445 | } |
446 | } | 446 | } |
447 | } | 447 | } |
448 | // 初始化日期值 | 448 | // 初始化日期值 |
449 | for (let i = 1; i < 32; i++) { | 449 | for (let i = 1; i < 32; i++) { |
450 | this.pickerInfoList[3].nameArray3.push(i) | 450 | this.pickerInfoList[3].nameArray3.push(i) |
451 | } | 451 | } |
452 | // 初始化年份前后五年 | 452 | // 初始化年份前后五年 |
453 | const myDate = new Date() | 453 | const myDate = new Date() |
454 | const nowYear = myDate.getFullYear() | 454 | const nowYear = myDate.getFullYear() |
455 | for (let i = 0; i < 5; i++) { | 455 | for (let i = 0; i < 5; i++) { |
456 | this.pickerInfoList[3].nameArray1.push(nowYear - i) | 456 | this.pickerInfoList[3].nameArray1.push(nowYear - i) |
457 | } | 457 | } |
458 | }, | 458 | }, |
459 | name : "bottomSheet", | 459 | name : "bottomSheet", |
460 | methods: { | 460 | methods: { |
461 | //参数点击事件==》改变对应图片 | 461 | //参数点击事件==》改变对应图片 |
462 | cartOnClickItem(index, i,aid) { | 462 | cartOnClickItem(index, i,aid) { |
463 | //根据aid拼接skuValue | 463 | //根据aid拼接skuValue |
464 | this.skuValueArray[index] = aid | 464 | this.skuValueArray[index] = aid |
465 | const sku_value = this.skuValueArray.join('_') | 465 | const sku_value = this.skuValueArray.join('_') |
466 | //根据sku_value获取对应的sk_id | 466 | //根据sku_value获取对应的sk_id |
467 | const itemSk_id = this.skuList.filter(item=>item.sku_value == sku_value)[0].sk_id | 467 | const itemSk_id = this.skuList.filter(item=>item.sku_value == sku_value)[0].sk_id |
468 | //修改sk_id | 468 | //修改sk_id |
469 | this.skId = itemSk_id | 469 | this.skId = itemSk_id |
470 | if (this.current[index] !== i) { | 470 | if (this.current[index] !== i) { |
471 | this.current[index] = i | 471 | this.current[index] = i |
472 | } | 472 | } |
473 | this.$forceUpdate() | 473 | this.$forceUpdate() |
474 | }, | 474 | }, |
475 | comfirmChoose(){ | 475 | comfirmChoose(){ |
476 | const price = this.skuList.filter(item=>item.sk_id == this.skId)[0].real_price | 476 | const price = this.skuList.filter(item=>item.sk_id == this.skId)[0].real_price |
477 | this.$emit("chooseCartModi",this.mp_id,this.skId,price,this.pid,this.count,this.cart_id,this.index)//添加购物车 | 477 | this.$emit("chooseCartModi",this.mp_id,this.skId,price,this.pid,this.count,this.cart_id,this.index)//添加购物车 |
478 | this.$emit("closeBottom") | 478 | this.$emit("closeBottom") |
479 | }, | 479 | }, |
480 | addCart(){ | 480 | addCart(){ |
481 | const that = this | 481 | const that = this |
482 | const checkedSKUName = [that.goodInfo.attrList[0].meta_name,that.goodInfo.attrList[1].meta_name] | 482 | const checkedSKUName = [that.goodInfo.attrList[0].meta_name,that.goodInfo.attrList[1].meta_name] |
483 | const checkedSKU = [] | 483 | const checkedSKU = [] |
484 | let j; | 484 | let j; |
485 | for (let i = 0;i<that.current.length;i++) { | 485 | for (let i = 0;i<that.current.length;i++) { |
486 | checkedSKU.push(that.goodInfo.attrList[i].attr[that.current[i]]) | 486 | checkedSKU.push(that.goodInfo.attrList[i].attr[that.current[i]]) |
487 | // console.log('i', i, j, i !== this.current.length - 1) | 487 | // console.log('i', i, j, i !== this.current.length - 1) |
488 | if (i !== this.current.length - 1) { | 488 | if (i !== this.current.length - 1) { |
489 | // 后续需修改算法:目前暂定只有两个参数选择,后续若有多个参数需要修改实现自适应 | 489 | // 后续需修改算法:目前暂定只有两个参数选择,后续若有多个参数需要修改实现自适应 |
490 | j = this.current[i] * this.attrList[1].attr.length | 490 | j = this.current[i] * this.attrList[1].attr.length |
491 | } else { | 491 | } else { |
492 | j += this.current[i] | 492 | j += this.current[i] |
493 | } | 493 | } |
494 | } | 494 | } |
495 | let sk_id = this.skuList[j].sk_id | 495 | let sk_id = this.skuList[j].sk_id |
496 | console.log('选择的商品sk_id',sk_id,'选择的商品参数',checkedSKU) | 496 | console.log('选择的商品sk_id',sk_id,'选择的商品参数',checkedSKU) |
497 | this.$emit("addCart",this.mp_id,this.count,checkedSKU,sk_id)//添加购物车 | 497 | this.$emit("addCart",this.mp_id,this.count,checkedSKU,sk_id)//添加购物车 |
498 | this.$emit("closeBottom")//关闭弹窗 | 498 | this.$emit("closeBottom")//关闭弹窗 |
499 | }, | 499 | }, |
500 | onClickLoveItem(index,name){ | 500 | onClickLoveItem(index,name){ |
501 | const loveList = this.loveList | 501 | const loveList = this.loveList |
502 | for (let index = 0; index < loveList.length; index++) { | 502 | for (let index = 0; index < loveList.length; index++) { |
503 | if (name === loveList[index].name && name!==this.name) { | 503 | if (name === loveList[index].name && name!==this.name) { |
504 | this.isDataName = true | 504 | this.isDataName = true |
505 | this.kinds = 2 | 505 | this.kinds = 2 |
506 | this.name = loveList[index].name | 506 | this.name = loveList[index].name |
507 | this.pd = loveList[index].pd | 507 | this.pd = loveList[index].pd |
508 | this.mp_id = loveList[index].mp_id | 508 | this.mp_id = loveList[index].mp_id |
509 | this.oldname = loveList[index].name | 509 | this.oldname = loveList[index].name |
510 | this.oldpd = loveList[index].pd | 510 | this.oldpd = loveList[index].pd |
511 | this.pickerInfoList[0].nameArray1.unshift(loveList[index].leftSph) | 511 | this.pickerInfoList[0].nameArray1.unshift(loveList[index].leftSph) |
512 | this.pickerInfoList[0].nameArray2.unshift(loveList[index].rightSph) | 512 | this.pickerInfoList[0].nameArray2.unshift(loveList[index].rightSph) |
513 | this.pickerInfoList[1].nameArray1.unshift(loveList[index].leftCyl) | 513 | this.pickerInfoList[1].nameArray1.unshift(loveList[index].leftCyl) |
514 | this.pickerInfoList[1].nameArray2.unshift(loveList[index].rightCyl) | 514 | this.pickerInfoList[1].nameArray2.unshift(loveList[index].rightCyl) |
515 | this.pickerInfoList[2].nameArray1.unshift(loveList[index].leftAxi) | 515 | this.pickerInfoList[2].nameArray1.unshift(loveList[index].leftAxi) |
516 | this.pickerInfoList[2].nameArray2.unshift(loveList[index].rightAxi) | 516 | this.pickerInfoList[2].nameArray2.unshift(loveList[index].rightAxi) |
517 | this.pickerInfoList[3].nameArray1.unshift(loveList[index].in_time.toString().slice(0, 4)) | 517 | this.pickerInfoList[3].nameArray1.unshift(loveList[index].in_time.toString().slice(0, 4)) |
518 | if (loveList[index].in_time.toString().slice(5, 6) === 0) { | 518 | if (loveList[index].in_time.toString().slice(5, 6) === 0) { |
519 | this.pickerInfoList[3].nameArray2.unshift(loveList[index].in_time.toString().slice(6, 7)) | 519 | this.pickerInfoList[3].nameArray2.unshift(loveList[index].in_time.toString().slice(6, 7)) |
520 | } else { | 520 | } else { |
521 | this.pickerInfoList[3].nameArray2.unshift(loveList[index].in_time.toString().slice(5, 7)) | 521 | this.pickerInfoList[3].nameArray2.unshift(loveList[index].in_time.toString().slice(5, 7)) |
522 | } | 522 | } |
523 | if (loveList[index].in_time.toString().slice(8, 9) === 0) { | 523 | if (loveList[index].in_time.toString().slice(8, 9) === 0) { |
524 | this.pickerInfoList[3].nameArray3.unshift(loveList[index].in_time.toString().slice(9, 10)) | 524 | this.pickerInfoList[3].nameArray3.unshift(loveList[index].in_time.toString().slice(9, 10)) |
525 | } else { | 525 | } else { |
526 | this.pickerInfoList[3].nameArray3.unshift(loveList[index].in_time.toString().slice(8, 10)) | 526 | this.pickerInfoList[3].nameArray3.unshift(loveList[index].in_time.toString().slice(8, 10)) |
527 | } | 527 | } |
528 | } | 528 | } |
529 | } | 529 | } |
530 | this.name = name; | 530 | this.name = name; |
531 | this.loveCurrent = index; | 531 | this.loveCurrent = index; |
532 | }, | 532 | }, |
533 | closeSheet(){ | 533 | closeSheet(){ |
534 | this.$emit('closeBottom'); | 534 | this.$emit('closeBottom'); |
535 | }, | 535 | }, |
536 | stopEvent(){ //@click.stop防止事件冒泡 | 536 | stopEvent(){ //@click.stop防止事件冒泡 |
537 | 537 | ||
538 | }, | 538 | }, |
539 | moveHandle(){ //不让页面滚动 | 539 | moveHandle(){ //不让页面滚动 |
540 | 540 | ||
541 | }, | 541 | }, |
542 | // picker相关功能 | 542 | // picker相关功能 |
543 | handleInput(e) { | 543 | handleInput(e) { |
544 | this.name = e.target.value | 544 | this.name = e.target.value |
545 | this.isDataName = false | 545 | this.isDataName = false |
546 | const mpList = this.mpList | 546 | const mpList = this.mpList |
547 | // console.log('mpList===>', mpList) | 547 | // console.log('mpList===>', mpList) |
548 | for (let index = 0; index < mpList.length; index++) { | 548 | for (let index = 0; index < mpList.length; index++) { |
549 | if (e.detail.value === mpList[index].name) { | 549 | if (e.detail.value === mpList[index].name) { |
550 | this.isDataName = true | 550 | this.isDataName = true |
551 | uni.showModal({ | 551 | uni.showModal({ |
552 | title: '提示', | 552 | title: '提示', |
553 | content: `是否填充已有的"${e.detail.value}"的数据`, | 553 | content: `是否填充已有的"${e.detail.value}"的数据`, |
554 | success: (res) => { | 554 | success: (res) => { |
555 | if (res.confirm) { | 555 | if (res.confirm) { |
556 | this.kinds = 2 | 556 | this.kinds = 2 |
557 | // console.log('args===>', index) | 557 | // console.log('args===>', index) |
558 | // const mpList=Object.assign({},this.$store.state.mympList.mpList) | 558 | // const mpList=Object.assign({},this.$store.state.mympList.mpList) |
559 | this.name = mpList[index].name | 559 | this.name = mpList[index].name |
560 | this.pd = mpList[index].pd | 560 | this.pd = mpList[index].pd |
561 | this.mp_id = mpList[index].mp_id | 561 | this.mp_id = mpList[index].mp_id |
562 | this.oldname = mpList[index].name | 562 | this.oldname = mpList[index].name |
563 | this.oldpd = mpList[index].pd | 563 | this.oldpd = mpList[index].pd |
564 | // 将kinds =2时的值传到该页面 | 564 | // 将kinds =2时的值传到该页面 |
565 | this.pickerInfoList[0].nameArray1.unshift(mpList[index].leftSph) | 565 | this.pickerInfoList[0].nameArray1.unshift(mpList[index].leftSph) |
566 | this.pickerInfoList[0].nameArray2.unshift(mpList[index].rightSph) | 566 | this.pickerInfoList[0].nameArray2.unshift(mpList[index].rightSph) |
567 | this.pickerInfoList[1].nameArray1.unshift(mpList[index].leftCyl) | 567 | this.pickerInfoList[1].nameArray1.unshift(mpList[index].leftCyl) |
568 | this.pickerInfoList[1].nameArray2.unshift(mpList[index].rightCyl) | 568 | this.pickerInfoList[1].nameArray2.unshift(mpList[index].rightCyl) |
569 | this.pickerInfoList[2].nameArray1.unshift(mpList[index].leftAxi) | 569 | this.pickerInfoList[2].nameArray1.unshift(mpList[index].leftAxi) |
570 | this.pickerInfoList[2].nameArray2.unshift(mpList[index].rightAxi) | 570 | this.pickerInfoList[2].nameArray2.unshift(mpList[index].rightAxi) |
571 | this.pickerInfoList[3].nameArray1.unshift(mpList[index].in_time.toString().slice(0, 4)) | 571 | this.pickerInfoList[3].nameArray1.unshift(mpList[index].in_time.toString().slice(0, 4)) |
572 | if (mpList[index].in_time.toString().slice(5, 6) === 0) { | 572 | if (mpList[index].in_time.toString().slice(5, 6) === 0) { |
573 | this.pickerInfoList[3].nameArray2.unshift(mpList[index].in_time.toString().slice(6, 7)) | 573 | this.pickerInfoList[3].nameArray2.unshift(mpList[index].in_time.toString().slice(6, 7)) |
574 | } else { | 574 | } else { |
575 | this.pickerInfoList[3].nameArray2.unshift(mpList[index].in_time.toString().slice(5, 7)) | 575 | this.pickerInfoList[3].nameArray2.unshift(mpList[index].in_time.toString().slice(5, 7)) |
576 | } | 576 | } |
577 | if (mpList[index].in_time.toString().slice(8, 9) === 0) { | 577 | if (mpList[index].in_time.toString().slice(8, 9) === 0) { |
578 | this.pickerInfoList[3].nameArray3.unshift(mpList[index].in_time.toString().slice(9, 10)) | 578 | this.pickerInfoList[3].nameArray3.unshift(mpList[index].in_time.toString().slice(9, 10)) |
579 | } else { | 579 | } else { |
580 | this.pickerInfoList[3].nameArray3.unshift(mpList[index].in_time.toString().slice(8, 10)) | 580 | this.pickerInfoList[3].nameArray3.unshift(mpList[index].in_time.toString().slice(8, 10)) |
581 | } | 581 | } |
582 | // this.checkedData = mpList[index] | 582 | // this.checkedData = mpList[index] |
583 | // console.log('checkedData', this.checkedData) | 583 | // console.log('checkedData', this.checkedData) |
584 | } else if (res.cancel) { | 584 | } else if (res.cancel) { |
585 | this.kinds = 2 | 585 | this.kinds = 2 |
586 | } | 586 | } |
587 | }, | 587 | }, |
588 | }) | 588 | }) |
589 | } | 589 | } |
590 | } | 590 | } |
591 | }, | 591 | }, |
592 | handleInputPd(e) { | 592 | handleInputPd(e) { |
593 | // 只能输入正浮点数或正数 | 593 | // 只能输入正浮点数或正数 |
594 | if (/^\d+(\.\d+)?$/.test(e.target.value)) { | 594 | if (/^\d+(\.\d+)?$/.test(e.target.value)) { |
595 | this.pd = e.target.value | 595 | this.pd = e.target.value |
596 | } else { | 596 | } else { |
597 | uni.showToast({ | 597 | uni.showToast({ |
598 | title: '请输入有效数据;示例:89', | 598 | title: '请输入有效数据;示例:89', |
599 | icon: 'none', | 599 | icon: 'none', |
600 | duration: 2000, | 600 | duration: 2000, |
601 | }) | 601 | }) |
602 | this.pd = '' | 602 | this.pd = '' |
603 | } | 603 | } |
604 | }, | 604 | }, |
605 | changeConfirm() { | 605 | changeConfirm() { |
606 | this.confirm = !this.confirm | 606 | this.confirm = !this.confirm |
607 | }, | 607 | }, |
608 | bindPickerChange01: function(e) { | 608 | bindPickerChange01: function(e) { |
609 | this.pickerInfoList[0].nameIndex1 = e.target.value | 609 | this.pickerInfoList[0].nameIndex1 = e.target.value |
610 | this.pickerInfoChioce.leftSph = this.pickerInfoList[0].nameArray1[e.target.value] | 610 | this.pickerInfoChioce.leftSph = this.pickerInfoList[0].nameArray1[e.target.value] |
611 | }, | 611 | }, |
612 | bindPickerChange02: function(e) { | 612 | bindPickerChange02: function(e) { |
613 | this.pickerInfoList[0].nameIndex2 = e.target.value | 613 | this.pickerInfoList[0].nameIndex2 = e.target.value |
614 | this.pickerInfoChioce.rightSph = this.pickerInfoList[0].nameArray2[e.target.value] | 614 | this.pickerInfoChioce.rightSph = this.pickerInfoList[0].nameArray2[e.target.value] |
615 | }, | 615 | }, |
616 | 616 | ||
617 | bindPickerChange11: function(e) { | 617 | bindPickerChange11: function(e) { |
618 | this.pickerInfoList[1].nameIndex1 = e.target.value | 618 | this.pickerInfoList[1].nameIndex1 = e.target.value |
619 | this.pickerInfoChioce.leftCyl = this.pickerInfoList[1].nameArray1[e.target.value] | 619 | this.pickerInfoChioce.leftCyl = this.pickerInfoList[1].nameArray1[e.target.value] |
620 | }, | 620 | }, |
621 | bindPickerChange12: function(e) { | 621 | bindPickerChange12: function(e) { |
622 | this.pickerInfoList[1].nameIndex2 = e.target.value | 622 | this.pickerInfoList[1].nameIndex2 = e.target.value |
623 | this.pickerInfoChioce.rightCyl = this.pickerInfoList[1].nameArray2[e.target.value] | 623 | this.pickerInfoChioce.rightCyl = this.pickerInfoList[1].nameArray2[e.target.value] |
624 | }, | 624 | }, |
625 | 625 | ||
626 | bindPickerChange21: function(e) { | 626 | bindPickerChange21: function(e) { |
627 | this.pickerInfoList[2].nameIndex1 = e.target.value | 627 | this.pickerInfoList[2].nameIndex1 = e.target.value |
628 | this.pickerInfoChioce.leftAxi = this.pickerInfoList[2].nameArray1[e.target.value] | 628 | this.pickerInfoChioce.leftAxi = this.pickerInfoList[2].nameArray1[e.target.value] |
629 | }, | 629 | }, |
630 | bindPickerChange22: function(e) { | 630 | bindPickerChange22: function(e) { |
631 | this.pickerInfoList[2].nameIndex2 = e.target.value | 631 | this.pickerInfoList[2].nameIndex2 = e.target.value |
632 | this.pickerInfoChioce.rightAxi = this.pickerInfoList[2].nameArray2[e.target.value] | 632 | this.pickerInfoChioce.rightAxi = this.pickerInfoList[2].nameArray2[e.target.value] |
633 | }, | 633 | }, |
634 | 634 | ||
635 | bindPickerChange41: function(e) { | 635 | bindPickerChange41: function(e) { |
636 | this.pickerInfoList[3].nameIndex1 = e.target.value | 636 | this.pickerInfoList[3].nameIndex1 = e.target.value |
637 | this.pickerInfoChioce.time.year = this.pickerInfoList[3].nameArray1[e.target.value] | 637 | this.pickerInfoChioce.time.year = this.pickerInfoList[3].nameArray1[e.target.value] |
638 | }, | 638 | }, |
639 | bindPickerChange42: function(e) { | 639 | bindPickerChange42: function(e) { |
640 | this.pickerInfoList[3].nameIndex2 = e.target.value | 640 | this.pickerInfoList[3].nameIndex2 = e.target.value |
641 | this.pickerInfoChioce.time.month = this.pickerInfoList[3].nameArray2[e.target.value] | 641 | this.pickerInfoChioce.time.month = this.pickerInfoList[3].nameArray2[e.target.value] |
642 | }, | 642 | }, |
643 | bindPickerChange43: function(e) { | 643 | bindPickerChange43: function(e) { |
644 | this.pickerInfoList[3].nameIndex3 = e.target.value | 644 | this.pickerInfoList[3].nameIndex3 = e.target.value |
645 | this.pickerInfoChioce.time.day = this.pickerInfoList[3].nameArray3[e.target.value] | 645 | this.pickerInfoChioce.time.day = this.pickerInfoList[3].nameArray3[e.target.value] |
646 | }, | 646 | }, |
647 | changeShow(num) { | 647 | changeShow(num) { |
648 | this.show[num] = !this.show[num] | 648 | this.show[num] = !this.show[num] |
649 | this.$forceUpdate() | 649 | this.$forceUpdate() |
650 | }, | 650 | }, |
651 | counter(isadd) { | 651 | counter(isadd) { |
652 | if (isadd) { | 652 | if (isadd) { |
653 | this.count >= this.maxCount ? this.addDisabled = true : this.count++ | 653 | this.count >= this.maxCount ? this.addDisabled = true : this.count++ |
654 | } else { | 654 | } else { |
655 | this.count <= 1 ? this.desDisabled = true : this.count-- | 655 | this.count <= 1 ? this.desDisabled = true : this.count-- |
656 | } | 656 | } |
657 | }, | 657 | }, |
658 | toComfirmOrder() { | 658 | toComfirmOrder() { |
659 | // 先处理验光部分的逻辑,如果ok在跳转 | 659 | // 先处理验光部分的逻辑,如果ok在跳转 |
660 | let flag = 0 | 660 | let flag = 0 |
661 | if (this.name === '') { | 661 | if (this.name === '') { |
662 | uni.showToast({ | 662 | uni.showToast({ |
663 | title: '请输入验光单取名', | 663 | title: '请输入验光单取名', |
664 | icon: 'none', | 664 | icon: 'none', |
665 | duration: 2000, | 665 | duration: 2000, |
666 | }) | 666 | }) |
667 | } else { | 667 | } else { |
668 | if (this.pd === '') { | 668 | if (this.pd === '') { |
669 | uni.showToast({ | 669 | uni.showToast({ |
670 | title: '请输入瞳距', | 670 | title: '请输入瞳距', |
671 | icon: 'none', | 671 | icon: 'none', |
672 | duration: 2000, | 672 | duration: 2000, |
673 | }) | 673 | }) |
674 | } else { | 674 | } else { |
675 | if (this.kinds === 1) { | 675 | if (this.kinds === 1) { |
676 | // 添加用户验光单 | 676 | // 添加用户验光单 |
677 | console.log('kinds====>', this.pickerInfoChioce.leftSph) | 677 | console.log('kinds====>', this.pickerInfoChioce.leftSph) |
678 | console.log('kinds====>', this.pickerInfoChioce.leftSph === Number) | 678 | console.log('kinds====>', this.pickerInfoChioce.leftSph === Number) |
679 | console.log('kinds====>', this.pickerInfoChioce.rightSph === Number) | 679 | console.log('kinds====>', this.pickerInfoChioce.rightSph === Number) |
680 | if (this.pickerInfoChioce.rightSph === '' || this.pickerInfoChioce.leftSph === '' || | 680 | if (this.pickerInfoChioce.rightSph === '' || this.pickerInfoChioce.leftSph === '' || |
681 | this.pickerInfoChioce.leftCyl === '' || this.pickerInfoChioce.rightCyl === '' || | 681 | this.pickerInfoChioce.leftCyl === '' || this.pickerInfoChioce.rightCyl === '' || |
682 | this.pickerInfoChioce.leftAxi === '' || this.pickerInfoChioce.rightAxi === '' | 682 | this.pickerInfoChioce.leftAxi === '' || this.pickerInfoChioce.rightAxi === '' |
683 | ) { | 683 | ) { |
684 | uni.showToast({ | 684 | uni.showToast({ |
685 | title: '请输入您的验光数据', | 685 | title: '请输入您的验光数据', |
686 | icon: 'none', | 686 | icon: 'none', |
687 | duration: 2000, | 687 | duration: 2000, |
688 | }) | 688 | }) |
689 | } else { | 689 | } else { |
690 | if (this.confirm) { | 690 | if (this.confirm) { |
691 | store.dispatch('myLoveList/addMylove', { | 691 | store.dispatch('myLoveList/addMylove', { |
692 | uid: this.$store.state.user.userInfo.uid, | 692 | uid: this.$store.state.user.userInfo.uid, |
693 | openid: this.$store.state.user.userInfo.openid, | 693 | openid: this.$store.state.user.userInfo.openid, |
694 | // mp_name: this.$store.state.user.userInfo.mp_name, | 694 | // mp_name: this.$store.state.user.userInfo.mp_name, |
695 | leftSph: this.pickerInfoChioce.leftSph, | 695 | leftSph: this.pickerInfoChioce.leftSph, |
696 | rightSph: this.pickerInfoChioce.rightSph, | 696 | rightSph: this.pickerInfoChioce.rightSph, |
697 | leftCyl: this.pickerInfoChioce.leftCyl, | 697 | leftCyl: this.pickerInfoChioce.leftCyl, |
698 | rightCyl: this.pickerInfoChioce.rightCyl, | 698 | rightCyl: this.pickerInfoChioce.rightCyl, |
699 | leftAxi: this.pickerInfoChioce.leftAxi, | 699 | leftAxi: this.pickerInfoChioce.leftAxi, |
700 | rightAxi: this.pickerInfoChioce.rightAxi, | 700 | rightAxi: this.pickerInfoChioce.rightAxi, |
701 | pd: this.pd, // 瞳距 | 701 | pd: this.pd, // 瞳距 |
702 | mp_name: this.name, | 702 | mp_name: this.name, |
703 | // time: this.pickerInfoChioce.time, | 703 | // time: this.pickerInfoChioce.time, |
704 | // img_url2: "http://localhost:8087/images/shop_1/1/", | 704 | // img_url2: "http://localhost:8087/images/shop_1/1/", |
705 | }).then(({ mp_id: mpId }) => { | 705 | }).then(({ mp_id: mpId }) => { |
706 | this.mp_id = mpId | 706 | this.mp_id = mpId |
707 | }) | 707 | }) |
708 | flag = 1 | 708 | flag = 1 |
709 | } else { | 709 | } else { |
710 | uni.showToast({ | 710 | uni.showToast({ |
711 | title: '请确认您的验光数据', | 711 | title: '请确认您的验光数据', |
712 | icon: 'none', | 712 | icon: 'none', |
713 | duration: 3000, | 713 | duration: 3000, |
714 | }) | 714 | }) |
715 | } | 715 | } |
716 | } | 716 | } |
717 | } | 717 | } |
718 | if (this.kinds === 2) { | 718 | if (this.kinds === 2) { |
719 | if (this.confirm) { | 719 | if (this.confirm) { |
720 | const leftList = ['leftSph', 'leftCyl', 'leftAxi'] | 720 | const leftList = ['leftSph', 'leftCyl', 'leftAxi'] |
721 | const rightList = ['rightSph', 'rightCyl', 'rightAxi'] | 721 | const rightList = ['rightSph', 'rightCyl', 'rightAxi'] |
722 | // let flag=0; | 722 | // let flag=0; |
723 | if (this.name !== this.oldname) { | 723 | if (this.name !== this.oldname) { |
724 | store.dispatch('myLoveList/updateMylove', { | 724 | store.dispatch('myLoveList/updateMylove', { |
725 | uid: this.$store.state.user.userInfo.uid, | 725 | uid: this.$store.state.user.userInfo.uid, |
726 | openid: this.$store.state.user.userInfo.openid, | 726 | openid: this.$store.state.user.userInfo.openid, |
727 | mp_id: this.mp_id, | 727 | mp_id: this.mp_id, |
728 | keyname: 'name', | 728 | keyname: 'name', |
729 | keyvalue: this.name, | 729 | keyvalue: this.name, |
730 | }) | 730 | }) |
731 | flag = 1 | 731 | flag = 1 |
732 | } | 732 | } |
733 | if (this.pd !== this.oldpd) { | 733 | if (this.pd !== this.oldpd) { |
734 | store.dispatch('myLoveList/updateMylove', { | 734 | store.dispatch('myLoveList/updateMylove', { |
735 | uid: this.$store.state.user.userInfo.uid, | 735 | uid: this.$store.state.user.userInfo.uid, |
736 | openid: this.$store.state.user.userInfo.openid, | 736 | openid: this.$store.state.user.userInfo.openid, |
737 | mp_id: this.mp_id, | 737 | mp_id: this.mp_id, |
738 | keyname: 'pd', | 738 | keyname: 'pd', |
739 | keyvalue: this.pd, | 739 | keyvalue: this.pd, |
740 | }) | 740 | }) |
741 | flag = 1 | 741 | flag = 1 |
742 | } | 742 | } |
743 | // 先验证是否输入有无空 | 743 | // 先验证是否输入有无空 |
744 | let q = true | 744 | let q = true |
745 | for (let k = 0; k < 3; k++) { | 745 | for (let k = 0; k < 3; k++) { |
746 | q = q && (this.pickerInfoList[k].nameArray1[this.pickerInfoList[k].nameIndex1] !== '' && | 746 | q = q && (this.pickerInfoList[k].nameArray1[this.pickerInfoList[k].nameIndex1] !== '' && |
747 | this.pickerInfoList[k].nameArray2[this.pickerInfoList[k].nameIndex2] !== '') | 747 | this.pickerInfoList[k].nameArray2[this.pickerInfoList[k].nameIndex2] !== '') |
748 | } | 748 | } |
749 | if (q) { | 749 | if (q) { |
750 | for (let j = 0; j < 3; j++) { | 750 | for (let j = 0; j < 3; j++) { |
751 | if (this.pickerInfoList[j].nameIndex1 !== 0) { | 751 | if (this.pickerInfoList[j].nameIndex1 !== 0) { |
752 | store.dispatch('myLoveList/updateMylove', { | 752 | store.dispatch('myLoveList/updateMylove', { |
753 | uid: this.$store.state.user.userInfo.uid, | 753 | uid: this.$store.state.user.userInfo.uid, |
754 | openid: this.$store.state.user.userInfo.openid, | 754 | openid: this.$store.state.user.userInfo.openid, |
755 | mp_id: this.mp_id, | 755 | mp_id: this.mp_id, |
756 | keyname: leftList[j], | 756 | keyname: leftList[j], |
757 | keyvalue: this.pickerInfoList[j].nameArray1[this.pickerInfoList[j].nameIndex1], | 757 | keyvalue: this.pickerInfoList[j].nameArray1[this.pickerInfoList[j].nameIndex1], |
758 | }) | 758 | }) |
759 | } | 759 | } |
760 | if (this.pickerInfoList[j].nameIndex2 !== 0) { | 760 | if (this.pickerInfoList[j].nameIndex2 !== 0) { |
761 | store.dispatch('myLoveList/updateMylove', { | 761 | store.dispatch('myLoveList/updateMylove', { |
762 | uid: this.$store.state.user.userInfo.uid, | 762 | uid: this.$store.state.user.userInfo.uid, |
763 | openid: this.$store.state.user.userInfo.openid, | 763 | openid: this.$store.state.user.userInfo.openid, |
764 | mp_id: this.mp_id, | 764 | mp_id: this.mp_id, |
765 | keyname: rightList[j], | 765 | keyname: rightList[j], |
766 | keyvalue: this.pickerInfoList[j].nameArray2[this.pickerInfoList[j].nameIndex2], | 766 | keyvalue: this.pickerInfoList[j].nameArray2[this.pickerInfoList[j].nameIndex2], |
767 | }) | 767 | }) |
768 | } | 768 | } |
769 | flag = 1 | 769 | flag = 1 |
770 | } | 770 | } |
771 | } else { | 771 | } else { |
772 | flag = 0 | 772 | flag = 0 |
773 | uni.showToast({ | 773 | uni.showToast({ |
774 | title: '请输入您的验光数据', | 774 | title: '请输入您的验光数据', |
775 | icon: 'none', | 775 | icon: 'none', |
776 | duration: 2000, | 776 | duration: 2000, |
777 | }) | 777 | }) |
778 | } | 778 | } |
779 | if (flag !== 0) { | 779 | if (flag !== 0) { |
780 | store.dispatch('myLoveList/getLoveList', { | 780 | store.dispatch('myLoveList/getLoveList', { |
781 | uid: this.$store.state.user.userInfo.uid, | 781 | uid: this.$store.state.user.userInfo.uid, |
782 | }) | 782 | }) |
783 | } | 783 | } |
784 | } else { | 784 | } else { |
785 | uni.showToast({ | 785 | uni.showToast({ |
786 | title: '请确认您的验光数据', | 786 | title: '请确认您的验光数据', |
787 | icon: 'none', | 787 | icon: 'none', |
788 | duration: 3000, | 788 | duration: 3000, |
789 | }) | 789 | }) |
790 | } | 790 | } |
791 | } | 791 | } |
792 | } | 792 | } |
793 | } | 793 | } |
794 | if (flag !== 0) { | 794 | if (flag !== 0) { |
795 | // 如果数据验证无误,那么更新验光单的数据 | 795 | // 如果数据验证无误,那么更新验光单的数据 |
796 | store.dispatch('myLoveList/getLoveList', { | 796 | store.dispatch('myLoveList/getLoveList', { |
797 | uid: this.$store.state.user.userInfo.uid, | 797 | uid: this.$store.state.user.userInfo.uid, |
798 | }) | 798 | }) |
799 | let i = 0 | 799 | let i = 0 |
800 | // 判断出是哪一个sku被选中 | 800 | // 判断出是哪一个sku被选中 |
801 | for (let index = 0; index < this.current.length; index++) { | 801 | for (let index = 0; index < this.current.length; index++) { |
802 | // console.log('index', index, i, index !== this.current.length - 1) | 802 | // console.log('index', index, i, index !== this.current.length - 1) |
803 | if (index !== this.current.length - 1) { | 803 | if (index !== this.current.length - 1) { |
804 | // 后续需修改算法:目前暂定只有两个参数选择,后续若有多个参数需要修改实现自适应 | 804 | // 后续需修改算法:目前暂定只有两个参数选择,后续若有多个参数需要修改实现自适应 |
805 | i = this.current[index] * this.attrList[1].attr.length | 805 | i = this.current[index] * this.attrList[1].attr.length |
806 | } else { | 806 | } else { |
807 | i += this.current[index] | 807 | i += this.current[index] |
808 | } | 808 | } |
809 | } | 809 | } |
810 | // 判断是否其输入的人员数据是否已存在 | 810 | // 判断是否其输入的人员数据是否已存在 |
811 | store.dispatch('order/saveParams', { | 811 | store.dispatch('order/saveParams', { |
812 | sk_id_arr: this.skuList[i], | 812 | sk_id_arr: this.skuList[i], |
813 | current: this.current, | 813 | current: this.current, |
814 | mp_id: this.mp_id, | 814 | mp_id: this.mp_id, |
815 | attrList: this.attrList, | 815 | attrList: this.attrList, |
816 | }) | 816 | }) |
817 | this.$store.state.cart.buyItem = this.skuItem | ||
817 | // 跳转到确认订单页面 | 818 | // 跳转到确认订单页面 |
818 | uni.navigateTo({ | 819 | uni.navigateTo({ |
819 | url: `../confirmOrder/confirmOrder?pid=${this.pid}&count=${this.count}&name=${this.name}`, | 820 | url: `../confirmOrder/confirmOrder?pid=${this.pid}&count=${this.count}&name=${this.name}&isCart=false`, |
820 | }) | 821 | }) |
821 | } | 822 | } |
822 | }, | 823 | }, |
823 | } | 824 | } |
824 | } | 825 | } |
825 | </script> | 826 | </script> |
826 | 827 | ||
827 | <style lang="scss"> | 828 | <style lang="scss"> |
828 | .BottomSheetContent { | 829 | .BottomSheetContent { |
829 | min-height: 100vh; | 830 | min-height: 100vh; |
830 | background-color: #f2f2f2; | 831 | background-color: #f2f2f2; |
831 | // padding-top: 20rpx; | 832 | // padding-top: 20rpx; |
832 | .goodInfo { | 833 | .goodInfo { |
833 | width: 100%; | 834 | width: 100%; |
834 | height: 272rpx; | 835 | height: 272rpx; |
835 | border-radius: 16rpx; | 836 | border-radius: 16rpx; |
836 | background-color: #ffffff; | 837 | background-color: #ffffff; |
837 | box-sizing: border-box; | 838 | box-sizing: border-box; |
838 | padding: 36rpx; | 839 | padding: 36rpx; |
839 | display: flex; | 840 | display: flex; |
840 | flex-direction: row; | 841 | flex-direction: row; |
841 | justify-content: flex-start; | 842 | justify-content: flex-start; |
842 | position: sticky; | 843 | position: sticky; |
843 | top: 0rpx; | 844 | top: 0rpx; |
844 | left: 0rpx; | 845 | left: 0rpx; |
845 | z-index: 99999; | 846 | z-index: 99999; |
846 | .imageWrap { | 847 | .imageWrap { |
847 | height: 188rpx; | 848 | height: 188rpx; |
848 | width: 188rpx; | 849 | width: 188rpx; |
849 | margin-right: 28rpx; | 850 | margin-right: 28rpx; |
850 | image { | 851 | image { |
851 | height: 188rpx; | 852 | height: 188rpx; |
852 | width: 188rpx; | 853 | width: 188rpx; |
853 | } | 854 | } |
854 | } | 855 | } |
855 | .infoRight { | 856 | .infoRight { |
856 | display: flex; | 857 | display: flex; |
857 | flex-direction: column; | 858 | flex-direction: column; |
858 | align-items: flex-start; | 859 | align-items: flex-start; |
859 | justify-content: space-between; | 860 | justify-content: space-between; |
860 | width: 100%; | 861 | width: 100%; |
861 | .goodName { | 862 | .goodName { |
862 | font-size: 28rpx; | 863 | font-size: 28rpx; |
863 | color: #333333; | 864 | color: #333333; |
864 | } | 865 | } |
865 | .remarks { | 866 | .remarks { |
866 | font-size: 20rpx; | 867 | font-size: 20rpx; |
867 | color: #999999; | 868 | color: #999999; |
868 | } | 869 | } |
869 | .priceBox { | 870 | .priceBox { |
870 | display: flex; | 871 | display: flex; |
871 | justify-content: space-between; | 872 | justify-content: space-between; |
872 | align-items: center; | 873 | align-items: center; |
873 | width: 100%; | 874 | width: 100%; |
874 | font-size: 14px; | 875 | font-size: 14px; |
875 | color: #999999; | 876 | color: #999999; |
876 | .price { | 877 | .price { |
877 | color: #ff6b4a; | 878 | color: #ff6b4a; |
878 | font-size: 28rpx; | 879 | font-size: 28rpx; |
879 | } | 880 | } |
880 | .counter { | 881 | .counter { |
881 | display: flex; | 882 | display: flex; |
882 | flex-direction: row; | 883 | flex-direction: row; |
883 | justify-content: space-between; | 884 | justify-content: space-between; |
884 | align-items: center; | 885 | align-items: center; |
885 | font-size: 28rpx; | 886 | font-size: 28rpx; |
886 | color: #333333; | 887 | color: #333333; |
887 | width: 122rpx; | 888 | width: 122rpx; |
888 | .btn { | 889 | .btn { |
889 | display: flex; | 890 | display: flex; |
890 | justify-content: center; | 891 | justify-content: center; |
891 | line-height: 32rpx; | 892 | line-height: 32rpx; |
892 | height: 32rpx; | 893 | height: 32rpx; |
893 | width: 32rpx; | 894 | width: 32rpx; |
894 | background-color: #f2f2f2; | 895 | background-color: #f2f2f2; |
895 | color: #cfcfcf; | 896 | color: #cfcfcf; |
896 | } | 897 | } |
897 | } | 898 | } |
898 | } | 899 | } |
899 | } | 900 | } |
900 | } | 901 | } |
901 | .peopleChoose{ | 902 | .peopleChoose{ |
902 | width: 100%; | 903 | width: 100%; |
903 | min-height: 200rpx; | 904 | min-height: 200rpx; |
904 | border-radius: 16rpx; | 905 | border-radius: 16rpx; |
905 | background-color: #ffffff; | 906 | background-color: #ffffff; |
906 | box-sizing: border-box; | 907 | box-sizing: border-box; |
907 | padding: 36rpx; | 908 | padding: 36rpx; |
908 | margin: 10px 0; | 909 | margin: 10px 0; |
909 | display: flex; | 910 | display: flex; |
910 | flex-direction: column; | 911 | flex-direction: column; |
911 | justify-content: flex-start; | 912 | justify-content: flex-start; |
912 | align-items: center; | 913 | align-items: center; |
913 | .title{ | 914 | .title{ |
914 | font-size: 16px; | 915 | font-size: 16px; |
915 | color: #333333; | 916 | color: #333333; |
916 | letter-spacing: -0.3px; | 917 | letter-spacing: -0.3px; |
917 | text-align: justify; | 918 | text-align: justify; |
918 | line-height: 24px; | 919 | line-height: 24px; |
919 | margin: 4px 0; | 920 | margin: 4px 0; |
920 | } | 921 | } |
921 | .loveList{ | 922 | .loveList{ |
922 | display: flex; | 923 | display: flex; |
923 | flex-direction: row; | 924 | flex-direction: row; |
924 | flex-wrap: wrap; | 925 | flex-wrap: wrap; |
925 | justify-content: flex-start; | 926 | justify-content: flex-start; |
926 | align-items: center; | 927 | align-items: center; |
927 | padding-top: 24rpx; | 928 | padding-top: 24rpx; |
928 | width: 100%; | 929 | width: 100%; |
929 | .peopleName { | 930 | .peopleName { |
930 | padding: 0 30rpx; | 931 | padding: 0 30rpx; |
931 | height: 60rpx; | 932 | height: 60rpx; |
932 | margin: 0 20rpx 20rpx 0; | 933 | margin: 0 20rpx 20rpx 0; |
933 | transition: all 0.3s; | 934 | transition: all 0.3s; |
934 | background: #f2f2f2; | 935 | background: #f2f2f2; |
935 | border-radius: 2px; | 936 | border-radius: 2px; |
936 | border-radius: 2px; | 937 | border-radius: 2px; |
937 | line-height: 60rpx; | 938 | line-height: 60rpx; |
938 | text-align: center; | 939 | text-align: center; |
939 | color: #666666; | 940 | color: #666666; |
940 | font-size: 12px; | 941 | font-size: 12px; |
941 | } | 942 | } |
942 | .active2 { | 943 | .active2 { |
943 | background: rgba(255, 107, 74, 0.15); | 944 | background: rgba(255, 107, 74, 0.15); |
944 | color: #ff6b4a; | 945 | color: #ff6b4a; |
945 | } | 946 | } |
946 | } | 947 | } |
947 | } | 948 | } |
948 | .goods-data { | 949 | .goods-data { |
949 | width: 100%; | 950 | width: 100%; |
950 | box-sizing: border-box; | 951 | box-sizing: border-box; |
951 | padding: 37rpx 40rpx 0 40rpx; | 952 | padding: 37rpx 40rpx 0 40rpx; |
952 | background: #ffffff; | 953 | background: #ffffff; |
953 | border-radius: 12rpx; | 954 | border-radius: 12rpx; |
954 | .opCollapse { | 955 | .opCollapse { |
955 | width: 100%; | 956 | width: 100%; |
956 | padding-bottom: 28rpx; | 957 | padding-bottom: 28rpx; |
957 | margin-top: 7px; | 958 | margin-top: 7px; |
958 | border-bottom: 1px solid #e9e9e9; | 959 | border-bottom: 1px solid #e9e9e9; |
959 | .head { | 960 | .head { |
960 | display: flex; | 961 | display: flex; |
961 | justify-content: space-between; | 962 | justify-content: space-between; |
962 | height: 24px; | 963 | height: 24px; |
963 | // font-family: PingFangSC-Medium; | 964 | // font-family: PingFangSC-Medium; |
964 | font-size: 16px; | 965 | font-size: 16px; |
965 | color: #333333; | 966 | color: #333333; |
966 | letter-spacing: -0.3px; | 967 | letter-spacing: -0.3px; |
967 | text-align: justify; | 968 | text-align: justify; |
968 | line-height: 24px; | 969 | line-height: 24px; |
969 | margin-bottom: 18rpx; | 970 | margin-bottom: 18rpx; |
970 | .headRighted { | 971 | .headRighted { |
971 | width: 0; | 972 | width: 0; |
972 | height: 0; | 973 | height: 0; |
973 | border-left: 4px solid transparent; | 974 | border-left: 4px solid transparent; |
974 | border-right: 4px solid transparent; | 975 | border-right: 4px solid transparent; |
975 | border-bottom: 4px solid #cfcfcf; | 976 | border-bottom: 4px solid #cfcfcf; |
976 | transform: scaleY(-1); | 977 | transform: scaleY(-1); |
977 | margin-top: 10px; | 978 | margin-top: 10px; |
978 | } | 979 | } |
979 | .headMid { | 980 | .headMid { |
980 | font-size: 10px; | 981 | font-size: 10px; |
981 | color: #999999; | 982 | color: #999999; |
982 | letter-spacing: -0.19px; | 983 | letter-spacing: -0.19px; |
983 | margin-left: -120rpx; | 984 | margin-left: -120rpx; |
984 | } | 985 | } |
985 | .headRight { | 986 | .headRight { |
986 | width: 0; | 987 | width: 0; |
987 | height: 0; | 988 | height: 0; |
988 | border-left: 4px solid transparent; | 989 | border-left: 4px solid transparent; |
989 | border-right: 4px solid transparent; | 990 | border-right: 4px solid transparent; |
990 | border-bottom: 4px solid #cfcfcf; | 991 | border-bottom: 4px solid #cfcfcf; |
991 | margin-top: 10px; | 992 | margin-top: 10px; |
992 | } | 993 | } |
993 | } | 994 | } |
994 | .body { | 995 | .body { |
995 | font-size: 12px; | 996 | font-size: 12px; |
996 | color: #666666; | 997 | color: #666666; |
997 | letter-spacing: 0; | 998 | letter-spacing: 0; |
998 | .bodyBox { | 999 | .bodyBox { |
999 | margin-top: 15px; | 1000 | margin-top: 15px; |
1000 | .names { | 1001 | .names { |
1001 | font-size: 12px; | 1002 | font-size: 12px; |
1002 | color: #151515; | 1003 | color: #151515; |
1003 | letter-spacing: 0; | 1004 | letter-spacing: 0; |
1004 | text-align: justify; | 1005 | text-align: justify; |
1005 | line-height: 17px; | 1006 | line-height: 17px; |
1006 | margin-left: 5px; | 1007 | margin-left: 5px; |
1007 | margin-right: 10px; | 1008 | margin-right: 10px; |
1008 | } | 1009 | } |
1009 | text { | 1010 | text { |
1010 | font-size: 12px; | 1011 | font-size: 12px; |
1011 | color: #666666; | 1012 | color: #666666; |
1012 | letter-spacing: 0; | 1013 | letter-spacing: 0; |
1013 | text-align: justify; | 1014 | text-align: justify; |
1014 | } | 1015 | } |
1015 | } | 1016 | } |
1016 | } | 1017 | } |
1017 | .goods-form { | 1018 | .goods-form { |
1018 | display: flex; | 1019 | display: flex; |
1019 | flex-direction: column; | 1020 | flex-direction: column; |
1020 | align-items: center; | 1021 | align-items: center; |
1021 | justify-content: center; | 1022 | justify-content: center; |
1022 | background-color: #fff; | 1023 | background-color: #fff; |
1023 | width: 100%; | 1024 | width: 100%; |
1024 | padding: 40rpx 0; | 1025 | padding: 40rpx 0; |
1025 | .p1 { | 1026 | .p1 { |
1026 | font-size: 16px; | 1027 | font-size: 16px; |
1027 | color: #333333; | 1028 | color: #333333; |
1028 | letter-spacing: -0.3px; | 1029 | letter-spacing: -0.3px; |
1029 | text-align: justify; | 1030 | text-align: justify; |
1030 | line-height: 24px; | 1031 | line-height: 24px; |
1031 | margin: 4px 0; | 1032 | margin: 4px 0; |
1032 | 1033 | ||
1033 | } | 1034 | } |
1034 | .p2 { | 1035 | .p2 { |
1035 | font-size: 12px; | 1036 | font-size: 12px; |
1036 | color: #999999; | 1037 | color: #999999; |
1037 | letter-spacing: -0.23px; | 1038 | letter-spacing: -0.23px; |
1038 | margin-bottom: 32rpx; | 1039 | margin-bottom: 32rpx; |
1039 | } | 1040 | } |
1040 | .image2{ | 1041 | .image2{ |
1041 | width: 42rpx; | 1042 | width: 42rpx; |
1042 | height: 34rpx; | 1043 | height: 34rpx; |
1043 | margin-right: 12rpx; | 1044 | margin-right: 12rpx; |
1044 | } | 1045 | } |
1045 | .confirm { | 1046 | .confirm { |
1046 | display: flex; | 1047 | display: flex; |
1047 | align-items: center; | 1048 | align-items: center; |
1048 | font-size: 12px; | 1049 | font-size: 12px; |
1049 | color: #666666; | 1050 | color: #666666; |
1050 | letter-spacing: -0.23px; | 1051 | letter-spacing: -0.23px; |
1051 | width: 684rpx; | 1052 | width: 684rpx; |
1052 | .image1{ | 1053 | .image1{ |
1053 | margin-right:25rpx; | 1054 | margin-right:25rpx; |
1054 | width: 42rpx; | 1055 | width: 42rpx; |
1055 | height: 38rpx; | 1056 | height: 38rpx; |
1056 | } | 1057 | } |
1057 | } | 1058 | } |
1058 | .picker{ | 1059 | .picker{ |
1059 | display: flex; | 1060 | display: flex; |
1060 | flex-direction: column; | 1061 | flex-direction: column; |
1061 | justify-content: center; | 1062 | justify-content: center; |
1062 | align-items: center; | 1063 | align-items: center; |
1063 | width: 100%; | 1064 | width: 100%; |
1064 | 1065 | ||
1065 | .picker-choice{ | 1066 | .picker-choice{ |
1066 | display: flex; | 1067 | display: flex; |
1067 | width: 684rpx; | 1068 | width: 684rpx; |
1068 | align-items: center; | 1069 | align-items: center; |
1069 | margin-bottom: 40rpx; | 1070 | margin-bottom: 40rpx; |
1070 | .input{ | 1071 | .input{ |
1071 | border-bottom: 1px solid #CFCFCF; | 1072 | border-bottom: 1px solid #CFCFCF; |
1072 | height: 40rpx; | 1073 | height: 40rpx; |
1073 | } | 1074 | } |
1074 | .choice-left{ | 1075 | .choice-left{ |
1075 | width: 210rpx; | 1076 | width: 210rpx; |
1076 | .pd{ | 1077 | .pd{ |
1077 | font-size: 14px; | 1078 | font-size: 14px; |
1078 | color: #333333; | 1079 | color: #333333; |
1079 | letter-spacing: -0.26px; | 1080 | letter-spacing: -0.26px; |
1080 | text-align: justify; | 1081 | text-align: justify; |
1081 | line-height: 24px; | 1082 | line-height: 24px; |
1082 | margin-right: 44rpx; | 1083 | margin-right: 44rpx; |
1083 | } | 1084 | } |
1084 | .p11 { | 1085 | .p11 { |
1085 | font-size: 14px; | 1086 | font-size: 14px; |
1086 | color: #333333; | 1087 | color: #333333; |
1087 | letter-spacing: -0.26px; | 1088 | letter-spacing: -0.26px; |
1088 | text-align: justify; | 1089 | text-align: justify; |
1089 | line-height: 24px; | 1090 | line-height: 24px; |
1090 | // margin-right: 10px; | 1091 | // margin-right: 10px; |
1091 | } | 1092 | } |
1092 | .p12 { | 1093 | .p12 { |
1093 | font-size: 10px; | 1094 | font-size: 10px; |
1094 | color: #3F3F3F; | 1095 | color: #3F3F3F; |
1095 | letter-spacing: -0.19px; | 1096 | letter-spacing: -0.19px; |
1096 | text-align: justify; | 1097 | text-align: justify; |
1097 | line-height: 24px; | 1098 | line-height: 24px; |
1098 | } | 1099 | } |
1099 | 1100 | ||
1100 | } | 1101 | } |
1101 | .p13 { | 1102 | .p13 { |
1102 | font-size: 10px; | 1103 | font-size: 10px; |
1103 | color: #999999; | 1104 | color: #999999; |
1104 | letter-spacing: -0.19px; | 1105 | letter-spacing: -0.19px; |
1105 | margin-right: 10px; | 1106 | margin-right: 10px; |
1106 | } | 1107 | } |
1107 | .p13-date { | 1108 | .p13-date { |
1108 | font-size: 10px; | 1109 | font-size: 10px; |
1109 | color: #999999; | 1110 | color: #999999; |
1110 | letter-spacing: -0.19px; | 1111 | letter-spacing: -0.19px; |
1111 | margin-right: 5px; | 1112 | margin-right: 5px; |
1112 | } | 1113 | } |
1113 | picker{ | 1114 | picker{ |
1114 | width: 144rpx; | 1115 | width: 144rpx; |
1115 | height: 40rpx; | 1116 | height: 40rpx; |
1116 | display: flex; | 1117 | display: flex; |
1117 | position: relative; | 1118 | position: relative; |
1118 | .p14 { | 1119 | .p14 { |
1119 | font-size: 14px; | 1120 | font-size: 14px; |
1120 | color: #666666; | 1121 | color: #666666; |
1121 | letter-spacing: -0.26px; | 1122 | letter-spacing: -0.26px; |
1122 | text-align: center; | 1123 | text-align: center; |
1123 | width: 124rpx; | 1124 | width: 124rpx; |
1124 | border-bottom: 1px solid #CFCFCF; | 1125 | border-bottom: 1px solid #CFCFCF; |
1125 | height: 38rpx; | 1126 | height: 38rpx; |
1126 | } | 1127 | } |
1127 | image{ | 1128 | image{ |
1128 | width: 20rpx; | 1129 | width: 20rpx; |
1129 | height: 20rpx; | 1130 | height: 20rpx; |
1130 | position: absolute; | 1131 | position: absolute; |
1131 | right: 20rpx; | 1132 | right: 20rpx; |
1132 | top: 8rpx; | 1133 | top: 8rpx; |
1133 | } | 1134 | } |
1134 | } | 1135 | } |
1135 | 1136 | ||
1136 | } | 1137 | } |
1137 | } | 1138 | } |
1138 | } | 1139 | } |
1139 | } | 1140 | } |
1140 | } | 1141 | } |
1141 | .choose { | 1142 | .choose { |
1142 | width: 100%; | 1143 | width: 100%; |
1143 | background: #ffffff; | 1144 | background: #ffffff; |
1144 | border-radius: 12rpx; | 1145 | border-radius: 12rpx; |
1145 | margin-top: 20rpx; | 1146 | margin-top: 20rpx; |
1146 | padding: 40rpx 40rpx 112rpx 40rpx; | 1147 | padding: 40rpx 40rpx 112rpx 40rpx; |
1147 | box-sizing: border-box; | 1148 | box-sizing: border-box; |
1148 | .chooseItem { | 1149 | .chooseItem { |
1149 | width: 100%; | 1150 | width: 100%; |
1150 | padding-bottom: 32rpx; | 1151 | padding-bottom: 32rpx; |
1151 | border-bottom: 1px solid #e9e9e9; | 1152 | border-bottom: 1px solid #e9e9e9; |
1152 | margin-bottom: 28rpx; | 1153 | margin-bottom: 28rpx; |
1153 | } | 1154 | } |
1154 | .chooseRes { | 1155 | .chooseRes { |
1155 | font-size: 12px; | 1156 | font-size: 12px; |
1156 | color: #666666; | 1157 | color: #666666; |
1157 | } | 1158 | } |
1158 | .itemsWrap { | 1159 | .itemsWrap { |
1159 | display: flex; | 1160 | display: flex; |
1160 | flex-direction: row; | 1161 | flex-direction: row; |
1161 | flex-wrap: wrap; | 1162 | flex-wrap: wrap; |
1162 | justify-content: flex-start; | 1163 | justify-content: flex-start; |
1163 | align-items: center; | 1164 | align-items: center; |
1164 | padding-top: 24rpx; | 1165 | padding-top: 24rpx; |
1165 | .item1 { | 1166 | .item1 { |
1166 | width: 64rpx; | 1167 | width: 64rpx; |
1167 | height: 64rpx; | 1168 | height: 64rpx; |
1168 | border-radius: 32rpx; | 1169 | border-radius: 32rpx; |
1169 | margin: 0 36rpx 24rpx 0; | 1170 | margin: 0 36rpx 24rpx 0; |
1170 | transition: all 0.3s; | 1171 | transition: all 0.3s; |
1171 | border: 1px solid #ffffff; | 1172 | border: 1px solid #ffffff; |
1172 | } | 1173 | } |
1173 | .item2 { | 1174 | .item2 { |
1174 | // width: 100rpx; | 1175 | // width: 100rpx; |
1175 | padding: 0 30rpx; | 1176 | padding: 0 30rpx; |
1176 | height: 60rpx; | 1177 | height: 60rpx; |
1177 | margin: 0 20rpx 20rpx 0; | 1178 | margin: 0 20rpx 20rpx 0; |
1178 | transition: all 0.3s; | 1179 | transition: all 0.3s; |
1179 | background: #f2f2f2; | 1180 | background: #f2f2f2; |
1180 | border-radius: 2px; | 1181 | border-radius: 2px; |
1181 | border-radius: 2px; | 1182 | border-radius: 2px; |
1182 | line-height: 60rpx; | 1183 | line-height: 60rpx; |
1183 | text-align: center; | 1184 | text-align: center; |
1184 | color: #666666; | 1185 | color: #666666; |
1185 | font-size: 12px; | 1186 | font-size: 12px; |
1186 | } | 1187 | } |
1187 | .active1 { | 1188 | .active1 { |
1188 | opacity: 0.7; | 1189 | opacity: 0.7; |
1189 | border: 1px solid #ff6b4a; | 1190 | border: 1px solid #ff6b4a; |
1190 | } | 1191 | } |
1191 | .active2 { | 1192 | .active2 { |
1192 | background: rgba(255, 107, 74, 0.15); | 1193 | background: rgba(255, 107, 74, 0.15); |
1193 | color: #ff6b4a; | 1194 | color: #ff6b4a; |
1194 | } | 1195 | } |
1195 | } | 1196 | } |
1196 | } | 1197 | } |
1197 | .button { | 1198 | .button { |
1198 | width: 100%; | 1199 | width: 100%; |
1199 | height: 112rpx; | 1200 | height: 112rpx; |
1200 | background-color: #ff6b4a; | 1201 | background-color: #ff6b4a; |
1201 | font-size: 16px; | 1202 | font-size: 16px; |
1202 | color: #ffffff; | 1203 | color: #ffffff; |
1203 | line-height: 112rpx; | 1204 | line-height: 112rpx; |
1204 | text-align: center; | 1205 | text-align: center; |
1205 | position: sticky; | 1206 | position: sticky; |
1206 | bottom: 0rpx; | 1207 | bottom: 0rpx; |
1207 | left: 0rpx; | 1208 | left: 0rpx; |
1208 | } | 1209 | } |
1209 | } | 1210 | } |
1210 | /* sheet弹窗 */ | 1211 | /* sheet弹窗 */ |
1211 | .sheet{ | 1212 | .sheet{ |
1212 | width: 100%; | 1213 | width: 100%; |
1213 | height: 100%; | 1214 | height: 100%; |
1214 | position: fixed; | 1215 | position: fixed; |
1215 | top: 150%; | 1216 | top: 150%; |
1216 | left: 0upx; | 1217 | left: 0upx; |
1217 | bottom: 0upx; | 1218 | bottom: 0upx; |
1218 | right: 0upx; | 1219 | right: 0upx; |
1219 | background:rgba(0,0,0,0.3); | 1220 | background:rgba(0,0,0,0.3); |
1220 | z-index: 10000; | 1221 | z-index: 10000; |
1221 | } | 1222 | } |
1222 | 1223 | ||
1223 | /* 显示时候的动画默认0.5s */ | 1224 | /* 显示时候的动画默认0.5s */ |
1224 | .sheetView{ | 1225 | .sheetView{ |
1225 | width: 100%; | 1226 | width: 100%; |
1226 | height: 0upx; | 1227 | height: 0upx; |
1227 | position: absolute; | 1228 | position: absolute; |
1228 | bottom: 0upx; | 1229 | bottom: 0upx; |
1229 | background: white; | 1230 | background: white; |
1230 | z-index: 10001; | 1231 | z-index: 10001; |
1231 | transition: all 0.5s; | 1232 | transition: all 0.5s; |
1232 | } | 1233 | } |
1233 | .sheetShow{ | 1234 | .sheetShow{ |
1234 | top:0upx !important; | 1235 | top:0upx !important; |
1235 | } | 1236 | } |
1236 | /* 关闭时的动画,时间自己可以设置0.5s*/ | 1237 | /* 关闭时的动画,时间自己可以设置0.5s*/ |
1237 | .sheeHide{ | 1238 | .sheeHide{ |
1238 | top:120% !important; | 1239 | top:120% !important; |
1239 | transition: all 0.5s; | 1240 | transition: all 0.5s; |
1240 | } | 1241 | } |
1241 | 1242 | ||
1242 | /* 项目需求根据设计稿要展示的高度,超出这个高度就自动滚动*/ | 1243 | /* 项目需求根据设计稿要展示的高度,超出这个高度就自动滚动*/ |
1243 | .sheetView_active{ | 1244 | .sheetView_active{ |
1244 | height: 1042upx; | 1245 | height: 1042upx; |
1245 | } | 1246 | } |
1246 | 1247 | ||
1247 | </style> | 1248 | </style> |
1248 | 1249 |
src/components/CommodityCard/CommodityCard.vue
1 | <template> | 1 | <template> |
2 | <view | 2 | <view |
3 | class="card" | 3 | class="card" |
4 | @tap="toGoods(goods.id?goods.id:goods.pid,goods.sk_id)" | 4 | @tap="toGoods(goods.id?goods.id:goods.pid,goods.sk_id)" |
5 | > | 5 | > |
6 | <easy-loadimage mode="widthFix" | 6 | <easy-loadimage mode="widthFix" |
7 | :scroll-top="scrollTop" | 7 | :scroll-top="scrollTop" |
8 | :image-src="goods.imgurl?goods.imgurl:goods.pic" | 8 | :image-src="goods.imgurl?goods.imgurl:goods.pic" |
9 | :viewHeight="viewHeight"></easy-loadimage> | 9 | :viewHeight="viewHeight"></easy-loadimage> |
10 | <!-- <image | 10 | <!-- <image |
11 | mode="widthFix" | 11 | mode="widthFix" |
12 | :src="goods.imgurl?goods.imgurl:goods.pic" | 12 | :src="goods.imgurl?goods.imgurl:goods.pic" |
13 | ></image> --> | 13 | ></image> --> |
14 | <view class="name">{{goods.name?goods.name:goods.p_name}}</view> | 14 | <view class="name">{{goods.name?goods.name:goods.p_name}}</view> |
15 | <view class="info"> | 15 | <view class="info"> |
16 | <view class="priceBox"> | 16 | <view class="priceBox"> |
17 | <view class="price">{{goods.old_price ? goods.old_price : (goods.rsSon && goods.rsSon.Min_Price)}}</view> | 17 | <view class="price">{{goods.old_price ? goods.old_price : (goods.rsSon && goods.rsSon.Min_Price)}}</view> |
18 | <view class="originCost"> | 18 | <view class="originCost"> |
19 | <!-- {{goods.price !== undefined?goods.price:goods.real_price}} --> | 19 | <!-- {{goods.price !== undefined?goods.price:goods.real_price}} --> |
20 | {{goods.real_price ? goods.real_price : parseInt(goods.rsSon && goods.rsSon.Min_Price*(1 + Number(goods.rsSon.discount)/100))}} | 20 | {{goods.real_price ? goods.real_price : parseInt(goods.rsSon && goods.rsSon.Min_Price*(1 + Number(goods.rsSon.discount)/100))}} |
21 | </view> | 21 | </view> |
22 | </view> | 22 | </view> |
23 | <view class="trade_num">{{goods.trade_num}}人购买</view> | 23 | <view class="trade_num">{{goods.trade_num}}人购买</view> |
24 | </view> | 24 | </view> |
25 | </view> | 25 | </view> |
26 | </template> | 26 | </template> |
27 | 27 | ||
28 | <script> | 28 | <script> |
29 | import easyLoadimage from '@/components/EasyLoadimage/EasyLoadimage.vue' | 29 | import easyLoadimage from '@/components/EasyLoadimage/EasyLoadimage.vue' |
30 | // const MockData = require('@/static/easy-loadimage/mock-data.json') | 30 | // const MockData = require('@/static/easy-loadimage/mock-data.json') |
31 | export default { | 31 | export default { |
32 | components:{easyLoadimage}, | 32 | components:{easyLoadimage}, |
33 | props: { | 33 | props: { |
34 | /** | 34 | /** |
35 | * 商品数据 | 35 | * 商品数据 |
36 | */ | 36 | */ |
37 | goods: { | 37 | goods: { |
38 | id: Number, | 38 | id: Number, |
39 | imgurl: String, | 39 | imgurl: String, |
40 | name: String, | 40 | name: String, |
41 | rsSon: Object, | 41 | rsSon: Object, |
42 | originCost: String, | 42 | originCost: String, |
43 | price: String, | 43 | price: String, |
44 | trade_num: String, | 44 | trade_num: String, |
45 | goodType: String, | 45 | goodType: String, |
46 | }, | 46 | }, |
47 | scrollTop:Number, | 47 | scrollTop:Number, |
48 | viewHeight:Number, | 48 | viewHeight:Number, |
49 | }, | 49 | }, |
50 | created () { | 50 | created () { |
51 | }, | 51 | }, |
52 | data () { | 52 | data () { |
53 | return { | 53 | return { |
54 | 54 | ||
55 | } | 55 | } |
56 | }, | 56 | }, |
57 | 57 | ||
58 | methods: { | 58 | methods: { |
59 | toGoods (id, skId) { | 59 | toGoods (id, skId) { |
60 | console.log('---', '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + skId) | 60 | console.log('---', '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + skId) |
61 | uni.navigateTo({ | 61 | uni.navigateTo({ |
62 | url: '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + skId, | 62 | url: '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + skId, |
63 | success: res => {}, | 63 | success: res => {}, |
64 | fail: () => {}, | 64 | fail: () => {}, |
65 | complete: () => {}, | 65 | complete: () => {}, |
66 | }) | 66 | }) |
67 | }, | 67 | }, |
68 | }, | 68 | }, |
69 | } | 69 | } |
70 | </script> | 70 | </script> |
71 | 71 | ||
72 | <style lang="scss"> | 72 | <style lang="scss"> |
73 | 73 | ||
74 | image { | 74 | image { |
75 | width: 100%; | 75 | width: 100%; |
76 | height: 120rpx; | 76 | height: 120rpx; |
77 | } | 77 | } |
78 | .name { | 78 | .name { |
79 | width: 92%; | 79 | width: 92%; |
80 | height: 76rpx; | 80 | height: 84rpx; |
81 | padding: 5px 4%; | 81 | padding: 5px 4%; |
82 | box-sizing: border-box; | 82 | box-sizing: border-box; |
83 | display: -webkit-box; | 83 | display: -webkit-box; |
84 | -webkit-box-orient: vertical; | 84 | -webkit-box-orient: vertical; |
85 | -webkit-line-clamp: 2; | 85 | -webkit-line-clamp: 2; |
86 | text-align: justify; | 86 | text-align: justify; |
87 | overflow: hidden; | 87 | overflow: hidden; |
88 | font-size: 26rpx; | 88 | font-size: 26rpx; |
89 | color: #333333; | 89 | color: #333333; |
90 | } | 90 | } |
91 | .info { | 91 | .info { |
92 | display: flex; | 92 | display: flex; |
93 | justify-content: space-between; | 93 | justify-content: space-between; |
94 | align-items: center; | 94 | align-items: center; |
95 | width: 92%; | 95 | width: 92%; |
96 | padding: 5px 4% 5px 4%; | 96 | padding: 5px 4% 5px 4%; |
97 | .priceBox { | 97 | .priceBox { |
98 | display: flex; | 98 | display: flex; |
99 | justify-content: space-between; | 99 | justify-content: space-between; |
100 | align-items: center; | 100 | align-items: center; |
101 | .price { | 101 | .price { |
102 | color: #eb5d3b; | 102 | color: #eb5d3b; |
103 | font-size: 28rpx; | 103 | font-size: 28rpx; |
104 | font-weight: 600; | 104 | font-weight: 600; |
105 | margin-right: 10rpx; | 105 | margin-right: 10rpx; |
106 | } | 106 | } |
107 | .originCost { | 107 | .originCost { |
108 | text-decoration: line-through; | 108 | text-decoration: line-through; |
109 | color: #999999; | 109 | color: #999999; |
110 | font-size: 20rpx; | 110 | font-size: 20rpx; |
111 | } | 111 | } |
112 | } | 112 | } |
113 | .trade_num { | 113 | .trade_num { |
114 | color: #999999; | 114 | color: #999999; |
115 | font-size: 20rpx; | 115 | font-size: 20rpx; |
116 | } | 116 | } |
117 | } | 117 | } |
118 | </style> | 118 | </style> |
119 | 119 |
src/components/uni-swipe-action-item/bindingx.js
File was created | 1 | const BindingX = uni.requireNativePlugin('bindingx'); | |
2 | const dom = uni.requireNativePlugin('dom'); | ||
3 | const animation = uni.requireNativePlugin('animation'); | ||
4 | |||
5 | export default { | ||
6 | data() { | ||
7 | return { | ||
8 | right: 0, | ||
9 | button: [], | ||
10 | preventGesture: false | ||
11 | } | ||
12 | }, | ||
13 | |||
14 | watch: { | ||
15 | show(newVal) { | ||
16 | if (!this.position || JSON.stringify(this.position) === '{}') return; | ||
17 | if (this.autoClose) return | ||
18 | if (this.isInAnimation) return | ||
19 | if (newVal) { | ||
20 | this.open() | ||
21 | } else { | ||
22 | this.close() | ||
23 | } | ||
24 | }, | ||
25 | }, | ||
26 | created() { | ||
27 | if (this.swipeaction.children !== undefined) { | ||
28 | this.swipeaction.children.push(this) | ||
29 | } | ||
30 | }, | ||
31 | mounted() { | ||
32 | this.boxSelector = this.getEl(this.$refs['selector-box-hock']); | ||
33 | this.selector = this.getEl(this.$refs['selector-content-hock']); | ||
34 | this.buttonSelector = this.getEl(this.$refs['selector-button-hock']); | ||
35 | this.position = {} | ||
36 | this.x = 0 | ||
37 | setTimeout(() => { | ||
38 | this.getSelectorQuery() | ||
39 | }, 200) | ||
40 | }, | ||
41 | beforeDestroy() { | ||
42 | if (this.timing) { | ||
43 | BindingX.unbind({ | ||
44 | token: this.timing.token, | ||
45 | eventType: 'timing' | ||
46 | }) | ||
47 | } | ||
48 | if (this.eventpan) { | ||
49 | BindingX.unbind({ | ||
50 | token: this.eventpan.token, | ||
51 | eventType: 'pan' | ||
52 | }) | ||
53 | } | ||
54 | this.swipeaction.children.forEach((item, index) => { | ||
55 | if (item === this) { | ||
56 | this.swipeaction.children.splice(index, 1) | ||
57 | } | ||
58 | }) | ||
59 | }, | ||
60 | methods: { | ||
61 | onClick(index, item) { | ||
62 | this.$emit('click', { | ||
63 | content: item, | ||
64 | index | ||
65 | }) | ||
66 | }, | ||
67 | touchstart(e) { | ||
68 | if (this.isInAnimation) return | ||
69 | if (this.stop) return | ||
70 | this.stop = true | ||
71 | if (this.autoClose) { | ||
72 | this.swipeaction.closeOther(this) | ||
73 | } | ||
74 | let endWidth = this.right | ||
75 | let boxStep = `(x+${this.x})` | ||
76 | let pageX = `${boxStep}> ${-endWidth} && ${boxStep} < 0?${boxStep}:(x+${this.x} < 0? ${-endWidth}:0)` | ||
77 | |||
78 | let props = [{ | ||
79 | element: this.selector, | ||
80 | property: 'transform.translateX', | ||
81 | expression: pageX | ||
82 | }] | ||
83 | |||
84 | let left = 0 | ||
85 | for (let i = 0; i < this.options.length; i++) { | ||
86 | let buttonSelectors = this.getEl(this.$refs['button-hock'][i]); | ||
87 | if (this.button.length === 0 || !this.button[i] || !this.button[i].width) return | ||
88 | let moveMix = endWidth - left | ||
89 | left += this.button[i].width | ||
90 | let step = `(${this.x}+x)/${endWidth}` | ||
91 | let moveX = `(${step}) * ${moveMix}` | ||
92 | let pageButtonX = `${moveX}&& (x+${this.x} > ${-endWidth})?${moveX}:${-moveMix}` | ||
93 | props.push({ | ||
94 | element: buttonSelectors, | ||
95 | property: 'transform.translateX', | ||
96 | expression: pageButtonX | ||
97 | }) | ||
98 | } | ||
99 | |||
100 | this.eventpan = this._bind(this.boxSelector, props, 'pan', (e) => { | ||
101 | if (e.state === 'end') { | ||
102 | this.x = e.deltaX + this.x; | ||
103 | if (this.x < -endWidth) { | ||
104 | this.x = -endWidth | ||
105 | } | ||
106 | if (this.x > 0) { | ||
107 | this.x = 0 | ||
108 | } | ||
109 | this.stop = false | ||
110 | this.bindTiming(); | ||
111 | } | ||
112 | }) | ||
113 | }, | ||
114 | touchend(e) { | ||
115 | this.$nextTick(() => { | ||
116 | if (this.isopen && !this.isDrag && !this.isInAnimation) { | ||
117 | this.close() | ||
118 | } | ||
119 | }) | ||
120 | }, | ||
121 | bindTiming() { | ||
122 | if (this.isopen) { | ||
123 | this.move(this.x, -this.right) | ||
124 | } else { | ||
125 | this.move(this.x, -40) | ||
126 | } | ||
127 | }, | ||
128 | move(left, value) { | ||
129 | if (left >= value) { | ||
130 | this.close() | ||
131 | } else { | ||
132 | this.open() | ||
133 | } | ||
134 | }, | ||
135 | /** | ||
136 | * 开启swipe | ||
137 | */ | ||
138 | open() { | ||
139 | this.animation(true) | ||
140 | }, | ||
141 | /** | ||
142 | * 关闭swipe | ||
143 | */ | ||
144 | close() { | ||
145 | this.animation(false) | ||
146 | }, | ||
147 | /** | ||
148 | * 开启关闭动画 | ||
149 | * @param {Object} type | ||
150 | */ | ||
151 | animation(type) { | ||
152 | this.isDrag = true | ||
153 | let endWidth = this.right | ||
154 | let time = 200 | ||
155 | this.isInAnimation = true; | ||
156 | |||
157 | let exit = `t>${time}`; | ||
158 | let translate_x_expression = `easeOutExpo(t,${this.x},${type?(-endWidth-this.x):(-this.x)},${time})` | ||
159 | let props = [{ | ||
160 | element: this.selector, | ||
161 | property: 'transform.translateX', | ||
162 | expression: translate_x_expression | ||
163 | }] | ||
164 | |||
165 | let left = 0 | ||
166 | for (let i = 0; i < this.options.length; i++) { | ||
167 | let buttonSelectors = this.getEl(this.$refs['button-hock'][i]); | ||
168 | if (this.button.length === 0 || !this.button[i] || !this.button[i].width) return | ||
169 | let moveMix = endWidth - left | ||
170 | left += this.button[i].width | ||
171 | let step = `${this.x}/${endWidth}` | ||
172 | let moveX = `(${step}) * ${moveMix}` | ||
173 | let pageButtonX = `easeOutExpo(t,${moveX},${type ? -moveMix + '-' + moveX: 0 + '-' + moveX},${time})` | ||
174 | props.push({ | ||
175 | element: buttonSelectors, | ||
176 | property: 'transform.translateX', | ||
177 | expression: pageButtonX | ||
178 | }) | ||
179 | } | ||
180 | |||
181 | this.timing = BindingX.bind({ | ||
182 | eventType: 'timing', | ||
183 | exitExpression: exit, | ||
184 | props: props | ||
185 | }, (e) => { | ||
186 | if (e.state === 'end' || e.state === 'exit') { | ||
187 | this.x = type ? -endWidth : 0 | ||
188 | this.isInAnimation = false; | ||
189 | |||
190 | this.isopen = this.isopen || false | ||
191 | if (this.isopen !== type) { | ||
192 | this.$emit('change', type) | ||
193 | } | ||
194 | this.isopen = type | ||
195 | this.isDrag = false | ||
196 | } | ||
197 | }); | ||
198 | }, | ||
199 | /** | ||
200 | * 绑定 BindingX | ||
201 | * @param {Object} anchor | ||
202 | * @param {Object} props | ||
203 | * @param {Object} fn | ||
204 | */ | ||
205 | _bind(anchor, props, eventType, fn) { | ||
206 | return BindingX.bind({ | ||
207 | anchor, | ||
208 | eventType, | ||
209 | props | ||
210 | }, (e) => { | ||
211 | typeof(fn) === 'function' && fn(e) | ||
212 | }); | ||
213 | }, | ||
214 | /** | ||
215 | * 获取ref | ||
216 | * @param {Object} el | ||
217 | */ | ||
218 | getEl(el) { | ||
219 | return el.ref | ||
220 | }, | ||
221 | /** | ||
222 | * 获取节点信息 | ||
223 | */ | ||
224 | getSelectorQuery() { | ||
225 | dom.getComponentRect(this.$refs['selector-content-hock'], (data) => { | ||
226 | if (this.position.content) return | ||
227 | this.position.content = data.size | ||
228 | }) | ||
229 | for (let i = 0; i < this.options.length; i++) { | ||
230 | dom.getComponentRect(this.$refs['button-hock'][i], (data) => { | ||
231 | if (!this.button) { | ||
232 | this.button = [] | ||
233 | } | ||
234 | if (this.options.length === this.button.length) return | ||
235 | this.button.push(data.size) | ||
236 | this.right += data.size.width | ||
237 | if (this.autoClose) return | ||
238 | if (this.show) { | ||
239 | this.open() | ||
240 | } | ||
241 | }) | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | } | ||
246 |
src/components/uni-swipe-action-item/index.wxs
File was created | 1 | /** | |
2 | * 监听页面内值的变化,主要用于动态开关swipe-action | ||
3 | * @param {Object} newValue | ||
4 | * @param {Object} oldValue | ||
5 | * @param {Object} ownerInstance | ||
6 | * @param {Object} instance | ||
7 | */ | ||
8 | function sizeReady(newValue, oldValue, ownerInstance, instance) { | ||
9 | var state = instance.getState() | ||
10 | state.position = JSON.parse(newValue) | ||
11 | if (!state.position || state.position.length === 0) return | ||
12 | var show = state.position[0].show | ||
13 | state.left = state.left || state.position[0].left; | ||
14 | // 通过用户变量,开启或关闭 | ||
15 | if (show) { | ||
16 | openState(true, instance, ownerInstance) | ||
17 | } else { | ||
18 | openState(false, instance, ownerInstance) | ||
19 | } | ||
20 | } | ||
21 | |||
22 | /** | ||
23 | * 开始触摸操作 | ||
24 | * @param {Object} e | ||
25 | * @param {Object} ins | ||
26 | */ | ||
27 | function touchstart(e, ins) { | ||
28 | var instance = e.instance; | ||
29 | var state = instance.getState(); | ||
30 | var pageX = e.touches[0].pageX; | ||
31 | // 开始触摸时移除动画类 | ||
32 | instance.removeClass('ani'); | ||
33 | var owner = ins.selectAllComponents('.button-hock') | ||
34 | for (var i = 0; i < owner.length; i++) { | ||
35 | owner[i].removeClass('ani'); | ||
36 | } | ||
37 | // state.position = JSON.parse(instance.getDataset().position); | ||
38 | state.left = state.left || state.position[0].left; | ||
39 | // 获取最终按钮组的宽度 | ||
40 | state.width = pageX - state.left; | ||
41 | ins.callMethod('closeSwipe') | ||
42 | } | ||
43 | |||
44 | /** | ||
45 | * 开始滑动操作 | ||
46 | * @param {Object} e | ||
47 | * @param {Object} ownerInstance | ||
48 | */ | ||
49 | function touchmove(e, ownerInstance) { | ||
50 | var instance = e.instance; | ||
51 | var disabled = instance.getDataset().disabled | ||
52 | var state = instance.getState() | ||
53 | // fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复 | ||
54 | disabled = (typeof(disabled) === 'string' ? JSON.parse(disabled) : disabled) || false; | ||
55 | |||
56 | if (disabled) return | ||
57 | var pageX = e.touches[0].pageX; | ||
58 | move(pageX - state.width, instance, ownerInstance) | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * 结束触摸操作 | ||
63 | * @param {Object} e | ||
64 | * @param {Object} ownerInstance | ||
65 | */ | ||
66 | function touchend(e, ownerInstance) { | ||
67 | var instance = e.instance; | ||
68 | var disabled = instance.getDataset().disabled | ||
69 | var state = instance.getState() | ||
70 | |||
71 | // fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复 | ||
72 | disabled = (typeof(disabled) === 'string' ? JSON.parse(disabled) : disabled) || false; | ||
73 | |||
74 | if (disabled) return | ||
75 | // 滑动过程中触摸结束,通过阙值判断是开启还是关闭 | ||
76 | // fixed by mehaotian 定时器解决点击按钮,touchend 触发比 click 事件时机早的问题 ,主要是 ios13 | ||
77 | moveDirection(state.left, -40, instance, ownerInstance) | ||
78 | } | ||
79 | |||
80 | /** | ||
81 | * 设置移动距离 | ||
82 | * @param {Object} value | ||
83 | * @param {Object} instance | ||
84 | * @param {Object} ownerInstance | ||
85 | */ | ||
86 | function move(value, instance, ownerInstance) { | ||
87 | var state = instance.getState() | ||
88 | // 获取可滑动范围 | ||
89 | var x = Math.max(-state.position[1].width, Math.min((value), 0)); | ||
90 | state.left = x; | ||
91 | instance.setStyle({ | ||
92 | transform: 'translateX(' + x + 'px)', | ||
93 | '-webkit-transform': 'translateX(' + x + 'px)' | ||
94 | }) | ||
95 | // 折叠按钮动画 | ||
96 | buttonFold(x, instance, ownerInstance) | ||
97 | } | ||
98 | |||
99 | /** | ||
100 | * 移动方向判断 | ||
101 | * @param {Object} left | ||
102 | * @param {Object} value | ||
103 | * @param {Object} ownerInstance | ||
104 | * @param {Object} ins | ||
105 | */ | ||
106 | function moveDirection(left, value, ins, ownerInstance) { | ||
107 | var state = ins.getState() | ||
108 | var position = state.position | ||
109 | var isopen = state.isopen | ||
110 | if (!position[1].width) { | ||
111 | openState(false, ins, ownerInstance) | ||
112 | return | ||
113 | } | ||
114 | // 如果已经是打开状态,进行判断是否关闭,还是保留打开状态 | ||
115 | if (isopen) { | ||
116 | if (-left <= position[1].width) { | ||
117 | openState(false, ins, ownerInstance) | ||
118 | } else { | ||
119 | openState(true, ins, ownerInstance) | ||
120 | } | ||
121 | return | ||
122 | } | ||
123 | // 如果是关闭状态,进行判断是否打开,还是保留关闭状态 | ||
124 | if (left <= value) { | ||
125 | openState(true, ins, ownerInstance) | ||
126 | } else { | ||
127 | openState(false, ins, ownerInstance) | ||
128 | } | ||
129 | } | ||
130 | |||
131 | /** | ||
132 | * 设置按钮移动距离 | ||
133 | * @param {Object} value | ||
134 | * @param {Object} instance | ||
135 | * @param {Object} ownerInstance | ||
136 | */ | ||
137 | function buttonFold(value, instance, ownerInstance) { | ||
138 | var ins = ownerInstance.selectAllComponents('.button-hock'); | ||
139 | var state = instance.getState(); | ||
140 | var position = state.position; | ||
141 | var arr = []; | ||
142 | var w = 0; | ||
143 | for (var i = 0; i < ins.length; i++) { | ||
144 | if (!ins[i].getDataset().button) return | ||
145 | var btnData = JSON.parse(ins[i].getDataset().button) | ||
146 | |||
147 | // fix by mehaotian TODO 在 app-vue 中,字符串转对象,需要转两次,这里先这么兼容 | ||
148 | if (typeof(btnData) === 'string') { | ||
149 | btnData = JSON.parse(btnData) | ||
150 | } | ||
151 | |||
152 | var button = btnData[i] && btnData[i].width || 0 | ||
153 | w += button | ||
154 | arr.push(-w) | ||
155 | // 动态计算按钮组每个按钮的折叠动画移动距离 | ||
156 | var distance = arr[i - 1] + value * (arr[i - 1] / position[1].width) | ||
157 | if (i != 0) { | ||
158 | ins[i].setStyle({ | ||
159 | transform: 'translateX(' + distance + 'px)', | ||
160 | }) | ||
161 | } | ||
162 | } | ||
163 | } | ||
164 | |||
165 | /** | ||
166 | * 开启状态 | ||
167 | * @param {Boolean} type | ||
168 | * @param {Object} ins | ||
169 | * @param {Object} ownerInstance | ||
170 | */ | ||
171 | function openState(type, ins, ownerInstance) { | ||
172 | var state = ins.getState() | ||
173 | var position = state.position | ||
174 | if (state.isopen === undefined) { | ||
175 | state.isopen = false | ||
176 | } | ||
177 | // 只有状态有改变才会通知页面改变状态 | ||
178 | if (state.isopen !== type) { | ||
179 | // 通知页面,已经打开 | ||
180 | ownerInstance.callMethod('change', { | ||
181 | open: type | ||
182 | }) | ||
183 | } | ||
184 | // 设置打开和移动状态 | ||
185 | state.isopen = type | ||
186 | |||
187 | |||
188 | // 添加动画类 | ||
189 | ins.addClass('ani'); | ||
190 | var owner = ownerInstance.selectAllComponents('.button-hock') | ||
191 | for (var i = 0; i < owner.length; i++) { | ||
192 | owner[i].addClass('ani'); | ||
193 | } | ||
194 | // 设置最终移动位置 | ||
195 | move(type ? -position[1].width : 0, ins, ownerInstance) | ||
196 | |||
197 | } | ||
198 | |||
199 | module.exports = { | ||
200 | sizeReady: sizeReady, | ||
201 | touchstart: touchstart, | ||
202 | touchmove: touchmove, | ||
203 | touchend: touchend | ||
204 | } | ||
205 |
src/components/uni-swipe-action-item/mpalipay.js
File was created | 1 | export default { | |
2 | data() { | ||
3 | return { | ||
4 | isshow: false, | ||
5 | viewWidth: 0, | ||
6 | buttonWidth: 0, | ||
7 | disabledView: false, | ||
8 | x: 0, | ||
9 | transition: false | ||
10 | } | ||
11 | }, | ||
12 | watch: { | ||
13 | show(newVal) { | ||
14 | if (this.autoClose) return | ||
15 | if (newVal) { | ||
16 | this.open() | ||
17 | } else { | ||
18 | this.close() | ||
19 | } | ||
20 | }, | ||
21 | }, | ||
22 | created() { | ||
23 | if (this.swipeaction.children !== undefined) { | ||
24 | this.swipeaction.children.push(this) | ||
25 | } | ||
26 | }, | ||
27 | beforeDestroy() { | ||
28 | this.swipeaction.children.forEach((item, index) => { | ||
29 | if (item === this) { | ||
30 | this.swipeaction.children.splice(index, 1) | ||
31 | } | ||
32 | }) | ||
33 | }, | ||
34 | mounted() { | ||
35 | this.isopen = false | ||
36 | this.transition = true | ||
37 | setTimeout(() => { | ||
38 | this.getQuerySelect() | ||
39 | }, 50) | ||
40 | |||
41 | }, | ||
42 | methods: { | ||
43 | onClick(index, item) { | ||
44 | this.$emit('click', { | ||
45 | content: item, | ||
46 | index | ||
47 | }) | ||
48 | }, | ||
49 | touchstart(e) { | ||
50 | let { | ||
51 | pageX, | ||
52 | pageY | ||
53 | } = e.changedTouches[0] | ||
54 | this.transition = false | ||
55 | this.startX = pageX | ||
56 | if (this.autoClose) { | ||
57 | this.swipeaction.closeOther(this) | ||
58 | } | ||
59 | }, | ||
60 | touchmove(e) { | ||
61 | let { | ||
62 | pageX, | ||
63 | } = e.changedTouches[0] | ||
64 | this.slide = this.getSlide(pageX) | ||
65 | if (this.slide === 0) { | ||
66 | this.disabledView = false | ||
67 | } | ||
68 | |||
69 | }, | ||
70 | touchend(e) { | ||
71 | this.stop = false | ||
72 | this.transition = true | ||
73 | if (this.isopen) { | ||
74 | if (this.moveX === -this.buttonWidth) { | ||
75 | this.close() | ||
76 | return | ||
77 | } | ||
78 | this.move() | ||
79 | } else { | ||
80 | if (this.moveX === 0) { | ||
81 | this.close() | ||
82 | return | ||
83 | } | ||
84 | this.move() | ||
85 | } | ||
86 | }, | ||
87 | open() { | ||
88 | this.x = this.moveX | ||
89 | this.$nextTick(() => { | ||
90 | this.x = -this.buttonWidth | ||
91 | this.moveX = this.x | ||
92 | |||
93 | if(!this.isopen){ | ||
94 | this.isopen = true | ||
95 | this.$emit('change', true) | ||
96 | } | ||
97 | }) | ||
98 | }, | ||
99 | close() { | ||
100 | this.x = this.moveX | ||
101 | this.$nextTick(() => { | ||
102 | this.x = 0 | ||
103 | this.moveX = this.x | ||
104 | if(this.isopen){ | ||
105 | this.isopen = false | ||
106 | this.$emit('change', false) | ||
107 | } | ||
108 | }) | ||
109 | }, | ||
110 | move() { | ||
111 | if (this.slide === 0) { | ||
112 | this.open() | ||
113 | } else { | ||
114 | this.close() | ||
115 | } | ||
116 | }, | ||
117 | onChange(e) { | ||
118 | let x = e.detail.x | ||
119 | this.moveX = x | ||
120 | if (x >= this.buttonWidth) { | ||
121 | this.disabledView = true | ||
122 | this.$nextTick(() => { | ||
123 | this.x = this.buttonWidth | ||
124 | }) | ||
125 | } | ||
126 | }, | ||
127 | getSlide(x) { | ||
128 | if (x >= this.startX) { | ||
129 | this.startX = x | ||
130 | return 1 | ||
131 | } else { | ||
132 | this.startX = x | ||
133 | return 0 | ||
134 | } | ||
135 | |||
136 | }, | ||
137 | getQuerySelect() { | ||
138 | const query = uni.createSelectorQuery().in(this); | ||
139 | query.selectAll('.viewWidth-hook').boundingClientRect(data => { | ||
140 | |||
141 | this.viewWidth = data[0].width | ||
142 | this.buttonWidth = data[1].width | ||
143 | this.transition = false | ||
144 | this.$nextTick(() => { | ||
145 | this.transition = true | ||
146 | }) | ||
147 | |||
148 | if (!this.buttonWidth) { | ||
149 | this.disabledView = true | ||
150 | } | ||
151 | |||
152 | if (this.autoClose) return | ||
153 | if (this.show) { | ||
154 | this.open() | ||
155 | } | ||
156 | }).exec(); | ||
157 | |||
158 | } | ||
159 | } | ||
160 | } | ||
161 |
src/components/uni-swipe-action-item/mpother.js
File was created | 1 | // #ifdef APP-NVUE | |
2 | const dom = weex.requireModule('dom'); | ||
3 | // #endif | ||
4 | export default { | ||
5 | data() { | ||
6 | return { | ||
7 | uniShow: false, | ||
8 | left: 0 | ||
9 | } | ||
10 | }, | ||
11 | computed: { | ||
12 | moveLeft() { | ||
13 | return `translateX(${this.left}px)` | ||
14 | } | ||
15 | }, | ||
16 | watch: { | ||
17 | show(newVal) { | ||
18 | if (!this.position || JSON.stringify(this.position) === '{}') return; | ||
19 | if (this.autoClose) return | ||
20 | if (newVal) { | ||
21 | this.$emit('change', true) | ||
22 | this.open() | ||
23 | } else { | ||
24 | this.$emit('change', false) | ||
25 | this.close() | ||
26 | } | ||
27 | } | ||
28 | }, | ||
29 | mounted() { | ||
30 | this.position = {} | ||
31 | if (this.swipeaction.children !== undefined) { | ||
32 | this.swipeaction.children.push(this) | ||
33 | } | ||
34 | setTimeout(() => { | ||
35 | this.getSelectorQuery() | ||
36 | }, 100) | ||
37 | }, | ||
38 | beforeDestoy() { | ||
39 | this.swipeaction.children.forEach((item, index) => { | ||
40 | if (item === this) { | ||
41 | this.swipeaction.children.splice(index, 1) | ||
42 | } | ||
43 | }) | ||
44 | }, | ||
45 | methods: { | ||
46 | onClick(index, item) { | ||
47 | this.$emit('click', { | ||
48 | content: item, | ||
49 | index | ||
50 | }) | ||
51 | this.close() | ||
52 | }, | ||
53 | touchstart(e) { | ||
54 | const { | ||
55 | pageX | ||
56 | } = e.touches[0] | ||
57 | if (this.disabled) return | ||
58 | const left = this.position.content.left | ||
59 | if (this.autoClose) { | ||
60 | this.swipeaction.closeOther(this) | ||
61 | } | ||
62 | this.width = pageX - left | ||
63 | if (this.isopen) return | ||
64 | if (this.uniShow) { | ||
65 | this.uniShow = false | ||
66 | this.isopen = true | ||
67 | this.openleft = this.left + this.position.button.width | ||
68 | } | ||
69 | }, | ||
70 | touchmove(e, index) { | ||
71 | if (this.disabled) return | ||
72 | const { | ||
73 | pageX | ||
74 | } = e.touches[0] | ||
75 | this.setPosition(pageX) | ||
76 | }, | ||
77 | touchend() { | ||
78 | if (this.disabled) return | ||
79 | if (this.isopen) { | ||
80 | this.move(this.openleft, 0) | ||
81 | return | ||
82 | } | ||
83 | this.move(this.left, -40) | ||
84 | }, | ||
85 | setPosition(x, y) { | ||
86 | if (!this.position.button.width) { | ||
87 | return | ||
88 | } | ||
89 | // this.left = x - this.width | ||
90 | this.setValue(x - this.width) | ||
91 | }, | ||
92 | setValue(value) { | ||
93 | // 设置最大最小值 | ||
94 | this.left = Math.max(-this.position.button.width, Math.min(parseInt(value), 0)) | ||
95 | this.position.content.left = this.left | ||
96 | if (this.isopen) { | ||
97 | this.openleft = this.left + this.position.button.width | ||
98 | } | ||
99 | }, | ||
100 | move(left, value) { | ||
101 | if (left >= value) { | ||
102 | this.$emit('change', false) | ||
103 | this.close() | ||
104 | } else { | ||
105 | this.$emit('change', true) | ||
106 | this.open() | ||
107 | } | ||
108 | }, | ||
109 | open() { | ||
110 | this.uniShow = true | ||
111 | this.left = -this.position.button.width | ||
112 | this.setValue(-this.position.button.width) | ||
113 | }, | ||
114 | close() { | ||
115 | this.uniShow = true | ||
116 | this.setValue(0) | ||
117 | setTimeout(() => { | ||
118 | this.uniShow = false | ||
119 | this.isopen = false | ||
120 | }, 300) | ||
121 | }, | ||
122 | getSelectorQuery() { | ||
123 | // #ifndef APP-NVUE | ||
124 | const views = uni.createSelectorQuery() | ||
125 | .in(this) | ||
126 | views | ||
127 | .selectAll('.selector-query-hock') | ||
128 | .boundingClientRect(data => { | ||
129 | this.position.content = data[1] | ||
130 | this.position.button = data[0] | ||
131 | if (this.autoClose) return | ||
132 | if (this.show) { | ||
133 | this.open() | ||
134 | } else { | ||
135 | this.close() | ||
136 | } | ||
137 | }) | ||
138 | .exec() | ||
139 | // #endif | ||
140 | // #ifdef APP-NVUE | ||
141 | dom.getComponentRect(this.$refs['selector-content-hock'], (data) => { | ||
142 | if (this.position.content) return | ||
143 | this.position.content = data.size | ||
144 | }) | ||
145 | dom.getComponentRect(this.$refs['selector-button-hock'], (data) => { | ||
146 | if (this.position.button) return | ||
147 | this.position.button = data.size | ||
148 | if (this.autoClose) return | ||
149 | if (this.show) { | ||
150 | this.open() | ||
151 | } else { | ||
152 | this.close() | ||
153 | } | ||
154 | }) | ||
155 | // #endif | ||
156 | } | ||
157 | } | ||
158 | } | ||
159 |
src/components/uni-swipe-action-item/mpwxs.js
File was created | 1 | export default { | |
2 | data() { | ||
3 | return { | ||
4 | position: [], | ||
5 | button: [] | ||
6 | } | ||
7 | }, | ||
8 | computed: { | ||
9 | pos() { | ||
10 | return JSON.stringify(this.position) | ||
11 | }, | ||
12 | btn() { | ||
13 | return JSON.stringify(this.button) | ||
14 | } | ||
15 | }, | ||
16 | watch: { | ||
17 | show(newVal) { | ||
18 | if (this.autoClose) return | ||
19 | let valueObj = this.position[0] | ||
20 | if (!valueObj) { | ||
21 | this.init() | ||
22 | return | ||
23 | } | ||
24 | valueObj.show = newVal | ||
25 | this.$set(this.position, 0, valueObj) | ||
26 | } | ||
27 | }, | ||
28 | created() { | ||
29 | if (this.swipeaction.children !== undefined) { | ||
30 | this.swipeaction.children.push(this) | ||
31 | } | ||
32 | }, | ||
33 | mounted() { | ||
34 | this.init() | ||
35 | |||
36 | }, | ||
37 | beforeDestroy() { | ||
38 | this.swipeaction.children.forEach((item, index) => { | ||
39 | if (item === this) { | ||
40 | this.swipeaction.children.splice(index, 1) | ||
41 | } | ||
42 | }) | ||
43 | }, | ||
44 | methods: { | ||
45 | init() { | ||
46 | |||
47 | setTimeout(() => { | ||
48 | this.getSize() | ||
49 | this.getButtonSize() | ||
50 | }, 50) | ||
51 | }, | ||
52 | closeSwipe(e) { | ||
53 | if (!this.autoClose) return | ||
54 | this.swipeaction.closeOther(this) | ||
55 | }, | ||
56 | |||
57 | change(e) { | ||
58 | this.$emit('change', e.open) | ||
59 | let valueObj = this.position[0] | ||
60 | if (valueObj.show !== e.open) { | ||
61 | valueObj.show = e.open | ||
62 | this.$set(this.position, 0, valueObj) | ||
63 | } | ||
64 | }, | ||
65 | onClick(index, item) { | ||
66 | this.$emit('click', { | ||
67 | content: item, | ||
68 | index | ||
69 | }) | ||
70 | }, | ||
71 | appTouchStart(){}, | ||
72 | appTouchEnd(){}, | ||
73 | getSize() { | ||
74 | const views = uni.createSelectorQuery().in(this) | ||
75 | views | ||
76 | .selectAll('.selector-query-hock') | ||
77 | .boundingClientRect(data => { | ||
78 | if (this.autoClose) { | ||
79 | data[0].show = false | ||
80 | } else { | ||
81 | data[0].show = this.show | ||
82 | } | ||
83 | this.position = data | ||
84 | }) | ||
85 | .exec() | ||
86 | }, | ||
87 | getButtonSize() { | ||
88 | const views = uni.createSelectorQuery().in(this) | ||
89 | views | ||
90 | .selectAll('.button-hock') | ||
91 | .boundingClientRect(data => { | ||
92 | this.button = data | ||
93 | }) | ||
94 | .exec() | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 |
src/components/uni-swipe-action-item/uni-swipe-action-item.vue
File was created | 1 | <template> | |
2 | <view class="uni-swipe"> | ||
3 | <!-- 在微信小程序 app vue端 h5 使用wxs 实现--> | ||
4 | <!-- #ifdef APP-VUE || MP-WEIXIN || H5 --> | ||
5 | <view class="uni-swipe_content"> | ||
6 | <view :data-disabled="disabled" :data-position="pos" :change:prop="swipe.sizeReady" :prop="pos" class="uni-swipe_move-box selector-query-hock move-hock" | ||
7 | @touchstart="swipe.touchstart" @touchmove="swipe.touchmove" @touchend="swipe.touchend" @change="change"> | ||
8 | <view class="uni-swipe_box"> | ||
9 | <slot /> | ||
10 | </view> | ||
11 | <view ref="selector-button-hock" class="uni-swipe_button-group selector-query-hock move-hock"> | ||
12 | <!-- 使用 touchend 解决 ios 13 不触发按钮事件的问题--> | ||
13 | <view v-for="(item,index) in options" :data-button="btn" :key="index" :style="{ | ||
14 | backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD', | ||
15 | fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px' | ||
16 | }" | ||
17 | class="uni-swipe_button button-hock" @touchend="onClick(index,item)"><text class="uni-swipe_button-text" :style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}">{{ item.text }}</text></view> | ||
18 | </view> | ||
19 | </view> | ||
20 | </view> | ||
21 | <!-- #endif --> | ||
22 | |||
23 | <!-- app nvue端 使用 bindingx --> | ||
24 | <!-- #ifdef APP-NVUE --> | ||
25 | <view ref="selector-box-hock" class="uni-swipe_content" @horizontalpan="touchstart" @touchend="touchend"> | ||
26 | <view ref="selector-button-hock" class="uni-swipe_button-group selector-query-hock move-hock" :style="{width:right+'px'}"> | ||
27 | <view ref="button-hock" v-for="(item,index) in options" :key="index" :style="{ | ||
28 | backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',left: right+'px'}" | ||
29 | class="uni-swipe_button " @click.stop="onClick(index,item)"><text class="uni-swipe_button-text" :style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'}">{{ item.text }}</text></view> | ||
30 | </view> | ||
31 | <view ref='selector-content-hock' class="uni-swipe_move-box selector-query-hock"> | ||
32 | <view class="uni-swipe_box"> | ||
33 | <slot /> | ||
34 | </view> | ||
35 | </view> | ||
36 | </view> | ||
37 | <!-- #endif --> | ||
38 | |||
39 | <!-- 在非 app 端、非微信小程序、支付宝小程序、h5端使用 js --> | ||
40 | <!-- #ifndef APP-PLUS || MP-WEIXIN || MP-ALIPAY || H5 --> | ||
41 | <view class="uni-swipe_content"> | ||
42 | <view ref="selector-button-hock" class="uni-swipe_button-group selector-query-hock move-hock"> | ||
43 | <view v-for="(item,index) in options" :data-button="btn" :key="index" :style="{ | ||
44 | backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD', | ||
45 | fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px' | ||
46 | }" | ||
47 | class="uni-swipe_button button-hock" @click.stop="onClick(index,item)"><text class="uni-swipe_button-text" :style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}">{{ item.text }}</text></view> | ||
48 | </view> | ||
49 | <view ref='selector-content-hock' class="selector-query-hock" @touchstart="touchstart" @touchmove="touchmove" | ||
50 | @touchend="touchend" :class="{'ani':uniShow}" :style="{transform:moveLeft}"> | ||
51 | <view class="uni-swipe_move-box" > | ||
52 | <view class="uni-swipe_box"> | ||
53 | <slot /> | ||
54 | </view> | ||
55 | </view> | ||
56 | </view> | ||
57 | </view> | ||
58 | <!-- #endif --> | ||
59 | <!-- #ifdef MP-ALIPAY --> | ||
60 | <view class="uni-swipe-box" @touchstart="touchstart" @touchmove="touchmove" @touchend="touchend"> | ||
61 | <view class="viewWidth-hook"> | ||
62 | <movable-area v-if="viewWidth !== 0" class="movable-area" :style="{width:(viewWidth-buttonWidth)+'px'}"> | ||
63 | <movable-view class="movable-view" direction="horizontal" :animation="!transition" :style="{width:viewWidth+'px'}" | ||
64 | :class="[transition?'transition':'']" :x="x" :disabled="disabledView" @change="onChange"> | ||
65 | <view class="movable-view-box"> | ||
66 | <slot></slot> | ||
67 | </view> | ||
68 | </movable-view> | ||
69 | </movable-area> | ||
70 | </view> | ||
71 | <view ref="selector-button-hock" class="uni-swipe_button-group viewWidth-hook"> | ||
72 | <view v-for="(item,index) in options" :data-button="btn" :key="index" :style="{ | ||
73 | backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD', | ||
74 | fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px' | ||
75 | }" | ||
76 | class="uni-swipe_button button-hock" @click.stop="onClick(index,item)"><text class="uni-swipe_button-text" :style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}">{{ item.text }}</text></view> | ||
77 | </view> | ||
78 | </view> | ||
79 | <!-- #endif --> | ||
80 | </view> | ||
81 | </template> | ||
82 | <script src="./index.wxs" module="swipe" lang="wxs"></script> | ||
83 | <script> | ||
84 | // #ifdef APP-VUE|| MP-WEIXIN || H5 | ||
85 | import mpwxs from './mpwxs' | ||
86 | // #endif | ||
87 | |||
88 | // #ifdef APP-NVUE | ||
89 | import bindingx from './bindingx.js' | ||
90 | // #endif | ||
91 | |||
92 | // #ifndef APP-PLUS|| MP-WEIXIN || MP-ALIPAY || H5 | ||
93 | import mixins from './mpother' | ||
94 | // #endif | ||
95 | |||
96 | // #ifdef MP-ALIPAY | ||
97 | import mpalipay from './mpalipay' | ||
98 | // #endif | ||
99 | |||
100 | /** | ||
101 | * SwipeActionItem 滑动操作子组件 | ||
102 | * @description 通过滑动触发选项的容器 | ||
103 | * @tutorial https://ext.dcloud.net.cn/plugin?id=181 | ||
104 | * @property {Boolean} show = [true|false] 开启关闭组件,auto-close = false 时生效 | ||
105 | * @property {Boolean} disabled = [true|false] 是否禁止滑动 | ||
106 | * @property {Boolean} autoClose = [true|false] 其他组件开启的时候,当前组件是否自动关闭 | ||
107 | * @property {Array} options 组件选项内容及样式 | ||
108 | * @event {Function} click 点击选项按钮时触发事件,e = {content,index} ,content(点击内容)、index(下标) | ||
109 | * @event {Function} change 组件打开或关闭时触发,true:开启状态;false:关闭状态 | ||
110 | */ | ||
111 | |||
112 | export default { | ||
113 | // #ifdef APP-VUE|| MP-WEIXIN||H5 | ||
114 | mixins: [mpwxs], | ||
115 | // #endif | ||
116 | |||
117 | // #ifdef APP-NVUE | ||
118 | mixins: [bindingx], | ||
119 | // #endif | ||
120 | |||
121 | // #ifndef APP-PLUS|| MP-WEIXIN || MP-ALIPAY || H5 | ||
122 | mixins: [mixins], | ||
123 | // #endif | ||
124 | |||
125 | // #ifdef MP-ALIPAY | ||
126 | mixins: [mpalipay], | ||
127 | // #endif | ||
128 | |||
129 | props: { | ||
130 | /** | ||
131 | * 按钮内容 | ||
132 | */ | ||
133 | options: { | ||
134 | type: Array, | ||
135 | default () { | ||
136 | return [] | ||
137 | } | ||
138 | }, | ||
139 | /** | ||
140 | * 禁用 | ||
141 | */ | ||
142 | disabled: { | ||
143 | type: Boolean, | ||
144 | default: false | ||
145 | }, | ||
146 | /** | ||
147 | * 变量控制开关 | ||
148 | */ | ||
149 | show: { | ||
150 | type: Boolean, | ||
151 | default: false | ||
152 | }, | ||
153 | /** | ||
154 | * 是否自动关闭 | ||
155 | */ | ||
156 | autoClose: { | ||
157 | type: Boolean, | ||
158 | default: true | ||
159 | } | ||
160 | }, | ||
161 | inject: ['swipeaction'] | ||
162 | |||
163 | |||
164 | } | ||
165 | </script> | ||
166 | <style lang="scss" scoped> | ||
167 | .uni-swipe { | ||
168 | overflow: hidden; | ||
169 | } | ||
170 | |||
171 | .uni-swipe-box { | ||
172 | position: relative; | ||
173 | width: 100%; | ||
174 | } | ||
175 | |||
176 | .uni-swipe_content { | ||
177 | flex: 1; | ||
178 | position: relative; | ||
179 | } | ||
180 | |||
181 | .uni-swipe_move-box { | ||
182 | /* #ifndef APP-NVUE */ | ||
183 | display: flex; | ||
184 | /* #endif */ | ||
185 | position: relative; | ||
186 | flex-direction: row; | ||
187 | } | ||
188 | |||
189 | .uni-swipe_box { | ||
190 | /* #ifndef APP-NVUE */ | ||
191 | display: flex; | ||
192 | flex-direction: row; | ||
193 | width: 100%; | ||
194 | flex-shrink: 0; | ||
195 | /* #endif */ | ||
196 | /* #ifdef APP-NVUE */ | ||
197 | flex: 1; | ||
198 | /* #endif */ | ||
199 | font-size: 14px; | ||
200 | background-color: #fff; | ||
201 | } | ||
202 | |||
203 | .uni-swipe_button-group { | ||
204 | /* #ifndef APP-VUE|| MP-WEIXIN||H5 */ | ||
205 | position: absolute; | ||
206 | top: 0; | ||
207 | right: 0; | ||
208 | bottom: 0; | ||
209 | z-index: 0; | ||
210 | /* #endif */ | ||
211 | /* #ifndef APP-NVUE */ | ||
212 | display: flex; | ||
213 | flex-shrink: 0; | ||
214 | /* #endif */ | ||
215 | flex-direction: row; | ||
216 | } | ||
217 | |||
218 | .uni-swipe_button { | ||
219 | /* #ifdef APP-NVUE */ | ||
220 | position: absolute; | ||
221 | left: 0; | ||
222 | top: 0; | ||
223 | bottom: 0; | ||
224 | /* #endif */ | ||
225 | /* #ifndef APP-NVUE */ | ||
226 | display: flex; | ||
227 | /* #endif */ | ||
228 | flex-direction: row; | ||
229 | justify-content: center; | ||
230 | align-items: center; | ||
231 | padding: 0 20px; | ||
232 | } | ||
233 | |||
234 | .uni-swipe_button-text { | ||
235 | /* #ifndef APP-NVUE */ | ||
236 | flex-shrink: 0; | ||
237 | /* #endif */ | ||
238 | font-size: 14px; | ||
239 | } | ||
240 | |||
241 | .ani { | ||
242 | transition-property: transform; | ||
243 | transition-duration: 0.3s; | ||
244 | transition-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1); | ||
245 | } | ||
246 | |||
247 | /* #ifdef MP-ALIPAY */ | ||
248 | .movable-area { | ||
249 | width: 300px; | ||
250 | height: 100%; | ||
251 | height: 45px; | ||
252 | } | ||
253 | |||
254 | .movable-view { | ||
255 | position: relative; | ||
256 | width: 160%; | ||
257 | height: 45px; | ||
258 | z-index: 2; | ||
259 | } | ||
260 | .transition { | ||
261 | transition: all 0.3s; | ||
262 | } | ||
263 | |||
264 | .movable-view-box { | ||
265 | width: 100%; | ||
266 | height: 100%; | ||
267 | background-color: #fff; | ||
268 | } | ||
269 | /* #endif */ | ||
270 | </style> | ||
271 |
src/components/uni-swipe-action/uni-swipe-action.vue
File was created | 1 | <template> | |
2 | <view> | ||
3 | <slot></slot> | ||
4 | </view> | ||
5 | </template> | ||
6 | |||
7 | <script> | ||
8 | /** | ||
9 | * SwipeAction 滑动操作 | ||
10 | * @description 通过滑动触发选项的容器 | ||
11 | * @tutorial https://ext.dcloud.net.cn/plugin?id=181 | ||
12 | */ | ||
13 | export default { | ||
14 | data() { | ||
15 | return {}; | ||
16 | }, | ||
17 | provide() { | ||
18 | return { | ||
19 | swipeaction: this | ||
20 | } | ||
21 | }, | ||
22 | created() { | ||
23 | this.children = [] | ||
24 | }, | ||
25 | methods: { | ||
26 | closeOther(vm) { | ||
27 | let children = this.children | ||
28 | children.forEach((item, index) => { | ||
29 | if (vm === item) return | ||
30 | // 支付宝执行以下操作 | ||
31 | // #ifdef MP-ALIPAY | ||
32 | if (item.isopen) { | ||
33 | item.close() | ||
34 | } | ||
35 | // #endif | ||
36 | |||
37 | // app vue 端、h5 、微信、支付宝 执行以下操作 | ||
38 | // #ifdef APP-VUE || H5 || MP-WEIXIN | ||
39 | let position = item.position[0] | ||
40 | let show = position.show | ||
41 | if (show) { | ||
42 | position.show = false | ||
43 | } | ||
44 | // #endif | ||
45 | |||
46 | // nvue 执行以下操作 | ||
47 | // #ifdef APP-NVUE || MP-BAIDU || MP-QQ || MP-TOUTIAO | ||
48 | item.close() | ||
49 | // #endif | ||
50 | }) | ||
51 | } | ||
52 | } | ||
53 | } | ||
54 | </script> | ||
55 | |||
56 | <style> | ||
57 | |||
58 | </style> | ||
59 |
src/components/uni-transition/uni-transition.vue
1 | <template> | 1 | <template> |
2 | <view v-if="isShow" ref="ani" class="uni-transition" :class="[ani.in]" :style="'transform:' +transform+';'+stylesObject" | 2 | <view v-if="isShow" ref="ani" class="uni-transition" :class="[ani.in]" :style="'transform:' +transform+';'+stylesObject" |
3 | @click="change"> | 3 | @click="change"> |
4 | <slot></slot> | 4 | <slot></slot> |
5 | </view> | 5 | </view> |
6 | </template> | 6 | </template> |
7 | 7 | ||
8 | <script> | 8 | <script> |
9 | // #ifdef APP-NVUE | 9 | // #ifdef APP-NVUE |
10 | const animation = uni.requireNativePlugin('animation'); | 10 | const animation = uni.requireNativePlugin('animation'); |
11 | // #endif | 11 | // #endif |
12 | /** | 12 | /** |
13 | * Transition 过渡动画 | 13 | * Transition 过渡动画 |
14 | * @description 简单过渡动画组件 | 14 | * @description 简单过渡动画组件 |
15 | * @tutorial https://ext.dcloud.net.cn/plugin?id=985 | 15 | * @tutorial https://ext.dcloud.net.cn/plugin?id=985 |
16 | * @property {Boolean} show = [false|true] 控制组件显示或隐藏 | 16 | * @property {Boolean} show = [false|true] 控制组件显示或隐藏 |
17 | * @property {Array} modeClass = [fade|slide-top|slide-right|slide-bottom|slide-left|zoom-in|zoom-out] 过渡动画类型 | 17 | * @property {Array} modeClass = [fade|slide-top|slide-right|slide-bottom|slide-left|zoom-in|zoom-out] 过渡动画类型 |
18 | * @value fade 渐隐渐出过渡 | 18 | * @value fade 渐隐渐出过渡 |
19 | * @value slide-top 由上至下过渡 | 19 | * @value slide-top 由上至下过渡 |
20 | * @value slide-right 由右至左过渡 | 20 | * @value slide-right 由右至左过渡 |
21 | * @value slide-bottom 由下至上过渡 | 21 | * @value slide-bottom 由下至上过渡 |
22 | * @value slide-left 由左至右过渡 | 22 | * @value slide-left 由左至右过渡 |
23 | * @value zoom-in 由小到大过渡 | 23 | * @value zoom-in 由小到大过渡 |
24 | * @value zoom-out 由大到小过渡 | 24 | * @value zoom-out 由大到小过渡 |
25 | * @property {Number} duration 过渡动画持续时间 | 25 | * @property {Number} duration 过渡动画持续时间 |
26 | * @property {Object} styles 组件样式,同 css 样式,注意带’-‘连接符的属性需要使用小驼峰写法如:`backgroundColor:red` | 26 | * @property {Object} styles 组件样式,同 css 样式,注意带’-‘连接符的属性需要使用小驼峰写法如:`backgroundColor:red` |
27 | */ | 27 | */ |
28 | export default { | 28 | export default { |
29 | name: 'uniTransition', | 29 | name: 'uniTransition', |
30 | props: { | 30 | props: { |
31 | show: { | 31 | show: { |
32 | type: Boolean, | 32 | type: Boolean, |
33 | default: false | 33 | default: false |
34 | }, | 34 | }, |
35 | modeClass: { | 35 | modeClass: { |
36 | type: Array, | 36 | type: Array, |
37 | default () { | 37 | default () { |
38 | return [] | 38 | return [] |
39 | } | 39 | } |
40 | }, | 40 | }, |
41 | duration: { | 41 | duration: { |
42 | type: Number, | 42 | type: Number, |
43 | default: 300 | 43 | default: 300 |
44 | }, | 44 | }, |
45 | styles: { | 45 | styles: { |
46 | type: Object, | 46 | type: Object, |
47 | default () { | 47 | default () { |
48 | return {} | 48 | return {} |
49 | } | 49 | } |
50 | } | 50 | } |
51 | }, | 51 | }, |
52 | data() { | 52 | data() { |
53 | return { | 53 | return { |
54 | isShow: false, | 54 | isShow: false, |
55 | transform: '', | 55 | transform: '', |
56 | ani: { in: '', | 56 | ani: { in: '', |
57 | active: '' | 57 | active: '' |
58 | } | 58 | } |
59 | }; | 59 | }; |
60 | }, | 60 | }, |
61 | watch: { | 61 | watch: { |
62 | show: { | 62 | show: { |
63 | handler(newVal) { | 63 | handler(newVal) { |
64 | if (newVal) { | 64 | if (newVal) { |
65 | this.open() | 65 | this.open() |
66 | } else { | 66 | } else { |
67 | this.close() | 67 | this.close() |
68 | } | 68 | } |
69 | }, | 69 | }, |
70 | immediate: true | 70 | immediate: true |
71 | } | 71 | } |
72 | }, | 72 | }, |
73 | computed: { | 73 | computed: { |
74 | stylesObject() { | 74 | stylesObject() { |
75 | let styles = { | 75 | let styles = { |
76 | ...this.styles, | 76 | ...this.styles, |
77 | 'transition-duration': this.duration / 1000 + 's' | 77 | 'transition-duration': this.duration / 1000 + 's' |
78 | } | 78 | } |
79 | let transfrom = '' | 79 | let transfrom = '' |
80 | for (let i in styles) { | 80 | for (let i in styles) { |
81 | let line = this.toLine(i) | 81 | let line = this.toLine(i) |
82 | transfrom += line + ':' + styles[i] + ';' | 82 | transfrom += line + ':' + styles[i] + ';' |
83 | } | 83 | } |
84 | return transfrom | 84 | return transfrom |
85 | } | 85 | } |
86 | }, | 86 | }, |
87 | created() { | 87 | created() { |
88 | // this.timer = null | 88 | // this.timer = null |
89 | // this.nextTick = (time = 50) => new Promise(resolve => { | 89 | // this.nextTick = (time = 50) => new Promise(resolve => { |
90 | // clearTimeout(this.timer) | 90 | // clearTimeout(this.timer) |
91 | // this.timer = setTimeout(resolve, time) | 91 | // this.timer = setTimeout(resolve, time) |
92 | // return this.timer | 92 | // return this.timer |
93 | // }); | 93 | // }); |
94 | }, | 94 | }, |
95 | methods: { | 95 | methods: { |
96 | change() { | 96 | change() { |
97 | this.$emit('click', { | 97 | this.$emit('click', { |
98 | detail: this.isShow | 98 | detail: this.isShow |
99 | }) | 99 | }) |
100 | }, | 100 | }, |
101 | open() { | 101 | open() { |
102 | clearTimeout(this.timer) | 102 | clearTimeout(this.timer) |
103 | this.isShow = true | 103 | this.isShow = true |
104 | this.transform = '' | 104 | this.transform = '' |
105 | this.ani.in = '' | 105 | this.ani.in = '' |
106 | for (let i in this.getTranfrom(false)) { | 106 | for (let i in this.getTranfrom(false)) { |
107 | if (i === 'opacity') { | 107 | if (i === 'opacity') { |
108 | this.ani.in = 'fade-in' | 108 | this.ani.in = 'fade-in' |
109 | } else { | 109 | } else { |
110 | this.transform += `${this.getTranfrom(false)[i]} ` | 110 | this.transform += `${this.getTranfrom(false)[i]} ` |
111 | } | 111 | } |
112 | } | 112 | } |
113 | this.$nextTick(() => { | 113 | this.$nextTick(() => { |
114 | setTimeout(() => { | 114 | setTimeout(() => { |
115 | this._animation(true) | 115 | this._animation(true) |
116 | }, 50) | 116 | }, 50) |
117 | }) | 117 | }) |
118 | 118 | ||
119 | }, | 119 | }, |
120 | close(type) { | 120 | close(type) { |
121 | clearTimeout(this.timer) | 121 | clearTimeout(this.timer) |
122 | this._animation(false) | 122 | this._animation(false) |
123 | }, | 123 | }, |
124 | _animation(type) { | 124 | _animation(type) { |
125 | let styles = this.getTranfrom(type) | 125 | let styles = this.getTranfrom(type) |
126 | // #ifdef APP-NVUE | 126 | // #ifdef APP-NVUE |
127 | if(!this.$refs['ani']) return | 127 | if(!this.$refs['ani']) return |
128 | animation.transition(this.$refs['ani'].ref, { | 128 | animation.transition(this.$refs['ani'].ref, { |
129 | styles, | 129 | styles, |
130 | duration: this.duration, //ms | 130 | duration: this.duration, //ms |
131 | timingFunction: 'ease', | 131 | timingFunction: 'ease', |
132 | needLayout: false, | 132 | needLayout: false, |
133 | delay: 0 //ms | 133 | delay: 0 //ms |
134 | }, () => { | 134 | }, () => { |
135 | if (!type) { | 135 | if (!type) { |
136 | this.isShow = false | 136 | this.isShow = false |
137 | } | 137 | } |
138 | this.$emit('change', { | 138 | this.$emit('change', { |
139 | detail: this.isShow | 139 | detail: this.isShow |
140 | }) | 140 | }) |
141 | }) | 141 | }) |
142 | // #endif | 142 | // #endif |
143 | // #ifndef APP-NVUE | 143 | // #ifndef APP-NVUE |
144 | this.transform = '' | 144 | this.transform = '' |
145 | for (let i in styles) { | 145 | for (let i in styles) { |
146 | if (i === 'opacity') { | 146 | if (i === 'opacity') { |
147 | this.ani.in = `fade-${type?'out':'in'}` | 147 | this.ani.in = `fade-${type?'out':'in'}` |
148 | } else { | 148 | } else { |
149 | this.transform += `${styles[i]} ` | 149 | this.transform += `${styles[i]} ` |
150 | } | 150 | } |
151 | } | 151 | } |
152 | this.timer = setTimeout(() => { | 152 | this.timer = setTimeout(() => { |
153 | if (!type) { | 153 | if (!type) { |
154 | this.isShow = false | 154 | this.isShow = false |
155 | } | 155 | } |
156 | this.$emit('change', { | 156 | this.$emit('change', { |
157 | detail: this.isShow | 157 | detail: this.isShow |
158 | }) | 158 | }) |
159 | 159 | ||
160 | }, this.duration) | 160 | }, this.duration) |
161 | // #endif | 161 | // #endif |
162 | 162 | ||
163 | }, | 163 | }, |
164 | getTranfrom(type) { | 164 | getTranfrom(type) { |
165 | let styles = { | 165 | let styles = { |
166 | transform: '' | 166 | transform: '' |
167 | } | 167 | } |
168 | this.modeClass.forEach((mode) => { | 168 | this.modeClass.forEach((mode) => { |
169 | switch (mode) { | 169 | switch (mode) { |
170 | case 'fade': | 170 | case 'fade': |
171 | styles.opacity = type ? 1 : 0 | 171 | styles.opacity = type ? 1 : 0 |
172 | break; | 172 | break; |
173 | case 'slide-top': | 173 | case 'slide-top': |
174 | styles.transform += `translateY(${type?'0':'-100%'}) ` | 174 | styles.transform += `translateY(${type?'0':'-100%'}) ` |
175 | break; | 175 | break; |
176 | case 'slide-right': | 176 | case 'slide-right': |
177 | styles.transform += `translateX(${type?'0':'100%'}) ` | 177 | styles.transform += `translateX(${type?'0':'100%'}) ` |
178 | break; | 178 | break; |
179 | case 'slide-bottom': | 179 | case 'slide-bottom': |
180 | styles.transform += `translateY(${type?'0':'100%'}) ` | 180 | styles.transform += `translateY(${type?'0':'100%'}) ` |
181 | break; | 181 | break; |
182 | case 'slide-left': | 182 | case 'slide-left': |
183 | styles.transform += `translateX(${type?'0':'-100%'}) ` | 183 | styles.transform += `translateX(${type?'0':'-100%'}) ` |
184 | break; | 184 | break; |
185 | case 'zoom-in': | 185 | case 'zoom-in': |
186 | styles.transform += `scale(${type?1:0.8}) ` | 186 | styles.transform += `scale(${type?1:0.8}) ` |
187 | break; | 187 | break; |
188 | case 'zoom-out': | 188 | case 'zoom-out': |
189 | styles.transform += `scale(${type?1:1.2}) ` | 189 | styles.transform += `scale(${type?1:1.2}) ` |
190 | break; | 190 | break; |
191 | } | 191 | } |
192 | }) | 192 | }) |
193 | return styles | 193 | return styles |
194 | }, | 194 | }, |
195 | _modeClassArr(type) { | 195 | _modeClassArr(type) { |
196 | let mode = this.modeClass | 196 | let mode = this.modeClass |
197 | if (typeof(mode) !== "string") { | 197 | if (typeof(mode) !== "string") { |
198 | let modestr = '' | 198 | let modestr = '' |
199 | mode.forEach((item) => { | 199 | mode.forEach((item) => { |
200 | modestr += (item + '-' + type + ',') | 200 | modestr += (item + '-' + type + ',') |
201 | }) | 201 | }) |
202 | return modestr.substr(0, modestr.length - 1) | 202 | return modestr.substr(0, modestr.length - 1) |
203 | } else { | 203 | } else { |
204 | return mode + '-' + type | 204 | return mode + '-' + type |
205 | } | 205 | } |
206 | }, | 206 | }, |
207 | // getEl(el) { | 207 | // getEl(el) { |
208 | // console.log(el || el.ref || null); | 208 | // console.log(el || el.ref || null); |
209 | // return el || el.ref || null | 209 | // return el || el.ref || null |
210 | // }, | 210 | // }, |
211 | toLine(name) { | 211 | toLine(name) { |
212 | return name.replace(/([A-Z])/g, "-$1").toLowerCase(); | 212 | return name.replace(/([A-Z])/g, "-$1").toLowerCase(); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | } | 215 | } |
216 | </script> | 216 | </script> |
217 | 217 | ||
218 | <style> | 218 | <style> |
219 | .uni-transition { | 219 | .uni-transition { |
220 | transition-timing-function: ease; | 220 | transition-timing-function: ease; |
221 | transition-duration: 0.3s; | 221 | transition-duration: 0.3s; |
222 | transition-property: transform, opacity; | 222 | transition-property: transform, opacity; |
223 | } | 223 | } |
224 | 224 | ||
225 | .fade-in { | 225 | .fade-in { |
226 | opacity: 0; | 226 | opacity: 0; |
227 | } | 227 | } |
228 | 228 | ||
229 | .fade-active { | 229 | .fade-active { |
230 | opacity: 1; | 230 | opacity: 1; |
231 | } | 231 | } |
232 | 232 | ||
233 | .slide-top-in { | 233 | .slide-top-in { |
234 | /* transition-property: transform, opacity; */ | 234 | /* transition-property: transform, opacity; */ |
235 | transform: translateY(-100%); | 235 | transform: translateY(-100%); |
236 | } | 236 | } |
237 | 237 | ||
238 | .slide-top-active { | 238 | .slide-top-active { |
239 | transform: translateY(0); | 239 | transform: translateY(0); |
240 | /* opacity: 1; */ | 240 | /* opacity: 1; */ |
241 | } | 241 | } |
242 | 242 | ||
243 | .slide-right-in { | 243 | .slide-right-in { |
244 | transform: translateX(100%); | 244 | transform: translateX(100%); |
245 | } | 245 | } |
246 | 246 | ||
247 | .slide-right-active { | 247 | .slide-right-active { |
248 | transform: translateX(0); | 248 | transform: translateX(0); |
249 | } | 249 | } |
250 | 250 | ||
251 | .slide-bottom-in { | 251 | .slide-bottom-in { |
252 | transform: translateY(100%); | 252 | transform: translateY(100%); |
253 | } | 253 | } |
254 | 254 | ||
255 | .slide-bottom-active { | 255 | .slide-bottom-active { |
256 | transform: translateY(0); | 256 | transform: translateY(0); |
257 | } | 257 | } |
258 | 258 | ||
259 | .slide-left-in { | 259 | .slide-left-in { |
260 | transform: translateX(-100%); | 260 | transform: translateX(-100%); |
261 | } | 261 | } |
262 | 262 | ||
263 | .slide-left-active { | 263 | .slide-left-active { |
264 | transform: translateX(0); | 264 | transform: translateX(0); |
265 | opacity: 1; | 265 | opacity: 1; |
266 | } | 266 | } |
267 | 267 | ||
268 | .zoom-in-in { | 268 | .zoom-in-in { |
269 | transform: scale(0.8); | 269 | transform: scale(0.8); |
270 | } | 270 | } |
271 | 271 | ||
272 | .zoom-out-active { | 272 | .zoom-out-active { |
273 | transform: scale(1); | 273 | transform: scale(1); |
274 | } | 274 | } |
275 | 275 | ||
276 | .zoom-out-in { | 276 | .zoom-out-in { |
277 | transform: scale(1.2); | 277 | transform: scale(1.2); |
278 | } | 278 | } |
279 | </style> | 279 | </style> |
280 | 280 |
src/pages.json
1 | { | 1 | { |
2 | "pages": [ | 2 | "pages": [ |
3 | { | 3 | { |
4 | "path": "pages/index/index", | 4 | "path": "pages/index/index", |
5 | "style": { | 5 | "style": { |
6 | "navigationBarTitleText": "商城一览" | 6 | "navigationBarTitleText": "商城一览" |
7 | } | 7 | } |
8 | }, | 8 | }, |
9 | { | 9 | { |
10 | "path": "pages/user/user", | 10 | "path": "pages/user/user", |
11 | "style": { | 11 | "style": { |
12 | "navigationBarTitleText": "我的" | 12 | "navigationBarTitleText": "我的" |
13 | } | 13 | } |
14 | }, | 14 | }, |
15 | { | 15 | { |
16 | "path": "pages/addOpticsData/addOpticsData", | 16 | "path": "pages/addOpticsData/addOpticsData", |
17 | "style": { | 17 | "style": { |
18 | "navigationBarTitleText": "验光数据" | 18 | "navigationBarTitleText": "验光数据" |
19 | } | 19 | } |
20 | }, | 20 | }, |
21 | { | 21 | { |
22 | "path": "pages/detailsChoiceArgs/detailsChoiceArgs", | 22 | "path": "pages/detailsChoiceArgs/detailsChoiceArgs", |
23 | "style": { | 23 | "style": { |
24 | "navigationBarTitleText": "镜片名称名称" | 24 | "navigationBarTitleText": "镜片名称名称" |
25 | } | 25 | } |
26 | }, | 26 | }, |
27 | { | 27 | { |
28 | "path": "pages/purchaseLenses/purchaseLenses", | 28 | "path": "pages/purchaseLenses/purchaseLenses", |
29 | "style": { | 29 | "style": { |
30 | "navigationBarTitleText": "参数选择" | 30 | "navigationBarTitleText": "参数选择" |
31 | } | 31 | } |
32 | }, | 32 | }, |
33 | { | 33 | { |
34 | "path": "pages/lensDetails/lensDetails", | 34 | "path": "pages/lensDetails/lensDetails", |
35 | "style": { | 35 | "style": { |
36 | "navigationBarTitleText": "产品详情" | 36 | "navigationBarTitleText": "产品详情" |
37 | } | 37 | } |
38 | }, | 38 | }, |
39 | { | 39 | { |
40 | "path": "pages/details/details", | 40 | "path": "pages/details/details", |
41 | "style": { | 41 | "style": { |
42 | "navigationBarTitleText": "产品详情" | 42 | "navigationBarTitleText": "产品详情" |
43 | } | 43 | } |
44 | }, | 44 | }, |
45 | { | 45 | { |
46 | "path": "pages/myOrderPaying/myOrderPaying", | 46 | "path": "pages/myOrderPaying/myOrderPaying", |
47 | "style": { | 47 | "style": { |
48 | "navigationBarTitleText": "我的订单" | 48 | "navigationBarTitleText": "我的订单" |
49 | } | 49 | } |
50 | }, | 50 | }, |
51 | { | 51 | { |
52 | "path": "pages/myOrder/myOrder", | 52 | "path": "pages/myOrder/myOrder", |
53 | "style": { | 53 | "style": { |
54 | "navigationBarTitleText": "我的订单" | 54 | "navigationBarTitleText": "我的订单" |
55 | } | 55 | } |
56 | }, | 56 | }, |
57 | { | 57 | { |
58 | "path": "pages/cart/cart", | 58 | "path": "pages/cart/cart", |
59 | "style": { | 59 | "style": { |
60 | "navigationBarTitleText": "购物车" | 60 | "navigationBarTitleText": "购物车", |
61 | // "disableScroll":true, | ||
62 | "app-plus":{ | ||
63 | "bounce":"none" | ||
64 | } | ||
61 | } | 65 | } |
62 | }, | 66 | }, |
63 | { | 67 | { |
64 | "path": "pages/frameDetail/frameDetail", | 68 | "path": "pages/frameDetail/frameDetail", |
65 | "style": { | 69 | "style": { |
66 | "navigationBarTitleText": "产品详情" | 70 | "navigationBarTitleText": "产品详情" |
67 | } | 71 | } |
68 | }, | 72 | }, |
69 | // { | 73 | // { |
70 | // "path": "pages/refundProgress/refundProgress", | 74 | // "path": "pages/refundProgress/refundProgress", |
71 | // "style": { | 75 | // "style": { |
72 | // "navigationBarTitleText": "申请退款" | 76 | // "navigationBarTitleText": "申请退款" |
73 | // } | 77 | // } |
74 | // }, | 78 | // }, |
75 | // { | 79 | // { |
76 | // "path": "pages/address/addAddress", | 80 | // "path": "pages/address/addAddress", |
77 | // "style": { | 81 | // "style": { |
78 | // "navigationBarTitleText": "新增地址" | 82 | // "navigationBarTitleText": "新增地址" |
79 | // } | 83 | // } |
80 | // }, | 84 | // }, |
81 | // { | 85 | // { |
82 | // "path": "pages/address/addressList", | 86 | // "path": "pages/address/addressList", |
83 | // "style": { | 87 | // "style": { |
84 | // "navigationBarTitleText": "地址管理" | 88 | // "navigationBarTitleText": "地址管理" |
85 | // } | 89 | // } |
86 | // }, | 90 | // }, |
87 | { | 91 | { |
88 | "path": "pages/confirmOrder/confirmOrder", | 92 | "path": "pages/confirmOrder/confirmOrder", |
89 | "style": { | 93 | "style": { |
90 | "navigationBarTitleText": "确认订单" | 94 | "navigationBarTitleText": "确认订单" |
91 | } | 95 | } |
92 | }, | 96 | }, |
93 | // { | 97 | // { |
94 | // "path": "pages/refundment/refundWays", | 98 | // "path": "pages/refundment/refundWays", |
95 | // "style": { | 99 | // "style": { |
96 | // "navigationBarTitleText": "退款方式" | 100 | // "navigationBarTitleText": "退款方式" |
97 | // } | 101 | // } |
98 | // }, | 102 | // }, |
99 | // { | 103 | // { |
100 | // "path": "pages/refundment/refundment", | 104 | // "path": "pages/refundment/refundment", |
101 | // "style": { | 105 | // "style": { |
102 | // "navigationBarTitleText": "申请退款" | 106 | // "navigationBarTitleText": "申请退款" |
103 | // } | 107 | // } |
104 | // }, | 108 | // }, |
105 | { | 109 | { |
106 | "path": "pages/predelivery/predelivery", | 110 | "path": "pages/predelivery/predelivery", |
107 | "style": { | 111 | "style": { |
108 | "navigationBarTitleText": "待发货" | 112 | "navigationBarTitleText": "待发货" |
109 | } | 113 | } |
110 | }, | 114 | }, |
111 | { | 115 | { |
112 | "path": "pages/customerService/customerService", | 116 | "path": "pages/customerService/customerService", |
113 | "style": { | 117 | "style": { |
114 | "navigationBarTitleText": "在线客服" | 118 | "navigationBarTitleText": "在线客服" |
115 | } | 119 | } |
116 | }, | 120 | }, |
117 | { | 121 | { |
118 | "path": "pages/detailStandard/detailStandard_sun", | 122 | "path": "pages/detailStandard/detailStandard_sun", |
119 | "style": { | 123 | "style": { |
120 | "navigationBarTitleText": "太阳镜选购页" | 124 | "navigationBarTitleText": "太阳镜选购页" |
121 | } | 125 | } |
122 | }, | 126 | }, |
123 | { | 127 | { |
124 | "path": "pages/detailStandard/detailStandard_k", | 128 | "path": "pages/detailStandard/detailStandard_k", |
125 | "style": { | 129 | "style": { |
126 | "navigationBarTitleText": "镜框选购页" | 130 | "navigationBarTitleText": "镜框选购页" |
127 | } | 131 | } |
128 | }, | 132 | }, |
129 | { | 133 | { |
130 | "path": "pages/newOpticsData/newOpticsData", | 134 | "path": "pages/newOpticsData/newOpticsData", |
131 | "style": { | 135 | "style": { |
132 | "navigationBarTitleText": "验光数据" | 136 | "navigationBarTitleText": "验光数据" |
133 | } | 137 | } |
134 | } | 138 | } |
135 | ], | 139 | ], |
136 | "subpackages": [ | 140 | "subpackages": [ |
137 | { | 141 | { |
138 | "root": "pages/refundment", | 142 | "root": "pages/refundment", |
139 | "pages": [ | 143 | "pages": [ |
140 | "pages/refundment/refundWays", | 144 | "pages/refundment/refundWays", |
141 | "pages/refundment/refundment", | 145 | "pages/refundment/refundment", |
142 | "pages/refundProgress/refundProgress" | 146 | "pages/refundProgress/refundProgress" |
143 | ] | 147 | ] |
144 | }, | 148 | }, |
145 | { | 149 | { |
146 | "root": "pages/address", | 150 | "root": "pages/address", |
147 | "name": "pack2", | 151 | "name": "pack2", |
148 | "pages": [ | 152 | "pages": [ |
149 | "pages/address/addAddress", | 153 | "pages/address/addAddress", |
150 | "pages/address/addressList" | 154 | "pages/address/addressList" |
151 | ] | 155 | ] |
152 | } | 156 | } |
153 | ], | 157 | ], |
154 | "globalStyle": { | 158 | "globalStyle": { |
155 | "navigationBarTextStyle": "black", | 159 | "navigationBarTextStyle": "black", |
156 | "navigationBarTitleText": "uni-app", | 160 | "navigationBarTitleText": "uni-app", |
157 | "navigationBarBackgroundColor": "#F8F8F8", | 161 | "navigationBarBackgroundColor": "#F8F8F8", |
158 | "backgroundColor": "#F8F8F8" | 162 | "backgroundColor": "#F8F8F8" |
159 | }, | 163 | }, |
160 | "tabBar": { | 164 | "tabBar": { |
161 | "color": "#C0C4CC", | 165 | "color": "#C0C4CC", |
162 | "selectedColor": "#fa436a", | 166 | "selectedColor": "#fa436a", |
163 | "borderStyle": "black", | 167 | "borderStyle": "black", |
164 | "backgroundColor": "#ffffff", | 168 | "backgroundColor": "#ffffff", |
165 | "list": [ | 169 | "list": [ |
166 | { | 170 | { |
167 | "pagePath": "pages/index/index", | 171 | "pagePath": "pages/index/index", |
168 | "iconPath": "static/tab-home.png", | 172 | "iconPath": "static/tab-home.png", |
169 | "selectedIconPath": "static/tab-home-current.png", | 173 | "selectedIconPath": "static/tab-home-current.png", |
170 | "text": "首页" | 174 | "text": "首页" |
171 | }, | 175 | }, |
172 | { | 176 | { |
173 | "pagePath": "pages/cart/cart", | 177 | "pagePath": "pages/cart/cart", |
174 | "iconPath": "static/tab-cart.png", | 178 | "iconPath": "static/tab-cart.png", |
175 | "selectedIconPath": "static/tab-cart-current.png", | 179 | "selectedIconPath": "static/tab-cart-current.png", |
176 | "text": "购物车" | 180 | "text": "购物车" |
177 | }, | 181 | }, |
178 | { | 182 | { |
179 | "pagePath": "pages/user/user", | 183 | "pagePath": "pages/user/user", |
180 | "iconPath": "static/tab-my.png", | 184 | "iconPath": "static/tab-my.png", |
181 | "selectedIconPath": "static/tab-my-current.png", | 185 | "selectedIconPath": "static/tab-my-current.png", |
182 | "text": "我的" | 186 | "text": "我的" |
183 | } | 187 | } |
184 | ] | 188 | ] |
185 | }, | 189 | }, |
186 | "condition": { | 190 | "condition": { |
187 | "current": 0, | 191 | "current": 0, |
188 | "list": [ | 192 | "list": [ |
189 | // { | 193 | // { |
190 | // "name": "首页", | 194 | // "name": "首页", |
191 | // "path": "pages/test/index", | 195 | // "path": "pages/test/index", |
192 | // "query": "" | 196 | // "query": "" |
193 | // }, | 197 | // }, |
194 | { | 198 | { |
195 | "name": "首页", | 199 | "name": "首页", |
196 | "path": "pages/index/index", | 200 | "path": "pages/index/index", |
197 | "query": "" | 201 | "query": "" |
198 | }, | 202 | }, |
199 | { | 203 | { |
200 | "name": "产品详情", | 204 | "name": "产品详情", |
201 | "path": "pages/details/details", | 205 | "path": "pages/details/details", |
202 | "query": "" | 206 | "query": "" |
203 | }, | 207 | }, |
204 | { | 208 | { |
205 | "name": "旧版产品详情", | 209 | "name": "旧版产品详情", |
206 | "path": "pages/frameDetail/frameDetail", | 210 | "path": "pages/frameDetail/frameDetail", |
207 | "query": "" | 211 | "query": "" |
208 | }, | 212 | }, |
209 | { | 213 | { |
210 | "name": "镜片、美瞳参数选择", | 214 | "name": "镜片、美瞳参数选择", |
211 | "path": "pages/purchaseLenses/purchaseLenses", | 215 | "path": "pages/purchaseLenses/purchaseLenses", |
212 | "query": "" | 216 | "query": "" |
213 | }, | 217 | }, |
214 | { | 218 | { |
215 | "name": "确认订单", | 219 | "name": "确认订单", |
216 | "path": "pages/confirmOrder/confirmOrder", | 220 | "path": "pages/confirmOrder/confirmOrder", |
217 | "query": "" | 221 | "query": "" |
218 | }, | 222 | }, |
219 | { | 223 | { |
220 | "name": "新增地址", | 224 | "name": "新增地址", |
221 | "path": "pages/address/addAddress", | 225 | "path": "pages/address/addAddress", |
222 | "query": "" | 226 | "query": "" |
223 | }, | 227 | }, |
224 | { | 228 | { |
225 | "name": "地址管理", | 229 | "name": "地址管理", |
226 | "path": "pages/address/addressList", | 230 | "path": "pages/address/addressList", |
227 | "query": "" | 231 | "query": "" |
228 | }, | 232 | }, |
229 | { | 233 | { |
230 | "name": "我的订单", | 234 | "name": "我的订单", |
231 | "path": "pages/myOrder/myOrder", | 235 | "path": "pages/myOrder/myOrder", |
232 | "query": "" | 236 | "query": "" |
233 | }, | 237 | }, |
234 | { | 238 | { |
235 | "name": "待付款订单详情", | 239 | "name": "待付款订单详情", |
236 | "path": "pages/myOrderPaying/myOrderPaying", | 240 | "path": "pages/myOrderPaying/myOrderPaying", |
237 | "query": "" | 241 | "query": "" |
238 | }, | 242 | }, |
239 | { | 243 | { |
240 | "name": "我的", | 244 | "name": "我的", |
241 | "path": "pages/user/user", | 245 | "path": "pages/user/user", |
242 | "query": "" | 246 | "query": "" |
243 | } | 247 | } |
244 | ] | 248 | ] |
245 | } | 249 | } |
246 | } | 250 | } |
src/pages/cart/cart.vue
1 | <template> | 1 | <template> |
2 | <view class="content"> | 2 | <view class="content"> |
3 | <block v-if="cartList.length==0"> | 3 | <block v-if="cartList.length==0"> |
4 | 4 | ||
5 | </block> | 5 | </block> |
6 | <block v-else> | 6 | <block v-else> |
7 | <view class="card"> | 7 | <view class="card"> |
8 | <view class="cardHeader"> | 8 | <view class="cardHeader"> |
9 | <view | 9 | <view |
10 | v-bind:class="pIsoPen? 'partentChecked' : 'partentCheck'" | 10 | v-bind:class="pIsoPen? 'partentChecked' : 'partentCheck'" |
11 | @click="pClick" | 11 | @click="pClick" |
12 | > | 12 | > |
13 | <span class="correct"></span> | 13 | <span class="correct"></span> |
14 | </view> | 14 | </view> |
15 | <image | 15 | <image |
16 | src="../../static/store.png" | 16 | src="../../static/store.png" |
17 | mode="aspectFill" | 17 | mode="aspectFill" |
18 | ></image> | 18 | ></image> |
19 | <text>非常戴镜</text> | 19 | <text>非常戴镜</text> |
20 | </view> | 20 | </view> |
21 | <view | 21 | <view |
22 | class="cardBody" | 22 | class="cardBody" |
23 | v-for="(item,index) in cartList" | 23 | v-for="(item,index) in cartList" |
24 | :key="index" | 24 | :key="index" |
25 | @longpress="delCart(item.cart_id,index)" | 25 | @longpress="delCart(item.cart_id,index)" |
26 | > | 26 | > |
27 | <view | 27 | <view |
28 | v-bind:class="cartList[index].isChecked? 'partentChecked':'partentCheck'" | 28 | v-bind:class="cartList[index].isChecked? 'partentChecked':'partentCheck'" |
29 | @click="childClick(cartList[index],index)" | 29 | @click="childClick(cartList[index],index)" |
30 | > | 30 | > |
31 | <span class="correct"></span> | 31 | <span class="correct"></span> |
32 | </view> | 32 | </view> |
33 | <view class="imageWrap"> | 33 | <view class="imageWrap"> |
34 | <image | 34 | <image |
35 | :src="item.img_index_url" | 35 | :src="item.img_index_url" |
36 | mode="aspectFit" | 36 | mode="aspectFit" |
37 | style="width: 188rpx;height: 168rpx;" | 37 | style="width: 188rpx;height: 168rpx;" |
38 | ></image> | 38 | ></image> |
39 | </view> | 39 | </view> |
40 | <view class="goodInfo"> | 40 | <view class="goodInfo"> |
41 | <!-- <view class="imageWrap"> | 41 | <!-- <view class="imageWrap"> |
42 | <image :src="item.img_index_url" mode="aspectFit" style="width: 188rpx;height: 168rpx;"></image> | 42 | <image :src="item.img_index_url" mode="aspectFit" style="width: 188rpx;height: 168rpx;"></image> |
43 | </view> --> | 43 | </view> --> |
44 | <view class="infoRight"> | 44 | <view class="infoRight"> |
45 | <view | 45 | <view |
46 | class="goodName" | 46 | class="goodName" |
47 | @tap="toGoods(item.pid,item.sk_id)" | 47 | @tap="toGoods(item.pid,item.sk_id)" |
48 | >{{item.p_name}}</view> | 48 | >{{item.p_name}}</view> |
49 | <view class="describ" @click="showBottom(3,item.pid,item.sk_id,item.mp_id,item.cart_id,index)"> | 49 | <view class="describ" @click="showBottom(3,item.pid,item.sk_id,item.mp_id,item.cart_id,index)"> |
50 | <view class="desL"> | 50 | <view class="desL"> |
51 | <view class="people"> | 51 | <view class="people"> |
52 | 使用人:{{item.peopleName}} | 52 | 使用人:{{item.peopleName}} |
53 | </view> | 53 | </view> |
54 | <view class="skuInfo"> | 54 | <view class="skuInfo"> |
55 | {{item.sku_name}} | 55 | {{item.sku_name}} |
56 | </view> | 56 | </view> |
57 | </view> | 57 | </view> |
58 | <view class="desR"> | 58 | <view class="desR"> |
59 | <image src="../../static/right.png" mode="aspectFit" style="width: 18rpx;height: 18rpx;"></image> | 59 | <image src="../../static/right.png" mode="aspectFit" style="width: 18rpx;height: 18rpx;"></image> |
60 | </view> | 60 | </view> |
61 | </view> | 61 | </view> |
62 | <view class="priceBox"> | 62 | <view class="priceBox"> |
63 | <view class="price">¥{{item.nowPrice*item.num}}</view> | 63 | <view class="price">¥{{item.nowPrice*item.num}}</view> |
64 | <text class="maxCount">(限购{{maxCount}}副)</text> | 64 | <text class="maxCount">(限购{{maxCount}}副)</text> |
65 | <view class="counter"> | 65 | <view class="counter"> |
66 | <view | 66 | <view |
67 | class="btn" | 67 | class="btn" |
68 | disabled="this.addDisabled" | 68 | disabled="this.addDisabled" |
69 | type="default" | 69 | type="default" |
70 | @tap="counter(index,false,item)" | 70 | @tap="counter(index,false,item)" |
71 | >-</view> | 71 | >-</view> |
72 | <text>{{item.num}}</text> | 72 | <text>{{item.num}}</text> |
73 | <view | 73 | <view |
74 | class="btn" | 74 | class="btn" |
75 | disabled="this.desDisabled" | 75 | disabled="this.desDisabled" |
76 | type="default" | 76 | type="default" |
77 | @tap="counter(index,true,item)" | 77 | @tap="counter(index,true,item)" |
78 | >+</view> | 78 | >+</view> |
79 | </view> | 79 | </view> |
80 | </view> | 80 | </view> |
81 | </view> | 81 | </view> |
82 | </view> | 82 | </view> |
83 | </view> | 83 | </view> |
84 | </view> | 84 | </view> |
85 | </block> | 85 | </block> |
86 | <view class="footer"> | 86 | <view class="footer"> |
87 | <view class="footerLeft">实付金额:<text>¥{{totalPrice}}</text></view> | 87 | <view class="footerLeft">实付金额:<text>¥{{totalPrice}}</text></view> |
88 | <view class="footerRight"> | 88 | <view class="footerRight"> |
89 | <view class="paybtn" @click="toComfirmOrder">立即结算</view> | 89 | <view class="paybtn" @click="toComfirmOrder">立即结算</view> |
90 | </view> | 90 | </view> |
91 | </view> | 91 | </view> |
92 | <BottomSheet v-if="isShowBottom" :isCart="isCart" @addCart="addCart" :sk_id="sk_id" :propMpId="mp_id" @chooseCartModi="chooseCartModi" :cart_id="cart_id" | 92 | <BottomSheet v-if="isShowBottom" :isCart="isCart" @addCart="addCart" :sk_id="sk_id" :propMpId="mp_id" @chooseCartModi="chooseCartModi" :cart_id="cart_id" |
93 | :index="cartIndex" | 93 | :index="cartIndex" |
94 | :pid="pid" :goodInfo="goodInfo" :isShowBottom="isShowBottom" @closeBottom="closeBottom"></BottomSheet> | 94 | :pid="pid" :goodInfo="goodInfo" :isShowBottom="isShowBottom" @closeBottom="closeBottom"></BottomSheet> |
95 | </view> | 95 | </view> |
96 | </template> | 96 | </template> |
97 | 97 | ||
98 | <script> | 98 | <script> |
99 | 99 | ||
100 | import store from '@/store' | 100 | import store from '@/store' |
101 | import BottomSheet from '../../components/BottomSheet/BottomSheet.vue'; | 101 | import BottomSheet from '../../components/BottomSheet/BottomSheet.vue'; |
102 | export default { | 102 | export default { |
103 | components:{ | 103 | components:{ |
104 | BottomSheet, | 104 | BottomSheet, |
105 | }, | 105 | }, |
106 | data() { | 106 | data() { |
107 | return { | 107 | return { |
108 | pid:Number, | 108 | pid:Number, |
109 | isCart:Number, | 109 | isCart:Number, |
110 | sk_id:String, | 110 | sk_id:String, |
111 | mp_id:String, | 111 | mp_id:String, |
112 | isShowBottom : false, //底部弹窗开关 | 112 | isShowBottom : false, //底部弹窗开关 |
113 | cart_id:Number, | 113 | cart_id:Number, |
114 | maxCount: 20, | 114 | maxCount: 20, |
115 | cartIndex:Number, | 115 | cartIndex:Number, |
116 | cartList:[] | 116 | cartList:[] |
117 | } | 117 | } |
118 | }, | 118 | }, |
119 | computed: { | 119 | computed: { |
120 | pIsoPen (){ | 120 | pIsoPen (){ |
121 | if (this.cartList.length > 0){ | 121 | if (this.cartList.length > 0){ |
122 | return this.cartList.find(item => !item.isChecked) ? false : true; | 122 | return this.cartList.find(item => !item.isChecked) ? false : true; |
123 | } | 123 | } |
124 | return false | 124 | return false |
125 | }, | 125 | }, |
126 | goodInfo () { | 126 | goodInfo () { |
127 | return this.$store.state.read.goodInfo | 127 | return this.$store.state.read.goodInfo |
128 | }, | 128 | }, |
129 | totalPrice() { | 129 | totalPrice() { |
130 | let totalPrice = 0 | 130 | let totalPrice = 0 |
131 | this.cartList.forEach((item)=>{ | 131 | this.cartList.forEach((item)=>{ |
132 | if(item.isChecked){ | 132 | if(item.isChecked){ |
133 | totalPrice += item.nowPrice * item.num; | 133 | totalPrice += item.nowPrice * item.num; |
134 | } | 134 | } |
135 | }) | 135 | }) |
136 | return totalPrice | 136 | return totalPrice |
137 | } | 137 | } |
138 | }, | 138 | }, |
139 | onLoad: async function() { | 139 | onShow() { |
140 | await this.$store.dispatch('cart/getCartList', { | 140 | this.cartList = this.$store.state.cart.cartList; |
141 | uid: this.$store.state.user.userInfo.uid, // 用户id | 141 | }, |
142 | onLoad: async function() { | ||
143 | await this.$store.dispatch('cart/getCartList', { | ||
144 | uid: this.$store.state.user.userInfo.uid, // 用户id | ||
142 | }) | 145 | }) |
143 | 146 | ||
144 | this.cartList = this.$store.state.cart.cartList; | 147 | this.cartList = this.$store.state.cart.cartList; |
145 | this.cartList.forEach((item)=>{ | 148 | this.cartList.forEach((item)=>{ |
146 | item.isChecked = false | 149 | item.isChecked = false |
147 | }) | 150 | }) |
148 | }, | 151 | }, |
149 | methods: { | 152 | methods: { |
150 | //全选按钮 | 153 | //全选按钮 |
151 | pClick(){ | 154 | pClick(){ |
152 | let pStatus = this.cartList.find(item => !item.isChecked) ? false : true | 155 | let pStatus = this.cartList.find(item => !item.isChecked) ? false : true |
153 | let oldList = this.cartList; | 156 | let oldList = this.cartList; |
154 | oldList.forEach((item, index)=>{ | 157 | oldList.forEach((item, index)=>{ |
155 | item.isChecked = !pStatus | 158 | item.isChecked = !pStatus |
156 | this.cartList.splice(index,1, item) | 159 | this.cartList.splice(index,1, item) |
157 | }) | 160 | }) |
158 | }, | 161 | }, |
159 | //单选按钮 | 162 | //单选按钮 |
160 | childClick(type,index){ | 163 | childClick(type,index){ |
161 | this.cartList[index].isChecked = !this.cartList[index].isChecked | 164 | this.cartList[index].isChecked = !this.cartList[index].isChecked |
162 | //vue没有办法监听数组内部值的变化,所以需要通过这个方法去触发 | 165 | //vue没有办法监听数组内部值的变化,所以需要通过这个方法去触发 |
163 | this.cartList.splice(index,1, this.cartList[index]) | 166 | this.cartList.splice(index,1, this.cartList[index]) |
164 | }, | 167 | }, |
165 | //修改购物车 | 168 | //修改购物车 |
166 | chooseCartModi(mp_id,sk_id,price,pid,num,cart_id,index){ | 169 | chooseCartModi(mp_id,sk_id,price,pid,num,cart_id,index){ |
167 | // console.log('modi',mp_id,sk_id,price,pid,num,cart_id) | 170 | // console.log('modi',mp_id,sk_id,price,pid,num,cart_id) |
168 | store.dispatch('cart/modiCart', { | 171 | store.dispatch('cart/modiCart', { |
169 | uid: this.$store.state.user.userInfo.uid, | 172 | uid: this.$store.state.user.userInfo.uid, |
170 | openid: this.$store.state.user.userInfo.openid, | 173 | openid: this.$store.state.user.userInfo.openid, |
171 | mp_id: mp_id, | 174 | mp_id: mp_id, |
172 | sk_id: sk_id, | 175 | sk_id: sk_id, |
173 | price: price, | 176 | price: price, |
174 | pid: pid, | 177 | pid: pid, |
175 | num: num, | 178 | num: num, |
176 | cart_id: cart_id, | 179 | cart_id: cart_id, |
177 | args: { | 180 | args: { |
178 | index: index, | 181 | index: index, |
179 | }, | 182 | }, |
180 | }) | 183 | }) |
181 | store.dispatch('cart/getCartList', { | 184 | store.dispatch('cart/getCartList', { |
182 | uid: this.$store.state.user.userInfo.uid, // 用户id | 185 | uid: this.$store.state.user.userInfo.uid, // 用户id |
183 | }) | 186 | }) |
184 | 187 | ||
185 | this.$forceUpdate() | 188 | this.$forceUpdate() |
186 | // console.log('21212121212',this.cartList) | 189 | // console.log('21212121212',this.cartList) |
187 | }, | 190 | }, |
188 | //底部弹窗开关 | 191 | //底部弹窗开关 |
189 | showBottom(isCart,pid,skId,mp_id,cart_id,index){ | 192 | showBottom(isCart,pid,skId,mp_id,cart_id,index){ |
190 | store.dispatch('read/fetch', { | 193 | store.dispatch('read/fetch', { |
191 | pid, | 194 | pid, |
192 | sk_id: skId, | 195 | sk_id: skId, |
193 | }).then(()=>{ | 196 | }).then(()=>{ |
194 | this.cartIndex = index | 197 | this.cartIndex = index |
195 | this.sk_id = skId; | 198 | this.sk_id = skId; |
196 | this.pid = pid; | 199 | this.pid = pid; |
197 | this.mp_id = mp_id; | 200 | this.mp_id = mp_id; |
198 | this.isCart = isCart; | 201 | this.isCart = isCart; |
199 | this.cart_id = cart_id; | 202 | this.cart_id = cart_id; |
200 | this.isShowBottom = true; | 203 | this.isShowBottom = true; |
201 | }) | 204 | }) |
202 | }, | 205 | }, |
203 | closeBottom(){ | 206 | closeBottom(){ |
204 | this.isShowBottom = false; | 207 | this.isShowBottom = false; |
205 | }, | 208 | }, |
206 | toGoods(id, sk_id) { | 209 | toGoods(id, sk_id) { |
207 | uni.navigateTo({ | 210 | uni.navigateTo({ |
208 | url: '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + sk_id, | 211 | url: '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + sk_id, |
209 | success: res => {}, | 212 | success: res => {}, |
210 | fail: () => {}, | 213 | fail: () => {}, |
211 | complete: () => {}, | 214 | complete: () => {}, |
212 | }) | 215 | }) |
213 | }, | 216 | }, |
214 | toComfirmOrder(){ | 217 | toComfirmOrder(){ |
215 | uni.navigateTo({ | 218 | this.$store.state.cart.checkedCartLst = this.cartList.filter(item => item.isChecked) |
216 | url:`../confirmOrder/confirmOrder`, | 219 | uni.navigateTo({ |
217 | }) | 220 | url:`../confirmOrder/confirmOrder?isCart=true`, |
218 | }, | 221 | }) |
219 | counter(index, isadd, item) { | 222 | }, |
220 | // console.log('item=====>', item) | 223 | counter(index, isadd, item) { |
221 | // console.log('num=====>', item.num) | 224 | // console.log('item=====>', item) |
222 | const nums = parseInt(item.num) | 225 | // console.log('num=====>', item.num) |
223 | if (isadd) { | 226 | const nums = parseInt(item.num) |
224 | if (nums >= this.maxCount) { | 227 | if (isadd) { |
225 | this.addDisabled = true | 228 | if (nums >= this.maxCount) { |
226 | } else { | 229 | this.addDisabled = true |
227 | this.addDisabled = true | 230 | } else { |
228 | store.dispatch('cart/modiCart', { | 231 | this.addDisabled = true |
229 | uid: this.$store.state.user.userInfo.uid, | 232 | store.dispatch('cart/modiCart', { |
230 | openid: this.$store.state.user.userInfo.openid, | 233 | uid: this.$store.state.user.userInfo.uid, |
231 | mp_id: item.mp_id, | 234 | openid: this.$store.state.user.userInfo.openid, |
232 | sk_id: item.sk_id, | 235 | mp_id: item.mp_id, |
233 | price: item.nowPrice, | 236 | sk_id: item.sk_id, |
234 | pid: item.pid, | 237 | price: item.nowPrice, |
235 | num: nums + 1, | 238 | pid: item.pid, |
236 | cart_id: item.cart_id, | 239 | num: nums + 1, |
237 | args: { | 240 | cart_id: item.cart_id, |
238 | index: index, | 241 | args: { |
239 | isadd: isadd, | 242 | index: index, |
240 | }, | 243 | isadd: isadd, |
241 | }) | 244 | }, |
242 | this.addDisabled = false | 245 | }) |
243 | } | 246 | this.addDisabled = false |
244 | } else { | 247 | } |
245 | if (nums <= 1) { | 248 | } else { |
246 | this.desDisabled = true | 249 | if (nums <= 1) { |
247 | } else { | 250 | this.desDisabled = true |
248 | this.desDisabled = false | 251 | } else { |
249 | 252 | this.desDisabled = false | |
250 | store.dispatch('cart/modiCart', { | 253 | |
251 | uid: this.$store.state.user.userInfo.uid, | 254 | store.dispatch('cart/modiCart', { |
252 | openid: this.$store.state.user.userInfo.openid, | 255 | uid: this.$store.state.user.userInfo.uid, |
253 | mp_id: item.mp_id, | 256 | openid: this.$store.state.user.userInfo.openid, |
254 | sk_id: item.sk_id, | 257 | mp_id: item.mp_id, |
255 | price: item.nowPrice, | 258 | sk_id: item.sk_id, |
256 | pid: item.pid, | 259 | price: item.nowPrice, |
257 | num: nums - 1, | 260 | pid: item.pid, |
258 | cart_id: item.cart_id, | 261 | num: nums - 1, |
259 | args: { | 262 | cart_id: item.cart_id, |
260 | index: index, | 263 | args: { |
261 | isadd: isadd, | 264 | index: index, |
262 | }, | 265 | isadd: isadd, |
263 | }) | 266 | }, |
264 | this.desDisabled = true | 267 | }) |
265 | } | 268 | this.desDisabled = true |
266 | } | 269 | } |
267 | 270 | } | |
268 | }, | 271 | |
269 | delCart(cart_id, index) { | 272 | }, |
270 | cart_id = parseInt(cart_id) | 273 | delCart(cart_id, index) { |
271 | uni.showModal({ | 274 | cart_id = parseInt(cart_id) |
272 | title: '是否删除该商品', | 275 | uni.showModal({ |
273 | success: function (res) { | 276 | title: '是否删除该商品', |
274 | if (res.confirm) { | 277 | success: function (res) { |
275 | 278 | if (res.confirm) { | |
276 | store.dispatch('cart/delCart', { | 279 | store.dispatch('cart/delCart', { |
277 | uid: this.$store.state.user.userInfo.uid, | 280 | uid: this.$store.state.user.userInfo.uid, |
278 | openid: this.$store.state.user.userInfo.openid, | 281 | openid: this.$store.state.user.userInfo.openid, |
279 | cart_id: cart_id, // 要修改的购物车id | 282 | cart_id: cart_id, // 要修改的购物车id |
280 | arg: index, // 由于action 传参是能接收两参数,因此将index放入对象 | 283 | arg: index, // 由于action 传参是能接收两参数,因此将index放入对象 |
281 | }) | 284 | }) |
282 | } | 285 | } |
283 | }.bind(this), | 286 | }.bind(this), |
284 | }) | 287 | }) |
285 | }, | 288 | // this.cartList.splice(index,1) |
286 | }, | 289 | }, |
287 | } | 290 | }, |
288 | </script> | 291 | } |
289 | 292 | </script> | |
290 | <style lang="scss"> | 293 | |
291 | .content { | 294 | <style lang="scss"> |
292 | min-height: 100vh; | 295 | .content { |
293 | background-color: #f2f2f2; | 296 | min-height: 100vh; |
294 | display: flex; | 297 | background-color: #f2f2f2; |
295 | flex-direction: column; | 298 | display: flex; |
296 | align-items: center; | 299 | flex-direction: column; |
297 | justify-content: space-between; | 300 | align-items: center; |
298 | padding: 20rpx 40rpx; | 301 | justify-content: space-between; |
299 | box-sizing: border-box; | 302 | padding: 20rpx 40rpx; |
300 | 303 | box-sizing: border-box; | |
301 | .partentCheck { | 304 | |
302 | width: 16px; | 305 | .partentCheck { |
303 | height: 16px; | 306 | width: 16px; |
304 | border-radius: 22px; | 307 | height: 16px; |
305 | border: 1px solid #cfcfcf; | 308 | border-radius: 22px; |
306 | background-color: #ffffff; | 309 | border: 1px solid #cfcfcf; |
307 | margin: 24rpx 12rpx 24rpx 24rpx; | 310 | background-color: #ffffff; |
308 | } | 311 | margin: 24rpx 12rpx 24rpx 24rpx; |
309 | .partentChecked { | 312 | } |
310 | width: 18px; | 313 | .partentChecked { |
311 | height: 18px; | 314 | width: 18px; |
312 | border-radius: 22px; | 315 | height: 18px; |
313 | background-color: #ff6b4a; | 316 | border-radius: 22px; |
314 | margin: 24rpx 12rpx 24rpx 24rpx; | 317 | background-color: #ff6b4a; |
315 | .correct { | 318 | margin: 24rpx 12rpx 24rpx 24rpx; |
316 | display: inline-block; | 319 | .correct { |
317 | position: relative; | 320 | display: inline-block; |
318 | width: 10rpx; | 321 | position: relative; |
319 | height: 2rpx; | 322 | width: 10rpx; |
320 | background: #ffffff; | 323 | height: 2rpx; |
321 | line-height: 0; | 324 | background: #ffffff; |
322 | font-size: 0; | 325 | line-height: 0; |
323 | position: relative; | 326 | font-size: 0; |
324 | top: -7px; | 327 | position: relative; |
325 | left: 4px; | 328 | top: -7px; |
326 | -webkit-transform: rotate(45deg); | 329 | left: 4px; |
327 | } | 330 | -webkit-transform: rotate(45deg); |
328 | .correct:after { | 331 | } |
329 | content: "/"; | 332 | .correct:after { |
330 | display: block; | 333 | content: "/"; |
331 | width: 16rpx; | 334 | display: block; |
332 | height: 2rpx; | 335 | width: 16rpx; |
333 | background: #ffffff; | 336 | height: 2rpx; |
334 | -webkit-transform: rotate(-90deg) translateY(50%) translateX(50%); | 337 | background: #ffffff; |
335 | } | 338 | -webkit-transform: rotate(-90deg) translateY(50%) translateX(50%); |
336 | } | 339 | } |
337 | 340 | } | |
338 | .card { | 341 | |
339 | background-color: #ffffff; | 342 | .card { |
340 | border-radius: 16rpx; | 343 | background-color: #ffffff; |
341 | box-sizing: border-box; | 344 | border-radius: 16rpx; |
342 | padding: 36rpx 36rpx 36rpx 18rpx; | 345 | box-sizing: border-box; |
343 | display: flex; | 346 | padding: 36rpx 36rpx 36rpx 18rpx; |
344 | flex-direction: column; | 347 | display: flex; |
345 | align-items: center; | 348 | flex-direction: column; |
346 | justify-content: space-between; | 349 | align-items: center; |
347 | margin-bottom: 180rpx; | 350 | justify-content: space-between; |
348 | .cardHeader { | 351 | margin-bottom: 180rpx; |
349 | width: 100%; | 352 | .cardHeader { |
350 | height: 36rpx; | 353 | width: 100%; |
351 | display: flex; | 354 | height: 36rpx; |
352 | align-items: center; | 355 | display: flex; |
353 | justify-content: flex-start; | 356 | align-items: center; |
354 | margin-bottom: 20rpx; | 357 | justify-content: flex-start; |
355 | image { | 358 | margin-bottom: 20rpx; |
356 | height: 32rpx; | 359 | image { |
357 | width: 32rpx; | 360 | height: 32rpx; |
358 | padding-left: 6px; | 361 | width: 32rpx; |
359 | padding-right: 10px; | 362 | padding-left: 6px; |
360 | } | 363 | padding-right: 10px; |
361 | text { | 364 | } |
362 | // font-family: PingFangSC-Regular; | 365 | text { |
363 | font-size: 14px; | 366 | // font-family: PingFangSC-Regular; |
364 | color: #333333; | 367 | font-size: 14px; |
365 | letter-spacing: -0.26px; | 368 | color: #333333; |
366 | } | 369 | letter-spacing: -0.26px; |
367 | } | 370 | } |
368 | .cardBody { | 371 | } |
369 | width: 100%; | 372 | .cardBody { |
370 | min-height: 300rpx; | 373 | width: 100%; |
371 | display: flex; | 374 | min-height: 300rpx; |
372 | align-items: center; | 375 | display: flex; |
373 | justify-content: space-between; | 376 | align-items: center; |
374 | .goodInfo { | 377 | justify-content: space-between; |
375 | width: 390rpx; | 378 | .goodInfo { |
376 | display: flex; | 379 | width: 390rpx; |
377 | flex-direction: row; | 380 | display: flex; |
378 | justify-content: flex-start; | 381 | flex-direction: row; |
379 | padding-left: 6px; | 382 | justify-content: flex-start; |
380 | 383 | padding-left: 6px; | |
381 | .imageWrap { | 384 | |
382 | height: 188rpx; | 385 | .imageWrap { |
383 | width: 188rpx; | 386 | height: 188rpx; |
384 | margin-right: 28rpx; | 387 | width: 188rpx; |
385 | 388 | margin-right: 28rpx; | |
386 | image { | 389 | |
387 | border-radius: 4px; | 390 | image { |
388 | height: 188rpx; | 391 | border-radius: 4px; |
389 | width: 188rpx; | 392 | height: 188rpx; |
390 | } | 393 | width: 188rpx; |
391 | } | 394 | } |
392 | .infoRight { | 395 | } |
393 | display: flex; | 396 | .infoRight { |
394 | flex-direction: column; | 397 | display: flex; |
395 | align-items: flex-start; | 398 | flex-direction: column; |
396 | justify-content: space-between; | 399 | align-items: flex-start; |
397 | min-height: 240rpx; | 400 | justify-content: space-between; |
398 | width: 100%; | 401 | min-height: 240rpx; |
399 | .goodName { | 402 | width: 100%; |
400 | display: -webkit-box; | 403 | .goodName { |
401 | -webkit-box-orient: vertical; | 404 | display: -webkit-box; |
402 | -webkit-line-clamp: 2; | 405 | -webkit-box-orient: vertical; |
403 | text-align: justify; | 406 | -webkit-line-clamp: 2; |
404 | overflow: hidden; | 407 | text-align: justify; |
405 | font-size: 28rpx; | 408 | overflow: hidden; |
406 | color: #333333; | 409 | font-size: 28rpx; |
407 | } | 410 | color: #333333; |
408 | .describ { | 411 | } |
409 | width: 100%; | 412 | .describ { |
410 | min-height: 80rpx; | 413 | width: 100%; |
411 | background: #F9F9F9; | 414 | min-height: 80rpx; |
412 | border-radius: 2px; | 415 | background: #F9F9F9; |
413 | box-sizing: border-box; | 416 | border-radius: 2px; |
414 | padding: 10rpx; | 417 | box-sizing: border-box; |
415 | font-size: 20rpx; | 418 | padding: 10rpx; |
416 | letter-spacing: -0.23px; | 419 | font-size: 20rpx; |
417 | color: #999999; | 420 | letter-spacing: -0.23px; |
418 | display: flex; | 421 | color: #999999; |
419 | justify-content: space-between; | 422 | display: flex; |
420 | align-items: center; | 423 | justify-content: space-between; |
421 | .desL{ | 424 | align-items: center; |
422 | 425 | .desL{ | |
423 | view{ | 426 | |
424 | margin: 10rpx 0 10rpx 0 ; | 427 | view{ |
425 | } | 428 | margin: 10rpx 0 10rpx 0 ; |
426 | } | 429 | } |
427 | 430 | } | |
428 | } | 431 | |
429 | .priceBox { | 432 | } |
430 | display: flex; | 433 | .priceBox { |
431 | justify-content: space-between; | 434 | display: flex; |
432 | align-items: center; | 435 | justify-content: space-between; |
433 | // margin-top: 26px; | 436 | align-items: center; |
434 | width: 100%; | 437 | // margin-top: 26px; |
435 | font-size: 14px; | 438 | width: 100%; |
436 | color: #999999; | 439 | font-size: 14px; |
437 | .maxCount { | 440 | color: #999999; |
438 | color: #999999; | 441 | .maxCount { |
439 | font-size: 20rpx; | 442 | color: #999999; |
440 | } | 443 | font-size: 20rpx; |
441 | .price { | 444 | } |
442 | color: #ff6b4a; | 445 | .price { |
443 | font-size: 28rpx; | 446 | color: #ff6b4a; |
444 | } | 447 | font-size: 28rpx; |
445 | .counter { | 448 | } |
446 | display: flex; | 449 | .counter { |
447 | flex-direction: row; | 450 | display: flex; |
448 | justify-content: space-between; | 451 | flex-direction: row; |
449 | align-items: center; | 452 | justify-content: space-between; |
450 | font-size: 28rpx; | 453 | align-items: center; |
451 | color: #333333; | 454 | font-size: 28rpx; |
452 | width: 122rpx; | 455 | color: #333333; |
453 | .btn { | 456 | width: 122rpx; |
454 | display: flex; | 457 | .btn { |
455 | justify-content: center; | 458 | display: flex; |
456 | line-height: 32rpx; | 459 | justify-content: center; |
457 | height: 32rpx; | 460 | line-height: 32rpx; |
458 | width: 32rpx; | 461 | height: 32rpx; |
459 | background-color: #f2f2f2; | 462 | width: 32rpx; |
460 | color: #cfcfcf; | 463 | background-color: #f2f2f2; |
461 | } | 464 | color: #cfcfcf; |
462 | } | 465 | } |
463 | } | 466 | } |
464 | } | 467 | } |
465 | } | 468 | } |
466 | } | 469 | } |
467 | } | 470 | } |
468 | .footer { | 471 | } |
469 | position: fixed; | 472 | .footer { |
470 | left: 0; | 473 | position: fixed; |
471 | bottom: 0px; | 474 | left: 0; |
472 | height: 112rpx; | 475 | bottom: 0px; |
473 | width: 100%; | 476 | height: 112rpx; |
474 | background-color: #ffffff; | 477 | width: 100%; |
475 | font-size: 16px; | 478 | background-color: #ffffff; |
476 | display: flex; | 479 | font-size: 16px; |
477 | justify-content: space-between; | 480 | display: flex; |
478 | align-items: center; | 481 | justify-content: space-between; |
479 | .footerLeft { | 482 | align-items: center; |
480 | display: flex; | 483 | .footerLeft { |
481 | justify-content: center; | 484 | display: flex; |
482 | align-items: center; | 485 | justify-content: center; |
483 | width: 50%; | 486 | align-items: center; |
484 | color: #333333; | 487 | width: 50%; |
485 | text { | 488 | color: #333333; |
486 | color: #ff6b4a; | 489 | text { |
487 | } | 490 | color: #ff6b4a; |
488 | } | 491 | } |
489 | .footerRight { | 492 | } |
490 | display: flex; | 493 | .footerRight { |
491 | justify-content: flex-end; | 494 | display: flex; |
492 | align-items: center; | 495 | justify-content: flex-end; |
493 | width: 50%; | 496 | align-items: center; |
494 | margin-right: 26rpx; | 497 | width: 50%; |
495 | .paybtn { | 498 | margin-right: 26rpx; |
496 | display: flex; | 499 | .paybtn { |
497 | justify-content: center; | 500 | display: flex; |
498 | align-items: center; | 501 | justify-content: center; |
499 | background: #ff6b4a; | 502 | align-items: center; |
500 | border-radius: 20px; | 503 | background: #ff6b4a; |
501 | border-radius: 20px; | 504 | border-radius: 20px; |
502 | color: #ffffff; | 505 | border-radius: 20px; |
503 | width: 204rpx; | 506 | color: #ffffff; |
504 | height: 80rpx; | 507 | width: 204rpx; |
505 | } | 508 | height: 80rpx; |
506 | } | 509 | } |
507 | } | 510 | } |
508 | } | 511 | } |
509 | /* 隐藏滚动条 */ | 512 | } |
510 | ::-webkit-scrollbar { | 513 | /* 隐藏滚动条 */ |
511 | width: 0; | 514 | ::-webkit-scrollbar { |
512 | height: 0; | 515 | width: 0; |
513 | color: transparent; | 516 | height: 0; |
514 | } | 517 | color: transparent; |
515 | </style> | 518 | } |
519 | </style> |
src/pages/confirmOrder/confirmOrder.vue
1 | <template> | 1 | <template> |
2 | <view class="wrap"> | 2 | <view class="wrap"> |
3 | <view></view> | 3 | <view></view> |
4 | <view | 4 | <view |
5 | class="addAddress" | 5 | class="addAddress" |
6 | @tap="toaddAddress" | 6 | @tap="toaddAddress" |
7 | v-if="this.showAddress" | 7 | v-if="this.showAddress" |
8 | > | 8 | > |
9 | <view class="addIcon"> | 9 | <view class="addIcon"> |
10 | <image | 10 | <image |
11 | src="../../static/add.png" | 11 | src="../../static/add.png" |
12 | mode="aspectFill" | 12 | mode="aspectFill" |
13 | ></image> | 13 | ></image> |
14 | </view> | 14 | </view> |
15 | <view class="addressText">{{addAddress}}</view> | 15 | <view class="addressText">{{addAddress}}</view> |
16 | <image | 16 | <image |
17 | src="../../static/right.png" | 17 | src="../../static/right.png" |
18 | mode="aspectFill" | 18 | mode="aspectFill" |
19 | ></image> | 19 | ></image> |
20 | </view> | 20 | </view> |
21 | <view | 21 | <view |
22 | v-else | 22 | v-else |
23 | @tap="toaddAddress" | 23 | @tap="toaddAddress" |
24 | class="list order-user" | 24 | class="list order-user" |
25 | > | 25 | > |
26 | <view class="order-user-head"> | 26 | <view class="order-user-head"> |
27 | <view class="name"> | 27 | <view class="name"> |
28 | <view | 28 | <view |
29 | v-if="addressInfo.default === '1'" | 29 | v-if="addressInfo.default === '1'" |
30 | class="default" | 30 | class="default" |
31 | ><text>默认</text></view>{{addressInfo.name}} | 31 | ><text>默认</text></view>{{addressInfo.name}} |
32 | </view> | 32 | </view> |
33 | <text class="mobile">{{addressInfo.mobile}}</text> | 33 | <text class="mobile">{{addressInfo.mobile}}</text> |
34 | </view> | 34 | </view> |
35 | <view class="order-user-body"> | 35 | <view class="order-user-body"> |
36 | <image src="../../static/myorder-paying-location.png"></image> | 36 | <image src="../../static/myorder-paying-location.png"></image> |
37 | <text class="address">{{addressInfo.address}}\n{{addressInfo.add_detail}}</text> | 37 | <text class="address">{{addressInfo.address}}\n{{addressInfo.add_detail}}</text> |
38 | </view> | 38 | </view> |
39 | <image | 39 | <image |
40 | class="arrow" | 40 | class="arrow" |
41 | src="../../static/right.png" | 41 | src="../../static/right.png" |
42 | mode="aspectFill" | 42 | mode="aspectFill" |
43 | ></image> | 43 | ></image> |
44 | </view> | 44 | </view> |
45 | <view class="content"> | 45 | <view class="content"> |
46 | <view class="orderInfo"> | 46 | <view class="orderInfo"> |
47 | <view class="title"> | 47 | <view class="title"> |
48 | <image | 48 | <image |
49 | src="../../static/store.png" | 49 | src="../../static/store.png" |
50 | mode="aspectFill" | 50 | mode="aspectFill" |
51 | style="width: 40rpx;height: 40rpx;" | 51 | style="width: 40rpx;height: 40rpx;" |
52 | ></image> | 52 | ></image> |
53 | <text>非常戴镜</text> | 53 | <text>非常戴镜</text> |
54 | </view> | 54 | </view> |
55 | <view class="infoBox"> | 55 | |
56 | <view class="infoBox" v-if="isCart == 'true'" v-for="(item, index) in checkedCartLst" :key="index"> | ||
57 | <view class="infoTop"> | ||
58 | <image | ||
59 | :src="item.img_index_url" | ||
60 | mode="aspectFill" | ||
61 | ></image> | ||
62 | <view class="infoRight"> | ||
63 | <text class="goodName">{{item.p_name}}</text> | ||
64 | <text class="remarks">支持7天无理由退货 顺丰发货</text> | ||
65 | <view class="priceBox"> | ||
66 | <view class="price">¥{{Number(item.nowPrice) * item.num}}<text class="originCost"> | ||
67 | ¥{{item.oldPrice*item.num}} | ||
68 | </text></view> | ||
69 | <view class="counter"> | ||
70 | <view | ||
71 | class="btn" | ||
72 | disabled="this.disabled" | ||
73 | type="default" | ||
74 | @click="counter(false,index)" | ||
75 | >-</view> | ||
76 | <text>{{checkedCartLst[index].num}}</text> | ||
77 | <view | ||
78 | class="btn" | ||
79 | type="default" | ||
80 | @click="counter(true,index)" | ||
81 | >+</view> | ||
82 | </view> | ||
83 | </view> | ||
84 | </view> | ||
85 | </view> | ||
86 | <view class="infoBottom"> | ||
87 | <view class="norm">规格 <text> | ||
88 | <!-- 长度超出变省略号未做 --> | ||
89 | <block >{{item.sku_name}}<block v-if="index !== current.length -1">/</block> | ||
90 | </block> | ||
91 | </text></view> | ||
92 | <view class="shippingMethod">使用人 <text> | ||
93 | {{item.peopleName}} | ||
94 | </text></view> | ||
95 | <view class="shippingMethod">配送方式 <text>快递</text></view> | ||
96 | <view class="message">买家留言 | ||
97 | <input | ||
98 | type="text" | ||
99 | :value="note" | ||
100 | placeholder="建议提前协商(50字以内)" | ||
101 | /> | ||
102 | </view> | ||
103 | </view> | ||
104 | </view> | ||
105 | |||
106 | <view class="infoBox" v-if="isCart !== 'true'"> | ||
56 | <view class="infoTop"> | 107 | <view class="infoTop"> |
57 | <image | 108 | <image |
58 | :src="goodInfo.img_index_url" | 109 | :src="buyItem.pic" |
59 | mode="aspectFill" | 110 | mode="aspectFill" |
60 | ></image> | 111 | ></image> |
61 | <view class="infoRight"> | 112 | <view class="infoRight"> |
62 | <text class="goodName">{{goodInfo.p_name}}</text> | 113 | <text class="goodName">{{goodInfo.p_name}}</text> |
63 | <text class="remarks">支持7天无理由退货 顺丰发货</text> | 114 | <text class="remarks">支持7天无理由退货 顺丰发货</text> |
64 | <view class="priceBox"> | 115 | <view class="priceBox"> |
65 | <view class="price">¥{{Number(skuInfo.real_price) * count}}<text class="originCost"> | 116 | <view class="price">¥{{buyItem.real_price * count}}<text class="originCost"> |
66 | ¥{{parseInt(skuInfo.real_price * (1 + Number(skuInfo.discount) / 100))}} | 117 | ¥{{buyItem.out_price * count}} |
67 | </text></view> | 118 | </text></view> |
68 | <view class="counter"> | 119 | <view class="counter"> |
69 | <view | 120 | <view |
70 | class="btn" | 121 | class="btn" |
71 | disabled="this.disabled" | 122 | disabled="this.disabled" |
72 | type="default" | 123 | type="default" |
73 | @click="counter(false)" | 124 | @click="counter(false)" |
74 | >-</view> | 125 | >-</view> |
75 | <text>{{count}}</text> | 126 | <text>{{count}}</text> |
76 | <view | 127 | <view |
77 | class="btn" | 128 | class="btn" |
78 | type="default" | 129 | type="default" |
79 | @click="counter(true)" | 130 | @click="counter(true)" |
80 | >+</view> | 131 | >+</view> |
81 | </view> | 132 | </view> |
82 | </view> | 133 | </view> |
83 | </view> | 134 | </view> |
84 | </view> | 135 | </view> |
85 | <view class="infoBottom"> | 136 | <view class="infoBottom"> |
86 | <view class="norm">规格 <text> | 137 | <view class="norm">规格 <text> |
87 | <!-- 长度超出变省略号未做 --> | 138 | <!-- 长度超出变省略号未做 --> |
88 | <block | 139 | <block |
89 | v-for="(item, index) in current" | 140 | v-for="(item, index) in current" |
90 | :key="index" | 141 | :key="index" |
91 | >{{attrList[index].attr[item].name}}<block v-if="index !== current.length -1">/</block> | 142 | >{{attrList[index].attr[item].name}}<block v-if="index !== current.length -1">/</block> |
92 | </block> | 143 | </block> |
93 | </text></view> | 144 | </text></view> |
94 | <view class="shippingMethod">使用人 <text> | 145 | <view class="shippingMethod">使用人 <text> |
95 | {{name}} | 146 | {{name}} |
96 | </text></view> | 147 | </text></view> |
97 | <view class="shippingMethod">配送方式 <text>快递</text></view> | 148 | <view class="shippingMethod">配送方式 <text>快递</text></view> |
98 | <view class="message">买家留言 | 149 | <view class="message">买家留言 |
99 | <input | 150 | <input |
100 | type="text" | 151 | type="text" |
101 | :value="note" | 152 | :value="note" |
102 | placeholder="建议提前协商(50字以内)" | 153 | placeholder="建议提前协商(50字以内)" |
103 | /> | 154 | /> |
104 | </view> | 155 | </view> |
105 | </view> | 156 | </view> |
106 | </view> | 157 | </view> |
107 | </view> | 158 | </view> |
108 | <view class="payWay"> | 159 | <view class="payWay"> |
109 | <view class="item"> | 160 | <view class="item"> |
110 | <text>支付方式</text> | 161 | <text>支付方式</text> |
111 | <view class="itemRight"> | 162 | <view class="itemRight"> |
112 | <view class="rightText"> | 163 | <view class="rightText"> |
113 | <view class="choosePayWay"> | 164 | <view class="choosePayWay"> |
114 | <image | 165 | <image |
115 | src="../../static/chat_logo.png" | 166 | src="../../static/chat_logo.png" |
116 | mode="aspectFill" | 167 | mode="aspectFill" |
117 | ></image> | 168 | ></image> |
118 | <text>微信支付</text> | 169 | <text>微信支付</text> |
119 | </view> | 170 | </view> |
120 | <!-- <view class="randomSubstraction">最高随机立减¥99</view> --> | 171 | <!-- <view class="randomSubstraction">最高随机立减¥99</view> --> |
121 | </view> | 172 | </view> |
122 | <!-- <image | 173 | <!-- <image |
123 | src="../../static/right.png" | 174 | src="../../static/right.png" |
124 | mode="aspectFill" | 175 | mode="aspectFill" |
125 | ></image> --> | 176 | ></image> --> |
126 | </view> | 177 | </view> |
127 | </view> | 178 | </view> |
128 | <!-- <view class="item"> | 179 | <!-- <view class="item"> |
129 | <text>优惠券</text> | 180 | <text>优惠券</text> |
130 | <view class="itemRight"> | 181 | <view class="itemRight"> |
131 | <view class="rightText"> | 182 | <view class="rightText"> |
132 | <view class="chooseOffers"> | 183 | <view class="chooseOffers"> |
133 | <text>-¥70.00</text> | 184 | <text>-¥70.00</text> |
134 | </view> | 185 | </view> |
135 | <view class="preferentialWay">最大优惠</view> | 186 | <view class="preferentialWay">最大优惠</view> |
136 | </view> | 187 | </view> |
137 | <image | 188 | <image |
138 | src="../../static/right.png" | 189 | src="../../static/right.png" |
139 | mode="aspectFill" | 190 | mode="aspectFill" |
140 | ></image> | 191 | ></image> |
141 | </view> | 192 | </view> |
142 | </view> --> | 193 | </view> --> |
143 | <view class="item"> | 194 | <view class="item"> |
144 | <text>运费</text> | 195 | <text>运费</text> |
145 | <view class="itemRight"> | 196 | <view class="itemRight"> |
146 | <view class="freight">免运费</view> | 197 | <view class="freight">免运费</view> |
147 | </view> | 198 | </view> |
148 | </view> | 199 | </view> |
149 | <view class="item"> | 200 | <view class="item"> |
150 | <text>合计</text> | 201 | <text>合计</text> |
151 | <view class="itemRight"> | 202 | <view class="itemRight"> |
152 | <view class="total">¥{{Number(skuInfo.real_price) * count}}</view> | 203 | <view class="total">¥{{totalPrice}}</view> |
204 | <!-- <view class="total" v-else>¥{{Number(skuInfo.real_price) * count}}</view> --> | ||
153 | </view> | 205 | </view> |
154 | </view> | 206 | </view> |
155 | </view> | 207 | </view> |
156 | <!-- | 208 | <!-- |
157 | <view class="checkBox"> | 209 | <view class="checkBox"> |
158 | <checkbox-group> | 210 | <checkbox-group> |
159 | <label> | 211 | <label> |
160 | <checkbox color="#FF6B4A" value="isAnonymous" checked="true" />匿名购买 | 212 | <checkbox color="#FF6B4A" value="isAnonymous" checked="true" />匿名购买 |
161 | </label> | 213 | </label> |
162 | </checkbox-group> | 214 | </checkbox-group> |
163 | </view> --> | 215 | </view> --> |
164 | </view> | 216 | </view> |
165 | <view class="last_zhanwei"></view> | 217 | <view class="last_zhanwei"></view> |
166 | <view class="footer"> | 218 | <view class="footer"> |
167 | <view class="footerLeft">实付金额:<text>¥{{Number(skuInfo.real_price) * count}}</text></view> | 219 | <view class="footerLeft">实付金额: |
220 | <text >¥{{totalPrice}}</text> | ||
221 | <!-- <text v-else>¥{{Number(skuInfo.real_price) * count}}</text> --> | ||
222 | </view> | ||
168 | <view class="footerRight"> | 223 | <view class="footerRight"> |
169 | <view | 224 | <view |
170 | class="paybtn" | 225 | class="paybtn" |
171 | @tap="orderBuild" | 226 | @tap="orderBuild" |
172 | >立即支付</view> | 227 | >立即支付</view> |
173 | </view> | 228 | </view> |
174 | </view> | 229 | </view> |
175 | </view> | 230 | </view> |
176 | </template> | 231 | </template> |
177 | 232 | ||
178 | <script> | 233 | <script> |
179 | import store from '@/store' | 234 | import store from '@/store' |
180 | import MD5Util from '../../utils/md5' | 235 | import MD5Util from '../../utils/md5' |
181 | 236 | ||
182 | export default { | 237 | export default { |
183 | data() { | 238 | data() { |
184 | return { | 239 | return { |
185 | name:String, | 240 | name:String, |
186 | addAddress: '添加收货地址', | 241 | addAddress: '添加收货地址', |
187 | count: 1, | 242 | count: 1, |
188 | pid: 0, | 243 | pid: 0, |
189 | disabled: false, | 244 | disabled: false, |
190 | freight: 0.0, | 245 | freight: 0.0, |
191 | showAddress: false, | 246 | showAddress: false, |
192 | note: '', | 247 | note: '', |
193 | addressInfo: { | 248 | addressInfo: { |
194 | address: '', | 249 | address: '', |
195 | }, | 250 | }, |
251 | isCart:Boolean, | ||
196 | // isAnonymous: | 252 | // isAnonymous: |
253 | checkedCartLst:[] | ||
197 | } | 254 | } |
198 | }, | 255 | }, |
199 | onShow(addressId) { | 256 | onShow(addressId) { |
200 | // console.log('+-+-*-*-+-+',addressId) | 257 | // console.log('+-+-*-*-+-+',addressId) |
201 | if (addressId) { | 258 | if (addressId) { |
202 | store | 259 | store |
203 | .dispatch('address/details', { | 260 | .dispatch('address/details', { |
204 | add_id: addressId, | 261 | add_id: addressId, |
205 | }) | 262 | }) |
206 | .then(({ code, data }) => { | 263 | .then(({ code, data }) => { |
207 | if (code === 1) { | 264 | if (code === 1) { |
208 | // console.log('code', code, data) | 265 | // console.log('code', code, data) |
209 | this.showAddress = true | 266 | this.showAddress = true |
210 | this.addressInfo = data | 267 | this.addressInfo = data |
211 | } | 268 | } |
212 | }) | 269 | }) |
213 | } | 270 | } |
214 | }, | 271 | }, |
215 | onLoad({ pid, addressId,isCart ,count,name}) { | 272 | onLoad({ pid, addressId,isCart ,count,name}) { |
216 | this.pid = pid; | 273 | if(isCart == 'false'){ |
274 | |||
275 | this.pid = pid; | ||
276 | store.dispatch('read/fetch', { | ||
277 | pid, | ||
278 | }) | ||
279 | } | ||
217 | this.count = count; | 280 | this.count = count; |
218 | this.name = name; | 281 | this.name = name; |
219 | store.dispatch('read/fetch', { | 282 | this.isCart = isCart; |
220 | pid, | 283 | |
221 | }) | 284 | console.log('++++++++++++'+pid,addressId,isCart) |
222 | console.log('++++++++++++'+pid,addressId,isCart,count) | 285 | this.checkedCartLst = this.$store.state.cart.checkedCartLst |
286 | // console.log('++++++++++6666666666++',this.$store.state.cart.checkedCartLst) | ||
223 | // 若已经选择地址 | 287 | // 若已经选择地址 |
224 | if (addressId) { | 288 | if (addressId) { |
225 | store | 289 | store |
226 | .dispatch('address/details', { | 290 | .dispatch('address/details', { |
227 | add_id: addressId, | 291 | add_id: addressId, |
228 | }) | 292 | }) |
229 | .then(({ code, data }) => { | 293 | .then(({ code, data }) => { |
230 | if (code === 1) { | 294 | if (code === 1) { |
231 | console.log('code', code, data) | 295 | // console.log('code', code, data) |
232 | this.showAddress = true | 296 | this.showAddress = true |
233 | this.addressInfo = data | 297 | this.addressInfo = data |
234 | } | 298 | } |
235 | }) | 299 | }) |
236 | } else { | 300 | } else { |
237 | store.dispatch('address/default').then(({ code, data }) => { | 301 | store.dispatch('address/default').then(({ code, data }) => { |
238 | if (code === 1) { | 302 | if (code === 1) { |
239 | console.log('code', code, data) | 303 | // console.log('code', code, data) |
240 | this.showAddress = true | 304 | this.showAddress = true |
241 | this.addressInfo = data | 305 | this.addressInfo = data |
242 | } | 306 | } |
243 | }) | 307 | }) |
244 | } | 308 | } |
245 | }, | 309 | }, |
246 | computed: { | 310 | computed: { |
311 | totalPrice(){ | ||
312 | if(this.isCart == 'true'){ | ||
313 | let total = 0 | ||
314 | this.$store.state.cart.checkedCartLst.map(item =>{ | ||
315 | total += item.nowPrice*item.num | ||
316 | }) | ||
317 | return total | ||
318 | }else{ | ||
319 | return this.buyItem.real_price* this.count | ||
320 | } | ||
321 | }, | ||
322 | buyItem(){ | ||
323 | return this.$store.state.cart.buyItem | ||
324 | }, | ||
325 | // checkedCartLst(){ | ||
326 | // console.log('checkedCartLst',this.$store.state.cart.checkedCartLst) | ||
327 | // return this.$store.state.cart.checkedCartLst | ||
328 | // }, | ||
247 | goodInfo() { | 329 | goodInfo() { |
248 | console.log('state', this.$store.state.read.goodInfo) | 330 | console.log('state', this.$store.state.read.goodInfo) |
249 | return this.$store.state.read.goodInfo | 331 | return this.$store.state.read.goodInfo |
250 | }, | 332 | }, |
251 | skuInfo() { | 333 | skuInfo() { |
252 | return this.$store.state.order.param.sk_id_arr | 334 | return this.$store.state.order.param.sk_id_arr |
253 | }, | 335 | }, |
254 | attrList() { | 336 | attrList() { |
255 | return this.$store.state.order.param.attrList | 337 | return this.$store.state.order.param.attrList |
256 | }, | 338 | }, |
257 | current() { | 339 | current() { |
258 | return this.$store.state.order.param.current | 340 | return this.$store.state.order.param.current |
259 | }, | 341 | }, |
260 | }, | 342 | }, |
261 | methods: { | 343 | methods: { |
262 | counter(isadd) { | 344 | counter(isadd,index) { |
263 | if (isadd) { | 345 | if (isadd) { |
264 | this.count++ | 346 | if(this.isCart =='true'){ |
347 | this.checkedCartLst[index].num++ | ||
348 | }else{ | ||
349 | this.count++ | ||
350 | } | ||
265 | } else { | 351 | } else { |
266 | this.count <= 1 ? (this.disabled = true) : this.count-- | 352 | if(this.isCart =='true'){ |
353 | this.checkedCartLst[index].num<= 1 ? (this.disabled = true) : this.checkedCartLst[index].num-- | ||
354 | }else{ | ||
355 | this.count <= 1 ? (this.disabled = true) : this.count-- | ||
356 | } | ||
267 | } | 357 | } |
268 | }, | 358 | }, |
269 | // 跳转添加地址页面 | 359 | // 跳转添加地址页面 |
270 | toaddAddress() { | 360 | toaddAddress() { |
271 | uni.navigateTo({ | 361 | uni.navigateTo({ |
272 | url: `../address/addressList?edit=${1}`, | 362 | url: `../address/addressList?edit=${1}`, |
273 | success: res => {}, | 363 | success: res => {}, |
274 | fail: error => { | 364 | fail: error => { |
275 | console.log('跳转到地址列表页面失败====>', error) | 365 | console.log('跳转到地址列表页面失败====>', error) |
276 | }, | 366 | }, |
277 | complete: () => {}, | 367 | complete: () => {}, |
278 | }) | 368 | }) |
279 | }, | 369 | }, |
280 | // 下单 | 370 | // 下单 |
281 | orderBuild() { | 371 | orderBuild() { |
282 | uni.showLoading({ | 372 | uni.showLoading({ |
283 | title: '支付中', | 373 | title: '支付中', |
284 | }) | 374 | }) |
285 | console.log('this', this.$store.state) | 375 | if(this.isCart == 'true'){ |
286 | const { sk_id_arr: skId, mp_id: mpId } = this.$store.state.order.param | 376 | const checkedGoods = [] |
287 | store.dispatch('order/buyNow', { | 377 | const sk_id_arr = [] |
288 | pid: skId.pid, | 378 | this.checkedCartLst.map(item=>{ |
289 | sk_id: skId.sk_id, | 379 | checkedGoods.push(item.pid) |
290 | number: this.count, | 380 | sk_id_arr.push(item.sk_id) |
291 | mp_id: mpId, | 381 | }) |
292 | address: JSON.stringify(this.addressInfo), | 382 | store.dispatch('order/build', { |
293 | totalPrice: Number(this.skuInfo.real_price) * this.count * 100, | 383 | uid: this.$store.state.user.userInfo.uid, |
294 | liuyan: this.note, | 384 | address: JSON.stringify(this.addressInfo), |
295 | dir: 1, | 385 | checkedGoods:checkedGoods, |
296 | }).then((res) => { | 386 | sk_id_arr: sk_id_arr, |
297 | this.pay(res.data) | 387 | totalPrice: this.totalPrice, |
298 | }) | 388 | }).then((res) => { |
389 | this.pay(res.data) | ||
390 | }) | ||
391 | } | ||
392 | if(this.isCart == 'false'){ | ||
393 | const { sk_id_arr: skId, mp_id: mpId } = this.$store.state.order.param | ||
394 | store.dispatch('order/buyNow', { | ||
395 | pid: skId.pid, | ||
396 | sk_id: skId.sk_id, | ||
397 | number: this.count, | ||
398 | mp_id: mpId, | ||
399 | address: JSON.stringify(this.addressInfo), | ||
400 | totalPrice: this.totalPrice, | ||
401 | liuyan: this.note, | ||
402 | dir: 1, | ||
403 | }).then((res) => { | ||
404 | this.pay(res.data) | ||
405 | }) | ||
406 | } | ||
299 | }, | 407 | }, |
300 | // 支付 | 408 | // 支付 |
301 | pay(res) { | 409 | pay(res) { |
302 | console.log('pay', res) | 410 | console.log('pay', res) |
303 | const { data, exKeyName: keyName } = res | 411 | const { data, exKeyName: keyName } = res |
304 | const uid = uni.getStorageSync('uid') | 412 | const uid = uni.getStorageSync('uid') |
305 | const timeStamp = new Date().getTime().toString() | 413 | const timeStamp = new Date().getTime().toString() |
306 | const nonceStr = 'asfafasfasfasfasf' | 414 | const nonceStr = 'asfafasfasfasfasf' |
307 | // 支付参数 | 415 | // 支付参数 |
308 | const fieldSet = { | 416 | const fieldSet = { |
309 | openid: this.$store.state.user.userInfo.openid, | 417 | openid: this.$store.state.user.userInfo.openid, |
310 | uid: this.$store.state.user.userInfo.uid, | 418 | uid: this.$store.state.user.userInfo.uid, |
311 | shopid: 0, | 419 | shopid: 0, |
312 | payCate: 2020, | 420 | payCate: 2020, |
313 | payMoney: Number(this.skuInfo.real_price) * this.count * 100, | 421 | payMoney: this.totalPrice, |
314 | payWoodId: `fcdj-${uid}-${keyName}`, | 422 | payWoodId: `fcdj-${uid}-${keyName}`, |
315 | payWoodDesc: '在【非常戴镜】的微信付款凭证', | 423 | payWoodDesc: '在【非常戴镜】的微信付款凭证', |
316 | nonceStr, | 424 | nonceStr, |
317 | signType: 'MD5', | 425 | signType: 'MD5', |
318 | app_uid: 2020, | 426 | app_uid: 2020, |
319 | timeStamp, | 427 | timeStamp, |
320 | keyname: keyName, | 428 | keyname: keyName, |
321 | billInfo: JSON.stringify(data), | 429 | billInfo: JSON.stringify(data), |
322 | } | 430 | } |
323 | // 请求后台支付接口 | 431 | // 请求后台支付接口 |
324 | store.dispatch('order/pay', fieldSet).then(({ data, data2, pay_id: payId }) => { | 432 | store.dispatch('order/pay', fieldSet).then(({ data, data2, pay_id: payId }) => { |
325 | if (data.return_code === 'SUCCESS' && data.result_code === 'SUCCESS') { | 433 | if (data.return_code === 'SUCCESS' && data.result_code === 'SUCCESS') { |
326 | const stringA = `appId=wx115b25aa396d27ac&nonceStr=${nonceStr}&package=prepay_id=${data.prepay_id}&signType=MD5&timeStamp=${timeStamp}` | 434 | const stringA = `appId=wx115b25aa396d27ac&nonceStr=${nonceStr}&package=prepay_id=${data.prepay_id}&signType=MD5&timeStamp=${timeStamp}` |
327 | const stringSignTemp = stringA + '&key=NewMoney2017hatemydaddy123456789' | 435 | const stringSignTemp = stringA + '&key=NewMoney2017hatemydaddy123456789' |
328 | 436 | ||
329 | // 微信支付接口 | 437 | // 微信支付接口 |
330 | uni.requestPayment({ | 438 | uni.requestPayment({ |
331 | appId: data.appid, | 439 | appId: data.appid, |
332 | timeStamp, | 440 | timeStamp, |
333 | nonceStr, | 441 | nonceStr, |
334 | total_fee: Number(this.skuInfo.real_price) * this.count * 100, | 442 | total_fee: this.totalPrice, |
335 | package: `prepay_id=${data.prepay_id}`, | 443 | package: `prepay_id=${data.prepay_id}`, |
336 | signType: 'MD5', | 444 | signType: 'MD5', |
337 | paySign: MD5Util.MD5(stringSignTemp).toUpperCase(), | 445 | paySign: MD5Util.MD5(stringSignTemp).toUpperCase(), |
338 | success: (res) => { | 446 | success: (res) => { |
339 | // 支付成功 | 447 | // 支付成功 |
340 | uni.showModal({ | 448 | uni.showModal({ |
341 | content: '支付成功', | 449 | content: '支付成功', |
342 | showCancel: false, | 450 | showCancel: false, |
343 | }) | 451 | }) |
344 | // 跳转订单详情页->状态 待收货 | 452 | // 跳转订单详情页->状态 待收货 |
345 | uni.reLaunch({ | 453 | uni.reLaunch({ |
346 | url: `../myOrderPaying/myOrderPaying?payId=${payId}&state=1&isPay=1`, | 454 | url: `../myOrderPaying/myOrderPaying?payId=${payId}&state=1&isPay=1`, |
347 | }) | 455 | }) |
348 | }, | 456 | }, |
349 | fail: (res) => { | 457 | fail: (res) => { |
350 | // 支付失败 | 458 | // 支付失败 |
351 | uni.showModal({ | 459 | uni.showModal({ |
352 | content: '支付失败', | 460 | content: '支付失败', |
353 | showCancel: false, | 461 | showCancel: false, |
354 | }) | 462 | }) |
355 | // 跳转订单详情页->状态 待付款 | 463 | // 跳转订单详情页->状态 待付款 |
356 | uni.reLaunch({ | 464 | uni.reLaunch({ |
357 | url: `../myOrderPaying/myOrderPaying?payId=${payId}&state=0&isPay=1`, | 465 | url: `../myOrderPaying/myOrderPaying?payId=${payId}&state=0&isPay=1`, |
358 | }) | 466 | }) |
359 | }, | 467 | }, |
360 | complete: () => { | 468 | complete: () => { |
361 | uni.hideLoading() | 469 | uni.hideLoading() |
362 | }, | 470 | }, |
363 | }) | 471 | }) |
364 | } else { | 472 | } else { |
365 | uni.showModal({ | 473 | uni.showModal({ |
366 | content: '支付失败', | 474 | content: '支付失败', |
367 | showCancel: false, | 475 | showCancel: false, |
368 | }) | 476 | }) |
369 | console.log('支付失败') | 477 | console.log('支付失败') |
370 | uni.hideLoading() | 478 | uni.hideLoading() |
371 | } | 479 | } |
372 | }) | 480 | }) |
373 | }, | 481 | }, |
374 | }, | 482 | }, |
375 | } | 483 | } |
376 | </script> | 484 | </script> |
377 | 485 | ||
378 | <style lang="scss"> | 486 | <style lang="scss"> |
379 | .wrap { | 487 | .wrap { |
380 | height: 100vh; | 488 | height: 100vh; |
381 | background-color: #f2f2f2; | 489 | background-color: #f2f2f2; |
382 | font-family: PingFangSC-Regular; | 490 | font-family: PingFangSC-Regular; |
383 | letter-spacing: -0.23px; | 491 | letter-spacing: -0.23px; |
384 | position: absolute; | 492 | position: absolute; |
385 | } | 493 | } |
386 | .addAddress { | 494 | .addAddress { |
387 | background-color: #ffffff; | 495 | background-color: #ffffff; |
388 | box-sizing: border-box; | 496 | box-sizing: border-box; |
389 | height: 124rpx; | 497 | height: 124rpx; |
390 | width: 100%; | 498 | width: 100%; |
391 | display: flex; | 499 | display: flex; |
392 | align-items: center; | 500 | align-items: center; |
393 | padding: 0 40rpx; | 501 | padding: 0 40rpx; |
394 | .addIcon { | 502 | .addIcon { |
395 | background-color: #f2f2f2; | 503 | background-color: #f2f2f2; |
396 | height: 56rpx; | 504 | height: 56rpx; |
397 | width: 60rpx; | 505 | width: 60rpx; |
398 | border-radius: 4rpx; | 506 | border-radius: 4rpx; |
399 | display: flex; | 507 | display: flex; |
400 | justify-content: center; | 508 | justify-content: center; |
401 | align-items: center; | 509 | align-items: center; |
402 | margin-right: 40rpx; | 510 | margin-right: 40rpx; |
403 | } | 511 | } |
404 | image { | 512 | image { |
405 | height: 28rpx; | 513 | height: 28rpx; |
406 | width: 30rpx; | 514 | width: 30rpx; |
407 | } | 515 | } |
408 | .addressText { | 516 | .addressText { |
409 | font-size: 28rpx; | 517 | font-size: 28rpx; |
410 | color: #333333; | 518 | color: #333333; |
411 | margin-right: 364rpx; | 519 | margin-right: 364rpx; |
412 | } | 520 | } |
413 | } | 521 | } |
414 | .content { | 522 | .content { |
415 | background-color: #f2f2f2; | 523 | background-color: #f2f2f2; |
416 | width: 100%; | 524 | width: 100%; |
417 | display: flex; | 525 | display: flex; |
418 | flex-direction: column; | 526 | flex-direction: column; |
419 | justify-content: center; | 527 | justify-content: center; |
420 | align-items: center; | 528 | align-items: center; |
421 | padding: 40rpx; | 529 | padding: 40rpx; |
422 | box-sizing: border-box; | 530 | box-sizing: border-box; |
423 | .orderInfo { | 531 | .orderInfo { |
424 | width: 670rpx; | 532 | width: 670rpx; |
425 | min-height: 488rpx; | 533 | min-height: 488rpx; |
426 | background-color: #ffffff; | 534 | background-color: #ffffff; |
427 | border-radius: 20rpx; | 535 | border-radius: 20rpx; |
428 | box-sizing: border-box; | 536 | box-sizing: border-box; |
429 | padding: 0 40rpx 40rpx 40rpx; | 537 | padding: 0 40rpx 40rpx 40rpx; |
430 | .title { | 538 | .title { |
431 | display: flex; | 539 | display: flex; |
432 | align-items: center; | 540 | align-items: center; |
433 | font-size: 28rpx; | 541 | font-size: 28rpx; |
434 | color: #333333; | 542 | color: #333333; |
435 | height: 60rpx; | 543 | height: 60rpx; |
436 | line-height: 40rpx; | 544 | line-height: 40rpx; |
437 | padding: 10rpx 10rpx 10rpx 0rpx; | 545 | padding: 10rpx 10rpx 10rpx 0rpx; |
438 | image { | 546 | image { |
439 | margin-right: 20rpx; | 547 | margin-right: 20rpx; |
440 | } | 548 | } |
441 | } | 549 | } |
442 | .infoBox { | 550 | .infoBox { |
443 | margin-top: 42rpx; | 551 | margin-top: 42rpx; |
444 | .infoTop { | 552 | .infoTop { |
445 | display: flex; | 553 | display: flex; |
446 | flex-direction: row; | 554 | flex-direction: row; |
447 | image { | 555 | image { |
448 | height: 188rpx; | 556 | height: 188rpx; |
449 | width: 188rpx; | 557 | width: 188rpx; |
450 | margin-right: 24rpx; | 558 | margin-right: 24rpx; |
451 | } | 559 | } |
452 | .infoRight { | 560 | .infoRight { |
453 | width: 374rpx; | 561 | width: 374rpx; |
454 | display: flex; | 562 | display: flex; |
455 | flex-direction: column; | 563 | flex-direction: column; |
456 | align-items: flex-start; | 564 | align-items: flex-start; |
457 | justify-content: space-between; | 565 | justify-content: space-between; |
458 | .goodName { | 566 | .goodName { |
459 | font-size: 28rpx; | 567 | font-size: 28rpx; |
460 | color: #333333; | 568 | color: #333333; |
461 | } | 569 | } |
462 | .remarks { | 570 | .remarks { |
463 | font-size: 20rpx; | 571 | font-size: 20rpx; |
464 | color: #999999; | 572 | color: #999999; |
465 | } | 573 | } |
466 | .priceBox { | 574 | .priceBox { |
467 | display: flex; | 575 | display: flex; |
468 | justify-content: space-between; | 576 | justify-content: space-between; |
469 | align-items: center; | 577 | align-items: center; |
470 | width: 100%; | 578 | width: 100%; |
471 | .price { | 579 | .price { |
472 | color: #ff6b4a; | 580 | color: #ff6b4a; |
473 | font-size: 28rpx; | 581 | font-size: 28rpx; |
474 | } | 582 | } |
475 | .originCost { | 583 | .originCost { |
476 | text-decoration: line-through; | 584 | text-decoration: line-through; |
477 | color: #999999; | 585 | color: #999999; |
478 | font-size: 20rpx; | 586 | font-size: 20rpx; |
479 | } | 587 | } |
480 | .counter { | 588 | .counter { |
481 | display: flex; | 589 | display: flex; |
482 | flex-direction: row; | 590 | flex-direction: row; |
483 | justify-content: space-between; | 591 | justify-content: space-between; |
484 | font-size: 28rpx; | 592 | font-size: 28rpx; |
485 | color: #333333; | 593 | color: #333333; |
486 | width: 122rpx; | 594 | width: 122rpx; |
487 | .btn { | 595 | .btn { |
488 | display: flex; | 596 | display: flex; |
489 | justify-content: center; | 597 | justify-content: center; |
490 | line-height: 32rpx; | 598 | line-height: 32rpx; |
491 | height: 32rpx; | 599 | height: 32rpx; |
492 | width: 32rpx; | 600 | width: 32rpx; |
493 | background-color: #f2f2f2; | 601 | background-color: #f2f2f2; |
494 | color: #cfcfcf; | 602 | color: #cfcfcf; |
495 | } | 603 | } |
496 | } | 604 | } |
497 | } | 605 | } |
498 | } | 606 | } |
499 | } | 607 | } |
500 | .infoBottom { | 608 | .infoBottom { |
501 | display: flex; | 609 | display: flex; |
502 | flex-direction: column; | 610 | flex-direction: column; |
503 | justify-content: flex-start; | 611 | justify-content: flex-start; |
504 | font-size: 24rpx; | 612 | font-size: 24rpx; |
505 | color: #333333; | 613 | color: #333333; |
506 | text { | 614 | text { |
507 | color: #999999; | 615 | color: #999999; |
508 | margin-left: 20rpx; | 616 | margin-left: 20rpx; |
509 | } | 617 | } |
510 | 618 | ||
511 | .norm { | 619 | .norm { |
512 | margin-top: 28rpx; | 620 | margin-top: 28rpx; |
513 | } | 621 | } |
514 | .shippingMethod { | 622 | .shippingMethod { |
515 | margin-top: 12rpx; | 623 | margin-top: 12rpx; |
516 | } | 624 | } |
517 | .message { | 625 | .message { |
518 | display: flex; | 626 | display: flex; |
519 | flex-direction: row; | 627 | flex-direction: row; |
520 | align-items: center; | 628 | align-items: center; |
521 | margin-top: 18rpx; | 629 | margin-top: 18rpx; |
522 | input { | 630 | input { |
523 | margin-left: 20rpx; | 631 | margin-left: 20rpx; |
524 | width: 75%; | 632 | width: 75%; |
525 | } | 633 | } |
526 | } | 634 | } |
527 | } | 635 | } |
528 | } | 636 | } |
529 | } | 637 | } |
530 | .payWay { | 638 | .payWay { |
531 | height: 464rpx; | 639 | height: 464rpx; |
532 | width: 670rpx; | 640 | width: 670rpx; |
533 | background-color: #ffffff; | 641 | background-color: #ffffff; |
534 | color: #333333; | 642 | color: #333333; |
535 | font-size: 24rpx; | 643 | font-size: 24rpx; |
536 | border-radius: 20rpx; | 644 | border-radius: 20rpx; |
537 | box-sizing: border-box; | 645 | box-sizing: border-box; |
538 | padding: 0 52rpx 0rpx 40rpx; | 646 | padding: 0 52rpx 0rpx 40rpx; |
539 | margin-top: 20rpx; | 647 | margin-top: 20rpx; |
540 | display: flex; | 648 | display: flex; |
541 | flex-direction: column; | 649 | flex-direction: column; |
542 | justify-content: center; | 650 | justify-content: center; |
543 | align-items: flex-start; | 651 | align-items: flex-start; |
544 | .item { | 652 | .item { |
545 | display: flex; | 653 | display: flex; |
546 | flex-direction: row; | 654 | flex-direction: row; |
547 | justify-content: space-between; | 655 | justify-content: space-between; |
548 | align-items: center; | 656 | align-items: center; |
549 | width: 100%; | 657 | width: 100%; |
550 | height: 115rpx; | 658 | height: 115rpx; |
551 | .itemRight { | 659 | .itemRight { |
552 | display: flex; | 660 | display: flex; |
553 | flex-direction: row; | 661 | flex-direction: row; |
554 | justify-content: space-between; | 662 | justify-content: space-between; |
555 | align-items: center; | 663 | align-items: center; |
556 | image { | 664 | image { |
557 | height: 24rpx; | 665 | height: 24rpx; |
558 | width: 12rpx; | 666 | width: 12rpx; |
559 | } | 667 | } |
560 | .rightText { | 668 | .rightText { |
561 | margin-right: 20rpx; | 669 | margin-right: 20rpx; |
562 | text-align: right; | 670 | text-align: right; |
563 | .choosePayWay { | 671 | .choosePayWay { |
564 | display: flex; | 672 | display: flex; |
565 | align-items: center; | 673 | align-items: center; |
566 | text { | 674 | text { |
567 | color: #333333; | 675 | color: #333333; |
568 | } | 676 | } |
569 | image { | 677 | image { |
570 | height: 36rpx; | 678 | height: 36rpx; |
571 | width: 40rpx; | 679 | width: 40rpx; |
572 | margin-right: 8px; | 680 | margin-right: 8px; |
573 | } | 681 | } |
574 | } | 682 | } |
575 | .randomSubstraction { | 683 | .randomSubstraction { |
576 | color: #ff6b4a; | 684 | color: #ff6b4a; |
577 | } | 685 | } |
578 | .preferentialWay { | 686 | .preferentialWay { |
579 | color: #999999; | 687 | color: #999999; |
580 | } | 688 | } |
581 | } | 689 | } |
582 | .freight, | 690 | .freight, |
583 | .total { | 691 | .total { |
584 | margin-right: 32rpx; | 692 | margin-right: 32rpx; |
585 | } | 693 | } |
586 | text { | 694 | text { |
587 | color: #ff6b4a; | 695 | color: #ff6b4a; |
588 | } | 696 | } |
589 | } | 697 | } |
590 | } | 698 | } |
591 | } | 699 | } |
592 | // .checkBox { | 700 | // .checkBox { |
593 | // height: 58rpx; | 701 | // height: 58rpx; |
594 | // line-height: 58rpx; | 702 | // line-height: 58rpx; |
595 | // width: 100%; | 703 | // width: 100%; |
596 | // margin-top: 36rpx; | 704 | // margin-top: 36rpx; |
597 | // margin-left: 40rpx; | 705 | // margin-left: 40rpx; |
598 | // font-size: 12px; | 706 | // font-size: 12px; |
599 | // color: #999999; | 707 | // color: #999999; |
600 | // } | 708 | // } |
601 | } | 709 | } |
602 | .footer { | 710 | .footer { |
603 | height: 112rpx; | 711 | height: 112rpx; |
604 | width: 100%; | 712 | width: 100%; |
605 | background-color: #fff; | 713 | background-color: #fff; |
606 | font-size: 16px; | 714 | font-size: 16px; |
607 | display: flex; | 715 | display: flex; |
608 | justify-content: space-between; | 716 | justify-content: space-between; |
609 | align-items: center; | 717 | align-items: center; |
610 | position: fixed; | 718 | position: fixed; |
611 | bottom: 0; | 719 | bottom: 0; |
720 | z-index: 9999; | ||
612 | .footerLeft { | 721 | .footerLeft { |
613 | display: flex; | 722 | display: flex; |
614 | justify-content: center; | 723 | justify-content: center; |
615 | align-items: center; | 724 | align-items: center; |
616 | width: 50%; | 725 | width: 50%; |
617 | color: #333333; | 726 | color: #333333; |
618 | text { | 727 | text { |
619 | color: #ff6b4a; | 728 | color: #ff6b4a; |
620 | } | 729 | } |
621 | } | 730 | } |
622 | .footerRight { | 731 | .footerRight { |
623 | display: flex; | 732 | display: flex; |
624 | justify-content: flex-end; | 733 | justify-content: flex-end; |
625 | align-items: center; | 734 | align-items: center; |
626 | width: 50%; | 735 | width: 50%; |
627 | margin-right: 26rpx; | 736 | margin-right: 26rpx; |
628 | .paybtn { | 737 | .paybtn { |
629 | display: flex; | 738 | display: flex; |
630 | justify-content: center; | 739 | justify-content: center; |
631 | align-items: center; | 740 | align-items: center; |
632 | background: #ff6b4a; | 741 | background: #ff6b4a; |
633 | border-radius: 20px; | 742 | border-radius: 20px; |
634 | border-radius: 20px; | 743 | border-radius: 20px; |
635 | color: #ffffff; | 744 | color: #ffffff; |
636 | width: 204rpx; | 745 | width: 204rpx; |
637 | height: 80rpx; | 746 | height: 80rpx; |
638 | } | 747 | } |
639 | } | 748 | } |
640 | } | 749 | } |
641 | // 地址信息样式 | 750 | // 地址信息样式 |
642 | .order-user { | 751 | .order-user { |
643 | width: 670rpx; | 752 | width: 670rpx; |
644 | height: 228rpx; | 753 | height: 228rpx; |
645 | background: #ffffff; | 754 | background: #ffffff; |
646 | border-radius: 14rpx; | 755 | border-radius: 14rpx; |
647 | margin: 0 auto; | 756 | margin: 0 auto; |
648 | margin-top: 20rpx; | 757 | margin-top: 20rpx; |
649 | position: relative; | 758 | position: relative; |
650 | .order-user-head { | 759 | .order-user-head { |
651 | display: flex; | 760 | display: flex; |
652 | height: 108rpx; | 761 | height: 108rpx; |
653 | width: 100%; | 762 | width: 100%; |
654 | align-items: center; | 763 | align-items: center; |
655 | padding-left: 126rpx; | 764 | padding-left: 126rpx; |
656 | box-sizing: border-box; | 765 | box-sizing: border-box; |
657 | .name { | 766 | .name { |
658 | display: flex; | 767 | display: flex; |
659 | justify-content: space-between; | 768 | justify-content: space-between; |
660 | font-size: 14px; | 769 | font-size: 14px; |
661 | color: #333333; | 770 | color: #333333; |
662 | letter-spacing: -0.26px; | 771 | letter-spacing: -0.26px; |
663 | margin-right: 20rpx; | 772 | margin-right: 20rpx; |
664 | .default { | 773 | .default { |
665 | height: 40rpx; | 774 | height: 40rpx; |
666 | width: 80rpx; | 775 | width: 80rpx; |
667 | background-color: #4a90e2; | 776 | background-color: #4a90e2; |
668 | border-radius: 13px; | 777 | border-radius: 13px; |
669 | border-radius: 13px; | 778 | border-radius: 13px; |
670 | text-align: center; | 779 | text-align: center; |
671 | margin-right: 20rpx; | 780 | margin-right: 20rpx; |
672 | text { | 781 | text { |
673 | display: flex; | 782 | display: flex; |
674 | justify-content: center; | 783 | justify-content: center; |
675 | align-items: center; | 784 | align-items: center; |
676 | font-size: 12px; | 785 | font-size: 12px; |
677 | color: #ffffff; | 786 | color: #ffffff; |
678 | letter-spacing: -0.23px; | 787 | letter-spacing: -0.23px; |
679 | } | 788 | } |
680 | } | 789 | } |
681 | } | 790 | } |
682 | .mobile { | 791 | .mobile { |
683 | font-size: 14px; | 792 | font-size: 14px; |
684 | color: #999999; | 793 | color: #999999; |
685 | letter-spacing: -0.26px; | 794 | letter-spacing: -0.26px; |
686 | } | 795 | } |
687 | } | 796 | } |
688 | .order-user-body { | 797 | .order-user-body { |
689 | display: flex; | 798 | display: flex; |
690 | width: 100%; | 799 | width: 100%; |
691 | image { | 800 | image { |
692 | width: 24px; | 801 | width: 24px; |
693 | height: 28px; | 802 | height: 28px; |
694 | margin: 12rpx 32rpx 0 40rpx; | 803 | margin: 12rpx 32rpx 0 40rpx; |
695 | } | 804 | } |
696 | .address { | 805 | .address { |
697 | font-weight: bold; | 806 | font-weight: bold; |
698 | font-size: 14px; | 807 | font-size: 14px; |
699 | color: #333333; | 808 | color: #333333; |
700 | letter-spacing: -0.26px; | 809 | letter-spacing: -0.26px; |
701 | } | 810 | } |
702 | } | 811 | } |
703 | .arrow { | 812 | .arrow { |
704 | width: 12px; | 813 | width: 12px; |
705 | height: 12px; | 814 | height: 12px; |
706 | position: absolute; | 815 | position: absolute; |
707 | right: 40rpx; | 816 | right: 40rpx; |
708 | bottom: 104rpx; | 817 | bottom: 104rpx; |
709 | } | 818 | } |
710 | } | 819 | } |
711 | .last_zhanwei{ | 820 | .last_zhanwei{ |
712 | background: #f2f2f2; | 821 | background: #f2f2f2; |
713 | height: 60px; | 822 | height: 60px; |
714 | } | 823 | } |
715 | </style> | 824 | </style> |
716 | 825 |
src/store/modules/cart.js
1 | import urlAlias from '../url' | 1 | import urlAlias from '../url' |
2 | import request from '../request' | 2 | import request from '../request' |
3 | 3 | ||
4 | const { cartList, cartModi, cartDel, cartAdd } = urlAlias | 4 | const { cartList, cartModi, cartDel, cartAdd } = urlAlias |
5 | 5 | ||
6 | const state = { | 6 | const state = { |
7 | cartList: [], | 7 | cartList: [], |
8 | checkedCartLst:[], | ||
9 | buyItem:Object | ||
8 | } | 10 | } |
9 | 11 | ||
10 | const mutations = { | 12 | const mutations = { |
11 | INIT: (state, cartList) => { | 13 | INIT: (state, cartList) => { |
12 | state.cartList = cartList | 14 | state.cartList = cartList |
13 | }, | 15 | }, |
14 | DEL: (state, index) => { | 16 | DEL: (state, index) => { |
15 | console.log('mutations====>', state.cartList) | ||
16 | state.cartList.splice(index, 1) | 17 | state.cartList.splice(index, 1) |
17 | console.log('mutations====>index', index) | ||
18 | // state.cartList=delList | ||
19 | }, | 18 | }, |
20 | MODI: (state, args) => { | 19 | MODI: (state, args) => { |
21 | state.cartList[args.index].num = args.num | 20 | state.cartList[args.index].num = args.num |
22 | }, | 21 | }, |
23 | 22 | ||
24 | } | 23 | } |
25 | 24 | ||
26 | const actions = { | 25 | const actions = { |
27 | // 获取购物车列表 | 26 | // 获取购物车列表 |
28 | getCartList({ commit }, param) { | 27 | getCartList({ commit }, param) { |
29 | return new Promise((resolve) => request({ | 28 | return new Promise((resolve) => request({ |
30 | url: cartList, | 29 | url: cartList, |
31 | data: param, | 30 | data: param, |
32 | success: (res) => { | 31 | success: (res) => { |
33 | let test = { | 32 | let test = { |
34 | isChecked: false, | 33 | isChecked: false, |
35 | itemNum:1, | 34 | itemNum:1, |
36 | price:0 | 35 | price:0 |
37 | } | 36 | } |
38 | commit('INIT', res.data.data) | 37 | commit('INIT', res.data.data) |
39 | resolve(res.data.data) | 38 | resolve(res.data.data) |
40 | }, | 39 | }, |
41 | })) | 40 | })) |
42 | }, | 41 | }, |
43 | // 修改购物车数量 | 42 | // 修改购物车数量 |
44 | modiCart({ commit }, param) { | 43 | modiCart({ commit }, param) { |
45 | const arg = Object.assign({ num: param.num }, param.args) | 44 | const arg = Object.assign({ num: param.num }, param.args) |
46 | delete param.args | 45 | delete param.args |
47 | return new Promise((resolve) => request({ | 46 | return new Promise((resolve) => request({ |
48 | url: cartModi, | 47 | url: cartModi, |
49 | data: param, | 48 | data: param, |
50 | success: (res) => { | 49 | success: (res) => { |
51 | console.log('modi-parm', param) | ||
52 | commit('MODI', arg) | 50 | commit('MODI', arg) |
53 | }, | 51 | }, |
54 | fail: (res) => { | 52 | fail: (res) => { |
55 | console.log('fail status === > ', res) | ||
56 | }, | 53 | }, |
57 | complete: (res) => { | 54 | complete: (res) => { |
58 | console.log('complete status === > ', res) | ||
59 | }, | 55 | }, |
60 | })) | 56 | })) |
61 | }, | 57 | }, |
62 | // 删除购物车商品 | 58 | // 删除购物车商品 |
63 | delCart({ commit }, param) { | 59 | delCart({ commit }, param) { |
64 | const arg = param.arg | 60 | const arg = param.arg |
65 | delete param.arg | 61 | delete param.arg |
66 | request({ | 62 | request({ |
67 | url: cartDel, | 63 | url: cartDel, |
68 | data: param, | 64 | data: param, |
69 | success: (res) => { | 65 | success: (res) => { |
70 | console.log('del-parm', param) | ||
71 | console.log('del-myparms==>', arg) | ||
72 | commit('DEL', arg) | 66 | commit('DEL', arg) |
73 | }, | 67 | }, |
74 | fail: (res) => { | 68 | fail: (res) => { |
75 | console.log('fail status === > ', res) | ||
76 | }, | 69 | }, |
77 | complete: (res) => { | 70 | complete: (res) => { |
78 | console.log('complete status === > ', res) | ||
79 | }, | 71 | }, |
80 | }) | 72 | }) |
81 | }, | 73 | }, |
82 | // 添加到购物车 | 74 | // 添加到购物车 |
83 | addCart({ commit }, param) { | 75 | addCart({ commit }, param) { |
84 | console.log('请求接口开始') | 76 | console.log('请求接口开始') |
85 | return new Promise((resolve) => request({ | 77 | return new Promise((resolve) => request({ |
86 | url: cartAdd, | 78 | url: cartAdd, |
87 | data: param, | 79 | data: param, |
88 | success: (res) => { | 80 | success: (res) => { |
89 | console.log('add-parm', param) | 81 | console.log('add-parm', param) |
90 | console.log('addcart===>res.data===>', res.data) | 82 | console.log('addcart===>res.data===>', res.data) |
91 | // commit('INIT', res.data.data) | 83 | // commit('INIT', res.data.data) |
92 | resolve(res.data) | 84 | resolve(res.data) |
93 | }, | 85 | }, |
94 | fail: (res) => { | 86 | fail: (res) => { |
95 | console.log('添加购物车失败 === > ', res) | 87 | console.log('添加购物车失败 === > ', res) |
96 | }, | 88 | }, |
97 | complete: (res) => { | 89 | complete: (res) => { |
98 | console.log('添加购物车完成 === > ', res) | 90 | console.log('添加购物车完成 === > ', res) |
99 | }, | 91 | }, |
100 | })) | 92 | })) |
101 | }, | 93 | }, |
102 | } | 94 | } |
103 | 95 | ||
104 | export default { | 96 | export default { |
105 | namespaced: true, | 97 | namespaced: true, |
106 | state, | 98 | state, |
107 | mutations, | 99 | mutations, |
108 | actions, | 100 | actions, |