diff --git a/alipay/app.acss b/alipay/app.acss index c5895806b..56008a9f0 100755 --- a/alipay/app.acss +++ b/alipay/app.acss @@ -205,14 +205,23 @@ textarea { width: 100%; } +.bg-main, .bg-primary, .bg-warning { + color: #fff; + border: 0; + font-size: 34rpx; +} .bg-main { - background: #d2364c; - color: #fff; - border: 0; + background: #d2364c; +} +.bg-primary { + background: #ed6977; +} +.bg-warning { + background: #F37B1D; } .bg-active-main { - background: #d2364c !important; - color: #fff !important; + background: #d2364c !important; + color: #fff !important; } .submit-bottom { diff --git a/alipay/images/address-select-active-icon.png b/alipay/images/address-select-active-icon.png deleted file mode 100755 index 1e0624d65..000000000 Binary files a/alipay/images/address-select-active-icon.png and /dev/null differ diff --git a/alipay/images/address-select-icon.png b/alipay/images/address-select-icon.png deleted file mode 100755 index 5b5e42b50..000000000 Binary files a/alipay/images/address-select-icon.png and /dev/null differ diff --git a/alipay/images/default-cart-empty.png b/alipay/images/default-cart-empty.png new file mode 100644 index 000000000..b7a0596c2 Binary files /dev/null and b/alipay/images/default-cart-empty.png differ diff --git a/alipay/images/default-select-active-icon.png b/alipay/images/default-select-active-icon.png new file mode 100644 index 000000000..12dfcfe38 Binary files /dev/null and b/alipay/images/default-select-active-icon.png differ diff --git a/alipay/images/default-select-icon.png b/alipay/images/default-select-icon.png new file mode 100644 index 000000000..466c0ebc0 Binary files /dev/null and b/alipay/images/default-select-icon.png differ diff --git a/alipay/pages/cart/cart.acss b/alipay/pages/cart/cart.acss index 54933fa5b..b6a71e18b 100644 --- a/alipay/pages/cart/cart.acss +++ b/alipay/pages/cart/cart.acss @@ -1,13 +1,16 @@ /** * 商品列表 */ -.goods-title { - line-height: 36rpx; + .page { + padding-bottom: 120rpx; } .goods-item { padding: 20rpx 10rpx; position: relative; } +.goods-title { + line-height: 36rpx; +} .goods-item:not(:last-child) { border-bottom: 1px solid #eee; } @@ -28,6 +31,12 @@ .buy-number { margin-left: 20rpx; } +.goods-item .items { + padding-left: 80rpx; +} +.goods-item .selected { + margin-top: 60rpx; +} /** * 数量操作 @@ -35,7 +44,7 @@ .number-content { position: absolute; right: 20rpx; - top: 120rpx; + top: 100rpx; } .number-content button { @@ -57,4 +66,67 @@ { border: 1px solid #ddd; padding: 0; +} + +/** + * 空购物车 + */ +.no-data-box { + padding: 30% 0 0 0; +} +.no-data-box image { + width: 160rpx; + margin-bottom: 20rpx; +} +.no-data-box .no-data-tips { + font-size: 28rpx; + color: #a6a6a6; +} +.no-data-box button { + margin: 0 auto; + width: 220rpx; + height: 60rpx; + line-height: 60rpx; + font-size: 28rpx; + margin-top: 30rpx; +} + +/** + * 操作导航 + */ +.buy-nav { + position: fixed; + left: 0; + bottom: 0; +} +.buy-nav, .nav-base, .nav-submit button { + height: 100rpx; +} +.nav-base, .nav-submit button { + line-height: 100rpx; +} +.nav-base { + width: calc(75% - 20rpx); + padding: 0 10rpx; +} +.nav-submit { + width: 25%; +} +.nav-submit button { + border-radius: 0; +} +.page { + padding-bottom: 120rpx; +} +.selected .icon { + width: 50rpx; + height: 50rpx !important; + margin: 0 10rpx; + vertical-align: middle; +} +.buy-nav .price { + width: calc(100% - 140rpx); +} +.buy-nav .sales-price { + max-width: calc(100% - 40px); } \ No newline at end of file diff --git a/alipay/pages/cart/cart.axml b/alipay/pages/cart/cart.axml index ed624547a..ced969448 100644 --- a/alipay/pages/cart/cart.axml +++ b/alipay/pages/cart/cart.axml @@ -1,29 +1,72 @@ - - - - - - - - - {{item.title}} - - - {{attr.attr_type_name}}:{{attr.attr_name}} + + + + + + + - - - - - - - + + + + + + + + + + {{item.title}} + + + {{attr.attr_type_name}}:{{attr.attr_name}} + + + + + + + + + + + + ¥{{item.price}} + ¥{{item.original_price}} + x{{item.stock}} + + + - - - ¥{{item.price}} - ¥{{item.original_price}} - x{{item.stock}} + + + + + + + 全选 + + + ¥{{total_price}} + 合计: + + + + + - \ No newline at end of file + + + + + 购物车空空如也 + + + + + + + + \ No newline at end of file diff --git a/alipay/pages/cart/cart.js b/alipay/pages/cart/cart.js index f296880c2..5e7d51141 100644 --- a/alipay/pages/cart/cart.js +++ b/alipay/pages/cart/cart.js @@ -5,7 +5,9 @@ Page({ data_list_loding_msg: '', data_bottom_line_status: false, data_list: [], - value: 8, + swipe_index: null, + total_price: 0, + is_selected_all: false, }, onShow() { @@ -13,7 +15,33 @@ Page({ this.init(); }, - init() { + init(e) { + var user = app.GetUserInfo(this, "init"); + if (user != false) { + // 用户未绑定用户则转到登录页面 + if ((user.mobile || null) == null) { + my.confirm({ + title: '温馨提示', + content: '绑定手机号码', + confirmButtonText: '确认', + cancelButtonText: '暂不', + success: (result) => { + if (result.confirm) { + my.navigateTo({ + url: "/pages/login/login?event_callback=init" + }); + } + this.get_data(); + }, + }); + } else { + this.get_data(); + } + } + }, + + // 获取数据 + get_data() { this.setData({ data_list_loding_status: 1 }); @@ -25,15 +53,21 @@ Page({ dataType: "json", success: res => { my.stopPullDownRefresh(); - if (res.data.code == 0) { + if (res.data.code == 0) { + var data = res.data.data; + if (data.length > 0) { + for (var i in data) { + data[i]['right'] = [{ type: 'edit', text: '收藏' }, { type: 'delete', text: '删除' }]; + } + } this.setData({ - data_list: res.data.data, - data_list_loding_status: 3, + data_list: data, + data_list_loding_status: data.length == 0 ? 0 : 3, data_bottom_line_status: true, data_list_loding_msg: '', }); } else { - self.setData({ + this.setData({ data_list_loding_status: 2, data_bottom_line_status: false, data_list_loding_msg: res.data.msg, @@ -46,7 +80,7 @@ Page({ }, fail: () => { my.stopPullDownRefresh(); - self.setData({ + this.setData({ data_list_loding_status: 2, data_bottom_line_status: false, data_list_loding_msg: '服务器请求出错', @@ -88,10 +122,10 @@ Page({ // 数量处理方法 goods_buy_number_func(index, buy_number) { var temp_data_list = this.data.data_list; - var buy_min_number = parseInt(temp_data_list['buy_min_number']) || 1; - var buy_max_number = parseInt(temp_data_list['buy_max_number']) || 0; - var inventory = parseInt(temp_data_list['inventory']); - var inventory_unit = temp_data_list['inventory_unit']; + var buy_min_number = parseInt(temp_data_list[index]['buy_min_number']) || 1; + var buy_max_number = parseInt(temp_data_list[index]['buy_max_number']) || 0; + var inventory = parseInt(temp_data_list[index]['inventory']); + var inventory_unit = temp_data_list[index]['inventory_unit']; if (buy_number < buy_min_number) { buy_number = buy_min_number; if (buy_min_number > 1) { @@ -142,4 +176,136 @@ Page({ }); }, + // 滑动操作 + right_item_event(e) { + var type = e.detail.type; + var index = e.extra; + var id = this.data.data_list[index]['id']; + var goods_id = this.data.data_list[index]['goods_id']; + + // 收藏 + if (type == 'edit') { + this.goods_favor_event(id, goods_id, type); + } else { + my.confirm({ + title: '温馨提示', + content: '删除后不可恢复,确定继续吗?', + confirmButtonText: '确定', + cancelButtonText: '取消', + success: (result) => { + if (result.confirm) { + this.cart_delete(id, type); + } else { + this.setData({ swipe_index: null }); + } + } + }); + } + }, + + // 滑动操作 + swipe_start_event(e) { + this.setData({ swipe_index: e.index }); + }, + + // 收藏事件 + goods_favor_event(id, goods_id, type) { + my.httpRequest({ + url: app.get_request_url('Favor', 'Goods'), + method: 'POST', + data: { "id": goods_id, "is_mandatory_favor": 1 }, + dataType: 'json', + success: (res) => { + if (res.data.code == 0) { + this.cart_delete(id, type); + } else { + my.showToast({ + type: 'fail', + content: res.data.msg + }); + } + }, + fail: () => { + my.showToast({ + type: 'fail', + content: '服务器请求出错' + }); + } + }); + }, + + // 购物车删除 + cart_delete(id, type) { + my.httpRequest({ + url: app.get_request_url('Delete', 'Cart'), + method: 'POST', + data: { "id": id }, + dataType: 'json', + success: (res) => { + if (res.data.code == 0) { + var temp_data_list = this.data.data_list; + temp_data_list.splice(this.data.swipe_index, 1); + this.setData({ + data_list: temp_data_list, + swipe_index: null, + data_list_loding_status: temp_data_list.length == 0 ? 0 : this.data.data_list_loding_status, + }); + + my.showToast({ + type: 'success', + content: (type == 'delete') ? '删除成功' : '收藏成功' + }); + } else { + my.showToast({ + type: 'fail', + content: (type == 'delete') ? '删除失败' : '收藏失败' + }); + } + }, + fail: () => { + my.showToast({ + type: 'fail', + content: '服务器请求出错' + }); + } + }); + }, + + // 选中处理 + selectedt_event(e) { + var type = e.currentTarget.dataset.type || null; + + if (type != null) + { + var temp_data_list = this.data.data_list; + var temp_is_selected_all = this.data.is_selected_all; + var total_price = 0; + switch(type) { + case 'all' : + temp_is_selected_all = (temp_is_selected_all == true) ? false : true; + for (var i in temp_data_list) { + temp_data_list[i]['selected'] = temp_is_selected_all; + } + break; + + case 'node' : + var index = e.currentTarget.dataset.index || 0; + temp_data_list[index]['selected'] = (temp_data_list[index]['selected'] == true) ? false : true; + break; + } + + for (var i in temp_data_list) { + if ((temp_data_list[i]['selected'] || false) == true) { + total_price += temp_data_list[i]['stock'] * temp_data_list[i]['price']; + } + } + + this.setData({ + data_list: temp_data_list, + is_selected_all: temp_is_selected_all, + total_price: total_price.toFixed(2), + }) + } + } + }); diff --git a/alipay/pages/cart/cart.json b/alipay/pages/cart/cart.json index c96031fd7..43d0cc198 100644 --- a/alipay/pages/cart/cart.json +++ b/alipay/pages/cart/cart.json @@ -1,3 +1,7 @@ { - "pullRefresh": true + "pullRefresh": true, + "usingComponents": { + "list-item": "mini-antui/es/list/list-item/index", + "swipe-action": "mini-antui/es/swipe-action/index" + } } \ No newline at end of file diff --git a/alipay/pages/goods-attribute/goods-attribute.axml b/alipay/pages/goods-attribute/goods-attribute.axml index 7fc414e6b..3fe902e10 100755 --- a/alipay/pages/goods-attribute/goods-attribute.axml +++ b/alipay/pages/goods-attribute/goods-attribute.axml @@ -11,7 +11,7 @@ - + diff --git a/alipay/pages/goods-category/goods-category.axml b/alipay/pages/goods-category/goods-category.axml index 626b33040..cbe23423b 100644 --- a/alipay/pages/goods-category/goods-category.axml +++ b/alipay/pages/goods-category/goods-category.axml @@ -10,7 +10,7 @@ - + {{v.name}} diff --git a/alipay/pages/goods-category/goods-category.js b/alipay/pages/goods-category/goods-category.js index 0a81655ba..455872a2e 100644 --- a/alipay/pages/goods-category/goods-category.js +++ b/alipay/pages/goods-category/goods-category.js @@ -7,16 +7,11 @@ Page({ data_list_loding_status: 1, data_bottom_line_status: false, data_list: [], - params: null, - }, - - onLoad(params) { - this.setData({params: params}); - this.init(); }, onShow() { my.setNavigationBar({title: app.data.common_pages_title.goods_category}); + this.init(); }, // 获取数据 @@ -30,7 +25,7 @@ Page({ my.httpRequest({ url: app.get_request_url("GoodsCategory", "Resources"), method: "POST", - data: this.data.params, + data: {}, dataType: "json", success: res => { my.stopPullDownRefresh(); diff --git a/alipay/pages/goods-detail/goods-detail.acss b/alipay/pages/goods-detail/goods-detail.acss index 908da9648..0c8150f47 100755 --- a/alipay/pages/goods-detail/goods-detail.acss +++ b/alipay/pages/goods-detail/goods-detail.acss @@ -109,15 +109,15 @@ height: 100rpx; } .goods-buy-nav .fl { - width: calc(25% - 1rpx); + width: calc(20% - 1rpx); } .goods-buy-nav .fr { - width: 50%; + width: 60%; } .goods-buy-nav .fr button { - border: 0; border-radius: 0; line-height: 100rpx; + width: 50%; } .goods-buy-nav .fr button, .goods-buy-nav .fl diff --git a/alipay/pages/goods-detail/goods-detail.axml b/alipay/pages/goods-detail/goods-detail.axml index 4182eaf58..7e700df46 100755 --- a/alipay/pages/goods-detail/goods-detail.axml +++ b/alipay/pages/goods-detail/goods-detail.axml @@ -71,7 +71,8 @@ {{goods_favor_text}} - + + diff --git a/alipay/pages/goods-detail/goods-detail.js b/alipay/pages/goods-detail/goods-detail.js index bc1f01bec..5c090a8f9 100755 --- a/alipay/pages/goods-detail/goods-detail.js +++ b/alipay/pages/goods-detail/goods-detail.js @@ -22,10 +22,11 @@ Page({ goods_favor_icon: '/images/goods-detail-favor-icon-0.png', temp_attribute_active: {}, temp_buy_number: 1, + buy_event_type: 'buy', }, onLoad(params) { - //params['goods_id']=1; + //params['goods_id']=16; this.setData({params: params}); this.init(); }, @@ -70,16 +71,16 @@ Page({ if (res.data.code == 0) { var data = res.data.data; self.setData({ - goods: data.goods, + goods: data, indicator_dots: (data.photo.length > 1), autoplay: (data.photo.length > 1), goods_photo: data.photo, goods_attribute_show: data.attribute.show || [], goods_attribute_choose: data.attribute.choose || [], goods_content_app: data.content_app, - temp_buy_number: (data.goods.buy_min_number) || 1, - goods_favor_text: (data.goods.is_favor == 1) ? '已收藏' : '收藏', - goods_favor_icon: '/images/goods-detail-favor-icon-'+data.goods.is_favor+'.png', + temp_buy_number: (data.buy_min_number) || 1, + goods_favor_text: (data.is_favor == 1) ? '已收藏' : '收藏', + goods_favor_icon: '/images/goods-detail-favor-icon-'+data.is_favor+'.png', data_bottom_line_status: true, data_list_loding_status: 3, }); @@ -134,9 +135,14 @@ Page({ }); }, + // 加入购物车 + cart_submit_event(e) { + this.setData({ popup_status: '', buy_event_type: 'cart' }); + }, + // 立即购买 buy_submit_event(e) { - this.setData({popup_status: ''}); + this.setData({ popup_status: '', buy_event_type: 'buy'}); }, // 收藏事件 @@ -151,19 +157,18 @@ Page({ }); return false; } else { - var self = this; my.showLoading({content: '处理中...'}); my.httpRequest({ url: app.get_request_url('Favor', 'Goods'), method: 'POST', - data: {goods_id: self.data.goods.id}, + data: {"id": this.data.goods.id}, dataType: 'json', success: (res) => { my.hideLoading(); if(res.data.code == 0) { - var status = (self.data.goods.is_favor == 1) ? 0 : 1; + var status = (this.data.goods.is_favor == 1) ? 0 : 1; this.setData({ 'goods.is_favor': status, goods_favor_text: (status == 1) ? '已收藏' : '收藏', @@ -193,6 +198,61 @@ Page({ } }, + // 加入购物车事件 + goods_cart_event(e) { + var user = app.GetUserInfo(this, 'goods_cart_event'); + if (user != false) { + // 用户未绑定用户则转到登录页面 + if ((user.mobile || null) == null) { + my.navigateTo({ + url: "/pages/login/login?event_callback=init" + }); + return false; + } else { + var attribute_all_cart = {}; + var temp_attribute_active = this.data.temp_attribute_active; + if (app.get_length(temp_attribute_active) > 0) + { + var goods_attribute_choose = this.data.goods_attribute_choose; + for (var i in temp_attribute_active) { + attribute_all_cart[goods_attribute_choose[i]['id']] = goods_attribute_choose[i]['find'][temp_attribute_active[i]]['id']; + } + } + my.showLoading({ content: '处理中...' }); + + my.httpRequest({ + url: app.get_request_url('Save', 'Cart'), + method: 'POST', + data: { "goods_id": this.data.goods.id, "stock": this.data.temp_buy_number, "attr": JSON.stringify(attribute_all_cart) }, + dataType: 'json', + success: (res) => { + my.hideLoading(); + if (res.data.code == 0) { + this.popup_close_event(); + my.showToast({ + type: 'success', + content: res.data.msg + }); + } else { + my.showToast({ + type: 'fail', + content: res.data.msg + }); + } + }, + fail: () => { + my.hideLoading(); + + my.showToast({ + type: 'fail', + content: '服务器请求出错' + }); + } + }); + } + } + }, + // 属性事件 goods_attribute_event(e) { var key = e.currentTarget.dataset.key || 0; @@ -256,7 +316,7 @@ Page({ this.setData({temp_buy_number: buy_number}); }, - // 购买确认 + // 确认 goods_buy_confirm_event(e) { var user = app.GetUserInfo(this, 'goods_buy_confirm_event'); if (user != false) { @@ -289,20 +349,37 @@ Page({ } } } + + // 操作类型 + switch (this.data.buy_event_type) { + case 'buy' : + // 进入订单确认页面 + var data = [{ + "goods_id": this.data.goods.id, + "buy_number": this.data.temp_buy_number, + "attribute": attribute_all.join(',') + }] + my.navigateTo({ + url: '/pages/buy/buy?data=' + JSON.stringify(data) + }); + break; - // 进入订单确认页面 - var data = [{ - "goods_id": this.data.goods.id, - "buy_number": this.data.temp_buy_number, - "attribute": attribute_all.join(',') - }] - my.navigateTo({ - url: '/pages/buy/buy?data='+JSON.stringify(data) - }); + case 'cart' : + this.goods_cart_event(); + break; + + default : + my.showToast({ + type: "fail", + content: "操作事件类型有误" + }); + } } } }, + + // 详情图片查看 goods_detail_images_view_event(e) { var value = e.currentTarget.dataset.value || null; diff --git a/alipay/pages/goods-search/goods-search.axml b/alipay/pages/goods-search/goods-search.axml index 13112bc5f..78b1a04b2 100755 --- a/alipay/pages/goods-search/goods-search.axml +++ b/alipay/pages/goods-search/goods-search.axml @@ -16,9 +16,9 @@ - - - + + + diff --git a/alipay/pages/user-address/user-address.axml b/alipay/pages/user-address/user-address.axml index 8ba1f3227..0c390c79e 100755 --- a/alipay/pages/user-address/user-address.axml +++ b/alipay/pages/user-address/user-address.axml @@ -13,8 +13,8 @@ - - + + 设为默认地址 diff --git a/service/Application/Admin/Controller/GoodsController.class.php b/service/Application/Admin/Controller/GoodsController.class.php index ec5bf22a1..c917aa3ec 100755 --- a/service/Application/Admin/Controller/GoodsController.class.php +++ b/service/Application/Admin/Controller/GoodsController.class.php @@ -102,7 +102,7 @@ class GoodsController extends CommonController $v['category_text'] = implode(',', $category_name); // 产地 - $v['place_origin_text'] = M('Region')->where(['id'=>$v['place_origin']])->getField('name'); + $v['place_origin_name'] = ResourcesService::RegionName($v['place_origin']); // 品牌 $v['brand_name'] = empty($v['brand_id']) ? null : M('Brand')->where(['id'=>$v['brand_id']])->getField('name'); diff --git a/service/Application/Admin/Lang/zh-cn/goods.php b/service/Application/Admin/Lang/zh-cn/goods.php index 37df73c4a..30ddd3962 100755 --- a/service/Application/Admin/Lang/zh-cn/goods.php +++ b/service/Application/Admin/Lang/zh-cn/goods.php @@ -21,7 +21,7 @@ return array( 'goods_category_id_text' => '商品分类', 'goods_category_id_format' => '请至少选择一个商品分类', - 'goods_place_origin_text' => '生产地', + 'goods_place_origin_name' => '生产地', 'goods_place_origin_format' => '请选择生产地', 'goods_inventory_text' => '库存数量', diff --git a/service/Application/Admin/View/Default/Goods/Index.html b/service/Application/Admin/View/Default/Goods/Index.html index 9cec81f8f..cdb6a2389 100755 --- a/service/Application/Admin/View/Default/Goods/Index.html +++ b/service/Application/Admin/View/Default/Goods/Index.html @@ -123,8 +123,8 @@
{{:L('goods_brand_id_text')}}
{{$v.brand_name}}
-
{{:L('goods_place_origin_text')}}
-
{{$v.place_origin_text}}
+
{{:L('goods_place_origin_name')}}
+
{{$v.place_origin_name}}
{{:L('goods_category_id_text')}}
{{$v.category_text}}
diff --git a/service/Application/Admin/View/Default/Goods/SaveInfo.html b/service/Application/Admin/View/Default/Goods/SaveInfo.html index d4b4f5238..cd27d0aae 100755 --- a/service/Application/Admin/View/Default/Goods/SaveInfo.html +++ b/service/Application/Admin/View/Default/Goods/SaveInfo.html @@ -98,7 +98,7 @@
- +