|
@@ -188,31 +188,48 @@ class UserModel |
|
@@ -188,31 +188,48 @@ class UserModel |
188
|
$favProduct = UserData::favoriteProductData($uid, $page, $limit);
|
188
|
$favProduct = UserData::favoriteProductData($uid, $page, $limit);
|
189
|
|
189
|
|
190
|
// 处理用户收藏的商品数据
|
190
|
// 处理用户收藏的商品数据
|
191
|
- if (isset($favProduct['data']) && $page <= $favProduct['data']['page_total']) {
|
|
|
192
|
- $datas = array();
|
|
|
193
|
- $product = array();
|
|
|
194
|
- foreach ($favProduct['data']['product_list'] as $val) {
|
|
|
195
|
- if (empty($val['product_skn'])) {
|
|
|
196
|
- continue;
|
|
|
197
|
- }
|
191
|
+ do {
|
|
|
192
|
+ // 开始就没获取到数据或者获取的数据为空时的处理
|
|
|
193
|
+ if (!isset($favProduct['data']['product_list']) && $page == 1) {
|
|
|
194
|
+ break;
|
|
|
195
|
+ }
|
198
|
|
196
|
|
|
|
197
|
+ // 加载第二页以及第二页之后的数据时接口不返回时的处理
|
|
|
198
|
+ if ($page > 1 && !$favProduct) {
|
|
|
199
|
+ $result['end'] = true;
|
|
|
200
|
+ break;
|
|
|
201
|
+ }
|
|
|
202
|
+
|
|
|
203
|
+ if ($page <= $favProduct['data']['page_total']) {
|
|
|
204
|
+ $datas = array();
|
199
|
$product = array();
|
205
|
$product = array();
|
200
|
- $product['fav_id'] = $val['product_id'];
|
|
|
201
|
- $product['link'] = isset($val['goodsId'], $val['cnAlphabet']) ? Helpers::url('/product/pro_' . $val['product_id'] . '_' . $val['goodsId'] . '/' . $val['cnAlphabet'] . '.html') : '';
|
|
|
202
|
- $product['imgUrl'] = !empty($val['image']) ? Helpers::getImageUrl($val['image'], 447, 596) : '';
|
|
|
203
|
- ;
|
|
|
204
|
- $product['title'] = $val['product_name'];
|
|
|
205
|
- $product['price'] = '¥' . Helpers::transPrice($val['market_price']);
|
|
|
206
|
- $product['discountPrice'] = ($val['market_price'] - $val['sales_price'] > 0) ? '¥' . Helpers::transPrice($val['sales_price']) : false;
|
|
|
207
|
- $product['savePrice'] = ($val['price_down'] > 0) ? '¥' . Helpers::transPrice($val['price_down']) : false;
|
|
|
208
|
- $product['sellOut'] = ($val['storage'] <= 0);
|
|
|
209
|
-
|
|
|
210
|
- $datas[] = $product;
|
|
|
211
|
- }
|
|
|
212
|
- !empty($datas) && $result['hasFavProduct'] = $datas;
|
|
|
213
|
- } else if (($page > 1 && !$favProduct) || $page > $favProduct['data']['page_total']) {
|
|
|
214
|
- $result['end'] = true;
|
|
|
215
|
- }
|
206
|
+ foreach ($favProduct['data']['product_list'] as $val) {
|
|
|
207
|
+ if (empty($val['product_skn'])) {
|
|
|
208
|
+ continue;
|
|
|
209
|
+ }
|
|
|
210
|
+
|
|
|
211
|
+ $product = array();
|
|
|
212
|
+ $product['fav_id'] = $val['product_id'];
|
|
|
213
|
+ $product['link'] = isset($val['goodsId'], $val['cnAlphabet']) ? Helpers::url('/product/pro_' . $val['product_id'] . '_' . $val['goodsId'] . '/' . $val['cnAlphabet'] . '.html') : '';
|
|
|
214
|
+ $product['imgUrl'] = !empty($val['image']) ? Helpers::getImageUrl($val['image'], 447, 596) : '';
|
|
|
215
|
+ ;
|
|
|
216
|
+ $product['title'] = $val['product_name'];
|
|
|
217
|
+ $product['price'] = '¥' . Helpers::transPrice($val['market_price']);
|
|
|
218
|
+ $product['discountPrice'] = ($val['market_price'] - $val['sales_price'] > 0) ? '¥' . Helpers::transPrice($val['sales_price']) : false;
|
|
|
219
|
+ $product['savePrice'] = ($val['price_down'] > 0) ? '¥' . Helpers::transPrice($val['price_down']) : false;
|
|
|
220
|
+ $product['sellOut'] = ($val['storage'] <= 0);
|
|
|
221
|
+
|
|
|
222
|
+ $datas[] = $product;
|
|
|
223
|
+ }
|
|
|
224
|
+
|
|
|
225
|
+ if (!empty($datas)) {
|
|
|
226
|
+ $result['hasFavProduct'] = $datas;
|
|
|
227
|
+ }
|
|
|
228
|
+ } else {
|
|
|
229
|
+ $result['end'] = true;
|
|
|
230
|
+ }
|
|
|
231
|
+
|
|
|
232
|
+ } while (false);
|
216
|
|
233
|
|
217
|
return $result;
|
234
|
return $result;
|
218
|
}
|
235
|
}
|
|
@@ -234,40 +251,56 @@ class UserModel |
|
@@ -234,40 +251,56 @@ class UserModel |
234
|
$favBrand = UserData::favoriteBrandData($uid, $gender, $page, $limit);
|
251
|
$favBrand = UserData::favoriteBrandData($uid, $gender, $page, $limit);
|
235
|
|
252
|
|
236
|
// 处理用户收藏的品牌数据
|
253
|
// 处理用户收藏的品牌数据
|
237
|
- if (isset($favBrand['data']) && $page <= $favBrand['data']['page_total']) {
|
|
|
238
|
- $datas = array();
|
|
|
239
|
- $brand = array();
|
|
|
240
|
- foreach ($favBrand['data']['brand_list'] as $val) {
|
|
|
241
|
- $brand = array();
|
|
|
242
|
- $brand['id'] = $val['brand_id'];
|
|
|
243
|
- $brand['brandImg'] = !empty($val['brand_ico']) ? Images::getImageUrl($val['brand_ico'], 47, 47) : '';
|
|
|
244
|
- $brand['brandName'] = $val['brand_name'];
|
|
|
245
|
- $brand['update'] = $val['new_product_num'];
|
|
|
246
|
- $brand['discount'] = $val['product_discount_num'];
|
|
|
247
|
- $brand['link'] = Helpers::url('', array(), $val['brand_domain']);
|
|
|
248
|
-
|
|
|
249
|
- // 处理品牌产品
|
|
|
250
|
- $product = array();
|
|
|
251
|
- foreach ($val['new_product'] as $one) {
|
|
|
252
|
- if (empty($one['product_skn'])) {
|
|
|
253
|
- continue;
|
|
|
254
|
- }
|
254
|
+ do {
|
|
|
255
|
+ // 开始就没获取到数据或者获取的数据为空时的处理
|
|
|
256
|
+ if (!isset($favBrand['data']['brand_list']) && $page == 1) {
|
|
|
257
|
+ break;
|
|
|
258
|
+ }
|
255
|
|
259
|
|
|
|
260
|
+ // 加载第二页以及第二页之后的数据时接口不返回时的处理
|
|
|
261
|
+ if ($page > 1 && !$favBrand) {
|
|
|
262
|
+ $result['end'] = true;
|
|
|
263
|
+ break;
|
|
|
264
|
+ }
|
|
|
265
|
+
|
|
|
266
|
+ if ($page <= $favBrand['data']['page_total']) {
|
|
|
267
|
+ $datas = array();
|
|
|
268
|
+ $brand = array();
|
|
|
269
|
+ foreach ($favBrand['data']['brand_list'] as $val) {
|
|
|
270
|
+ $brand = array();
|
|
|
271
|
+ $brand['id'] = $val['brand_id'];
|
|
|
272
|
+ $brand['brandImg'] = !empty($val['brand_ico']) ? Images::getImageUrl($val['brand_ico'], 47, 47) : '';
|
|
|
273
|
+ $brand['brandName'] = $val['brand_name'];
|
|
|
274
|
+ $brand['update'] = $val['new_product_num'];
|
|
|
275
|
+ $brand['discount'] = $val['product_discount_num'];
|
|
|
276
|
+ $brand['link'] = Helpers::url('', array(), $val['brand_domain']);
|
|
|
277
|
+
|
|
|
278
|
+ // 处理品牌产品
|
256
|
$product = array();
|
279
|
$product = array();
|
257
|
- $product['link'] = isset($one['goods'][0], $one['cnAlphabet']) ? Helpers::url('/product/pro_' . $one['product_id'] . '_' . $one['goods'][0]['id'] . '/' . $one['cnAlphabet'] . '.html') : '';
|
|
|
258
|
- $product['imgUrl'] = (isset($one['default_images']) && !empty($one['default_images'])) ? Images::getImageUrl($one['default_images'], 235, 314) : '';
|
|
|
259
|
- $product['price'] = '¥' . Helpers::transPrice($one['market_price']);
|
|
|
260
|
- $product['discount'] = ($one['market_price'] > $one['sales_price']) ? '¥' . Helpers::transPrice($one['sales_price']) : false;
|
280
|
+ foreach ($val['new_product'] as $one) {
|
|
|
281
|
+ if (empty($one['product_skn'])) {
|
|
|
282
|
+ continue;
|
|
|
283
|
+ }
|
|
|
284
|
+
|
|
|
285
|
+ $product = array();
|
|
|
286
|
+ $product['link'] = isset($one['goods'][0], $one['cnAlphabet']) ? Helpers::url('/product/pro_' . $one['product_id'] . '_' . $one['goods'][0]['id'] . '/' . $one['cnAlphabet'] . '.html') : '';
|
|
|
287
|
+ $product['imgUrl'] = (isset($one['default_images']) && !empty($one['default_images'])) ? Images::getImageUrl($one['default_images'], 235, 314) : '';
|
|
|
288
|
+ $product['price'] = '¥' . Helpers::transPrice($one['market_price']);
|
|
|
289
|
+ $product['discount'] = ($one['market_price'] > $one['sales_price']) ? '¥' . Helpers::transPrice($one['sales_price']) : false;
|
|
|
290
|
+
|
|
|
291
|
+ $brand['productList'][] = $product;
|
|
|
292
|
+ }
|
261
|
|
293
|
|
262
|
- $brand['productList'][] = $product;
|
294
|
+ $datas[] = $brand;
|
263
|
}
|
295
|
}
|
264
|
|
296
|
|
265
|
- $datas[] = $brand;
|
297
|
+ if (!empty($datas)) {
|
|
|
298
|
+ $result['hasFavBrand'] = $datas;
|
|
|
299
|
+ }
|
|
|
300
|
+ } else {
|
|
|
301
|
+ $result['end'] = true;
|
266
|
}
|
302
|
}
|
267
|
- !empty($datas) && $result['hasFavBrand'] = $datas;
|
|
|
268
|
- } else if (($page > 1 && !$favBrand) || $page > $favBrand['data']['page_total']) {
|
|
|
269
|
- $result['end'] = true;
|
|
|
270
|
- }
|
303
|
+ } while (false);
|
271
|
|
304
|
|
272
|
return $result;
|
305
|
return $result;
|
273
|
}
|
306
|
}
|