From 8fa76bed6763b1de8d1c14d955c65e40d7a42cc5 Mon Sep 17 00:00:00 2001 From: devil Date: Sun, 9 Aug 2020 22:57:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BE=E5=BA=A6=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/goods-detail/goods-detail.axml | 2 +- .../user-order-detail/user-order-detail.axml | 7 +- sourcecode/baidu/app.js | 2 +- sourcecode/baidu/pages/buy/buy.css | 39 ++- sourcecode/baidu/pages/buy/buy.js | 113 +++++--- sourcecode/baidu/pages/buy/buy.swan | 272 +++++++++--------- .../pages/goods-category/goods-category.css | 137 +++++---- .../pages/goods-category/goods-category.js | 57 ++-- .../pages/goods-category/goods-category.json | 3 +- .../pages/goods-category/goods-category.swan | 96 +++++-- .../pages/goods-detail/goods-detail.swan | 2 +- sourcecode/baidu/pages/paytips/paytips.js | 1 - sourcecode/baidu/pages/paytips/paytips.swan | 4 - .../user-order-detail/user-order-detail.js | 41 +-- .../baidu/pages/user-order/user-order.css | 181 ++++++------ .../baidu/pages/user-order/user-order.js | 171 ++++++----- .../baidu/pages/user-order/user-order.swan | 18 +- .../pages/goods-detail/goods-detail.wxml | 2 +- 18 files changed, 681 insertions(+), 467 deletions(-) diff --git a/sourcecode/alipay/pages/goods-detail/goods-detail.axml b/sourcecode/alipay/pages/goods-detail/goods-detail.axml index be262691b..ba5336124 100644 --- a/sourcecode/alipay/pages/goods-detail/goods-detail.axml +++ b/sourcecode/alipay/pages/goods-detail/goods-detail.axml @@ -73,7 +73,7 @@ - {{price_symbol}} + {{price_symbol}} {{item.discount_value}} {{item.type_unit}} diff --git a/sourcecode/alipay/pages/user-order-detail/user-order-detail.axml b/sourcecode/alipay/pages/user-order-detail/user-order-detail.axml index 2f7aecfec..2acefa070 100644 --- a/sourcecode/alipay/pages/user-order-detail/user-order-detail.axml +++ b/sourcecode/alipay/pages/user-order-detail/user-order-detail.axml @@ -81,11 +81,14 @@ - - + + 扩展数据 + + {{item.name}} {{item.tips}} + diff --git a/sourcecode/baidu/app.js b/sourcecode/baidu/app.js index 4578d5736..78c83e039 100755 --- a/sourcecode/baidu/app.js +++ b/sourcecode/baidu/app.js @@ -68,7 +68,7 @@ App({ // 请求地址 request_url: "{{request_url}}", request_url: 'http://shopxo.com/', - // request_url: 'https://dev.shopxo.net/', + request_url: 'https://dev.shopxo.net/', // 基础信息 application_title: "{{application_title}}", diff --git a/sourcecode/baidu/pages/buy/buy.css b/sourcecode/baidu/pages/buy/buy.css index 937284f4c..99657b11f 100755 --- a/sourcecode/baidu/pages/buy/buy.css +++ b/sourcecode/baidu/pages/buy/buy.css @@ -41,14 +41,40 @@ /** * 商品 */ -.goods .goods-item:not(:last-child) { +.goods-group-list .goods-item:not(:last-child) { border-bottom: 1px dashed #efefef; } -.goods-item { - padding: 20rpx 10rpx; +.goods-group-list { + padding: 0 10rpx 10rpx 10rpx; +} +.goods-group-hd { + padding: 20rpx 0; +} +.goods-group-title { + font-weight: bold; + vertical-align: middle; +} +.goods-group-alias { + border: 1px solid #3bb4f2; + color: #3bb4f2; + padding: 2rpx 10rpx; + border-radius: 6rpx; + margin-left: 10rpx; +} +.goods-group-footer .original-price { + margin-right: 10rpx; +} +.goods-group-map-submit { + font-size: 24rpx; + padding: 5rpx 20rpx; + background: #f0f0f0; + border-radius: 6rpx; } .goods-title, .goods-spec { - margin-bottom: 10rpx; + margin-bottom: 5rpx; +} +.goods-item { + padding: 10rpx 0; } .goods-image { width: 160rpx; @@ -119,6 +145,7 @@ */ .extension-list { background-color: #ffffeb; + border: 1px solid #ffe2cf; } .extension-list .item { padding: 20rpx 10rpx; @@ -136,10 +163,10 @@ .content-textarea-view, .content-textarea-view textarea { height: 180rpx; + padding: 5rpx; } -.content-textarea-view textarea, .content-textarea-view view { - padding: 10rpx; + padding: 12rpx; } /** diff --git a/sourcecode/baidu/pages/buy/buy.js b/sourcecode/baidu/pages/buy/buy.js index be9f6c58c..5e883655a 100755 --- a/sourcecode/baidu/pages/buy/buy.js +++ b/sourcecode/baidu/pages/buy/buy.js @@ -19,16 +19,14 @@ Page({ common_site_type: 0, extraction_address: [], site_model: 0, - buy_header_nav: [ - { name: "快递邮寄", value: 0 }, - { name: "自提点取货", value: 2 } - ], + buy_header_nav: [{ name: "快递邮寄", value: 0 }, { name: "自提点取货", value: 2 }], // 优惠劵 plugins_coupon_data: null, - plugins_use_coupon_id: 0, - plugins_choice_coupon_value: '选择优惠劵', - popup_plugins_coupon_status: false + plugins_use_coupon_ids: [], + plugins_choice_coupon_value: [], + popup_plugins_coupon_status: false, + popup_plugins_coupon_index: null }, onLoad(params) { //params['data'] = '{"buy_type":"goods","goods_id":"1","stock":"1","spec":"[]"}'; @@ -63,7 +61,7 @@ Page({ if ((cache_address || null) != null) { this.setData({ address: cache_address, - address_id: cache_address.id, + address_id: cache_address.id }); } } @@ -77,12 +75,11 @@ Page({ var data = this.data.params; data['address_id'] = this.data.address_id; data['payment_id'] = this.data.payment_id; - data['coupon_id'] = this.data.plugins_use_coupon_id; data['site_model'] = this.data.site_model; swan.request({ url: app.get_request_url("index", "buy"), method: "POST", - data: data, + data: this.request_data_coupon_merge(data), dataType: "json", success: res => { swan.stopPullDownRefresh(); @@ -105,18 +102,23 @@ Page({ // 优惠劵选择处理 if ((data.plugins_coupon_data || null) != null) { - if ((data.plugins_coupon_data.coupon_choice || null) != null) { - this.setData({ plugins_choice_coupon_value: data.plugins_coupon_data.coupon_choice.coupon.desc }); - } else { - var coupon_count = (data.plugins_coupon_data.coupon_list || null) != null ? data.plugins_coupon_data.coupon_list.length : 0; - this.setData({ plugins_choice_coupon_value: coupon_count > 0 ? '可选优惠劵' + coupon_count + '张' : '暂无可用优惠劵' }); + var plugins_choice_coupon_value = []; + for (var i in data.plugins_coupon_data) { + var cupk = data.plugins_coupon_data[i]['warehouse_id']; + if ((data.plugins_coupon_data[i]['coupon_data']['coupon_choice'] || null) != null) { + plugins_choice_coupon_value[cupk] = data.plugins_coupon_data[i]['coupon_data']['coupon_choice']['desc']; + } else { + var coupon_count = (data.plugins_coupon_data[i]['coupon_data']['coupon_list'] || null) != null ? data.plugins_coupon_data[i]['coupon_data'].coupon_list.length : 0; + plugins_choice_coupon_value[cupk] = coupon_count > 0 ? '可选优惠劵' + coupon_count + '张' : '暂无可用优惠劵'; + } } + this.setData({ plugins_choice_coupon_value: plugins_choice_coupon_value }); } // 地址 this.setData({ address: data.base.address || null, - address_id: ((data.base.address || null) != null) ? data.base.address.id : null + address_id: (data.base.address || null) != null ? data.base.address.id : null }); swan.setStorage({ key: app.data.cache_buy_user_address_select_key, @@ -149,6 +151,17 @@ Page({ }); }, + // 请求参数合并优惠券参数 + request_data_coupon_merge(data) { + var coupon_ids = this.data.plugins_use_coupon_ids; + if ((coupon_ids || null) != null && coupon_ids.length > 0) { + for (var i in coupon_ids) { + data['coupon_id_' + i] = coupon_ids[i]; + } + } + return data; + }, + // 下拉刷新 onPullDownRefresh() { this.init(); @@ -166,7 +179,6 @@ Page({ data['address_id'] = this.data.address_id; data['payment_id'] = this.data.payment_id; data['user_note'] = this.data.user_note_value; - data['coupon_id'] = this.data.plugins_use_coupon_id; data['site_model'] = this.data.site_model; // 数据验证 @@ -177,6 +189,7 @@ Page({ if (this.data.common_order_is_booking != 1) { validation.push({ fields: 'payment_id', msg: '请选择支付方式' }); } + if (app.fields_check(data, validation)) { // 加载loding swan.showLoading({ title: '提交中...' }); @@ -185,14 +198,14 @@ Page({ swan.request({ url: app.get_request_url("add", "buy"), method: "POST", - data: data, + data: this.request_data_coupon_merge(data), dataType: "json", success: res => { swan.hideLoading(); if (res.data.code == 0) { - if (res.data.data.order.status == 1) { + if (res.data.data.order_status == 1) { swan.redirectTo({ - url: '/pages/user-order/user-order?is_pay=1&order_id=' + res.data.data.order.id + url: '/pages/user-order/user-order?is_pay=1&order_ids=' + res.data.data.order_ids.join(',') }); } else { swan.redirectTo({ url: '/pages/user-order/user-order' }); @@ -205,7 +218,6 @@ Page({ fail: () => { swan.hideLoading(); this.setData({ buy_submit_disabled_status: false }); - app.showToast("服务器请求出错"); } }); @@ -235,7 +247,11 @@ Page({ // 优惠劵弹层开启 plugins_coupon_open_event(e) { - this.setData({ popup_plugins_coupon_status: true }); + var index = e.currentTarget.dataset.index; + this.setData({ + popup_plugins_coupon_status: true, + popup_plugins_coupon_index: index + }); }, // 优惠劵弹层关闭 @@ -245,19 +261,27 @@ Page({ // 优惠劵选择 plugins_coupon_use_event(e) { - var index = e.currentTarget.dataset.index; + var wid = e.currentTarget.dataset.wid; var value = e.currentTarget.dataset.value; - this.setData({ - plugins_use_coupon_id: value, - popup_plugins_coupon_status: false - }); - this.init(); + var temp = this.data.plugins_use_coupon_ids; + // 是否已选择优惠券id + if (temp.indexOf(value) == -1) { + temp[wid] = value; + this.setData({ + plugins_use_coupon_ids: temp, + popup_plugins_coupon_status: false + }); + this.init(); + } }, // 不使用优惠劵 plugins_coupon_not_use_event(e) { + var wid = e.currentTarget.dataset.wid; + var temp = this.data.plugins_use_coupon_ids; + temp[wid] = 0; this.setData({ - plugins_use_coupon_id: 0, + plugins_use_coupon_ids: temp, popup_plugins_coupon_status: false }); this.init(); @@ -265,11 +289,11 @@ Page({ // 地址选择事件 address_event(e) { - if (this.data.common_site_type == 0 || (this.data.common_site_type == 4 && this.data.site_model == 0)) { + if (this.data.common_site_type == 0 || this.data.common_site_type == 4 && this.data.site_model == 0) { swan.navigateTo({ url: '/pages/user-address/user-address?is_back=1' }); - } else if (this.data.common_site_type == 2 || (this.data.common_site_type == 4 && this.data.site_model == 2)) { + } else if (this.data.common_site_type == 2 || this.data.common_site_type == 4 && this.data.site_model == 2) { swan.navigateTo({ url: '/pages/extraction-address/extraction-address?is_back=1' }); @@ -278,16 +302,15 @@ Page({ } }, - // 销售+自提 模式选择事件 + // 销售+自提 模式选择事件 buy_header_nav_event(e) { var value = e.currentTarget.dataset.value || 0; - if (value != this.data.site_model) - { + if (value != this.data.site_model) { // 数据设置 this.setData({ address: null, address_id: null, - site_model: value, + site_model: value }); // 删除地址缓存 @@ -297,4 +320,24 @@ Page({ this.init(); } }, + + // 地图查看 + map_event(e) { + var index = e.currentTarget.dataset.index || 0; + var data = this.data.goods_list[index] || null; + if (data == null) { + app.showToast("地址有误"); + return false; + } + + var lng = parseFloat(data.lng || 0); + var lat = parseFloat(data.lat || 0); + swan.openLocation({ + latitude: lat, + longitude: lng, + scale: 18, + name: data.name || data.alias || '', + address: (data.province_name || '') + (data.city_name || '') + (data.county_name || '') + (data.address || '') + }); + } }); \ No newline at end of file diff --git a/sourcecode/baidu/pages/buy/buy.swan b/sourcecode/baidu/pages/buy/buy.swan index db659ab18..aa4265f95 100755 --- a/sourcecode/baidu/pages/buy/buy.swan +++ b/sourcecode/baidu/pages/buy/buy.swan @@ -1,139 +1,153 @@ - - - - - - - - - {{item.name}} - - - - - - - - - {{address.alias}} - {{address.name}} - {{address.tel}} + + + + + + + + + {{item.name}} + + + + + + + + + {{address.alias}} + {{address.name}} + {{address.tel}} + + + + {{address.province_name}}{{address.city_name}}{{address.county_name}}{{address.address}} + - - - {{address.province_name}}{{address.city_name}}{{address.county_name}}{{address.address}} + + {{(common_site_type == 0 || (common_site_type == 4 && site_model == 0)) ? '请选择收货地址' : '请选择取货地址'}} - - {{(common_site_type == 0 || (common_site_type == 4 && site_model == 0)) ? '请选择收货地址' : '请选择取货地址'}} + + + + + + + + + {{group.name}} + {{group.alias}} + + + 查看地图 + + + + + + + {{item.title}} + + {{spec.type}}:{{spec.value}} + + + + + {{price_symbol}}{{item.price}} + + {{price_symbol}}{{item.original_price}} + + x{{item.stock}} + + + + + + 优惠劵 + {{((plugins_choice_coupon_value || null) != null && (plugins_choice_coupon_value[group.id] || null) != null) ? plugins_choice_coupon_value[group.id] : '请选择优惠券'}} + + + + + {{item.name}} + + {{item.tips}} + + + + + + {{price_symbol}}{{group.order_base.total_price}} + {{price_symbol}}{{group.order_base.actual_price}} - - - - - - - - - {{item.title}} - - {{spec.type}}:{{spec.value}} + + + +