| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555 |
- <?php
- use common\helpers\ComponentHelper;
- ComponentHelper::loadComponentView('component/com-add-cat', __DIR__);
- ComponentHelper::loadComponentView('component/com-attr-group', __DIR__);
- ComponentHelper::loadComponentView('component/com-attr', __DIR__);
- ComponentHelper::loadComponentView('component/com-attrs-setting', __DIR__);
- ComponentHelper::loadComponentView('com-rich-text');
- ComponentHelper::loadComponentView('com-district');
- ComponentHelper::loadComponentView('com-coupon', Yii::$app->basePath . '/../addons/Coupon/backend/views/goods');
- ComponentHelper::loadComponentView('component/com-package-attr', Yii::$app->basePath . '/../addons/Store/client/views/goods');
- $addons_settings = empty($addons_settings) ? [] : $addons_settings;
- foreach ($addons_settings as $key => $item) {
- ComponentHelper::loadComponentView($item['components'], Yii::$app->basePath . '/../addons/' . ucfirst($key) . '/backend/views/goods');
- }
- $addons_settings = \yii\helpers\Json::encode($addons_settings);
- if (!empty($components)) {
- foreach ($components as $addons => $component) {
- if(!file_exists($component['path'])) continue;
- ComponentHelper::loadComponentView($component['component'], $component['path']);
- }
- $components = \yii\helpers\Json::encode($components);
- }
- ?>
- <script src="/resources/js/Sortable.min.js"></script>
- <script src="/resources/unpkg/vuedraggable@2.18.1/dist/vuedraggable.umd.min.js"></script>
- <style>
- <?= ComponentHelper::loadComponentView('edit', __DIR__ . '/css', [], true, 'css'); ?>
- </style>
- <div id="app" v-cloak>
- <el-card shadow="never" style="border:0" class="box-card" body-style="background-color: #f3f3f3;padding: 20px 0 0;" class="box-card" v-loading="cardLoading">
- <!-- <div slot="header">
- <div flex="cross:center box:first">
- <div><span @click="$navigate({r:'mall/goods/index'})" class="text">商品列表</span>/编辑商品</div>
- </div>
- </div> -->
- <div class="goods-box">
- <el-form :model="ruleForm" :rules="rules" ref="ruleForm" size="mini" label-width="150px" class="demo-ruleForm">
- <!-- tab切换 -->
- <div class="tabs-box">
- <div class="tabs-list" flex="cross:center">
- <span v-for="(item, index) in tabs" :key="index" class="tabs-item" :class="item.value == activeName ? 'tabActive' : ''" @click="toggle(item, index, 'tabs')">{{item.name}}</span>
- </div>
- </div>
- <!-- 基础设置 -->
- <div v-show="activeName == 'basic'">
- <?= ComponentHelper::loadComponentView('goods-basic', __DIR__) ?>
- </div>
- <div v-show="activeName == 'mode'">
- <template v-if="addonsSettings">
- <div class="goods-box">
- <!-- <el-form :model="settingForm" ref="settingForm" size="mini" label-width="150px" class="demo-ruleForm"> -->
- <div class="basic">
- <!-- 分润设置 -->
- <component v-for="(addons,index) in addonsSettings" v-bind:is="addons.components" :goods="goods" :level_arr="level" :commission_type_map="commission_type_map" :coupon_type_map="coupon_type_map" :setting="setting[index]" @change="getData" :key="index" :boss_commission_type="{commission: '佣金'}" style="margin-bottom:20px"></component>
- </div>
- <!-- </el-form> -->
- </div>
- </template>
- <template v-else>
- <el-button size="mini" type="info" >相关应用分润未设置</el-button>
- </template>
- </div>
- <div v-show="activeName == 'marketing'">
- <?= ComponentHelper::loadComponentView('goods-marketing', __DIR__) ?>
- </div>
- <!-- 关联商品 -->
- <div v-show="activeName == 'goods_association'">
- <?= ComponentHelper::loadComponentView('goods-association', __DIR__) ?>
- </div>
- </el-form>
- </div>
- </el-card>
- <div v-if="isAudit" class="bottom-btns" flex="main:center cross:center">
- <el-button size="mini" type="primary" @click="goodAudit('adopt')" :loading="btnLoading">通过</el-button>
- <el-button size="mini" type="primary" @click="goodAuditFailed('failed')" :loading="btnLoading">不通过</el-button>
- </div>
- <div v-else-if="supplier_type != 4" class="bottom-btns" flex="main:center cross:center">
- <el-button size="mini" type="primary" @click="submit()" :loading="btnLoading">保存</el-button>
- </div>
- </div>
- <script>
- const app = new Vue({
- el: '#app',
- data() {
- return {
- tabs: [{
- name: '基础设置',
- value: 'basic'
- },
- {
- name: '营销配置',
- value: 'marketing'
- },
- {
- name: '模式设置',
- value: 'mode'
- },
- {
- name: '关联商品',
- value: 'goods_association'
- },
- ],
- activeName: 'basic',
- typeArr: [],
- goods_type: 'physical',
- is_base_show: false,
- is_mch: false,
- is_default_services: 1,
- typeIndex: 0,
- btnLoading: false,
- cardLoading: false,
- cats: [],
- freight_id: 0,
- goodsId: null,
- // freight: {
- // dialog: false,
- // list: [],
- // checked: {},
- // loading: false
- // },
- attrGroups: [], //规格组
- attrGroupName: '',
- attrName: [],
- // 批量设置
- batch: {},
- label_list: [], // 商品标签列表
- service_list: [], // 商品服务列表
- freight_rules: [ // 运费模板
- // {
- // id: '1',
- // name: '全国包邮'
- // },
- // {
- // id: '2',
- // name: '北京包邮'
- // }
- ],
- is_show_freight: false,
- defaultMemberPrice: [],
- member_level_list: [
- // {level: 1, name: '普通用户', value: {"sign_id_2:4":40, "sign_id_3:4": 41, "sign_id_2:5": 41, "sign_id_3:5": 41}},
- // {level: 2, name: '权重2', value: {"sign_id_2:4":30, "sign_id_3:4": 31, "sign_id_2:5": 32, "sign_id_3:5": 33}},
- // {level: 3, name: '权重3', value: {"sign_id_2:4":20, "sign_id_3:4": 21, "sign_id_2:5": 22, "sign_id_3:5": 23}},
- // {level: 4, name: '权重4', value: {"sign_id_2:6":10, "sign_id_3:4": 11, "sign_id_2:5": 12, "sign_id_3:5": 13}}
- ],
- dialogVisible: false, // 配送范围弹出框
- earaRule: [],
- multiple_selection: [], //优惠券
- is_show_counpon: 0, //优惠券是否展示
- show_addons: <?= $components ?? '{}'; ?>, //插件营销是否展示
- the_addons_name: 'Store',
- ruleForm: {
- /*********************************** 基础设置 ****************************************/
- goods_type: 1,
- goods_name: '',
- subtitle: '',
- cover_pic: '',
- bannar_pic: [],
- video_url: '',
- cats: [],
- mchCats: [], //多商户系统分类
- services: [],
- freight: null,
- labels: '', // 商品标签
- is_attr: 0, // 是否有规格
- attr: [],
- price: 0,
- original_price: 0,
- cost_price: 0,
- stock: '',
- unit: '', // 单位
- stock_warning: 0, // 库存预警 - 自定义字段,后面改
- goods_weight: 0, // 商品重量 - 自定义字段,后面改
- goods_no: '', // 商品货号
- is_show_stock: 1, // 是否显示库存 - 自定义字段,后面改
- is_show_sales: 1, // 是否显示销量 - 自定义字段,后面改
- virtual_sales: 0,
- coupon_is_enable: 0, //优惠卷的开关
- // logistics_way: [{
- // name: '快递发货',
- // checked: true
- // }], // 快递发货 - 自定义字段,后面改
- freight_type: [1], //物流方式 1快递物流
- freight_rules_type: 1, // 运费规则类型 1运费模板 2统一运费
- freight_id: '', // 运费模板ID
- shipping_fee: 0, //统一运费
- free_shipping_num: 0, //满N件包邮
- free_shipping_money: 0, //满N元包邮
- is_cross_border: 0, // 是否跨境商品 - 自定义字段,后面改
- is_id_card: 0, // 是否身份证上传 - 自定义字段,后面改
- is_on_sale: 1, // 是否上架
- show_style: 1, // 展示风格
- extra: {
- full_reduce_price_limit: 0, // 单品满额减免价格阈值
- full_reduce_money: 0, // 单品满额减免金额
- score_give_setting: {
- is_alone:0,
- code: 'score',
- name: '积分',
- give_num: 0, // 货币赠送
- give_type: 1, // 货币赠送 1.固定值 2售价百分比
- condition: 0, // 条件
- },
- is_member_price: 0,
- member_price_setting: {},
- member_buy_limit_setting: {
- member_level: [],
- every_num: 0,
- every_day_num: 0,
- every_week_num: 0,
- every_month_num: 0,
- nums: 0,
- total_num: 0,
- },
- currency_deduct_setting: [], // 货币这块有bug,暂时不需要展示,所以不需要提交数据
- repurchase_setting: [],
- is_repurchase: 0,
- is_alone_settle:0,
- alone_settle_price:0,
- service_fee_setting: {
- is_alone: 0,
- service_fee_ratio: null
- },
- platform_service_fee_setting: {
- service_fee_type: 0,
- max_platform_ratio: 0,
- min_platform_ratio: 0,
- }
- },
- coupon_selection: [],
- goods_setting: {
- /*********************************** 用户权益 **********************************************/
- member_setting: { // 用户权益模块提交的格式
- member_price_setting: '',
- member_price: {},
- member_buy_limit_setting: {
- member_level: [],
- every_num: 0,
- every_day_num: 0,
- every_week_num: 0,
- every_month_num: 0,
- nums: 0,
- total_num: 0,
- }
- },
- /*********************************** 营销设置 **********************************************/
- marketing_setting: { // 营销配置模块提交的格式
- full_reduce_price_limit: 0, // 单品满额减免价格阈值
- full_reduce_money: 0, // 单品满额减免金额
- score_give_setting: {
- code: 'score',
- name: '积分',
- give_num: 0, // 货币赠送
- give_type: 1, // 货币赠送 1.固定值 2售价百分比
- },
- score_deduct_setting: {
- code: 'score',
- name: '积分',
- deduct_num: 0, // 货币抵扣
- deduct_type: 1, // 1.单件抵扣 2.多件累计抵扣
- },
- currency_deduct_setting: [], // 货币这块有bug,暂时不需要展示,所以不需要提交数据
- }
- },
- /******************************* 配送范围 ************************************/
- is_area_limit: 0,
- // area_limit: [{ list: [] }]
- area_limit: [],
- is_sync_goods: 0,
- addons: {},
- // 预约商品
- reserve: {
- reserve_date_type: 1, // 可预约时间类型(1范围 2自选日期)
- reserve_date: null, // 可预约日期
- reserve_time_range_type: 1, //预约模式(1按天预约 2按时间段预约)
- time_slot_type: 1, // 时间段划分方式(1自定义划分 2自动划分)
- reserve_time_slot: null, // 时间段划分
- reserve_price_type: 0, // 价格设置方式(0统一售价 1按日期时间段设置)
- reserve_time_slot_price: [], // 按时间段设置的价格
- reserve_week: [0,1,2,3,4,5,6], // 可预约周,如:0,1,2,3,4,5,6
- reserve_max_buy: 0, // 每天最大预约数量
- reserve_advance_hourse: 0, // 提前预约时间(小时)
- reserve_days_range: 0, //限制选择并购买的时间在设置内天数的商品
- cancel_type: 1, // 取消类型(1不允许取消 2服务开始前取消 3订单类型取消)
- cancel_rule: {
- cancel_hour: 0,
- cancel_fee_percent: 0
- }, // 取消规则
- expired_handle_type: 1, // 预约码过期后处理方式(1不退款 2自动退款)
- service_type: 1, // 服务方式(1上门 2到店)
- // 位置信息
- province_id: 0, // 省份Id
- city_id: 0, // 城市Id
- district_id: 0, // 区县Id
- detail: '', // 详细地址
- lat: '', // 纬度
- lng: '', // 经度
- skus: [], // 预约多规格
- ordering_information: '', // 订购须知
- information_detail: '', // 须知详情
- reserve_type: 1, // 门店只能是1
- distance: '', // 有效距离
- },
- },
- rules: {
- cats: [{
- required: true,
- type: 'array',
- validator: (rule, value, callback) => {
- if (this.ruleForm.cats instanceof Array && this.ruleForm.cats.length > 0) {
- callback();
- }
- callback('请选择分类');
- }
- }],
- mchCats: [{
- required: true,
- type: 'array',
- validator: (rule, value, callback) => {
- if (this.ruleForm.mchCats instanceof Array && this.ruleForm.mchCats.length > 0) {
- callback();
- }
- callback('请选择系统分类');
- }
- }],
- goods_name: [{
- required: true,
- message: '请输入商品名称',
- trigger: 'blur'
- }],
- cover_pic: [{
- required: true,
- message: '请添加图片',
- trigger: 'change'
- }],
- price: [{
- required: true,
- message: '请输入价格',
- trigger: 'blur'
- }],
- extra: {
- full_reduce_price_limit: [{
- validator: (rule, value, callback) => {
- if (value > 1000000) {
- callback('不能大于1000000');
- }
- callback();
- }
- }],
- full_reduce_money: [{
- validator: (rule, value, callback) => {
- if (value > 1000000) {
- callback('不能大于1000000');
- }
- callback();
- }
- }]
- },
- stock: [{
- required: true,
- message: '请输入商品库存',
- trigger: 'blur'
- }],
- // area_limit: [{
- // required: true,
- // type: 'array',
- // validator: (rule, value, callback) => {
- // if (value instanceof Array && value[0]['list'].length === 0) {
- // callback('允许购买区域不能为空');
- // }
- // callback();
- // }
- // }],
- },
- revealArea: [],
- extra1_goods_list:[],
- extra2_goods_list:[],
- isAudit: false,
- addonsSettings: <?= $addons_settings ?? '{}'; ?>, // 各个插件模式配置
- setting: {},
- commission_type_map: {},
- coupon_type_map: {},
- goods: {},
- level: {},
- settingForm: {},
- storeId: 0,
- package_data: [],
- supplier_type: 0,
- store_login_url: '',
- };
- },
- created() {
- this.goodsId = parseInt(getQuery('id'));
- this.isAudit = getQuery('is_audit');
- let isMode = getQuery('is_mode');
- if (isMode) {
- this.activeName = 'mode';
- } else {
- this.activeName = 'basic';
- }
- },
- mounted: function() {
- this.getGoodsDetail();
- this.getModelDetail();
- },
- watch: {
- 'ruleForm.detail'(newVal, oldVal) {
- this.cForm.detail = newVal
- },
- 'ruleForm.show_style'(newVal, oldVal) {
- if (newVal != oldVal) {
- // this.attrGroups = []
- // this.ruleForm.attr = []
- }
- if (newVal == 2) {
- this.ruleForm.is_attr = 1
- }
- }
- },
- computed: {
- cForm() {
- let form = {};
- let ruleForm = JSON.parse(JSON.stringify(this.ruleForm));
- if (this.form) {
- form = Object.assign(ruleForm, JSON.parse(JSON.stringify(this.form)));
- } else {
- form = ruleForm;
- }
- if (getQuery('id')) {
- form.id = getQuery('id')
- }
- return form;
- },
- cRule() {
- return this.rule ? Object.assign({}, this.rules, this.rule) : this.rules;
- },
- },
- methods: {
- changeFreightType() {
- this.is_show_freight = inArray(1, this.ruleForm.freight_type);
- },
- getGoodsDetail() {
- let self = this;
- self.cardLoading = true;
- request({
- params: {
- r: 'store/store-goods/edit',
- id: getQuery('id')
- },
- method: 'get',
- }).then(e => {
- self.cardLoading = false;
- if (e.data.code == 0) {
- if (!isEmpty(e.data.data.detail)) {
- if(e.data.data.detail.goods_type && e.data.data.detail.goods_type == 3){
- self.isEdit = true;
- self.ruleForm = e.data.data.detail;
- console.log("gggvv",e.data.data.detail);
- //self.ruleForm = JSON.parse(JSON.stringify(e.data.data.detail));
- self.long_lat = self.ruleForm.reserve.lat + '-' + self.ruleForm.reserve.lng;
- if(!(self.ruleForm.reserve && self.ruleForm.reserve.cancel_rule)){
- self.ruleForm.reserve.cancel_rule = {
- cancel_hour: 0,
- cancel_fee_percent: 0
- }
- }
- if(this.ruleForm.is_attr == 1){
- if(self.ruleForm.reserve && self.ruleForm.reserve.skus && self.ruleForm.reserve.skus.length){
- self.ruleForm.attr = [];
- let receiveList = self.ruleForm.reserve.skus;
- receiveList.forEach(item => {
- item.checkRangeList = [];
- item.dayArr = [];
- item.checkWeekList = [];
- item.selectTimeList = [];
- item.finalData = [];
- if(item.reserve_date_type == 1 && this.ruleForm.reserve.reserve_type == 0){
- item.reserve_date.sort(function (a, b) {
- return new Date(a) - new Date(b);
- });
- item.checkRangeList.push(item.reserve_date[0],item.reserve_date[item.reserve_date.length-1]);
- let val = [new Date(item.checkRangeList[0]),new Date(item.checkRangeList[1])];
- let arr = [];
- let txtArr = [{val: 0,txt: '周日',children: []},{val: 1,txt: '周一',children: []},{val: 2,txt: '周二',children: []},{val: 3,txt: '周三',children: []},{val: 4,txt: '周四',children: []},{val: 5,txt: '周五',children: []},{val: 6,txt: '周六',children: []}];
- if (val.length) {
- let arr1 = [];
- let str1 = val[0];
- let str2 = val[1];
- let unixDb = str1.getTime() - 24 * 60 * 60 * 1000;
- let unixDe = str2.getTime() - 24 * 60 * 60 * 1000;
- for(let j = unixDb; j <= unixDe;){
- j = j + 24 * 60 * 60 * 1000
- arr1.push(new Date(parseInt(j)))
- }
- for(let i = 0; i < arr1.length; i++){
- txtArr.forEach(it => {
- if(it.val == arr1[i].getDay()){
- let fm = this.formatDate(arr1[i])
- it.children.push(fm);
- }
- })
- }
- txtArr.forEach(it => {
- if(it.children.length){
- arr.push(it);
- }
- });
- item.dayArr = arr;
- }
- let warr = [];
- item.dayArr.forEach(it => {
- warr.push(it.txt);
- });
- item.checkWeekList = [...new Set(warr)];
- let selectArr = [];
- let selectDateArr = [];
- for(let i = 0; i < item.dayArr.length; i++){
- item.checkWeekList.forEach(it => {
- if(it == item.dayArr[i].txt){
- selectArr.push(item.dayArr[i]);
- }
- });
- }
- for(let j = 0; j < selectArr.length; j++){
- selectDateArr = selectDateArr.concat(selectArr[j].children);
- }
- item.reserve_date = selectDateArr;
- }
- if(item.reserve_time_slot_price && item.reserve_time_slot_price.length){
- item.reserve_time_slot_price.forEach(it => {
- item.finalData.push({
- date: it.reserve_time,
- time_spec: it.time_spec,
- isSelect: false,
- times: [],
- selectTimes: []
- });
- item.selectTimeList.push({
- date: it.reserve_time,
- isSelect: false,
- children: [],
- intervalList: [],
- checkAll: false,
- isIndeterminate: true,
- checkedIntervalList: [],
- time_spec: it.time_spec,
- });
- });
- } else if (item.reserve_price_type == 2 && typeof item.reserve_time_slot_price == "object") { // 按天设置价格
- for (let day in item.reserve_time_slot_price) {
- item.finalData.push({
- date: day,
- price: item.reserve_time_slot_price[day].price || 0,
- linePrice: item.reserve_time_slot_price[day].original_price || 0,
- reservationNum: item.reserve_time_slot_price[day].reserve_max_buy || 0,
- children: item.reserve_time_slot_price[day].children || [],
- times: item.reserve_time_slot_price[day].times || []
- })
- }
- }
- item.finalData.forEach(ite => {
- if(ite.time_spec.length){
- ite.time_spec.forEach(it => {
- ite.times.push(it.spec_time);
- ite.selectTimes.push({
- time: it.spec_time,
- price: it.price,
- linePrice: it.original_price,
- reservationNum: it.reserve_max_buy
- });
- });
- }
- });
- item.selectTimeList.forEach(ite => {
- if(ite.time_spec.length){
- ite.time_spec.forEach(it => {
- ite.children.push(it.spec_time);
- });
- }
- });
- });
- let targetArr = [];
- receiveList.forEach(item => {
- targetArr.push({
- attr_list: item.attr_list || [],
- reserve_date_type: item.reserve_date_type || 1,
- reserve_date: item.reserve_date || [],
- reserve_time_range_type: item.reserve_time_range_type || 1,
- time_slot_type: item.time_slot_type || 1,
- reserve_time_slot: item.reserve_time_slot || null,
- reserve_price_type: item.reserve_price_type || 0,
- reserve_time_slot_price: JSON.parse(JSON.stringify(item.reserve_time_slot_price)) || null,
- reserve_week: JSON.parse(JSON.stringify(item.reserve_week)) || [0,1,2,3,4,5,6],
- reserve_max_buy: item.reserve_max_buy || null,
- price: item.price || null,
- original_price: item.original_price || null,
- dayArr: item.dayArr || [],
- checkWeekList: item.checkWeekList || [],
- checkRangeList: item.checkRangeList || [],
- selectTimeList: JSON.parse(JSON.stringify(item.selectTimeList)) || [],
- finalData: item.finalData || [],
- service_min: item.service_min || 0,
- unit: item.unit || '',
- });
- });
- targetArr.forEach(item => {
- item.selectTimeList.forEach(it => {
- it.children = JSON.stringify(it.children);
- it.time_spec = JSON.stringify(it.time_spec);
- });
- });
- targetArr.forEach(item => {
- let obj = {
- attr_list: JSON.parse(JSON.stringify(item.attr_list)),
- reserve_date_type: item.reserve_date_type,
- reserve_date: JSON.parse(JSON.stringify(item.reserve_date)),
- reserve_time_range_type: item.reserve_time_range_type,
- time_slot_type: item.time_slot_type,
- reserve_time_slot: item.reserve_time_slot,
- reserve_price_type: item.reserve_price_type,
- reserve_time_slot_price: JSON.parse(JSON.stringify(item.reserve_time_slot_price)),
- reserve_week: JSON.parse(JSON.stringify(item.reserve_week)),
- reserve_max_buy: item.reserve_max_buy,
- price: item.price,
- original_price: item.original_price,
- dayArr: JSON.parse(JSON.stringify(item.dayArr)),
- checkWeekList: JSON.parse(JSON.stringify(item.checkWeekList)),
- checkRangeList: JSON.parse(JSON.stringify(item.checkRangeList)),
- selectTimeList: JSON.parse(JSON.stringify(item.selectTimeList)),
- finalData: JSON.parse(JSON.stringify(item.finalData)),
- service_min: item.service_min || 0,
- unit: item.unit || '',
- }
- self.ruleForm.attr.push(JSON.stringify(obj));
- });
- for(let i = 0; i < self.ruleForm.attr.length; i++){
- self.ruleForm.attr[i] = JSON.parse(self.ruleForm.attr[i]);
- }
- self.ruleForm.attr.forEach(item => {
- item.selectTimeList.forEach(it => {
- it.children = JSON.parse(it.children);
- it.time_spec = JSON.parse(it.time_spec);
- });
- });
- }
- }else{
- if(self.ruleForm.reserve && self.ruleForm.reserve.reserve_date && self.ruleForm.reserve.reserve_date.length){
- if(self.ruleForm.reserve.reserve_date_type == 1){
- self.ruleForm.reserve.reserve_date.sort(function (a, b) {
- return new Date(a) - new Date(b);
- });
- self.checkRangeList.push(self.ruleForm.reserve.reserve_date[0],self.ruleForm.reserve.reserve_date[self.ruleForm.reserve.reserve_date.length-1]);
- this.dateSelectChange([new Date(self.checkRangeList[0]),new Date(self.checkRangeList[1])]);
- }
- self.ruleForm.reserve.reserve_time_slot_price.forEach(item => {
- self.initializationDates.push({
- date: item.reserve_time,
- time_spec: item.time_spec,
- isSelect: false,
- times: [],
- selectTimes: []
- });
- });
- self.initializationDates.forEach(item => {
- if(item.time_spec.length){
- item.time_spec.forEach(it => {
- item.times.push(it.spec_time);
- item.selectTimes.push({
- time: it.spec_time,
- price: it.price,
- linePrice: it.original_price,
- reservationNum: it.reserve_max_buy
- });
- });
- }
- });
- }
- }
- }else{
- self.ruleForm = Object.assign(self.ruleForm, e.data.data.detail);
- self.ruleForm.attr = e.data.data.detail.attr;
- }
- self.attrGroups = e.data.data.detail.attr_groups;
- self.storeId = e.data.data.detail.store_id;
- self.cats = e.data.data.detail.cats;
- self.selectCat(e.data.data.detail.cats)
- for (let key in e.data.data.detail.freight_type) {
- if (e.data.data.detail.freight_type[key] == 1) {
- this.is_show_freight = true;
- break;
- }
- }
- if (self.ruleForm.area_limit) {
- self.deduplicationArea();
- }
- }
- self.label_list = e.data.data.labels;
- self.service_list = e.data.data.services;
- self.member_level_list = e.data.data.levels;
- // 以下数据用于默认规格情况下的 用户价设置
- if (!e.data.data.detail.is_attr && e.data.data.detail.is_attr != 0) {
- self.member_level_list.forEach((item, index) => {
- let obj = {};
- obj['id'] = index;
- obj['name'] = item.name;
- obj['level'] = 'level' + parseInt(item.level);
- var key = item.level + '';
- self.$set(this.ruleForm.extra.member_price_setting, key, 0);
- });
- }
- // 以下数据用于默认规格情况下的 用户价设置
- var memberSetting = e.data.data.detail.extra;
- self.member_level_list.forEach(function(item, index) {
- let obj = {};
- let key = 'level' + parseInt(item.level);
- obj['id'] = index;
- obj['name'] = item.name;
- obj['level'] = key;
- if (memberSetting && memberSetting.member_price_setting && memberSetting.member_price_setting[key]) {
- self.member_level_list[index]['value'] = memberSetting.member_price_setting[key]; // 赋值到用户列表数据中
- } else {
- self.member_level_list[index]['value'] = {};
- }
- self.defaultMemberPrice.push(obj);
- });
- self.typeArr = e.data.data.goods_type;
- self.freight_rules = e.data.data.freight_rules;
- // 默认运费模板
- if (self.ruleForm.freight_rules_type == 1 && isEmpty(self.ruleForm.freight_id) && self.freight_rules.length > 0) {
- self.ruleForm.freight_id = self.freight_rules[0].id;
- }
- this.extra1_goods_list = e.data.data.extra1_goods_list;
- this.extra2_goods_list = e.data.data.extra2_goods_list;
- self.ruleForm.show_style = self.ruleForm.show_style;
- this.store_login_url = e.data.data.store_login_url;
- // 套餐数据
- self.package_data = e.data.data.detail.package_data
- this.supplier_type = e.data.data.detail.supplier_type;
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- /* 配送范围start */
- openDistrict() {
- this.dialogVisible = true;
- this.earaRule = this.ruleForm.area_limit;
- },
- selectDistrict(e) {
- let list = [];
- for (let i in e) {
- let obj = {
- id: e[i].id,
- name: e[i].name
- };
- list.push(obj);
- }
- this.earaRule = list;
- },
- districtConfirm() {
- this.ruleForm.area_limit = JSON.parse(JSON.stringify(this.earaRule));
- this.deduplicationArea();
- this.dialogVisible = false;
- // this.$refs['ruleForm'].validate((valid) => {
- // return false;
- // })
- },
- deduplicationArea() {
- let that = this;
- let reg = /市$|特别行政区$/;
- let filt = [...new Set(this.ruleForm.area_limit.filter(v => reg.test(v.name)).map(v => v.name))];
- this.ruleForm.area_limit.forEach(v => {
- let length = that.revealArea.filter(f => f.name == v.name).length;
- if (filt.findIndex(f => f == v.name) != -1 && length > 0) {
- return;
- }
- that.revealArea.push(v);
- })
- },
- space() { // 删除地区
- this.ruleForm.area_limit = [];
- },
- /* 配送范围end */
- showMore(type) { // 展开更多
- switch (type) {
- case 'base':
- this.is_base_show = !this.is_base_show
- }
- },
- toggle(it, i, type) { // tab切换
- console.log(it, i, type, 'toggle ==========');
- switch (type) {
- case 'tabs':
- this.activeName = it.value
- break;
- case 'select':
- if (this.ruleForm.id > 0) return;
- this.ruleForm.goods_type = it.type
- break;
- default:
- break;
- }
- },
- coverPic(e) { // 选择图片
- this.ruleForm.cover_pic = e[0].url
- },
- bannerPic(e) { // 选择轮播图
- if (e.length) {
- e.forEach((item, index) => {
- if (this.ruleForm.bannar_pic.length >= 9) return;
- this.ruleForm.bannar_pic.push({
- id: item.id,
- pic_url: item.url
- });
- })
- }
- },
- delPic(type, index) { // 删除图片
- switch (type) {
- case 'cover_pic':
- this.ruleForm.cover_pic = ''
- break;
- case 'bannar_pic':
- this.ruleForm.bannar_pic.splice(index, 1)
- break;
- default:
- break;
- }
- },
- // 商品视频
- videoUrl(e) {
- if (e.length) {
- this.ruleForm.video_url = e[0].url;
- }
- },
- /*---商品分类----*/
- selectCat(cats) {
- this.cats = cats;
- let arr = [];
- cats.map(v => {
- arr.push(v.id);
- })
- this.ruleForm.cats = arr;
- this.$refs.ruleForm.validateField('cats');
- },
- selectMchCat(cats) {
- this.mchCats = cats;
- let arr = [];
- cats.map(v => {
- arr.push(v.id);
- })
- this.ruleForm.mchCats = arr;
- this.$refs.ruleForm.validateField('mchCats');
- },
- /*---商品分类end----*/
- /*----规格start----*/
- // 规格组合
- makeAttrGroup(e) {
- let self = this;
- let array = [];
- self.attrGroups.forEach(function(attrGroupItem, attrGroupIndex) {
- attrGroupItem.attr_list.forEach(function(attrListItem, attrListIndex) {
- let object = {
- attr_group_id: attrGroupItem.attr_group_id,
- attr_group_name: attrGroupItem.attr_group_name,
- attr_id: attrListItem.attr_id,
- attr_name: attrListItem.attr_name,
- };
- if (!array[attrGroupIndex]) {
- array[attrGroupIndex] = [];
- }
- array[attrGroupIndex].push(object)
- });
- });
- // 2.属性排列组合
- const res = array.reduce((osResult, options) => {
- return options.reduce((oResult, option) => {
- if (!osResult.length) {
- return oResult.concat(option)
- } else {
- return oResult.concat(osResult.map(o => [].concat(o, option)))
- }
- }, [])
- }, []);
- // 3.组合结果赋值
- for (let i in res) {
- const options = Array.isArray(res[i]) ? res[i] : [res[i]];
- const row = {
- attr_list: options,
- stock: typeof(self.ruleForm.attr[i]) == 'undefined' ? 0 : self.ruleForm.attr[i].stock,
- price: typeof(self.ruleForm.attr[i]) == 'undefined' ? 0 : self.ruleForm.attr[i].price,
- original_price: typeof(self.ruleForm.attr[i]) == 'undefined' ? 0 : self.ruleForm.attr[i].original_price,
- cost_price: typeof(self.ruleForm.attr[i]) == 'undefined' ? 0 : self.ruleForm.attr[i].cost_price,
- no: typeof(self.ruleForm.attr[i]) == 'undefined' ? '' : self.ruleForm.attr[i].no,
- weight: typeof(self.ruleForm.attr[i]) == 'undefined' ? 0 : self.ruleForm.attr[i].weight,
- pic_url: typeof(self.ruleForm.attr[i]) == 'undefined' ? '' : self.ruleForm.attr[i].pic_url,
- distributionLevelList: [],
- levelPrice: typeof(self.ruleForm.attr[i]) == 'undefined' ? {} : self.ruleForm.attr[i].levelPrice,
- sign_id: typeof(self.ruleForm.attr[i]) == 'undefined' ? '' : self.ruleForm.attr[i].sign_id,
- };
- let arr = [];
- row.attr_list.forEach(val => {
- arr.push(val.attr_id);
- })
- // console.info(arr.join(":"),"::::");
- row.sign_id = arr.join(":");
- // 动态绑定多规格用户价
- let obj = {};
- self.member_level_list.forEach(function(item, index) {
- let key = 'level' + item.level;
- obj[key] = 0;
- });
- row['member_price'] = obj;
- // 3-1.已设置数据的优先使用原数据
- if (self.ruleForm.attr.length) {
- for (let j in self.ruleForm.attr) {
- const oldOptions = [];
- for (let k in self.ruleForm.attr[j].attr_list) {
- oldOptions.push(self.ruleForm.attr[j].attr_list[k].attr_name)
- }
- const newOptions = [];
- for (let k in options) {
- newOptions.push(options[k].attr_name)
- }
- if (oldOptions.toString() === newOptions.toString()) {
- row['price'] = self.ruleForm.attr[j].price;
- row['stock'] = self.ruleForm.attr[j].stock;
- row['no'] = self.ruleForm.attr[j].no;
- row['weight'] = self.ruleForm.attr[j].weight;
- row['pic_url'] = self.ruleForm.attr[j].pic_url;
- break
- }
- }
- }
- res[i] = row;
- }
- self.ruleForm.attr = res;
- console.log(self.ruleForm.attr, '-------------------------------attr');
- },
- // 批量设置
- batchAttr(key) {
- let self = this;
- if (self.batch[key] && self.batch[key] >= 0 || key === 'no') {
- self.ruleForm.attr.forEach(function(item, index) {
- // 批量设置用户价
- // 判断字符串是否出现过,并返回位置
- if (key.indexOf('level') !== -1) {
- item['member_price'][key] = self.batch[key];
- } else {
- item[key] = self.batch[key];
- }
- });
- }
- },
- destroyCat(value, index) {
- let self = this;
- self.ruleForm.cats.splice(self.ruleForm.cats.indexOf(value), 1)
- self.cats.splice(index, 1)
- },
- /*----规格end----*/
- submit() {
- if(this.ruleForm.cats.length && (typeof this.ruleForm.cats[0]) !== 'number'){
- let idarr = [];
- this.ruleForm.cats.forEach(item => {
- idarr.push(item.id);
- });
- this.ruleForm.cats = JSON.parse(JSON.stringify(idarr));
- }
- let _ = this
- if(this.ruleForm.goods_type == 3){
- if(this.ruleForm.is_attr == 1){
- let skus = [];
- this.ruleForm.attr.forEach(item => {
- skus.push({
- attr_list: JSON.parse(JSON.stringify(item.attr_list)),
- reserve_date_type: item.reserve_date_type,
- reserve_date: item.reserve_date,
- reserve_time_range_type: item.reserve_time_range_type,
- time_slot_type: item.time_slot_type,
- reserve_price_type: item.reserve_price_type,
- reserve_max_buy: item.reserve_max_buy,
- price: item.price,
- original_price: item.original_price,
- reserve_time_slot: item.reserve_time_slot,
- reserve_time_slot_price: [],
- reserve_week: item.reserve_week,
- service_min: item.service_min,
- unit: item.unit,
- finalData: JSON.parse(JSON.stringify(item.finalData)),
- selectTimeList: JSON.parse(JSON.stringify(item.selectTimeList))
- });
- });
- skus.forEach(item => {
- // 0统一设置价格 1 按时间段设置 2按天设置 - 只有按时间段才有finalData数据
- // reserve_time_range_type 按天=1 时间段=2 2,2,0
- // time_slot_type 自定义=1 自动划分=2
- // reserve_price_type 统一售价=0 按时间段设置=1 按天设置=2
- if(item.reserve_price_type == 1 && item.finalData && item.finalData.length){ // 按时间段设置价格
- item.finalData.forEach(it => {
- item.reserve_time_slot_price.push({
- reserve_time: it.date,
- price: it.selectTimes[0].price,
- original_price: it.selectTimes[0].linePrice,
- cost_price: 0,
- reserve_max_buy: it.selectTimes[0].reservationNum,
- time_spec: it.selectTimes
- });
- });
- }
- if(item.reserve_price_type == 0 && item.selectTimeList && item.selectTimeList.length){ // 统一设置价格
- // time_slot_type = 1 自定义时间段 = 2 自动划分
- if(item.time_slot_type == 1){ // 自定义时间段
- item.selectTimeList.forEach(it => {
- item.reserve_time_slot_price.push({
- reserve_time: it.date,
- price: item.price,
- original_price: item.original_price,
- cost_price: 0,
- reserve_max_buy: item.reserve_max_buy,
- time_spec: it.children
- });
- });
- }
- if(item.time_slot_type == 2){ // 自动划分
- item.selectTimeList.forEach(it => {
- item.reserve_time_slot_price.push({
- reserve_time: it.date,
- price: item.price,
- original_price: item.original_price,
- cost_price: 0,
- reserve_max_buy: item.reserve_max_buy,
- time_spec: it.checkedIntervalList
- });
- });
- }
- }
- if (item.reserve_price_type == 2) { // 按天设置价格
- console.log('item.reserve_price_type == 2item.reserve_price_type == 2item.reserve_price_type == 2', item)
- }
- });
- skus.forEach(item => {
- // 0 统一,1 时间段,2 按天
- if(item.reserve_price_type == 1){ // 时间段
- item.reserve_time_slot_price.forEach(it => {
- it.time_spec = it.time_spec.map(itc => {
- _.setFormPrice(itc.price, 'price', 3)
- _.setFormPrice(itc.linePrice, 'original_price', 3)
- return {
- spec_time: itc.time,
- start: itc.time ? itc.time.split('-')[0] : '',
- end: itc.time ? itc.time.split('-')[1] : '',
- price: itc.price,
- original_price: itc.linePrice,
- cost_price: 0,
- reserve_max_buy: itc.reservationNum,
- checked: 1,
- is_next: 0,
- }
- });
- });
- } else if(item.reserve_price_type == 2) { // 按天
- item.reserve_time_slot_price = {}
- item.finalData.forEach(it => {
- _.setFormPrice(it.price, 'price', 2)
- _.setFormPrice(it.linePrice, 'original_price', 2)
- item.reserve_time_slot_price[it.date] = {
- reserve_time: it.date,
- price: it.price,
- original_price: it.linePrice,
- cost_price: 0,
- reserve_max_buy: it.reservationNum,
- }
- });
- }else{ // 统一
- _.setFormPrice(item.price, 'price', 2)
- _.setFormPrice(item.original_price, 'original_price', 2)
- item.reserve_time_slot_price.forEach(it => {
- // _.setFormPrice(it.price, 'price', 2)
- // _.setFormPrice(it.linePrice, 'original_price', 2)
- it.time_spec = it.time_spec.map(itc => {
- return {
- spec_time: itc,
- start: itc.split('-')[0] || '',
- end: itc.split('-')[1] || '',
- price: it.price,
- original_price: it.linePrice || item.original_price,
- cost_price: 0,
- reserve_max_buy: it.reservationNum || item.reserve_max_buy,
- checked: 1,
- is_next: 0,
- }
- });
- });
- }
- });
- this.ruleForm.reserve.skus = JSON.parse(JSON.stringify(skus));
- }else{
- this.ruleForm.reserve.reserve_time_slot_price = [];
- let preList = [];
- if(this.ruleForm.reserve.reserve_price_type == 1){
- preList = this.$refs.priceSet && this.$refs.priceSet.selectedDates ? this.$refs.priceSet.selectedDates : [];
- } else if (this.ruleForm.reserve.reserve_price_type == 2) { // 按天 - 有可能需要修改
- preList = this.$refs.priceSet && this.$refs.priceSet.selectedDates ? this.$refs.priceSet.selectedDates : [];
- }else{
- preList = this.$refs.timeSelect && this.$refs.timeSelect.selectedDates ? this.$refs.timeSelect.selectedDates : [];
- if(this.ruleForm.reserve.time_slot_type == 1){
- preList.forEach(item => {
- item.selectTimes = item.children
- });
- }
- if(this.ruleForm.reserve.time_slot_type == 2){
- preList.forEach(item => {
- item.selectTimes = item.checkedIntervalList
- });
- }
- }
- if (this.ruleForm.reserve.reserve_price_type == 2) { // 按天
- this.ruleForm.reserve.reserve_time_slot_price = {}
- preList.forEach(item => {
- _.setFormPrice(item.price, 'price', 1)
- _.setFormPrice(item.linePrice, 'original_price', 1)
- this.ruleForm.reserve.reserve_time_slot_price[item.date] = {
- reserve_time: item.date,
- price: item.price,
- original_price: item.linePrice,
- cost_price: 0,
- reserve_max_buy: item.reservationNum,
- }
- });
- } else { // 统一/时间段
- preList.forEach(item => {
- this.ruleForm.reserve.reserve_time_slot_price.push({
- reserve_time: item.date,
- price: this.ruleForm.price,
- original_price: this.ruleForm.original_price,
- cost_price: 0,
- reserve_max_buy: this.ruleForm.reserve.reserve_max_buy,
- time_spec: item.selectTimes
- });
- });
- }
- if(this.ruleForm.reserve.reserve_price_type == 1){ // 按时间段
- this.ruleForm.reserve.reserve_time_slot_price.forEach(item => {
- item.time_spec = item.time_spec.map(it => {
- _.setFormPrice(it.price, 'price', 1)
- _.setFormPrice(it.linePrice, 'original_price', 1)
- return {
- spec_time: it.time,
- start: it.time ? it.time.split('-')[0] : '',
- end: it.time ? it.time.split('-')[1] : '',
- price: it.price,
- original_price: it.linePrice,
- cost_price: 0,
- reserve_max_buy: it.reservationNum,
- checked: 1,
- is_next: 0,
- }
- });
- });
- } else if(this.ruleForm.reserve.reserve_price_type == 2){ // 按天
- }else{ // 统一
- this.ruleForm.reserve.reserve_time_slot_price.forEach(item => {
- item.time_spec = item.time_spec.map(it => {
- return {
- spec_time: it,
- start: it.split('-')[0] || '',
- end: it.split('-')[1] || '',
- price: this.ruleForm.price,
- original_price: this.ruleForm.original_price,
- cost_price: 0,
- reserve_max_buy: this.ruleForm.reserve.reserve_max_buy,
- checked: 1,
- is_next: 0,
- }
- });
- });
- }
- }
- }
- // console.log('submit ========: ', this.ruleForm, this.settingForm); return null;
- if ('basic' == this.activeName || 'marketing' == this.activeName) {
- this.$refs['ruleForm'].validate((valid) => {
- if (valid) {
- let self = this;
- if (Number(self.ruleForm.extra.member_buy_limit_setting.every_num) > 0 && Number(self.ruleForm.extra.member_buy_limit_setting.every_num) < Number(self.ruleForm.extra.member_buy_limit_setting.nums)) {
- this.$message.error('每次限购数量不能小于起购数量');
- return
- }
- if (Number(self.ruleForm.extra.member_buy_limit_setting.every_day_num) > 0 && Number(self.ruleForm.extra.member_buy_limit_setting.every_day_num) < Number(self.ruleForm.extra.member_buy_limit_setting.nums)) {
- this.$message.error('每天限购数量不能小于起购数量');
- return
- }
- if (self.ruleForm.is_attr == 1) {
- if (this.attrGroups.length == 0) {
- this.$message.error('请完善规格组');
- return
- }
- self.ruleForm.extra.member_price_setting = this.getMemberPrice(this.ruleForm.attr);
- }
- //把纯数字转字符
- this.ruleForm.goods_name = this.ruleForm.goods_name + '';
- this.ruleForm.subtitle = this.ruleForm.subtitle + '';
- self.btnLoading = true;
- // package-list 套餐内容
- let packageList = {}
- if (this.$refs['package']) {
- packageList = {
- package_data: this.$refs['package'].list
- }
- }
- params = Object.assign(self.ruleForm, this.cForm, packageList)
- request({
- params: {
- r: 'store/store-goods/edit'
- },
- method: 'post',
- data: {
- form: JSON.stringify(params),
- }
- }).then(e => {
- self.btnLoading = false;
- if (e.data.code == 0) {
- self.$message.success(e.data.msg);
- this.$navigate({
- r: 'store/store-goods/index'
- })
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- self.$message.error(e.data.msg);
- self.btnLoading = false;
- });
- }
- });
- } else if ('mode' == this.activeName) {
- this.commissionSettingSubmit();
- }
- },
- //添加优惠券
- add_coupon(e) {
- this.ruleForm.coupon_selection = e;
- },
- //跳转新增优惠券界面
- // handle_coupon() {
- // this.$navigate({
- // r: 'coupon/default/edit'
- // })
- // },
- checkoutChange(it) {
- console.log(it)
- },
- setFormPrice(price, key) {
- if (this.ruleForm.is_attr == 1 && this.ruleForm.goods_type == 3) {
- // 重新设置价格
- if (price > 0) {
- // this.$set(this.ruleForm, key, this.ruleForm[key] > 0 ? Math.min(this.ruleForm[key], price) : price)
- // if (this.ruleForm[key] <= 0) this.$message.error("价格不能为0")
- }
- }
- },
- getFreight() { // 获取运费规则选项
- let self = this;
- request({
- params: {
- r: 'mall/postage-rules/all-list'
- },
- method: 'get',
- data: {}
- }).then(e => {
- if (e.data.code == 0) {
- self.freight.list = e.data.data.list;
- // 添加商品时使用默认运费
- self.freight.list.unshift({
- id: 0,
- name: '默认运费',
- status: 1
- })
- console.log(self.freight.list)
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- freightChange(e) {
- console.log(e)
- },
- // 获取规格用户价
- getMemberPrice(attr) {
- let that = this;
- let member_price_setting = {};
- let levels = objectKeys(attr[0].member_price_setting);
- levels.forEach(level => {
- that.$set(member_price_setting, level, {});
- });
- attr.forEach((v) => {
- let sign_id = v.sign_id;
- for (const key in v.member_price_setting) {
- member_price_setting[key][sign_id] = v.member_price_setting[key];
- }
- })
- member_price_setting = member_price_setting;
- return member_price_setting;
- },
- // 商品审核不通过
- goodAuditFailed(type) {
- this.$prompt('不通过原因', '审核', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- }).then(({
- value
- }) => {
- if (!value) {
- this.$message.error('驳回原因不能为空');
- return false;
- }
- let self = this;
- // self.btnLoading = true;
- request({
- params: {
- r: 'store/store-goods/audit',
- },
- method: 'post',
- data: {
- goods_id: self.goodsId,
- type: type,
- check_remark: value,
- },
- }).then(e => {
- if (e.data.code == 0) {
- self.$message.success('操作成功');
- setTimeout(function() {
- navigateTo({
- r: 'store/store-goods/index'
- });
- }, 300);
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- self.btnLoading = false;
- self.$message.error('网络错误');
- console.log(e);
- });
- }).catch(() => {
- this.btnLoading = false;
- console.log('取消驳回审核');
- });
- },
- // 商品审核
- goodAudit(adopt) {
- let self = this;
- request({
- params: {
- r: 'store/store-goods/audit',
- },
- method: 'post',
- data: {
- goods_id: self.goodsId,
- type: adopt,
- check_remark: '',
- },
- }).then(e => {
- if (e.data.code == 0) {
- self.$message.success('操作成功');
- setTimeout(function() {
- navigateTo({
- r: 'store/store-goods/index'
- });
- }, 300);
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- self.btnLoading = false;
- self.$message.error('网络错误');
- console.log(e);
- });
- },
- getModelDetail() {
- let self = this;
- self.cardLoading = true;
- request({
- params: {
- r: 'store/store-goods/goods-model',
- id: getQuery('id')
- },
- method: 'get',
- }).then(e => {
- // console.log(e, '===============');
- self.cardLoading = false;
- if (e.data.code == 0) {
- if (e.data.data.detail) {
- self.storeId = e.data.data.detail.store_id;
- }
- self.level = e.data.data.level;
- if (!isEmpty(e.data.data.setting)) {
- self.setting = e.data.data.setting;
- for (let key in self.setting) {
- // 将空的
- if (isEmpty(self.setting[key])) self.setting[key] = {};
- }
- }
- self.commission_type_map = e.data.data.commission_type_map;
- self.coupon_type_map = e.data.data.coupon_type_map;
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- commissionSettingSubmit() {
- let self = this;
- self.btnLoading = true;
- self.settingForm.goods_id = getQuery('id');
- self.settingForm.store_id = self.storeId;
- params = Object.assign(self.settingForm, this.cForm);
- request({
- params: {
- r: 'store/store-goods/goods-model'
- },
- method: 'post',
- data: {
- form: params
- }
- }).then(e => {
- self.btnLoading = false;
- if (e.data.code == 0) {
- self.$message.success(e.data.msg);
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- self.$message.error(e.data.msg);
- self.btnLoading = false;
- });
- },
- getData(val, key) {
- this.settingForm[key] = val;
- },
- /**
- * 显示规格套餐
- */
- packageShow () {
- return this.ruleForm.show_style == 2
- },
- /**
- * 限制添加规格
- */
- attrLimit () {
- return this.ruleForm.show_style == 2 ? 2 : 1
- },
- appendRepurchaseItem(){
- item = {start: 0, end: 0, price: 0}
- this.ruleForm.extra.repurchase_setting.push(item)
- },
- delRepurchaseItem(index){
- this.ruleForm.extra.repurchase_setting.splice(index, 1);
- },
- setRepurchase(index, field, val){
- item = this.ruleForm.extra.repurchase_setting[index]
- item[field] = Number(val)
- this.$set(this.ruleForm.extra.repurchase_setting, index, item)
- },
- addons_data_change(e) {
- Object.assign(this.ruleForm.addons, e);
- console.log(this.ruleForm.addons, '=======addons====');
- // this.ruleForm.addons.coupon_selection = e;
- },
- upDownBatch(command) {
- // 要复制的链接
- const linkToCopy = this.store_login_url; // 直接从 #app 获取
- this.$confirm(`<div class="title">O2O门店分类只能到门店后台进行操作添加,且门店后台与主商城不能使用同一浏览器</div><br>请复制下方链接使用别的浏览器进行登录<br><br><div>门店管理端登录入口链接:<br>${linkToCopy}</div>`, {
- title: '警告',
- customClass: 'custom-confirm-width',
- dangerouslyUseHTMLString: true,
- confirmButtonText: '复制去登录',
- cancelButtonText: '取消',
- type: 'warning',
- }).then(() => {
- // 用户点击"复制去登录"时执行复制
- this.copyToClipboard(linkToCopy);
- }).catch(() => {
- // 用户点击"取消"什么都不做
- });
- },
- copyToClipboard(text) {
- if (navigator.clipboard) {
- // 现代浏览器(Chrome/Firefox/Edge)
- navigator.clipboard.writeText(text)
- .then(() => {
- this.$message.success('链接已复制!');
- })
- .catch((err) => {
- console.error('复制失败:', err);
- this.$message.error('复制失败,请手动复制');
- });
- } else {
- // 兼容旧浏览器(如IE)
- const textarea = document.createElement('textarea');
- textarea.value = text;
- document.body.appendChild(textarea);
- textarea.select();
- try {
- document.execCommand('copy');
- this.$message.success('链接已复制!');
- } catch (err) {
- console.error('复制失败:', err);
- this.$message.error('复制失败,请手动复制');
- }
- document.body.removeChild(textarea);
- }
- }
- }
- });
- </script>
|