1.分类优化滚动条
parent
42211958e5
commit
548dabdf60
|
|
@ -24,8 +24,8 @@
|
|||
<style scoped>
|
||||
/* iconfont.css全局注册需要将src切换成绝对路径 */
|
||||
/* @/static/icon/ */
|
||||
/* @import url("@/static/icon/iconfont.css"); */
|
||||
@import url('https://at.alicdn.com/t/c/font_4227145_ezq1taohcms.css');
|
||||
@import url('@/static/icon/iconfont.css');
|
||||
/* @import url('https://at.alicdn.com/t/c/font_4227145_ezq1taohcms.css'); */
|
||||
|
||||
.iconfont {
|
||||
display: inline-block;
|
||||
|
|
|
|||
|
|
@ -190,8 +190,7 @@
|
|||
|
||||
/**
|
||||
* 商品列表模式
|
||||
*/
|
||||
.category-content.goods-model {
|
||||
*/.category-content.goods-model {
|
||||
padding-top: 182rpx;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
</block>
|
||||
|
||||
<!-- 分类内容 -->
|
||||
<view v-if="category_list.length > 0" :class="'category-content bs-bb pr ' + (category_show_level == 0 ? 'goods-model' : '')" :style="'height:calc(100vh - ' + (status_bar_height + 45) + 'px);'">
|
||||
<view v-if="category_list.length > 0" :class="'category-content bs-bb pr ' + (category_show_level == 0 ? 'goods-model' : '')" :style="'height:calc(100vh - ' + search_height + 'px);'">
|
||||
<block v-if="category_show_level == 1">
|
||||
<!-- 一级模式 -->
|
||||
<scroll-view scroll-y class="ht-auto">
|
||||
|
|
@ -54,7 +54,7 @@
|
|||
</view>
|
||||
</block>
|
||||
</scroll-view>
|
||||
<component-nav-more class="nav-more-top" :prop-top="status_bar_height + 47 + 'px'" :prop-status="popup_status" @open-popup="open_popup_event">
|
||||
<component-nav-more class="nav-more-top" :prop-top="search_height + 'px'" :prop-status="popup_status" @open-popup="open_popup_event">
|
||||
<view class="nav-list-more">
|
||||
<view class="flex-row flex-warp align-c">
|
||||
<block v-for="(item, index) in category_list" :key="index">
|
||||
|
|
@ -371,28 +371,28 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
const app = getApp();
|
||||
import base64 from "../../common/js/lib/base64.js";
|
||||
import componentGoodsBuy from "../../components/goods-buy/goods-buy";
|
||||
import componentSearch from "../../components/search/search";
|
||||
import componentQuickNav from "../../components/quick-nav/quick-nav";
|
||||
import componentNoData from "../../components/no-data/no-data";
|
||||
import componentPopup from "../../components/popup/popup";
|
||||
import componentBadge from "../../components/badge/badge";
|
||||
import componentCartParaCurve from "../../components/cart-para-curve/cart-para-curve";
|
||||
import componentUserBase from "../../components/user-base/user-base";
|
||||
import componentNavMore from "../../components/nav-more/nav-more";
|
||||
const app = getApp();
|
||||
import base64 from '../../common/js/lib/base64.js';
|
||||
import componentGoodsBuy from '../../components/goods-buy/goods-buy';
|
||||
import componentSearch from '../../components/search/search';
|
||||
import componentQuickNav from '../../components/quick-nav/quick-nav';
|
||||
import componentNoData from '../../components/no-data/no-data';
|
||||
import componentPopup from '../../components/popup/popup';
|
||||
import componentBadge from '../../components/badge/badge';
|
||||
import componentCartParaCurve from '../../components/cart-para-curve/cart-para-curve';
|
||||
import componentUserBase from '../../components/user-base/user-base';
|
||||
import componentNavMore from '../../components/nav-more/nav-more';
|
||||
|
||||
var theme_static_url = app.globalData.get_static_url("goods");
|
||||
var common_static_url = app.globalData.get_static_url("common");
|
||||
// 状态栏高度
|
||||
var bar_height = parseInt(app.globalData.get_system_info("statusBarHeight", 0));
|
||||
// #ifdef MP-TOUTIAO
|
||||
bar_height = 0;
|
||||
// #endif
|
||||
var theme_static_url = app.globalData.get_static_url('goods');
|
||||
var common_static_url = app.globalData.get_static_url('common');
|
||||
// 状态栏高度
|
||||
var bar_height = parseInt(app.globalData.get_system_info('statusBarHeight', 0));
|
||||
// #ifdef MP-TOUTIAO
|
||||
bar_height = 0;
|
||||
// #endif
|
||||
|
||||
var icon_type = app.globalData.data.category_goods_model_icon_type;
|
||||
export default {
|
||||
var icon_type = app.globalData.data.category_goods_model_icon_type;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
theme_static_url: theme_static_url,
|
||||
|
|
@ -400,7 +400,7 @@ export default {
|
|||
status_bar_height: bar_height,
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: "",
|
||||
data_list_loding_msg: '',
|
||||
data_is_loading: 0,
|
||||
user: null,
|
||||
tabbar_params: null,
|
||||
|
|
@ -415,7 +415,7 @@ export default {
|
|||
data_page: 1,
|
||||
currency_symbol: app.globalData.data.currency_symbol,
|
||||
is_first: 1,
|
||||
search_keywords_value: "",
|
||||
search_keywords_value: '',
|
||||
nav_active_index: 0,
|
||||
nav_active_item_two_index: -1,
|
||||
nav_active_item_three_index: -1,
|
||||
|
|
@ -431,7 +431,7 @@ export default {
|
|||
// 是否单页预览
|
||||
is_single_page: app.globalData.is_current_single_page() || 0,
|
||||
// 商品列表模式一级分类图标类型
|
||||
category_goods_model_icon_field: icon_type == 0 ? "realistic_images" : icon_type == 1 ? "icon" : "big_images",
|
||||
category_goods_model_icon_field: icon_type == 0 ? 'realistic_images' : icon_type == 1 ? 'icon' : 'big_images',
|
||||
// 商品分类页面搜索进入独立搜索页面
|
||||
is_goods_category_search_alone: app.globalData.data.is_goods_category_search_alone,
|
||||
// 临时操作数据
|
||||
|
|
@ -440,6 +440,8 @@ export default {
|
|||
plugins_label_data: null,
|
||||
theme_color: app.globalData.get_theme_color(),
|
||||
popup_status: false,
|
||||
// 获取搜索框高度
|
||||
search_height: 0,
|
||||
};
|
||||
},
|
||||
|
||||
|
|
@ -474,26 +476,39 @@ export default {
|
|||
|
||||
// 用户头像和昵称设置提示
|
||||
if ((this.$refs.user_base || null) != null) {
|
||||
this.$refs.user_base.init("goods-category");
|
||||
this.$refs.user_base.init('goods-category');
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// #ifdef H5 || APP
|
||||
this.popup_top = "98rpx";
|
||||
this.popup_top = '98rpx';
|
||||
// #endif
|
||||
},
|
||||
mounted() {
|
||||
const query = uni.createSelectorQuery();
|
||||
query
|
||||
.select('.nav-search')
|
||||
.boundingClientRect((data) => {
|
||||
console.log(data);
|
||||
// 获取搜索框高度
|
||||
this.setData({
|
||||
search_height: data.height,
|
||||
});
|
||||
})
|
||||
.exec();
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 初始化配置
|
||||
init_config(status) {
|
||||
if ((status || false) == true) {
|
||||
this.setData({
|
||||
common_site_type: app.globalData.get_config("config.common_site_type"),
|
||||
currency_symbol: app.globalData.get_config("currency_symbol"),
|
||||
category_show_level: app.globalData.get_config("config.category_show_level"),
|
||||
common_site_type: app.globalData.get_config('config.common_site_type'),
|
||||
currency_symbol: app.globalData.get_config('currency_symbol'),
|
||||
category_show_level: app.globalData.get_config('config.category_show_level'),
|
||||
});
|
||||
} else {
|
||||
app.globalData.is_config(this, "init_config");
|
||||
app.globalData.is_config(this, 'init_config');
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -506,10 +521,10 @@ export default {
|
|||
}
|
||||
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url("category", "goods"),
|
||||
method: "POST",
|
||||
url: app.globalData.get_request_url('category', 'goods'),
|
||||
method: 'POST',
|
||||
data: {},
|
||||
dataType: "json",
|
||||
dataType: 'json',
|
||||
success: (res) => {
|
||||
uni.stopPullDownRefresh();
|
||||
if (res.data.code == 0) {
|
||||
|
|
@ -523,12 +538,12 @@ export default {
|
|||
if (temp_category.length > 0) {
|
||||
for (var i in temp_category) {
|
||||
// 是否指定分类
|
||||
if ((tabbar_params || null) != null && (tabbar_params.id || null) != null && temp_category[i]["id"] == tabbar_params.id) {
|
||||
if ((tabbar_params || null) != null && (tabbar_params.id || null) != null && temp_category[i]['id'] == tabbar_params.id) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
// 是否全部数据都无二级
|
||||
if ((temp_category[i]["items"] || null) != null && temp_category[i]["items"].length > 0) {
|
||||
if ((temp_category[i]['items'] || null) != null && temp_category[i]['items'].length > 0) {
|
||||
category_one_subset_count++;
|
||||
}
|
||||
}
|
||||
|
|
@ -543,17 +558,17 @@ export default {
|
|||
};
|
||||
// 指定分类则重新读取列表数据
|
||||
if (tabbar_params != null && this.nav_active_index != index) {
|
||||
upd_data["is_first"] = 1;
|
||||
upd_data["data_page"] = 1;
|
||||
upd_data["data_list"] = [];
|
||||
upd_data["data_list_loding_status"] = 1;
|
||||
upd_data["nav_active_item_two_index"] = -1;
|
||||
upd_data["nav_active_item_three_index"] = -1;
|
||||
upd_data['is_first'] = 1;
|
||||
upd_data['data_page'] = 1;
|
||||
upd_data['data_list'] = [];
|
||||
upd_data['data_list_loding_status'] = 1;
|
||||
upd_data['nav_active_item_two_index'] = -1;
|
||||
upd_data['nav_active_item_three_index'] = -1;
|
||||
}
|
||||
// 非商品列表模式
|
||||
if (this.category_show_level != 0) {
|
||||
upd_data["data_list_loding_status"] = temp_category.length == 0 ? 0 : 3;
|
||||
upd_data["data_bottom_line_status"] = true;
|
||||
upd_data['data_list_loding_status'] = temp_category.length == 0 ? 0 : 3;
|
||||
upd_data['data_bottom_line_status'] = true;
|
||||
}
|
||||
this.setData(upd_data);
|
||||
|
||||
|
|
@ -585,7 +600,7 @@ export default {
|
|||
// 基础自定义分享
|
||||
this.setData({
|
||||
share_info: {
|
||||
path: "/pages/goods-category/goods-category",
|
||||
path: '/pages/goods-category/goods-category',
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -598,9 +613,9 @@ export default {
|
|||
uni.stopPullDownRefresh();
|
||||
this.setData({
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: "服务器请求出错",
|
||||
data_list_loding_msg: '服务器请求出错',
|
||||
});
|
||||
app.globalData.showToast("服务器请求出错");
|
||||
app.globalData.showToast('服务器请求出错');
|
||||
},
|
||||
});
|
||||
},
|
||||
|
|
@ -626,28 +641,28 @@ export default {
|
|||
// 请求参数
|
||||
var data = {
|
||||
page: this.data_page,
|
||||
wd: this.search_keywords_value || "",
|
||||
wd: this.search_keywords_value || '',
|
||||
};
|
||||
// 分类id
|
||||
if ((this.data_content || null) != null) {
|
||||
// 主分类id
|
||||
data["category_id"] = this.data_content["id"];
|
||||
data['category_id'] = this.data_content['id'];
|
||||
// 是否选中了二级分类
|
||||
if (this.nav_active_item_two_index != -1) {
|
||||
data["category_id"] = this.data_content["items"][this.nav_active_item_two_index]["id"];
|
||||
data['category_id'] = this.data_content['items'][this.nav_active_item_two_index]['id'];
|
||||
}
|
||||
// 是否选中了三级分类
|
||||
if (this.data_three_content != null && this.nav_active_item_three_index != -1) {
|
||||
data["category_id"] = this.data_three_content["items"][this.nav_active_item_three_index]["id"];
|
||||
data['category_id'] = this.data_three_content['items'][this.nav_active_item_three_index]['id'];
|
||||
}
|
||||
}
|
||||
|
||||
// 获取数据
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url("datalist", "search"),
|
||||
method: "POST",
|
||||
url: app.globalData.get_request_url('datalist', 'search'),
|
||||
method: 'POST',
|
||||
data: data,
|
||||
dataType: "json",
|
||||
dataType: 'json',
|
||||
success: (res) => {
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
|
|
@ -702,10 +717,10 @@ export default {
|
|||
fail: () => {
|
||||
this.setData({
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: "服务器请求出错",
|
||||
data_list_loding_msg: '服务器请求出错',
|
||||
data_is_loading: 0,
|
||||
});
|
||||
app.globalData.showToast("服务器请求出错");
|
||||
app.globalData.showToast('服务器请求出错');
|
||||
},
|
||||
});
|
||||
},
|
||||
|
|
@ -742,7 +757,7 @@ export default {
|
|||
var temp_data_content = this.category_list[index] || null;
|
||||
var temp_data_three_content = null;
|
||||
if (two_index != -1 && temp_data_content != null) {
|
||||
temp_data_three_content = temp_data_content["items"][two_index];
|
||||
temp_data_three_content = temp_data_content['items'][two_index];
|
||||
}
|
||||
this.setData({
|
||||
nav_active_index: index,
|
||||
|
|
@ -773,7 +788,7 @@ export default {
|
|||
// 分类事件
|
||||
category_event(e) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/goods-search/goods-search?category_id=" + e.currentTarget.dataset.value,
|
||||
url: '/pages/goods-search/goods-search?category_id=' + e.currentTarget.dataset.value,
|
||||
});
|
||||
},
|
||||
|
||||
|
|
@ -782,7 +797,7 @@ export default {
|
|||
// 商品列表模式
|
||||
if (this.category_show_level == 0) {
|
||||
this.setData({
|
||||
search_keywords_value: e || "",
|
||||
search_keywords_value: e || '',
|
||||
data_page: 1,
|
||||
data_list_loding_status: 1,
|
||||
data_list: [],
|
||||
|
|
@ -791,7 +806,7 @@ export default {
|
|||
} else {
|
||||
// 进入搜索页面
|
||||
uni.navigateTo({
|
||||
url: "/pages/goods-search/goods-search" + ((e || null) == null ? "" : "?keywords=" + e),
|
||||
url: '/pages/goods-search/goods-search' + ((e || null) == null ? '' : '?keywords=' + e),
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
@ -811,7 +826,7 @@ export default {
|
|||
// 用户未绑定手机则转到登录页面
|
||||
if (app.globalData.user_is_need_login(user)) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/login/login?event_callback=buy_number_event",
|
||||
url: '/pages/login/login?event_callback=buy_number_event',
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
|
|
@ -829,11 +844,11 @@ export default {
|
|||
this.setData({
|
||||
cart_status: true,
|
||||
});
|
||||
app.globalData.showToast("不同规格的商品需在购物车减购");
|
||||
app.globalData.showToast('不同规格的商品需在购物车减购');
|
||||
} else {
|
||||
if ((this.$refs.goods_buy || null) != null) {
|
||||
this.$refs.goods_buy.init(temp_goods, {
|
||||
buy_event_type: "cart",
|
||||
buy_event_type: 'cart',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -853,20 +868,20 @@ export default {
|
|||
},
|
||||
|
||||
// 列表数量事件处理
|
||||
buy_number_event_handle(e, type, goods, spec = "") {
|
||||
var res = this.buy_number_handle(type, goods, "buy_number");
|
||||
buy_number_event_handle(e, type, goods, spec = '') {
|
||||
var res = this.buy_number_handle(type, goods, 'buy_number');
|
||||
if (res === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 为0或减操作则查询
|
||||
var cart_item = null;
|
||||
if (type == 0 || (type == 1 && goods["buy_number"] > 0)) {
|
||||
if (type == 0 || (type == 1 && goods['buy_number'] > 0)) {
|
||||
var cart_data = this.cart.data;
|
||||
var params_spec = (spec || null) == null || typeof spec != "object" ? "" : JSON.stringify(spec);
|
||||
var params_spec = (spec || null) == null || typeof spec != 'object' ? '' : JSON.stringify(spec);
|
||||
for (var i in cart_data) {
|
||||
if (goods["id"] == cart_data[i]["goods_id"]) {
|
||||
var cart_spec = (cart_data[i]["spec"] || null) == null || typeof cart_data[i]["spec"] != "object" ? "" : JSON.stringify(cart_data[i]["spec"]);
|
||||
if (goods['id'] == cart_data[i]['goods_id']) {
|
||||
var cart_spec = (cart_data[i]['spec'] || null) == null || typeof cart_data[i]['spec'] != 'object' ? '' : JSON.stringify(cart_data[i]['spec']);
|
||||
if (type == 0 || (type == 1 && cart_spec == params_spec)) {
|
||||
cart_item = cart_data[i];
|
||||
}
|
||||
|
|
@ -887,15 +902,15 @@ export default {
|
|||
// 操作类型
|
||||
if (res == 0) {
|
||||
if (cart_item == null) {
|
||||
app.globalData.showToast("购物车id有误");
|
||||
app.globalData.showToast('购物车id有误');
|
||||
return false;
|
||||
}
|
||||
this.cart_delete(cart_item.id);
|
||||
} else if (cart_item == null) {
|
||||
this.cart_save(goods["id"], res, spec);
|
||||
this.cart_save(goods['id'], res, spec);
|
||||
} else {
|
||||
var number = type == 0 ? parseInt(cart_item["stock"]) - res : res + parseInt(cart_item["stock"]);
|
||||
this.cart_update(cart_item.id, goods["id"], number);
|
||||
var number = type == 0 ? parseInt(cart_item['stock']) - res : res + parseInt(cart_item['stock']);
|
||||
this.cart_update(cart_item.id, goods['id'], number);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
|
@ -906,7 +921,7 @@ export default {
|
|||
if ((this.$refs.cart_para_curve || null) != null) {
|
||||
var self = this;
|
||||
uni.createSelectorQuery()
|
||||
.select(".botton-nav .cart")
|
||||
.select('.botton-nav .cart')
|
||||
.boundingClientRect()
|
||||
.exec(function (res) {
|
||||
self.$refs.cart_para_curve.init(res, self.temp_opt_data.pos, self.temp_opt_data.goods.images);
|
||||
|
|
@ -925,7 +940,7 @@ export default {
|
|||
// 用户未绑定手机则转到登录页面
|
||||
if (app.globalData.user_is_need_login(user)) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/login/login?event_callback=cart_buy_number_event",
|
||||
url: '/pages/login/login?event_callback=cart_buy_number_event',
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
|
|
@ -935,7 +950,7 @@ export default {
|
|||
var temp_goods = temp_data[index];
|
||||
|
||||
// 数据操作处理
|
||||
var res = this.buy_number_handle(type, temp_goods, "stock");
|
||||
var res = this.buy_number_handle(type, temp_goods, 'stock');
|
||||
if (res === false) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -951,10 +966,10 @@ export default {
|
|||
|
||||
// 操作类型
|
||||
if (res == 0) {
|
||||
this.cart_delete(temp_goods["id"]);
|
||||
this.cart_delete(temp_goods['id']);
|
||||
} else {
|
||||
var number = type == 0 ? parseInt(temp_goods["stock"]) - res : res + parseInt(temp_goods["stock"]);
|
||||
this.cart_update(temp_goods["id"], temp_goods["goods_id"], number);
|
||||
var number = type == 0 ? parseInt(temp_goods['stock']) - res : res + parseInt(temp_goods['stock']);
|
||||
this.cart_update(temp_goods['id'], temp_goods['goods_id'], number);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -974,12 +989,12 @@ export default {
|
|||
}
|
||||
|
||||
// 数据校验
|
||||
var buy_min_number = parseInt(goods["buy_min_number"]) || 1;
|
||||
var buy_max_number = parseInt(goods["buy_max_number"]) || 0;
|
||||
var spec_buy_min_number = parseInt(goods["spec_buy_min_number"]) || 0;
|
||||
var spec_buy_max_number = parseInt(goods["spec_buy_max_number"]) || 0;
|
||||
var inventory = parseInt(goods["inventory"]);
|
||||
var inventory_unit = goods["inventory_unit"];
|
||||
var buy_min_number = parseInt(goods['buy_min_number']) || 1;
|
||||
var buy_max_number = parseInt(goods['buy_max_number']) || 0;
|
||||
var spec_buy_min_number = parseInt(goods['spec_buy_min_number']) || 0;
|
||||
var spec_buy_max_number = parseInt(goods['spec_buy_max_number']) || 0;
|
||||
var inventory = parseInt(goods['inventory']);
|
||||
var inventory_unit = goods['inventory_unit'];
|
||||
|
||||
// 最小起购数量
|
||||
var min = spec_buy_min_number > 0 ? spec_buy_min_number : buy_min_number;
|
||||
|
|
@ -999,13 +1014,13 @@ export default {
|
|||
var max = spec_buy_max_number > 0 ? spec_buy_max_number : buy_max_number;
|
||||
if (max > 0 && buy_number > max) {
|
||||
buy_number = max;
|
||||
app.globalData.showToast("限购" + max + inventory_unit);
|
||||
app.globalData.showToast('限购' + max + inventory_unit);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 数量是否改变
|
||||
if (goods[buy_number_field] == buy_number) {
|
||||
app.globalData.showToast("数量未改变");
|
||||
app.globalData.showToast('数量未改变');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1016,24 +1031,24 @@ export default {
|
|||
opt_number = 0;
|
||||
}
|
||||
} else {
|
||||
if (buy_number > goods["buy_number"]) {
|
||||
opt_number = buy_number - goods["buy_number"];
|
||||
if (buy_number > goods['buy_number']) {
|
||||
opt_number = buy_number - goods['buy_number'];
|
||||
}
|
||||
}
|
||||
return opt_number;
|
||||
},
|
||||
|
||||
// 购物车添加
|
||||
cart_save(goods_id, buy_number, spec = "") {
|
||||
cart_save(goods_id, buy_number, spec = '') {
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url("save", "cart"),
|
||||
method: "POST",
|
||||
url: app.globalData.get_request_url('save', 'cart'),
|
||||
method: 'POST',
|
||||
data: {
|
||||
goods_id: goods_id,
|
||||
stock: buy_number,
|
||||
spec: spec,
|
||||
},
|
||||
dataType: "json",
|
||||
dataType: 'json',
|
||||
success: (res) => {
|
||||
if (res.data.code == 0) {
|
||||
this.cart_para_curve_handle();
|
||||
|
|
@ -1045,7 +1060,7 @@ export default {
|
|||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.globalData.showToast("服务器请求出错");
|
||||
app.globalData.showToast('服务器请求出错');
|
||||
},
|
||||
});
|
||||
},
|
||||
|
|
@ -1053,14 +1068,14 @@ export default {
|
|||
// 购物车更新
|
||||
cart_update(cart_id, goods_id, buy_number) {
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url("stock", "cart"),
|
||||
method: "POST",
|
||||
url: app.globalData.get_request_url('stock', 'cart'),
|
||||
method: 'POST',
|
||||
data: {
|
||||
id: cart_id,
|
||||
goods_id: goods_id,
|
||||
stock: buy_number,
|
||||
},
|
||||
dataType: "json",
|
||||
dataType: 'json',
|
||||
success: (res) => {
|
||||
if (res.data.code == 0) {
|
||||
this.cart_para_curve_handle();
|
||||
|
|
@ -1069,12 +1084,12 @@ export default {
|
|||
if (app.globalData.is_login_check(res.data)) {
|
||||
app.globalData.showToast(res.data.msg);
|
||||
} else {
|
||||
app.globalData.showToast("提交失败,请重试!");
|
||||
app.globalData.showToast('提交失败,请重试!');
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.globalData.showToast("服务器请求出错");
|
||||
app.globalData.showToast('服务器请求出错');
|
||||
},
|
||||
});
|
||||
},
|
||||
|
|
@ -1082,12 +1097,12 @@ export default {
|
|||
// 购物车删除
|
||||
cart_delete(cart_id) {
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url("delete", "cart"),
|
||||
method: "POST",
|
||||
url: app.globalData.get_request_url('delete', 'cart'),
|
||||
method: 'POST',
|
||||
data: {
|
||||
id: cart_id,
|
||||
},
|
||||
dataType: "json",
|
||||
dataType: 'json',
|
||||
success: (res) => {
|
||||
if (res.data.code == 0) {
|
||||
this.get_cart_data();
|
||||
|
|
@ -1095,12 +1110,12 @@ export default {
|
|||
if (app.globalData.is_login_check(res.data)) {
|
||||
app.globalData.showToast(res.data.msg);
|
||||
} else {
|
||||
app.globalData.showToast("提交失败,请重试!");
|
||||
app.globalData.showToast('提交失败,请重试!');
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.globalData.showToast("服务器请求出错");
|
||||
app.globalData.showToast('服务器请求出错');
|
||||
},
|
||||
});
|
||||
},
|
||||
|
|
@ -1109,10 +1124,10 @@ export default {
|
|||
get_cart_data() {
|
||||
if (this.user != null) {
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url("index", "cart"),
|
||||
method: "POST",
|
||||
url: app.globalData.get_request_url('index', 'cart'),
|
||||
method: 'POST',
|
||||
data: {},
|
||||
dataType: "json",
|
||||
dataType: 'json',
|
||||
success: (res) => {
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
|
|
@ -1131,7 +1146,7 @@ export default {
|
|||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.globalData.showToast("服务器请求出错");
|
||||
app.globalData.showToast('服务器请求出错');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
@ -1144,11 +1159,11 @@ export default {
|
|||
var temp_data_list = this.data_list;
|
||||
if (temp_data_list.length > 0) {
|
||||
for (var i in temp_data_list) {
|
||||
temp_data_list[i]["buy_number"] = 0;
|
||||
temp_data_list[i]['buy_number'] = 0;
|
||||
if (temp_cart.data.length > 0) {
|
||||
for (var k in temp_cart.data) {
|
||||
if (temp_cart.data[k]["goods_id"] == temp_data_list[i]["id"]) {
|
||||
temp_data_list[i]["buy_number"] += parseInt(temp_cart.data[k]["stock"]);
|
||||
if (temp_cart.data[k]['goods_id'] == temp_data_list[i]['id']) {
|
||||
temp_data_list[i]['buy_number'] += parseInt(temp_cart.data[k]['stock']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1163,18 +1178,18 @@ export default {
|
|||
// 批量删除操作
|
||||
cart_all_delete_event(e) {
|
||||
uni.showModal({
|
||||
title: "温馨提示",
|
||||
content: "挑了这么久,真的要清空吗?",
|
||||
confirmText: "确认",
|
||||
cancelText: "暂不",
|
||||
title: '温馨提示',
|
||||
content: '挑了这么久,真的要清空吗?',
|
||||
confirmText: '确认',
|
||||
cancelText: '暂不',
|
||||
success: (result) => {
|
||||
if (result.confirm) {
|
||||
var ids = [];
|
||||
var temp_data = this.cart.data;
|
||||
for (var i in temp_data) {
|
||||
ids.push(temp_data[i]["id"]);
|
||||
ids.push(temp_data[i]['id']);
|
||||
}
|
||||
this.cart_delete(ids.join(","));
|
||||
this.cart_delete(ids.join(','));
|
||||
this.setData({
|
||||
cart_status: !this.cart_status,
|
||||
});
|
||||
|
|
@ -1207,28 +1222,28 @@ export default {
|
|||
if ((this.cart || null) != null) {
|
||||
var temp_data = this.cart.data || [];
|
||||
for (var i in temp_data) {
|
||||
if (temp_data[i]["is_error"] == 0) {
|
||||
ids.push(temp_data[i]["id"]);
|
||||
if (temp_data[i]['is_error'] == 0) {
|
||||
ids.push(temp_data[i]['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ids.length <= 0) {
|
||||
app.globalData.showToast("请先选购商品");
|
||||
app.globalData.showToast('请先选购商品');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 进入订单确认页面
|
||||
var data = {
|
||||
buy_type: "cart",
|
||||
ids: ids.join(","),
|
||||
buy_type: 'cart',
|
||||
ids: ids.join(','),
|
||||
};
|
||||
uni.navigateTo({
|
||||
url: "/pages/buy/buy?data=" + encodeURIComponent(base64.encode(JSON.stringify(data))),
|
||||
url: '/pages/buy/buy?data=' + encodeURIComponent(base64.encode(JSON.stringify(data))),
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
@import "./goods-category.css";
|
||||
@import './goods-category.css';
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Reference in New Issue