1352 lines
65 KiB
Vue
1352 lines
65 KiB
Vue
<template>
|
||
<view>
|
||
<view v-if="(info || null) != null">
|
||
<view class="pr">
|
||
<!-- 头部 -->
|
||
<view class="header" :style="'background-image: url('+info.banner+');'">
|
||
<!-- 顶部 -->
|
||
<view v-if="is_single_page == 0" class="header-top padding-horizontal-main" :style="'padding-top:'+(status_bar_height+8)+'px;'">
|
||
<!-- 返回 -->
|
||
<!-- #ifdef MP-WEIXIN || MP-QQ || MP-KUAISHOU || H5 || APP -->
|
||
<view v-if="is_realstore_top_nav_back == 1" class="nav-back dis-inline-block round tc va-m" @tap="top_nav_left_back_event">
|
||
<uni-icons type="arrowleft" size="46rpx" color="#fff"></uni-icons>
|
||
</view>
|
||
<!-- #endif -->
|
||
<!-- 搜索 -->
|
||
<view :class="'fr va-m '+(is_realstore_top_nav_back == 1 ? 'nav-search' : 'wh-auto')">
|
||
<!-- #ifndef H5 -->
|
||
<component-search @onsearch="search_button_event" @onicon="search_icon_event" :propIsIconOnEvent="is_realstore_top_search_scan == 1" :propIsOnEvent="true" :propIsRequired="false" :propIcon="is_realstore_top_search_scan == 1 ? 'scan' : 'search'" propIconColor="#fff" propPlaceholderClass="cr-grey" propTextColor="#fff" propPlaceholder="商品搜索" propBgColor="rgba(0, 0, 0, 0.1)" propBrColor="rgb(205 205 205 / 60%)"></component-search>
|
||
<!-- #endif -->
|
||
<!-- #ifdef H5 -->
|
||
<component-search @onsearch="search_button_event" :propIsRequired="false" propIconColor="#9A9A9A" propPlaceholderClass="cr-grey" propTextColor="#fff" propPlaceholder="商品搜索" propBgColor="rgba(0, 0, 0, 0.1)" propBrColor="rgb(205 205 205 / 60%)"></component-search>
|
||
<!-- #endif -->
|
||
</view>
|
||
</view>
|
||
<!-- 桌码 -->
|
||
<view v-if="(tablecode || null) != null" class="tablecode dis-inline-block margin-left-main round cr-red">
|
||
{{tablecode.name}}({{tablecode.code}})
|
||
</view>
|
||
</view>
|
||
<!-- 头部基础内容 -->
|
||
<view class="header-content margin-main padding-main border-radius-main bg-white pa br">
|
||
<view class="base oh">
|
||
<!-- 基础内容 -->
|
||
<image :src="info.logo" mode="widthFix" class="logo circle fl br" :data-value="info.logo" @tap="image_show_event"></image>
|
||
<view class="base-right fr">
|
||
<view v-if="(info.buy_use_type_list || null) != null && info.buy_use_type_list.length > 0" class="use-type-icon pa text-size-xs cr-white bg-main" @tap="buy_use_type_event">
|
||
<text class="va-m margin-right-xs">{{info.buy_use_type_list[buy_use_type_index]['name']}}</text>
|
||
<view class="dis-inline-block va-m">
|
||
<uni-icons type="arrowdown" size="32rpx" color="#fff"></uni-icons>
|
||
</view>
|
||
</view>
|
||
<view :class="'title fw-b text-size single-text '+((info.buy_use_type_list || null) != null && info.buy_use_type_list.length > 0 ? 'title-length-limit' : '')">
|
||
<text v-if="(info.alias || null) != null" class="va-m title-icon round br-main cr-main text-size-xs padding-left-sm padding-right-sm margin-right-xs">{{info.alias}}</text>
|
||
<text class="va-m">{{info.name}}</text>
|
||
</view>
|
||
<view class="margin-top-xs text-size-xs cr-grey">
|
||
<view v-if="(info.status_info.time || null) != null">营业时间:{{info.status_info.time}}</view>
|
||
<view v-if="(info.distance || null) != null">距离您{{info.distance}}</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<!-- 地址 -->
|
||
<view class="margin-top-sm oh cp">
|
||
<view class="dis-inline-block va-m">
|
||
<uni-icons type="location-filled" size="32rpx" color="#8d8d8d"></uni-icons>
|
||
</view>
|
||
<view class="address-content single-text cr-base margin-left-xs dis-inline-block text-size-sm va-m" :data-value="info.province_name+info.city_name+info.county_name+info.address" @tap="text_copy_event">{{info.province_name}}{{info.city_name}}{{info.county_name}}{{info.address}}</view>
|
||
</view>
|
||
<!-- 右侧操作 -->
|
||
<view class="icon-list pa">
|
||
<view v-if="(data_base.is_service_info || 0) == 1" class="icon-item bg-green circle dis-inline-block tc cp" @tap="header_service_event">
|
||
<uni-icons type="chatbubble-filled" size="32rpx" color="#fff"></uni-icons>
|
||
</view>
|
||
<!-- #ifndef MP-KUAISHOU -->
|
||
<view v-if="(info.lat != 0 && info.lng != 0)" class="icon-item bg-blue circle dis-inline-block tc cp" @tap="address_map_event">
|
||
<uni-icons type="paperplane-filled" size="32rpx" color="#fff"></uni-icons>
|
||
</view>
|
||
<!-- #endif -->
|
||
<view :class="'icon-item circle dis-inline-block tc cp pr '+((favor_info.status == 1) ? 'bg-red' : 'bg-gray')" @tap="favor_event">
|
||
<uni-icons type="heart-filled" size="32rpx" color="#fff"></uni-icons>
|
||
<view class="badge-icon pa">
|
||
<component-badge :propNumber="favor_info.count"></component-badge>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 在线客服 -->
|
||
<view v-if="header_service_status && ((data_base.is_service_info || 0) == 1 || (info.chat_info || null) != null)" class="header-service pa border-radius-main oh bg-white br">
|
||
<view v-if="(info.chat_info || null) != null" class="item padding-main br-t single-text">
|
||
<text class="va-m">客服:</text>
|
||
<view class="dis-inline-block chat-info cp" @tap="chat_event">
|
||
<image class="dis-inline-block va-m" :src="info.chat_info.icon" mode="scaleToFill"></image>
|
||
<text class="margin-left-sm va-m cr-blue" :data-value="info.chat_info.chat_url">{{info.chat_info.name}}</text>
|
||
</view>
|
||
</view>
|
||
<view v-if="(info.service_qq || null) != null" class="item padding-main br-t single-text">
|
||
<text>Q Q:</text>
|
||
<text class="cp" @tap="text_copy_event" :data-value="info.service_qq">{{info.service_qq}}</text>
|
||
</view>
|
||
<view v-if="(info.service_tel || null) != null" class="item padding-main br-t single-text">
|
||
<text>电话:</text>
|
||
<text class="cp" @tap="tel_event" :data-value="info.service_tel">{{info.service_tel}}</text>
|
||
</view>
|
||
<view v-if="(info.service_weixin_qrcode || null) != null || (info.service_line_qrcode || null) != null" class="oh qrcode tc br-t padding-top-main">
|
||
<view v-if="(info.service_weixin_qrcode || null) != null" class="item padding-bottom-lg dis-inline-block">
|
||
<image class="radius cp" :src="info.service_weixin_qrcode" mode="scaleToFill" @tap="image_show_event" :data-value="info.service_weixin_qrcode"></image>
|
||
<view>长按微信咨询</view>
|
||
</view>
|
||
<view v-if="(info.service_line_qrcode || null) != null" class="item padding-bottom-lg dis-inline-block">
|
||
<image class="radius cp" :src="info.service_line_qrcode" mode="scaleToFill" @tap="image_show_event" :data-value="info.service_line_qrcode"></image>
|
||
<view>长按line咨询</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 内容 -->
|
||
<view class="content oh">
|
||
<!-- 左侧 -->
|
||
<scroll-view :scroll-y="true" class="left-content fl ht-auto bg-white">
|
||
<view class="left-content-actual">
|
||
<view :class="'item tc cr-base text-size-sm cp ' + (nav_active_index == -1 ? 'active cr-main border-color-main fw-b' : '')" :data-index="-1" :data-itemindex="-1" @tap="nav_event">全部</view>
|
||
<block v-if="(goods_category || null) != null && goods_category.length > 0">
|
||
<block v-for="(item, index) in goods_category" :key="index">
|
||
<view :class="'item tc cr-base text-size-sm pr cp ' + (nav_active_index == index ? 'active cr-main border-color-main fw-b' : '')" :data-index="index" :data-itemindex="-1" @tap="nav_event">
|
||
<text>{{item.name}}</text>
|
||
<view v-if="(item.buy_number || 0) > 0" class="badge-icon pa">
|
||
<component-badge :propNumber="item.buy_number"></component-badge>
|
||
</view>
|
||
</view>
|
||
</block>
|
||
</block>
|
||
</view>
|
||
</scroll-view>
|
||
<!-- 右侧 -->
|
||
<scroll-view :scroll-y="true" class="right-content padding-right-main fr ht-auto goods-list" :scroll-top="scroll_top" @scroll="scroll_event" @scrolltolower="scroll_lower" lower-threshold="60">
|
||
<view class="right-content-actual pr">
|
||
<!-- 二级分类 -->
|
||
<view v-if="(goods_category || null) != null && goods_category.length > 0 && nav_active_index != -1 && (goods_category[nav_active_index]['items'] || null) != null && goods_category[nav_active_index]['items'].length > 0" class="word-list scroll-view-horizontal">
|
||
<scroll-view :scroll-x="true" :scroll-with-animation="true" :scroll-into-view="'two-nav-item-'+nav_active_item_index">
|
||
<view :class="'word-icon dis-inline-block text-size-sm round padding-top-xs padding-bottom-xs padding-left padding-right '+((nav_active_item_index == -1) ? 'bg-main-light br-main-light cr-main' : 'br-gray cr-gray')" :data-index="nav_active_index" :data-itemindex="-1" @tap="nav_event">全部</view>
|
||
<block v-for="(cv, ci) in goods_category[nav_active_index]['items']" :key="ci">
|
||
<view :class="'word-icon dis-inline-block text-size-sm round padding-top-xs padding-bottom-xs padding-left padding-right '+((nav_active_item_index != -1 && nav_active_item_index == ci) ? 'bg-main-light br-main-light cr-main' : 'br-gray cr-gray')" :id="'two-nav-item-'+ci" :data-index="nav_active_index" :data-itemindex="ci" @tap="nav_event">{{cv.name}}</view>
|
||
</block>
|
||
</scroll-view>
|
||
</view>
|
||
<!-- 右侧商品列表 -->
|
||
<block v-if="(data_list || null) != null && data_list.length > 0">
|
||
<view v-for="(item, index) in data_list" :key="index" class="item bg-white padding-main border-radius-main oh spacing-mb">
|
||
<view :data-value="'/pages/goods-detail/goods-detail?id='+item.id+'&is_opt_back=1&buy_use_type_index='+buy_use_type_index+'&realstore_id='+info.id" @tap="url_event">
|
||
<image :src="item.images" mode="widthFix" class="goods-img radius fl br"></image>
|
||
<view class="goods-base fr">
|
||
<view class="goods-base-content">
|
||
<view class="goods-title text-size-sm single-text">{{item.title}}</view>
|
||
<view v-if="(item.simple_desc || null) != null" class="simple-desc cr-red text-size-xs margin-top-xs multi-text">{{item.simple_desc}}</view>
|
||
</view>
|
||
<view class="margin-top-sm oh">
|
||
<view class="sales-price text-size-sm single-text dis-inline-block va-m">{{currency_symbol}}{{item.min_price}}</view>
|
||
<view class="tc fr">
|
||
<block v-if="(item.is_error || 0) == 0">
|
||
<view v-if="(item.buy_number || 0) > 0" class="dis-inline-block va-m cp" :data-index="index" data-type="0" @tap.stop="buy_number_event">
|
||
<uni-icons type="minus" size="46rpx" color="#f00"></uni-icons>
|
||
</view>
|
||
<view v-if="(item.buy_number || 0) > 0" class="buy-number dis-inline-block cr-base text-size-sm padding-left-xs padding-right-xs va-m">{{item.buy_number}}</view>
|
||
<view class="dis-inline-block va-m cp" :data-index="index" data-type="1" @tap.stop="buy_number_event">
|
||
<uni-icons type="plus" size="46rpx" color="#1AAD19"></uni-icons>
|
||
</view>
|
||
</block>
|
||
<block v-else>
|
||
<text class="cr-grey text-size-xs">{{item.is_error_msg}}</text>
|
||
</block>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</block>
|
||
<block v-else>
|
||
<component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
|
||
</block>
|
||
</view>
|
||
</scroll-view>
|
||
</view>
|
||
|
||
<!-- 购物车列表 -->
|
||
<block v-if="cart_status">
|
||
<view class="cart-mask wh-auto ht-auto pf" @tap="cart_event"></view>
|
||
<view class="cart-content bg-white border-radius-main pa oh">
|
||
<block v-if="(cart || null) != null && (cart.data || null) != null && cart.data.length > 0">
|
||
<view class="oh br-b padding-vertical-main padding-horizontal-main">
|
||
<text class="va-m text-size-xs cr-base">已选商品</text>
|
||
<view class="dis-inline-block margin-left-xl text-size-xs">
|
||
<text class="cr-red">没有已加购的商品?</text>
|
||
<text class="br-green cr-green round padding-left padding-right padding-top-xs padding-bottom-xs cp" @tap="buy_use_type_event">切换下单类型</text>
|
||
</view>
|
||
<view class="fr cp" @tap="cart_all_delete_event">
|
||
<view class="dis-inline-block va-m">
|
||
<uni-icons type="trash" size="24rpx" color="#f00"></uni-icons>
|
||
</view>
|
||
<text class="cr-red va-m text-size-xs margin-left-xs">清空</text>
|
||
</view>
|
||
</view>
|
||
<scroll-view :scroll-y="true" class="cart-list goods-list">
|
||
<view v-for="(goods, index) in cart.data" :key="index" class="item padding-main oh spacing-mb">
|
||
<navigator :url="'/pages/goods-detail/goods-detail?id='+goods.goods_id+'&is_opt_back=1&buy_use_type_index='+buy_use_type_index+'&realstore_id='+info.id" hover-class="none">
|
||
<image :src="goods.images" mode="widthFix" class="goods-img radius fl br"></image>
|
||
<view class="goods-base fr">
|
||
<view class="goods-base-content">
|
||
<view class="goods-title text-size-sm single-text">{{goods.title}}</view>
|
||
<view v-if="goods.spec != null" class="text-size-xs cr-grey margin-top-sm">
|
||
<block v-for="(sv, si) in goods.spec" :key="si">
|
||
<text v-if="si > 0" class="padding-left-xs padding-right-xs">;</text>
|
||
<text>{{sv.value}}</text>
|
||
</block>
|
||
</view>
|
||
</view>
|
||
<view class="margin-top-sm oh">
|
||
<view class="sales-price text-size-sm single-text dis-inline-block va-m">{{currency_symbol}}{{goods.price}}</view>
|
||
<view class="tc fr">
|
||
<view v-if="(goods.stock || 0) > 0" class="dis-inline-block va-m cp" :data-index="index" data-type="0" @tap.stop="cart_buy_number_event">
|
||
<uni-icons type="minus" size="46rpx" color="#f00"></uni-icons>
|
||
</view>
|
||
<view v-if="(goods.stock || 0) > 0" class="buy-number dis-inline-block cr-base text-size-sm padding-left-xs padding-right-xs va-m">{{goods.stock}}</view>
|
||
<view class="dis-inline-block va-m cp" :data-index="index" data-type="1" @tap.stop="cart_buy_number_event">
|
||
<uni-icons type="plus" size="46rpx" color="#1AAD19"></uni-icons>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</navigator>
|
||
</view>
|
||
</scroll-view>
|
||
</block>
|
||
<block v-else>
|
||
<component-no-data propStatus="0" propMsg="请先选购商品"></component-no-data>
|
||
<view class="padding-bottom-xxxl margin-bottom-xxxl tc text-size-xs margin-top-xxl">
|
||
<text class="cr-red">没有已加购的商品?</text>
|
||
<text class="br-green cr-green round padding-left padding-right padding-top-xs padding-bottom-xs cp" @tap="buy_use_type_event">切换下单类型</text>
|
||
</view>
|
||
</block>
|
||
</view>
|
||
</block>
|
||
|
||
<!-- 购物车底部导航 -->
|
||
<view class="botton-nav round pa bg-main-pair oh">
|
||
<view class="cart dis-inline-block va-m margin-left-xxl pr cp" @tap="cart_event">
|
||
<uni-icons type="cart" size="32rpx" color="#fff"></uni-icons>
|
||
<view v-if="(cart || null) != null && (cart.buy_number || 0) > 0" class="badge-icon pa">
|
||
<component-badge :propNumber="cart.buy_number"></component-badge>
|
||
</view>
|
||
</view>
|
||
<view class="cart-total-price single-text dis-inline-block fw-b cr-white va-m margin-left-xl">
|
||
<text class="text-size-sm">{{currency_symbol}}</text>
|
||
<text class="text-size-lg">{{(cart || null) == null ? 0 : (cart.total_price || 0)}}</text>
|
||
</view>
|
||
<button type="default" size="mini" hover-class="none" @tap="buy_submit_event" :class="'text-size-sm pa radius-0 '+((info.status_info.status == 1) ? 'bg-main cr-white' : 'bg-gray cr-gray')">{{info.status_info.status == 1 ? '去结算' : info.status_info.msg}}</button>
|
||
</view>
|
||
|
||
<!-- 购物车抛物线 -->
|
||
<component-cart-para-curve ref="cart_para_curve"></component-cart-para-curve>
|
||
|
||
<!-- 商品购买 -->
|
||
<component-goods-buy ref="goods_buy" v-on:CartSuccessEvent="goods_cart_back_event"></component-goods-buy>
|
||
</view>
|
||
<view v-else>
|
||
<!-- 提示信息 -->
|
||
<component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
<script>
|
||
const app = getApp();
|
||
import base64 from '../../../../common/js/lib/base64.js';
|
||
import componentGoodsBuy from "../../../../components/goods-buy/goods-buy";
|
||
import componentNoData from "../../../../components/no-data/no-data";
|
||
import componentSearch from "../../../../components/search/search";
|
||
import componentBadge from "../../../../components/badge/badge";
|
||
import componentPopup from "../../../../components/popup/popup";
|
||
import componentCartParaCurve from '../../../../components/cart-para-curve/cart-para-curve';
|
||
|
||
var common_static_url = app.globalData.get_static_url('common');
|
||
export default {
|
||
data() {
|
||
return {
|
||
status_bar_height: parseInt(app.globalData.get_system_info('statusBarHeight', 0)),
|
||
common_static_url: common_static_url,
|
||
data_list_loding_status: 1,
|
||
data_list_loding_msg: '',
|
||
data_is_loading: 0,
|
||
currency_symbol: app.globalData.data.currency_symbol,
|
||
cache_buy_use_type_index_key: 'cache_plugins_realstore_buy_use_type_index',
|
||
buy_use_type_index: 0,
|
||
params: null,
|
||
is_first: 1,
|
||
scroll_top: 0,
|
||
scroll_top_old: 0,
|
||
user: null,
|
||
info: null,
|
||
goods_category: [],
|
||
data_list: [],
|
||
data_total: 0,
|
||
data_page_total: 0,
|
||
data_page: 1,
|
||
cart: null,
|
||
goods_count: 0,
|
||
data_base: null,
|
||
favor_user: [],
|
||
tablecode: null,
|
||
category: [],
|
||
goods_list: [],
|
||
search_keywords_value: '',
|
||
nav_active_index: -1,
|
||
nav_active_item_index: -1,
|
||
cart_status: false,
|
||
popup_spec_status: false,
|
||
goods_choose_data: {},
|
||
header_service_status: false,
|
||
// 收藏信息
|
||
favor_info: {
|
||
"text": "收藏",
|
||
"status": 0,
|
||
"count": 0
|
||
},
|
||
// 用户位置信息
|
||
user_location: null,
|
||
// 自定义分享信息
|
||
share_info: {},
|
||
// 是否单页预览
|
||
is_single_page: app.globalData.is_current_single_page() || 0,
|
||
// 顶部导航返回按钮
|
||
is_realstore_top_nav_back: app.globalData.data.is_realstore_top_nav_back || 0,
|
||
is_realstore_top_search_scan: app.globalData.data.is_realstore_top_search_scan || 0,
|
||
// 临时操作数据
|
||
temp_opt_data: null,
|
||
};
|
||
},
|
||
|
||
components: {
|
||
componentGoodsBuy,
|
||
componentNoData,
|
||
componentSearch,
|
||
componentBadge,
|
||
componentPopup,
|
||
componentCartParaCurve
|
||
},
|
||
props: {},
|
||
|
||
onLoad(params) {
|
||
this.setData({
|
||
params: app.globalData.launch_params_handle(params),
|
||
user: app.globalData.get_user_cache_info()
|
||
});
|
||
},
|
||
|
||
onShow() {
|
||
// 类型选择
|
||
this.setData({
|
||
buy_use_type_index: this.get_buy_use_type_index()
|
||
});
|
||
|
||
// 用户位置初始化
|
||
this.user_location_init();
|
||
|
||
// 获取数据
|
||
this.get_detail_init();
|
||
|
||
// 初始化配置
|
||
this.init_config();
|
||
},
|
||
|
||
// 下拉刷新
|
||
onPullDownRefresh() {
|
||
this.setData({
|
||
data_page: 1
|
||
});
|
||
this.reset_scroll();
|
||
this.get_detail_init();
|
||
},
|
||
|
||
methods: {
|
||
// 初始化配置
|
||
init_config(status) {
|
||
if ((status || false) == true) {
|
||
this.setData({
|
||
currency_symbol: app.globalData.get_config('currency_symbol')
|
||
});
|
||
} else {
|
||
app.globalData.is_config(this, 'init_config');
|
||
}
|
||
},
|
||
|
||
// 获取数据-初始化
|
||
get_detail_init() {
|
||
uni.request({
|
||
url: app.globalData.get_request_url("index", "detail", "realstore"),
|
||
method: 'POST',
|
||
data: this.request_params_merge({
|
||
"id": this.params.id || 0
|
||
}, 'init'),
|
||
dataType: 'json',
|
||
success: res => {
|
||
uni.stopPullDownRefresh();
|
||
if (res.data.code == 0) {
|
||
var data = res.data.data;
|
||
this.setData({
|
||
data_base: data.base || null,
|
||
info: data.info || null,
|
||
goods_category: data.goods_category || [],
|
||
favor_user: data.favor_user || [],
|
||
tablecode: data.tablecode || null
|
||
});
|
||
|
||
// 下单类型是否存在索引
|
||
this.setData({
|
||
buy_use_type_index: this.get_buy_use_type_index()
|
||
});
|
||
|
||
// 收藏处理
|
||
if ((this.info || null) != null) {
|
||
// 收藏信息
|
||
var status = this.favor_user.indexOf(this.info.id) != -1 ? 1 : 0;
|
||
this.setData({
|
||
favor_info: {
|
||
"count": this.info.favor_count || 0,
|
||
"status": status,
|
||
"text": (status == 1 ? '已' : '') + '收藏'
|
||
}
|
||
});
|
||
|
||
// 基础自定义分享
|
||
this.setData({
|
||
share_info: {
|
||
title: this.info.seo_title || this.info.name,
|
||
desc: this.info.seo_desc || this.info.describe,
|
||
path: '/pages/plugins/realstore/detail/detail',
|
||
query: 'id='+this.info.id,
|
||
img: this.info.logo
|
||
}
|
||
});
|
||
|
||
// 标题名称
|
||
uni.setNavigationBarTitle({
|
||
title: this.info.name
|
||
});
|
||
|
||
// 获取数据、仅首次调用
|
||
// 获取列表接口和购物车
|
||
if(this.is_first == 1) {
|
||
this.get_data_list();
|
||
this.get_cart_data(this.is_first);
|
||
this.setData({is_first: 0});
|
||
} else {
|
||
// 非首次赋值购物车数据
|
||
this.setData({
|
||
cart: data.cart || null,
|
||
});
|
||
// 购物车更新列表数据处理
|
||
this.cart_data_list_handle();
|
||
}
|
||
}
|
||
} else {
|
||
this.setData({
|
||
data_list_loding_status: 2,
|
||
data_list_loding_msg: res.data.msg
|
||
});
|
||
}
|
||
|
||
// 分享菜单处理
|
||
app.globalData.page_share_handle(this.share_info);
|
||
},
|
||
fail: () => {
|
||
uni.stopPullDownRefresh();
|
||
this.setData({
|
||
data_list_loding_status: 2,
|
||
data_list_loding_msg: '服务器请求出错'
|
||
});
|
||
app.globalData.showToast('服务器请求出错');
|
||
}
|
||
});
|
||
},
|
||
|
||
// 获取数据-商品列表
|
||
get_data_list(is_mandatory) {
|
||
// 分页是否还有数据
|
||
if ((is_mandatory || 0) == 0) {
|
||
if (this.data_bottom_line_status == true) {
|
||
uni.stopPullDownRefresh();
|
||
return false;
|
||
}
|
||
}
|
||
|
||
// 是否加载中
|
||
if(this.data_is_loading == 1) {
|
||
return false;
|
||
}
|
||
this.setData({data_is_loading: 1});
|
||
|
||
// 加载loding
|
||
uni.showLoading({
|
||
title: '加载中...',
|
||
mask: true
|
||
});
|
||
|
||
// 分类id
|
||
var temp_category = this.goods_category;
|
||
if(this.nav_active_item_index != -1) {
|
||
var category_id = temp_category[this.nav_active_index]['items'][this.nav_active_item_index]['id'];
|
||
} else {
|
||
var category_id = (this.nav_active_index == -1) ? 0 : temp_category[this.nav_active_index]['id'];
|
||
}
|
||
|
||
// 获取数据
|
||
uni.request({
|
||
url: app.globalData.get_request_url("datalist", "detail", "realstore"),
|
||
method: 'POST',
|
||
data: this.request_params_merge({
|
||
id: this.info.id || 0,
|
||
page: this.data_page,
|
||
keywords: this.search_keywords_value,
|
||
category_id: category_id
|
||
}, 'data'),
|
||
dataType: 'json',
|
||
success: res => {
|
||
uni.hideLoading();
|
||
uni.stopPullDownRefresh();
|
||
if (res.data.code == 0) {
|
||
var data = res.data.data;
|
||
if (data.data.length > 0) {
|
||
if (this.data_page <= 1) {
|
||
var temp_data_list = data.data;
|
||
} else {
|
||
var temp_data_list = this.data_list || [];
|
||
var temp_data = data.data;
|
||
for (var i in temp_data) {
|
||
temp_data_list.push(temp_data[i]);
|
||
}
|
||
}
|
||
this.setData({
|
||
data_list: temp_data_list,
|
||
data_total: data.total,
|
||
data_page_total: data.page_total,
|
||
data_list_loding_status: 3,
|
||
data_page: this.data_page + 1,
|
||
data_is_loading: 0
|
||
});
|
||
|
||
// 是否还有数据
|
||
this.setData({
|
||
data_bottom_line_status: (this.data_page > 1 && this.data_page > this.data_page_total)
|
||
});
|
||
} else {
|
||
this.setData({
|
||
data_list_loding_status: 0,
|
||
data_is_loading: 0
|
||
});
|
||
if (this.data_page <= 1) {
|
||
this.setData({
|
||
data_list: [],
|
||
data_bottom_line_status: false
|
||
});
|
||
}
|
||
}
|
||
} else {
|
||
this.setData({
|
||
data_list_loding_status: 0,
|
||
data_list_loding_msg: res.data.msg,
|
||
data_is_loading: 0
|
||
});
|
||
app.globalData.showToast(res.data.msg);
|
||
}
|
||
},
|
||
fail: () => {
|
||
uni.hideLoading();
|
||
uni.stopPullDownRefresh();
|
||
this.setData({
|
||
data_list_loding_status: 2,
|
||
data_list_loding_msg: '服务器请求出错',
|
||
data_is_loading: 0
|
||
});
|
||
app.globalData.showToast('服务器请求出错');
|
||
}
|
||
});
|
||
},
|
||
|
||
// 收藏事件
|
||
favor_event(e) {
|
||
if(!app.globalData.is_single_page_check()) {
|
||
return false;
|
||
}
|
||
var user = app.globalData.get_user_info(this, 'favor_event');
|
||
if (user != false) {
|
||
// 用户未绑定用户则转到登录页面
|
||
if (app.globalData.user_is_need_login(user)) {
|
||
uni.navigateTo({
|
||
url: "/pages/login/login?event_callback=favor_event"
|
||
});
|
||
return false;
|
||
} else {
|
||
uni.showLoading({
|
||
title: '处理中...'
|
||
});
|
||
uni.request({
|
||
url: app.globalData.get_request_url("reversal", "favor", "realstore"),
|
||
method: 'POST',
|
||
data: {
|
||
"id": this.info.id
|
||
},
|
||
dataType: 'json',
|
||
success: res => {
|
||
uni.hideLoading();
|
||
if (res.data.code == 0) {
|
||
this.setData({
|
||
favor_info: res.data.data
|
||
});
|
||
app.globalData.showToast(res.data.msg, 'success');
|
||
} else {
|
||
if (app.globalData.is_login_check(res.data, this, 'favor_event')) {
|
||
app.globalData.showToast(res.data.msg);
|
||
}
|
||
}
|
||
},
|
||
fail: () => {
|
||
uni.hideLoading();
|
||
app.globalData.showToast('服务器请求出错');
|
||
}
|
||
});
|
||
}
|
||
}
|
||
},
|
||
|
||
// 列表数据操作
|
||
buy_number_event(e) {
|
||
if(!app.globalData.is_single_page_check()) {
|
||
return false;
|
||
}
|
||
var user = app.globalData.get_user_info(this);
|
||
if (user != false) {
|
||
// 用户未绑定用户则转到登录页面
|
||
if (app.globalData.user_is_need_login(user)) {
|
||
uni.navigateTo({
|
||
url: "/pages/login/login?event_callback=buy_number_event"
|
||
});
|
||
return false;
|
||
} else {
|
||
var index = e.currentTarget.dataset.index;
|
||
var type = parseInt(e.currentTarget.dataset.type) || 0;
|
||
var temp_goods = this.data_list[index];
|
||
this.setData({goods_choose_data: temp_goods});
|
||
|
||
// 是否存在多规格
|
||
if((temp_goods.is_exist_many_spec || 0) != 0) {
|
||
// 是否购物车中操作
|
||
if(type == 0) {
|
||
this.setData({
|
||
cart_status: true
|
||
});
|
||
app.globalData.showToast('不同规格的商品需在购物车减购');
|
||
} else {
|
||
if((this.$refs.goods_buy || null) != null) {
|
||
var buy_params = this.params;
|
||
buy_params['buy_event_type'] = 'cart';
|
||
buy_params['buy_use_type_index'] = this.buy_use_type_index;
|
||
buy_params['realstore_id'] = this.info.id;
|
||
this.$refs.goods_buy.init(temp_goods, buy_params);
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
// 数据操作处理
|
||
this.buy_number_event_handle(e, type, temp_goods);
|
||
}
|
||
}
|
||
},
|
||
|
||
// 加入购物车成功回调
|
||
goods_cart_back_event(e) {
|
||
// 重新获取购物车数据
|
||
this.get_cart_data();
|
||
},
|
||
|
||
// 列表数量事件处理
|
||
buy_number_event_handle(e, type, goods, spec = '') {
|
||
var res = this.buy_number_handle(type, goods, 'buy_number');
|
||
if(res === false) {
|
||
return false;
|
||
}
|
||
|
||
// 数据临时记录
|
||
this.setData({
|
||
temp_opt_data: {
|
||
pos: e,
|
||
goods: goods,
|
||
type: type,
|
||
}
|
||
});
|
||
|
||
// 为0或减操作则查询
|
||
var cart_item = null;
|
||
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);
|
||
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(type == 0 || (type == 1 && cart_spec == params_spec)) {
|
||
cart_item = cart_data[i];
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
// 操作类型
|
||
if(res == 0) {
|
||
if(cart_item == null) {
|
||
app.globalData.showToast('购物车id有误');
|
||
return false;
|
||
}
|
||
this.cart_delete(cart_item.id);
|
||
} else if(cart_item == null) {
|
||
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);
|
||
}
|
||
return true;
|
||
},
|
||
|
||
// 购物车抛物线动画
|
||
cart_para_curve_handle() {
|
||
if((this.temp_opt_data || null) != null && (this.temp_opt_data.type || 0) == 1) {
|
||
if((this.$refs.cart_para_curve || null) != null) {
|
||
var self = this;
|
||
uni.createSelectorQuery().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);
|
||
});
|
||
}
|
||
}
|
||
},
|
||
|
||
// 购物车数量操作
|
||
cart_buy_number_event(e) {
|
||
if(!app.globalData.is_single_page_check()) {
|
||
return false;
|
||
}
|
||
var user = app.globalData.get_user_info(this);
|
||
if (user != false) {
|
||
// 用户未绑定用户则转到登录页面
|
||
if (app.globalData.user_is_need_login(user)) {
|
||
uni.navigateTo({
|
||
url: "/pages/login/login?event_callback=cart_buy_number_event"
|
||
});
|
||
return false;
|
||
} else {
|
||
var index = e.currentTarget.dataset.index;
|
||
var type = parseInt(e.currentTarget.dataset.type) || 0;
|
||
var temp_data = this.cart.data;
|
||
var temp_goods = temp_data[index];
|
||
|
||
// 数据操作处理
|
||
var res = this.buy_number_handle(type, temp_goods, 'stock');
|
||
if(res === false) {
|
||
return false;
|
||
}
|
||
|
||
// 数据临时记录
|
||
this.setData({
|
||
temp_opt_data: {
|
||
pos: e,
|
||
goods: temp_goods,
|
||
type: type,
|
||
}
|
||
});
|
||
|
||
// 操作类型
|
||
if(res == 0) {
|
||
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);
|
||
}
|
||
}
|
||
}
|
||
},
|
||
|
||
// 批量删除操作
|
||
cart_all_delete_event(e) {
|
||
uni.showModal({
|
||
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']);
|
||
}
|
||
this.cart_delete(ids.join(','));
|
||
}
|
||
}
|
||
});
|
||
},
|
||
|
||
// 数量操作处理
|
||
buy_number_handle(type, goods, buy_number_field) {
|
||
// 门店状态
|
||
if(type == 1 && !this.is_status_check()) {
|
||
return false;
|
||
}
|
||
|
||
// 加减处理
|
||
var buy_number = parseInt(goods[buy_number_field]) || 0;
|
||
if(type == 0) {
|
||
buy_number -= 1;
|
||
} else {
|
||
buy_number += 1;
|
||
}
|
||
if(buy_number < 0) {
|
||
buy_number = 0;
|
||
}
|
||
|
||
// 数据校验
|
||
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;
|
||
if (min > 0) {
|
||
if(type == 0) {
|
||
if(buy_number < min) {
|
||
buy_number = 0;
|
||
}
|
||
} else {
|
||
if(buy_number < min) {
|
||
buy_number = min;
|
||
}
|
||
}
|
||
}
|
||
|
||
// 最大购买数量
|
||
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);
|
||
return false;
|
||
}
|
||
|
||
// 数量是否改变
|
||
if (goods[buy_number_field] == buy_number) {
|
||
app.globalData.showToast('数量未改变');
|
||
return false;
|
||
}
|
||
|
||
// 操作数量
|
||
var opt_number = 1;
|
||
if(type == 0) {
|
||
if(buy_number <= 0) {
|
||
opt_number = 0;
|
||
}
|
||
} else {
|
||
if(buy_number > goods['buy_number']) {
|
||
opt_number = buy_number-goods['buy_number'];
|
||
}
|
||
}
|
||
return opt_number;
|
||
},
|
||
|
||
// 购物车添加
|
||
cart_save(goods_id, buy_number, spec = '') {
|
||
uni.request({
|
||
url: app.globalData.get_request_url('save', 'cart'),
|
||
method: 'POST',
|
||
data: {
|
||
"goods_id": goods_id,
|
||
"stock": buy_number,
|
||
"spec": spec
|
||
},
|
||
dataType: 'json',
|
||
success: res => {
|
||
if (res.data.code == 0) {
|
||
this.cart_para_curve_handle();
|
||
this.get_cart_data();
|
||
} else {
|
||
if (app.globalData.is_login_check(res.data)) {
|
||
app.globalData.showToast(res.data.msg);
|
||
}
|
||
}
|
||
},
|
||
fail: () => {
|
||
app.globalData.showToast('服务器请求出错');
|
||
}
|
||
});
|
||
},
|
||
|
||
// 购物车更新
|
||
cart_update(cart_id, goods_id, buy_number) {
|
||
uni.request({
|
||
url: app.globalData.get_request_url("stock", "cart"),
|
||
method: 'POST',
|
||
data: {
|
||
"id": cart_id,
|
||
"goods_id": goods_id,
|
||
"stock": buy_number
|
||
},
|
||
dataType: 'json',
|
||
success: res => {
|
||
if (res.data.code == 0) {
|
||
this.cart_para_curve_handle();
|
||
this.get_cart_data();
|
||
} else {
|
||
if (app.globalData.is_login_check(res.data)) {
|
||
app.globalData.showToast(res.data.msg);
|
||
} else {
|
||
app.globalData.showToast('提交失败,请重试!');
|
||
}
|
||
}
|
||
},
|
||
fail: () => {
|
||
app.globalData.showToast('服务器请求出错');
|
||
}
|
||
});
|
||
},
|
||
|
||
// 购物车删除
|
||
cart_delete(cart_id) {
|
||
uni.request({
|
||
url: app.globalData.get_request_url('delete', 'cart'),
|
||
method: 'POST',
|
||
data: {
|
||
"id": cart_id
|
||
},
|
||
dataType: 'json',
|
||
success: res => {
|
||
if (res.data.code == 0) {
|
||
this.get_cart_data();
|
||
} else {
|
||
if (app.globalData.is_login_check(res.data)) {
|
||
app.globalData.showToast(res.data.msg);
|
||
} else {
|
||
app.globalData.showToast('提交失败,请重试!');
|
||
}
|
||
}
|
||
},
|
||
fail: () => {
|
||
app.globalData.showToast('服务器请求出错');
|
||
}
|
||
});
|
||
},
|
||
|
||
// 获取购物车数据、参数是否首次请求
|
||
get_cart_data(is_first = 0) {
|
||
uni.request({
|
||
url: app.globalData.get_request_url("cartdata", "detail", "realstore"),
|
||
method: 'POST',
|
||
data: this.request_params_merge({
|
||
"id": this.info.id || 0
|
||
}, 'cart'),
|
||
dataType: 'json',
|
||
success: res => {
|
||
if (res.data.code == 0) {
|
||
this.setData({
|
||
cart: res.data.data
|
||
});
|
||
this.cart_data_list_handle();
|
||
|
||
// 首次判断是否需要开启购物车
|
||
if(is_first == 1 && (this.params.is_show_cart || 0) == 1) {
|
||
this.setData({
|
||
cart_status: true
|
||
});
|
||
}
|
||
} else {
|
||
app.globalData.showToast('请求失败,请重试!');
|
||
}
|
||
},
|
||
fail: () => {
|
||
app.globalData.showToast('服务器请求出错');
|
||
}
|
||
});
|
||
},
|
||
|
||
// 购物车更新列表数据处理
|
||
cart_data_list_handle() {
|
||
var temp_cart = this.cart || null;
|
||
if(temp_cart != null) {
|
||
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;
|
||
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']);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
this.setData({
|
||
data_list: temp_data_list
|
||
});
|
||
}
|
||
},
|
||
|
||
// 门店状态判断
|
||
is_status_check() {
|
||
if((this.info || null) == null) {
|
||
app.globalData.showToast('门店信息有误');
|
||
return false;
|
||
} else {
|
||
if(this.info.status_info.status != 1) {
|
||
app.globalData.showToast(this.info.status_info.msg);
|
||
return false;
|
||
}
|
||
}
|
||
return true;
|
||
},
|
||
|
||
// 搜索事件
|
||
search_button_event(e) {
|
||
this.setData({
|
||
search_keywords_value: e || '',
|
||
data_page: 1
|
||
});
|
||
this.reset_scroll();
|
||
this.get_data_list(1);
|
||
},
|
||
|
||
// 搜索icon扫码事件、扫码商品id实现加入购物车
|
||
search_icon_event(e) {
|
||
var user = app.globalData.get_user_info(this);
|
||
if (user != false) {
|
||
// 用户未绑定用户则转到登录页面
|
||
if (app.globalData.user_is_need_login(user)) {
|
||
uni.navigateTo({
|
||
url: "/pages/login/login?event_callback=cart_buy_number_event"
|
||
});
|
||
return false;
|
||
} else {
|
||
// 门店状态
|
||
if(!this.is_status_check()) {
|
||
return false;
|
||
}
|
||
|
||
// 调用扫码
|
||
var self = this;
|
||
uni.scanCode({
|
||
success: function (res) {
|
||
uni.showLoading({
|
||
title: '处理中...',
|
||
mask: true
|
||
});
|
||
uni.request({
|
||
url: app.globalData.get_request_url("scan", "detail", "realstore"),
|
||
method: 'POST',
|
||
data: self.request_params_merge({
|
||
value: res.result
|
||
}, 'buy'),
|
||
dataType: 'json',
|
||
success: res => {
|
||
uni.hideLoading();
|
||
if (res.data.code == 0) {
|
||
if(res.data.data.is_error == 1) {
|
||
app.globalData.showToast(res.data.data.is_error_msg);
|
||
} else {
|
||
// 加入购物车
|
||
self.cart_save(res.data.data.goods_id, 1, res.data.data.spec);
|
||
}
|
||
} else {
|
||
if (app.globalData.is_login_check(res.data)) {
|
||
app.globalData.showToast(res.data.msg);
|
||
} else {
|
||
app.globalData.showToast('提交失败,请重试!');
|
||
}
|
||
}
|
||
},
|
||
fail: () => {
|
||
uni.hideLoading();
|
||
app.globalData.showToast('服务器请求出错');
|
||
}
|
||
});
|
||
}
|
||
});
|
||
}
|
||
}
|
||
},
|
||
|
||
// 购物车状态
|
||
cart_event(e) {
|
||
this.setData({
|
||
cart_status: !this.cart_status
|
||
});
|
||
},
|
||
|
||
// 购物车结算
|
||
buy_submit_event(e) {
|
||
if(!app.globalData.is_single_page_check()) {
|
||
return false;
|
||
}
|
||
|
||
// 门店状态
|
||
if(!this.is_status_check()) {
|
||
return false;
|
||
}
|
||
|
||
// 获取购物车数据
|
||
var ids = [];
|
||
if((this.cart || null) != null) {
|
||
var temp_data = this.cart.data || [];
|
||
for (var i in temp_data) {
|
||
ids.push(temp_data[i]['id']);
|
||
}
|
||
}
|
||
if (ids.length <= 0) {
|
||
app.globalData.showToast('请先选购商品');
|
||
return false;
|
||
}
|
||
|
||
// 起步价
|
||
var starting_price = parseFloat(this.info.starting_price) || 0;
|
||
if(starting_price > 0 && this.cart.total_price < starting_price) {
|
||
// 是否限制类型
|
||
var limit_type = this.info.starting_price_limit_type_list || [];
|
||
if(limit_type.length > 0) {
|
||
var buy_use_type = this.info.buy_use_type_list[this.buy_use_type_index];
|
||
if(limit_type.indexOf(buy_use_type['index']) != -1 || limit_type.indexOf(buy_use_type['index'].toString()) != -1) {
|
||
app.globalData.showToast(buy_use_type['name']+'起步价'+starting_price+'元');
|
||
return false;
|
||
}
|
||
} else {
|
||
app.globalData.showToast('起步价'+starting_price+'元');
|
||
return false;
|
||
}
|
||
}
|
||
|
||
// 进入订单确认页面
|
||
var data = this.request_params_merge({
|
||
"buy_type": "cart",
|
||
"ids": ids.join(',')
|
||
}, 'buy');
|
||
uni.navigateTo({
|
||
url: '/pages/buy/buy?data=' + encodeURIComponent(base64.encode(JSON.stringify(data)))
|
||
});
|
||
},
|
||
|
||
// 剪切板
|
||
text_copy_event(e) {
|
||
app.globalData.text_copy_event(e);
|
||
},
|
||
|
||
// 地图查看
|
||
address_map_event(e) {
|
||
var info = this.info;
|
||
if (info.lat == 0 || info.lng == 0) {
|
||
app.globalData.showToast("地址有误");
|
||
return false;
|
||
}
|
||
|
||
// 打开地图
|
||
var address = (info.province_name || '') + (info.city_name || '') + (info.county_name || '') + (info.address || '');
|
||
app.globalData.open_location(info.lng, info.lat, info.name, address);
|
||
},
|
||
|
||
// 电话
|
||
tel_event(e) {
|
||
app.globalData.call_tel(this.info.service_tel || null);
|
||
},
|
||
|
||
// 图片预览
|
||
image_show_event(e) {
|
||
app.globalData.image_show_event(e);
|
||
},
|
||
|
||
// 进入客服系统
|
||
chat_event() {
|
||
app.globalData.chat_entry_handle(this.info.chat_info.chat_url);
|
||
},
|
||
|
||
// 导航事件
|
||
nav_event(e) {
|
||
this.setData({
|
||
nav_active_index: e.currentTarget.dataset.index,
|
||
nav_active_item_index: e.currentTarget.dataset.itemindex,
|
||
data_page: 1
|
||
});
|
||
this.reset_scroll();
|
||
this.get_data_list(1);
|
||
},
|
||
|
||
// 重置滑动位置
|
||
reset_scroll() {
|
||
this.setData({
|
||
scroll_top: this.scroll_top_old
|
||
});
|
||
this.$nextTick(() => {
|
||
this.setData({
|
||
scroll_top: 0
|
||
});
|
||
});
|
||
},
|
||
|
||
// 滑动事件位置记录
|
||
scroll_event(e) {
|
||
this.setData({
|
||
scroll_top_old: e.detail.scrollTop
|
||
});
|
||
},
|
||
|
||
// 滚动加载
|
||
scroll_lower(e) {
|
||
this.get_data_list();
|
||
},
|
||
|
||
// 顶部返回操作
|
||
top_nav_left_back_event(e) {
|
||
var pages = getCurrentPages();
|
||
if (pages.length <= 1) {
|
||
uni.switchTab({
|
||
url: app.globalData.data.tabbar_pages[0]
|
||
});
|
||
} else {
|
||
uni.navigateBack();
|
||
}
|
||
},
|
||
|
||
// 地址信息初始化
|
||
user_location_init() {
|
||
var result = uni.getStorageSync(app.globalData.data.cache_userlocation_key) || null;
|
||
var data = null;
|
||
if (result != null) {
|
||
data = {
|
||
name: result.name || null,
|
||
address: result.address || null,
|
||
lat: result.latitude || null,
|
||
lng: result.longitude || null
|
||
};
|
||
}
|
||
this.setData({
|
||
user_location: data
|
||
});
|
||
},
|
||
|
||
// 使用类型事件
|
||
buy_use_type_event(e) {
|
||
var self = this;
|
||
uni.showActionSheet({
|
||
itemList: this.info.buy_use_type_list.map(function(v) {return v.name}),
|
||
success: function (res) {
|
||
self.setData({
|
||
buy_use_type_index: res.tapIndex,
|
||
data_page: 1
|
||
});
|
||
uni.setStorageSync(self.cache_buy_use_type_index_key, res.tapIndex);
|
||
self.reset_scroll();
|
||
self.get_data_list(1);
|
||
self.get_cart_data();
|
||
}
|
||
});
|
||
},
|
||
|
||
// 获取使用类型数据索引、默认在店0
|
||
get_buy_use_type_index() {
|
||
var index = uni.getStorageSync(this.cache_buy_use_type_index_key);
|
||
if((this.info || null) != null) {
|
||
// 用户未设置类型则使用默认的
|
||
if(index === null || index === '') {
|
||
// 是否默认类型
|
||
if(this.info.default_buy_use_type != undefined && this.info.default_buy_use_type != -1) {
|
||
// 不在店铺设置的类型列表则默认0
|
||
var temp_index = null;
|
||
for(var i in this.info.buy_use_type_list) {
|
||
if(this.info.buy_use_type_list[i]['index'] == this.info.default_buy_use_type) {
|
||
temp_index = i;
|
||
}
|
||
}
|
||
if(temp_index !== null) {
|
||
index = temp_index;
|
||
}
|
||
}
|
||
}
|
||
|
||
// 不在店铺设置的类型列表则默认0
|
||
if(this.info.buy_use_type_list[index] == undefined) {
|
||
index = 0;
|
||
}
|
||
}
|
||
return index || 0;
|
||
},
|
||
|
||
// 请求参数处理
|
||
// 默认增加使用类型参数
|
||
// 下单 buy / 初始化 init / 获取数据 data / 获取购物车 cart
|
||
request_params_merge(data, type = 'init') {
|
||
// 用户使用类型
|
||
var index = this.buy_use_type_index;
|
||
if((this.info || null) != null && (this.info.buy_use_type_list || null) != null && this.info.buy_use_type_list.length > 0) {
|
||
if(this.info.buy_use_type_list[index] == undefined) {
|
||
index = 0;
|
||
}
|
||
data['buy_use_type_index'] = index;
|
||
}
|
||
|
||
// 初始化
|
||
if(type == 'init') {
|
||
// 桌码
|
||
if((this.params.tablecode_id || null) != null) {
|
||
data['tablecode_id'] = this.params.tablecode_id;
|
||
}
|
||
}
|
||
|
||
// 初始化、获取数据
|
||
if(type == 'init' || type == 'data' || type == 'cart') {
|
||
// 用户选择的位置
|
||
var lng = 0;
|
||
var lat = 0;
|
||
if((this.user_location || null) != null) {
|
||
lng = this.user_location.lng || 0;
|
||
lat = this.user_location.lat || 0;
|
||
}
|
||
data['lng'] = lng;
|
||
data['lat'] = lat;
|
||
}
|
||
|
||
// 提交订单
|
||
if(type == 'buy') {
|
||
// 门店id
|
||
data['realstore_id'] = this.info.id;
|
||
|
||
// 桌码
|
||
if((this.tablecode || null) != null) {
|
||
data['tablecode_id'] = this.tablecode.id;
|
||
}
|
||
}
|
||
|
||
return data;
|
||
},
|
||
|
||
// url事件
|
||
url_event(e) {
|
||
app.globalData.url_event(e);
|
||
},
|
||
|
||
// 客服服务事件
|
||
header_service_event(e) {
|
||
this.setData({
|
||
header_service_status: !this.header_service_status
|
||
});
|
||
}
|
||
}
|
||
};
|
||
</script>
|
||
<style>
|
||
@import './detail.css';
|
||
</style> |