| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756 |
- <?php
- Yii::$app->loadComponentView('com-rich-text');
- Yii::$app->loadComponentView('goods/com-dialog-select');
- Yii::$app->loadComponentView('goods/com-attr');
- Yii::$app->loadComponentView('goods/com-attr-select');
- Yii::$app->loadComponentView('goods/com-add-cat');
- Yii::$app->loadComponentView('goods/com-select-goods');
- Yii::$app->loadComponentView('goods/com-area-limit');
- Yii::$app->loadComponentView('goods/com-preview');
- Yii::$app->loadComponentView('goods/com-attr-group');
- Yii::$app->loadComponentView('goods/com-goods-area');
- Yii::$app->loadComponentView('goods/com-goods-currency-area');
- Yii::$app->loadComponentView('goods/com-goods-agent');
- Yii::$app->loadComponentView('goods/com-goods-currency-agent');
- Yii::$app->loadComponentView('mall/choose-user','@app/plugins/o2o_store/views/components');
- ?>
- <style>
- .mt-24 {
- margin-bottom: 24px;
- }
- .com-goods .el-form-item__label {
- padding: 0 20px 0 0;
- }
- .com-goods .el-dialog__body h3 {
- font-weight: normal;
- color: #999999;
- }
- .com-goods .form-body {
- padding: 10px 20px 20px;
- background-color: #fff;
- margin-bottom: 30px;
- }
- .com-goods .button-item {
- padding: 9px 25px;
- margin-bottom: 10px;
- }
- .com-goods .sortable-chosen {
- /* border: 2px solid #3399ff; */
- }
- .del-btn {
- position: absolute;
- right: -8px;
- top: -8px;
- padding: 4px 4px;
- }
- .com-goods .app-share {
- padding-top: 12px;
- border-top: 1px solid #e2e2e2;
- margin-top: -20px;
- }
- .com-goods .app-share .app-share-bg {
- position: relative;
- width: 310px;
- height: 360px;
- background-repeat: no-repeat;
- background-size: contain;
- background-position: center
- }
- .com-goods .app-share .app-share-bg .title {
- width: 160px;
- height: 29px;
- line-height: 1;
- word-break: break-all;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- }
- .com-goods .app-share .app-share-bg .pic-image {
- background-repeat: no-repeat;
- background-position: 0 0;
- background-size: cover;
- width: 160px;
- height: 130px;
- }
- .bottom-div {
- border-top: 1px solid #E3E3E3;
- position: fixed;
- bottom: 0;
- background-color: #ffffff;
- z-index: 999;
- padding: 10px;
- width: 80%;
- }
- .com-goods .add-image-btn {
- width: 100px;
- height: 100px;
- color: #419EFB;
- border: 1px solid #e2e2e2;
- cursor: pointer;
- }
- .com-goods .pic-url-remark {
- font-size: 13px;
- color: #c9c9c9;
- margin-bottom: 12px;
- }
- .com-goods .customize-share-title {
- margin-top: 10px;
- width: 80px;
- height: 80px;
- position: relative;
- cursor: move;
- }
- .com-goods .share-title {
- font-size: 16px;
- color: #303133;
- padding-bottom: 22px;
- border-bottom: 1px solid #e2e2e2;
- }
- .box-grow-0 {
- /* flex 子元素固定宽度*/
- min-width: 0;
- -webkit-box-flex: 0;
- -webkit-flex-grow: 0;
- -ms-flex-positive: 0;
- flex-grow: 0;
- -webkit-flex-shrink: 0;
- -ms-flex-negative: 0;
- flex-shrink: 0;
- }
- </style>
- <template id="store">
- <el-card shadow="never" style="border:0" body-style="background-color: #f3f3f3;padding: 10px 0 0;" class="com-goods" v-loading="cardLoading">
- <div class='form-body'>
- <el-form :model="cForm" :rules="cRule" ref="ruleForm" label-width="180px" size="small" class="demo-ruleForm">
- <el-tabs v-model="activeName" @tab-click="handleClick">
- <el-tab-pane label="基本设置" name="first">
- <el-card shadow="never" class="mt-24">
- <div slot="header">
- <span>开店会员</span>
- </div>
- <el-row>
- <el-col :xl="12" :lg="16">
- <el-form-item prop="user_id_list">
- <label slot="label">
- <span>会员ID</span>
- </label>
- <el-input style="width: 80%" placeholder="请输入分享标题" v-model="ruleForm.app_share_title"></el-input>
- <el-button type="primary" size="small" style="width:19%;padding: 9px 15px !important;" @click="chooseUser">选择会员
- </el-button>
- </el-form-item>
- <el-form-item prop="app_share_title">
- <label slot="label">
- <span>会员昵称</span>
- </label>
- <el-input placeholder="请输入分享标题" v-model="ruleForm.app_share_title"></el-input>
- </el-form-item>
- <el-form-item prop="app_share_title">
- <label slot="label">
- <span>绑定手机号</span>
- </label>
- <el-input placeholder="请输入分享标题" v-model="ruleForm.app_share_title"></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- </el-card>
- <!-- 基本信息 -->
- <slot name="before_info"></slot>
- <el-card shadow="never" class="mt-24">
- <div slot="header">
- <span>基本信息</span>
- </div>
- <el-row>
- <el-col :xl="12" :lg="16">
- <el-form-item prop="app_share_title">
- <label slot="label">
- <span>会员昵称</span>
- </label>
- <el-input placeholder="请输入分享标题" v-model="ruleForm.app_share_title"></el-input>
- </el-form-item>
- <el-form-item prop="app_share_pic">
- <label slot="label">
- <span>自定义分享图片</span>
- <el-tooltip class="item" effect="dark" content="分享给好友时,作为分享图片" placement="top">
- <i class="el-icon-info"></i>
- </el-tooltip>
- </label>
- <com-attachment v-model="ruleForm.app_share_pic" :multiple="false" :max="1">
- <el-tooltip class="item" effect="dark" content="建议尺寸:420 * 336" placement="top">
- <el-button size="mini">选择图片</el-button>
- </el-tooltip>
- </com-attachment>
- <div class="customize-share-title">
- <com-image mode="aspectFill" width='80px' height='80px' :src="ruleForm.app_share_pic ? ruleForm.app_share_pic : ''"></com-image>
- <el-button v-if="ruleForm.app_share_pic" class="del-btn" size="mini" type="danger" icon="el-icon-close" circle @click="ruleForm.app_share_pic = ''"></el-button>
- </div>
- <el-button @click="app_share.dialog = true;app_share.type = 'pic_bg'" type="text">查看图例
- </el-button>
- </el-form-item>
- <!-- 自定义 -->
- <el-dialog :title="app_share['type'] == 'pic_bg' ? `查看自定义分享图片图例`:`查看自定义分享标题图例`" :visible.sync="app_share.dialog" width="30%">
- <div flex="dir:left main:center" class="app-share">
- <div class="app-share-bg" :style="{backgroundImage: 'url('+app_share[app_share.type]+')'}"></div>
- </div>
- <div slot="footer" class="dialog-footer">
- <el-button @click="app_share.dialog = false" type="primary">我知道了</el-button>
- </div>
- </el-dialog>
- </el-col>
- </el-row>
- </el-card>
- <!-- 商品服务 -->
- <slot name="before_goods"></slot>
- <el-card shadow="never" class="mt-24">
- <div slot="header">
- <span>商品服务</span>
- </div>
- <el-row>
- <el-col :xl="12" :lg="16">
- <el-form-item label="商品服务">
- <template v-if="!defaultServiceChecked">
- <el-tag v-for="(service, index) in ruleForm.services" @close="serviceDelete(index)" :key="service.id" :disable-transitions="true" style="margin-right: 10px;" closable>
- {{service.name}}
- </el-tag>
- <el-button type="button" size="mini" @click="serviceOpen">新增服务
- </el-button>
- <el-dialog title="选择商品服务" :visible.sync="service.dialog" width="30%">
- <el-card shadow="never" flex="dir:left" style="flex-wrap: wrap" v-loading="service.loading">
- <el-checkbox-group v-model="service.list">
- <el-checkbox v-for="item in service.services" :label="item" :key="item.id">{{item.name}}
- </el-checkbox>
- </el-checkbox-group>
- </el-card>
- <div slot="footer" class="dialog-footer">
- <el-button @click="serviceCancel">取 消</el-button>
- <el-button type="primary" @click="serviceConfirm">确 定</el-button>
- </div>
- </el-dialog>
- </template>
- <el-checkbox v-model="defaultServiceChecked" @change="defaultService()">默认服务
- </el-checkbox>
- </el-form-item>
- <el-form-item prop="freight_id">
- <template slot='label'>
- <span>运费设置</span>
- <el-tooltip effect="dark" content="选择第一项(默认运费)将会根据运费管理的(默认运费)变化而变化" placement="top">
- <i class="el-icon-info"></i>
- </el-tooltip>
- </template>
- <el-tag @close="freightDelete()" v-if="ruleForm.freight" :key="ruleForm.freight.name" :disable-transitions="true" style="margin-right: 10px;" closable>
- {{ruleForm.freight.name}}
- </el-tag>
- <el-button type="button" size="mini" @click="freightOpen">选择运费
- </el-button>
- <el-dialog title="选择运费" :visible.sync="freight.dialog" width="30%">
- <el-card shadow="never" flex="dir:left" style="flex-wrap: wrap" v-loading="freight.loading">
- <el-radio-group v-model="freight.checked">
- <el-radio style="padding: 10px;" v-for="item in freight.list" :label="item" :key="item.id">{{item.name}}
- </el-radio>
- </el-radio-group>
- </el-card>
- <div slot="footer" class="dialog-footer">
- <el-button @click="freightCancel">取 消</el-button>
- <el-button type="primary" @click="freightConfirm">确 定</el-button>
- </div>
- </el-dialog>
- </el-form-item>
- <el-form-item label="限购数量" prop="confine_count">
- <div flex="dir:left">
- <span class="box-grow-0" style="color:#606266">商品</span>
- <div style="width: 100%;margin:0 10px">
- <el-input oninput="this.value = this.value.replace(/[^0-9]/g, '');" :disabled="ruleForm.confine_count <= -1" placeholder="请输入限购数量" v-model="ruleForm.confine_count">
- <template slot="append">件</template>
- </el-input>
- </div>
- <el-checkbox style="margin-left: 5px;" @change="itemChecked" v-model="ruleForm.confine_count <= -1">无限制
- </el-checkbox>
- </div>
- <div flex="dir:left" style="margin-top: 10px;">
- <span class="box-grow-0" style="color:#606266">订单</span>
- <div style="width: 100%;margin:0 10px">
- <el-input oninput="this.value = this.value.replace(/[^0-9]/g, '');" :disabled="ruleForm.confine_order_count <= -1" placeholder="请输入限购数量" v-model="ruleForm.confine_order_count">
- <template slot="append">单</template>
- </el-input>
- </div>
- <el-checkbox style="margin-left: 5px;" @change="itemOrderChecked" v-model="ruleForm.confine_order_count <= -1">无限制
- </el-checkbox>
- </div>
- </el-form-item>
- <el-form-item label="" prop="pieces">
- <template slot='label'>
- <span>单品满件包邮</span>
- <el-tooltip effect="dark" content="如果设置0或空,则不支持满件包邮" placement="top">
- <i class="el-icon-info"></i>
- </el-tooltip>
- </template>
- <el-input type="number" min="0" oninput="" placeholder="请输入数量" v-model="ruleForm.pieces">
- <template slot="append">件</template>
- </el-input>
- </el-form-item>
- <el-form-item prop="forehead">
- <template slot='label'>
- <span>单品满额包邮</span>
- <el-tooltip effect="dark" content="如果设置0或空,则不支持满额包邮" placement="top">
- <i class="el-icon-info"></i>
- </el-tooltip>
- </template>
- <el-input type="number" oninput="this.value = this.value.replace(/[^0-9\.]/, '');" min="0" placeholder="请输入金额" v-model="ruleForm.forehead">
- <template slot="append">元</template>
- </el-input>
- </el-form-item>
- <el-form-item label="配送范围" prop="is_area_limit">
- <el-switch
- v-model="ruleForm.is_area_limit"
- :active-value="1"
- :inactive-value="0">
- </el-switch>
- </el-form-item>
- <el-form-item v-if="ruleForm.is_area_limit" label="允许购买区域" prop="area_limit">
- <com-area-limit v-model="ruleForm.area_limit"></com-area-limit>
- </el-form-item>
- </el-col>
- </el-row>
- </el-card>
- <!-- 商品详情 -->
- <slot name="before_detail"></slot>
- <el-card shadow="never" class="mt-24">
- <div slot="header">
- <span>商品详情</span>
- </div>
- <el-row>
- <el-col :xl="12" :lg="16">
- <el-form-item label="商品详情">
- <com-rich-text style="width: 750px" v-model="ruleForm.detail"></com-rich-text>
- </el-form-item>
- </el-col>
- </el-row>
- </el-card>
- <slot name="after_detail"></slot>
- </el-tab-pane>
- <el-tab-pane label="营业设置" name="eighth">
- <!-- 单品满额减免 begin -->
- <el-card shadow="never" class="mt-24">
- <div slot="header">
- <span>单品满额减免</span>
- </div>
- <el-row>
- <el-col :xl="12" :lg="16">
- <el-form-item prop="fulfil_price">
- <template slot='label'>
- <span>单品满额金额</span>
- <el-tooltip effect="dark" content="单品达到该金额可减免一定金额,如果设置0或空,则不支持单品满额减免" placement="top">
- <i class="el-icon-info"></i>
- </el-tooltip>
- </template>
- <el-input type="number" oninput="this.value = this.value.replace(/[^0-9\.]/, '');" min="0" placeholder="请输入金额" v-model="ruleForm.fulfil_price" @input="change($event)">
- <template slot="append">元</template>
- </el-input>
- </el-form-item>
- <el-form-item prop="full_relief_price">
- <template slot='label'>
- <span>单品满额减免金额</span>
- <el-tooltip effect="dark" content="单品达到该金额可减免一定金额,如果设置0或空,则不支持单品满额减免" placement="top">
- <i class="el-icon-info"></i>
- </el-tooltip>
- </template>
- <el-input type="number" @input="change($event)" oninput="this.value = this.value.replace(/[^0-9\.]/, '');" min="0" placeholder="请输入金额" v-model="ruleForm.full_relief_price">
- <template slot="append">元</template>
- </el-input>
- </el-form-item>
- </el-col>
- </el-row>
- </el-card>
- <!-- 单品满额减免 end -->
- <!-- 显示设置 todo -->
- <el-card shadow="never" class="mt-24" v-if="false && is_show == 1">
- <div slot="header">
- <span>显示设置</span>
- </div>
- </el-card>
- <!-- 营销设置 -->
- <slot name="before_marketing"></slot>
- <el-card shadow="never" class="mt-24">
- <div slot="header">
- <span>营销设置</span>
- </div>
- <span>积分</span>
- <el-row>
- <el-col :xl="12" :lg="16">
- <el-form-item>
- <template slot='label'>
- <span>积分赠送</span>
- <el-tooltip effect="dark" placement="top">
- <div slot="content">用户购物赠送的积分, 如果不填写或填写0,则默认为不赠送积分,
- 如果为百分比则为按成交价格的比例计算积分"<br />
- 如: 购买2件,设置10 积分, 不管成交价格是多少, 则购买后获得20积分</br>
- 如: 购买2件,设置10%积分, 成交价格2 * 200= 400, 则购买后获得 40 积分(400*10%)
- </div>
- <i class="el-icon-info"></i>
- </el-tooltip>
- </template>
- <el-input type="number" min="0" oninput="this.value = this.value.replace(/[^0-9]/g, '');" placeholder="请输入赠送积分数量" v-model="ruleForm.give_score">
- <template slot="append">
- 分
- <el-radio v-model="ruleForm.give_score_type" :label="1">固定值
- </el-radio>
- <el-radio v-model="ruleForm.give_score_type" :label="2">百分比
- </el-radio>
- </template>
- </el-input>
- </el-form-item>
- <el-form-item>
- <template slot='label'>
- <span>积分抵扣</span>
- <el-tooltip effect="dark" content="如果设置0,则不支持积分抵扣" placement="top">
- <i class="el-icon-info"></i>
- </el-tooltip>
- </template>
- <el-input :disabled="ruleForm.full_forehead_score==1" type="number" min="0" oninput="this.value = this.value.replace(/[^0-9\.]/g, '');" placeholder="请输最高抵扣金额" v-model="ruleForm.forehead_score">
- <template slot="prepend">最多抵扣</template>
- <template slot="append">
- 元
- <el-radio v-model="ruleForm.forehead_score_type" :label="1" :disabled="ruleForm.full_forehead_score==1">固定值
- </el-radio>
- <el-radio style="display: none" v-model="ruleForm.forehead_score_type" :label="2">百分比
- </el-radio>
- </template>
- </el-input>
- <el-checkbox :true-label="1" :false-label="0" :disabled="ruleForm.full_forehead_score==1" v-model="ruleForm.accumulative">
- 允许多件累计抵扣
- </el-checkbox>
- <el-checkbox :true-label="1" :false-label="0" @change="fullForeheadScore" v-model="ruleForm.full_forehead_score">
- 允许全额抵扣
- </el-checkbox>
- </el-form-item>
- </el-col>
- </el-row>
- <template v-for="item in ruleForm.currency_deduct_setting">
- <!-- <span>{{currencyName(item.currency_code)}}</span> -->
- <!-- <span>{{item.currency_code | currencyName}}</span> -->
- <template v-for="its in currencyList">
- <span v-if="its.code==item.currency_code">{{its.name}}</span>
- </template>
- <el-row>
- <template>
- <el-col :xl="12" :lg="16">
- <el-form-item>
- <template slot='label'>
- <template v-for="its in currencyList">
- <span v-if="its.code==item.currency_code">{{its.name}}赠送</span>
- </template>
- <!-- <el-tooltip effect="dark" placement="top">
- <div slot="content">用户购物赠送的积分, 如果不填写或填写0,则默认为不赠送积分,
- 如果为百分比则为按成交价格的比例计算积分"<br />
- 如: 购买2件,设置10 积分, 不管成交价格是多少, 则购买后获得20积分</br>
- 如: 购买2件,设置10%积分, 成交价格2 * 200= 400, 则购买后获得 40 积分(400*10%)
- </div>
- <i class="el-icon-info"></i>
- </el-tooltip> -->
- </template>
- <el-input type="number" min="0" oninput="this.value = this.value.replace(/[^0-9]/g, '');" placeholder="请输入赠送积分数量" v-model="item.give_num">
- <template slot="append">
- <template v-for="its in currencyList">
- <template v-if="its.code==item.currency_code">{{its.unit}}</template>
- </template>
- <el-radio v-model="item.is_percent_give" :label="'0'">固定值
- </el-radio>
- <el-radio v-model="item.is_percent_give" :label="'1'">百分比
- </el-radio>
- </template>
- </el-input>
- </el-form-item>
- <el-form-item>
- <template slot='label'>
- <template v-for="its in currencyList">
- <span v-if="its.code==item.currency_code">{{its.name}}抵扣</span>
- </template>
- <!-- <el-tooltip effect="dark" content="如果设置0,则不支持积分抵扣" placement="top">
- <i class="el-icon-info"></i>
- </el-tooltip> -->
- </template>
- <el-input type="number" min="0" oninput="this.value = this.value.replace(/[^0-9\.]/g, '');" placeholder="请输最高抵扣金额" v-model="item.max_deduction_num">
- <template slot="prepend">最多抵扣</template>
- <template slot="append">
- 元
- <el-radio v-model="ruleForm.forehead_score_type" :label="1" :disabled="ruleForm.full_forehead_score==1">固定值
- </el-radio>
- <el-radio style="display: none" v-model="ruleForm.forehead_score_type" :label="2">百分比
- </el-radio>
- </template>
- </el-input>
- <el-radio v-model="item.deduction_type" :label="'1'">
- 允许单件抵扣
- </el-radio>
- <el-radio v-model="item.deduction_type" :label="'2'">
- 允许多件累计抵扣
- </el-radio>
- </el-form-item>
- </el-col>
- </template>
- </el-row>
- </template>
- </el-card>
- </el-tab-pane>
- <el-tab-pane label="有效期设置" name="ninth">
- <slot name="before_goods"></slot>
- <el-card shadow="never" class="mt-24">
- <el-row>
- <el-col :xl="12" :lg="16">
- <el-form-item label="配送范围" prop="is_area_limit">
- <el-switch v-model="ruleForm.is_area_limit" :active-value="1" :inactive-value="0">
- </el-switch>
- </el-form-item>
- <el-form-item v-if="ruleForm.is_area_limit" label="允许购买区域" prop="area_limit">
- <com-area-limit v-model="ruleForm.area_limit"></com-area-limit>
- </el-form-item>
- </el-col>
- </el-row>
- </el-card>
- </el-tab-pane>
- <el-tab-pane label="账号密码设置" name="second">
- <el-form-item label="是否享受会员功能" prop="is_level">
- <el-switch :active-value="1" :inactive-value="0" v-model="ruleForm.is_level">
- </el-switch>
- </el-form-item>
- <template v-if="ruleForm.is_level == 1">
- <el-form-item label="是否单独设置会员价" prop="is_level_alone">
- <el-switch :active-value="1" :inactive-value="0" v-model="ruleForm.is_level_alone">
- </el-switch>
- </el-form-item>
- <template v-if="ruleForm.is_level_alone == 1">
- <template v-if="ruleForm.use_attr == 1 && memberLevel.length > 0">
- <!--多规格会员价设置-->
- <el-form-item label="会员价设置">
- <com-attr v-model="ruleForm.attr" :attr-groups="attrGroups" :members="memberLevel" :is-level="true"></com-attr>
- </el-form-item>
- </template>
- <!-- 无规格默认会员价 -->
- <template v-if="ruleForm.use_attr == 0 && memberLevel.length > 0">
- <el-form-item label="默认规格会员价设置">
- <el-col :xl="12" :lg="16">
- <el-input v-for="item in defaultMemberPrice" :key="item.id" type="number" v-model="ruleForm.member_price[item.level]">
- <span slot="prepend">{{item.name}}</span>
- <span slot="append">元</span>
- </el-input>
- </el-col>
- </el-form-item>
- <el-form-item>
- <el-tag type="danger">如需设置多规格会员价,请先添加商品规格</el-tag>
- </el-form-item>
- </template>
- <el-form-item v-if="memberLevel.length == 0" label="会员价设置">
- <el-button type="danger" @click="$navigate({r: 'mall/member-level/edit'})">
- 如需设置,请先添加会员
- </el-button>
- </el-form-item>
- </template>
- </template>
- <el-form-item v-if="is_svip" label="是否享受超级会员功能" prop="is_vip_card_goods">
- <el-switch v-model="is_vip_card_goods" :active-value="1" :inactive-value="0"></el-switch>
- </el-form-item>
- </el-tab-pane>
- <el-tab-pane label="配送设置" name="third" v-if="is_show_distribution">
- <template v-if="goods_id!='0'">
- <el-tabs v-model="distributionName" v-if="activeName == 'third'" @tab-click="distributionClick" style="margin-left: 20px;">
- <el-tab-pane label="佣金" name="default">
- <com-goods-distribution v-if="distributionName=='default'" v-model="ruleForm"
- :is_mch="is_mch"
- :goods_type="goods_type"
- :goods_id="goods_id"
- @public-lever-data = "getPublicLeverData">
- </com-goods-distribution>
- </el-tab-pane>
- <template v-if="currencyList.length>0">
- <!-- 是否支持商业模式 -->
- <el-tab-pane v-if="item.enable_bussiness_mode" v-for="item in currencyList" :key="item.code" :label="item.name" :name="item.code">
- <com-goods-currency-distribution
- v-if="distributionName==item.code"
- :goods_type="goods_type"
- :goods_id="goods_id"
- :currency_code="item.code"
- :item_type="item"
- :public_lever_data="publicLeverData">
- </com-goods-currency-distribution>
- </el-tab-pane>
- </template>
- </el-tabs>
- </template>
- </el-tab-pane>
- <el-tab-pane label="结算设置" name="fourth" v-if="is_show_agent">
- <template v-if="goods_id!='0'">
- <el-tabs v-model="distributionName" v-if="activeName == 'fourth'" @tab-click="distributionClick" style="margin-left: 20px;">
- <el-tab-pane label="佣金" name="default">
- <com-goods-agent v-if="distributionName=='default'" v-model="ruleForm"
- :is_mch="is_mch"
- :goods_type="goods_type"
- :goods_id="goods_id"
- >
- </com-goods-agent>
- </el-tab-pane>
- <template v-if="currencyList.length>0">
- <el-tab-pane v-if="item.enable_bussiness_mode" v-for="item in currencyList" :key="item.code" :label="item.name" :name="item.code">
- <com-goods-currency-agent
- v-if="distributionName==item.code"
- :goods_type="goods_type"
- :goods_id="goods_id"
- :currency_code="item.code"
- :item_type="item"
- >
- </com-goods-currency-agent>
- </el-tab-pane>
- </template>
- </el-tabs>
- </template>
- </el-tab-pane>
- </el-tabs>
- </el-form>
- <choose-user v-model="edit.chooseUser"></choose-user>
- <div class="bottom-div" flex="cross:center">
- <el-button class="button-item" :loading="btnLoading" type="primary" size="small" @click="store('ruleForm')">保存
- </el-button>
- <el-button class="button-item" size="small" @click="showPreview">预览</el-button>
- </div>
- </div>
- </el-card>
- </template>
- <script src="<?= Yii::$app->request->baseUrl ?>/statics/unpkg/vuedraggable@2.18.1/dist/vuedraggable.umd.min.js"></script>
- <script>
- Vue.component('store', {
- template: '#store',
- data() {
- let ruleForm = {
- labels: [],
- attr: [],
- cats: [],
- mchCats: [], //多商户系统分类
- cards: [],
- services: [],
- pic_url: [],
- use_attr: 0,
- goods_num: 0,
- status: 0,
- unit: '件',
- virtual_sales: 0,
- cover_pic: '',
- sort: 100,
- accumulative: 0,
- confine_count: -1,
- confine_order_count: -1,
- forehead: 0,
- forehead_score: 0,
- forehead_score_type: 1,
- currency_deduct_setting : [], //可代扣货币设置信息
- freight_id: 0,
- freight: null,
- give_score: 0,
- give_score_type: 1,
- individual_share: 0,
- is_level: 1,
- is_level_alone: 0,
- pieces: 0,
- share_type: 0,
- attr_setting_type: 0,
- video_url: '',
- is_sell_well: 0,
- is_negotiable: 0,
- name: '',
- price: 0,
- original_price: 0,
- cost_price: 0,
- detail: '',
- extra: '',
- app_share_title: '', //自定义分享标题,
- app_share_pic: '', //自定义分享图片
- is_default_services: 1,
- member_price: {},
- goods_no: '',
- goods_weight: '',
- select_attr_groups: [], // 已选择的规格
- goodsWarehouse_attrGroups: [], // 商品库商品所有的规格
- share_level_type: 0,
- distributionLevelList: [],
- form: null,
- is_show_sales: 0,
- use_virtual_sales: 0,
- form_id: 0,
- attr_default_name: '',
- is_area_limit: 0,
- use_score: 0,
- area_limit: [{
- list: []
- }],
- full_relief_price: 0,
- fulfil_price: 0,
- // 短视频设置
- is_alone: 0, //是否独立
- video_share_type: "1", //默认选中百分比
- percentage: 0, //默认0%
- fixed_value: 0, //默认固定金额0
- };
- let 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('请选择系统分类');
- }
- }],
- name: [{
- required: true,
- message: '请输入商品名称',
- trigger: 'change'
- }, ],
- price: [{
- required: true,
- message: '请输入商品价格',
- trigger: 'change'
- }],
- original_price: [{
- required: true,
- message: '请输入商品原价',
- trigger: 'change'
- }],
- cost_price: [{
- required: false,
- message: '请输入商品成本价',
- trigger: 'change'
- }],
- unit: [{
- required: true,
- message: '请输入商品单位',
- trigger: 'change'
- },
- {
- max: 5,
- message: '最大为5个字符',
- trigger: 'change'
- },
- ],
- goods_num: [{
- required: true,
- message: '请输入商品总库存',
- trigger: 'change'
- }, ],
- is_area_limit: [{
- required: false,
- type: 'integer',
- message: '请选择是否开启',
- trigger: 'blur'
- }],
- area_limit: [{
- required: true,
- type: 'array',
- validator: (rule, value, callback) => {
- if (value instanceof Array && value[0]['list'].length === 0) {
- callback('允许购买区域不能为空');
- }
- callback();
- }
- }],
- pic_url: [{
- required: true,
- message: '请上传商品轮播图',
- trigger: 'change'
- }, ],
- };
- return {
- goods_id: '0',
- keyword: '',
- goods_type: 'MALL_GOODS',
- label_list: [],
- cardLoading: false,
- btnLoading: false,
- dialogLoading: false,
- activeName: 'first',
- distributionName : 'default', //二级tab默认显示佣金
- marketeName : 'default', //营销二级tab默认
- ruleForm: ruleForm,
- // 分销层级
- shareLevel: [],
- // 会员等级
- memberLevel: [],
- rules: rules,
- options: [], // 商品分类列表
- mchOptions: [], //多商户商品编辑时使用
- newOptions: [],
- cats: [], //用于前端已选的分类展示
- mchCats: [], //用于前端已选的分类展示 多商户
- cards: [], // 优惠券
- attrGroups: [], //规格组
- attrGroupName: '',
- attrName: [],
- // 批量设置
- batch: {},
- dialogVisible: false, //分类选择弹框
- mchDialogVisible: false,
- is_vip_card_goods: 0,
- is_svip: false,
- goods_warehouse: {},
- copyUrl: '',
- copyLoading: false,
- defaultServiceChecked: false,
- service: {
- dialog: false,
- list: [],
- services: [], // 商品服务列表
- loading: false
- },
- freight: {
- dialog: false,
- list: [],
- checked: {},
- loading: false
- },
- copyId: '',
- app_share: {
- dialog: false,
- type: '',
- bg: "<?= \Yii::$app->request->baseUrl ?>/statics/img/mall/app-share.png",
- name_bg: "<?= \Yii::$app->request->baseUrl ?>/statics/img/mall/app-share-name.png",
- pic_bg: "<?= \Yii::$app->request->baseUrl ?>/statics/img/mall/app-share-pic.png",
- },
- is_show_distribution: 1,
- is_show_agent: 1,
- is_show_area: 1,
- is_show_short_video: 1,
- is_show_coupon: 1,
- use_score: 0,
- video_type: 1,
- cardDialogVisible: false,
- isEcoupon: false, //默认没有安装电子券插件
- currencyList : [], //可用货币列表
- publicLeverData : {}, //红包设置公用的等级数据
- foundLoading: false,
- userList: {},
- edit: {
- chooseUser: false
- }
- };
- },
- created() {
- if (getQuery('id')) {
- this.getDetail(getQuery('id'));
- this.goods_id = getQuery('id');
- }
- if (this.is_distribution == 1) {
- this.getPermissions();
- } else {
- this.is_show_distribution = 0
- }
- this.getLabels();
- this.getEcoupon();
- },
- 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;
- },
- isConfineCount() {
- return this.ruleForm.confine_count === -1;
- },
- },
- filters: {
- checkedStatus(status) {
- if(this.checkedCities1.indexOf(status) > -1){
- return true
- }else{
- return false;
- }
- },
- },
- methods: {
- chooseUser() {
- this.edit.chooseUser = true;
- },
- search(){
- this.foundLoading = true;
- request({
- params: {
- r: 'plugin/o2o_store/mall/store/search-user',
- keyword: this.keyword,
- },
- }).then(e => {
- this.foundLoading = false;
- if (e.data.code == 0) {
- this.userList = e.data.data.list;
- }
- }).catch(e => {
- this.foundLoading = false;
- });
- },
- // 红包设置-公用的等级数据
- getPublicLeverData(msg){
- this.publicLeverData = msg;
- console.log(this.publicLeverData);
- console.log('msg');
- },
- // 获取获取可用货币,用于商品设置
- getEnableCurrency() {
- this.loading = true;
- // const cacheKey = '_MALL_CURRENCY'; //对应商城可用货币
- let params = {
- r: 'mall/currency/get-enable-currency'
- };
- request({
- params: params,
- method: 'get',
- }).then(e => {
- this.loading = false;
- if (e.data.code == 0) {
- this.currencyList = e.data.data;
- console.log(this.currencyList);
- // console.log('444555');
- if(this.currencyList.length && this.currencyList.length>0){
- let currency_deduct_setting = [];
- this.currencyList.forEach((item, index) => {
- let settingItem = {
- max_deduction_num : 0, //币种最大抵扣数
- give_num : 0, //币种赠送数额
- is_percent_give : '1', //是否按百分比赠送
- deduction_type : '1', //抵扣类型
- }
- settingItem['currency_code'] = item.code;
- let response_currency_deduct_setting = JSON.parse(JSON.stringify(this.ruleForm.currency_deduct_setting));
- // console.log(response_currency_deduct_setting);
- if(response_currency_deduct_setting.length && response_currency_deduct_setting.length>0){
- response_currency_deduct_setting.forEach((its, ids) => {
- if(its.currency_code == item.code){
- settingItem = Object.assign(settingItem, its);
- }
- })
- }
- currency_deduct_setting.push(settingItem);
- })
- this.$set(this.ruleForm, 'currency_deduct_setting', currency_deduct_setting);
- }
- } else {
- }
- }).catch(e => {
- this.loading = false;
- });
- },
- //0.1 getEcoupon-检查是否安装了电子券插件
- getEcoupon() {
- let self = this;
- self.cardLoading = true;
- request({
- params: {
- r: 'mall/plugin/is-install',
- plugin_name: 'e_coupon',
- },
- method: 'get',
- }).then(e => {
- self.cardLoading = false;
- if (e.data.code == 0) {
- self.isEcoupon = true;
- } else {
- self.isEcoupon = false;
- }
- })
- },
- getLabels() {
- request({
- params: {
- r: 'mall/goods/label',
- },
- }).then(e => {
- if (e.data.code === 0) {
- this.label_list = e.data.data.list;
- } else {
- }
- })
- },
- showPreview() {
- this.$refs.preview.previewGoods();
- this.$emit('handle-preview', this.ruleForm);
- },
- selectCat(cats) {
- this.cats = cats;
- let arr = [];
- cats.map(v => {
- arr.push(v.value);
- })
- this.ruleForm.cats = arr;
- this.$refs.ruleForm.validateField('cats');
- },
- selectMchCat(cats) {
- this.mchCats = cats;
- let arr = [];
- cats.map(v => {
- arr.push(v.value);
- })
- this.ruleForm.mchCats = arr;
- this.$refs.ruleForm.validateField('mchCats');
- },
- getSvip() {
- request({
- params: {
- r: 'mall/member-level/vip-card-permission',
- plugin: this.sign
- },
- }).then(e => {
- if (e.data.code === 0) {
- this.is_svip = true;
- } else {
- this.is_svip = false;
- }
- })
- },
- delPic(index) {
- this.ruleForm.pic_url.splice(index, 1)
- },
- catDialogCancel() {
- let that = this;
- that.mchDialogVisible = false;
- that.dialogVisible = false;
- that.ruleForm.cats = [];
- that.ruleForm.mchCats = [];
- if (that.cats.length > 0) {
- that.cats.forEach(function(row) {
- that.ruleForm.cats.push(row.value.toString());
- })
- }
- if (that.mchCats.length > 0) {
- that.mchCats.forEach(function(row) {
- that.ruleForm.mchCats.push(row.value.toString());
- })
- }
- },
- getPermissions() {
- let self = this;
- request({
- params: {
- r: 'mall/index/mall-permissions'
- },
- method: 'get',
- }).then(e => {
- if (e.data.code === 0) {
- if(self.admin_type > 1){
- self.is_show_distribution = 0;
- self.is_show_agent = 0;
- self.is_show_area = 0;
- self.is_show_short_video = 0;
- e.data.data.permissions.forEach(function (item) {
- if (item.includes('distribution')){
- self.is_show_distribution = 1;
- }
- if (item.includes('area')){
- self.is_show_area = 1;
- }
- if (item.includes('agent')){
- self.is_show_agent = 1;
- }
- if (item.includes('video')){
- self.is_show_short_video = 1;
- }
- })
- }
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- store(formName) {
- let self = this;
- try {
- self.cForm.attr.map(item => {
- if (item.price < 0 || item.price === '') {
- throw new Error('规格价格不能为空');
- }
- if (item.stock < 0 || item.stock === '') {
- throw new Error('库存不能为空');
- }
- })
- } catch (error) {
- self.$message.error(error.message);
- return;
- }
- self.$refs[formName].validate((valid) => {
- if (valid) {
- self.btnLoading = true;
- if (self.is_svip) {
- self.cForm.is_vip_card_goods = self.is_vip_card_goods
- } else {
- delete self.cForm['is_vip_card_goods']
- }
- // 积分设置百分比
- if(self.ruleForm.give_score_type==2 && ((self.ruleForm.give_score*1 < 0) || (self.ruleForm.give_score*1 >100))){
- this.$message.error('积分设置百分比范围为0%~100%');
- return
- }
- // console.log(self.cForm);
- // return
- request({
- params: {
- r: 'plugin/o2o_store/mall/store/edit'
- },
- method: 'post',
- data: {
- form: JSON.stringify(self.cForm),
- attrGroups: JSON.stringify(self.attrGroups),
- }
- }).then(e => {
- self.btnLoading = false;
- if (e.data.code === 0) {
- //保存成功
- self.$message.success(e.data.msg);
- if (typeof this.referrer === 'object') {
- navigateTo(this.referrer)
- } else {
- navigateTo({
- r: this.referrer,
- })
- }
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- } else {
- console.log('error submit!!');
- self.$message.error('请填写必填参数');
- return false;
- }
- });
- },
- getDetail(id, url = '') {
- let self = this;
- self.cardLoading = true;
- request({
- params: {
- r: url ? url : this.get_goods_url,
- id: id,
- },
- method: 'get',
- }).then(e => {
- self.cardLoading = false;
- if (e.data.code == 0) {
- let detail = e.data.data.detail;
- if (detail['use_attr'] === 0) {
- detail['attr_groups'] = [];
- }
- if (detail.is_vip_card_goods) {
- self.is_vip_card_goods = detail.is_vip_card_goods
- }
- if (this.form && this.form.extra) {
- for (let i in this.form.extra) {
- if (detail.use_attr == 1) {
- for (let j in detail.attr) {
- if (!detail.attr[j][i]) {
- detail.attr[j][i] = 0;
- }
- }
- }
- Vue.set(self.ruleForm, i, 0);
- }
- }
- self.cats = detail.cats;
- if (detail.cats) {
- let cats = [];
- for (let i in detail.cats) {
- cats.push(detail.cats[i].value.toString());
- }
- detail.cats = cats;
- }
- self.mchCats = detail.mchCats;
- if (detail.mchCats) {
- let mchCats = [];
- for (let i in detail.mchCats) {
- mchCats.push(detail.mchCats[i].value.toString());
- }
- detail.mchCats = mchCats;
- }
- self.ruleForm = Object.assign(self.ruleForm, detail);
- self.attrGroups = e.data.data.detail.attr_groups;
- self.goods_warehouse = e.data.data.detail.goods_warehouse;
- self.defaultServiceChecked = !!parseInt(self.ruleForm.is_default_services);
- //全额积分抵扣
- this.checkFullForeheadScore();
- self.$emit('goods-success', self.ruleForm);
- // 这里可能要构建-营销多货币返显数据
- self.getEnableCurrency(); //获取可用币种
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- self.cardLoading = false;
- console.log(e);
- });
- },
- // 标签页
- handleClick(tab, event) {
- this.$emit('change-tabs', tab.name);
- console.log(tab.name, 'tab.nametab.nametab.name')
- if (tab.name == "third") {
- if (this.goods_id == 0) {
- this.$alert('请先保存商品后重试!', '分销设置提示', {
- confirmButtonText: '确定',
- });
- return;
- }
- this.distributionName = 'default';
- this.getMembers();
- }
- if(tab.name == "fourth" || tab.name == "fifth"){
- // 分销、经销、区域设置二级tab初始化
- this.distributionName = 'default';
- }
- if (tab.name == "seventh") {
- // 请求短视频设置
- this.videoLoadData();
- }
- if (tab.name == "eighth") {
- this.marketeName = 'default';
- // 请求短视频设置
- // this.videoLoadData();
- }
- if (tab.name == "second") {
- // 请求会员价设置
- this.getMembers();
- }
- if (tab.name == "tenth") {
- // 电子券设置
- }
- },
- // 货币设置二级tab点击事件
- distributionClick(tab, event) {
- this.$emit('change-tabs', tab.name);
- console.log(tab.name, 'tab.nametab.nametab.name')
- },
- // 获取商品服务
- getServices() {
- let self = this;
- this.service.loading = true;
- request({
- params: {
- r: 'mall/service/options'
- },
- method: 'get',
- data: {}
- }).then(e => {
- this.service.loading = false;
- if (e.data.code == 0) {
- self.service.services = e.data.data.list;
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- // 设置默认服务
- defaultService() {
- if (this.defaultServiceChecked) {
- this.ruleForm.is_default_services = 1;
- this.ruleForm.services = [];
- } else {
- this.ruleForm.is_default_services = 0;
- }
- },
- // 获取会员列表
- getMembers() {
- let self = this;
- self.cardLoading = true;
- request({
- params: {
- r: 'mall/member-level/all-member'
- },
- method: 'get',
- data: {}
- }).then(e => {
- self.cardLoading = false;
- if (e.data.code == 0) {
- self.memberLevel = e.data.data.list;
- let defaultMemberPrice = [];
- // 以下数据用于默认规格情况下的 会员价设置
- self.memberLevel.forEach(function(item, index) {
- let obj = {};
- obj['id'] = index;
- obj['name'] = item.name;
- obj['level'] = 'level' + parseInt(item.level);
- defaultMemberPrice.push(obj);
- });
- self.defaultMemberPrice = defaultMemberPrice;
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- // 获取运费规则选项
- getFreight() {
- let self = this;
- this.freight.loading = true;
- request({
- params: {
- r: 'mall/postage-rules/all-list'
- },
- method: 'get',
- data: {}
- }).then(e => {
- this.freight.loading = false;
- if (e.data.code == 0) {
- self.freight.list = e.data.data.list;
- // 添加商品时使用默认运费
- self.freight.list.unshift({
- id: 0,
- name: '默认运费',
- status: 1
- })
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- // 规格组合
- 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: 0,
- price: 0,
- no: '',
- weight: 0,
- pic_url: '',
- distributionLevelList: [],
- };
- let extra = {};
- if (this.form && this.form.extra) {
- extra = JSON.parse(JSON.stringify(this.form.extra));
- for (let i in extra) {
- row[i] = 0;
- }
- }
- // 动态绑定多规格会员价
- let obj = {};
- self.memberLevel.forEach(function(memberLevelItem, memberLevelIndex) {
- let key = 'level' + memberLevelItem.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;
- },
- // 批量设置
- 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)
- },
- destroyCat_2(value, index) {
- let self = this;
- self.ruleForm.mchCats.splice(self.ruleForm.mchCats.indexOf(value), 1)
- self.mchCats.splice(index, 1)
- },
- // 商品视频
- videoUrl(e) {
- if (e.length) {
- this.ruleForm.video_url = e[0].url;
- }
- },
- // 短视频设置单选按钮
- shareTypeChange(e) {
- if (e == 0) {
- this.ruleForm.percentage = 0;
- } else {
- this.ruleForm.fixed_value = 0;
- }
- },
- // 4.0 短视频设置
- videoSetting() {
- let self = this;
- let postData = {
- goods_id: self.goods_id,
- video_share_type: self.ruleForm.video_share_type,
- percentage: self.ruleForm.percentage,
- fixed_value: self.ruleForm.fixed_value,
- is_alone: self.ruleForm.is_alone,
- }
- request({
- params: {
- r: 'plugin/short_video/mall/goods/goods-setting',
- },
- method: 'post',
- data: postData
- }).then(e => {
- self.loading = false;
- if (e.data.code == 0) {
- self.$message.success(e.data.msg);
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- // 4.1 获取短视频设置
- videoLoadData() {
- let self = this;
- self.loading = true;
- request({
- params: {
- r: 'plugin/short_video/mall/goods/goods-setting',
- goods_id: self.goods_id,
- },
- method: 'get',
- data: {}
- }).then(e => {
- self.loading = false;
- if (e.data.code == 0) {
- // self.form = e.data.data.setting;
- self.ruleForm.is_alone = e.data.data.is_alone;
- self.ruleForm.video_share_type = e.data.data.video_share_type;
- self.ruleForm.percentage = e.data.data.percentage;
- self.ruleForm.fixed_value = e.data.data.fixed_value;
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- // 商品轮播图
- picUrl(e) {
- if (e.length) {
- let self = this;
- e.forEach(function(item, index) {
- if (self.ruleForm.pic_url.length >= 9) {
- return;
- }
- self.ruleForm.pic_url.push({
- id: item.id,
- pic_url: item.url
- });
- });
- }
- },
- // 是否开启规格
- checkedAttr(e) {
- if (e == 1) {
- this.attrGroups = [];
- this.ruleForm.goods_num = this.ruleForm.goods_num ? this.ruleForm.goods_num : 0;
- }
- },
- itemChecked(type) {
- this.ruleForm.confine_count = type ? -1 : 0;
- },
- itemOrderChecked(type) {
- this.ruleForm.confine_order_count = type ? -1 : 0;
- },
- selectGoodsWarehouse(goods_warehouse) {
- this.ruleForm.select_attr_groups = [];
- this.getDetail(goods_warehouse.id, 'mall/goods/edit')
- },
- copyGoods() {
- this.copyLoading = true;
- request({
- params: {
- r: 'mall/goods/collect',
- url: this.copyUrl
- },
- method: 'get'
- }).then(e => {
- this.copyLoading = false;
- if (e.data.code === 0) {
- let detail = e.data.data.detail;
- if (this.form && this.form.extra) {
- for (let i in this.form.extra) {
- if (detail.use_attr == 1) {
- for (let j in detail.attr) {
- if (!detail.attr[j][i]) {
- detail.attr[j][i] = 0;
- }
- }
- }
- Vue.set(this.ruleForm, i, 0);
- }
- }
- this.ruleForm = Object.assign(this.ruleForm, detail);
- this.attrGroups = e.data.data.detail.attr_groups;
- this.$message.success(e.data.msg);
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- this.copyLoading = false;
- console.log(e);
- });
- },
- updatePicUrl(e, params) {
- this.ruleForm.pic_url[params.currentIndex].id = e[0].id;
- this.ruleForm.pic_url[params.currentIndex].pic_url = e[0].url;
- },
- getOptionName(name) {
- let newName = name;
- let num = 12;
- if (newName.length > num) {
- newName = newName.substring(0, num) + '...';
- }
- return newName;
- },
- /*---商品服务----*/
- serviceOpen() {
- this.service.dialog = true;
- this.getServices();
- },
- serviceCancel() {
- this.service.dialog = false;
- this.service.list = [];
- },
- serviceConfirm() {
- let self = this;
- let newServices = JSON.parse(JSON.stringify(this.service.list));
- let addServices = [];
- newServices.forEach(function(item, index) {
- let sign = true;
- self.ruleForm.services.forEach(function(item2, index2) {
- if (item.id == item2.id) {
- sign = false;
- }
- })
- if (sign) {
- addServices.push(item)
- }
- });
- this.ruleForm.services = this.ruleForm.services.concat(addServices);
- this.serviceCancel();
- },
- serviceDelete(index) {
- this.ruleForm.services.splice(index, 1);
- },
- /*---运费----*/
- freightOpen() {
- this.freight.dialog = true;
- this.getFreight();
- },
- freightCancel() {
- this.freight.checked = {};
- this.freight.dialog = false;
- },
- freightConfirm() {
- this.ruleForm.freight = JSON.parse(JSON.stringify(this.freight.checked));
- this.ruleForm.freight_id = this.ruleForm.freight.id;
- this.freightCancel();
- },
- freightDelete() {
- this.ruleForm.freight = null;
- this.ruleForm.freight_id = 0;
- },
- cardDelete(index) {
- this.ruleForm.cards.splice(index, 1);
- },
- // 上架状态开关,弹框文字提示
- statusChange(res) {
- if (res && this.status_change_text) {
- this.$alert(this.status_change_text, '提示', {
- confirmButtonText: '确定',
- callback: action => {}
- });
- }
- },
- selectForm(data) {
- this.ruleForm.form = data;
- this.ruleForm.form_id = data ? data.id : -1;
- },
- fullForeheadScore() {
- this.ruleForm.forehead_score = 99999999;
- this.ruleForm.forehead_score_type = 1;
- this.ruleForm.accumulative = this.ruleForm.full_forehead_score;
- if (this.ruleForm.full_forehead_score == 0) {
- this.ruleForm.forehead_score = 0;
- }
- },
- //检查是否积分全额抵扣
- checkFullForeheadScore() {
- if (this.ruleForm.forehead_score == 99999999 &&
- this.ruleForm.accumulative == 1
- ) {
- this.ruleForm.full_forehead_score = 1;
- }
- },
- change(e) {
- this.$forceUpdate();
- }
- }
- });
- </script>
|