| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176 |
- <?php
- use common\helpers\ComponentHelper;
- ComponentHelper::loadComponentView('goods/com-attr', __DIR__);
- ComponentHelper::loadComponentView('com-attr-select' );
- ComponentHelper::loadComponentView('com-select-goods');
- ComponentHelper::loadComponentView('com-dialog-select');
- ?>
- <style>
-
- .type_text {
- font-size: 16px;
- font-weight: 600;
- color: #333;
- margin-right: 20px;
- }
- .detail_top {
- flex-wrap: wrap;
- }
- .detail_box {
- margin-top: 10px;
- }
- .coupon_box {
- width: 600px;
- margin-right: 50px;
- }
- .detail_top .coupon_box:last-child {
- margin-right: 0px;
- }
- .coupon_list_box {
- padding: 20px 20px 0 0;
- flex-wrap: wrap;
- box-sizing: border-box;
- overflow: hidden;
- height: 125px;
- }
- .coupon_list_box_active {
- height: auto;
- }
- .coupon_list_item {
- background: #F4F4F4;
- width: 275px;
- border-radius: 5px;
- position: relative;
- margin-bottom: 15px;
- padding: 10px;
- }
- .add_coupon .el-button {
- padding: 6px 18px;
- margin: 20px 0;
- }
- .close_icon {
- font-size: 20px;
- font-weight: 700;
- position: absolute;
- right: 10px;
- top: 8px;
- cursor: pointer;
- }
- .coupon_list_title {
- font-size: 16px;
- margin-bottom: 5px;
- width: 180px;
- }
- .coupon_list_content {
- margin-bottom: 2px;
- font-size: 12px;
- }
- .more_btn {
- text-align: center;
- cursor: pointer;
- margin-top: 20px;
- }
- .more_icon {
- transform: rotate(0deg);
- transition: all 0.7s;
- }
- .show_more_icon {
- transform: rotate(180deg);
- }
- .show {
- height: auto;
- }
- .hide {
- height: 0;
- overflow: hidden;
- }
- .transform-hide {
- opacity: 0;
- -webkit-transform: translateY(-50%);
- transform: translateY(-50%);
- -webkit-transition: .3s;
- transition: .3s;
- }
- .transform-show {
- opacity: 1 !important;
- -webkit-transform: translateY(0) !important;
- transform: translateY(0) !important;
- }
- .is_divider {
- display: block;
- }
- @media screen and (min-width: 1540px) {
- .is_divider {
- display: none;
- }
- }
- .red_envelope_box {
- width: 600px;
- margin-right: 50px;
- }
- .red_envelope_box:last-child {
- margin-right: 0px;
- }
- .red_envelope_box .el-input {
- width: 150px;
- }
- .red_envelope_box .el-textarea {
- width: 250px;
- }
- .el-input {
- flex: 1;
- }
- .el-textarea {
- flex: 1;
- }
- .types_box {
- padding: 20px 20px 30px;
- }
- .label_title {
- font-weight: 600;
- margin-bottom: 8px;
- font-size: 16px;
- }
- .checkt_select {
- width: 140px;
- }
- .check_input {
- width: 200px;
- margin-left: 10px;
- }
- .check_btn_list .el-button {
- padding: 6px 14px;
- margin-bottom: 20px;
- }
- .el-dialog__footer {
- text-align: center;
- }
- .check_pagination {
- justify-content: flex-end;
- margin-top: 20px;
- }
- /* 谷歌 */
- input::-webkit-outer-spin-button,
- input::-webkit-inner-spin-button {
- -webkit-appearance: none;
- appearance: none;
- margin: 0;
- }
- /* 火狐 */
- input {
- -moz-appearance: textfield;
- }
- /* 公共样式 */
- .flex {
- display: -webkit-box;
- display: -webkit-flex;
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- }
- .flex-x-center {
- display: -webkit-box;
- display: -webkit-flex;
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- -webkit-box-pack: center;
- -webkit-justify-content: center;
- -ms-flex-pack: center;
- justify-content: center;
- }
- .flex-x-between {
- display: -webkit-box;
- display: -webkit-flex;
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- -webkit-box-pack: space-between;
- -webkit-justify-content: space-between;
- -ms-flex-pack: space-between;
- justify-content: space-between;
- }
- .flex-y-center {
- display: -webkit-box;
- display: -webkit-flex;
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- -webkit-box-align: center;
- -webkit-align-items: center;
- -ms-flex-align: center;
- -ms-grid-row-align: center;
- align-items: center;
- }
- /* 溢出隐藏 */
- .over1 {
- text-overflow: -o-ellipsis-lastline;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 1;
- -webkit-box-orient: vertical;
- }
- .over2 {
- text-overflow: -o-ellipsis-lastline;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- }
-
- .huiyuanRadio{
- margin-bottom: 10px;
- }
- </style>
- <template id="abc">
- <el-card shadow="never" style="border:0" body-style="background-color: #f3f3f3;padding: 10px 0 0;" class="com-goods" v-loading="cardLoading">
- <div>
- <el-form :model="cForm" :rules="cRule" ref="ruleForm" label-width="140px" size="small" class="demo-ruleForm">
- <el-tabs v-model="activeName">
- <el-tab-pane label="基础设置" name="first">
- <!-- 选择分类 -->
- <slot name="before_cats"></slot>
- <!-- 基本信息 -->
- <slot name="before_info"></slot>
- <el-card shadow="never" class="mt-24" style="margin-bottom: 20px;">
- <div slot="header">
- <span>基本信息</span>
- </div>
- <el-row>
- <el-col :xl="12" :lg="16">
- <template>
- <el-form-item label="拼团活动名称">
- <el-input class="width-200" v-model="title"></el-input>
- </el-form-item>
- <el-form-item label="拼团分类" prop="parent_title">
- <el-select v-model="cate_name" placeholder="请选择" @change="handleChange">
- <el-option v-for="item,k in cateList" :key="item.id" :label="item.name" :value="item.id">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="商品信息获取" width="120">
- <label slot="label">
- 商品信息获取
- <el-tooltip class="item" effect="dark" content="只能从商城中获取商品信息,且基本信息与商城商品保持一致" placement="top">
- <i class="el-icon-info"></i>
- </el-tooltip>
- </label>
- <div>
- <el-row type="flex">
- <com-dialog-select :multiple="false" :url="goodsIndexUrl"
- @selected="selectGoodsWarehouse" ref="comDialogSelect"
- :show-mch-source="true" :extra-search-fields="['goods_source']">
- <el-button>选择商品</el-button>
- </com-dialog-select>
- </el-row>
- </div>
- </el-form-item>
- <el-form-item v-if="formGoodsList.length>0" label="拼团商品">
- <div class="table-body" style="padding-left: 0;padding-top: 0;">
- <template>
- <el-table :data="formGoodsList" border style="width: 100%">
- <el-table-column fixed type="index" label="编号" show-overflow-tooltip width="50">
- </el-table-column>
- <el-table-column prop="goods_name,cover_pic" label="商品名称" >
- <template slot-scope="scope">
- <div flex="box:first">
- <div style="padding-right: 10px;">
- <com-image mode="aspectFill" :src="scope.row.cover_pic"></com-image>
- </div>
- <div flex="cross:top cross:center">
- {{scope.row.goods_name}}
- </div>
- </div>
- </template>
- </el-table-column>
- <el-table-column fixed="right" label="操作" width="100">
- <template slot-scope="scope">
- <el-button @click="delGoods(scope.$index)" type="primary" size="mini">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </template>
- </div>
- </el-form-item>
- <el-form-item label="规格" v-if="is_attr == 0">
- <el-row type="flex">
- <com-ellipsis :line="1">
- <template v-for="item in ruleForm.select_attr_groups">
- <span style="margin: 0 5px;">
- {{item.attr_group_name}}:{{item.attr_name}}
- </span>
- </template>
- </com-ellipsis>
- </el-row>
- </el-form-item>
- </template>
- </el-col>
- </el-row>
- </el-card>
- <!-- 价格库存 -->
- <slot name="before_attr"></slot>
- <el-card shadow="never" class="mt-24" style="margin-bottom: 20px;">
- <div slot="header">
- <span>价格库存</span>
- </div>
- <el-row>
- <el-col :xl="12" :lg="16">
- <template v-if="is_attr == 1">
- <el-form-item prop="goods_num" v-if="ruleForm.use_attr==0">
- <label slot="label">
- <span>拼团商品总库存</span>
- <el-tooltip class="item" effect="dark" content="拼团商品总库存与普通商品总库存相互独立" placement="top">
- <i class="el-icon-info"></i>
- </el-tooltip>
- </label>
-
- <el-input type="number" min="0" :max="999999" @input="changeInput" v-model="goods_stock"><!--oninput="this.value = this.value.replace(/[^0-9\.]/, '');" :disabled="moreAttrs" -->
- </el-input>
- </el-form-item>
- <el-form-item prop="goods_num" v-show="ruleForm.use_attr==1">
- <label slot="label">
- <span>商品规格</span>
- <el-tooltip class="item" effect="dark" content="如有颜色、尺码等多种规格,请添加商品规格" placement="top">
- <i class="el-icon-info"></i>
- </el-tooltip>
- </label>
- <div v-show="ruleForm.use_attr" style="width:130%;margin-top: 24px;">
- <com-attr ref="commAttrs" v-model="ruleForm.attr" :attr-groups="attrGroups" :extra="cForm.extra ? cForm.extra : {}"></com-attr>
- </div>
- </el-form-item>
- <el-form-item label="售价" prop="price" v-if="is_price !=3">
- <el-input :disabled="true" type="number" oninput="this.value = this.value.replace(/[^0-9\.]/, '');" min="0" v-model="ruleForm.price">
- <template slot="append">元</template>
- </el-input>
- </el-form-item>
- <el-form-item label="拼团价" prop="group_buy_price" v-if="ruleForm.use_attr==0">
- <el-input oninput="value = toNumber(value, 2)" min="0" :max="ruleForm.price" v-model="ruleForm.group_buy_price">
- <template slot="append">元</template>
- </el-input>
- </el-form-item>
- </template>
- </el-col>
- </el-row>
- </el-card>
- <el-card shadow="never" class="mt-24" style="margin-bottom: 20px;">
- <div slot="header">
- <span>拼团信息</span>
- </div>
- <el-row>
- <el-col :xl="12" :lg="16">
- <template v-if="is_attr == 1">
- <el-form-item label="拼团活动时间">
- <el-date-picker
- size="small"
- v-model="activeTime"
- @change="datetimeChange"
- type="datetimerange"
- range-separator="至"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- value-format="yyyy-MM-dd HH:mm:ss"
- align="center">
- </el-date-picker>
- </el-form-item>
- <el-form-item label="拼团有效时间" prop="goods_num">
- <el-input style="width:220px;" type="number" min="0" v-model="continuedHouse" @input="changeInput2"><!-- oninput="this.value = this.value.replace(/[^0-9\.]/, '');" -->
- <template slot="append">小时</template>
- </el-input>
- <el-input style="width:220px;margin-left: 20px;" type="number" min="0" max="59" v-model="continuedMinute" @input="changeInput3"><!-- oninput="this.value = this.value.replace(/[^0-9\.]/, '');" -->
- <template slot="append">分钟</template>
- </el-input>
- </el-form-item>
- <!-- 加入校验规则rules显示* -->
- <el-form-item label="成团人数" prop="goods_num">
- <el-input type="number" placeholder="请输入2-999999人" oninput="this.value = this.value.replace(/[^0-9]/, '');" min="0" v-model="group_size">
- <template slot="append">人</template>
- </el-input>
- </el-form-item>
- <!-- 高级设置 -->
- <el-form-item label="高级设置" prop="status">
- <el-switch v-model="senior_setting" :active-value="1" :inactive-value="0">
- </el-switch>
- </el-form-item>
-
- <el-form-item label="限购规则" v-if="senior_setting">
- <div>
- <el-radio v-model="purchase" border :label="2">不限购</el-radio>
- <el-radio v-model="purchase" border :label="1">限购</el-radio>
- </div>
- <div style="margin-top: 15px;width: 350px;" v-if="purchase == 1">
- <el-input placeholder="请输入数量" type="number" v-model="limit_buy_num" oninput="this.value = this.value.replace(/[^0-9]/, '');">
- <template slot="prepend">每单限购</template>
- <template slot="append">件/人</template>
- </el-input>
- </div>
- </el-form-item>
- <el-form-item label="限制参团规则" v-if="senior_setting" required>
- <label slot="label">
- 限制参团规则
- <el-tooltip class="item" effect="dark" content="只有拼团中和拼团成功才计算参团次数,拼团失败不计入参团次数" placement="top">
- <i class="el-icon-info"></i>
- </el-tooltip>
- </label>
- <div>
- <el-radio-group v-model="is_restrict_rule">
- <el-radio :label="0" border>不限制</el-radio>
- <el-radio :label="1" border>限制</el-radio>
- </el-radio-group>
- </div>
- <div style="margin-top: 15px;width: 350px;" v-if="is_restrict_rule == 1">
- <el-input placeholder="限制参团" type="number" v-model="restrict_rule_num" oninput="this.value = this.value.replace(/[^0-9]/, '');">
- <template slot="prepend">限制参团</template>
- <template slot="append">次/人</template>
- </el-input>
- </div>
- </el-form-item>
- <el-form-item label="团长权重限制" v-if="senior_setting">
- <div>
- <div>
- <el-radio class="huiyuanRadio" v-model="isAll_C" border :label="1">全部用户</el-radio>
- <el-radio class="huiyuanRadio" v-model="isAll_C" border :label="2">指定用户权重</el-radio>
- </div>
- <div style="display: flex;" v-if="isAll_C == 2">
- <div style="margin-right: 20px;">
- <el-checkbox :indeterminate="isIndeterminate_C" v-model="checkAll_C" @change="handleCheckAllChange_C">全选</el-checkbox>
- </div>
- <div>
- <el-checkbox-group v-model="checkedCities_C" @change="handleCheckedCitiesChange_C">
- <el-checkbox v-for="(item,index) in memberLevel" :label="item.level" :value="item.level" :key="index" >{{item.name}}</el-checkbox>
- </el-checkbox-group>
- </div>
-
- </div>
- </div>
- </el-form-item>
- <el-form-item label="团员等级限制" v-if="senior_setting">
- <div>
- <div>
- <el-radio class="huiyuanRadio" v-model="isAll" border :label="1">全部用户</el-radio>
- <el-radio class="huiyuanRadio" v-model="isAll" border :label="2">指定用户等级</el-radio>
- </div>
- <div style="display: flex;" v-if="isAll == 2">
- <div style="margin-right: 20px;">
- <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
- </div>
- <div>
- <el-checkbox-group v-model="checkedCities" @change="handleCheckedCitiesChange">
- <el-checkbox v-for="(item,index) in memberLevel" :label="item.level" :value="item.level" :key="index" >{{item.name}}</el-checkbox>
- </el-checkbox-group>
- </div>
- </div>
- </div>
- </el-form-item>
- <el-form-item v-if="senior_setting" label="团长福利" prop="goods_num">
- <el-radio style="display: block;" v-model="sendStatus" :label="1">
- 团长送积分
- <el-input type="number" style="width:200px;margin-left:10px;margin-bottom: 10px;" oninput="this.value = this.value.replace(/[^0-9\.]/, '');" min="0" :disabled="sendStatus==1?false:true" v-model="give_score">
- </el-input>
- 积分
- </el-radio>
- <el-radio style="display: block;" v-model="sendStatus" :label="2">
- 团长送余额
- <el-input type="number" style="width:200px;margin-left:10px;margin-bottom: 10px;" oninput="this.value = this.value.replace(/[^0-9\.]/, '');" min="0" :disabled="sendStatus==2?false:true" v-model="give_balance">
- </el-input>
- 元
- </el-radio>
- <div v-if="coupon_data.length > 2" class="more_btn flex flex-y-center flex-x-center" @click="showMore('coupon')">
- <div style="margin-right: 2px;" v-if="is_coupon_more">收起</div>
- <div style="margin-right: 2px;" v-else>更多</div>
- <i class="el-icon-arrow-down more_icon" :class="{show_more_icon:is_coupon_more}" style="font-size: 18px;"></i>
- </div>
- </el-form-item>
- <el-form-item v-if="senior_setting" label="发起人是否免费开团" prop="is_initiator_free">
- <el-switch v-model="is_initiator_free" :active-value="1" :inactive-value="0">
- </el-switch>
- </el-form-item>
- <el-form-item v-if="senior_setting" label="拼团详情是否显示参团人员昵称" prop="is_show_participant_nickname">
- <el-switch v-model="is_show_participant_nickname" :active-value="1" :inactive-value="0">
- </el-switch>
- </el-form-item>
- <!-- 是否开启虚拟成团 -->
- <el-form-item v-if="senior_setting" label="是否开启虚拟成团" prop="status">
- <div>
- <el-switch v-model="is_virtual" :active-value="1" :inactive-value="0">
- </el-switch>
- </div>
- <div style="margin-bottom: 10px;">
- <el-tag type="warning">开启模拟成团后,满足条件的团,系统将会模拟“匿名买家”凑满该团,仅需对真实拼团买家发货。建议合理开启,以提高成团率。</el-tag>
- </div>
- <div v-if="is_virtual&&senior_setting">
- <el-radio class="huiyuanRadio" v-model="virtual_group_type" :label="1">虚拟立即成团</el-radio>
- <el-radio class="huiyuanRadio" v-model="virtual_group_type" :label="3">参团结束成团</el-radio>
- <el-radio class="huiyuanRadio" v-model="virtual_group_type" :label="2">参团人数≥ <el-input :disabled="virtual_group_type == 1 || virtual_group_type == 3" style="width: 150px;" type="number" placeholder="请输入数量" v-model="gt_group_size"></el-input> 的团</el-radio>
- <div v-if="virtual_group_type == 3">
- <el-radio-group v-model="virtual_group_sub_type">
- <el-radio :label="0">当拼团有效期结束后,自动成团</el-radio>
- <el-radio :label="1">当参团人数≥
- <el-input v-model="expired_auto_complete_min_num" style="width: 80px;"></el-input>
- 人,拼团有效期结束后,自动成团
- <el-tooltip effect="dark" content="若参团人数 < 所设置的人数,则拼团失败,发起人支付的金额原路返回。" placement="top" style="position: absolute;">
- <i class="el-icon-question"></i>
- </el-tooltip>
- </el-radio>
- </el-radio-group>
- </div>
- </div>
- <!-- 是否显示虚拟成团人的头像 -->
- <el-form-item v-if="is_virtual && virtual_group_type == 3 && senior_setting" label="是否显示虚拟成团人的头像" prop="is_show_virtual_avatar" label-width="200">
- <div>
- <el-switch v-model="is_show_virtual_avatar" :active-value="1" :inactive-value="0">
- </el-switch>
- </div>
- </el-form-item>
- </el-form-item>
- </template>
- </el-col>
- </el-row>
- </el-card>
- </el-tab-pane>
- <slot name="tab_pane"></slot>
- </el-tabs>
- </el-form>
- <div class="bottom-div" flex="cross:center" v-if="is_save_btn == 1" style="margin-top: 10px;">
- <el-button class="button-item" :loading="btnLoading" type="primary" size="small" @click="store('ruleForm')">保存
- </el-button>
- </div>
- </div>
- </el-card>
- </template>
- <script>
- Vue.component('group-com-goods', {
- template: '#abc',
- props: {
- // 规格库存
- is_attr: {
- type: Number,
- default: 1
- },
- //todo 仅显示售价(抽奖) 秒杀3显示
- is_price: {
- type: Number,
- default: 0
- },
- // 添加数据接口
- store_url: {
- type: String,
- default: 'group-buy/default/add'
- },
- // 请求数据地址--获取详情
- get_goods_detail_url: {
- type: String,
- default: 'group-buy/index/show'
- },
- // 保存之后返回地址
- referrer: {
- default: 'group-buy/default/index'
- },
- // 页面上数据
- form: Object,
- // 数据验证方式
- rule: Object,
- is_save_btn: {
- type: Number,
- default: 1
- }
- },
- data() {
- let ruleForm = {
- labels: [],
- attr: [],
- use_attr: 0,
- group_buy_price: '',
- select_attr_groups: [], // 已选择的规格
- goodsWarehouse_attrGroups: [], // 商品库商品所有的规格
- share_level_type: 0,
- };
- let rules = {
- };
- return {
- value1: '',
- goodsIndexUrl: 'group-buy/default/goods-list',
- title: '', //拼团活动名称
- formGoodsList: [], //选中的商品数组(最多只能选一个)
- moreAttrs: true, //默认选中多规格商品
- goods_stock: 0, //拼团商品总库存
- groupGoodsId: '', //拼团商品id
- valueDay: '', //添加拼团商品开始日期
- valueTime: '', //添加拼团具体时间
- groupStartDate: '', //拼团活动开始时刻
- groupEndDate: '', //拼团活动结束时间
- continuedHouse: '', //拼团小时数
- continuedMinute: '', //拼团分钟数
- continuedTime: '', //拼团活动持续时间
- group_size: 0, //成团所需人数
- senior_setting: 0, //默认不开启虚拟成团
- virtual_group_size: 0, //虚拟成团人数
- is_virtual: 0, //是否虚拟成团
- sendStatus: 0,
- give_score: 0, //团长送积分
- give_balance: 0, //团长送余额
- send_red_packet: 0, //送红包
- limit_buy_num:'',//限制购买数量 0=不限制
- goods_id: 0,
- cardLoading: false,
- btnLoading: false,
- activeName: 'first',
- ruleForm: ruleForm,
- attrGroups: [], //规格组
- dialogCoupon:false,
- couponLoading:false,
- couponKeyword: '',
- coupon_delete: [], //删除了的优惠券数据
- coupon_total: 0, //优惠券发放总数
- cou_tableData: [],
- coupon_data: [],
- dialog_total_count: 0,
- page: 1,
- level_arr: [],
- level_index: 0,
- level_id: '',
- coupon_test: [],
- loading:false,
- is_coupon_more: false,
- staging_arr: [],
-
- activeTime:'',
- purchase:2,// 1限购 2不限购
- memberLevel:[],//会员等级列表
- is_restrict_rule: 0, // 0 不限制参团规则 1限制参团规则
- restrict_rule_num: 0, // 限制参团次数
- cateList:[],//分类列表,
- cate_name: '',
- cate_id: 0,
- checkAll: true,
- checkAll_C: true,
- checkedCities: [],
- checkedCities_C: [],
- isIndeterminate: false,
- isIndeterminate_C: false,
- virtual_group_type:1,//虚拟成团类型 1=全部 2=成团人数大于
- gt_group_size:0,//拼团人数大于N,则虚拟成团
- isAll:1,//1指定全部会员购买 2指定等级购买
- isAll_C:1,//1指定全部会员购买 2指定等级购买
- is_initiator_free: 0, // 发起人免费开团
- virtual_group_sub_type: 0, // "参团结束开团" 出现的选项
- expired_auto_complete_min_num: 0, // 当参团人数≥ x 人,拼团有效期结束后,自动成团
- is_show_participant_nickname: 0, // 是否显示参团人员昵称
- is_show_virtual_avatar: 1, // 是否显示虚拟拼团头像
- };
- },
- created() {
- if (getQuery('id')) {
- this.getGoodsList(getQuery('id'));
- this.goods_id = getQuery('id');
- }
- this.getMemberLevel();
- this.getGroupCateList();
- },
- watch: {
- 'ruleForm.detail'(newVal, oldVal) {
- this.cForm.detail = newVal
- },
- 'attrGroups'(newVal, oldVal) {
- this.ruleForm.use_attr = newVal.length === 0 ? 0 : 1;
- },
- 'ruleForm.is_level'(newVal, oldVal) {
- if (newVal === 0) {
- this.ruleForm.is_level_alone = 0;
- }
- },
- },
- // 这里有用到计算属性
- 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.rules;
- },
- },
- methods: {
- changeInput(){
- var pattern = /^[1-9][0-9]*$/ // 正整数的正则表达式
- // 不符合正整数时
- if (!pattern.test(this.goods_stock)) {
- // input 框绑定的内容为空
- this.goods_stock = ''
- }
- },
- changeInput2(){
- var pattern = /^[0-9][0-9]*$/ // 正整数的正则表达式
- // 不符合正整数时
- if (!pattern.test(this.continuedHouse)) {
- // input 框绑定的内容为空
- this.continuedHouse = ''
- }
- },
- changeInput3(){
- var pattern = /^[0-9][0-9]*$/ // 正整数的正则表达式
- // 不符合正整数时
- if (!pattern.test(this.continuedMinute)) {
- // input 框绑定的内容为空
- this.continuedMinute = ''
- }
- },
- handleCheckAllChange(val) {
- let arr = [];
- this.memberLevel.forEach((item)=>{
- arr.push(item.level)
- })
- this.checkedCities = val ? arr : [];
- this.isIndeterminate = false;
- },
- handleCheckAllChange_C(val) {
- let arr = [];
- this.memberLevel.forEach((item)=>{
- arr.push(item.level)
- })
- this.checkedCities_C = val ? arr : [];
- this.isIndeterminate_C = false;
- },
- handleCheckedCitiesChange(value) {
- let checkedCount = value.length;
- this.checkAll = checkedCount === this.memberLevel.length;
- this.isIndeterminate = checkedCount > 0 && checkedCount < this.memberLevel.length;
- },
- handleCheckedCitiesChange_C(value) {
- let checkedCount = value.length;
- this.checkAll_C = checkedCount === this.memberLevel.length;
- this.isIndeterminate_C = checkedCount > 0 && checkedCount < this.memberLevel.length;
- },
- // 会员等级列表
- getMemberLevel() {
- let self = this;
- request({
- params: {
- r: 'group-buy/default/user-level-list',
- page: 1,
- },
- method: 'get',
- }).then(e => {
- if (e.data.code === 0) {
- this.memberLevel = e.data.data.list;
- this.memberLevel.forEach((item)=>{
- this.checkedCities.push(item.level)
- this.checkedCities_C.push(item.level)
- })
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- getGroupCateList() {
- let self = this;
- request({
- params: {
- r: 'group-buy/default/cate-list',
- page: 1,
- },
- method: 'get',
- }).then(e => {
- if (e.data.code === 0) {
- this.cateList = e.data.data.list;
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- datetimeChange(){
- if(this.activeTime){
- this.start_at = this.activeTime[0];
- this.end_at = this.activeTime[1];
- }else{
- this.start_at = '';
- this.end_at = '';
- }
- },
- //拼团活动时间设置
- setActivityTime(params) {
- let begin = params[0];
- let end = params[1];
- self.groupStartDate = dateFormat('YYYY-mm-dd HH:MM:SS',begin);
- self.groupEndDate = dateFormat('YYYY-mm-dd HH:MM:SS',end);
- console.log(self.groupStartDate,self.groupEndDate)
- },
- // 0.0.1 删除选中商品
- delGoods() {
- this.formGoodsList = [];
- this.goods_warehouse = {};
- location.reload(); //刷新当前页
- },
- // 0.1 获取拼团开始时间 2020-08-07 00:00:00
- getGroupStartDate(valueDay, valueTime) {
- let self = this;
- self.groupStartDate = valueDay + ' ' + valueTime;
- },
- // 0.2 获取拼团持续分钟数 -''做乘法运算返回0
- getContinuedTime(continuedHouse, continuedMinute) {
- let self = this;
- self.continuedTime = continuedHouse * 60 + continuedMinute * 1;
- console.log(self.continuedTime);
- },
- store(formName) {
- self = this;
- let total_stock = 0
- this.$refs.commAttrs.cData.forEach(item => { total_stock += parseInt(item.stock) })
- if(total_stock==0){
- total_stock = this.goods_stock;
- }
- if (total_stock < this.group_size) {
- return self.$message.error("拼团商品总库存必须大于成团人数");
- }
- $res = this.validate();
- if($res === false) return false;
- if(this.senior_setting){//高级设置开启了
- // 判断是否开启了参团限制
- if (this.is_restrict_rule == 1 && this.restrict_rule_num <= 0) {
- return self.$message.error("请输入参团数量");
- }
- if(this.purchase == 1 && this.limit_buy_num <= 0){//限购 并且 没有填写限购数量
- return self.$message.error("请正确填写限购数量");
- }
-
- if(this.isAll == 2 && this.checkedCities.length == 0){//指定用户 没有勾选用户
- return self.$message.error("请勾选指定团长等级");
- }
- if(this.isAll_C == 2 && this.checkedCities_C.length == 0){//指定用户 没有勾选用户
- return self.$message.error("请勾选指定团员等级");
- }
-
- if(this.is_virtual && this.virtual_group_type == 2 && this.gt_group_size <=0 ){//开启虚拟成团
- return self.$message.error("请正确填写虚拟成团的参团人数");
- }
- if (this.is_virtual && this.virtual_group_type == 2 && this.gt_group_size > this.group_size) {
- return self.$message.error("虚拟成团参团人数不能大于拼团人数");
- }
- }else{
- //没有开启高级设置 把高级设置里面的参数设置为默认?
- this.purchase = 2; //不限购
- this.isAll = 1; //全部用户
- this.isAll_C = 1; //全部用户
- this.is_virtual = 0;//是否虚拟成团
- this.virtual_group_type = 1;
- this.sendStatus = 0
- }
-
-
- let commander_level_limit;
- let user_level_limit;
- if(this.isAll == 1){
- user_level_limit = 'all';
- }else if(this.isAll == 2){
- user_level_limit = this.checkedCities.join(',')
- }
- if(this.isAll_C == 1){
- commander_level_limit = 'all';
- }else if(this.isAll_C == 2){
- commander_level_limit = this.checkedCities_C.join(',')
- }
- let group_buy_goods = {
- "title": self.title,
- "cate_id": self.cate_id,
- "start_at": self.start_at, //开始时间
- "end_at": self.end_at, //结束时间
- "effective_time": self.continuedTime, //有效时间分钟数
- "group_size": self.group_size, //成团人数
- "virtual_group_size": self.virtual_group_size, //虚拟成团人数
- "is_virtual": self.is_virtual, //是否虚拟成团
- "goods_id": self.groupGoodsId, //商品id
- "goods_stock": self.goods_stock, //拼团商品总库存
- "limit_buy_num":self.purchase == 2?0:self.limit_buy_num,//购买数量限制 0=不限制
- 'commander_level_limit': commander_level_limit, //团长等级限制 或者全部用户all
- 'user_level_limit': user_level_limit, //团员等级限制 或者全部用户all
- "restrict_rule_num": self.is_restrict_rule === 0 ? 0 : self.restrict_rule_num, // 限制参团次数 0 不限制 1限制;
- "virtual_group_type":self.virtual_group_type,//虚拟成团类型 1=全部 2=成团人数大于
- "gt_group_size":self.gt_group_size,//拼团人数大于N,则虚拟成团,
- "is_initiator_free":self.is_initiator_free,// 发起人免费开团
- "is_show_participant_nickname":self.is_show_participant_nickname,// 是否显示参团人员昵称
- "is_show_virtual_avatar":self.is_show_virtual_avatar,// 是否显示虚拟人数头像
- };
- switch (self.sendStatus) {
- case 1:
- group_buy_goods['give_score'] = self.give_score;
- break;
- case 2:
- group_buy_goods['give_balance'] = self.give_balance
- break;
- case 3:
- group_buy_goods['send_red_packet'] = self.send_red_packet
- break;
- }
- if (group_buy_goods.virtual_group_type == 3) {
- group_buy_goods.virtual_group_sub_type = self.virtual_group_sub_type // "参团结束开团" 出现的选项
- group_buy_goods.expired_auto_complete_min_num = self.expired_auto_complete_min_num // 当参团人数≥ x 人,拼团有效期结束后,自动成团
- }
- // 如果是单规格商品
- request({
- params: {
- r: this.store_url
- },
- method: 'post',
- data: {
- form: self.cForm,
- group_buy_goods: group_buy_goods
- }
- }).then(e => {
- self.btnLoading = false;
- self.goods_stock = 0;
- if (e.data.code === 0) {
- //保存成功
- self.$message.success(e.data.msg);
- navigateTo({
- r: this.referrer,
- })
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- validate(){
- let self = this;
- try {
- if (self.title === '') throw new Error('请输入拼团活动名称');
- //单规格拼团价赋值
- if (self.cForm.use_attr == 0) {
- if (!self.groupGoodsId) throw new Error('请选择拼团商品');
- self.cForm.attr[0].group_buy_price = self.cForm.group_buy_price;
- }
- if(self.cForm.group_buy_price <= 0){
- throw new Error('拼团价格不能为0');
- }
-
- self.cForm.attr.map(item => {
- if (item.price < 0 || item.price === '') throw new Error('规格价格不能为空');
- if (item.stock < 0 || item.stock === '') throw new Error('库存不能为空');
- if (!item.group_buy_price || item.group_buy_price <= 0 || item.group_buy_price === '') throw new Error('拼团价不能为0或者空');
- if ( parseFloat(item.group_buy_price) > parseFloat(item.price)) throw new Error('拼团价不能大于售价');/* self.moreAttrs && */
- })
- if (!self.groupGoodsId) throw new Error('请选择拼团商品');
- // if (!self.valueDay || !self.valueTime || (!self.continuedHouse && !self.continuedMinute) || !self.group_size) throw new Error('请设置拼团相关信息');
- if (!self.start_at || !self.end_at || (!self.continuedHouse && !self.continuedMinute) || !self.group_size) throw new Error('请设置拼团相关信息');
- if (parseInt(self.cForm.group_buy_price) > parseInt(self.cForm.price) && (!self.moreAttrs)) throw new Error('拼团价不能高于售价');
- // 获取拼团持续分钟数
- self.getContinuedTime(self.continuedHouse, self.continuedMinute);
- self.getGroupStartDate(self.valueDay, self.valueTime);
- let startTimeStr = new Date(self.groupStartDate).getTime(); //活动开始时间时间戳
- let endTimeStr = new Date(self.groupEndDate).getTime(); //活动开始时间时间戳
- // 获取当前时间戳
- let nowTime = new Date();
- let nowTimeStr = nowTime.getTime();
- if (self.cForm.use_attr == 0 && self.goods_stock == 0) throw new Error('总库存不能为0');
- if (startTimeStr < nowTimeStr) throw new Error('开团时间不能早于当前时间');
- if (self.continuedTime < 15) throw new Error('拼团有效时间不能低于15分钟');
- if (self.group_size < 2 || self.group_size > 100) throw new Error('拼团人数需为2-100人');
- if (self.cate_id == 0) throw new Error('请选择拼团分类');
- //if (self.is_virtual == 1 && self.virtual_group_size < 2) throw new Error('虚拟成团人数不能少于2人');
- return true;
- } catch (error) {
- self.$message.error(error.message);
- return false;
- }
- },
- // 设置获取到的拼团商品信息
- setGroupBuyGoodsData(groupBuyGoods) {
- let self = this;
- let timeArr = groupBuyGoods.start_at.trim().split(" ");
- self.valueDay = timeArr[0];
- self.valueTime = timeArr[1];
- // console.log(valueDay+'111'+valueTime);
- self.continuedHouse = parseInt(groupBuyGoods.vaild_time / 60);
- self.continuedMinute = groupBuyGoods.vaild_time % 60;
- self.group_size = groupBuyGoods.people;
- self.is_virtual = groupBuyGoods.is_virtual;
- self.virtual_group_size = groupBuyGoods.virtual_group_size;
- },
- // 获取详情数据
- getGoodsList(id, url = '') {
- let self = this;
- // 存一下商品的id
- self.groupGoodsId = id;
- self.cardLoading = true;
- request({
- params: {
- r: url ? url : this.get_goods_detail_url,
- id: id,
- },
- method: 'get',
- }).then(e => {
- self.cardLoading = false;
- if (e.data.code == 0) { //状态码判断是否请求成功
- let detail = e.data.data.detail;
- detail.attr.length > 1 ? self.moreAttrs = true : self.moreAttrs = false; //是否选中多规格商品
- console.log('self.moreAttrs:'+self.moreAttrs);
- if (self.formGoodsList.length > 0) {
- this.goods_warehouse = {};
- }
- // 存一下商品的列表显示信息
- let formGoods = {};
- formGoods['goods_name'] = detail.goods_name;
- formGoods['cover_pic'] = detail.cover_pic;
- let formGoodsArr = [];
- formGoodsArr.push(formGoods);
- self.formGoodsList = formGoodsArr;
- if (e.data.data.group_buy_goods) {
- let groupBuyGoods = e.data.data.group_buy_goods;
- self.setGroupBuyGoodsData(groupBuyGoods);
- }
- if (detail['use_attr'] === 0) { //单规格
- detail['attr_groups'] = [];
- }
- 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);
- }
- }
- if (detail.attr.length > 1) {
- detail.attr.forEach(function(item, index) {
- item.stock = 0;
- });
- }
- self.ruleForm = Object.assign(self.ruleForm, detail);
- // 初始化一下规格
- self.attrGroups = e.data.data.detail.attr_groups;
- self.ruleForm.group_buy_price = detail.attr[0].group_buy_price;
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- self.cardLoading = false;
- console.log(e);
- });
- },
- handleChange(value) {
- this.cate_id = value;
- },
- // 选择商品(清空弹窗已有商品)
- selectGoodsWarehouse(goods_warehouse) {
- if(goods_warehouse.goods_stock <= 0){
- this.$message.error('该商品的库存为0,请重新选择商品');
- return
- }
- this.ruleForm.select_attr_groups = [];
- this.getGoodsList(goods_warehouse.id, 'group-buy/default/goods-detail')
- },
- },
- });
- </script>
|